id
stringlengths
40
40
text
stringlengths
9
86.7k
metadata
stringlengths
3k
16.2k
source
stringclasses
1 value
added
stringdate
2024-11-21 00:00:00
2024-12-12 00:00:00
created
stringdate
2024-11-21 00:00:00
2024-12-12 00:00:00
f1b5d0017eac6dea8c15ae424360425e36fa5aec
CSE 131 – Compiler Construction Fall 2015 Project #2 -- Code Generation Due Date: Friday, December 4th, 2015 @ 11:59pm IMPORTANT: You are responsible for having read and understood all items in this document. Contents Introduction ................................................................................................................................. 4 Foreword ................................................................................................................................. 4 Partners .................................................................................................................................. 4 Posting of Solutions .................................................................................................................. 4 Disclaimer ................................................................................................................................. 4 Beginning Your Project ............................................................................................................ 5 Background ............................................................................................................................... 5 Makefile Changes for Target Language ................................................................................... 5 Running the Project .................................................................................................................. 6 Turning in your Project ............................................................................................................. 6 Notes/Hints/Etc. ....................................................................................................................... 6 Summary table of global, static, extern variables/constatnts ....................................................... 7 What we are NOT testing or using in test cases (WNBT) .......................................................... 8 The Assignment ....................................................................................................................... 9 Phase I (~1.5 weeks) .................................................................................................................. 9 I.1 Declaration, initialization, assignment for literals, constants, and variables....................... 9 I.2 Output with cout .................................................................................................................. 9 I.3 Constant folding and sizeof .............................................................................................. 10 I.4 Integer arithmetic expressions .......................................................................................... 10 I.5 Basic if statements with integers in conditional expression ............................................. 10 I.6 Basic functions (no parameters) ....................................................................................... 10 I.7 Basic return statements ................................................................................................... 10 I.8 Exit statements .................................................................................................................. 10 Phase II (~1.5 weeks) ............................................................................................................... 11 II.1 Float arithmetic expressions ............................................................................................ 11 II.2 Basic if statements with floats in conditional expression .............................................. 11 II.3 Bool expressions ............................................................................................................. 11 II.4 Input with cin .................................................................................................................... 11 II.5 Mixed expressions .......................................................................................................... 11 II.6 Assignment expressions .................................................................................................. 12 II.7 If statements with more complex conditional expressions, plus else blocks ................. 12 II.8 While loops and break/continue statements................................. 12 II.9 Functions with parameters (including overloading)........................ 12 II.10 One-dimensional arrays and array indexing ................................ 12 II.11 Foreach loops and break/continue statements............................ 12 II.12 Structs..................................................................................... 13 II.13 Arrays of structs ..................................................................... 13 Phase III (~2 weeks) ......................................................................... 14 III.1 Pointer declaration, initialization, and assignment.......................... 14 III.2 Address-of operator .................................................................... 14 III.3 Pointer expressions .................................................................... 14 III.4 New and delete statements.......................................................... 14 III.5 Support parameters of composite types ....................................... 14 III.6 Support more complex return statements .................................... 15 III.7 Internal static variable and constant declarations......................... 15 III.8 Struct destructors calls .............................................................. 15 III.9 Extern variable and function declarations...................................... 16 III.10 Type casts ................................................................................. 17 III.11 Run-time array bounds check ..................................................... 17 III.12 Run-time NULL pointer dereference check................................. 17 Extra Credit (total of 10%) .................................................................. 18 1) Handling structs passed-by-value and returned-by-value (2%)........... 18 2) Passing more than 6 arguments to functions (2%).......................... 18 3a) Detect/report double deletes in heap space (3%).......................... 20 3b) Detect/report memory leaks in heap space (3%).......................... 20 Useful SPARC References .................................................................. 21 Introduction Foreword This is a large and complex software project. It will take you many days to complete, so do not procrastinate and attempt to complete it the night before the due date. **IMPORTANT: There will be no extensions to the deadline and late submissions will absolutely not be accepted, regardless of things such as power failures, computer crashes, personal issues, etc.** It is your responsibility to start on this project early and turn-in your code often to ensure you do not miss the deadline. You can turn-in your code as many times as you want. Partners You are encouraged to work in teams of 2, although you may also work individually. While this is a large project, it certainly can be completed successfully by a single individual (and many of the best scores in the past years have been by individuals). **IMPORTANT: Keep in mind that if you do choose to work with a partner, you are both still responsible for the entire project, even if your partner decides to drop the class or for whatever reason no longer wants to work with you.** If you decide to work with a partner, it is advisable that you communicate with them at minimum every other day, so you both are kept up-to-date and can ensure progress is being made. I cannot count the number of times I’ve seen partners decide to divide the project up and assume the other is working diligently, only to find out a couple days before the deadline that their partner has done nothing and has just dropped the class. Don’t put yourself in that situation. Communicate frequently with your partner, merge your code often, and if possible sit together and code together in the same room (or even same terminal if you like pair programming). Additionally, many questions on the quizzes and exams will be based on the project implementation. It is in your best interest to understand your entire project code, even if half the code was written by your partner. Posting of Solutions **IMPORTANT: You must not post online or otherwise distribute to others your solution to this programming project.** This prohibition applies both during and after the quarter. This prohibition specifically covers posting any programming assignments to GitHub or similar sites except in a private repository. Students violating this policy will be subject to an academic integrity disciplinary hearing. Disclaimer This handout is not perfect; corrections may be made. Updates and major clarifications will be incorporated in this document and noted on Piazza as they are made. Check for updates regularly. Beginning Your Project Background In this assignment you will generate SPARC assembly code for a subset of the Reduced-C (RC) language that, when assembled and linked, results in an executable program. IMPORTANT: You should do all your compiling, linking, and testing on ieng9, which is a SUN SPARC architecture. You will be adding code to the actions in your compiler to emit SPARC assembly language. In particular, your compiler should, given an RC program as input, write the corresponding SPARC assembly code to a file named rc.s. At that point, the generated file rc.s can be fed to the C compiler (to run the assembler and to link with Standard C Library routines you use and the input.c and output.s files we placed in the class public directory for the implementation of the inputInt(), inputFloat(), and printFloat() functions) to generate an executable named a.out. We will run the a.out executable and check that it produces the expected output. We will also have test cases involving separate compilation (using the extern and static keywords). Some of these test cases should pass through the linker without any errors, and an executable a.out should be produced. However, some of these cases will intentionally contain unresolved extern references that should cause the compilation to fail at link-time. The project is divided into 3 phases. The phases give you an indication of (roughly) how long it should take for each part to be completed. The subdivisions within each phase do not reflect separately-graded units; they merely suggest an order in which the subparts of each phase can be implemented. Makefile Changes for Target Language Since the assembly code you emit/generate will be dependent on the conventions of the C compiler you are using, you must also add the following rule to the end of your Makefile: ``` CC=cc compile: $(CC) rc.s $(PUBLIC)/input.c $(PUBLIC)/output.s $(LINKOBJ) ``` where variable CC is bound to either the cc or gcc compiler on ieng9. If you choose to use gcc, be sure to also include the -mcpu=v8 option when defining CC to compile to the SPARC V8 architecture. The variable LINKOBJ should be left undefined in the Makefile. When invoking the make command, it can be set to hold the name of one or more object files that should be linked into the executable. Examples of invoking make this way are shown below. ``` make compile make compile LINKOBJ='test1a.o' make compile LINKOBJ='test2a.o test2b.o' ``` The first command will permit us (and you!) to assemble your compiler's generated assembly code to create an executable a.out file for testing. Commands like the second and third one will also generate an executable a.out if all external references are resolved, or generate the appropriate linker errors otherwise. To create object files for testing the inter-functionality of external references, typically you will write C code that uses extern and/or static and compile it using: ```bash gcc -c module.c ``` This will create a module.o object file that you can then pass to LINKOBJ as described above. ### Running the Project Once your compiler is correctly generating an rc.s file, the following steps will compile, assemble, and execute your program: ```bash make new [ builds your RC compiler ] ./RC someTestFile.rc [ generates the rc.s file in current directory ] make compile [ generates the a.out file in the current directory ] ./a.out [ executes the program ] ``` If you are using ‘cin’ inputs within your program, you will enter the values after running a.out. If you want to automate this, you can place the value(s) in a text file (one value per line) and redirect that file into a.out, like so: ```bash ./a.out < inputs.txt [ executes the program with values in inputs.txt ] ``` **IMPORTANT:** All testing/grading will be done on ieng9, so it is imperative that you validate your compiler works in that environment using the command line Makefile to build your project. Failure to do so will result in your project getting a score of 0. ### Turning in your Project Refer to the turn-in procedure document on the website for instructions on the turn-in procedure. **IMPORTANT:** Remove all debugging output (both from your RC compiler and your generated assembly file) before you turn-in your project. Failure to do so will result in a very poor score. Debugging comments written in the generated assembly source file are fine. **IMPORTANT:** All output should go to stdout including any run time error messages produced by your assembly code. **IMPORTANT:** Do a test turn-in about a week before the deadline. This way we can help resolve turn-in problems early and ensure a smooth turn-in process when the deadline approaches. Notes/Hints/Etc. - Only syntactically, semantically legal (according to the Project I spec) RC programs will be given to your compiler. This doesn't mean you can scrap all your code from the last project -- some of it will be needed in this project. - **The C compiler is your friend.** This cannot be overemphasized. A wealth of knowledge can be gained by simply seeing how the C compiler does things, and emulating it. In most cases, the assembly code generated by `cc` will be similar to what you want your compiler to produce. You may also look at `gcc`, but it is much less straightforward. However, you should only emulate one compiler, since the techniques you use have to be internally consistent. In deciding which to use, think about which one produces the simpler code (in your opinion). - To see how the C compiler generates assembly, write a C program (make it small!) and compile it with the `-S` option: ```c cc -S program.c ``` This produces `program.s`, which contains the generated assembly code. Also, some of the constructs in RC (e.g. global and static variables with run-time initialization values) are based on C++. In these instances, you may want to use `CC` or `g++` to see how the C++ compiler does this. - Outputting assembly language comments within the `rc.s` text file has been found to be very helpful in debugging. Assembly comments begin with an "!" character (similar to // comments in C/C++). - **IMPORTANT:** It is highly recommend to use unique characters when creating assembly labels to ensure no conflicts from the same identifier string being generated in the RC language. Keep in mind that the RC language identifiers will only contain letters (a-z), numbers (0-9), and underscores (_). SPARC assembly allows for labels to contain the same characters, plus the dot (.) and dollar sign ($) characters. When creating internal labels (for things like string .asciz values or targets for branches), it is advisable to create those labels with some combination of . and/or $ characters to ensure user-input RC code does not accidentally collide with your labels. For example, if you wanted to create a label called “str1:” or “x_init:”, we advise you to instead name the label “.str1:” or “.x.init$:”, since a user may possibly define a global variable named “str1” or “x_init” in RC which would then cause a conflict. - **IMPORTANT:** You should place global/static variables and named constants in either “.data” (initialized) or “.bss” (uninitialized) section. Do not use “.rodata” section for named constants (i.e. constants that are addressable). The only values that should be placed in “.rodata” are literals (i.e. things that are not addressable, such as float and string literals). This is to allow subverting/modifying named constants by taking the address-of and dereferencing, like so: ```c const int x = 99; function : void main() { *&x = 44; // Doing dereference results in a modifiable 1-value cout << x << endl; // Should print 44 } ``` Summary table of global, static, extern variables/constants The table below provides an overview of the differences between global, static, and extern variables and constants. Note that you should not allocate any memory or generate any labels for extern variables, as those will be imported from the external module(s) during linking. <table> <thead> <tr> <th>Allocate mem in .data/.bss</th> <th>Global Variables</th> <th>Global Constants</th> <th>Static Variables</th> <th>Static Constants</th> <th>Extern Variables</th> </tr> </thead> <tbody> <tr> <td>Emit .global directive</td> <td>✓</td> <td>✓</td> <td>✗</td> <td>✗</td> <td>✗</td> </tr> <tr> <td>Supported types</td> <td>• int</td> <td>• int</td> <td>• int</td> <td>• int</td> <td>• int</td> </tr> <tr> <td></td> <td>• float</td> <td>• float</td> <td>• float</td> <td>• float</td> <td>• float</td> </tr> <tr> <td></td> <td>• bool</td> <td>• bool</td> <td>• bool</td> <td>• bool</td> <td>• bool</td> </tr> <tr> <td></td> <td>• structs</td> <td>• structs</td> <td>• structs</td> <td>• structs</td> <td>• structs</td> </tr> <tr> <td></td> <td>• pointers to all above</td> <td>• pointers to all above</td> <td>• pointers to all above</td> <td>• pointers to all above</td> <td>• pointers to all above</td> </tr> <tr> <td>Arrays of the types above</td> <td>✓</td> <td>✗</td> <td>✓</td> <td>✗</td> <td>✓</td> </tr> <tr> <td>Initialization except for structs/arrays</td> <td>✓ (optional) compile-time or run-time init</td> <td>✓ (required) compile-time values only</td> <td>✓ (optional) compile-time or run-time init</td> <td>✓ (required) compile-time values only</td> <td>✗</td> </tr> </tbody> </table> What we are NOT testing or using in test cases (WNBT) - Constructs omitted/not tested in Project I. - String expressions (String literals are of course OK. i.e. "Hello World\n"). - Arrays of arrays. - Structs passed/returned by value (these are Extra Credit options). - Passing more than 6 arguments to a regular function or more than 5 arguments to a struct-member function or constructor (these are Extra Credit options). - Declaring a local struct variable or a local array of struct variable in a scope other than the top-level of the function. This restriction does not include pointers to structs, which can occur in any scope. - Ambiguous statements (e.g. y = ++x + x, where it is unclear if the second operand to + gets bound to the incremented value of x or not). - Overloaded extern functions. - RC test files without a main() function. - Calling the main() function recursively (other functions will be tested with recursive calls). - Any other construct not listed below (unless we forgot something really important). The Assignment Phase I (~1.5 weeks) Declaration, initialization, and assignment for literals, constants, and variables of all basic types, cout, constant folding, integer arithmetic expressions, basic if statements with integers, basic functions, basic return statements, and exits. I.1 Declaration, initialization, assignment for literals, constants, and variables - Global variables and constants of type int, float, and bool. - All uninitialized global variables should be initialized to zero/false. - Handle both initialization and assignment (using literals, constants, or variables). - Static variables and constants of type int, float, and bool. - All uninitialized static variables should be initialized to zero/false. - Handle both initialization and assignment (using literals, constants, or variables). - For this phase, just external (not inside a function) static variables/constants. - Local variables and constants of type int, float, and bool. - Local variables are not automatically initialized. - Handle both initialization and assignment (using literals, constants, or variables). - Global scope resolution operator. Note: this should already be working from Project I. - The auto keyword for constants and variables (including static constants/variables). Note: this should already be working from Project I. I.2 Output with cout - Output to screen with cout for: - int expressions (no newline is automatically appended on output). Use printf() with the "%d" format specifier. - float expressions (no newline is automatically appended on output). Use the printFloat() function provided in output.s ($PUBLIC/output.s). Note: Pass single precision floating point float values in register %f0. - bool expressions. Bools should be output as "true" or "false" (no newline is automatically appended on output). - String literals (no newline is automatically appended on output). Use printf() with the "%s" format specifier. Do not use puts() to output a string literal. - The symbol endl, which represents the newline character and can be used interchangeably with "\n". Each object in a cout chain should be outputted before subsequent objects in the chain are evaluated. For example, consider the following code which should print "33", not "39": ``` function : void main() { int x = 9; cout << x = 3 << x << endl; } ``` I.3 Constant folding and sizeof - Constant folding for arithmetic and logical expressions involving ints, floats, and bools (and no other types). This should already be working from Project I. ```cpp const int c1 = 210; const int c2 = sizeof(c1) + c1; cout << c1 + 210 << endl; // outputs 420 cout << c2 << endl; // outputs 214 const float r1 = 420.25; cout << r1 + 662.50 << "\n"; // outputs 1082.75 cout << sizeof(r1) << endl; // outputs 4 ``` - The `sizeof` construct. This should already be working from Project I. I.4 Integer arithmetic expressions - int arithmetic expressions containing `+`, `-`, and `UnarySign`. - See SPARC Instructions Summary on class website - int arithmetic expressions containing `*`, `/`, and `%` - int bit-wise expressions containing `&`, `|`, and `^` - int arithmetic expressions using pre/post increment and decrement (;++/--). I.5 Basic if statements with integers in conditional expression - if statements of the form: if (expression) { statements }. expression will be limited to the form x > y, where x and y are int expressions (we will extend these expressions in Phase II). For Phase I, the only bool operator you need to deal with is greater-than (>). I.6 Basic functions (no parameters) - Functions with no parameters (including support for recursion). - Functions with int, float, bool, and void return types. I.7 Basic return statements - `return expr;` for int, float, and bool expressions - `return;` for void functions. I.8 Exit statements - `exit(expr);` statements. Phase II (~1.5 weeks) Float arithmetic expressions, basic if statements with floats, bool expressions, cin (ints/floats), mixed expressions (int/float), assignment expressions, if statements with else, while loops, break/continue statements, functions with parameters (basic types), one-dimensional arrays and array indexing, foreach loops, structs, arrays of structs. II.1 Float arithmetic expressions - float arithmetic expressions containing +, - and UnarySign. - See SPARC Instructions Summary on class website - float arithmetic expressions containing * and /. - float arithmetic expressions using pre/post increment and decrement (++/--). II.2 Basic if statements with floats in conditional expression - if statements of the form: if (expression) { statements }. expression will be limited to the form \( x > y \), where \( x \) and \( y \) are float expressions (we will extend these expressions in the next bullet). II.3 Bool expressions - bool expressions containing >=, <=, >, <, ==, !=, &&, ||, and !. **IMPORTANT**: && and || are **short-circuiting** operators. In other words, in \((a \land b)\), if \(a\) evaluates to false, \(b\) is not evaluated/executed. Similarly, in \((a \lor b)\), if \(a\) evaluates to true, \(b\) is not evaluated/executed. II.4 Input with cin - cin with modifiable L-value ints and floats. - cin should use the inputInt() function for ints and the inputFloat() function for floats. Both functions are provided in input.c ($PUBLIC/input.c). - Note: The int return value from inputInt() is available to the caller in register %o0. - Note: The float return value from inputFloat() is available to the caller in register %f0. ```cpp cin >> intVar; cin >> floatVar; ``` II.5 Mixed expressions - Handle mixed int and float expressions for all of the above. ```cpp floatVar = intVar + floatVar * 420; ``` II.6 Assignment expressions - Handle assignment expressions. For example, ```cpp int i; int j; bool b1; function : void main() { if ( b1 = i > 0 ) { j = i = i – 1; } cout << (i = j = 9) << i << j << endl; } ``` II.7 If statements with more complex conditional expressions, plus else blocks - Extend condition expression to handle all valid bool expressions. - Handle if statements with (optional) else statements. II.8 While loops and break/continue statements - Handle while loops with all valid bool conditional expressions. - Handle break statements within while loops. - Handle continue statements within while loops. II.9 Functions with parameters (including overloading) - Functions with pass-by-value int, float, and bool parameters (including recursion). - Functions with pass-by-reference (e.g. &) int, float, and bool parameters (including recursion). - Support for valid overloaded function definitions and calls. II.10 One-dimensional arrays and array indexing - Arrays and array indexing with one dimension with run time layout in the style of C/C++ arrays. - No bounds checking is required on run-time array access for Phase II (will be done in Phase III). - Each element of a global or static array should be initialized to the appropriate value for its data type (e.g. ints and floats should be initialized to zero, and bools to false). - Local arrays should not be automatically initialized. II.11 Foreach loops and break/continue statements - Foreach loops with value iteration variables of type int, float, and bool. - Foreach loops with reference (e.g. &) iteration variables of type int, float, and bool. - Handle break statements within foreach loops. - Handle continue statements within foreach loops. II.12 Structs - Handle structs with fields of all valid types. - Fields of global and static structs should be initialized in a way appropriate to their types (see arrays, above). - Local struct fields should not be automatically initialized. - Support for valid overloaded struct-member function definitions and calls. - The appropriate struct constructor should be called to handle any custom initializations. This includes support for a default constructor (which does nothing) if none are explicitly defined, as well as possibly overloaded constructor definitions. (Don’t worry about destructor calls yet - we will handle those in Phase III). - Support entire struct assignment (copy all memory from one struct into another). - Support expressions with struct-member variables and struct-member function calls (you should pass the “this” address of the struct as a hidden parameter for any struct-member function calls). II.13 Arrays of structs - Follow same rules about initializing memory as arrays above. - The appropriate struct constructor should be called on each array element to handle any custom initializations. (Again, don’t worry about destructor calls yet – we will handle those in Phase III). - Extend foreach loops to handle both value and reference iteration variables of struct type. Phase III (~2 weeks) Pointer declaration/initialization/assignment, address-of operator, pointer expressions, new/delete statements, support parameters of composite types, support more complex return statements, internal static declarations, struct destructor calls, extern variable/function declarations, type casts, run-time array bounds check, run-time NULL pointer check. III.1 Pointer declaration, initialization, and assignment - Global, static, and local declarations. - Pointers to all valid types. - Extend arrays to support arrays of pointers. - Uninitialized global and static pointers should be initialized to NULL (0). - Local pointers should not be automatically initialized. III.2 Address-of operator - Address-of operator (&) on valid objects of all types. - Note that the address-of operator can be done on elements of an array (e.g. &myArray[3]), if the element type is not an array itself (which is always the case, since we are not testing arrays of arrays). - Handle pointer variable initialization and assignment using address-of expression. III.3 Pointer expressions - Pointer assignment and comparison using ==/!= (including nullptr). - Pointer dereference expressions (*, ->, and [] operators). - Pointer arithmetic expressions using pre/post increment and decrement (;++--). - Extend foreach loops to handle both value and reference iteration variables of pointer type. III.4 New and delete statements - new should return initialized memory. - delete should free the memory and set its argument to NULL. - new and delete can be used on pointers of any type. - For pointers to structs: - new should call the appropriate struct constructor after allocating/initializing memory. - delete should call the struct destructor (if defined) before freeing the memory. III.5 Support parameters of composite types - Pass-by-reference array argument to array parameters (pass-by-value array parameters WNBT). - Pass-by-reference struct parameters (pass-by-value struct parameters is extra credit). - Pass-by-value and pass-by-reference pointer parameters. III.6 Support more complex return statements - Return-by-value for pointer types. - Return-by-reference for int, float, bool, pointers, and structs (very similar to pass-by-reference). III.7 Internal static variable and constant declarations - Internal (i.e. within a function) static variable and constant declarations. - Support initialization (both constant and run-time values). Requires initialization guard on runtime value to ensure variable is only set the first time the function is called. - All uninitialized static variables should be initialized appropriately for their given type. ```c function : int foo(int w) { static int x = w; // Internal static (need conditional init) return x; // Should return the first value passed to w. } ``` ```c static bool* x; // External static (init to NULL) ``` III.8 Struct destructors calls - Calling destructors on non-heap structs when their scope ends. - An object’s destructor should be called only if one of the object’s constructors was executed at run time. - The destructor calls for multiple objects at the same scope level should occur in the reverse order of their constructor calls. - For global and static (both internal and external) struct variables, any destructor calls should occur when the program ends (due to reaching the end of main(), a return statement within main(), or a call to exit()). - For local struct variables (which will only be declared in the top-level scope of a function), any destructor calls should occur when the function’s scope is terminated (due to reaching the end of the function or a return statement in that function). We will not test having a recursive call on a function containing local struct variables. Note that calls to exit() do not invoke any destructor calls for local variables. - Below is an example program demonstrating of how destructors should be called: ```c struct def MS { int x; MS(int v) { this.x = v; cout << "ctor called on " << this.x << endl; } ~MS() { cout << "dtor called on " << this.x << endl; } }; ``` MS structA : (1); static MS structB : (2); function : void foo(int x) { MS structC : (3); static MS structD : (4); if ( x == 4 ) { return; } MS structE : (5); } function : void main() { MS structF : (6); foo(3); foo(4); } The above program should output: ctor called on 1 ctor called on 2 ctor called on 6 ctor called on 3 ctor called on 4 ctor called on 5 dtor called on 5 dtor called on 3 cctor called on 3 dtor called on 3 dtor called on 6 dtor called on 4 dtor called on 2 dtor called on 1 III.9 Extern variable and function declarations - We will compile and link your rc.s file together with one or more pre-compiled *.o object files in various ways, some of which should fail at link-time. - All combinations of non-constant variables or functions declared extern, static, or global are valid for testing and should be handled. - Extern variables will only be tested with type int, float, pointer to int/float (any level), and one-dimension arrays of these types. - Extern functions will only be tested with return types of void, int, and pointer to int/float (any level), as well as parameter types of int and pointer to int/float (any level). - Overloaded extern functions will not be tested. - Remember that a variable declared static is visible only to the module where it is defined (e.g. no .global directive should be output in your rc.s file). III.10 Type casts - Type casts for all valid types (as described in the Project I spec). - Includes the constant folding portion that should have been done in Project I. - Run-time conversion of non-constant values. III.11 Run-time array bounds check - Out-of-bounds accesses should cause the program to print the following message to stdout "Index value of %d is outside legal range [0, %d).\n" and exit (do an assembly function call to exit, passing 1 in %o0). NOTE: The notation '[' means up to and including, ']' means up to and NOT including. III.12 Run-time NULL pointer dereference check - Attempts to dereference (*, ->, or []) or delete a NULL pointer should cause the program to print the following message to stdout "Attempt to dereference NULL pointer.\n" and exit (do an assembly function call to exit, passing 1 in %o0). Extra Credit (total of 10%) The following extra credit features are available. Be advised that you should certainly make sure your project is working well before focusing on extra credit since the fundamental functional of your compiler will have a far greater impact on your score. These extra credit features are listed in order of increasing difficulty. Note: We reserve the right to add more extra credit options and adjust the percentage each extra credit option is worth so they total 10%. 1) Handling structs passed-by-value and returned-by-value (2%) - You handled struct parameters passed-by-reference and struct variables returned-by-reference in Phase III. - Extend this support to include struct parameters passed-by-value and struct variables returned-by-value. - Conceptually, you will need to create a temporary memory location in the caller to hold the entire struct, and then pass a pointer to that location for use in the callee. The callee will then use that address to read and/or write the struct data. - Recall that location %sp+64 (in the caller) / %fp+64 (in the callee) is already setup for passing a pointer to deal with return-by-value structs. 2) Passing more than 6 arguments to functions (2%) - You already handled passing up to 6 arguments to regular functions (or passing up to 5 arguments to struct-member functions/constructors, given that “this” was implicitly one of the arguments). - Extend support to handle any number of arguments. - This includes regular functions, struct-member functions, and struct constructors. - This includes any combinations of pass-by-value and pass-by-reference parameters of all valid types. - Also includes support for structs passed-by-value (described in Extra Credit 1 above). - The main thing you have to do is allocate stack space for the additional args and copy the actual arguments into those stack locations before the call -- all done via %sp. Then in the function that was called, access those additional params at the same offsets but via %fp. Then back in the caller after the function call return you have to deallocate the stack space you allocated for those additional args. This is essentially what you have to do in most CISC architectures for every arg passed. - **IMPORTANT:** always make sure pass the first 6 arguments through the %o0-%o5 registers. Otherwise, the SPARC calling convention is violated and calls to extern functions that are linked into your RC code can break. - An example of passing 8 arguments to a function named ‘foo’ is shown below. The first 6 args passed in regs %o0-%o5 as usual. Args 7 and 8 have to be passed on the stack. foo: ! Normal save sequence here ! args #1-6 are in %i0-%i5 st %i0, [%fp + 68] ! store arg #1 on stack st %i1, [%fp + 72] ! store arg #2 on stack st %i2, [%fp + 76] ! store arg #3 on stack ! ... ! arg #7 at %fp + 92 ! arg #7 already on stack ! arg #8 at %fp + 96 ! arg #8 already on stack ! Body of function ! Access formal params from memory locations %fp + 68 thru %fp + 96 ! Put return value —> %i0 ret ! %i7 + 8 —> %pc restore ! slide register window up 16 regs main: ! Normal save sequence here ! Move args 1-6 into %o0-%o5 per normal arg passing mov 1, %o0 mov 2, %o1 mov 3, %o2 ! ... add %sp, -(2*4) & -8, %sp ! allocate stack space for args 7 & 8 mov 7, %i0 ! value of arg #7 (7 in this example) st %i0, [%sp + 92] ! pass arg #7 on stack mov 8, %i0 ! value of arg #8 (8 in this example) st %i0, [%sp + 96] ! pass arg #8 on stack call foo, 8 ! %pc —> %o7 (addr of call instr) nop ! foo —> %pc (addr of target —> %pc) sub %sp, -(2*4) & -8, %sp ! dealloc stack space for args 7 & 8 ! Retrieve return value in %o0 ! Rest of main ... 3a) Detect/report double deletes in heap space (3%) - Detect when delete is called on a pointer whose heap memory space has already been deallocated earlier in the program (often termed a “double delete”). - A simple example of such a case is provided below: ```c int * x; int * y; function : int main() { new x; y = x; delete x; // Okay - will set x to NULL when complete delete y; // This will be a dangling reference, and cause double delete return 0; } ``` - When this error is detected, the program should print the following message to `stdout` ``` "Double delete detected. Memory region has already been released in heap space.\n" ``` and exit (do an assembly function call to exit, passing 1 in %o0). 3b) Detect/report memory leaks in heap space (3%) - Detect when dynamically allocated heap space is created via a `new` but never released because no corresponding `delete`. - Once the program terminates (due to reaching the end of `main()`, a return statement within `main()`, or a call to `exit()`), check and report any dynamically created memory that has not been deallocated. - A simple example of such a case is provided below: ```c int * x; function : int main() { new x; return 0; // Would report a memory leak here delete x; } ``` - When this error is detected, the program should print the following message to `stdout` ``` "%d memory leak(s) detected in heap space.\n" ``` where %d is the number of leaks found. (NOTE: no need to call exit, since the program will already be terminating.) Useful SPARC References - SPARC Instructions Summary: http://cseweb.ucsd.edu/~gbournou/CSE131/GenAndFPNotes.html - Global and Static Variables: Initializations and Guards: http://cseweb.ucsd.edu/~gbournou/CSE131/GlobalAndStaticVars.pdf - Reference vs. Value Parameters: http://cseweb.ucsd.edu/~gbournou/CSE131/RefVsValue.pdf - University of New Mexico SPARC Lab Manual: http://www.cs.unm.edu/~maccabe/classes/341/labman/labman.html - Sun SPARC Assembly Reference Manual: http://docs.sun.com/app/docs/doc/806-3774 (ignore V9 Instruction Set)
{"Source-Url": "http://cseweb.ucsd.edu:80/~gbournou/CSE131/Project2.pdf", "len_cl100k_base": 8751, "olmocr-version": "0.1.50", "pdf-total-pages": 21, "total-fallback-pages": 0, "total-input-tokens": 53555, "total-output-tokens": 9725, "length": "2e13", "weborganizer": {"__label__adult": 0.0005731582641601562, "__label__art_design": 0.0004897117614746094, "__label__crime_law": 0.0003752708435058594, "__label__education_jobs": 0.0067138671875, "__label__entertainment": 0.0001042485237121582, "__label__fashion_beauty": 0.00027441978454589844, "__label__finance_business": 0.00024819374084472656, "__label__food_dining": 0.00058746337890625, "__label__games": 0.0012083053588867188, "__label__hardware": 0.0012311935424804688, "__label__health": 0.000408172607421875, "__label__history": 0.00027179718017578125, "__label__home_hobbies": 0.0002319812774658203, "__label__industrial": 0.0006031990051269531, "__label__literature": 0.0004000663757324219, "__label__politics": 0.0003085136413574219, "__label__religion": 0.0006871223449707031, "__label__science_tech": 0.0033721923828125, "__label__social_life": 0.0002428293228149414, "__label__software": 0.0032367706298828125, "__label__software_dev": 0.97705078125, "__label__sports_fitness": 0.0004582405090332031, "__label__transportation": 0.0007228851318359375, "__label__travel": 0.0002892017364501953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 40942, 0.01988]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 40942, 0.19595]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 40942, 0.78754]], "google_gemma-3-12b-it_contains_pii": [[0, 120, false], [120, 4334, null], [4334, 6575, null], [6575, 9140, null], [9140, 11609, null], [11609, 13891, null], [13891, 16900, null], [16900, 19672, null], [19672, 22050, null], [22050, 23590, null], [23590, 25457, null], [25457, 27208, null], [27208, 28516, null], [28516, 30596, null], [30596, 32703, null], [32703, 34107, null], [34107, 34956, null], [34956, 37638, null], [37638, 38836, null], [38836, 40391, null], [40391, 40942, null]], "google_gemma-3-12b-it_is_public_document": [[0, 120, true], [120, 4334, null], [4334, 6575, null], [6575, 9140, null], [9140, 11609, null], [11609, 13891, null], [13891, 16900, null], [16900, 19672, null], [19672, 22050, null], [22050, 23590, null], [23590, 25457, null], [25457, 27208, null], [27208, 28516, null], [28516, 30596, null], [30596, 32703, null], [32703, 34107, null], [34107, 34956, null], [34956, 37638, null], [37638, 38836, null], [38836, 40391, null], [40391, 40942, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, true], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 40942, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 40942, null]], "pdf_page_numbers": [[0, 120, 1], [120, 4334, 2], [4334, 6575, 3], [6575, 9140, 4], [9140, 11609, 5], [11609, 13891, 6], [13891, 16900, 7], [16900, 19672, 8], [19672, 22050, 9], [22050, 23590, 10], [23590, 25457, 11], [25457, 27208, 12], [27208, 28516, 13], [28516, 30596, 14], [30596, 32703, 15], [32703, 34107, 16], [34107, 34956, 17], [34956, 37638, 18], [37638, 38836, 19], [38836, 40391, 20], [40391, 40942, 21]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 40942, 0.02016]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
f6aaf82f37d660e286e3027fe5fd849fc4c1c197
Important Information SOME TIBCO SOFTWARE EMBEDS OR BUNDLES OTHER TIBCO SOFTWARE. USE OF SUCH EMBEDDED OR BUNDLED TIBCO SOFTWARE IS SOLELY TO ENABLE THE FUNCTIONALITY (OR PROVIDE LIMITED ADD-ON FUNCTIONALITY) OF THE LICENSED TIBCO SOFTWARE. THE EMBEDDED OR BUNDLED SOFTWARE IS NOT LICENSED TO BE USED OR ACCESSED BY ANY OTHER TIBCO SOFTWARE OR FOR ANY OTHER PURPOSE. USE OF TIBCO SOFTWARE AND THIS DOCUMENT IS SUBJECT TO THE TERMS AND CONDITIONS OF A LICENSE AGREEMENT FOUND IN EITHER A SEPARATELY EXECUTED SOFTWARE LICENSE AGREEMENT, OR, IF THERE IS NO SUCH SEPARATE AGREEMENT, THE CLICKWRAP END USER LICENSE AGREEMENT WHICH IS DISPLAYED DURING DOWNLOAD OR INSTALLATION OF THE SOFTWARE (AND WHICH IS DUPLICATED IN THE LICENSE FILE) OR IF THERE IS NO SUCH SOFTWARE LICENSE AGREEMENT OR CLICKWRAP END USER LICENSE AGREEMENT, THE LICENSE(S) LOCATED IN THE “LICENSE” FILE(S) OF THE SOFTWARE. USE OF THIS DOCUMENT IS SUBJECT TO THOSE TERMS AND CONDITIONS, AND YOUR USE HEREOF SHALL CONSTITUTE ACCEPTANCE OF AND AN AGREEMENT TO BE BOUND BY THE SAME. ANY SOFTWARE ITEM IDENTIFIED AS THIRD PARTY LIBRARY IS AVAILABLE UNDER SEPARATE SOFTWARE LICENSE TERMS AND IS NOT PART OF A TIBCO PRODUCT. AS SUCH, THESE SOFTWARE ITEMS ARE NOT COVERED BY THE TERMS OF YOUR AGREEMENT WITH TIBCO, INCLUDING ANY TERMS CONCERNING SUPPORT, MAINTENANCE, WARRANTIES, AND INDEMNITIES. DOWNLOAD AND USE THESE ITEMS IS SOLELY AT YOUR OWN DISCRETION AND SUBJECT TO THE LICENSE TERMS APPLICABLE TO THEM. BY PROCEEDING TO DOWNLOAD, INSTALL OR USE ANY OF THESE ITEMS, YOU ACKNOWLEDGE THE FOREGOING DISTINCTIONS BETWEEN THESE ITEMS AND TIBCO PRODUCTS. This document contains confidential information that is subject to U.S. and international copyright laws and treaties. No part of this document may be reproduced in any form without the written authorization of TIBCO Software Inc. TIBCO® Scribe Insight and TIBCO® Scribe Insight Adapter are either registered trademarks or trademarks of TIBCO Software Inc. in the United States and/or other countries. All other product and company names and marks mentioned in this document are the property of their respective owners and are mentioned for identification purposes only. THIS SOFTWARE MAY BE AVAILABLE ON MULTIPLE OPERATING SYSTEMS. HOWEVER, NOT ALL OPERATING SYSTEM PLATFORMS FOR A SPECIFIC SOFTWARE VERSION ARE RELEASED AT THE SAME TIME. SEE THE README FILE FOR THE AVAILABILITY OF THIS SOFTWARE VERSION ON A SPECIFIC OPERATING SYSTEM PLATFORM. THIS DOCUMENT IS PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THIS DOCUMENT COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THIS DOCUMENT. TIBCO SOFTWARE INC. MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS DOCUMENT AT ANY TIME. THE CONTENTS OF THIS DOCUMENT MAY BE MODIFIED AND/OR QUALIFIED, DIRECTLY OR INDIRECTLY, BY OTHER DOCUMENTATION WHICH ACCOMPANIES THIS SOFTWARE, INCLUDING BUT NOT LIMITED TO ANY RELEASE NOTES AND "READ ME" FILES. Copyright © 1996 - 2020 TIBCO Software Inc. All rights reserved. TIBCO Software Inc. Confidential Information ## Contents - Related Documentation........................................................................................................... 1 - Product-Specific Documentation......................................................................................... 1 - Requirements............................................................................................................................. 2 - Supported Operating Systems............................................................................................. 2 - Microsoft Windows Components......................................................................................... 2 - Database............................................................................................................................... 3 - Installing TIBCO Scribe Insight 7.9.4...................................................................................... 3 - Insight New Features................................................................................................................ 4 - Insight Changes In Functionality............................................................................................. 4 - Insight Deprecated And Removed Features........................................................................... 4 - Insight Migration And Compatibility...................................................................................... 4 - Updating Insight With Adapter Installations....................................................................... 6 - DTS Connection Used As Source And Target........................................................................ 6 - Insight Closed Issues............................................................................................................... 7 - Insight Known Issues............................................................................................................... 8 - Execution Log Viewer Launching From The Console............................................................ 10 - Formula Editor Field Reference Tool Tips........................................................................... 10 - Adapter For Microsoft Dynamics AX Version 1.2.3................................................................. 11 - Dynamics AX Adapter Requirements.................................................................................. 11 - Dynamics AX Adapter New Features.................................................................................. 11 - Dynamics AX Adapter Changes in Functionality................................................................. 11 - Dynamics AX Adapter Deprecated And Removed Features.............................................. 11 - Dynamics AX Adapter Migration And Compatibility......................................................... 11 - Adapter For Dynamics AX Closed Issues............................................................................ 12 - Adapter For Dynamics AX Known Issues............................................................................ 12 - Adapter For Microsoft Dynamics 365 and CRM Version 5.6.1............................................... 14 - Dynamics 365 and CRM Requirements............................................................................... 14 - Dynamics 365 and CRM Adapter New Features................................................................. 14 - Dynamics 365 and CRM Adapter Changes in Functionality.............................................. 14 - Dynamics 365 and CRM Adapter Deprecated And Removed Features............................. 14 - Dynamics 365 and CRM Adapter Migration And Compatibility......................................... 15 - Dynamics 365 and CRM Adapter Closed Issues................................................................. 15 - Dynamics 365 and CRM Adapter Known Issues................................................................. 16 - Adapter For Microsoft Dynamics GP Version 4.4.4................................................................. 21 - Dynamics GP Adapter Requirements.................................................................................. 21 - Dynamics GP Adapter New Features.................................................................................. 21 Preface TIBCO is proud to announce the latest release of TIBCO Scribe Insight software version 7.9.4. Related Documentation This section lists documentation resources you may find useful. Product-Specific Documentation The following documents form the TIBCO Scribe Insight documentation set: - **TIBCO Scribe Insight Release Notes** Read the release notes for a list of new and changed features. This document also contains lists of known issues and closed issues for this release. - **TIBCO Scribe Insight Installation Guide** Read this manual for instructions on site preparation and installation. - **TIBCO Scribe Insight Online Help Library** Read this documentation to gain an understanding of the product that you can apply to the various tasks you may undertake. See TIBCO Scribe Insight Help Library. Check the TIBCO Product Support web site at https://support.tibco.com for product information that was not available at release time. Entry to this site requires a username and password. If you do not have a username, you can request for one. You must have a valid maintenance or support contract to use this site. Topics - Requirements, page 2 - Insight New Features, page 4 - Insight Changes In Functionality, page 4 - Insight Deprecated And Removed Features, page 4 - Insight Migration And Compatibility, page 4 - Insight Closed Issues, page 7 - Insight Known Issues, page 8 - Adapter For Microsoft Dynamics AX Version 1.2.3, page 11 - Adapter For Microsoft Dynamics 365 and CRM Version 5.6.1, page 14 - Adapter For Microsoft Dynamics GP Version 4.4.4, page 21 - Adapter For Microsoft Dynamics NAV Version 3.2.1, page 25 - Adapter For Salesforce Version 2.8.3, page 29 - Adapter For SalesLogix Version 7.9.4, page 31 - Adapter For Web Services Version 1.5.6, page 34 Requirements Supported Operating Systems - Windows 10 (x64) - Windows Server 2016 Data Center and Standard Editions (x64) - Windows Server 2012 R2 Data Center and Standard Editions (x64) - Windows Server 2012 Data Center and Standard Editions (x64) Microsoft Windows Components - Microsoft .NET Framework 4.0 or later - On Windows 2012, also install Microsoft .NET Framework 3.5. - If you are connecting to a system that requires a TLS 1.2 connection, you must install Microsoft .NET Framework 4.5.2 or later. Some Windows Operating Systems do not support TLS 1.1 or 1.2. See this Microsoft Blog post for additional information: Support For SSL/TLS Protocols On Windows. - If you are installing TIBCO Scribe Insight on a system with TLS 1.2 enabled, you must also have TLS 1.0 enabled during the installation. After the installation is complete, you can disable TLS 1.0. - If you disable TLS 1.0 and only TLS 1.2 is enabled: - You must update the Scribe Internal Database to use the driver for Microsoft® ODBC Driver 13 for SQL Server® - Windows + Linux or later. Refer to the TIBCO Scribe Insight Installation Guide Appendix A: TIBCO Scribe Insight With TLS 1.2 Only Enabled for more information. - All drivers for connections must support TLS 1.2. - IIS 7 with IIS 6 Management Compatibility Mode may be required, depending on the Scribe server Operating System version and installed components - Microsoft Message Queuing Service (MSMQ) Database - Microsoft SQL Server 2017 Enterprise, Standard, and Express - Microsoft SQL Server 2016: Enterprise, Standard, and Express - Microsoft SQL Server 2014: Enterprise, Standard, and Express - Microsoft SQL Server 2012: Enterprise, Standard, and Express For Scribe products, the SCRIBEINTERNAL database is supported only on Latin_General collation orders (either case-sensitive or case-insensitive). SSL must be enabled on the Insight server where the database is installed for successful communication between Insight and the Scribe Internal Database. If only TLS 1.2 is enabled, then SSL is not required on the Insight server. Refer to the TIBCO Scribe Insight Installation Guide Appendix A: TIBCO Scribe Insight With TLS 1.2 Only Enabled for more information. Installing TIBCO Scribe Insight 7.9.4 Before installing Insight 7.9.4 with any supported edition of Windows Server 2012, you must turn on the Microsoft .NET3.5 and .NET4.5 features. You must be logged into a user account with local administrator privileges to install Insight. - Verify that you have your Insight Serial Number to register your software. Find the Serial Number in the original sign-up email from Scribe Software, or in TIBCO Scribe Workbench, select Help > About Scribe Insight. Contact your Sales representative if you have questions. - If you install Insight with any edition of Microsoft SQL Server 2012, you must edit the properties of the Scribe services to log on as a principal with proper rights, as described in the Scribe Insight Installation Guide. - You may need to restart the computer as part of the installation process. Plan accordingly. - In a new installation of 7.9.4, if you open a DTS from a pre-7.9.0 version, you are prompted to cascade changes and to save a backup. - You must be logged into a user account with local administrator privileges on the computer where you plan to install Insight and any Adapters. Insight New Features There are no new features in this release of TIBCO Scribe Insight. This release of TIBCO Scribe Insight addresses some Known Issues and updates the product branding from Scribe Insight to TIBCO Scribe Insight. Insight Changes In Functionality There are no changes in functionality for TIBCO Scribe Insight. Insight Deprecated And Removed Features TIBCO Scribe Insight no longer supports 32 bit operating systems nor does it support operating systems lower than Windows 12 Server. TIBCO Scribe Insight Adapters can no longer be downloaded individually from the downloads site. When a new Adapter is released, the entire TIBCO Scribe Insight product is released with all Adapters included. Insight Migration And Compatibility To migrate from a previous release of TIBCO Scribe Insight, refer to the TIBCO Scribe Insight Installation Guide. Before you upgrade to Insight 7.9.4: - Verify that you have your Insight Serial Number. To find the Serial Number, in TIBCO Scribe Workbench, select Help> About Scribe Insight. - Run ScribeMaintenance.sql to remove as many historical execution records as you can. Optional. • If your Scribe Internal database has a large number of historical records, the upgrade script may not be able to apply new indexes to the database and an index error may occur. If you receive an index error during the upgrade, create the indexes in the SQL Server Management Studio by running the appropriate ScribeInternal_Upgrade_xxx_to_xxx.sql script against the Scribe Internal database. These scripts are installed in the Program Files (x86)\Scribe directory. • Before you upgrade Insight, uninstall any of the following adapters that you have installed, then re-install the adapters after you complete the upgrade to TIBCO Scribe Insight 7.9.4: — Dynamics AX — Dynamics CRM — Dynamics GP — Dynamics NAV — Web Services When you upgrade to TIBCO Scribe Insight 7.9.4: • If you upgrade Insight with any edition of Microsoft SQL Server 2012, you must edit the properties of the Scribe services to log on as a principal with proper rights, as described in the TIBCO Scribe Insight Installation Guide. • Insight 7.9.4 and related adapters include most previously released hotfixes. If any Insight or Adapter hotfixes were applied before you upgraded to Insight 7.9.4, do not re-apply those hotfixes after upgrading. Hotfixes released prior to Insight 7.9.0 are not compatible with this release. To verify that hotfixes you have installed are included in this release, see the defects listed in this document and in the Adapter release notes. Certain hotfixes have been intentionally excluded from Insight 7.9.4. If your hotfix is not included in this release, contact Support. • When you upgrade a previous version of Insight to version 7.9.4, you may be prompted to save a backup, depending on how you responded to this prompt in previous releases. **Updating Insight With Adapter Installations** If any of the Adapters listed below is installed, when you install Insight 7.9.4, you must: 1. Uninstall the following adapters: - Dynamics AX - Dynamics CRM - Dynamics GP - Dynamics NAV - Web Services 2. Install Insight 7.9.4. 3. Reinstall the uninstalled adapters. **DTS Connection Used As Source And Target** A DTS connection used as both the source and a target cannot be changed in the target window. To change the connections when this scenario exists, open TIBCO Scribe Workbench and do the following: 1. Change the source connection. 2. Save the DTS. 3. Change the target connection. Failing to perform step 2 may cause TIBCO Scribe Workbench to shutdown. This shutdown does not damage your DTS. To continue, reopen your DTS and follow the steps above. Insight Closed Issues The following are closed issues in TIBCO Scribe Insight. <table> <thead> <tr> <th>Key/Case</th> <th>Summary</th> </tr> </thead> <tbody> <tr> <td>62336</td> <td>D62573: In some environments, where different languages or collations were used, using a query publisher with the <strong>publish only if changed</strong> option enabled, sometimes caused out of sort order errors because the data returned by the query was not sorted correctly.</td> </tr> <tr> <td>65987</td> <td>D69055: TIBCO Scribe Console could not connect to the Scribe Internal database when TLS 1.0 was disabled.</td> </tr> <tr> <td></td> <td>Note: With TIBCO Scribe Insight version 7.9.4, you must have TLS 1.0 enabled during the installation and Scribe Internal database configuration. After the installation, you can disable TLS 1.0, however, you must modify the ODBC drivers used by TIBCO Scribe Insight to connect to the Scribe Internal database. See Appendix A of the version 7.9.4 TIBCO Scribe Insight Installation Guide for step-by-step instructions.</td> </tr> </tbody> </table> | 66663, 66080, 66417, 66232 | D70421: When upgrading Insight from 7.9.x to 7.9.3 and using the XML Adapter with the ScribeIn queue on the target, an error similar to the following was generated: "20 - ADODB.Stream #3001 Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another". | # Insight Known Issues The following are known issues in TIBCO Scribe Insight. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | -- | **Summary**: D9225: When you create a new connection in the Target Steps dialog box, the Change button is disabled until you save the DTS, close the DTS, and reopen the DTS. **Workaround**: None. | | -- | **Summary**: D23975: Running a Timed integration process in the Default or user-defined message processor group when the **Run DTS one time only** option is selected causes a message to be created in the ScribeIn queue, but it is never processed. **Workaround**: None. | | 51253 | **Summary**: D7449: UPDATE, UPDATE/INSERT and SEEK steps SELECT ALL COLUMNS from CRM. **Workaround**: None. | | 54366 | **Summary**: D8166: DTS runs, empty table returns, and error 307: Source fields specified in the DTS were not found in the data source. **Workaround**: Insert a dummy row, then return a select command to exclude that row. | | 55310 | **Summary**: D8277: No error messages are displayed if duplicate messages are sent to the CRM PubIn queue, such as when many changes are made in Dynamics CRM rapidly. However, as intended, the duplicate messages are sent to the PubFailed queue. **Workaround**: None. | | 55732 | **Summary**: D8301: Fatal error 31 occurred: Execution terminated – target adapter user count invalid. **Workaround**: None. | <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | 66276 | **Summary:** D71250: The CLEAN function does not remove some non-printable characters, such as Hex(0b) or CHAR(11). **Workaround:** Use the SUBSTITUTE function first to substitute the non-printable characters with an empty string. Then, use the CLEAN function to remove the empty string, for example: CLEAN(SUBSTITUTE(S12, CHAR(11), "")) | | 69687 | **Summary:** D993: When three connections are configured in a DTS and there is a connection failure on the third connection that is neither source or target, the message that fails to process is not sent to the ScribeDeadMessage queue. **Workaround:** Select the third or extra connection as a target connection in Configure Steps > Data Objects. No steps are required for that connection, however, if a message fails to process it is retried and then sent to the ScribeDeadMessage queue. | | 69731 | **Summary:** D995: Setting up a query publisher with a custom source query that accesses a SQL database using an ODBC connection generates errors when selecting records based on a tinyint field. (SELECT id, tinyintfield ) **Workaround:** Cast the tinyint field as an int as follows: SELECT id, cast(tinyintfield as int) as tinyintfield | | 77271 | **Summary:** D10331: Execution log does not sort correctly by date when using the O IP ID filter on the Execution filter tab, running on Windows Server 2012, with locale set to the UK. **Workaround:** Use the Date Range filter instead. | | 80806 | **Summary:** D17567, 18999: Validating SQLQUERY functions that use a source value to compare against a field expecting a GUID or a datetime where the source value is NULL, generated errors and the function could not be saved. **Workaround:** Use an ISEMPTY check on the source value being passed to the function and if it is empty pass a dummy value so the function will validate. | | 80900 | **Summary:** D32086: When using SQL as a target, a target variable returns NULL with Update/Insert step if also attempting to return the primary key. **Workaround:** Use a Seek step after the Update/Insert step to lookup the value after it has been created in SQL. | **Execution Log Viewer Launching From The Console** In Workstation-only installs, the user name, DSN, and password for the Scribe Internal Database are not saved correctly under the current user in the registry. To launch the Execution Log viewer from the Console, do one of the following: - On the Workstation, create a new DSN to the Scribe Internal Database. When you set up the Console, use this Internal Database connection instead of the default connection created during install. - In the TIBCO Scribe Workbench, select Report > Report. - In the Insight install folder, double-click `ExecutionLogViewer.exe`. - In the registry, under `HKEY_CURRENT_USER > Software > Scribe > ScribeConsole > Sites > [GUID]`, enter the following information: - DSN — DSN to use, either the one used when installing Insight or another one. - PWD — Password for the current user. - UserName — User name for the current user. This enables you to launch the Execution Log Viewer from the Console. **Formula Editor Field Reference Tool Tips** If a field reference does not appear entirely on a single line, hovering your mouse over that field reference does not display the field name related to the field reference. For example, if the field reference S100 appears as S1 at the end of one line and the 00 appears at the beginning of the next line, no tool tip appears when you hover the mouse over the S1 or the 00. --- <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | 88866 | **Summary:** D33241: In some cases, when a field formula mapped to a string calculates to a 0, such as (0.99 * 3)-2.97, Insight returns a negative number. **Workaround:** Use the ROUND function. | Adapter For Microsoft Dynamics AX Version 1.2.3 Dynamics AX Adapter Requirements - TIBCO Scribe Insight 7.9.4 or later - Microsoft Dynamics AX 4 Sp2 or Microsoft Dynamics AX 5 only, for Microsoft Dynamics AX 2012 or higher, use the Adapter for Web Services - An AX Business Connector user license per concurrent Microsoft Dynamics AX connection. This license is not part of the User Counting ScribeTemplates.xpo that ships with the template. If you are upgrading from a previous version of the Microsoft Dynamics AX Adapter, see Dynamics AX Adapter Migration And Compatibility on page 11. You must be logged into a user account with local administrator privileges to install this adapter. Dynamics AX Adapter New Features Represents a technical alignment with TIBCO Scribe Insight Version 7.9.4. There are no other new features. Dynamics AX Adapter Changes in Functionality There are no changes in functionality for the Adapter for Microsoft Dynamics AX. Dynamics AX Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for Microsoft Dynamics AX. Dynamics AX Adapter Migration And Compatibility - If you are upgrading from a version of the Adapter that is lower than 1.2.2, the paths to the adapter queues have changed and you must update your system security settings to include the new path. Modify these settings in the TIBCO Scribe Console: expand Security and click the Message Queues tab, then move the new queues in the Shared Message Queues list. If messages do not appear in the correct queues, verify that you have updated the paths. - If you are upgrading from v1.0.1 or earlier releases of this Adapter, you must reconnect any AX connections to use the Windows service added in v1.1. Prior to v1.1, connections were handled through an IIS web service. - Some systems may require you to reboot after installing the ScribeAdapterForMicrosoftDynamicsAXServer.msi. **Adapter For Dynamics AX Closed Issues** The following are closed issues in this release of the Adapter for Microsoft Dynamics AX. <table> <thead> <tr> <th>Key/Case</th> <th>Summary</th> </tr> </thead> <tbody> <tr> <td>61826</td> <td>D58167: Dynamics AX Adapter was sending updates to the Scribe Queue when it should have only sent inserts.</td> </tr> </tbody> </table> **Adapter For Dynamics AX Known Issues** The following are known issues in the Adapter for Microsoft Dynamics AX. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> <tbody> <tr> <td>--</td> <td><strong>Summary:</strong> Scribe AXServiceHost service will not start. An error similar to the following displays: 'Windows could not start the Scribe AxServiceHost service on Local Computer', Error 1053: The service did not respond to the start or control request in a timely fashion'. <strong>Workaround:</strong> You may need to change the AxService login user to a local administrator or to the same user configured for the TIBCO Scribe Insight services. After the first time the service logs in, it can be changed to the default user.</td> </tr> <tr> <td>--</td> <td><strong>Summary:</strong> If your site is configured with the AOS on a separate server from the .NET Business Connector, you must specify a user name and password to connect. If you try to connect using the <strong>Use current user credentials</strong> option, a logon error occurs. <strong>Workaround:</strong> Uncheck the <strong>Use current user credentials</strong> option and provide user credentials.</td> </tr> <tr> <td>Key/Case</td> <td>Summary/Workaround</td> </tr> <tr> <td>----------</td> <td>--------------------</td> </tr> </tbody> </table> | 55311 | **Summary:** D37394: When Compatibility Mode is enabled for the Scribe domain in Dynamics AX, the Record Key for Item cannot be modified and an error similar to the following is generated. Error executing code: ScribeChangeLog(object), method logRenameKey has no return command. **Workaround:** Disable Compatibility Mode for the Scribe domain in Dynamics AX. Note that this also disables Dynamics AX logging. | | 74785 | **Summary:** D5700: In some cases, modifying the Dynamics AX endpoint URL in the Connections dialog generates an Invalid pointer error. **Workaround:** Modify the connection URL in the DTS XML file directly. | | 81024 | **Summary:** D16931: The Dynamics AX XPO causes unmapped fields to be replaced with default values. **Workaround:** Place the initValue call in an "If" statement, similar to the following example: ```java boolean initRecord(common _record, Struct _collection) { int i = 1; int fieldId; boolean isOk = true; DictField field; str arrayElementStr; int arrayElementInt; ; if (!_record.RecId) { _record.initValue(); } while(i <= _collection.fields() ) { fieldId = fieldName2Id(_record.TableId, _collection.fieldName(i)); // If "fieldId" is 0 then this is EDT with Array Elements if (fieldId == 0) ``` | Adapter For Microsoft Dynamics 365 and CRM Version 5.6.1 Dynamics 365 and CRM Requirements - TIBCO Scribe Insight 7.9.4 or later - Microsoft Dynamics CRM 2011, 2013, 2015, 2016, 2016 SP 1, Online, or Microsoft Dynamics 365 for Sales, 365 for Field Services, 365 for Project Services, or 365 for Customer Services - Microsoft .NET Framework 4.5.2 Full - A Microsoft Dynamics 365 or CRM account - Online, On-Premise, or Partner-Hosted - A licensed Microsoft Dynamics 365 or CRM user account with local administrator privileges You can continue to connect to Microsoft Dynamics CRM 3.0 and 4.0, however those versions are not supported. Dynamics 365 and CRM Adapter New Features Represents a technical alignment with TIBCO Scribe Insight Version 7.9.4. There are no other new features. Dynamics 365 and CRM Adapter Changes in Functionality There are no changes in functionality for the Adapter for Microsoft Dynamics 365 and CRM. Dynamics 365 and CRM Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for Microsoft Dynamics 365 and CRM. Dynamics 365 and CRM Adapter Migration And Compatibility - If you are upgrading from a version of the Dynamics 365 and CRM Adapter that is lower than version 5.6.0 and you want to use Multi-Select Option Sets for the online version of Dynamics 365, consider the following requirements after you upgrade: - Open and resave your publishers. If you do not open and resave your publishers, and you attempt to use Multi-Select Option Sets, an error similar to the following is generated: ``` Object reference not set to an instance of an object. at Scribe.DynamicsCrm5.plugin. ``` - To access Multi-Select Option Sets, you must delete your existing metadata for Microsoft Dynamics 365 in the Scribe Internal database and reconnect to upload the latest metadata. See Deleting Metadata in the TIBCO Scribe Insight Online Help. - If your site uses Insight Publishers for Dynamics 365 and CRM, reconnect and save each Publisher. Reconnecting with an Insight Publisher for Dynamics CRM 4.0 may cause an error. For information, see Error in refreshUserInfo(): IDispatch error #647 ADP Error info: was not expected. There is an error in XML document (2,2) in the Scribe Success Community. Dynamics 365 and CRM Adapter Closed Issues The following are closed issues in this release of the Adapter for Microsoft Dynamics 365 and CRM. <table> <thead> <tr> <th>Key/Case</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>67847</td> <td>D70999, 72267: If a custom entity was configured with a custom Multi-Select Picklist, loading the Picklist values failed with the following error: The operation was not performed due to invalid picklist value.</td> </tr> </tbody> </table> Dynamics 365 and CRM Adapter Known Issues The following are known issues in the Adapter for Microsoft Dynamics 365 and CRM. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | | **Summary:** On some systems when reconnecting a Publisher for Dynamics CRM 4.0 or creating schemas an error is generated and potentially followed by an "invalid procedure call or argument": Error in refreshUserInfo(): IDispatch error #647 ADP Error info: <ArrayOfCrmMetadata xmlns="" was not expected. There is an error in XML document (2,2)" **Workaround:** You can safely click through these errors and then retry the reconnect or creation of schemas. | | | **Summary:** D3338: Following error occurs when the Dynamics 365 and CRM system uses a language other than English and the English plug-in is not installed: Language not installed for Plugin. **Workaround:** After loading the Dynamics 365 and CRM system, install the English plug-in. | | | **Summary:** D7659: Error using the Annotation entity as a source with a Dynamics CRM 4.x connection. This issue occurs only when configuring the Annotation source entity as a Single Data Object. **Workaround:** Configure source as a Custom Query. This issue is not seen with Dynamics CRM 2011. See Annotation in the TIBCO Scribe Insight Online Help for more information. | | | **Summary:** When upgrading a plug-in Dynamics CRM Publisher from V 4.0 to V 2011, you must manually remove the 4.0 Publisher. **Workaround:** Make sure that the Scribe Plug-in publisher connecting to CRM 4.0 is removed. You cannot upgrade the publisher to 2011, you have to create a new one. Removing the CRM 4.0 publisher does not remove the plug-in from CRM. Log into CRM and go to Settings>Customizations>Customize the system. On the left side menu, find Plug-ins. Check for the Plug-ins that are registered. If there are two plug-ins for Scribe, delete the CRM (4.0) Plugin and leave the one that is CRM5 (2011). **Note:** Check the SDK Processing steps to see if there are any listed that do not have a name or EventHandler filled in. If so, then you need to delete those first before you can delete the Plug-in Assembly. | <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | 43340 | **Summary**: D5150/7068: Clearing the **Retrieve Entire Object** check box when using Dynamics CRM 4.4 Publisher publishes the old value instead of the new value. **Workaround**: None. | | 46590 | **Summary**: D6319/7067: Following error occurs with Dynamics CRM 2011 when using a parent join that produces multiple rows: **Index Out of Range**. **Workaround**: Perform the query using a primary/child query, if possible. | | 47719 | **Summary**: D6545: The **activityfieldname** and **activitytypecode** fields do not show in source. These are virtual fields and by nature cannot be queried. They are used to add or update an existing activity party, but do not exist on the actual entity. **Workaround**: Resolve this issue through a DTS: 1. Perform a seek on the activitypointer table with the activityId. 2. Store the activityTypecode in a target variable. 3. Create a fileLookup against the **participationtypemask** field in the activityparty table with a file using the following values. - 1 = "from" - 2 = "to" - 3 = "cc" - 4 = "bcc" - 5 = "requiredattendees" - 6 = "optionalattendees" - 7 = "organizer" - 8 = "regarding" - 9 = "owner" - 10 = "resources" - 11 = "customers" The "regarding" entries will fail on entities with no such field, such as email. | <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | 48891 | **Summary:** D6817/7066: Scheduled jobs on a SQL Server that migrate data from integration databases to Dynamics CRM databases crash TIBCO Scribe Workbench when the second job runs. When executing a DTS from the command line using a pre-7.9.0 version of the Workbench, the Dynamics CRM Adapter uses the connection properties last entered in the connection dialog by a user. These properties are written to the registry and used when the adapter connects in “silent mode”, such as when jobs are run from the command line. **Workaround:** Manually update the following registry keys between jobs: - HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Scribe\Microsoft Dynamics CRM 2011\LastOrganization\[database] where [database] changes for each job. - HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Scribe\Microsoft Dynamics CRM 2011\LastServer\[server URL]/[database] where [server URL] and [database] change for each job. | | 52414 | **Summary:** D34622: For versions of Dynamics CRM prior to 2016, the statecode and statuscode fields for an Invoice can not be updated in the first Update step of a DTS. **Workaround:** Update the invoice with all fields except statecode and statuscode. Move both the statecode and the statuscode to the second update step. | | 52656 | **Summary:** D38148: Using DBLOOKUP with unicode text does not successfully find unicode text values. It finds a non-unicode value if it exists. **Workaround:** None. | | 56644 | **Summary:** D39220: When creating a new Order in Dynamics CRM 2016, the header with totals is not inserted. **Workaround:** Add an Update step to the DTS to make a change to the Order and the totals are inserted. | <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | 59196, 60527, 60635 | **Summary:** D52326: The following error is generated when creating Dynamics CRM price lists if Dynamics CRM cannot validate that the price list has not been deactivated. Operation failed. Label: Update/Insert productpricelevel, Name: productpricelevelUpdateInsert, Message: -2147220989:entityName : System ArgumentNullException: Value cannot be null. Parameter name: entityName **Workaround:** Disable the following Microsoft plug-in: Microsoft.Dynamics.ProjectService.Plugins.PreProductPriceCreateReadOnlyCheck. | | 63530 | **Summary:** D58952: Doing an Upsert with an Alternate Key that is not all lower case generates the following error: Cannot find the XXXXX alternate key **Workaround:** When creating an Alternate Key, use only lower case letters in the key name. | | 65665 | **Summary:** D70404: In some cases upgrading to a version of the Dynamics 365 and CRM Adapter higher than version 5.5.4 causes out of memory errors when trying to create the metadata. **Workaround:** Use Dynamics 365 and CRM Adapter version 5.5.4 or lower. | | 67236 | **Summary:** D70781: When adding an image to a Dynamics 365 Contact, the following error is generated: Object reference not set to an instance of an object. **Workaround:** Use version 5.5.5 of the Adapter. | | 67258 | **Summary:** D69793: Unable to create a customer activityparty record in Dynamics 365 Version 9.0. **Workaround:** None. | | 73225 | **Summary:** D3691: When updating an address field with NULL, the address1_composite field is not recompiled. The address1_composite field is only recompiled when an actual value is mapped to one of the address fields. **Workaround:** None. | | 83758 | **Summary:** D28389: Datetime field created by the CRM Publisher when building the XML message is incorrect. **Workaround:** None. | <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> <tbody> <tr> <td>84014</td> <td><strong>Summary:</strong> D23127: DBLOOKUP() function generates an exception if no value is returned from Dynamics 365.&lt;br&gt;&lt;br&gt;<strong>Workaround:</strong> Use an ISEmpty function to check on the source value before the DBLOOKUP to avoid the error.</td> </tr> <tr> <td>85356</td> <td><strong>Summary:</strong> D30871: Deleting a custom field from Dynamics 365 causes DTS executions to fail in the Workbench with a 307 error even if the custom field is not being used in the DTS.&lt;br&gt;&lt;br&gt;<strong>Workaround:</strong> Open any DTS that connects to Dynamics 365 and save it to correct the associated metadata.</td> </tr> <tr> <td>85791</td> <td><strong>Summary:</strong> D31000: If the value of a field from a source datastore has trailing spaces, those spaces are not automatically trimmed when the value is stored in Dynamics 365.&lt;br&gt;&lt;br&gt;<strong>Workaround:</strong> Use a TRIM function to remove the extra spaces.</td> </tr> <tr> <td>87479</td> <td><strong>Summary:</strong> D34006: After upgrading from CRM 2013 to CRM 2016, updates to Invoices where invoice lines are deleted and then recreated sometimes perform very slowly and cause deadlocks.&lt;br&gt;&lt;br&gt;<strong>Workaround:</strong> None.</td> </tr> </tbody> </table> Adapter For Microsoft Dynamics GP Version 4.4.4 Dynamics GP Adapter Requirements - TIBCO Scribe Insight 7.9.4 or later - Microsoft Dynamics GP Versions: - 10.0 SP4 or later - 2010 (version 11) - 2013 (version 12) - 2013 R2 - 2015 - 2015 R2 - 2016 - 2018 - Microsoft Dynamics GP eConnect. You must have the appropriate version of eConnect for your version of Microsoft Dynamics GP. - You must be logged into a user account with local administrator privileges to install this adapter. Dynamics GP Adapter New Features Represents a technical alignment with TIBCO Scribe Insight Version 7.9.4. There are no other new features. Dynamics GP Adapter Changes in Functionality There are no changes in functionality for the Adapter for Microsoft Dynamics GP. Dynamics GP Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for Microsoft Dynamics GP. Dynamics GP Adapter Migration And Compatibility - Because Microsoft Dynamics GP does not support Unicode data, the Unicode features in TIBCO Scribe Insight v7.5.0 and later are not supported with this Adapter. - If your site uses Dynamics GP Publishers, you must reconnect and save each Publisher for Dynamics GP to recognize updates to the Publishers. - If you are upgrading from a previous version of the Adapter for Dynamics GP, you must execute a set of SQL scripts that contain the metadata shipped with this Adapter. If you do not run the appropriate SQL script after upgrading, your DTS executions will fail with a fatal error. The scripts you run depend on the Dynamics GP modules installed at your site: - **Dynamics GP (all previous versions)** — Run the GP Metadata script. - **Dynamics GP 10 SP4** — Installed in …\Scribe\Dynamics GP 10: - GP Metadata 10.0.sql – Always required. - GP AAMetadata 10.0.sql – Analytical Accounting module. - GP FAMetadata 10.0.sql – Fixed Asset module. - GP FSMetadata 10.0.sql – Field Service module. - GP PAMetadata 10.0.sql – Project Accounting module. - **Dynamics GP 2010 (version 11)** — Installed in …\Scribe\Dynamics GP 11: - GP Metadata 11.0.sql – Always required. - GP AAMetadata 11.0.sql – Analytical Accounting module. - GP FAMetadata 11.0.sql – Fixed Asset module. - GP FSMetadata 11.0.sql – Field Service module. - GP PAMetadata 11.0.sql – Project Accounting module. - **Dynamics GP 2013 (version 12)** — Installed in …\Scribe\Dynamics GP 12: - GP Metadata 12.0.sql – Always required. - GP AAMetadata 12.0.sql – Analytical Accounting module. - GP FAMetadata 12.0.sql – Fixed Asset module. - GP FSMetadata 12.0.sql – Field Service module. - GP PAMetadata 12.0.sql – Project Accounting module. — **Dynamics GP 2013 R2** – Installed in …\Scribe\Dynamics GP 12 R2: - GP Metadata 12 R2.sql – Always required. - GP AAMetadata 12 R2.sql – Analytical Accounting module. - GP FAMetadata 12 R2.sql – Fixed Asset module. - GP FSMetadata 12 R2.sql – Field Service module. - GP PAMetadata 12 R2.sql – Project Accounting module. — **Dynamics GP 2015** – Installed in …\Scribe\Dynamics GP 2015: - GP Metadata 2015.sql – Always required. - GP AAMetadata 2015.sql – Analytical Accounting module. - GP FSMetadata 2015.sql – Field Service module. - GP PAMetadata 2015.sql – Project Accounting module. — **Dynamics GP 2015 R2, 2016, 2018** – Installed in …\Scribe\Dynamics GP 2015: - GP Metadata 2015.sql – Always required. - GP AAMetadata 2015.sql – Analytical Accounting module. - GP FSMetadata 2015.sql – Field Service module. - GP PAMetadata 2015.sql – Project Accounting module. **Dynamics GP Adapter Closed Issues** There are no closed issues in this release of the Adapter for Microsoft Dynamics GP. # Dynamics GP Adapter Known Issues The following are known issues in the Adapter for Microsoft Dynamics GP. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workarounds</th> </tr> </thead> </table> | 56404 | **Summary:** D38480: In a multi-tenant environment, Subscription User counting sometimes generates the following error: Fatal Error: Execution terminated - target adapter user count invalid ([08004] SQL call failed. The server principal “ajg_sa” is not able to access the database “DYNAMICS” under the current security context.) **Workaround:** Contact Support for assistance with your licensing. | | 54960 | **Summary:** D38431 Shipping weight in Dynamics GP metadata is an integer value, however Insight displays it as an int. When trying to enter a shipping weight into Dynamics GP the decimal place is dropped and two additional places are added. For example, 2.5 is entered as 200 or 250 is entered as 25000. **Workaround:** Modify Shipping weight in the Dynamics GP metadata in the Scribe Internal Database to be numeric(8,2) instead of int. | | 74377 | **Summary:** D3045: Using GPNewCustomerID and GPNewVendorID functions can cause locking problems depending on the design of the DTS. **Workaround:** None. | | 83587 | **Summary:** D21712: Using GetNextNumber function to go from 99999 to 100000 fails with an error similar to the following: [23000] Success with info Cannot insert the value NULL into column 'PATSdoccnter', table 'INETM.dbo.PA41801'; column does not allow nulls. UPDATE fails. The statement has been terminated. **Workaround:** Modify the table manually to start with the number 100000. | Dynamics NAV Adapter Requirements - TIBCO Scribe Insight 7.9.4 or later - Microsoft Dynamics NAV Versions: - Dynamics NAV 2009 R2 - Dynamics NAV 2013 - Dynamics NAV 2013 R2 - Dynamics NAV 2015 - Dynamics NAV 2016 - Dynamics NAV 2017 - Dynamics NAV 2018 - This adapter is a NAS services application. For each NAS services application, Microsoft recommends creating a separate server instance: - Dynamics NAV 2009 R2 - Dynamics NAV 2013 - Dynamics NAV 2013 R2 - Dynamics NAV 2015 - Dynamics NAV 2016 - Dynamics NAV 2017 - Dynamics NAV 2018 - TIBCO recommends assigning a unique, version-specific Dynamics NAV user as the Login account of the Windows service associated with the Server Instance to ensure all requested changes are published and the audit logging features properly track records modified by TIBCO Scribe Insight. - Microsoft .NET Framework 4.5.0 or later You must install .NET on the Dynamics NAV Insight server and on the Dynamics NAV NAS server, if they are not the same. • Scribe NAV Granule - To use the Adapter Version 3.1.1 or higher, you must update your Microsoft Dynamics NAV client license with the Scribe NAV Granule ID 14094210 titled “Scribe NAV Adapter.” If you are a TIBCO Scribe Customer, contact your regional Microsoft AOC and request the change to your Microsoft Dynamics NAV client license. If you are a TIBCO Scribe partner, contact scribeproductmanagement@tibco.com for authorization to access the NAV Granule. In the email, include your Microsoft Partner ID number and country of registration. Product Management will respond within two business days. • microsoft.msxml.dll In some cases this file is not installed in the correct location. See the "Delegate not set for 'Command' operation." connecting to Microsoft Dynamics NAV 2016 article in the Knowledge Base for more information. Dynamics NAV Adapter New Features Represents a technical alignment with TIBCO Scribe Insight Version 7.9.4 and provides support for Dynamics NAV 2009 R2, 2013, 2013 R2, 2015, 2016, 2017, and 2018. Only these versions of Dynamics NAV are supported with v3.2.1. There are no other new features. Dynamics NAV Adapter Changes in Functionality There are no changes in functionality for the Adapter for Microsoft Dynamics NAV. Dynamics NAV Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for Microsoft Dynamics NAV. Dynamics NAV Adapter Migration And Compatibility - The Adapter for Microsoft Dynamics NAV version 3.2.1 only supports Microsoft Dynamics NAV 2009 R2, 2013, 2013 R2, 2015, 2016, 2017, or 2018. If your site is running an earlier version of Dynamics NAV do not upgrade your TIBCO Scribe Insight software. - If your site needs to upgrade the Microsoft Dynamics NAV client license to support the Scribe NAV Granule, contact your regional Microsoft AOC and request the Microsoft Dynamics NAV client license be upgraded to include granule ID: 14094210 titled “Scribe NAV Adapter.” Dynamics NAV Adapter Closed Issues The following are closed issues in the Adapter for Microsoft Dynamics NAV. <table> <thead> <tr> <th>Key/Case</th> <th>Summary</th> </tr> </thead> <tbody> <tr> <td>656436</td> <td>D66002, 65768: Version 3.1.1 of the Adapter for Dynamics NAV was unable to connect to Dynamics NAV 2009 R2. When attempting to update a Contact the following error was generated: \nCould not invoke the member ConvertInvalidXMLCharacters. The OLE control or Automation server returned an unknown error code.</td> </tr> </tbody> </table> Dynamics NAV Adapter Known Issues The following are known issues in the Adapter for Microsoft Dynamics NAV. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> <tbody> <tr> <td>--</td> <td><strong>Summary:</strong> The Dynamics NAV 2013 credential type of Access Control Service is not supported. <strong>Workaround:</strong> None.</td> </tr> </tbody> </table> | -- | **Summary:** D9422: Datetime or decimal filters on publisher messages must use the following formats: • Decimal format = X,XXX.XX • Date/time format = MM/DD/YY **Workaround:** None. | <p>| -- | <strong>Summary:</strong> D7111, D7018: Setting a custom query that filters on a field not in a selected output field causes an object reference error. <strong>Workaround:</strong> Add the filter field to the list of selected output fields. | | -- | <strong>Summary:</strong> D7089: Saving a schema file as UTF8 or UTF 16 saves the file as ANSI. Selecting this as an xml schema file in the Workbench causes the following error: The schema file could not be opened. Switch from current encoding to specified encoding is not supported. <strong>Workaround:</strong> Open the schema file in Notepad or WordPad and save as a Unicode file. |</p> <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | -- | **Summary:** D7091: Because the following database table names contain an ampersand (&), publishing on them is not supported: Sales & Receivables Setup, Purchases & Payables Setup. **Workaround:** None. | | -- | **Summary:** D6964: Using the following ASCII characters followed by another character in passwords is not supported: - less than (<) - ampersand (&) - single quote (’) - double quote (“) - semicolon (;) **Workaround:** None. | | -- | **Summary:** D7141: The Dynamics NAV adapter displays times in UTC when viewed in the Workbench. **Workaround:** None. | | -- | **Summary:** Records with double quotes (“”) in the key field are not processed by the Scribe Publisher for Dynamics NAV and cause the following error in the PubFailed queue: Exception from HRESULT: 0x80004046A. **Workaround:** None. | | -- | **Summary:** Records with double quotes (“”) in a source filter field or in a lookup field cause the following error: Invalid formula syntax. **Workaround:** None. | | 65934 | **Summary:** D70673: Inserting a Sales Order line that contains a Resource instead of an Item fails during validation. **Workaround:** Remove table 5403 from the Scribe Validation Rules in Microsoft Dynamics NAV. Restart the Microsoft Dynamics NAV/NAS service and the Scribe Services. See Importing Default Validation Rules in the TIBCO Scribe Insight Online Help for more information on editing Validation Rules. | ## Adapter For Salesforce Version 2.8.3 ### Salesforce Adapter Requirements - TIBCO Scribe Insight 7.9.4 or later - A Salesforce.com Account - Microsoft .NET Framework Version 4.5.2 or higher - Additional configuration may be required to leverage Salesforce.com’s workflow capabilities. For more information, see Implementing the Adapter in the TIBCO Scribe Insight Online Help. ### Salesforce Adapter New Features Represents a technical alignment with TIBCO Scribe Insight Version 7.9.4. ### Salesforce Adapter Changes in Functionality There are no changes in functionality for the Adapter for Salesforce. ### Salesforce Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for Salesforce. ### Salesforce Adapter Migration And Compatibility There are no migration procedures or compatibility issues in this release of the Adapter for Salesforce. ### Salesforce Adapter Closed Issues There are no closed issues in this release of the Adapter for Salesforce. # Salesforce Adapter Known Issues The following are known issues in the Adapter for Salesforce. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> </table> | 89360 | **Summary**: D34045: When selecting CaseHistory as a source in a source query and User (Createdby) as a parent, an error is returned by the API if the majority of the fields are selected. error: "MALFORMED_QUERY unexpected token: **Workaround**: None. | Adapter For SalesLogix Version 7.9.4 SalesLogix Adapter Requirements - TIBCO Scribe Insight 7.9.4 or later - SalesLogix 8.0 or later - The SalesLogix client must be installed on the same computer as the Adapter for SalesLogix SalesLogix Adapter New Features Represents a technical alignment with TIBCO Scribe Insight Version 7.9.4. SalesLogix Adapter Changes in Functionality There are no changes in functionality for the Adapter for SalesLogix. SalesLogix Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for SalesLogix. SalesLogix Adapter Migration And Compatibility Before you upgrade to SalesLogix Adapter 7.9.4 from SalesLogix 7.7.0 or 7.7.1: 1. Stop all Scribe Services and programs. 2. Uninstall the SalesLogix Adapter. 3. On the Windows Control Panel, double click Programs and Features. 4. Double-click TIBCO Scribe Insight. 5. Click Next and select the Repair option. 6. After the repair procedure completes, upgrade Insight and the SalesLogix Adapter. If you have questions about this procedure, contact Scribe Support using the Open a Case button in the Scribe Success Community. Setting Up SalesLogix Connections You must set up the SalesLogix database connections when you upgrade to version 7.7.0 or later of the SalesLogix Adapter. Verify that the database connections in SalesLogix are configured before setting up the SalesLogix Adapter. For more information, see the SalesLogix documentation. To set up the SalesLogix connections: 1. Log on to the Scribe system as administrator. 2. With the SalesLogix Administrator's Bundle Manager (located in ..\Program Files\Scribe), install the appropriate Scribe bundle (Scribe*.sxb) for your database. - New SalesLogix installation: - Microsoft SQL Server — Scribe - MSSQL.sxb - Oracle — Scribe - Oracle.sxb - SalesLogix Upgrade: - Microsoft SQL Server — Scribe Upgrade 6.x-7.x- MSSQL.sxb - Oracle — Scribe Upgrade 6.x-7.x - Oracle.sxb 3. From the SalesLogix client, use the SalesLogix Data Link Manager to set up at least one SalesLogix database connection. These database connections are used when connecting to SalesLogix as either the source or the target. SalesLogix Adapter Closed Issues The are no closed issues in this release of the Adapter for SalesLogix. ## SalesLogix Adapter Known Issues The following are known issues in the Adapter for SalesLogix. <table> <thead> <tr> <th>Key/Case</th> <th>Summary/Workaround</th> </tr> </thead> <tbody> <tr> <td>56707,</td> <td><strong>Summary:</strong> D7042, D8577: Seek step always fails with &quot;Could not create WHERE clause.&quot; Update/insert step works with the same criteria.</td> </tr> <tr> <td>57620</td> <td><strong>Workaround:</strong> None.</td> </tr> <tr> <td>64723</td> <td><strong>Summary:</strong> D7041, D9163: When editing and selecting metadata values from the drop-down list in the <strong>Adapter Metadata Configurator &gt; Edit Metadata</strong> dialog, incorrect values are saved.</td> </tr> <tr> <td></td> <td><strong>Workaround:</strong> None.</td> </tr> <tr> <td>79555</td> <td><strong>Summary:</strong> D17933: When using SalesLogix as a source, queries that retrieve more than 50,000 or 100,000 items fail with an out of memory error.</td> </tr> <tr> <td></td> <td><strong>Workaround:</strong> Use filters to reduce the number of records retrieved in by a single query.</td> </tr> <tr> <td>81336</td> <td><strong>Summary:</strong> D19320: Updating Accounts sometimes generates errors similar to the following: Main Error: Account PreUpdate failed: Operator '=' is not defined for type 'DBNull' and type 'DBNull'</td> </tr> <tr> <td></td> <td><strong>Workaround:</strong> None.</td> </tr> <tr> <td>83710</td> <td><strong>Summary:</strong> D30023: Deleting an Account with Attachment records where the linked file for one or more of those records is missing fails with an error similar to the following: System alert: Scribe EventManager - The job was terminated because the Message Processor is unresponsive (Alert # 323, Alert Id 9873)</td> </tr> <tr> <td></td> <td><strong>Workaround:</strong> None.</td> </tr> </tbody> </table> Adapter For Web Services Version 1.5.6 Web Services Adapter Requirements - TIBCO Scribe Insight 7.9.4 or later - Microsoft .NET 4.0 Framework Extended - You must be logged into a user account with local administrator privileges to install this adapter Web Services Adapter New Features Represent a technical alignment with TIBCO Scribe Insight Version 7.9.4. Web Services Adapter Changes in Functionality There are no changes in functionality for the Adapter for Web Services. Web Services Adapter Deprecated And Removed Features There are no deprecated or removed features for the Adapter for Web Services. Web Services Adapter Migration And Compatibility - After upgrading from a previous release of the Scribe Adapter for Web Services, revalidate any existing web service connections. - TIBCO recommends using the Adapter for Web Services to connect to Microsoft Dynamics AX 2012 and higher. - When using the Adapter for Web Services, be aware that: - Web Service connections are established using either the basicHttpBinding or the wsHttpBinding protocol. WS_* and other protocols are not supported. - This adapter has been tested against a wide variety of web services. However, you may find issues specific to your web service. If you have issues that you can’t resolve, please contact Technical Support. - In a DTS step configuration, you cannot execute the same method more than once on any given entity. Web Services Adapter Closed Issues There are no closed issues in the Adapter for Web Services. Web Services Adapter Known Issues The following are known issues in the Adapter for Web Services. <table> <thead> <tr> <th>Key/Case</th> <th>Summary</th> <th>Workaround</th> </tr> </thead> <tbody> <tr> <td>50209</td> <td><strong>Summary</strong>: D7138: Insight UI not showing certain fields contained in WSDL.</td> <td><strong>Workaround</strong>: None.</td> </tr> <tr> <td></td> <td><strong>Workaround</strong>: None.</td> <td></td> </tr> <tr> <td>61287</td> <td><strong>Summary</strong>: D8950: Error when trying to validate WSDL: Out of memory.</td> <td><strong>Workaround</strong>: None.</td> </tr> <tr> <td>74748</td> <td><strong>Summary</strong>: D4351: If SOAP header values defined by the published web service are longer than the configured size of the database field used in the Scribe Internal Database to store the value, truncation errors are generated.</td> <td><strong>Workaround</strong>: Use an Alter statement to change the field size in Microsoft SQL.</td> </tr> </tbody> </table>
{"Source-Url": "https://help.scribesoft.com/retpdfs/ReleaseNotesScribeInsight794.pdf", "len_cl100k_base": 14084, "olmocr-version": "0.1.53", "pdf-total-pages": 42, "total-fallback-pages": 0, "total-input-tokens": 82292, "total-output-tokens": 16206, "length": "2e13", "weborganizer": {"__label__adult": 0.0003237724304199219, "__label__art_design": 0.0004601478576660156, "__label__crime_law": 0.0003275871276855469, "__label__education_jobs": 0.00115203857421875, "__label__entertainment": 0.00015223026275634766, "__label__fashion_beauty": 0.0001423358917236328, "__label__finance_business": 0.0034961700439453125, "__label__food_dining": 0.0002703666687011719, "__label__games": 0.0011692047119140625, "__label__hardware": 0.000942707061767578, "__label__health": 0.0002028942108154297, "__label__history": 0.00022721290588378904, "__label__home_hobbies": 0.0001145005226135254, "__label__industrial": 0.0004453659057617187, "__label__literature": 0.0002343654632568359, "__label__politics": 0.0001928806304931641, "__label__religion": 0.00031638145446777344, "__label__science_tech": 0.007221221923828125, "__label__social_life": 0.00010544061660766602, "__label__software": 0.4365234375, "__label__software_dev": 0.54541015625, "__label__sports_fitness": 0.00023186206817626953, "__label__transportation": 0.00029587745666503906, "__label__travel": 0.0002378225326538086}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60359, 0.03581]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60359, 0.06549]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60359, 0.80016]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 3356, false], [3356, 7734, null], [7734, 7734, null], [7734, 8554, null], [8554, 8554, null], [8554, 9526, null], [9526, 10993, null], [10993, 12921, null], [12921, 14064, null], [14064, 15834, null], [15834, 16665, null], [16665, 18450, null], [18450, 19888, null], [19888, 22104, null], [22104, 23803, null], [23803, 25459, null], [25459, 27266, null], [27266, 28724, null], [28724, 30062, null], [30062, 31686, null], [31686, 33889, null], [33889, 35318, null], [35318, 37080, null], [37080, 38977, null], [38977, 40084, null], [40084, 40996, null], [40996, 42780, null], [42780, 43901, null], [43901, 45526, null], [45526, 46544, null], [46544, 48405, null], [48405, 50126, null], [50126, 51671, null], [51671, 52688, null], [52688, 53126, null], [53126, 54280, null], [54280, 55445, null], [55445, 57792, null], [57792, 59221, null], [59221, 60359, null], [60359, 60359, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 3356, false], [3356, 7734, null], [7734, 7734, null], [7734, 8554, null], [8554, 8554, null], [8554, 9526, null], [9526, 10993, null], [10993, 12921, null], [12921, 14064, null], [14064, 15834, null], [15834, 16665, null], [16665, 18450, null], [18450, 19888, null], [19888, 22104, null], [22104, 23803, null], [23803, 25459, null], [25459, 27266, null], [27266, 28724, null], [28724, 30062, null], [30062, 31686, null], [31686, 33889, null], [33889, 35318, null], [35318, 37080, null], [37080, 38977, null], [38977, 40084, null], [40084, 40996, null], [40996, 42780, null], [42780, 43901, null], [43901, 45526, null], [45526, 46544, null], [46544, 48405, null], [48405, 50126, null], [50126, 51671, null], [51671, 52688, null], [52688, 53126, null], [53126, 54280, null], [54280, 55445, null], [55445, 57792, null], [57792, 59221, null], [59221, 60359, null], [60359, 60359, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60359, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60359, null]], "pdf_page_numbers": [[0, 0, 1], [0, 3356, 2], [3356, 7734, 3], [7734, 7734, 4], [7734, 8554, 5], [8554, 8554, 6], [8554, 9526, 7], [9526, 10993, 8], [10993, 12921, 9], [12921, 14064, 10], [14064, 15834, 11], [15834, 16665, 12], [16665, 18450, 13], [18450, 19888, 14], [19888, 22104, 15], [22104, 23803, 16], [23803, 25459, 17], [25459, 27266, 18], [27266, 28724, 19], [28724, 30062, 20], [30062, 31686, 21], [31686, 33889, 22], [33889, 35318, 23], [35318, 37080, 24], [37080, 38977, 25], [38977, 40084, 26], [40084, 40996, 27], [40996, 42780, 28], [42780, 43901, 29], [43901, 45526, 30], [45526, 46544, 31], [46544, 48405, 32], [48405, 50126, 33], [50126, 51671, 34], [51671, 52688, 35], [52688, 53126, 36], [53126, 54280, 37], [54280, 55445, 38], [55445, 57792, 39], [57792, 59221, 40], [59221, 60359, 41], [60359, 60359, 42]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60359, 0.11075]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
129ca9efc9d70be1bbe5c26a11fd3b81189c4af6
A METRICS-BASED MODEL FOR ESTIMATING THE MAINTENANCE EFFORT OF PYTHON SOFTWARE Catherine Wambui Mukunga¹, John Gichuki Ndia² and Geoffrey Mariga Wambugu³ ¹, ², ³School of Computing and Information Technology, Murang’a University of Technology, Murang’a Kenya, ABSTRACT Software project management includes a substantial area for estimating software maintenance effort. Estimation of software maintenance effort improves the overall performance and efficiency of software. The Constructive Cost Model (COCOMO) and other effort estimation models are mentioned in literature but are inappropriate for Python programming language. This research aimed to modify the Constructive Cost Model (COCOMO II) by considering a range of Python maintenance effort influencing factors to get estimations and incorporated size and complexity metrics to estimate maintenance effort. A within-subjects experimental design was adopted and an experiment questionnaire was administered to forty subjects aiming to rate the maintainability of twenty Python programs. Data collected from the experiment questionnaire was analyzed using descriptive statistics. Metric values were collected using a developed metric tool. The subject ratings on software maintainability were correlated with the developed model’s maintenance effort, a strong correlation of 0.610 was reported meaning that the model is valid. KEYWORDS Software Maintenance, Software Maintenance effort, Software Maintenance estimation model, Python Software, Complexity metrics and size metrics 1. INTRODUCTION Software maintenance effort estimation still remains a challenge for most software development teams since the current methodologies are still unable to deal with the current software estimation challenges that exist today. Traditional software maintenance effort can be estimated using a variety of models such as the Constructive Cost Model (COCOMO), the Software Life Cycle Management model (SLIM), Function Point, and others but more work needs to be done on developing models that can accommodate programs from new programming languages. The most well-known software cost estimation model is the COCOMO, or generalized Constructive Cost Model, established by [1]. The COCOMO II model is the latest update. [2] remark that the COCOMO II model is a regression based software cost estimation model which is the most popular among the traditional models. Several effort estimation models are reported in the literature but are not suitable for Python software. A study by [3] advise on the need to revise the COCOMO model due to inaccuracies, in addition, the COCOMO II model considers the same software development cost drivers to estimate maintenance effort which does not reflect the true picture of the software maintenance phase. A software metric refers to a measurement of a software’s attributes or specifications [4]. Software metrics can be used to measure product output, project estimation, process progress, and process improvements as explained by [5]. Software complexity is described by [6] to be the challenges and difficulties in software reuse, software comprehension, and software maintenance. Software Complexity metrics have been defined by [6], [7], [8], [9], [10], [11], and [12]. [13] concluded that increasing complexity drives up adaptive maintenance costs. Software size has an impact on its complexity according to research conducted by [14]. [26] state that size metrics are a major factor in the determination of successful software projects. Additionally, the study by [15] suggests size metrics have a significant impact on project effort, duration, and productivity. One of the widely adopted size metrics is lines of code (LOC) which according to [13] is not effective since a statement may be spread over several lines. [27] did not consider lines of code (LOC) metric in the development of a generic effort estimation model explaining that the metric is language dependent. Research by [16] presents Python to be a fast-growing programing language. [16] mentioned that Python had become popular due to its simplicity, learnability, and supportability. The most popular programming language overall, out of 100, is Python, according to the Importance of Being Earnest index (TIOBE) of April 2023. The TIOBE index helps in making decisions about what programming language to adopt in building a new software system. This paper is structured as follows; section two is a discussion of software maintenance effort estimation models; section three discusses the proposed software maintenance effort estimation model; section four discusses how the proposed model was validated; section five is a discussion of the validation results, and section six is a discussion of the conclusion and future work. 2. LITERATURE REVIEW 2.1. Software Maintenance Effort Estimation Models The maintenance cost estimation model proposed by [17] is considers the Annual Change Traffic (ACT) metric and operates on a fourth generation language environment. In addition, the model has incorporated several factors grouped into technical and non-technical factors such as internal complexity, quality of source code, Computer Aided Software Engineering tools and others. [18] developed a model for estimating maintenance effort. The effort was expressed in person hours. The first step of developing the model involved identification of metrics that affect maintenance effort. A correlation coefficient analysis between the metrics and maintenance effort was done to determine the most effective metrics to predict adaptive maintenance effort. The equation $E = 63 + .1 \text{DLOC}$ was used to compute the maintenance effort. \( 1 \) A maintenance cost estimation model on the basis of regression was developed by [19] for a large application. The work is approached in three phases; creation of data transparency, examining maintenance expenditure, and cost optimization. Effort and product factors are considered such as programming languages and software deviations from the actual result. [20] Computed maintenance cost by implementing the intermediate COCOMO model. The researcher introduced new cost driver multipliers and concluded that additional multipliers and number of code lines increases the maintenance effort. To estimate the maintenance cost, the annual change of traffic (ACT) metric was introduced which consists the annual changes in the software source code. To compute ACT, NNL which stands for a count of new lines was added to a count of the modified lines and the result divided by a count of original lines. [14] created the Software Maintenance Effort Model (SMPEEM), which calculates the volume of the maintenance function using function points. The Function point’s measurement was used in estimating the sizes of maintenance tasks. The model considers value adjustment factors to adjust the counted function points. The effort is expressed as \[ \text{Effort} = A \times \text{Size}^B. \] (2) A and B are coefficients introduced from the regression results. The model was validated using a survey method. The results confirmed that adjusted function points are a good measure to estimate the maintenance effort of a project. According to [2], COCOMO II comprises of; the Application Composition Model which estimates effort at the first phase, the Early Design Model which implements the unadjusted function points to determine size, the Reuse model for computing the effort of reusable components and the post-architecture model. COCOMO II defines 17 cost drivers that are used with the Post Architecture model and are rated on a scale of very low to extra high. Precedentness, Development Flexibility, Architecture/Risk Resolution, Team Cohesion, and Process Maturity are the five scale drivers that affect how long a project takes to complete and which exponent is utilized in the Effort Equation. COCOMO II post architecture model is given as \[ P_M = A \times (\text{Size})^{1.01 + \sum_{j=1}^{s} SF_j \prod_{i=1}^{b} EM_i} \] B = 1.01 + 0.01\times\sum SF_i Where A = 2.45 [16] The investigations of [15] resulted in the development of the SMEEM (software maintenance effort model). The volume of maintenance and value adjustment parameters that have an impact on story points for effort estimation are calculated by the model. The model’s maintenance process is broken down into the computation of factor counts, story point assignments, story point adjustments, calculation of maintenance sizes, and finally calculation of maintenance durations. [15] assert that the paradigm is only applicable in contexts focused on extreme programming and agile development. [21] sought to improve the COCOMO II model for estimating maintenance size and effort by incorporating characteristics not considered in the COCOMO model. Steps followed in coming up with the model included; analyzing existing literature to identify size metrics, validating the size metrics on the maintenance cost, performing a behavioural analysis to identify the relative significance of the factors, determining a maintenance sizing method, determining the effort model, performing expert judgement on the effort, collection of project data for model validation, testing hypothesis, calibrating the model and evaluating model performance. An experiment with students as subjects and C++ programs as experiment objects confirmed that deleted source lines of code (SLOC) was a determinant of maintenance task effort. This model is limited to real-time software and implements the cost drivers for the COCOMO II model to compute maintenance effort which could lead to unrealistic estimates. [22] developed a Component-Based Software (CBS) model to estimate the maintenance cost. The model considered the development cost, the annual changes on the source code, and factors that influence the maintenance effort of component based software. Maintenance Cost Estimation is expressed as: \[ AME_{CBS} = ACT \times CDT \prod_{i=1}^{n} W_i \times F_i \] (4) Where - AMECBS is the Actual maintenance cost - CDT is the Component Development Cost - ACT are the annual source code changes - \( W_i \) is the \( i \)th weighting maintenance load - \( F_i \) is the Factors value This model is only used for component-based software. From the maintenance effort estimation models mentioned in the literature, none of the models is suitable for the Python language. The syntax of Python programs is unique from other Object Oriented based programs [16] and this disqualifies the existing models from precisely predicting the maintenance effort of Python programs. As a result of this realization, a maintenance effort estimation model for Python software would highly be desirable. 3. PROPOSED SOFTWARE MAINTENANCE EFFORT ESTIMATION MODEL In this work, a metrics based model for estimating the software maintenance effort of Python programs was developed. The model consists of three inputs namely; size, complexity, cost drivers, and maintenance effort as the output which is presented using the equation \[ Maintenance \ Effort \ (PM) = (\text{Size} \ \& \ \text{Complexity}) \times \prod_{i=1}^{24} EM \ i \] (5) 3.1. Size metrics The proposed model considers the System Size metric (SSpy) which is computed by considering the sizes of individual classes in a Python program. The SSpy metric is a consideration of the number of code blocks in several classes of a Python program. A code block is a collection of Python statements that belong to the same block or indent. The equation below was implemented to arrive at SSpy. \[ \text{System size} = \text{no of Code Blocks in class } a + \text{no of Code Blocks in class } b + \text{no of Code Blocks in class } c + \cdots + \text{no of Code Blocks in class } n \] (6) 3.2. Complexity metric In addition to Size, the proposed model also considered the complexity of the software. The proposed model considered the Weighted System Complexity (WSCpy) metric which is computed by considering the complexities of individual python classes. The metric Weighted System Complexity (WSCpy) was arrived at by considering the metric Weighted Class Complexity (WCCpy). Weighted Class Complexity (WCCpy) is a consideration of the complexities of variables and methods in a class. The equation below was implemented to arrive at WSCpy. \[ WSC_{py} = WCC_{py} \ \text{of class } a + WCC_{py} \ \text{of class } b + \cdots + WCC_{py} \ \text{of class } n, \text{ and expressed as} \] \[ WSC_{py} = \sum_{i=1}^{n} (i) \] (7) 3.3. Cost Drivers In our previous work [23], an expert opinion survey was conducted to identify and rank the relevant Python maintenance influencing factors. In the expert opinion survey, Python programmers and project managers were required to rate the factors influencing the maintenance cost of python software. Based on their responses, a mean value for each factor was computed by dividing the sum of actual responses per factor by sum of expected responses per attribute and multiplying the value by 100 i.e. Sum of actual responses / sum of expected responses *100. The factors were then ranked on the basis of the mean values. The 24 ranked factors are presented in Table 1. Table 1. Ranked software maintenance effort influencing factors. <table> <thead> <tr> <th>Ranking</th> <th>Factor</th> <th>Mean in %</th> <th>Normalised mean</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Code quality</td> <td>85.8</td> <td>0.858</td> </tr> <tr> <td>2</td> <td>Understandability</td> <td>85.71</td> <td>0.8571</td> </tr> <tr> <td>3</td> <td>Document Quality</td> <td>82.8</td> <td>0.828</td> </tr> <tr> <td></td> <td>Configuration Management</td> <td>82.3</td> <td>0.823</td> </tr> <tr> <td>4</td> <td>Technology Modern Programming</td> <td>80.95</td> <td>0.8095</td> </tr> <tr> <td>5</td> <td>Specifications</td> <td>80.95</td> <td>0.8095</td> </tr> <tr> <td>6</td> <td>Database Size</td> <td>80.95</td> <td>0.8095</td> </tr> <tr> <td>7</td> <td>Software Complexity</td> <td>80</td> <td>0.8</td> </tr> <tr> <td>8</td> <td>Staff ability and skills</td> <td>80</td> <td>0.8</td> </tr> <tr> <td>9</td> <td>Testing Quality</td> <td>79.52</td> <td>0.7952</td> </tr> <tr> <td>10</td> <td>Component Reusability</td> <td>78.57</td> <td>0.7857</td> </tr> <tr> <td>11</td> <td>Organization Maturity</td> <td>77.61</td> <td>0.7761</td> </tr> <tr> <td>12</td> <td>Maintenance Staff Ability</td> <td>77.14</td> <td>0.7714</td> </tr> <tr> <td>13</td> <td>Availability of maintainers</td> <td>75.2</td> <td>0.752</td> </tr> <tr> <td>14</td> <td>Technology Newness</td> <td>73.8</td> <td>0.738</td> </tr> <tr> <td>15</td> <td>Programming Style</td> <td>69.52</td> <td>0.6952</td> </tr> <tr> <td>16</td> <td>Number of maintainers</td> <td>69.4</td> <td>0.694</td> </tr> <tr> <td>17</td> <td>Hiring model of maintainers</td> <td>68.2</td> <td>0.682</td> </tr> <tr> <td>18</td> <td>Hardware Stability</td> <td>67.61</td> <td>0.6761</td> </tr> <tr> <td>19</td> <td>Location diversity of maintainers</td> <td>67</td> <td>0.67</td> </tr> <tr> <td>20</td> <td>Dependence on External</td> <td>63.8</td> <td>0.638</td> </tr> <tr> <td>21</td> <td>Environment Performance</td> <td>63.33</td> <td>0.6333</td> </tr> <tr> <td>22</td> <td>CASE Tools</td> <td>59.04</td> <td>0.5904</td> </tr> <tr> <td>23</td> <td>Application Type</td> <td>55.71</td> <td>0.5571</td> </tr> <tr> <td>24</td> <td>System Lifespan</td> <td>55.23</td> <td>0.5523</td> </tr> </tbody> </table> 3.4. Maintenance Effort The proposed model computes maintenance effort. The proposed model’s maintenance effort is expressed in Person-hours. 4. MODEL VALIDATION 4.1. Data Collection 4.1.1. Base Metrics The base metrics are computed once the Python source file is uploaded to the tool. The base metrics were the number of instance variables, the number of class variables, the number of instance methods, the number of static methods, the number of class methods, and the number of code blocks in a class. The tool user clicks the base metric tab to view base metrics for a Python file. 4.1.2. Derived metrics These were the metrics derived from the base metric. The derived metrics included; Weighted variable complexity (WVCpy), weighted method complexity (WMCpy), weighted class complexity (WCCpy), weighted system complexity (WSCpy), class size CSpy) and system size (SSpy). The tool user clicks on the derived metrics tab to view the derived metrics of a Python file. Metric values for the size and complexity of program one were collected using the PMMET tool as presented in figure 1. The program had a weighted system complexity of 12 and a system size of 16. The tool user clicks on the open button to upload a Python file for analysis. This is followed by clicking the run button to begin metrics computation. The tool user can now view base metrics. Derived metrics can be viewed upon clicking the derived metrics tab. Figure 1. Metric values for a Python program generated by the PMMET tool. 4.1.3. Effort Adjustment Factor (EAF) An Effort Adjustment Factor (EAF) value was computed by finding a product value of the factors influencing the maintenance effort of a Python program and the value recorded by the PMMET tool. The formula to compute the Effort Adjustment Factor value (EAF) is explained by [1]. There are 24 factors that influence the maintenance effort from Table 1. A software maintainer can select multiple factors and each factor has an effort multiplier value (weight). Order of occurrence of various cost drivers has a significant impact on overall efforts in project estimation. According to [25] variations to cost drivers in the COCOMO model contribute to an improved effort estimate. A highly ranked factor will contribute to a higher maintenance effort influencing power which will result in a higher maintenance effort value. A lowly ranked factor will contribute to a lower maintenance effort influencing power which will result in a lower maintenance effort value. The effort adjustment factor value (EAF) for Python program one is computed by the PMMET tool and presented in Figure 2. ![Figure 2](image) Figure 2 EAF value for a Python program generated by the PMMET tool. Figure 2 presents the Effort Adjustment Factor (EAF) value computed from three factors influencing the maintenance effort of program one. The factors are selected by the software maintainer and in this example, document quality, software complexity, and programming style were selected. The weights of the factors were multiplied to get an EAF value of 0.4605. 4.1.4. Model Maintenance Effort Once the tool generates the size and complexity metrics values and computes the effort adjustment factor, the last step is to compute the maintenance effort using the equation defined in section 3.4 of this work. The tool computes maintenance effort by finding a product of size, complexity, and EAF values and displays the output. The computed maintenance effort for program one is presented in Figure 3. From the maintenance effort tab, the software maintainer can confirm the selected factors, the generated metric values of size and complexity, and EAF value before computing maintenance effort. A total of twenty Python programs were considered in maintenance effort computation by the PMMET tool. The following steps were followed towards computing software maintenance effort using PMMET tool. Step 1: Upload the Python file to the tool Step 2: Click on run button Step 3: The tool displays the base and derived metrics of uploaded Python file. Step 4: The maintainer clicks on multiplier tab to select the factors affecting maintenance effort of the Python file. Step 5: The tool computes an Effort Adjustment Factor (EAF) Step 6: Maintainer clicks on the maintenance effort tab then the run button. The values for size, complexity, and EAF are presented to the maintainer for confirmation before computing effort. Step 7: The maintainer clicks on compute effort button and views the computed maintenance effort of the Python file. The maintenance effort computed for the twenty Python programs using the PMMET tool is presented in Table 2. Table 2. Maintenance Effort for twenty Python programs computed by PMMET tool. <table> <thead> <tr> <th>Program ID</th> <th>Size</th> <th>Complexity</th> <th>Ranking of factors influencing effort</th> <th>EAF</th> <th>Model Effort</th> </tr> </thead> <tbody> <tr> <td>program 1</td> <td>16</td> <td>12</td> <td>3,7,15</td> <td>0.4605</td> <td>88.41</td> </tr> <tr> <td>program 2</td> <td>13</td> <td>10</td> <td>1,3,5</td> <td>0.575</td> <td>74.76</td> </tr> <tr> <td>program 3</td> <td>11</td> <td>8</td> <td>1,3,5,7,9,10</td> <td>0.2874</td> <td>25.29</td> </tr> <tr> <td>program 4</td> <td>30</td> <td>29</td> <td>2,4,6,9</td> <td>0.454</td> <td>395.04</td> </tr> <tr> <td>program 5</td> <td>18</td> <td>18</td> <td>1,2,3,4,5,12</td> <td>0.3129</td> <td>101.37</td> </tr> </tbody> </table> program 6 20 8 2,3,5,8,12 0.3545 56.72 program 7 5 4 3,5,7,9 0.426 8.52 program 8 8 4 2,4,8,11,16 0.3039 9.72 program 9 6 6 1,2,3,4,5,14 0.2993 10.79 program 10 9 7 3,5,8,13 0.403 25.40 program 11 6 17 1,2,4,7,9 0.385 39.27 program 12 18 16 1,2,3,5,7,8,10 0.247 71.38 program 13 23 15 1,2,3,6,8,21,22,23 0.082 28.33 program 14 14 37 1,2,3,5,6,7,12,21 0.155 80.77 program 15 30 29 1,2,3,4,5,12 0.312 272.24 program 16 23 41 1,2,4,6 0.489 462.0 program 17 7 9 2,3,4,7 0.467 29.43 program 18 4 8 1,2,3,5,6,7,12,21 0.155 4.99 program 19 7 7 1,2,5,10,14 0.345 16.90 program 20 20 8 2,3,4,7 0.467 74.76 4.2. Context definition Second, third, and fourth year students belonging to Python programmers club of Kirinyaga University School of Pure and Applied Sciences department of Computing Studies were presented with twenty Python files. The twenty python files can be accessed from https://github.com/huckbyte/python-tool/tree/main/source%20codes. The subjects were asked about the features of Python programming language to assess their understanding of the language. All the forty participants had knowledge of classes, objects, methods, control structures, and Python indentation. 95% of the subjects had knowledge on inheritance and nesting. 80% had knowledge on abstraction. From the responses received under subject assessment section, it was concluded that all the subjects were qualified to take part in the study. All the subjects were taken through a refresher course on Python object oriented programming intensively for two hours. 4.3. Experiment Strategy A within-subject experiment design was adopted where every participant was assigned the same Python files for analysis. The subjects analyzed the Python files individually for two hours. The experiment objects consisted of twenty Python files which were already checked for syntax errors. Each participant was provided with twenty Python files containing different size and complexity metric values generated by the PMMET metric tool. The metrics tool was only used by the researcher to calculate metric values for the Python files and was not used by the participants. 4.4. Pilot study This study was conducted using within-subjects experimental design in which all the subjects received all treatments. The study aimed to find out whether the metric values generated by the PMMET metric tool correlated with the subjects’ rating of software maintainability of Python programs. The study also helped demystify whether the proposed metrics were contributors to increased levels of maintenance effort. A convenience random sample of ten subjects participated in the pilot study. Results of the pilot study suggested that the questionnaire was suitable for use in the study. 4.5. Experimental Planning Twenty Python files were shared with the students and the questionnaire. The instructions on how to carry out the exercise were explained for clarity purposes. To establish whether there is any relationship between Python metrics and subject ratings on maintainability of Python programs was achieved by testing the following hypothesis. i. Null Hypothesis (H0): There is no correlation between the Python size metric and the subject rating of maintainability of Python files. ii. Alternative Hypothesis (H1): There is a correlation between the Python size metric and the subject rating of maintainability of Python files. iii. Null Hypothesis (H0): There is no correlation between the Python complexity metric and the subject rating of maintainability of Python files. iv. Alternative Hypothesis (H1): There is a correlation between the Python complexity metric and the subject rating of maintainability of Python files. v. To establish whether there is any relationship between the proposed model’s maintenance effort and subject ratings on maintainability of Python programs was achieved by testing the following hypothesis. vi. Null Hypothesis (H0): The proposed model’s maintenance effort has no effect on the subject ratings on maintainability. vii. Alternative Hypothesis (H1): The proposed model’s maintenance effort has a significant effect on the subject ratings on maintainability. 4.6. Experiment results 4.6.1. Python programs maintainability descriptive analysis An experiment questionnaire was issued to forty students of Kirinyaga University, Kenya studying computer science related courses. The subjects were presented with twenty Python programs and were required to rate the extent to which the programs were maintainable. The SPSS statistical software was used to examine the acquired data. The descriptive statistics results of the twenty programs are presented in Table 3. <table> <thead> <tr> <th>Program no.</th> <th>N</th> <th>Minimum</th> <th>Maximum</th> <th>Mean</th> <th>Std. Deviation</th> </tr> </thead> <tbody> <tr> <td>program1</td> <td>37</td> <td>2.00</td> <td>4.00</td> <td>2.6216</td> <td>.54525</td> </tr> <tr> <td>program2</td> <td>37</td> <td>2.00</td> <td>4.00</td> <td>3.2432</td> <td>.59654</td> </tr> <tr> <td>program3</td> <td>37</td> <td>2.00</td> <td>4.00</td> <td>3.4054</td> <td>.55073</td> </tr> <tr> <td>program4</td> <td>37</td> <td>3.00</td> <td>5.00</td> <td>3.9459</td> <td>.62120</td> </tr> <tr> <td>program5</td> <td>37</td> <td>2.00</td> <td>5.00</td> <td>2.9459</td> <td>.77981</td> </tr> <tr> <td>program6</td> <td>37</td> <td>3.00</td> <td>4.00</td> <td>3.4865</td> <td>.50671</td> </tr> <tr> <td>program7</td> <td>37</td> <td>1.00</td> <td>5.00</td> <td>2.9730</td> <td>1.14228</td> </tr> <tr> <td>program8</td> <td>37</td> <td>1.00</td> <td>3.00</td> <td>1.6216</td> <td>.59401</td> </tr> <tr> <td>program9</td> <td>37</td> <td>1.00</td> <td>5.00</td> <td>2.4595</td> <td>1.14491</td> </tr> <tr> <td>program10</td> <td>37</td> <td>1.00</td> <td>5.00</td> <td>2.4054</td> <td>.89627</td> </tr> </tbody> </table> 4.6.2. Size, Complexity, Subjective data mean, and PMMET model effort values Table three presents the values for size, complexity metrics, the mean value for subject ratings on maintainability (subjective data), and the proposed model’s maintenance effort. Table 4: Size, Complexity, Subjective data mean, and PMMET model effort values <table> <thead> <tr> <th>Program no</th> <th>Size</th> <th>Complexity</th> <th>Subjective data</th> <th>Model Maintenance effort</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>16</td> <td>12</td> <td>2.62</td> <td>88.41</td> </tr> <tr> <td>2</td> <td>13</td> <td>10</td> <td>3.24</td> <td>74.76</td> </tr> <tr> <td>3</td> <td>11</td> <td>8</td> <td>3.41</td> <td>25.29</td> </tr> <tr> <td>4</td> <td>30</td> <td>29</td> <td>3.95</td> <td>395.04</td> </tr> <tr> <td>5</td> <td>18</td> <td>18</td> <td>2.95</td> <td>101.37</td> </tr> <tr> <td>6</td> <td>20</td> <td>8</td> <td>3.49</td> <td>56.72</td> </tr> <tr> <td>7</td> <td>5</td> <td>4</td> <td>2.97</td> <td>8.52</td> </tr> <tr> <td>8</td> <td>8</td> <td>4</td> <td>1.62</td> <td>9.72</td> </tr> <tr> <td>9</td> <td>6</td> <td>6</td> <td>2.46</td> <td>10.79</td> </tr> <tr> <td>10</td> <td>9</td> <td>7</td> <td>2.41</td> <td>25.40</td> </tr> <tr> <td>11</td> <td>6</td> <td>17</td> <td>3.19</td> <td>39.27</td> </tr> <tr> <td>12</td> <td>18</td> <td>16</td> <td>2.59</td> <td>71.38</td> </tr> <tr> <td>13</td> <td>23</td> <td>15</td> <td>3.08</td> <td>28.33</td> </tr> <tr> <td>14</td> <td>14</td> <td>37</td> <td>4.08</td> <td>80.77</td> </tr> <tr> <td>15</td> <td>30</td> <td>29</td> <td>3.73</td> <td>272.24</td> </tr> <tr> <td>16</td> <td>23</td> <td>41</td> <td>4.32</td> <td>462.0</td> </tr> <tr> <td>17</td> <td>7</td> <td>9</td> <td>1.68</td> <td>29.43</td> </tr> <tr> <td>18</td> <td>4</td> <td>8</td> <td>1.62</td> <td>4.99</td> </tr> <tr> <td>19</td> <td>7</td> <td>7</td> <td>2.24</td> <td>16.90</td> </tr> <tr> <td>20</td> <td>20</td> <td>8</td> <td>3.08</td> <td>74.76</td> </tr> </tbody> </table> 4.6.3 Relationship between Python size metric and subject ratings on maintainability A spearman’s rank-order correlation was run to determine the relationship between Python metrics and subject ratings on maintainability. The results are presented in Table 4. Size metric is significantly correlated to the subjects rating of Python maintainability by a correlation coefficient of 0.646 and a p value of 0.002. Table 5: Correlation results between Python size metric and subject ratings on maintainability 4.6.4 Relationship between Python complexity metric and subject ratings on maintainability A Spearman’s rank-order correlation was run to determine the relationship between Python complexity metrics and subject ratings on maintainability. The results are presented in Table 5. The complexity metric is significantly correlated to the subjects rating of Python maintainability by a correlation coefficient of 0.667 and a p value of 0.001. Table 6 Correlation results between Python complexity metric and subject ratings on maintainability <table> <thead> <tr> <th>Python metric</th> <th>Correlation Coefficient</th> <th>Sig.(2-tailed)</th> </tr> </thead> <tbody> <tr> <td>complexity</td> <td>0.667</td> <td>0.001</td> </tr> </tbody> </table> **. Correlation is significant at the 0.01 level (2-tailed) 4.6.5 Relationship between the model’s maintenance effort and subject ratings on maintainability The association between model effort and subject assessments on maintainability was investigated using a Spearman's rank-order correlation. The results are presented in Table 6. Maintenance effort is significantly correlated to the subject’s ratings on maintainability by a correlation coefficient of 0.610 and a p value of 0.004. Table 7 Correlation results between model effort and subject ratings on maintainability <table> <thead> <tr> <th>Model’s effort</th> <th>Correlation Coefficient</th> <th>Sig.(2-tailed)</th> </tr> </thead> <tbody> <tr> <td>Model’s effort</td> <td>0.610</td> <td>0.004</td> </tr> </tbody> </table> **. Correlation is significant at the 0.01 level (2-tailed) 5. DISCUSSION The proposed model for software maintenance effort estimation accepts three inputs namely; size, complexity, and an Effort Adjustment Factor value (EAF). Twenty Python projects were considered. Size and complexity metric values were computed using the PMMET tool. Effort multiplier values were determined through expert opinion and used in computing an Effort Adjustment Factor (EAF). An analysis was performed to determine whether there is a correlation between the size metric and the ratings given by the subjects for maintainability. The results indicated a significant correlation between size metric and maintainability. As a result, the null hypothesis that there is no significant correlation between the size metric and subject ratings on maintainability was rejected and the alternative hypothesis was supported. A second investigation was carried out to establish whether there is a relationship between Python complexity metrics and subject ratings on maintainability. The results indicated a significant correlation between complexity subject ratings on maintainability. As a result, the null hypothesis that there is no significant correlation between the complexity metric and subject ratings on maintainability was rejected and the alternative hypothesis was supported. The correlation analysis results on python size and complexity metrics confirm that large size programs that have high levels of complexity will definitely require higher effort compared to small sized programs with low complexity. The model's maintenance effort and the subjects' maintainability evaluations were the focus of a third experiment to determine whether there is a correlation. The results indicated a correlation of 0.610 between the model’s effort and subject ratings on maintainability. As a result, the null hypothesis that there is no significant correlation between the model effort and subject ratings on maintainability was rejected and the alternative hypothesis was supported. The experiment results confirms that the proposed model is valid. 6. CONCLUSION AND FUTURE WORK This research aimed to develop a metrics based maintenance effort estimation model for Python programs. The model accepts three inputs namely; size, complexity, and an effort adjustment factor value (EAF). The EAF is obtained by calculating the product value of the factors influencing maintenance effort in a project or program. Results of the metrics tool, model’s maintenance effort, and subject ratings were compared, and the findings indicated that metrics and subject ratings are strongly related and that the metrics are important factors in the maintainability of a Python program. A limitation of the developed model was that the dataset used comprised of small sized python programs. Future tasks would be to implement the estimation model on large sized Python projects and employing a machine learning strategy then evaluating the outcomes. The researchers hope that this study will be of great benefit to Python developers and maintainers to aid in estimating the maintenance effort of small sized Python programs. ACKNOWLEDGEMENT The Authors want to thank Professor Geoffrey Muchiri of Murang’a University of Technology, Murang’a Kenya. His comments and suggestions have contributed greatly to this work. REFERENCES AUTHORS Short Biography Catherine Wambui Mukunga is a Ph.D. student at Murang’a University of Technology, Kenya. She received her M.Sc. in Computer Science in 2014 from the University of Nairobi, Kenya and her BSc. in Information Technology in 2009 from Jomokenyatta University of Agriculture and Technology, Kenya. Her research activities are related to Software Engineering Metrics, Software Project Management and Machine Learning. Dr. John Gichuki Ndia is a lecturer at Murang’a University of Technology, Kenya. He obtained his Bachelor of Information Technology from Busoga University, Uganda in 2009, his MSc. in Data Communication from KCA University, Kenya in 2013, and his PhD in Information Technology from Masinde Muliro University of Science and Technology, Kenya in 2020. His Research interests include Software Engineering, Computer Networks Security and AI Applications. He is a Professional Member of Institute of Electrical and Electronics Engineers (IEEE) and the International Association of Engineers (IAENG). Dr. Geoffrey Mariga Wambugu is a senior lecturer at Murang’a University of Technology, Kenya. He obtained his BSc Degree in Mathematics and Computer Science from Jomo Kenyatta University of Agriculture and Technology in 2000, and his MSc Degree in Information Systems from the University of Nairobi in 2012. He holds a Doctor of Philosophy in Information Technology degree from Jomo Kenyatta University of Agriculture and Technology. His interests include Machine Learning and Text Analytics.
{"Source-Url": "https://aircconline.com/ijsea/V14N3/14323ijsea02.pdf", "len_cl100k_base": 9078, "olmocr-version": "0.1.49", "pdf-total-pages": 15, "total-fallback-pages": 0, "total-input-tokens": 44051, "total-output-tokens": 10547, "length": "2e13", "weborganizer": {"__label__adult": 0.0003578662872314453, "__label__art_design": 0.0002772808074951172, "__label__crime_law": 0.0002732276916503906, "__label__education_jobs": 0.0015697479248046875, "__label__entertainment": 5.5849552154541016e-05, "__label__fashion_beauty": 0.00015366077423095703, "__label__finance_business": 0.00034809112548828125, "__label__food_dining": 0.0003504753112792969, "__label__games": 0.00054931640625, "__label__hardware": 0.0005984306335449219, "__label__health": 0.00044608116149902344, "__label__history": 0.00017917156219482422, "__label__home_hobbies": 9.584426879882812e-05, "__label__industrial": 0.0002834796905517578, "__label__literature": 0.00027871131896972656, "__label__politics": 0.0001544952392578125, "__label__religion": 0.00031828880310058594, "__label__science_tech": 0.00887298583984375, "__label__social_life": 0.00011539459228515624, "__label__software": 0.005016326904296875, "__label__software_dev": 0.97900390625, "__label__sports_fitness": 0.00029468536376953125, "__label__transportation": 0.0003790855407714844, "__label__travel": 0.00017440319061279297}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 39917, 0.08943]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 39917, 0.21848]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 39917, 0.90606]], "google_gemma-3-12b-it_contains_pii": [[0, 3078, false], [3078, 6799, null], [6799, 9981, null], [9981, 12572, null], [12572, 15537, null], [15537, 17050, null], [17050, 19063, null], [19063, 20983, null], [20983, 23672, null], [23672, 26529, null], [26529, 29137, null], [29137, 31529, null], [31529, 34732, null], [34732, 38391, null], [38391, 39917, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3078, true], [3078, 6799, null], [6799, 9981, null], [9981, 12572, null], [12572, 15537, null], [15537, 17050, null], [17050, 19063, null], [19063, 20983, null], [20983, 23672, null], [23672, 26529, null], [26529, 29137, null], [29137, 31529, null], [31529, 34732, null], [34732, 38391, null], [38391, 39917, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 39917, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 39917, null]], "pdf_page_numbers": [[0, 3078, 1], [3078, 6799, 2], [6799, 9981, 3], [9981, 12572, 4], [12572, 15537, 5], [15537, 17050, 6], [17050, 19063, 7], [19063, 20983, 8], [20983, 23672, 9], [23672, 26529, 10], [26529, 29137, 11], [29137, 31529, 12], [31529, 34732, 13], [34732, 38391, 14], [38391, 39917, 15]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 39917, 0.28244]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
b1e3a8e6ec19ef8157091ff9e85b66c481704c24
PARALLEL GRAPH REWRITING ON LOOSELY COUPLED MACHINE ARCHITECTURES M.C.J.D. van Eekelen, M.J. Plasmeijer, J.E.W. Smetsers. 1 Faculty of Mathematics and Computer Science, University of Nijmegen, Toernooiveld 1, 6525 ED Nijmegen, The Netherlands, October 1990. Abstract Graph rewriting models are very suited to serve as the basic computational model for functional languages and their implementation. Graphs are used to share computations which is needed to make efficient implementations of functional languages on sequential hardware possible. When graphs are rewritten (reduced) on parallel loosely coupled machine architectures, subgraphs have to be copied from one processor to another such that sharing is lost. In this paper we introduce the notion of lazy copying. With lazy copying it is possible to duplicate a graph without duplicating work. Lazy copying can be combined with simple annotations which control the order of reduction. In principle, only interleaved execution of the individual reduction steps is possible. However, a condition is deduced under which parallel execution is allowed. When only certain combinations of lazy copying and annotations are used it is guaranteed that this so-called non-interference condition is fulfilled. Abbreviations for these combinations are introduced. Now complex process behaviours, such as process communication on a loosely coupled parallel machine architecture, can be modelled. This also includes a special case: modelling multi-processing on a single processor. Arbitrary process topologies can be created. Synchronous and asynchronous process communication can be modelled. The implementation of the language Concurrent Clean, which is based on the proposed graph rewriting model, has shown that complicated parallel algorithms which can go far beyond divide-and-conquer like applications can be expressed. 1 Introduction Ideally, a computational model of a language is a formal model as close as possible to both its semantics and its implementation, still it models only the essential aspects of them. In the following paragraphs it is explained why Graph Rewriting Systems (GRS's) are suited to serve as a computational model of functional languages and their implementations. After that, GRS's are extended in order to deal with parallel evaluation. Graph rewriting systems and functional languages Our prime interests are functional languages and their implementation on sequential and parallel hardware. Traditionally, the pure lambda calculus (Church (1932/3), Barendregt (1984)) is considered to be a suitable model for these languages. However, in our opinion, some important aspects of functional languages and the way they are usually implemented, cannot be modelled with this calculus. In particular, the calculus itself lacks pattern matching and the notion of sharing of computations. Patterns contain important information for strictness analyzers (Nöcker (1988)). Sharing of computations is essential to obtain efficient implementations on traditional hardware (Püschel & Keller (1986)). Graph Rewriting systems are based on pattern matching and sharing. We believe that compared to the λ-calculus graph rewriting systems (Barendregt et al. (1987a,b)) are better suited to serve as computational model for functional languages. In the past we have defined and implemented the intermediate language Clean (Brus et al. (1987)) based on graph rewriting systems with a functional evaluation strategy and we have shown that efficient state-of-the-art implementations on sequential hardware can be obtained by compiling functional languages to Clean (Koopman & Nöcker (1988)). Parallel evaluation At any stage during its evaluation a functional program may contain more than one function application that can be rewritten (reducible expression or shorter redex). If in this context redexes are rewritten in any order, the normal form (if it exists) will always be the same. This uniqueness of normal forms offers the theoretical possibility to reduce redexes in parallel. So, functional languages are often considered to be well suited for parallel computation. Two kinds of parallelism are distinguished: fine grain and coarse grain. In principle, with fine grain parallelism any redex (grain) is a candidate for parallel evaluation. Fine grain machine architectures try to exploit this parallelism fully. Unfortunately, these architectures, such as data flow machines (Gurd et al. (1985), Arvind et al. (1987)), are very complex and not yet commercially available. For coarse grain parallelism loosely coupled machine architectures, such as Transputer systems, are available on a wide scale. But now one of the major problems is that most reductions of function applications will not contain a sufficient amount of 1 This research is partially supported by the ESPRIT basic research action 3074: Semagraph (Semantics and Pragmatics of Generalised Graph Rewriting). computation compared with the overhead costs caused by the inter-processor communication (grain size problem). Therefore, for these architectures only redexes that yield a large amount of computation are suited to be evaluated in parallel. In analogy with the concurrent imperative languages, a parallel functional language should provide a way to create concurrent entities (processes) in a program, preferably without violating the functional semantics. Arbitrary communications between processes have to be definable in a general way. Special language constructs have been proposed to make process creation and communication possible (see section 6). Mostly, these constructs are either rather ad hoc or have limited expressive power. We are looking for powerful but elegant basic components needed to realize dynamic process creation with arbitrary communication. Parallel graph rewriting In order to deal with parallelism, the graph rewriting model is extended with two issues: a way to control the evaluation order and a way to regulate the distribution of data. By denoting subgraphs on which reduction processes have to be created, the reduction order in graph rewriting can be influenced. Reduction processes which evaluate an indicated subgraph are created dynamically. A subclass of GRS's in which reducers can be created explicitly will be prefixed with P. So the abbreviation for general graph rewriting systems with explicit parallelism is P-GRS. The distribution of data, which in the context of graph rewriting involves copying of graphs, can be regulated by means of a so called lazy copying mechanism. Intentionally, sharing is used to prevent that the same computation is performed more than once. With lazy copying it is possible to make a copy without losing this advantage. Although in implementations generally some kind of copying/sharing scheme is used, up to now it has never been incorporated in graph rewriting models. For all these reasons we have given a more firm basis to lazy copying by explicitly incorporating it in graph rewriting systems. As we shall see, with lazy copying one can model all the major aspects of data distribution on parallel machine architectures. It is possible to specify whether synchronous or asynchronous inter-processor links are used and also the kind of and the moment at which data is communicated. To handle all these aspects it is unavoidable that the lazy copying mechanism has become very complex. This in contrast with the rather obvious way of creating parallel reducers. A subclass of GRS's which is extended with lazy copying will be prefixed with C. So the abbreviation for general graph rewriting systems with lazy copying is C-GRS. In this paper it will be shown that arbitrary process structures with various forms of inter-process communication can be modelled in PC-GRS's (GRS's with explicit parallelism and lazy copying). In particular, loosely coupled parallel evaluation is defined wherein any process structure can be expressed. In order to illustrate the expressive power examples will be given of some non-trivial parallel algorithms. Structure of this paper This paper has not the intention to give a full formal description of a parallel graph rewriting model. As can be seen in Smetsers (1991) such a description becomes very complex. We believe that going into too many technical details at this stage will not help the reader to understand the fundamental issues of what we want to address. The next section introduces graph rewriting briefly. After that in section 3 process creation is incorporated in graph rewriting. In section 4 lazy copying is introduced. The power of the combination of lazy copying and process creation is shown in section 5. In particular, the use of the system to model parallel graph reduction on loosely coupled parallel architectures is demonstrated. In section 6 comparisons with related work, implementation aspects and directions for future research are given. 2 Graph Rewriting In graph rewriting systems (Barendregt et al. (1987b)) a program is represented by a set of rewrite rules. Each rewrite rule consists of a left-hand-side graph (the pattern), an optional right-hand-side graph (the contractum) and one or more redirections. A graph is a set of nodes. Each node has a defining node-identifier (the nodeid). A node consists of a symbol and a (possibly empty) sequence of applied nodeid's (the arguments of the symbol). Applied nodeid's can be seen as references (arcs) to nodes in the graph, as such they have a direction: from the node in which the nodeid is applied to the node of which the nodeid is the defining identifier. Starting with an initial graph the graph is rewritten according to the rules. When the pattern matches a subgraph, a rewrite can take place which consists of building the contractum and doing the redirections. A redirection of one nodeid to another nodeid means that all applied occurrences of one nodeid are replaced by occurrences of the other. The part of the graph that matches the pattern is sometimes called a \textit{redex}. A \textit{reduction strategy} is a function that indicates one or more of the available redexes. A \textit{reducer} is a process that reduces redexes which are indicated by the strategy. The result of a reducer is reached as soon as the reduction strategy does not indicate redexes anymore. A reducer chooses either deterministically or non-deterministically one of the redexes that are indicated by the strategy. In this paper only deterministic reducers (i.e. reducers which make their choices deterministically) are used. A graph is in \textit{normal form} if none of the patterns in the rules match any part of the graph. A graph is said to be in \textit{root normal form} when the root of a graph is not the root of a redex and can never become the root of a redex. The root normal form property is in general undecidable (Plasmeijer & Eekelen (1991)). Even if a graph has only one unique normal form, this graph may be reduced to several root normal forms depending on how far the subgraphs are reduced. An important subclass of graph rewriting systems is the class which is defined by the following restrictions: - all graphs are connected; - every rule has exactly one redirection which is a redirection from the root of the pattern to the root of the contractum (or when there is no contractum, to the root of a subgraph indicated in the pattern); - no rule is comparing (rewriting systems where multiple occurrences of variables on left-hand-sides are allowed are called \textit{comparing} or \textit{non left-linear}). No multiple occurrence of variables implies that it is impossible to pattern match on equivalency of nodeid's (sharing). In fact, a left-hand-side is always a graph without sharing (like a term); - a special reduction strategy is used: the \textit{functional} reduction strategy. Reducing graphs according to this strategy resembles very much the way execution proceeds in lazy functional languages (a full formal definition of this strategy can be found in Smetsers (1991)). This class will be called: \textit{Functional Graph Rewriting Systems (FGRS's)}. In an FGRS every rewrite implies that the root of the redex is redirected to another graph. Every node that after the rewrite is not connected to the root of the graph, is considered to be non-existent (\textit{garbage}). FGRS's serve as basis for Clean. Clean is an experimental functional language based on graph rewriting (Brus et al. (1987)). The language is designed to provide a firm base for functional programming. In particular, Clean is suitable and used as an intermediate language between functional languages and sequential machine architectures. Every Clean program is an FGRS. Although the proposed extensions are also meaningful in more general graph rewriting systems, throughout the rest of this paper it will be assumed that FGRS's are used. In all examples the Clean syntax will be used. The extensions to graph rewriting proposed in this paper are incorporated in a new intermediate language: Concurrent Clean (Eekelen et al. (1989)). For an intuitive understanding of what follows it is not necessary to know all details of FGRS's. Some general knowledge about graphs and functional languages will be sufficient. A few examples of FGRS's: \begin{verbatim} Hd (Cons a b) -> a ; Fib 0 -> 1 ; Fib 1 -> 1 ; Fib n -> +1 (Fib (-1 n)) (Fib (-1 n 2)) ; Second (Pair x y:(Cons a b)) -> y ; Ones -> x: Cons 1 x ; \end{verbatim} Every expression is actually a graph consisting of nodes. Each node contains a symbol and a possibly empty sequence of argument nodeid's. If these nodeid's are implicit, an ordinary tree structure is assumed. Using them explicitly before a \texttt{;}, one can define any graph structure. The last rule in the example is a typical graph rewrite rule containing a cycle in the right-hand-side. In many cases, the functional graph rewrite rules can intuitively be seen as ordinary function definitions. Each function has one or more alternatives which are distinguished by patterns on the left-hand-side of the definition. Symbols other than function symbols are called \textit{constructors} because they are usually used as data structures (i.e. constructs for defining new data types). For practical reasons some types are assumed to be predefined, such as \texttt{INT} or \texttt{BOOL}. Furthermore, some functions for arithmetic are assumed to be defined on these types, such as \texttt{+I} (i.e. integer increment) or \texttt{*I} (i.e. integer multiplication). 3 Extending FGRS's with Dynamic Process Creation: P-FGRS's The creation of parallel reduction processes, also called reducers, can be seen as a special case of influencing the order of evaluation. In FGRS's the reduction order is changed by means of annotations. These annotations, which have the form of a string placed between curly braces, can be assigned to both nodes and nodeid's. When the reduction strategy encounters an annotation it changes its default reduction order which will influence the way in which a result is achieved. Changing the reduction order is important if one wants to optimise the time and space behaviour of the reduction process. In sequential FGRS's only one annotation is defined indicating that the reduction of the annotated argument of a symbol (function or constructor) is demanded. From an operational point of view, this annotation, denoted by {!}, will force the evaluation of the corresponding argument before it is tried to rewrite the graph according to a rule definition of the symbol. Note that these annotations may make the reduction strategy partially eager instead of lazy. In formal reasoning about programs with {!} annotations on the left-hand-side it will always be true that the annotated argument will be in root normal form when the corresponding rule is applied. The semantics of annotations on the right-hand-side can be explained via transformations to sets of rules with left-hand-side annotations only. Intuitively, the transformation involves introducing an extra internal reduction with an annotated left-hand-side which forces evaluation before the rule is applied. The precise transformation for {!} can be found in Smetsers (1991). Example of a rule with a {!} on the right-hand-side: \[ \text{Gen} \ n \rightarrow \text{Cons} \ n \ (\text{Gen} \ \{!\} \ (+I \ n)) ; \] which is transformed into: \[ \text{Gen} \ n \rightarrow \text{Gen'} \ n \ (+I \ n) ; \] \[ \text{Gen'} \ n \ \{!\} \ m \rightarrow \text{Cons} \ n \ (\text{Gen} \ m) ; \] Process creation A single sequential reducer repeatedly chooses one of the redexes which are indicated by the reduction strategy and rewrites it. Interleaved reduction can be obtained by incarnating several sequential reducers which reduce different parts of the same graph. By using {!} annotations it is possible to influence the order in which the redexes are reduced by a single reducer. Now a new annotation is introduced: {!!}, to indicate that a new sequential reducer has to be created with the following properties: - the new reducer reduces the corresponding graph to root normal form after which the reducer dies; - the new reducer can proceed interleaved with the original reduction process; - all rewrites are assumed to be indivisible actions; - if for pattern matching or reduction a reducer needs access to a graph which is being rewritten by another reducer, the first reducer will wait until the second one has reduced the graph to root normal form. - for determining its redexes it uses the functional reduction strategy parameterized with {!} annotations. Considered operationally, if a {!!} annotation is encountered in the right-hand-side by a reducer, a new reducer is created after the redirection has been done (and if there is copying, also after the copying). If a {!!} annotation is specified on the left-hand-side, a new reducer is created just before the original reducer would reduce the corresponding function application. In reasoning about programs with {!!} annotations on the left-hand-side it will always be true that the annotated argument will have been reduced (by another reducer) to root normal form when the corresponding rule is applied. The meaning of {!!} on a left-hand-side can be explained via transformations to sets of rules with right-hand-side annotations only (Smetsers (1991)). Example of {!!} on the right-hand-side: \[ \text{Fib} \ 0 \rightarrow \ 1 \] \[ \text{Fib} \ 1 \rightarrow \ 1 \] \[ \text{Fib} \ n \rightarrow \ (+I \ (\{!!\} \ \text{Fib} \ (-I \ n \ 1)) \ (\{!!\} \ \text{Fib} \ (-I \ n \ 2))) ; \] Another way of looking at {!!} annotations is that they influence the overall reduction order. In this view, {!!} annotations are parameters of the overall reduction strategy. This overall reduction strategy will then indicate possibly more than one redex (every process may have a redex). The global reducer will make a non-deterministic choice out of the redexes indicated by the global strategy. So, in this way parallel reduction is modelled via (non-deterministic) interleaved execution of the individual reducers. In section 5 we will see how real parallel evaluation can be made possible. 4 Extending FGRS's with Lazy Copying: C-FGRS's A notion of graph copying is necessary if one wants to express explicitly the distribution of data in parallel environments. One would expect however that it is already possible to express graph copying in graph rewriting systems. Although this is indeed the case, it is rather complex. A function has to be defined which duplicates its argument. Evidently, the following definition only produces two pointers to the argument but it does not duplicate the argument itself! A graph sharing example: \[ \text{Duplicate } x \rightarrow \text{Pair } x \] The left graph reduces to the right graph which is illustrated in the following picture. The only way to access the structure of the argument is to use pattern matching. The only way to duplicate a constructor is to match on it on the left-hand-side and to create a new node with the same constructor on the right-hand-side. Such a rewrite rule is needed for every constructor that may appear. Furthermore, on the right-hand-side the graph structure of the argument has to be duplicated. To detect sharing multiple occurrences of the same nodeid on the left-hand-side should be introduced in FGRS's. Then, with many of such left-comparing rules (and a special strategy that handles left-comparing rules) a structure can be copied. The rules that define copying, are themselves part of the system which makes it difficult to reason about them because the copying gets intertwined with the rest of the evaluation. As a consequence, if such a structure contains redexes that have to be copied too the reduction strategy has to be changed again in order to prevent that the strategy indicates these redexes. So, extending the semantics of FGRS's with a special mechanism to explicitly copy graphs (possibly containing redexes) would considerably increase the expressive power of these graph rewriting systems. Eager copying To denote a graph g that should be copied, the node identifier that refers to the root of g is attributed with a subscript c. The c subscript can be placed on nodeid's of the right-hand-side only. The copying takes place after the contractum is built but before the root of the redex is redirected to the root of the contractum. All copies of one right-hand-side are simultaneously. Copying a graph g implies that an equivalent graph g' is made which has no nodes in common with the original graph g. During the copying no rewriting takes place. So, for every node of g (also for redexes) there is an equivalent node in g'. A graph copying example: \[ \text{Duplicate } x \rightarrow \text{Pair } x \] The new nodeid's are chosen in such a way that the structure is easily seen. This way of copying is also called \textit{eager copying} in contrast to lazy copying which is defined in the following sections. Lazy copying Take a graph containing redexes. The extension of explicit copying to graph rewriting introduces the possibility to copy this graph including all its redexes. We had already the possibility of sharing the graph. Unfortunately, there is nothing in between. However, duplication of work can be avoided by maintaining the sharing with the original graph as long as the corresponding function applications have not been evaluated. If after the evaluation to root normal form the copying is continued, the graph is duplicated after the work is done. But, also it can be useful to break up the sharing. Take for example a function application that delivers a large structure after relatively few reduction steps. If a graph containing such a function application is submitted to another processor then it is preferable not to reduce this application before the submission. Copying with the choice of maintaining or breaking up the sharing is called lazy copying. A node on which copying will be stopped temporarily, is called a deferred node. To denote a deferred node it is attributed with a subscript d. Because every node has an explicit symbol, it is syntactically convenient to attach the attribute of the node to the symbol of the node. Lazy copying implies that when a copy action hits a deferred node, the copying itself is deferred. The applied occurrence of the nodeid of the deferred node of which the (now deferred) copy was being made, will be administered as being a copying deferred nodeid. When a deferred node is in root normal form, the node will not longer be deferred. The actual copying may continue, but, as we shall see, this will only happen when this copy is demanded. The actual copy of a deferred node will not be deferred. Nodeid's of which the contents need to be known for matching, are according to the functional reduction strategy first reduced to root normal form. When a copying deferred nodeid is reduced this will trigger the continuation of the copying. A lazy copying example: \[ \begin{array}{l} \text{Start} \rightarrow \text{Duplicate (Fac}_d \ 6) \\ \text{Duplicate } x \rightarrow \text{Pair } x \ x_c \\ \text{Fac } 0 \rightarrow 1 \\ \text{Fac } n \rightarrow *I \ n \ (\text{Fac} (-I \ n)) \\ \end{array} \] the following rewrites occur: \[ \begin{array}{l} @1: \text{Start} \rightarrow @2: \text{Duplicate } @3, \rightarrow @4: \text{Pair } @3 \ @5, \rightarrow @3: \text{Fac}_d \ 6; @3: \text{Fac}_d \ 6; \\ @4: \text{Pair } @5 \ @5_c, \rightarrow @4: \text{Pair } @5 \ @5_c, \rightarrow @4: \text{Pair } @5 \ @5_15, \\ @5: 720_d; @5: 720; @5: 720, @15: 720; \\ \end{array} \] The nodeid attribute c in the graph is used to denote that that the nodeid is a copying deferred nodeid. Note that the c attribute was inherited when the nodeid @3 was redirected to @5 which corresponded with the reduction of the node. Do not confuse the c attribute in the graph with the c attribute in the rules which denotes that a copy action has to be started. The deferred attribute of the node @5 is taken away when it is recognized that the node is in root normal form. The rewrites are also shown in the following picture: Operational semantics of lazy copying In order to explain the semantics of lazy copying we introduce two special kind of indirection nodes are introduced: a D(eferred) node: this node indicates that the function it is pointing to has the deferred attribute. And a C(opy of such a deferred node) node: this node indicates that the graph it is pointing to still has to be copied: the copying is deferred. If on a right-hand-side nodeid n is attributed with the c subscript, all nodes accessible from n have to be copied such that the new graph structure is copy-equivalent with the old one. However, if the copy action hits on a D-node, a C-node which refers to the D-node is created and the subgraph to which the D-node refers is not copied. If the copy action hits on a C node, a new C node is created which has the same argument as the original C node. After the copying has been performed this way, this rewrite is finished and reduction continues as usual. D and C-nodes can be rewritten via the following internal reduction rules: \[ \begin{array}{l} \text{D } (!) \ x \rightarrow x \\ \text{C } (!) \ x \rightarrow x_c \\ \end{array} \] The strict annotations provide the property that a function application is "deferred" or "not yet copied" property is inherited by all intermediate function results until finally a root normal form is reached. Hereafter the reducer is able to apply the special rewrite rules for D and C which will make these nodes disappear. If the previous example is considered again, it should be more clear what the semantics are: \[ \begin{align*} @1: \text{Start} & \rightarrow \quad @2: \text{Duplicate } @1, \rightarrow \quad @4: \text{Pair } @1 @j, \rightarrow >> \\ @1: D @3, & \quad @1: D @3, \quad @1: C @1, \\ @3: \text{Fac } 6; & \quad @3: \text{Fac } 6; \quad @3: \text{Fac } 6; \\ @4: \text{Pair } @1 @j, & \quad @4: \text{Pair } @5 @j, \rightarrow \quad @4: \text{Pair } @5 @15, \\ @1: D @5, & \quad @1: D @5, \\ @3: C @1, & \quad @3: C @1, \\ @5: 720; & \quad @15: 720; \\ \end{align*} \] which is also illustrated in the following picture: Note that when the deferred copy turns out to be not needed by the reduction strategy, the C rule will never be executed, so the copying will not be continued. Properties of lazy copying An interesting aspect of lazy copying is that normal forms do not contain defer or copying deferred attributes. In a normal form every subgraph is trivially in root normal form. Evaluation of nodes to root normal form eliminates the defer attributes. Evaluation to root normal form and/or the attempt to access a node will cause the deferred copying to continue. Normal forms: With the following rule: \[ \begin{align*} \text{Start} & \rightarrow x: \text{Pair } 1 x; \\ \text{Start} & \rightarrow x: \text{Pair } d 1 x; \\ \text{Start} & \rightarrow x: \text{Pair } 1 x_c; \\ \text{Start} & \rightarrow x: \text{Pair } d 1 x_c; \\ \end{align*} \] this will be the normal form of Start: \[ \begin{align*} @1: \text{Pair } 1 @1; & \quad @1: \text{Pair } 1 @1; \quad @1: \text{Pair } 1 @1; \quad @1: \text{Pair } 1 @1; \\ @1: \text{Pair } 1 @3, & \quad @1: \text{Pair } 1 @3, \\ @3: \text{Fac } 6; & \quad @3: \text{Fac } 6; \\ @5: 720; & \quad @15: 720; \\ \end{align*} \] Lazy copying does influence the normal forms in the graph world. Sharing may be broken up when a cycle is copied which contains deferred nodes. The result will be partly unravelled with respect to a full copy. A typical example is given by the latter rewrite rule of the previous example. In C-FGRS's the normal form is also influenced by the order of evaluation (and hence by annotations). If the deferred nodes are not reduced before an attempt to copy them is made, the result will be partly unravelled. A typical example is given below. With the following rules: \[ \begin{align*} \text{Start} & \rightarrow r: A (F x), \\ x: B y, \\ y: (\{!\}) d z, \\ z: E x; \\ \end{align*} \] the normal form is: \[ \begin{align*} @1: A @13, & \quad @13: B @15, \\ @13: C @13, & \quad @15: B @15; \\ @13: E @13, & \quad @113: B @15; \\ \end{align*} \] without the \{!\} the normal form is: \[ \begin{align*} @1: A @13, & \quad @13: B @15, \\ @15: C @13, & \quad @113: B @15; \\ \end{align*} \] The unravelling of the normal forms of a rule system with lazy copying will always be the same as the unravelling of the normal forms of the same rule system without lazy copying. In other words unravelling is invariant with respect to lazy copying. This is an interesting property for the implementation of functional languages and for term graph rewriting as in Barendregt et al. (1957a). It seems that it enables the proof of the soundness and completeness of implementations which use sharing and copying via term graph rewriting. Lazy copying and term graph rewriting is a very promising topic for further research. With the \textit{copy} indication and the \textit{defer} indication lazy copying is introduced in graph rewriting systems. By introducing the possibility to use subtle combinations of sharing and copying this greatly improves the expressive power of graph rewriting systems. Furthermore, in the next section it will be shown that lazy copying can also be the basis for communication in a parallel environment. 5 The Descriptive Power of PC-FGRS’s In this section the power of the PC-FGRS’s is illustrated by showing how with certain combinations of process creation and lazy copying various kinds of process behaviours can be modelled. There are several kinds of behaviours one may be interested in, such as fine and coarse grain parallelism, all kinds of process topologies (hierarchical and non-hierarchical process topologies), synchronous and asynchronous communication between processes, etcetera. At first glance it may seem easy to specify these behaviours in PC-GRS’s, since there is the possibility to create reducers dynamically. However, note that a rewriting step is considered to be indivisible and without this assumption reasoning about rewriting systems is in general not possible. Still, of course, one would like to be able to create reducers of which the rewriting steps can be performed in parallel instead of interleaved. However, it should be clear that, without any restrictions, parallel rewriting causes problems. Imagine that a copy of a subgraph is made while another reducer is working on that subgraph. Problems may also arise when redirections are performed in parallel. Probably there will not be a problem when two reducers are running on subgraphs which have no node in common and no reference to each other. To call a reducer a \textit{parallel reducer} with respect to another reducer it has to be proven that the constraint that a rewrite step is indivisible action can be weakened. More precisely, it has to be proven that the corresponding rewrite steps cannot interfere with each other and therefore may be \textit{considered} as being indivisible so that they actually can be performed in parallel. This condition that has to be proven is also called the non-interference condition. Hence, the claim that parallel computations can be expressed in our model can only be justified by proving that, under specific conditions, certain reducers are parallel reducers with respect to certain other reducers. As in the introduction, we consider loosely coupled parallel machine architectures (each processor has its private memory) as the most interesting class of architectures. It should be clear that the kind of architecture the reduction is performed on influences the rewriting model. For instance, in a shared memory machine graph copying may be superfluous. 5.1 Modelling parallel rewriting on loosely coupled parallel architectures A loosely coupled parallel computer is defined as a multiprocessor system that consists of a number of self-contained computers, i.e. processors with their private memory attached to each other by a sparsely connected network. An important property of such system is that for each processor it is more efficient to access objects located in its own local memory than to use the communication medium to access remote objects. In order to achieve an efficient implementation it is necessary to map the computation graph to the physical processing elements in such a way that the communication overhead due to the exchanging of data is relatively small. Therefore, the computation graph is divided into a number of subgraphs (grains) which have the property that the intermediate links are sparsely used. Unfortunately, it is undecidable how much work the reduction of a subgraph involves. Furthermore, there are no well-established heuristics for dividing a graph into grains. So, this partition of the graph cannot automatically be performed. Therefore, in the program it has to be explicitly indicated what is expected to represent a large amount of reductions relative to the expected communication overhead. In this way the program can be tuned to a particular parallel machine architecture. The annotations and indications in the PC-FGRS have to be used in such a way that non-interference can be proven for reducers which might be executed on different processors. In order to avoid the need for a proof for every PC-FGRS methods of annotating and indicating will be developed. Using these methods will guarantee that parallel execution of groups of reducers is allowed. **Divide-and-Conquer evaluation** An obvious method to get safe parallelism is to create a reducer on a copy of an indicated subgraph. Such a copied subgraph has the property that it is self-contained, i.e. the root of the subgraph is the only connection between the subgraph and the rest of the graph. This will make it possible that the copied subgraph is reduced in parallel on another processor. When it is reduced to root normal form the result will be copied back to the father processor. So, copying is performed twice: one copy is made of the task for the off-loading of the task and one copy is made of the result to communicate it to the father. A self-contained subgraph will be regarded as a virtual processor because it has the property that it may be reduced on another processor. It is easy to prove that on a self-contained subgraph it is allowed to weaken the interleaving restriction to parallelism: the self-contained subgraph can only be accessed by other reducers via the root and the semantics of P-FGRS's does not allow reducers to access a node on which another reducer is running. *Example of a divide-and-conquer algorithm:* <table> <thead> <tr> <th>FIB 0</th> <th>1</th> </tr> </thead> <tbody> <tr> <td>FIB 1</td> <td>1</td> </tr> <tr> <td>FIB n</td> <td>left: {[!!]FIBd (-I n e 2),} right: {[!!]FIBd (-I n e 2) }</td> </tr> </tbody> </table> The following picture illustrates the virtual processor structure after one reduction of FIB 5: ![Virtual Processor Structure](image) This way of modelling divide-and-conquer algorithms relies on the fact that the subgraph to be reduced is self-contained and that after the reduction to root normal form, the result is also self-contained. Unfortunately, self-containedness is an undecidable property, for, if a lazy copy of a certain graph is made this graph may contain deferred nodes. But, as will be shown in the next section, it is possible to use a graph property that is on the one hand weaker than the property of self-containedness and, on the other hand, strong enough not to violate the non-interference requirement. **Modelling loosely coupled evaluation** A method which makes it possible to model process behaviours that are more general than divide-and-conquer, must provide a way to define arbitrary connections between processes and processors. The lazy copy scheme introduced in section 4 provides a way to make a self-contained copy on a lazy manner. Such a lazy copy is a self-contained subgraph with the exception of copying deferred nodeid's, which are references to deferred nodes in the graph. These deferred nodes will be copied later if they are in root normal form and needed for the evaluation. So, copying deferred nodeid's are natural candidates for serving as interconnections between parallel executing processes because they induce further copying when they are accessed. Therefore, communication between parallel processes can be realized via copying deferred nodeid's. In this context copying deferred nodeid's are also called communication channels or just channels. A subgraph is loosely connected if channels (copying deferred nodeid's) are the only connections between the subgraph and the rest of the graph. Note that this implies that a self-contained subgraph is loosely connected if its root is a channel. Also a loosely connected subgraph is regarded as a virtual processor because it has the property that it may be reduced on another processor. From now on the notion virtual processor stands for loosely connected subgraph. Several processes (reducers) can run on such a virtual processor. Processes running on the same virtual processor are running interleaved. So, there is interleaved multiprocessing on each virtual processor. Processes running on different virtual processors run in parallel. The semantics of copying deferred nodeid's implies that channels have the following properties. The flow of data through a channel is the reverse of the direction of the copying deferred nodeid in the graph. Since channels are nodeid's, they can be passed as parameters or copied. Now, suppose that a parallel process is reducing a loosely connected subgraph. This process may need the reduction of a channel connected to another processor. Of course, this channel cannot be reduced by the demanding process. It has to be reduced by another process running on the virtual processor which contains the graph to which the channel refers. Now, the demanding process will be suspended until the result has been calculated by the process running on the other processor. A channel can be used to retrieve an (intermediate) result in a demand-driven way, i.e. as soon as the result of a sub-reduction is needed a request for the result is made. This request will be answered if the corresponding result is in root normal form. Note that the channel vanishes after the result has been returned. Because the copying is lazy new channels may have come into existence. The question is now when the non-interference condition is fulfilled for reducers running on different virtual processors such that they can run in parallel instead of interleaved. The non-interference condition is satisfied if it can be guaranteed throughout the execution of the program that when a parallel reducer is demanding information from a channel which refers to another virtual processor, - this subgraph is either in root normal form (such that it can be lazy-copied to the demanding process) or, - there is a process running on the other virtual processor which is reducing the subgraph if it is not yet in root normal form (such that the demanding process will wait until the information has been reduced to root normal form). Virtual processors which satisfy these conditions are called loosely coupled virtual processors. It is possible to show that this allows the weakening of the restriction of interleaving to parallelism with respect to the loosely coupled virtual processors: parallel reducers running on different virtual processors work on different loosely connected subgraphs. They can only access subgraphs on other processors via copying deferred nodeid's (channels). The demanding reducer will wait if the information is not in root normal form because in that case another process is reducing the information. If the information is in root normal form a lazy copy is made. In that case the resulting graph, i.e. the original graph of the demanding reducer together with the copy that has been made, is also loosely connected. A method to create loosely coupled virtual processors The obvious way to guarantee that virtual processors are loosely coupled, is to create a reducer on every deferred node. Hence, when a deferred node is created, at the same time also a process is started which reduces the deferred node. So, when via a copy a channel will be created to the node, the node will already be in root normal form or a reducer is still reducing it to root normal form. First, we introduce two abbreviations \( \{e\} \) and \( \{i\} \) that can be put on a node \( n \). Example: \[ \text{Fib} \ n \quad \Rightarrow \quad +I \ \text{left} \ \text{right}, \\ \text{left}: \ \{i\} \ \text{Fib} \ \{-I \ n \ I\}, \\ \text{right}: \ \{e\} \ \text{Fib} \ \{-I \ n \ 2\} \] The \( \{e\} \) abbreviation (e for external) will create a new loosely coupled virtual processor together with an external reducer which reduces the corresponding loosely connected subgraph in parallel. To realize this, a channel to a lazy copy of the subgraph is made and a process is created to reduce this copy. The channel provides that a (lazy) copy of the result is returned if its value is demanded on other processors. In particular a lazy copy of the result is returned to the father process if it demands its value. The \( \{i\} \) abbreviation (i for internal) will create a new internal reducer on the same virtual processor which reduces the corresponding subgraph interleaved with the other processes on the same virtual processor. A deferred node to this subgraph is created which provides that a (lazy) copy of the result is returned if its value is demanded on other virtual processors (since all virtual processor are created via lazy copies, this demand will come via a channel). To realize this, a deferred node to the indicated subgraph is made and a process is created to reduce it. The \( \{e\} \) and \( \{i\} \) abbreviations may be used on the same positions as annotations. When an \( \{e\} \) or \( \{i\} \) abbreviation is put on a nodeid, this is equivalent with putting it on the node the nodeid belongs to. For each occurrence on a node a simple program transformation is made as follows: Each occurrence of: will be substituted by: \[ n : \{(e)\} \text{Sym } a_1 \ldots a_n \] \[ n : I x_c, \] \[ x : (!!) \text{Id } y_c, \] \[ y : \text{Sym } a_1 \ldots a_n \] A reducer is created by the \((!!)\) annotation, it will reduce a node which contains the identity function of a lazy copy of the annotated node \(\text{Sym } a_1 \ldots a_n\). The node on which the reducer is started, is itself deferred and a channel is immediately created to it via the copy in the new definition of the node \(n\). \[ n : \{(!!)\} \text{Id } x, \] \[ x : \text{Sym } a_1 \ldots a_n \] A reducer is created on a deferred node. All sharing is maintained. The nodeid's \(x\) and \(y\) in the substitution rules stand for nodeid's not used elsewhere in the rewrite rule. \(I\) is just the identity function: \(I x \rightarrow x\); the indirection nodes are only created to see to it that the copies are made correctly. In the following they are considered to be internal nodes. It can be proven that, when using the \((e)\) and \((i)\) abbreviations only (i.e. neither other defer or copy attributes nor other process annotations), it is guaranteed that each subgraph supplied with an \((e)\) denotes a loosely coupled virtual processor. So, the proposed abbreviations provide a method to create loosely coupled virtual processors which allows real parallel execution. 5.2 Examples of the use of the proposed method In this section some small examples are given illustrating the expressive power of the method for loosely coupled evaluation. Non-hierarchical process topology With the \((e)\) abbreviation parallel (sub)reduction can be created and distributed over a number of virtual processors. With the creation of internal processes by using \((i)\), multiprocessing can be realized on each virtual processor. The only way to refer to such an internal process is via its channel. If such a channel node is passed (via a lazy copy) to another virtual processor, a communication channel between this processor and the reducer on the original processor is established. In this way any number and any topology of communication channels between processes and processors can be set up. For instance, it is possible to model a cycle of virtual processors. An example of this is given at the end of this section. In the following example a simple non-hierarchical process topology is demonstrated. It serves the purpose of explaining how such process topologies can be expressed (it does not realistically implement the Fibonacci function). The \text{Fib} example using a non-hierarchical process structure (which is very unconventional for \text{Fib}): the second call of \text{Fib} will be executed on another virtual processor but the argument of that call is reduced internally on the virtual processor that also does the first call of \text{Fib}. \[ \text{Fib } 0 \rightarrow 1 \] \[ \text{Fib } 1 \rightarrow 1 \] \[ \text{Fib } n \rightarrow +I (\text{Fib } (-I n 1)) m, \] \[ m : \{e\} \text{Fib } o, \] \[ o : \{i\} -I n 2 \] which is equivalent to: \[ \text{Fib } 0 \rightarrow 1 \] \[ \text{Fib } 1 \rightarrow 1 \] \[ \text{Fib } n \rightarrow +I (\text{Fib } (-I n 1)) m, \] \[ m : I x_c, \] \[ x : (!!) \text{Id } y_c, \] \[ y : \text{Fib } o, \] \[ o : (!!) \text{Id } z, \] \[ z : -I n 2 \] So the following process topology is obtained (a snapshot of the program execution of \text{Fib } 5 is given): In the picture it is shown how the graph is distributed over two virtual processors. Channels are dashed. Note that the direction of the flow of data through a channel is the reverse of the direction of the corresponding reference in the graph. In the following, internal indirection nodes are not shown in pictures and their defer indications are added to the nodes they refer to. Asynchronous virtual processor communication with streams It is possible to model asynchronous communication between virtual processors, i.e. a virtual processor is already computing the next data before the previous data is communicated. To achieve this a family of internal processes has to be created connected to the communication channel between the processors. Each process computes a partial result which can be sent across the channel. Just before a process delivers the partial result (and dies) it creates a new process chained via a new channel to the delivered result. This new member of the family will compute the next partial result on the same way. For convenience sake, such a cascaded family of processes is often regarded as being one (asynchronously) sending process with some family name. The chain of channels is then regarded to be one channel. The total result which is copied, is sometimes called a stream. Note that this kind of stream is capable of sending over more than one node (a burst) at the same time. Furthermore, these streams can contain cyclic graphs such that cycles can be sent to another processor. A virtual processor may contain several such families each producing a stream via a chain of channels. In the case of the following filter example the virtual processor contains exactly one such process: Filter. It sends a stream via the channel to the process Print. The following example describes an asynchronous communication behaviour with streams: ``` Start list -> Print s, s: (e) Filter list 2 ; Filter Nil pr -> Nil 1 Filter (Cons f r) pr -> IF (=I (MOD f pr) 0) (Filter r pr) (NewFilter f r pr) ; NewFilter f r pr -> Cons f rest, rest: {i} Filter r pr ; ``` The main virtual processor creates a new virtual processor on which the Filter process is started. The channel s is the communication channel between the two processors. The function Filter removes from its first argument, which is a list, all the elements which are divisible by the number n. A part of the stream becomes available as soon as Filter has computed an element of the result list and a new interleaved Filter process has been created. It may start already computing the next element of the stream before the first is asked to be communicated. The partial stream result is a list containing the first element and a new channel reference to the new filtering process. Assume that the list to be filtered is the list containing the natural numbers from 1 to 7. Then the following situations can arise: Now the three list elements, root normal forms yielded by successive filter processes, can be shipped with one lazy copy action. Dynamically changing process topologies The sieve of Eratosthenes is a classical example which generates all prime numbers. A pipeline of virtual processors is created. On each processor a Sieve process (a family of processes actually) is running. Those Sieves hold the prime numbers in ascending order, one in each Sieve. Each Sieve accepts a stream of integers as its input. Those integers are not divisible by any of the foregoing primes in the pipeline. If an incoming integer is not divisible by the local prime as well, it is send to the ... next Sieve. A newly created Sieve accepts the first incoming integer as its own prime and outputs this prime and the channel of the next Sieve to a printing processor. After that it starts sieving. A virtual processor called Gen sends a stream of integers greater than one to the first Sieve. The Gen process and every Sieve process proceed in more or less the same way as the Filter process of the previous example. They all are actually families of processes servicing chains of channels. They are regarded as single processes. Every chain of channels is regarded as one channel. So Sieve1 holds 2 as its own prime, Sieve2 holds 3, Sieve3 holds 5, and so on. The printing process one by one receives the channel identifications from these sieves and collects the corresponding primes. Seen through the time this can be illustrated as follows (all arrows indicate flow of data on channels): The Sieve program: \[ \text{Start} \rightarrow \text{Print } s, \] \[ \text{s: (e) Sieve } g, \] \[ \text{g: (e) Gen 2} \] \[ \text{Sieve (Cons pr stream) } \rightarrow \text{Cons pr } s, \] \[ \text{s: (e) Sieve } f, \] \[ \text{f: (i) Filter stream pr} \] \[ \text{Gen n } \rightarrow \text{Cons n rest}, \] \[ \text{rest: (i) Gen (!) (+I n)} \] \[ \text{Filter (Cons f r) pr } \rightarrow \text{IF} (=I (MOD f pr) 0) \] \[ \text{(Filter r pr)} \] \[ \text{(NewFilter f r pr)} \] \[ \text{NewFilter f r pr } \rightarrow \text{Cons f rest}, \] \[ \text{rest: (i) Filter r pr} \] Note that when the {!} annotation in Gen would be left out, the increments of the integers would not be evaluated by Gen but by the first Sieve. Even worse: because the result of Gen is copied, the Sieve would have to recalculate every new integer by increments starting from 2. Cyclic process structures The next example shows how a cyclic process structure, i.e. a number of parallel reducer that are mutual dependent, can be created. This example has been extracted from quite a large program that implements Warshall’s solution for the shortest path problem. The full algorithm can be found in Eekelen (1988). First the intended reducer topology is given in a picture: This reducer structure can be specified directly in the following way: \[ \text{Start} \rightarrow \text{last:CreateProcs NrOfProcs last} \] \[ \text{CreateProcs 1 left } \rightarrow \text{Process 1 left} \] \[ \text{CreateProcs pid left } \rightarrow \text{CreateProcs (--I pid) new,} \] \[ \text{new: (e) Process pid left} \] CreateProcs is responsible for the generation of all the parallel reducers. This process, which will finally become the first reducer, has initially a reference to itself in order to make it possible to expand it to a cycle of reducers. Each reducer is connected to the next one, i.e. the one with the next pid number, by means of a channel. During the creation of the processes this channel is passed as a parameter called left. 5.3 Properties of the proposed method With the proposed abbreviations arbitrary process structure can be expressed clearly. Still one has to be careful with their use. Normally the abbreviations will be used to obtain a parallel version of an ordinary sequential program. In general the sequential program has to be transformed to create the wanted processes and process topologies. If the abbreviations of any parallel program are regarded as comments, again a sequential version of the program is obtained. In the given examples such a sequential version would yield the same result as the parallel version. Unfortunately, in general the normal form is not unique. In section 4 it was that the normal form in a C-FGRS depends on the order of evaluation. In section 3 it was explained that the overall reduction strategy of a P-FGRS is non-deterministic. Hence the normal form PC-FGRS will in general depend on the choices made by the reducer. Although the normal form is not unique, the different normal forms which can be produced are related. Modulo unravelling they are the same, i.e. if the normal forms are unravelled to terms, these terms are the same. This is a very important property. The consequence is that the use of PC-FGRS's as a base for the implementation of functional languages or of term rewriting systems is sound. In these cases first the terms are lifted to graphs and after reduction the graph in normal form will be unravelled to a term again. Then, always the same term will be yielded. 6 Discussion Related work The idea to use annotations (Burton (1987), Glauert et al. (1987), Goguen et al. (1986), Hudak & Smith (1986)) or special functions (Kluge (1983), Vree & Hartel (1988)) which control the reduction order is certainly not new. Some of them are introduced on the level of the programming language (Burton (1987), Hudak & Smith (1986), Vree & Hartel (1988)) while others are introduced on the level of the computational model (Glauert et al. (1987), Goguen et al. (1986), Kluge (1983). They all express that an indicated expression has to be shipped to another (or to some concrete) processor. Most annotations (Hudak & Smith (1986), Goguen et al. (1986), Kluge (1983), Vree & Hartel (1988)) are only capable of generating strict hierarchical "divide-and-conquer parallelism". Non-hierarchical process structures are possible in Burton's proposal. He proposes a call-by-name parameter passing mechanism (which must involve copying of some nodes) between mutual recursive functions. In DACTL (Glauert et al. (1987)), also based on Graph Rewriting Systems (Barendregt et al. (1987b)) there is no overall reduction strategy. This means that the reduction order is completely controlled by the annotations in the rewrite rules. This makes DACTL very suited for fine grain parallelism, but makes it very hard to reason about the overall behaviour of the program. In all proposals copying graphs from one processor to another and back is implicit and cycles cannot be copied. Some annotations (Burton (1987), Hudak & Smith (1986)) are not only used to control parallelism but also to control the actual load distribution. Annotations for load distribution are not yet incorporated in the model, primarily because virtual processors can be freely created on the level of the computational model. However, the specification of load distribution will be investigated in the future. Implementation aspects Efficient implementation of FGRS's is possible on sequential hardware (Brus et al. (1987), Smetsers (1989)). The ideas introduced in this paper are incorporated in the language Concurrent Clean (van Eekelen et al. (1989)). Type information (Plasmeijer & van Eekelen (1991)) and strictness information ((Nöcker (1988), Nöcker & Smetsers (1990)) play an important role. To investigate parallel programming a simulator for Concurrent Clean has been developed simulating multi-processing running. This simulator runs in any sequential C environment. Experiments with this implementation indicate that PC-FGRS's are in principle very suited for implementation on loosely coupled parallel architectures. Most problems that have to be solved are of a general nature: "How can a graph (with cycles) be shipped fast from one processor to another?", "What is the best suited algorithm for distributed garbage collection?", "What happens if one of the processors is out of memory or is completely out of order?". The efficiency of a parallel implementation will strongly depend on the solutions found for these general type of problems. These problems have to be solved for other kinds of concurrent languages too. Perhaps it is possible to adopt existing solutions. But also alternative solutions which take the special behaviour of GRS's into account are thinkable. Future work Besides the concepts introduced in this paper (lazy copying, annotations for dynamic process creation, abbreviations) we will add annotations for load distribution and add predefined rules such that frequently used process topologies (pipelines, array of processes) can easily be defined. Efficient implementation of Concurrent Clean are planned on loosely coupled multiprocessor systems (e.g. a Transputer rack). Developing an efficient implementation will also involve research to load balancing and garbage collection (without stopping all processors). The theoretical properties of PC-FGRS's will be further investigated. Especially in the context of term graph rewriting new results are envisaged. Using sharing and lazy copying, different ways of lifting term rewriting systems to graph rewriting systems can be investigated. Other strategies than the functional strategy may be interesting (van Eekelen & Plasmeijer (1986)). For instance, adding reducers following a non-deterministic strategy may be useful for the specification of process control, including scheduling and interrupts. 7 Conclusions In this paper two extensions of Functional Graph Rewriting Systems are presented: lazy copying and annotations to control the order of evaluation. The extensions are simple and elegant. The expressive power of a FGRS extended with both notions is very high. Multi-processing can be modelled as well as graph reduction on loosely coupled systems. Arbitrary process and processor topologies can be modelled, as well as synchronous and asynchronous process communication. The introduced abbreviations guarantee that the indicated subgraphs can be evaluated in parallel instead of interleaved. The abbreviations directly correspond with the notion of processes and processors and they are therefore relatively simple to use. The user-friendliness can be increased by creating libraries with functions which can create often used processor topologies like pipelines and arrays of processors. Efficient implementation of the proposed model on loosely coupled parallel architectures should be possible. Actual implementations are started. PC-FGRS's are very suited to serve as a base for the implementation of functional languages. Sequential functional languages can efficiently be implemented by translating them to FGRS's. The expressive power of the proposed abbreviations in PC-FGRS's and the properties of these systems will now make it also possible to exploit the potential parallelism in the programs successfully. References
{"Source-Url": "http://repository.ubn.ru.nl/bitstream/handle/2066/107657/107657.pdf?sequence=1", "len_cl100k_base": 13419, "olmocr-version": "0.1.53", "pdf-total-pages": 17, "total-fallback-pages": 0, "total-input-tokens": 41033, "total-output-tokens": 16125, "length": "2e13", "weborganizer": {"__label__adult": 0.0003705024719238281, "__label__art_design": 0.00042819976806640625, "__label__crime_law": 0.0003058910369873047, "__label__education_jobs": 0.0007085800170898438, "__label__entertainment": 9.119510650634766e-05, "__label__fashion_beauty": 0.00017440319061279297, "__label__finance_business": 0.00022792816162109375, "__label__food_dining": 0.0004086494445800781, "__label__games": 0.0006542205810546875, "__label__hardware": 0.0014629364013671875, "__label__health": 0.0005741119384765625, "__label__history": 0.00036454200744628906, "__label__home_hobbies": 0.00011599063873291016, "__label__industrial": 0.0006422996520996094, "__label__literature": 0.0004286766052246094, "__label__politics": 0.0003414154052734375, "__label__religion": 0.0007100105285644531, "__label__science_tech": 0.061126708984375, "__label__social_life": 8.386373519897461e-05, "__label__software": 0.005970001220703125, "__label__software_dev": 0.92333984375, "__label__sports_fitness": 0.0003554821014404297, "__label__transportation": 0.0008211135864257812, "__label__travel": 0.00024437904357910156}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 65474, 0.01941]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 65474, 0.57367]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 65474, 0.91364]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 4948, false], [4948, 9851, null], [9851, 14597, null], [14597, 19284, null], [19284, 22647, null], [22647, 26447, null], [26447, 29553, null], [29553, 34352, null], [34352, 38454, null], [38454, 43351, null], [43351, 47155, null], [47155, 50440, null], [50440, 53378, null], [53378, 58176, null], [58176, 63189, null], [63189, 65474, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 4948, true], [4948, 9851, null], [9851, 14597, null], [14597, 19284, null], [19284, 22647, null], [22647, 26447, null], [26447, 29553, null], [29553, 34352, null], [34352, 38454, null], [38454, 43351, null], [43351, 47155, null], [47155, 50440, null], [50440, 53378, null], [53378, 58176, null], [58176, 63189, null], [63189, 65474, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 65474, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 65474, null]], "pdf_page_numbers": [[0, 0, 1], [0, 4948, 2], [4948, 9851, 3], [9851, 14597, 4], [14597, 19284, 5], [19284, 22647, 6], [22647, 26447, 7], [26447, 29553, 8], [29553, 34352, 9], [34352, 38454, 10], [38454, 43351, 11], [43351, 47155, 12], [47155, 50440, 13], [50440, 53378, 14], [53378, 58176, 15], [58176, 63189, 16], [63189, 65474, 17]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 65474, 0.01036]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
f758777f5b43c17a55fc5747c6b1cd422531a87f
In publish/subscribe systems, subscribers express their interests in specific events and get notified about all published events that match their interests. As the amount of information generated increases rapidly, to control the amount of data delivered to users, we propose enhancing publish/subscribe systems with a ranking mechanism, so that only the top-ranked matching events are delivered. Ranking is based on letting users express their preferences on events by ordering the associated subscriptions. To avoid the blocking of new notifications by top-ranked old ones, we associate with each notification an expiration time. We have fully implemented our approach in SIENA, a popular publish/subscribe middleware system. 1. INTRODUCTION The publish/subscribe paradigm provides loosely coupled interaction among a large number of users of a large-scale distributed system. Users can express their interest in an event via a subscription and inject this subscription into the system. The system will then notify them whenever some other user generates (or publishes) an event that matches a previously made subscription. Users that generate such events are called publishers, while users that consume the published events are called subscribers. All published events that are relevant to at least one of a specific user’s subscription will eventually be delivered to this user. Typically, in publish/subscribe systems, all subscriptions are considered equally important. However, due to the abundance of information, users may receive overwhelming amounts of event notifications. In such cases, users would prefer to receive only a fraction of this information, namely the most interesting to them. For example, assume a user, say John, who is generally interested in drama movies. Specifically, John is more interested in drama movies directed by Tim Burton than drama movies directed by Steven Spielberg. Ideally, John would like to receive notifications about Steven Spielberg drama movies only in case there are no, or not enough, notifications about Tim Burton drama movies. In this paper, we advocate using some form of ranking among subscriptions, so that users can express the fact that some events are more important to them than others. To rank subscriptions, we use preferences. A variety of preference models have been proposed, most of which follow either a quantitative or a qualitative approach. In the quantitative approach (e.g. [5, 13]), users employ scoring functions that associate a numeric score with specific data to indicate their interest in it. In the qualitative approach (e.g. [8, 12, 11]), preferences between two data items are specified directly, typically using binary preference relations. To express priorities among subscriptions, we first introduce preferential subscriptions, that is, subscriptions enhanced with interest scores following the quantitative preference paradigm. Based on the subscription scores, we propagate to users only the notifications that are the most interesting to them. We extend this idea to encompass qualitative preferences. Based on preferential subscriptions, we introduce a top-k variation of the publish/subscribe paradigm in which users receive only the k most interesting events as opposed to all events matching their subscriptions. Since the delivery of notifications is continuous, we introduce a timing dimension to the top-k problem, since without some notion of freshness, receiving top-ranked notifications would block for ever the delivery of any new, less interesting notifications. To this end, we associate an expiration time with each notification, so that, notifications for old events will eventually die away and let new ones be delivered to the users. To locate the subscriptions that match a specific event notification efficiently, we adopt a graph-based representation of subscriptions, called preferential subscription graph. Subscriptions correspond to nodes in the graph and edges point from more general to more specific subscriptions. Our prototype implementation, PrefSIENA [3], extends SIENA [6], a popular publish/subscribe middleware system, by including preferential subscriptions and top-k notification delivery. We report some preliminary experimental results that compare the number of notifications delivered by PrefSIENA with respect to the corresponding number in the case of the original SIENA system. The rest of this paper is structured as follows. In Section 2, we introduce preferential subscriptions, that is, subscriptions augmented with interest scores. We also propose time-valid notifications by associating expiration times with notifications. In Section 3, we focus on how to compute the top-k notifications based on preferential subscriptions and time-valid notifications, while in Section 4, we extend pref- 2. PREFERENTIAL MODEL In this section, we first describe a typical form of notifications and subscriptions used in publish/subscribe systems. Then, we introduce an extended version of subscriptions that include the notion of preferences. Also, we extend the definition of notifications to include the notion of time validity. 2.1 Publish/Subscribe Preliminaries A publish/subscribe system is an event-notification service designed to be used over large-scale networks, such as the Internet. Generators of events, called publishers, can publish event notifications to the service and consumers of such events, called subscribers, can subscribe to the service to receive a portion of the published notifications. Publishers can publish notifications at any time. The notifications will be delivered to all interested subscribers at some point in the future. Architecture: In general, a publish/subscribe system [9] consists of three parts: (i) the publishers that provide events to the system, (ii) the subscribers that consume these events and (iii) an event-notification service that stores the various subscriptions, matches the incoming event notifications against them and delivers the notifications to the appropriate subscribers. As shown in Figure 1, the event-notification service provides a number of primitive operations to the users. The publish() operation is called by a publisher whenever it wishes to generate a new event. The subscribe() operation is called by a subscriber whenever it wants to receive a portion of the published notifications. The event-notification service can use the notify() operation whenever it wants to deliver a notification to a subscriber. An event-notification service can be implemented using a centralized or a distributed architecture, that is, we may have one or a set of servers responsible for the process of matching notifications to subscriptions. Definitions: - **Definition 1 (Notification).** A notification \( n \) is a set of typed attributes \( \{a_1, \ldots, a_p\} \), where each \( a_i \), \( 1 \leq i \leq p \), is of the form \( (a_i, \text{type } a_i, \text{name } a_i) \). - **Definition 2 (Subscription).** A subscription \( s \) is a set of attribute constraints \( \{b_1, \ldots, b_q\} \), where each \( b_i \), \( 1 \leq i \leq q \), is of the form \( (b_i, \text{type } b_i, \text{name } \theta_i, \text{value } \theta_i) \), \( \theta_i \in \{=, <, >, \leq, \geq, \neq, \text{substring}, \text{prefix} \text{, and suffix} \} \). Matching notifications to subscriptions: Intuitively, we can say that a notification \( n \) matches a subscription \( s \), or alternatively a subscription \( s \) covers a notification \( n \), if and only if every attribute constraint of \( s \) is satisfied by some attribute of \( n \). Formally: - **Definition 3 (Cover Relation).** Given a notification \( n \) of the form \( \{a_1, \ldots, a_p\} \) and a subscription \( s \) of the form \( \{b_1, \ldots, b_q\} \), \( s \) covers \( n \) if and only if \( \forall b_i \in s, \exists a_j \in n \) such that \( b_i, \text{type } a_j, b_i, \text{name } a_j, b_i, \text{name } a_j \) and it holds \( ((a_j, \text{value } \theta_i, (b_i, \text{value})), 1 \leq i \leq p, 1 \leq j \leq q) \). A notification \( n \) is delivered to a user if and only if the user has submitted at least one subscription \( s \), such that \( s \) covers \( n \). For example, the subscription of Figure 3 covers the notification of Figure 2 and therefore, this notification will be delivered to all users who have submitted this subscription. 2.2 Preferential Subscriptions In this paper, we extend the publish/subscribe paradigm to incorporate ranking capabilities. Assuming that each user has defined a set of preferences, then this user should receive a newly published notification, if and only if, the notification describes an event that is more preferable to the user than any previously received event. To express preferences along with subscriptions, we can follow either the quantitative or the qualitative approach. For simplicity reasons, we first consider the quantitative preference model, while in Section 4, we apply qualitative preferences. A preferential subscription is a subscription enhanced with a numeric score. The higher the score, the more interested the user is in notifications covered by this specific subscription. These scores can have any real value. We assume here that they take values within the range $[0,1]$. An example of a preferential subscription is shown in Figure 4. **Definition 4 (Preferential Subscription).** A preferential subscription $ps_X^n$, submitted by user $X$, is of the form $ps_X^n = (s_i, score_{s_i}^X)$, where $s_i$ is a subscription and $score_{s_i}^X$ is a real number within the range $[0,1]$. Assuming that a user $X$ defines a set of preferential subscriptions $P_X^n$, we use the user’s preferential subscriptions to rank the published notifications and deliver to the user only the top-$k$ notifications, i.e. the $k$ highest ranked ones (where $k$ is a user-defined parameter). We define the score of a notification to be the largest among the scores of the subscriptions that cover it: **Definition 5 (Notification Score).** Assume a notification $n$, a user $X$ and the set $P_X^n$ of the user’s preferential subscriptions. Assume further the set $P_P^n = \{(s_1, score_{s_1}^X), \ldots, (s_m, score_{s_m}^X)\}$, $P_P^n \subseteq P_X^n$, for which $s_i$ covers $n$, $1 \leq i \leq m$. The notification score of $n$ for $X$ is equal to $sc(n,X) = \max \{score_{s_1}^X, \ldots, score_{s_m}^X\}$. A newly published notification $n$ is delivered to a user $X$, if and only if, it is covered by some subscription $s$ previously issued by $X$ and $X$ has not already received $k$ notifications more preferable to $n$. A notification $n_1$ is more preferable for user $X$ to a notification $n_2$, if and only if, it has a higher notification score for $X$ than $n_2$. In general, we assume that scores are indicators of positive interest, thus, we use the maximum value of the corresponding subscriptions. One could argue for other ways of aggregating the scores, for instance using the mean, minimum or a weighted sum. Yet, an alternative way would be to use only the scores of a subset of $P_P^n$, namely the most specific subscriptions. A similar notion for preferences is introduced in [15]. For example, assume the notification of Figure 2 and the preferential subscriptions $\{(\text{genre} = \text{fantasy}), 0.7\}$ and $\{(\text{genre} = \text{fantasy}, \text{director} = \text{P. Jackson}), 0.6\}$ (for ease of presentation we omit the type of each attribute). The second subscription is more specific than the first one, in the sense that in the second subscription the user poses an additional, more specific requirement to movies than in the first one, and so, the score of the first one should be ignored. Formally, a subscription $s \in P_P^n$ is a most specific one if no other subscription in $P_P^n$ covers it (see Definition 7). We leave as future work a user study to evaluate the appropriateness of the different methods for assigning scores. In general, all such methods may increase the complexity of the process of matching notifications to subscriptions, since in traditional publish/subscribe, for matching to be completed successfully, it suffices to find just one subscription that covers the notification, whereas for computing the notification score, we may need to locate all covering subscriptions. ### 2.3 Time-Valid Notifications In a publish/subscribe system, where new event notifications are constantly produced, the following problem may arise: it is possible for very old but highly preferable notifications to prevent newer notifications from reaching the user. Specifically, after receiving $k$ very highly preferable notifications, the user will receive no new ones unless they are ranked higher, something that may not be desirable. For instance, consider the example of Figure 5. For simplicity, we assume a single user, say John, who has defined the following preferential subscriptions for movies: John has assigned score 0.9 to comedies and score 0.8 to dramas. Assume that a movie theater generates the notifications for movies: John is interested in the top-2 results. $n_1$ will be delivered to John, since it is the first notification that is covered by his subscriptions. $n_2$ will also be delivered, since it is the second best result seen up to this moment. $n_3$ is equally preferred to $n_1$ and will therefore also be delivered to John (replacing $n_2$ in the current top-2 results). Since $n_4$, $n_5$ and $n_6$ are less preferable to the current top-2 results, none of them will be delivered to John. Assuming that notifications are published one hour prior to the showing time, if John checks his top-2 results at 22:30 he will only find movies that he can no longer watch (the top-2 results at 22:30 are marked with gray color), even though other interesting movies that start at 23:00 have been published. To overcome this problem, we need to define the subset of notifications over which the top-$k$ notifications for each user will be located. One solution would be to split time in periods of duration $T$ and at each time instance, deliver a notification to the user, if the user has not already received, during the current period, $k$ notifications with higher scores. However, since top-$k$ computation starts anew in the beginning of each period, the rank of events received by the user may end up being rather arbitrary. For example, high-ranked notifications appearing in periods with many other high-ranked ones may not be delivered to the user, whereas low-ranked publications appearing in periods with a small number of high-ranked ones may be delivered. A more general approach is to associate each published notification $n$ with an expiration time $n.exp$. The notification is considered valid only while $n.exp$ has not expired. The top-$k$ results for each user are defined over the subset of valid notifications. This way, older notifications which have expired do not prevent valid ones from reaching the user even if they are more preferable than those. Considering the previous example, assume that each notification expires at the showing time of the corresponding movie (see Figure 6). $n_1$, $n_2$ and $n_3$ will be delivered to the user as before. By the time \( n_4 \) is published (22:00), \( n_1, n_2 \) and \( n_3 \) have expired and therefore, \( n_4 \) will also be delivered to the user. \( n_5 \) and \( n_6 \) will be delivered as well, since they are equally preferred as the notifications in the top-2 at the time of their publication. Notice that the periodic approach is a special case of the expiration-time one. By setting the expiration time of each notification equal to the ending time of their publication. Notice that the periodic approach and the expiration-time one are the same results as with the periodic approach. Based on the assumption that published notifications are valid only for a specific time period, next we define which ones belong to the top-\( k \) notifications for a user. **Definition 6** (Top-\( k \) Notifications). Assume a user \( X \) and \( P^X \) the set of \( X \)'s preferential subscriptions. A notification \( n \) published at time \( t \) belongs to the top-\( k \) notifications of \( X \), if and only if, \( n \) is covered by at least one subscription \( s \) appearing in a preferential subscription \( ps \in P^X \) and \( X \) has not already received \( k \) notifications \( n_1, \ldots, n_k \) with \( n_i.exp > t \) and \( sc(i, X) > sc(n, X) \), \( 1 \leq i \leq k \). An alternative way to set the expiration time for a notification would be to let the user define a refresh time along with each subscription. This can be also expressed through defining appropriate values of the expiration time for notifications as follows. Assuming that a notification \( n \) is covered by a user subscription \( s \) associated with a refresh time \( r \), then the expiration time of \( n \) could be set to \( t + r \), where \( t \) is the time that \( n \) is sent to the user. Note that in this approach, a specific notification does not have a single expiration time but instead, it is associated with a different one for each user. 3. RANKING IN PUBLISH/SUBSCRIBE In this section, we introduce a preferential subscription graph for organizing our preferential subscriptions. We also present an algorithm for computing the top-\( k \) results and discuss the server topology. 3.1 Preferential Subscription Graph To reduce the complexity of the matching process between notifications and subscriptions, it is useful to organize the subscriptions using a graph. We use preferential subscriptions to construct a directed acyclic graph, called preferential subscription graph, or PSG. To form such graphs, we use the cover relation between subscriptions defined as follows. ![Figure 6: Top-2 notifications for a single user at 22:30 (with expiration time used).](image) ![Figure 7: Preferential subscription graph example.](image) subscription graph $PSG$. In the next section, we generalize our approach for more servers. This single server acts as an access point for all subscribers and publishers. Although publish/subscribe systems are typically stateless, in the sense that they do not maintain any information about previous notifications, here, we need to maintain some information about previously sent top-ranked notifications. The server maintains a list of $k$ elements for each of the subscribers (users) that are connected to it. These lists contain elements of the form (score, expiration) where score is a numeric value and expiration is a time field. The score part of such a pair represents the score of a notification that has already been delivered to the corresponding user and expires at time expiration. Only the scores corresponding to the top-$k$ most preferable valid notifications that have been already sent to the users appear in these lists. All lists are initially empty. Whenever the server receives a notification $n$, it walks through its $PSG$ to find all subscriptions that cover $n$. For each subscriber $j$ associated with at least one of these subscriptions, a score $sc(n, j)$ is computed: assuming that $m$ subscriptions $s_1, s_2, \ldots, s_m$ submitted by $j$ cover $n$, then $sc(n, j) = max\{score_1, score_2, \ldots, score_m\}$. After that, the corresponding list, denoted $list^j$, is checked and all elements which have expired are removed. If $list^j$ contains less than $k$ elements, $n$ is forwarded to $j$ and the pair $(sc(n, j), n.exp)$ is added to the list, where $n.exp$ is the expiration time of $n$. Otherwise, $n$ is forwarded to $j$ only if $sc(n, j)$ is greater or equal to the score of the element with the minimum score in the list. In this case, this element is replaced by $(sc(n, j), n.exp)$. Note that, a more recent notification equally important to an older one is forwarded to the user to favor fresh data over equally-ranked old ones. The process described above is summarized in the Forward Notification Algorithm shown in Algorithm 1. Next, we prove the completeness and correctness of Algorithm 1. First, we will show that if a notification $n$ belongs to the top-$k$ results of user $j$, then it will be forwarded to $j$. Assume for the purpose of contradiction, that such a notification is not forwarded to $j$. Let $sc(n, j)$ be the score of $n$ for $j$. Since $n$ is not forwarded to $j$, there exist $k$ valid notifications $n_1, \ldots, n_k$ with scores $sc(n_1, j), \ldots, sc(n_k, j)$ such that $sc(n_i, j) > sc(n, j), 1 \leq i \leq k$. This means that $n$ does not belong to the top-$k$ results of user $j$, which violates our assumption. Next, we proceed with showing that if a notification $n$ is forwarded to $j$, then it belongs to the user’s top-$k$ results. For the purpose of contradiction, assume that $n$ does not belong to the user’s top-$k$ results. This means that there exist $k$ valid notifications $n_1, \ldots, n_k$ with scores $sc(n_1, j), \ldots, sc(n_k, j)$ such that $sc(n_i, j) > sc(n, j), 1 \leq i \leq k$. Therefore, according to Algorithm 1 (line 21), $n$ will not be forwarded to $j$, which is a contradiction. Note that it is not necessary to walk through all nodes of the preferential subscription graph to locate the subscriptions that cover a specific notification. We may safely ignore a node $v$ with subscription $s$ for which there is no other node $v'$ with subscription $s'$, such that $s'$ covers $s$ and at the same time $s'$ covers $n$. This way, entire paths of the graph can be pruned and not used in the matching process. ### 3.3 Hierarchical Topology of Servers An event-notification service can be implemented over various architectures. At one extreme, a centralized approach can be followed, e.g. [10]. In this case, a single server gathers all subscriptions and notifications and carries out the matching process. However, due to the nature of such systems, where participants are physically distributed across the globe, a distributed architecture is more scalable. When more than one server exists in the network, each server runs Algorithm 1 for its own preferential subscription graph. Notifications are propagated among servers based on the server topology. The servers of the system are responsible for collecting all the published notifications and carrying out the selection process, i.e. delivering each notification only to the subscribers that have declared their interest to it. We consider a hierarchical topology, where the servers that implement the event-notification service are connected to each other to form a hierarchy. Each publisher and subscriber is connected to one of the servers in the hierarchy. Furthermore, we wish to organize the participants of the network in an efficient way, i.e. in a way that will reduce the number of messages exchanged between the servers and the complexity of the maintained data structures. One way to achieve this is by placing subscribers with similar subscriptions nearby in the hierarchy, so that the notifications covered by those subscriptions need to be propagated only toward this part of the hierarchy. While in most publish/subscribe systems, new subscribers randomly select a server to connect to, in our approach, when a new subscriber enters the network it probes a number of servers and chooses one of them according to a number of criteria: - **(Criterion 1)** The number of new nodes added to the highest level of the server’s preferential subscription graph. The smaller the number of such nodes, the --- **Algorithm 1 Forward Notification Algorithm** **Input:** A notification $n$ and a preferential subscription graph $PSG$. **Output:** The set of subscribers $Reset$ will be forwarded to. ``` 1: Begin 2: ResSet = Ø; 3: tmpW = Ø; /* temporary score set */ 4: for all nodes $v_i$ in $PSG$ do 5: if $s_i$ covers $n$ then 6: $tmpW = tmpW \cup W_i$; 7: end if 8: end for 9: for all subscribers $j$ that appear in $tmpW$ do 10: $sc(n, j) = max\{score^1, \ldots, score^m\}$, where $(j, score^i_j) \in tmpW, 1 \leq i \leq m$; 11: for all elements $i$ in list$^j$ do 12: if $i$ has expired then 13: remove $i$ from list$^j$; 14: end if 15: end for 16: if list$^j$ contains less than $k$ elements then 17: add $(sc(n, j), n.exp)$ to list$^j$; 18: ResSet = ResSet $\cup$ $j$; 19: else 20: find the element $i$ of list$^j$ with the minimum score; 21: if $sc(n, j) > i.score$ then 22: remove $i$ from list$^j$; 23: add $(sc(n, j), n.exp)$ to list$^j$; 24: ResSet = ResSet $\cup$ $j$; 25: end if 26: end if 27: end for 28: return ResSet; 29: End ``` fewer the additional notifications that should be propagated to the server in the future. • (Criterion 2) The number of nodes in the server’s preferential subscription graph. Fewer the nodes in the graph, the lower the complexity of searching it. A new subscriber \( X \) chooses a server to subscribe according to the above criteria. For instance, \( X \) may first use Criterion 1, and in case of a tie, Criterion 2. For example, consider the case of Figure 8a where there are two servers, Server A and Server B, both already storing some user subscriptions from subscribers \( X_1 \) and \( X_2 \). Assume that a new subscriber \( X_3 \) wishes to insert a new preferential subscription \( \{ \text{genre} = \text{comedy}, \text{length} > 120 \} \) to the system. If \( X_3 \) chooses Server A to subscribe, the result will be the one shown in Figure 8b. If \( X_3 \) chooses Server B, the result will be the one shown in Figure 8c. Using the first criterion, \( X_3 \) will choose to join Server A because in this case no new nodes will be added to the highest level of the PSG of Server A and thus, no new message traffic will be generated (except from the messages sent from Server A to \( X_3 \)). 4. SUBSCRIPTIONS USING A QUALITATIVE MODEL Preferential subscriptions as defined in Section 2.2 exploit the notion of quantitative preferences. Here, we discuss how to express preferential subscriptions using a qualitative preference model. Assume that a user \( X \) provides a set of subscriptions \( S^X_P \). To define choices between subscriptions, \( X \) expresses priority conditions of the form \( s_i \succ s_j, s_i, s_j \in S^X_P \), to denote that \( s_i \) is preferred to \( s_j \) for \( X \). Let \( C^X \) be the set of priority conditions expressed by user \( X \), i.e. \( C^X = \{ (s_i \succ s_j) \mid s_i, s_j \in S^X_P \} \). To extract the most preferable subscriptions \( C^X \), we use the winnow operator [8]. In particular, the first application of the winnow operator returns the set \( \text{win}_X(1) \) of subscriptions \( s_i \in S^X_P \) such that \( \forall s_i \in \text{win}_X(1) \) there is no \( s_j \in S^X_P \) with \( s_j \succ s_i \). If we would like to retrieve further the most preferable subscriptions after the ones included in \( \text{win}_X(1) \), we apply the winnow a second time. \( \text{win}_X(2) \) consists of the subscriptions \( s_i \in (S^X_P - \text{win}_X(1)) \) such that \( \forall s_i \in \text{win}_X(2) \) there is no subscription \( s_j \in (S^X_P - \text{win}_X(1)) \) with \( s_j \succ s_i \). The winnow operator may be applied until all subscriptions are returned. To locate the subscriptions that belong to a specific winnow result set, we define the multiple level winnow operator. DEFINITION 10. (MULTIPLE LEVEL WINNOW OPERATOR). Assume a user \( X \) and let \( S^X_P \) be the set of \( X \)’s subscriptions. Let \( C^X \) be the set of priority conditions of \( X \), the multiple level winnow operator at level \( l > 1 \), returns a set of subscriptions \( \text{win}_X(l) \), consisting of the subscriptions \( s_i \in S^X_P - \cup_{j=1}^{l-1} \text{win}_X(q) \) such that \( \forall s_i \in \text{win}_X(l) \) \( \exists s_j \in S^X_P - \cup_{j=1}^{l-1} \text{win}_X(q) \) with \( s_j \succ s_i \) \( \in C^X \). To compute the top-\( k \) results for each user when priority conditions between subscriptions are specified, we modify the process described in Algorithm 1 as follows. Assume that a user \( X \) wishes to insert a new preferential subscription \( \{ \text{genre} = \text{comedy}, \text{length} > 120 \} \) to the system. For example, consider the case of Figure 8a where there are two servers, Server A and Server B, both already storing some user subscriptions from subscribers \( X_1 \) and \( X_2 \). Assume that a new subscriber \( X_3 \) wishes to insert a new preferential subscription \( \{ \text{genre} = \text{comedy}, \text{length} > 120 \} \) to the system. If \( X_3 \) chooses Server A to subscribe, the result will be the one shown in Figure 8b. If \( X_3 \) chooses Server B, the result will be the one shown in Figure 8c. Using the first criterion, \( X_3 \) will choose to join Server A because in this case no new nodes will be added to the highest level of the PSG of Server A and thus, no new message traffic will be generated (except from the messages sent from Server A to \( X_3 \)). 5. EVALUATION To evaluate our approach, we have extended the SIENA event notification service [4], a multi-threaded publish/subscribe implementation, to include preferential subscriptions. We refer to our implementation as PrefSIENA. Our source code is available for download at [3]. System Description: To evaluate the performance of our model, we use a real movie-dataset [2], which consists of data derived from the Internet Movie Database (IMDB) [1]. The dataset contains information about 58788 movies. For each movie the following information is available: title, year, budget, length, rating, MPAA and genre. Each publisher randomly selects \( m_P \) numbers from 1 to 58788. For each of the corresponding \( m_P \) movies, the pub- lisher creates a new notification consisting of the title, year, length, rating, MPAA and genre of the movie. An example of such a notification can be seen in Figure 9. Each subscriber generates $m_S$ subscriptions and each subscription is generated independently from the others. We randomly select a number of the available attributes to appear in a subscription. The value of each attribute can be generated using either a uniform (i.e. all values are equally preferable) or a zipf distribution (i.e. some values are more popular) according to the values appearing in the dataset. In both cases, a subscription is associated with a numeric score uniformly distributed in $[0, 1]$. Subscription examples can be seen in Figure 10. $\begin{align*} \text{string genre} &= \text{Romance} \\ \text{integer length} &> 120 \\ \text{string mpaa} &= \text{PG-13} \end{align*}$ $\begin{align*} \text{string genre} &= \text{Drama} \\ \text{integer length} &> 100 \\ \text{integer year} &< 1980 \\ \text{integer rating} &> 6 \end{align*}$ Figure 10: Generated subscriptions. **Experiments:** To run our experiments, we assume a network in which each computer node can act as a publisher, subscriber or server. A combination of these roles is also possible. The servers are organized in a hierarchical topology while clients (i.e. publishers and subscribers) can be connected to any one of the servers. Each involved client executes a series of service requests. More specifically, each publisher generates a number of notifications and injects them into the network. All notifications expire after time $\tau$ of their publication. Each subscriber generates a number of subscriptions and chooses a server to connect to and subscribe. After that, each subscriber waits for notifications to arrive. In general, the number of delivered notifications depends on the covering relations between the various subscriptions and published notifications, the scores associated with these subscriptions and the order in which notifications are generated. The notification receipt rate for each individual user can be fine-tuned by letting the user define appropriate values for refreshing the subscriptions (so that the expiration times of the corresponding notifications are set accordingly) and by selecting $k$. First, we measure the number of notifications delivered to a specific subscriber using PrefSIENA as a function of the number $k$ of the top results the subscriber is interested in. We run this experiment with 100 matching events and for expiration time $\tau$ equal to $15t$ and $20t$, where $t = 500\text{ms}$ is the time length between the generation of two notifications. Note that $t$ refers to real, and not simulated, time. We consider the following two scenarios. In the first one, *scenario 1*, most of the notifications with higher scores for the user are published early, while in the second one, *scenario 2*, notifications with higher scores arrive towards the end. We observe that in the first scenario the user receives fewer notifications than in the second one (Figure 11). This happens because in the first scenario, where notifications with higher scores arrive first, many of the notifications with lower scores cannot enter the top-$k$ results, until some of the first ones expire. In the second scenario, however, the user receives both the notifications with the lower scores that arrive first and the notifications with higher scores that arrive later. In both scenarios, the number of delivered notifications decreases with the increase of the expiration time. This happens because notifications with higher scores for the user remain in the top-$k$ results for a longer time period and prevent notifications with lower scores from reaching the user. Furthermore, we measure the number of notifications delivered to a number of different users in the following cases: (i) using SIENA, (ii) using PrefSIENA with no expiration time for notifications and (iii) using PrefSIENA with a number of different expiration times. The number of published events is 200 and their expiration time $\tau$ takes values from $t$ to $60t$, where $t = 500\text{ms}$. All subscribers submit 5 different subscriptions and are interested in the top-1 result. We select to show results for three users according to the percentage of delivered notifications in PrefSIENA over the number of notifications in SIENA. For user 1, the percentage values are 27% and 15% respectively. In Figure 12, we depict the results for these three users. We count the percentage of delivered notifications in PrefSIENA over the number of notifications in SIENA. By varying the expiration time, we can achieve different notification receipt rates. This rate depends on the scores of users subscriptions, and also, on the specific time that various notifications in the top-$k$ results expire, as shown by the previous experiment. We also experimented with using the clustering criteria described in Section 3.3 during bootstrapping. We observed a 27% reduction on average of the total messages exchanged between nodes of the system, even though in this case we have an overhead of extra messages during bootstrapping. 6. RELATED WORK Although there has been a lot of work on developing a variety of publish/subscribe systems, there has been only little work on the integration of ranking issues into publish/subscribe. Recently, [18] considers the case of continuous queries in distributed systems. In this approach, only a subset of publishers provide notifications for a specific query. These publishers are selected according to the similarity of their past publications to the query. Similarity is computed via IR techniques. In [17], user preferences are employed to deliver newly added documents of a digital library to the users. Next, we discuss work related to publish/subscribe systems and preferences. Publish/Subscribe Systems: The publish/subscribe paradigm can be applied to a number of different architectures. The naive approach is to gather all subscriptions and events to a specific node. This node will be responsible for managing subscriptions, matching the incoming events against them and notifying the appropriate subscribers. This is a centralized approach (e.g. [10]). Often, in publish/subscribe systems the number of participating nodes becomes very large. For scalability reasons, a distributed architecture seems to be more suitable. In this case, the event service is implemented via a network of interconnected servers who act as a middle level for the communication of publishers and subscribers. Various distributed architectures such as hierarchical [6] and DHT-based [7] ones, have been proposed. There are two widely used methods for users to express their subscriptions: the topic-based method and the content-based one. In the topic-based method (such as [14]) there are a number of predefined event topics, usually identified by keywords. Published events are associated with a number of topics. Users can subscribe to a number of individual topics and receive all events associated with at least one of these topics. In the content-based method [6, 7], such as the one used in this paper, the classification of the published events is based on their actual content. Users express their subscriptions through constraints which identify valid events. An event matches a subscription, if and only if, it satisfies all of the subscription’s constraints. In general, the content-based method offers greater expressiveness to subscribers but is harder to implement. Preferences: The research literature on preferences is extensive. In general, there are two different approaches for expressing preferences: a quantitative and a qualitative one. In the quantitative approach (such as [5, 13, 16]), preferences are expressed indirectly by using scoring functions that associate numeric scores with data items. In the qualitative approach (e.g. [8, 12, 11]), preferences between data items are specified directly, typically using binary preference relations. 7. CONCLUSIONS To control the amount of data delivered to users in publish/subscribe systems, we extend such systems to incorporate ranking capabilities. In particular, in this paper, we address the problem of ranking notifications based on preferential subscriptions, that is, user subscriptions augmented with interest scores. To maintain the freshness of data delivered to users, we associate expiration times with notifications. We organize preferential subscriptions in a graph and utilize it to forward notifications to users. We have fully implemented our approach in SIENA, a popular publish/subscribe middleware system. There are many directions for future work. One is considering alternative approaches for achieving timeliness, such as computing top-\(k\) results over sliding windows of notifications. Among our future plans is also studying a weighting scheme based on both time and relevance for ranking notifications. Finally, the focus of this paper has been on enhancing the expressiveness of publish/subscribe systems. Besides expressiveness, performance is also central in such large-scale dynamic systems. In this respect, we plan to consider additional topologies besides the hierarchical one used in this work. 8. REFERENCES
{"Source-Url": "http://users.cs.uoi.gr/~mdrosou/docs/persdb08.pdf", "len_cl100k_base": 8933, "olmocr-version": "0.1.50", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 32967, "total-output-tokens": 10400, "length": "2e13", "weborganizer": {"__label__adult": 0.0004696846008300781, "__label__art_design": 0.0008997917175292969, "__label__crime_law": 0.0004067420959472656, "__label__education_jobs": 0.0021076202392578125, "__label__entertainment": 0.0014400482177734375, "__label__fashion_beauty": 0.0002237558364868164, "__label__finance_business": 0.0009965896606445312, "__label__food_dining": 0.0006098747253417969, "__label__games": 0.0015811920166015625, "__label__hardware": 0.0020599365234375, "__label__health": 0.00048160552978515625, "__label__history": 0.0005421638488769531, "__label__home_hobbies": 0.0001373291015625, "__label__industrial": 0.00047469139099121094, "__label__literature": 0.0011377334594726562, "__label__politics": 0.0004239082336425781, "__label__religion": 0.000560760498046875, "__label__science_tech": 0.273681640625, "__label__social_life": 0.00027108192443847656, "__label__software": 0.10760498046875, "__label__software_dev": 0.6025390625, "__label__sports_fitness": 0.00022530555725097656, "__label__transportation": 0.0005059242248535156, "__label__travel": 0.0003750324249267578}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 41403, 0.03983]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 41403, 0.2126]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 41403, 0.89024]], "google_gemma-3-12b-it_contains_pii": [[0, 4841, false], [4841, 9166, null], [9166, 15292, null], [15292, 18050, null], [18050, 24675, null], [24675, 29836, null], [29836, 34747, null], [34747, 41403, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4841, true], [4841, 9166, null], [9166, 15292, null], [15292, 18050, null], [18050, 24675, null], [24675, 29836, null], [29836, 34747, null], [34747, 41403, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 41403, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 41403, null]], "pdf_page_numbers": [[0, 4841, 1], [4841, 9166, 2], [9166, 15292, 3], [15292, 18050, 4], [18050, 24675, 5], [24675, 29836, 6], [29836, 34747, 7], [34747, 41403, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 41403, 0.0]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
9d55776900ebe68b5587dd31d4cb8304f25745f3
Research Article Applying a Goal Programming Model to Support the Selection of Artifacts in a Testing Process Andreia Rodrigues da Silva, Fernando Rodrigues de Almeida Júnior, and Placido Rogerio Pinheiro Graduate Program in Applied Informatics, University of Fortaleza (UNIFOR), Avenue Washington Soares, 1321, 60811-341 Fortaleza, CE, Brazil Correspondence should be addressed to Placido Rogerio Pinheiro, placidrp@uol.com.br Received 11 August 2012; Revised 20 October 2012; Accepted 12 November 2012 1. Introduction According to the Ministry of Science and Technology of Brazil, about 60% of software development enterprises in this country are classified as micro and small enterprises [1, 2]. In order to remain on the market, these companies need to invest significantly in improving the quality of their products because of the inherent complexity of the software development activity, which depends mainly on the interpretation skills of those involved. For that reason, this activity is susceptible to various issues, including the possibility of developing software other than what is expected by the user. In this context, the test activity is fundamental in supporting the quality assurance of products. However, it is important to note that according to the estimates obtained in recent years, 50% of development costs are allocated to software testing [3] and, in the scenario of micro and small enterprises (MSEs), where resources availability is limited, software testing activities are reduced or, in many cases, eliminated [4], because of the lack of skilled professionals in the area, the variety of techniques existing, and the difficulty of implementing a testing process. These companies do not have the necessary capital to hire such professionals, besides not having the know-how of testing techniques and having much difficulty to deploy a testing process practical enough. A variety of micro and small enterprises still do not have a formal testing process and even have the ability to implement a process that meets the needs and ensure the correct execution of activities. Generally testing activities, when included in the development process of software these companies are carried out by developers or system analysts. These professionals do not have knowledge about the techniques and testing criteria and, therefore, cannot benefit from the application of the techniques most appropriate to the context of the organization and the characteristics of the software being developed. About these limitations, it is important to define an approach that is not large or unviable, to allow the utilization of a testing process in these companies. As you can see, the testing process is very expensive and time consuming, spending valuable resources in such activity [5]. Small businesses have unique and distinct characteristics: they develop software generally smaller and less complex; do not have many financial resources; avoid expensive tools, sophisticated and complex procedures; processes and methods are unique [6]. Thus, from the definition of constraints and objectives expected for a testing process and considering the favorable and unfavorable conditions of the enterprise, it is possible to use operations research techniques such as linear programming, game theory, queuing theory, dynamic programming, risk analysis, goal programming, among others. These techniques and methods provide the decision maker with the possibility of increasing the degree of rationality of the decision, assisting in defining the actions to be taken, since they allow considering various relevant aspects of the decision making process. The remainder of this paper is organized as follows. Section 2 explains the importance of software testing activity for enterprises in general and how the main standards and maturity models for software address such activities. Section 3 explains the basis of the multicriteria model and how this model can be used for the decision support process. Then, a multicriteria model is defined to support the definition of a software testing methodology in Section 4. Next, Section 5 describes the goal programming model, the proposed model and the results obtained with application from this model. Finally, a conclusion of this work is taken in Section 6. 2. The Importance of Using a Process Software testing has been covered in the most acknowledged process maturity models and standards, such as CMMI [7], MPS BR [8], ISO/IEC 12207 [9], and ISO/IEC 15504 [10]. All of these maturity models and standards provide a guide to support the definition of a software testing process so that the testing activities are performed in an organized, disciplined manner and based on a set of well-defined activities. However, the definition of that process and the artifacts generated are the responsibility of the company that implements the standard or model and should be in accordance with their needs and the particular characteristics of each project. Likewise, the evaluation and improvement models of software testing processes, such as Testing Maturity Model [11] and Test Process Improvement [12], were created in order to provide support to companies wishing to improve the testing process. Nevertheless, it is not the purpose of these models to assist the company in the definition of the testing process. However, the ISO/IEC 829 [13] Standard is slightly different from other standards and models because it establishes a set of documents to be generated over the testing activities. Altogether there are eight documents included from planning and specification activities until testing reports, as shown in Figure 1. 3. Related Works According to [14], although the IEEE 829 can be used to test software products of any size or complexity, for small or low-complexity projects, some proposed documents can be grouped to reduce the management and production cost of documents. Moreover, the content of the documents can also be shortened. GRASP metaheuristic is applied to the regression test case selection problem, defining an application related to prioritization of tests in [15]. In another work [16], an application for test redundancy detection is developed in a useful way, as a collaborative process between testers and a proposed redundancy detection engine to guide the tester to use valuable coverage information. 4. Fundamentals of Multicriteria The objective of multicriteria is to reduce the subjectivity in the decision making process, using multiple criteria and application of mathematical calculations. However, it is important to emphasize that the subjectivity factor will always be present in the decision making process since the items to be mathematically evaluated are a result of human opinions. Its focus is, therefore, to support the decision maker in the information analysis and seek the best strategy among existing alternatives. The adoption of a multicriteria decision support approach in this work is due to the fact that this approach, that is in constant growth, provides the group involved in the decision making process with subsidies required to obtain a solution that best fits the needs of the group [17]. Also, the approach focuses on issues that include qualitative and/or quantitative aspects, based on the principle that the experience and knowledge of people are at least as valuable as the data used for decision making [18]. Another factor that encouraged the adoption of the multicriteria approach in our study was the fact that this method has already been applied in the software engineering field [19–21]. 5. A Multicriteria Model to Support the Development of a Software Testing Methodology for Micro and Small Enterprises A multicriteria model, developed by Rodrigues et al. [20–23], based on objective and subjective criteria was applied in order to support the prioritization of the artifacts available in the IEEE 829-1998 Standard, selecting the most relevant items for micro and small enterprises. The model consists of a series of generic steps that were distributed among the three main phases of the decision supporting process: (1) structure, (2) evaluation, and (3) recommendation. However, in the context of our work, we used only the structure phase of the model because other phases were replaced by the goal programming model, resulting in a hybrid model. The steps of the structure phase are detailed in Table 1. 5.1. Structure. In the step “identify criteria,” all the involved actors participated in a conference session to choose the criteria to be analyzed for prioritization of the documents of the IEEE 829-1998 Standard. The criteria selected for the evaluation are shown in Table 2. In the step “identify actors and their weights,” two groups of actors were selected to participate in this decision making process: the first group, consisting of two experts in software testing, and the second group composed of two professionals working in micro and small enterprises. Then the actors answered a survey composed of three sections covering the characterization of the respondent, the prioritization of the criteria used in the model and the analysis from the point of view of the actor regarding the criteria and documents analyzed. The documents, in turn, represent the alternative solutions in decision making process. To calculate the weight for a specific actor, a value for each of the answer options was established for each item of the survey. Also an adjustment factor was established for each group of actors, testing experts and professionals working in micro and small enterprises in relation to each of the criteria considered in the model. This is needed to establish a differentiated weight for each group of actors by criterion evaluated in the model. Thus, the weight of each actor consists of the sum of the scores referring to the actor’s response to each item of the survey, multiplied by the adjustment factor of the criterion in question, considering the group to which the actor belongs to. The formula applied for obtaining the actor’s weight is given below: $$PA(a, c) = \sum_{i \in A} R_i \ast F_c,$$ where $PA(a, c)$ is the actor’s weight $a$ for the criterion $c$, $R_i$ corresponds to the actor’s answer for the item $i$ of the survey, $F_c$ corresponds to the multiplication factor of the criterion in question, and $A$ corresponds to the number of items of the survey. It is worth noting that the actor’s weight for the criterion does not vary according to the document being assessed. In the step “assign prioritization to the criteria,” each actor ranked the selected criteria according to their degree of relevance, not by specific document, but for the company’s testing process, as shown below: $$\text{Priority}(a, c) \in \{1, \ldots, i, \ldots, n\} \quad \forall c_i, c_j \Rightarrow \text{Priority}(a, c_i) \neq \text{Priority}(a, c_j),$$ where $\text{Priority}(a, c_i)$ is the criterion priority $c$ for the actor $a$, $n$ is the number of criteria, and $i, j > 0$. Next, for each criterion, a partial evaluation of the score was made. This partial evaluation is derived by multiplying the values obtained from the viewpoint of the actor for each document, the actor’s weight for each criterion and Table 1: Model’s steps. <table> <thead> <tr> <th>Phase</th> <th>Step</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>(7) Identify criteria</td> <td>Identifies the criteria to be used to evaluate the artifacts and defines the priority of these criteria.</td> <td></td> </tr> <tr> <td>(8) Identify actors and their weights</td> <td>Identifies the actors who will expose their points of view, also considering their roles in the decision making process.</td> <td></td> </tr> <tr> <td>Structure</td> <td>(9) Assign prioritization to the criteria</td> <td>Each actor should assign a weight to the criterion, considering the full test process and not only a specific artifact.</td> </tr> <tr> <td></td> <td>(11) Execute a partial evaluation</td> <td>During this step, the values are normalized by placing them on the same base (base 1), in order to perform an equality partial evaluation. This evaluation is derived by multiplying the values obtained from the point of view of the actor for each document by the actor’s weight and the criteria priority.</td> </tr> <tr> <td></td> <td>(12) Calculate the general scores of the criteria</td> <td>It is the calculation of the median obtained using values resulting from the previous step.</td> </tr> </tbody> </table> Table 2: Selected criteria. <table> <thead> <tr> <th>Criterion</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Difficulty level</td> <td>Is the level of difficulty to obtain the information necessary to fulfill the artifact low?</td> </tr> <tr> <td>Information relevance</td> <td>Is the information contained in the artifact relevant to the reality of the organization?</td> </tr> <tr> <td>Reuse possibility</td> <td>Is there a high possibility for the information contained in the artifact to be reused?</td> </tr> <tr> <td>Effort</td> <td>Is the effort required to complete the artifact low?</td> </tr> <tr> <td>Knowledge</td> <td>Is the level of knowledge in software testing required to fulfill the artifact appropriately quite low?</td> </tr> <tr> <td>Cost</td> <td>Is the cost for fulfilling the artifact low?</td> </tr> </tbody> </table> the priority assigned by the actor to the criterion. This multiplication represents the score \((E)\) of each actor for each criterion of each document and will serve for further classification and prioritization of documents, as shown below: \[ E_x(a, c) = [PV_x(a, c)]_1 \times [PA(a, c)]_1 \times [Priority(a, c)]_1. \] \[(3)\] It is noteworthy that the values applied for the criteria priority and actor’s weight were equalized in order to ensure an equitable evaluation, as shown below: \[ [Priority(a, c)]_1 \in \{\frac{1}{n}, \frac{2}{n}, \ldots, \frac{n}{n}\}, \] \[(4)\] where \(n\) represents the number of criteria. \[ [PA(a, c)]_1 = \sum_{i=A} R_{xi} * F_{c}, \] \[(5)\] where \(m\) is the number of actors. After the results obtained in the partial evaluation for each actor, in the step “calculate the general scores of the criteria” was carried out, the calculation of the arithmetic mean to obtain the final score of each document for each criterion, as shown below: \[ Average(x, c) = \sum_{i=1}^{m} \frac{E_x}{m}, \] \[(6)\] where \(E_x\) is the corresponds to the partial score of the document \(x_i\), determined by the actor \(a\) referring to the criterion \(c\), \(m\) is the number of actors. The average value found was used as a basis for the prioritization of the documents during the application of the goal programming model. 6. Goal Programming In real problems, the occurrence of multiple objectives to be considered at the time of resolution is frequent and mutually conflicting goals are not uncommon. The goal programming is an extension of linear programming that has emerged as an option to the basic mathematical programming models, allowing to solve, simultaneously, a system of complex goals, rather than a single, simple goal [24]. This is a method that requires an iterative solution procedure by which the decision maker investigates a variety of solutions. However, a peculiarity of goal programming is the impossibility of representing all the goals in a single-objective function (often conflicting or unrelated). Therefore, goal programming considers all the objectives and seeks a solution that least deviates this set and at the same time meets the restrictions of the problem. The goal programming and the approaches for multicriteria decision support have in common the fact of presenting a series of feasible solutions to the problem so that the decision makers can find/choose the one that best meets their needs and expectations. This similarity between the approaches motivated the creation of the hybrid model for the selection of documents to be produced during the testing activities. The main idea of goal programming problems is to describe a function for each goal and also set a goal value for each of these. These functions represent the constraints of the problem, and then formulate an objective function that minimizes the sum of the deviations of all goals. The following presents a goal programming model simplified, first presented by Charnes and Cooper [25]: Minimize \[ \sum_{m} (y_{m}^{+} + y_{m}^{-}) \] \hspace{1cm} (7) Subject to \[ f_{m}(X) - v_{m} = y_{m}^{+} - y_{m}^{-} ; \] \hspace{1cm} (8) for each goal \( m \) \[ y_{m}^{+}, y_{m}^{-}, x_{n} \geq 0; \] \[ \forall m, i = 1, \ldots, n, \] \hspace{1cm} (9) where \( X = \{x_{1}, \ldots, x_{n}\} \) corresponds to the vector of decision making variables that at the end of the process of resolution of the model will provide a configuration that leads to better results, considering all the goals and constraints applied to the model; \( f_{m}(X) \) is a function \( f : \mathbb{R}^{n} \rightarrow \mathbb{R} \) that defines the objective of goal \( m; \) \( v_{m} \) is the numerical value to be achieved by the goal \( m; \) \( y_{m}^{+} \) and \( y_{m}^{-} \) are the positive and negative deviation variables, respectively, that calculate the variation of the goal \( m. \) The variable \( y_{j} \) represents the absolute value that each goal is below the originally desired and \( y_{j}^{-} \) represents the absolute value that each goal is above the originally desired. In order that a negative deviation does not cancel a positive deviation, the model should measure it in absolute terms, and, therefore, the objective function is represented by minimizing the sum of the deviations of each goal. Note that in the model suggested by Charnes and Cooper [25], we assumed that all objectives and all goals have the same weight. 6.1. Proposed Goal Programming Model. The purpose of our work is to decide which documents, among those suggested by the ISO/IEC 829 Standard, presented in Section 2 of this paper, and are more relevant to the reality of micro and small enterprises, in order to make the amount of documents produced during the testing activity more viable to the context of the MSE. These variables are represented by the binary variables \( u_{x}, \) which represent \[ u_{x} = \begin{cases} 1, & \text{if the document } x \text{ is selected,} \\ 0, & \text{otherwise.} \end{cases} \] \hspace{1cm} (10) Next, we define the goals for each objective. The goals were defined based on the criteria considered relevant for the selection of artifacts. Each goal relates directly to one of the six selected criteria during the application of the multicriteria model, as shown in Table 2. The definition of the goals can be seen below: (i) Goal 1—select artifacts whose level of difficulty to obtain the information needed to its completion is low; (ii) Goal 2—select the artifacts whose information is of most relevance to the reality of the enterprise; (iii) Goal 3—select the artifacts in which the possibility of reusing the information contained therein is high; (iv) Goal 4—select artifacts whose effort required to complete them is low; (v) Goal 5—Select artifacts whose level of knowledge in software testing required to complete them properly is pretty low; (vi) Goal 6—Select the artifacts whose cost to complete is considered low. As you can see, the goals defined do not have values directly associated. Therefore, the values obtained using the multicriteria model (step “calculate the general scores of the criteria”), depicted in the previous section, were used as the value of each one of the goal defined herein. Thus, two possible values \( v_{m} \) were established for each goal \( m \) associated with a criterion \( c, \) and that will be applied to the constraints of inequality (8), according to the section Goal Programming: (I) \( v_{m} = \sum_{x \in D} E_{c,x} ; \) summation of the scores of documents to the criterion \( c; \) (II) \( v_{m} = \frac{\sum_{x \in D} E_{c,x}}{|D|} ; \) average of the scores of the documents to the criterion \( c, \) where \( D \) represents the set of all documents. After assignment of values of each goal, the constraint (8) presented in the simplified model of Charnes and Cooper [25], was redefined using the decision variables and the goal values assigned, as shown below: \[ \sum_{x \in D} E_{c,x} \times U_{x} \geq v_{m}, \] \hspace{1cm} (11) where \( x \) is the document and \( c \) is the criterion related to goal \( m. \) Then, the objective function (7) was also redefined by considering that all the positive deviations can be discarded since it is a maximization problem. For a maximization problem it does no matter how much a positive deviation is exceeded, it matters only how to minimize the maximum negative deviations, which represents how much is missed for achieving the goal. Another difference between the objective function redefined and the function originally presented in the simplified model of Charnes and Cooper [25] is the inclusion of weights for each of the goals, which makes the model closer to reality, considering that each goal will have a differentiated factor of relevance according to the particularities of each enterprise. Therefore, we have the following objective function: Minimize \[ \sum_{m} w_{m} y_{m}^{-}. \] \hspace{1cm} (12) Finally, to avoid the obvious solution, which in the context of this work is the use of all the documents in order to achieve all the objectives, it was necessary to add constraint (13), in order to obtain the best subset of \( n \) documents, \[ \sum_{x \in D} U_x \leq q, \] where \( q \) is a parameter of the model created with the purpose of limiting the amount of documents used. Thus, if \( q = 1 \), then the model will define the best document considering all the goals and constraints. If \( q = 2 \), then the model will define the two best documents, given that the first document was already known after the first run of the model. Therefore, the successive execution with the value of \( q \) incremented step by step will result in a formulation of the top ranking documents. The final model consists of the objective function (12) plus the constraints (9), (11), and (13). The results obtained for the goal values (I) and (II) are presented in the next section: \[ \begin{align*} \text{Minimize} & \quad \sum_{m} w_m y_{m}^x, \\ \text{Subject to} & \quad \sum_{x \in D} E_{x,m} \cdot U_x \geq v_m, \\ & \quad \sum_{x \in D} U_x \leq q, \\ & \quad y_{m}^x, y_{m}, x_i \geq 0; \quad \forall m, i = 1, \ldots, n. \end{align*} \] 7. Application of Hybrid Model for the Selection of Test Artifacts The proposed testing methodology for micro and small software development companies is based on the ISO 829, with regard to the standard documentation to be developed during the planning and execution of the tests. We chose to use this standard as a basis for this work, given that, in addition to presenting a set of documents that can be adapted for specific organizations or projects, this standard provides a set of information relevant to the testing of software. The adaptation of ISO 829 with the purpose of enabling its use in micro and small enterprises was based on Crespo (2003). According to Crespo (2003), although the IEEE 829 can be used for testing of software products of any size or complexity, for the projects of small or low complexity, some proposed that documents can be grouped so as to decrease the manageability and production cost of documents. Furthermore, document content may also be abbreviated. That way, the proposed methodology was defined with the support of experts in software testing and professionals engaged in micro and small enterprises through the hybrid approach involving multiple criteria and goal programming technique, as presented in the following section. 7.1. Application of Multicriteria Model in the Prioritization of Documents Made Available by ISO 829 Initially the multicriteria model was applied to the documentation provided by the IEEE 829-1998, aiming at obtaining a goal value to each of the documents and, thus, supporting the selection of the items most relevant to the needs of micro and small enterprises through the application of goal programming model. The structuring phase of the multicriteria model consists of the steps of identifying criteria, identification of the actors and their weights, and realization of partial evaluation. During the stage of identification of criteria, all actors participated in a section for the choice of the criteria to be considered for prioritization of documents of IEEE 829-1998. Two groups of actors were selected to be part of this decision making process. The first group consists of 2 (two) experts in software testing, and the second group consists of 2 (two) professionals working in micro and small enterprises. These actors have responded to a questionnaire consisting of 3 (three) sections, covering the characterization of the interviewee, the prioritization of criteria used in the model, and the analysis of the actor’s point of view against the criteria and analysed documents. The documents, in turn, represent the decision making process solution alternatives. The calculation of the actor’s weight was obtained through the sum of the score corresponding to each of the items of the questionnaire. For example, in the case of the item of the questionnaire that considers the degree of the actors, each one of the options: bachelor, specialization, masters, and Ph.D., corresponds to a specific score, ranging between 0.25; 0.50; 0.75; 1.0, respectively. The weight of each actor is presented in Table 3. Still regarding the weight of the actor, each criterion was established with the support of experts and through conferences, a factor that is differentiated for each group (experts and practitioners of micro and small enterprises), which multiplied the weight of the actor obtained previously, corresponds to the actor’s weight to the criterion in question. Table 4 presents the factor defined for each criterion and a group of actors. To facilitate the understanding, the calculation of the final weight of one of the actors participating in the process in relation to the relevance of information is presented below: \[ \text{PA}(a,c) = \sum_{i \in A} R_{x_i} \cdot F_c, \] so \( \text{PA}(\text{Professional MPE 2}, \text{Relevance of information}) = (1 + 1 + 1 + 0.75) \cdot 0.66 = 2.475 \). Then each actor ranked the selected criteria as your perception of their priority for the process as a whole, as can be seen in Table 5. Continuing the process, for each criterion, we performed a partial evaluation of the score. This partial evaluation is the result of the multiplication of the values obtained from the point of view of the actor for each document, the actor’s weight, and priority of the criterion. It is worth mentioning that the values applied to priority and weight of the actor, were equalized, aiming to ensure equal assessment. Thus, whereas the priority value presented in Table 5, for the professional actor MPE 2 regarding the criterion “relevance of information” is 4, for the calculation of partial evaluation, we have \[ [\text{Priority}(a,c)]_1 \in \left\{ \frac{1}{n}, \frac{2}{n}, \ldots, \frac{n}{n} \right\}, \] Advances in Software Engineering Table 3: Actor’s weight. <table> <thead> <tr> <th>Criteria</th> <th>Expert 1</th> <th>Expert 2</th> <th>Professional MPE 1</th> <th>Professional MPE 2</th> </tr> </thead> <tbody> <tr> <td>Difficulty level</td> <td>0,99</td> <td>0,7425</td> <td>3,25</td> <td>3,75</td> </tr> <tr> <td>Information relevance</td> <td>2,49</td> <td>1,8675</td> <td>2,145</td> <td>2,475</td> </tr> <tr> <td>Reuse possibility</td> <td>1,5</td> <td>1,125</td> <td>1,0725</td> <td>1,2375</td> </tr> <tr> <td>Effort</td> <td>1,98</td> <td>1,485</td> <td>1,625</td> <td>1,875</td> </tr> <tr> <td>Knowledge</td> <td>3</td> <td>2,25</td> <td>0,52</td> <td>0,6</td> </tr> <tr> <td>Cost</td> <td>0,48</td> <td>0,36</td> <td>2,6975</td> <td>3,1125</td> </tr> </tbody> </table> Table 4: Adjustment factor per criterion and group of actors. <table> <thead> <tr> <th>Group of professionals</th> <th>Difficulty level</th> <th>Information relevance</th> <th>Reuse</th> <th>Effort</th> <th>Knowledge</th> <th>Cost</th> </tr> </thead> <tbody> <tr> <td>Professionals in micro and small enterprises</td> <td>0,33</td> <td>0,66</td> <td>0,33</td> <td>0,5</td> <td>0,16</td> <td>0,83</td> </tr> <tr> <td>Expert in software testing</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> where \( n \) represents the amount of criteria, so: Priority (Professional MPE 2, Relevance of information) = \( \frac{4}{6} \), Priority (Professional MPE 2, Relevance of information) = 0,66. Similarly, the actor’s weight was also standardised. Therefore, standardisation of professional actor weight MPE 2, presented in Table 3, for the relevance of the information, is shown below: \[ [PA(a,c)]_1 = \frac{\sum_{i \in A} R_{xi} \ast F_c}{4}, \] so \( PA(\text{Professional MPE 2, Relevance of information}) = 2,475/4, PA (\text{Professional MPE 2, Relevance of information}) = 0,61. \) Finally, the calculation of partial evaluation representing the score obtained for the test plan document of professional actor MPE 2, with respect to the criterion “relevance of information,” is presented below: \[ e_{v_x}(a,c) = [PV_x(a,c)]_1 \ast [PA(a,c)]_1 \ast [\text{Priority (a,c)}]_1, \] \[ e_{\text{test plan}}(\text{Professional MPE 2, Relevance of information}) = [1 \ast 0,61 \ast 0,66], \] \[ e_{\text{test plan}}(\text{Professional MPE 2, Relevance of information}) = 0,40. \] After the result was obtained in partial evaluation for each actor, the average calculation was performed to obtain the final score of each document for each criterion. Thus, for the test plan document, criterion “relevance information,” considering the scores of all the actors, we have \[ e_{\text{test plan}}(\text{Expert 1, Relevance of information}) = [1 \ast 0,62 \ast 0,5] = 0,31, \] \[ e_{\text{test plan}}(\text{Expert 2, Relevance of information}) = [1 \ast 0,46 \ast 0,5] = 0,23, \] \[ e_{\text{test plan}}(\text{Professional MPE 1, Relevance of information}) = [1 \ast 0,53 \ast 1] = 0,53, \] \[ e_{\text{test plan}}(\text{Professional MPE 2, Relevance of information}) = [1 \ast 0,61 \ast 0,66] = 0,40, \] \[ \text{ME(test plan, Relevance of information)} = 0,3675. \] Table 6 presents the result of the average of each document and criteria. This result, as shown in Section 5.1, the value of goal of each criterion was evaluated in the model obtained based on: (I) \( v_m = \sum_{c \in D} e_{v_x} \): summation of the scores of documents to the criterion \( c \); (II) \( v_m = \frac{\sum e_{v_x}}{|D|} \): average of the scores of the documents to the criterion \( c \). The value corresponding to the sum of the scores of documents for each criterion, as well as the average of the scores of the calculated documents was obtained based on the presented values. Finally, the goal programming model structured based on the results obtained through the application of multicriteria model is presented below. The average of the priorities assigned to each criteria by the actors involved in the decision process was used as the weight of the criteria in the objective function of goal programming model. Likewise, as shown in Table 5: Priorities criteria by actor. <table> <thead> <tr> <th>Criteria</th> <th>Expert 1</th> <th>Expert 2</th> <th>Professional MPE 1</th> <th>Professional MPE 2</th> </tr> </thead> <tbody> <tr> <td>Difficulty level</td> <td>5</td> <td>2</td> <td>4</td> <td>1</td> </tr> <tr> <td>Information relevance</td> <td>3</td> <td>3</td> <td>6</td> <td>4</td> </tr> <tr> <td>Reuse possibility</td> <td>1</td> <td>4</td> <td>1</td> <td>2</td> </tr> <tr> <td>Effort</td> <td>6</td> <td>5</td> <td>3</td> <td>5</td> </tr> <tr> <td>Knowledge</td> <td>2</td> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>Cost</td> <td>4</td> <td>6</td> <td>5</td> <td>6</td> </tr> </tbody> </table> Table 6: Overall score of the criteria. <table> <thead> <tr> <th>Document</th> <th>Difficulty level</th> <th>Information relevance</th> <th>Reuse possibility</th> <th>Effort</th> <th>Knowledge</th> <th>Cost</th> </tr> </thead> <tbody> <tr> <td>Test plan</td> <td>0,000</td> <td>1,493</td> <td>0,335</td> <td>0,495</td> <td>0,000</td> <td>0,080</td> </tr> <tr> <td>Test design specification</td> <td>0,062</td> <td>1,182</td> <td>0,103</td> <td>0,804</td> <td>0,250</td> <td>0,090</td> </tr> <tr> <td>Test case specification</td> <td>0,206</td> <td>1,493</td> <td>0,166</td> <td>0,495</td> <td>0,250</td> <td>0,080</td> </tr> <tr> <td>Test procedure specification</td> <td>0,542</td> <td>1,493</td> <td>0,166</td> <td>0,203</td> <td>0,250</td> <td>0,642</td> </tr> <tr> <td>Test log</td> <td>0,966</td> <td>0,311</td> <td>0,000</td> <td>0,513</td> <td>0,462</td> <td>0,732</td> </tr> <tr> <td>Test incident report</td> <td>0,966</td> <td>1,493</td> <td>0,000</td> <td>1,089</td> <td>0,368</td> <td>1,420</td> </tr> <tr> <td>Test summary report</td> <td>0,218</td> <td>1,493</td> <td>0,000</td> <td>1,195</td> <td>0,344</td> <td>0,948</td> </tr> </tbody> </table> In the second run, the value of the summation of the scores of each general document for each criteria was used as the target value for the constraint R_Crit_0. In this case, the value 0.1058571 was replaced by 0.8468571. The following are the results of applying the hybrid model to support the decision of the test artifacts selection. In the second run, the value of the summation of the scores of each general document for each criteria was used as the target value for the constraint R_Crit_0. 7.2. Computational Results. The proposed model was solved using the software IBM ILOG OPL 6.3, assigned to the academic community. Two scenarios were performed using the sum (I) and the average (II) as the goal values. The results are shown in Figure 2. We can note that the prioritization of the documents was carried out satisfactorily, considering the two goal values options established. However, the application of the model using the average as a goal value obtained a result closer to what had already been obtained by applying a multicriteria model and evaluation of the actors involved in decision making process presented by Rodrigues [26]. This result is possibly more feasible because it includes documents produced during the main stages of the testing activity. On the other hand, the result that considered as a goal value of the summation could be more interesting for an enterprise in which the documents produced for the stage of execution and evaluation of the tests are of higher priority than those documents produced for the planning stage of tests. 8. Conclusion and Future Works This paper proposed a hybrid model for prioritization of documents to be produced during the software testing activity in an enterprise. The purpose of applying the model to obtain the prioritization of the documents available on IEEE 829 [13] Standard is to establish a set of documents that may be considered, possibly closer to the reality of micro and small enterprises when they are not able to produce all documents suggested by the IEEE 829. The application of the proposed model met the goal of prioritization while at the same time allowed to replace the way enterprises define, often using an evaluation without criteria formally established, the documents that are part of the scope of their processes. Thus, the application of a decision support model attempts to decrease the subjectivity, with which decisions are made, but it is important to note, not necessarily the result of decision making will be exactly equal to the result obtained with application of the prioritization model. However, future works, it is essential that the differences among the results obtained with the application of the model and the judgments expressed by the participants involved in the decision making process are evaluated, with the purpose of adjusting the model as close as possible to the reality. Although the proposed approach aims the prioritization of documents to form a testing process, we believe that it can be applied to different prioritization problems, such as prioritization of use cases to perform peer review. Acknowledgments The first and second authors would like to thank FUNCAP—Foundation for Support in Scientific and Technological Development State of Ceará—that has been financially sponsored this work, and the third author would like to thank CNPq—National Counsel of Technological and Scientific Development, via Grant no. 305844/2011-3. The authors also acknowledge IBM for making the IBM ILOG CPLEX Optimization Studio available to the academic community. References
{"Source-Url": "http://downloads.hindawi.com/archive/2012/765635.pdf", "len_cl100k_base": 8966, "olmocr-version": "0.1.50", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 37360, "total-output-tokens": 10986, "length": "2e13", "weborganizer": {"__label__adult": 0.0003218650817871094, "__label__art_design": 0.0004732608795166016, "__label__crime_law": 0.0003614425659179687, "__label__education_jobs": 0.00449371337890625, "__label__entertainment": 6.80685043334961e-05, "__label__fashion_beauty": 0.00018727779388427737, "__label__finance_business": 0.0008935928344726562, "__label__food_dining": 0.0003361701965332031, "__label__games": 0.0005917549133300781, "__label__hardware": 0.0006999969482421875, "__label__health": 0.0005507469177246094, "__label__history": 0.000263214111328125, "__label__home_hobbies": 0.00011903047561645508, "__label__industrial": 0.0004112720489501953, "__label__literature": 0.00031256675720214844, "__label__politics": 0.0002386569976806641, "__label__religion": 0.00035834312438964844, "__label__science_tech": 0.0271453857421875, "__label__social_life": 0.00012063980102539062, "__label__software": 0.0100250244140625, "__label__software_dev": 0.951171875, "__label__sports_fitness": 0.00024378299713134768, "__label__transportation": 0.00036025047302246094, "__label__travel": 0.00020182132720947263}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 42044, 0.03144]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 42044, 0.28613]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 42044, 0.89824]], "google_gemma-3-12b-it_contains_pii": [[0, 3063, false], [3063, 5596, null], [5596, 11310, null], [11310, 15708, null], [15708, 21195, null], [21195, 27111, null], [27111, 31302, null], [31302, 35299, null], [35299, 40041, null], [40041, 42044, null], [42044, 42044, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3063, true], [3063, 5596, null], [5596, 11310, null], [11310, 15708, null], [15708, 21195, null], [21195, 27111, null], [27111, 31302, null], [31302, 35299, null], [35299, 40041, null], [40041, 42044, null], [42044, 42044, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 42044, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 42044, null]], "pdf_page_numbers": [[0, 3063, 1], [3063, 5596, 2], [5596, 11310, 3], [11310, 15708, 4], [15708, 21195, 5], [21195, 27111, 6], [27111, 31302, 7], [31302, 35299, 8], [35299, 40041, 9], [40041, 42044, 10], [42044, 42044, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 42044, 0.17391]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
f66aac5c84ff8298369f58b5b9546e78d798b0ee
Ensuring Authorization Privileges for Cascading User Obligations Omar Chowdhury The University of Texas at San Antonio ochowdhu@cs.utsa.edu Murillo Pontual The University of Texas at San Antonio mpontual@cs.utsa.edu William H. Winsborough The University of Texas at San Antonio wwinsborough@acm.org Ting Yu North Carolina State University tyu@ncsu.edu Keith Irwin Winston-Salem State University irwinke@wssu.edu Jianwei Niu The University of Texas at San Antonio niu@cs.utsa.edu 1. INTRODUCTION Many access control and privacy policies contain some notion of actions that are required to be performed by a system or its users in some future time. Such required actions can be naturally modeled as obligations. Consider the following paraphrased regulation excerpt from section §164.524 of the Health Insurance Privacy and Accountability Act (HIPAA) [11]. A covered entity must respond to a request for access no later than 30 days after receipt of the request of the patient. As we can see from the regulation, the action of the covered entity is required when he receives a request from the patient. When we use obligations to capture this notion of required actions, we need a proper framework and mechanisms by which obligations can be managed efficiently. Many access control and privacy policies contain some notion of actions that are required to be performed by a system or its users in some future time. Such required actions can be naturally modeled as obligations. Consider the following regulation excerpt from section §164.524 of the Health Insurance Privacy and Accountability Act (HIPAA) [11]. A covered entity must respond to a request for access no later than 30 days after receipt of the request of the patient. As we can see from the regulation, the action of the covered entity is required when it receives a request from the patient. When we use obligations to capture this notion of required actions, we need a proper framework and mechanisms by which obligations can be managed efficiently. The notion of obligations is not new. Several researchers [3, 4, 6, 13, 15–17, 19, 25, 26] have proposed frameworks for modeling and managing obligations. The majority of the existing work [3, 4, 6, 15, 19, 25, 26] focuses on policy specification languages for obligations rather than efficient management of obligations [3, 7, 10, 12, 14, 18, 21]. Even for works on the management of obligations, they mainly consider system obligations. Our goal is to address technical issues for efficient management of user obligations. A user (resp., system) obligation is an action that is to be carried out by a user (resp., the system) in some future time. Managing user obligations is challenging as system obligations can be assumed to be always fulfilled whereas this is often not the case for user obligations. More generally, we consider user obligations that can require authorization and can also alter the authorization state of the system. As a user obligation is an action, it is subjected to the authorization requirements imposed by the security policy of the system. We also consider that each of the user obligations has a time interval (e.g., 30 days, etc.) which represents the allotted time window at which the obligation should be performed. Such intervals help detect obligation violation. When managing user obligations that depend on and can affect authorization, we have to consider the case in which users can incur obligations that they are not authorized to perform. Otherwise, when an obligation goes unfulfilled, it is difficult to know if it is due to insufficient authorization or lack of diligence from the user. When it is ensured that all the obligatory actions are authorized, any obligations A violation will only be caused due to user negligence. Irwin et al. [12] introduce a property of the authorization state and the current obligation pool, accountability, that tries to ensure that all the obligatory actions are authorized in some part of their stipulated time interval. They consider two variations of the accountability property (i.e., strong accountability and weak accountability) based on when in the time intervals the obligatory actions should be authorized. Irwin et al. [12] propose to maintain the accountability property as an invariant of the system. They propose to use the reference monitor of the system for maintaining accountability by denying actions that violate accountability. Extending the work of Irwin et al. [12], Pontual et al. [20] show that for an obligation system using mini-RBAC [23,24] and mini-ARBAC [23,24] as its authorization model, strong accountability can be decided in polynomial time whereas deciding weak accountability is co-NP complete. They also provide empirical evaluations for showing that a reference monitor can maintain the strong accountability property efficiently. They partition possible actions into two disjoint sets, discretionary and obligatory and only allow discretionary actions to incur further obligations. By doing this, they disallow cascading obligations. The assumption of disallowing cascading obligations is restrictive. It significantly reduces the expressive power of the obligation model they use. For instance, consider the following scenario. When a sales assistant submits a purchase order, the clerk incurs an obligation to issue a check in the amount identified in the purchase order. As soon as the clerk issues the check, the manager incurs an obligation that requires him to check the consistency of the purchase order. If the purchase order is consistent and the manager approves it, then the accountant incurs another obligation to approve the check. Now, this situation can be easily modeled with cascading obligations, but it cannot be modeled by the obligation model of Pontual et al. [20]. Thus, one of the principal goals of this paper is to provide a concrete model in which the policy writers can specify cascading obligations easily. Furthermore, we also present a decision procedure which can be used to decide the strong accountability property efficiently for special but practical cases of cascading obligations in the model. The abstract obligation model that Irwin et al. [12] and Pontual et al. [20] use, allows specification of cascading obligations. However, their concrete model does not support the specification of cascading obligations. We adopt the concrete model of Pontual et al. [20] that uses mini-RBAC and mini-ARBAC as its authorization model and augment it in a way that cascading obligations can be specified. Furthermore, existing work [12,20] does not discuss how to specify the user (obligatee) who incurs the new obligation when a user takes an action (obligatory or discretionary). We present several proposals for specifying the obligatee in a policy. The enhancement to the obligation model and proposals for obligatee selection comprise our first contribution. The specification for strong accountability presented by Pontual et al. [20] also takes advantage of the assumption that cascading obligations are not allowed. Our second contribution is to precisely specify the strong accountability property in presence of cascading obligations. There are two possible interpretations of strong accountability when considering cascading obligations. We define both interpretations, existential and universal, and give motivations for choosing the existential interpretation. Our third contribution is to present a theorem which states that deciding accountability in presence of cascading obligations is in general NP-hard. We then consider several special cases which makes the problem tractable. We then provide a polynomial time algorithm (polynomial in the size of the policy, the size of the current obligation pool, and the new obligations to be considered) that can decide strong accountability for special cases of cascading obligations. This is our fourth contribution. We then present empirical evaluations of the accountability decision procedure allowing special cases of cascading obligations. Our empirical evaluations show that strong accountability can be efficiently decided for these special cases of cascading obligations. This is our final contribution. Section 2 reviews the background materials. Section 3 discusses the necessary enhancement of the obligation model to specify cascading obligations. Our main technical contribution is presented in section 4. It presents the refined definition of strong accountability, the complexity of deciding strong accountability, special cases that make deciding accountability feasible, and an algorithm for deciding strong accountability under these assumptions. Section 5 explains our input instance generation and presents empirical evaluation results. Related works are discussed in section 6. Section 7 discusses our future work and concludes. 2. BACKGROUND In this section, we first summarize the restricted variation of the role-based access control (RBAC) and administrative role-based access control (ARBAC) model, mini-RBAC [23,24] and mini-ARBAC [23,24], respectively. We then discuss the obligation model presented by Pontual et al. [20] that uses mini-RBAC and mini-ARBAC as its authorization model. 2.1 mini-RBAC and mini-ARBAC In the context of studying the role reachability problem, Sasturkar et al. [23] introduced mini-RBAC and mini-ARBAC which are simplified variations of the widely used RBAC [9] and ARBAC97 [22] model, respectively. The variation of mini-RBAC and mini-ARBAC model we use excludes sessions, role hierarchies, static mutual exclusion of roles, conditional revocation, changes to the permission-role assignment, and role administration operations. We use mini-RBAC and mini-ARBAC due its similarities with the widely popular RBAC and ARBAC model. We refer interested reader to [23,24] for a more detailed presentation. **Definition 1 (mini-RBAC model).** A mini-RBAC model $\gamma$ is a tuple $(U, R, P, U A, P A)$ in which $U$, $R$, and $P$ represents the finite set of users, roles, and permissions, respectively. Each element of $P$ is a pair $(a, o)$ where $a$ represents an action and $o$ denotes an object. The formal type of $a$ and $o$ will be given later. $U A \subseteq U \times R$, denotes the set of user-role assignment and $P A \subseteq R \times P$, denotes the set of permission-role assignment. **Definition 2 (mini-ARBAC policy).** A mini-ARBAC policy $\Phi$ is a pair $(CA, CR)$ in which $CA$ and $CR$ denotes the set of can_assign and can_revoke rules, respectively. The following is the formal type of $CA \subseteq R \times C \times R$ in which assign rule \((r_a, c, r_i) \in CA\) specifies that a user in role \(r_a\) is authorized to grant a target user the target role \(r_i\) provided that the target user satisfies the pre-condition \(c\). A pre-condition \(c\) is a conjunction of positive and negative role memberships. The formal type of \(CR\) is \(CR \subseteq R \times R\). Each \((r_a, r_i) \in CR\) represents that a user in role \(r_a\) can revoke the \(r_i\) role from another user. 2.2 Obligation Model We now summarize the obligation model proposed by Pontual et al. [20]. Note that, we augment this model for supporting cascading obligations in section 3. We use \(U \subseteq U\) to denote the finite set of users in the system at any given point of time. We use \(u\) possibly with subscripts to represent users. The finite set of objects in the system is denoted by \(O \subseteq O\). We use \(o\) with possibly subscripts to range over the elements of \(O\). Note that, the universes \(U\) and \(O\) are countably infinite as we want to model systems of finite but unbounded sizes. For supporting administrative actions, we have \(U \subseteq O\). The set of possible actions in the system is given by \(A\). The formal type of \(A\) is given below: We denote a system state with \(s = (U, O, t, \gamma, B)\) where \(t \in T\) denotes the current system time, \(\gamma \in \Gamma\) represents the mini-RBAC authorization state, and \(B \subseteq B\) represents the current pool of obligations. Obligations in the system have the form \(b = (\mathcal{u}_a, \mathcal{a}, \mathcal{c}, \mathcal{r})\), the universe of which, \(B\) has the formal type \(U \times A \times O^* \times T\). \(b\) is a function that takes as input \((\mathcal{u}_a, \mathcal{a}, \mathcal{c}, \mathcal{r})\) and returns a set of obligations (possibly empty) \(\{\mathcal{u}_a, \mathcal{a}, \mathcal{c}, \mathcal{r}\}\) predicate of a policy rule \(p\) (definition 3). We then formally specify the transition relation of the system. **Definition 3.** For all \(u \in U\) and \(o \in O^*\), \(\gamma \vdash \text{cond}(u, o, \delta)\) if and only if the following holds. \[ \begin{align*} & \exists r, t \in T, (u, r) \in \gamma \wedge \text{cond}(u, o, \delta) \\ & \quad \wedge (\forall r' : (u, r) \wedge (v, r) \in \gamma \Rightarrow \text{cond}(v, o, \delta)) \\ & \quad \wedge (\forall r' : (u, r) \wedge (v, r) \in \gamma \Rightarrow \text{cond}(v, o, \delta)) \end{align*} \] **Definition 4 (Transition Relation).** Given any sequence of event/policy-rule pairs, \((e, p)_{i=0,k-1}\), and any sequence of system states \(s_0, s_{k+1}\), the relation \(\rightarrow \subseteq (S \times (E \times P))\) is defined inductively on \(k \in \mathbb{N}\) as follows: 1. \(s_k \xleftarrow{(e,p)_{0\ldots k-1}} s_{k+1}\) holds if and only if, letting \(p_k = (a, \delta) \leftarrow \text{cond}(u, o, \delta) : F_{\text{obl}}(s, u, o, \delta)\), we have \(s_k \vdash \gamma \Rightarrow \text{cond}(c_k, u, c_k, o, \delta, a)\), and \(s_{k+1} = (U', O', t', \gamma', B')\), in which \((U', O', \gamma', B') = (a, \delta)(s_k, U, s_k, O, s_k, \gamma, B')\) when \(c_k \in B\), and \(B' = s_k, B \cup F_{\text{obl}}(s_k, c_k, u, c_k, o, \delta)\) otherwise. \(t'\) denotes the system time when \(a\) is completed. 2. \(s_0 \xleftarrow{(e,p)_{0\ldots k}} s_{k+1}\) and if only if there exists \(s_k \in S\) such that \(s_0 \xleftarrow{(e,p)_{0\ldots k-1}} s_k\) and \(s_k \xleftarrow{(e,p)_{0\ldots k}} s_{k+1}\). 3. ENHANCEMENT OF THE MODEL In this section, we extend the obligation model of Pontual et al. [20] to facilitate the specification and analysis of accountability in presence of cascading obligations. 3.1 Time Interval of the Incurred Obligation In the previous obligation model [20], when a discretionary action \(a\) is taken at time \(t\) and it causes an obligation \(b\) to be incurred, the time interval of \(b\) depends on the time \(t\). Thus, the time interval of \(b\) is calculated using a fixed offset from \(t\) and the interval size of \(b\). Let us assume the fixed offset is \(\delta\). and the interval size of $b$ is $w$. So, the time interval of $b$ will be $[t+\delta, t+\delta+w]$. Now, consider the case where an obligation $b_1$ with time interval $[s, e]$ incurs another obligation $b_2$. The time $t$ at which $b_1$ can possibly be performed can be any value between $s$ and $e$, inclusive. Thus, we have several possible intervals for $b_2$ considering each possible values of $t$ (see figure 1(a)). For deciding strong accountability, we have to check whether $b_2$ is authorized in each of the possible time intervals. One possibility is to consider the interval $[s+\delta, e+\delta+w]$ to be the time interval of $b_2$, as all the possible time intervals are inside this interval. However, when $b_1$ is performed (we know $t$) we get $b_2$'s original time interval and have to shrink the large time interval $[s+\delta, e+\delta+w]$ appropriately with respect to $t$. When we use this approach, it will yield runtime overhead for managing obligations and accountability will be less likely to hold due to increasingly large obligation time intervals. To mitigate this problem, we assume that $b_2$'s time interval will be at a fixed distance $\delta \in \mathbb{N}$ from the time interval of $b_1$ (see figure 1(b)). We assume $\delta$ is measured from the end time of $b_1$'s interval. Thus, $b_2$'s stipulated time interval in our approach will be $[e+\delta, e+\delta+w]$. This approach will ensure that the cascading obligation’s time interval is fixed. For a discretionary action incurring an obligation, we replace $e$ with $t$, the time at which the action is performed. Thus, in our model obligations have the form $b = (u, a, \delta, t, s, t, e, \delta, w)$. In section 4.4.2, we further augment our obligations to contain one additional field (replication). We also extend the notion of the transition relation to allow cascading obligations. 3.2 Selection of Obligatee We now present some strategies by which a user who incurs obligations, can be specified in the policy. When a user executes an action, this can generate other obligations to the user who initiated the action, or for other users. The user who incurs an obligation is called an obligatee. Existing work [12, 20] does not discuss how obligatees are specified in the policy. To allow the specification of obligatees, we extend the policy rules to include an extra field called “obligatee”. Thus, policies now have the following form: $p = a(u, \delta) \leftarrow \text{cond}(u, a) \land F_{\text{obl}}(\text{obligatee}, s, u, \delta, w)$. Note that, $F_{\text{obl}}$ function returns a set of obligations and is guaranteed to terminate in a constant time. Explicit User: In this strategy, the obligatee is hard-coded in the policy rule. Example 5 (Explicit User). Let us consider the following policy rule, $p_0 : \text{check}(u, \log) \leftarrow (u \in \text{manager}) \land F_{\text{obl}}(\text{Bob}, s, u, \log, \delta = 10, w = 5)$. This rule authorizes a user in the role of manager to check the log and it will incur an obligation\footnote{The action associated with the obligation will be specified in the body of the $F_{\text{obl}}$ function.} for Bob. Self, Target, and Explicit User: In this strategy, the obligatee field can contain “Self”, “Target”, or an explicit user. When a policy rule’s obligatee field contains “Self”, it represents that the user who initiates the action, authorized by the current policy, will incur the associated obligations. Example 6 (Self). Let us consider a policy rule, $p_1 : \text{grant}(u, \{u, \text{programmer}\}) \leftarrow ((u \in \text{manager}) \lor (u \in \text{employee})) \land F_{\text{obl}}(\text{Self}, s, u, \{u, \text{programmer}\}, \delta = 10, w = 5)$. This rule authorizes a user $u$ in the role of manager to grant a new role programmer to a target user $u_1$ in the role of employee and this will incur an obligation for $u$. Let us consider that manager Bob grants the employee Alice the role programmer. This will generate a new obligation for Bob. On the other hand, whenever the policy rule is authorizing an administrative action and the obligatee field of that policy rule contains “Target”, it signifies that the target of the original administrative action authorized by this policy would incur the obligations specified by it. Example 7 (Target). Let us consider a policy rule, $p_2 : \text{grant}(u, \{u, \text{programmer}\}) \leftarrow ((u \in \text{manager}) \lor (u \in \text{employee})) \land F_{\text{obl}}(\text{Target}, s, u, \{u, \text{programmer}\}, \delta = 10, w = 5)$. The policy rule $p_2$ is similar to $p_1$ except it incurs an obligation for the target. As in the previous example, when Bob grants the role programmer to Alice, Alice will incur an obligation as she is the target of the action. Role Expression: In this approach, the obligatee field can contain a boolean role expression. Each literal in the boolean expression is either a positive or a negative role membership test. The system can select a user to be the obligatee provided that the user satisfies the role expression when the original action is performed. A comprehensive example of this strategy is presented in appendix A. In the current work, we use the “Self, Target, and Explicit User” scheme to specify the obligatee. Although this approach is not the most general strategy to specify an obligation, our accountability decision procedure requires every obligation to have an individual user statically associated with it. However, in the “Role expression” scheme multiple users can satisfy the role expression specified in the obligation policy rule. Thus, we have two possible interpretations of strong accountability. One of which says that the newly incurred obligation will maintain accountability if at least one of the users satisfying the role expression is authorized to perform the obligation during its whole time interval. The other interpretation requires that every user who satisfies the role expression must be authorized to perform the obligation during its whole time interval. Although both of the interpretations have practical utility, the choice of interpretation will influence the time complexity of the accountability decision procedure. We leave the adoption of the role expression scheme for specifying the obligatee as a future work. 4. STRONG ACCOUNTABILITY When considering user obligations that depend on and affect authorization, we can have a situation where a user can incurs obligations which she is not authorized to fulfill. How- never, without any preemptive approach, the obligatee will realize the absence of proper authorization in the time she attempts the obligation. This can hinder the proper func- tioning of the system. To mitigate this, Irwin et al. [12] introduced a property of the authorization state and the current obligation pool, accountability, that ensures that all the obligatory actions are authorized in some part of their time interval. Based on when they are supposed to be au- thorized in their time intervals, they introduced two varia- tions of the accountability property, weak and strong. Pon- tual et al. [20] have shown that deciding weak accountability is co-NP complete for a model using mini-RBAC and mini- RBAC, whereas deciding strong accountability is poly- nomial. Due to its high complexity, we do not consider weak accountability. Roughly, strong accountability requires that as long as prior obligations have been performed in their stip- ulated time interval, each obligatory action must be autho- rized no matter what policy rules are used to authorize the other obligations and no matter when they are performed in their time interval. In this section, we first present the definition of strong accountability presented by Pontual et al. [20]. As men- tioned before, their definition of strong accountability does not take into account cascading obligations. We call their notion of the property restricted strong accountability. We then refine their notion of the property and give a recursive definition of it considering the presence of cascading obliga- tions. We go on to show that deciding strong accountability in presence of cascading obligations in general is NP-hard. We then consider some special cases of cascading obligations and give a tractable decision procedure for deciding strong accountability in their presence. 4.1 Restricted Strong Accountability Roughly stated, under the assumption that all previous obligations have been fulfilled in their time interval, strong accountability property requires that each obligation be au- thorized throughout its entire time interval, no matter when during that interval the other obligations are scheduled, and no matter which policy rules are used to authorize them. Given a pool of obligations $B$, a schedule of $B$ is a se- quence $b_{0..n}$ that enumerates $B$, for $n = |B| - 1$ (including the possibility that $B$ may be countably infinite). A sche- dule of $B$ is valid if for all $i$ and $j$, if $0 \leq i < j \leq n$, then $b_i$ start $\leq b_j$ end. This prevents scheduling $b_i$ before $b_j$ if $b_j$ end $< b_i$ start. Given a system state $s_0$ and a policy $P$, a proper prefix $b_{0..j}$ of a schedule $b_{0..n}$ for $B$ is authorized by policy-rule sequence $p_{0..j}$ $\subseteq P^*$ if there exists $s_{j+1}$ such that $s_0 (b_{0..j}) s_{j+1}$. Definition 8 (Restricted Strong Accountability). Given a state $s_0$ in $S$ and a policy $P$, we say that $s_0$ is strongly accountable (denoted by RStrongAccountable($s_0$, $P$)) if for every valid schedule, $b_{0..n}$, every proper prefix of it, $b_{0..k}$, for every policy-rule sequence $p_{0..k}$ $\subseteq P^*$ and every state $s_{k+1}$ such that $s_0 (b_{0..k}) s_{k+1}$, there exists a policy rule $p_{k+1}$ and a state $s_{k+2}$ such that $s_{k+1} (b_{0..k} p_{k+1}) s_{k+2}$. 4.2 Unrestricted Strong Accountability In this section, we provide a formal specification of the strongly accountability property with cascading obligations. The strongly accountability definition presented by Pontual et al. [20] disallowed cascading obligation. We extend their model to allow them. We define three auxiliary functions that will be used in the definition of strong accountability. Definition 9 ($\Psi$ function). $\Psi$ is a function that takes as input an obligation $b$ and a fixed set of policy rules $P$ and returns a set of sets of obligations $B$ in which each element represents a set of obligations that $b$ can incur according to the $F_{\text{obl}}$ function of a policy rule authorizing it. The formal specification and the type of $\Psi$ are precisely shown below. \[ \Psi : B \times FP(P) \rightarrow FP(FP(B)) \] \[ \Psi(b, P) = \left\{ \begin{array}{l} F_{\text{obl}}(\text{obligate}, s, u, \alpha, \delta, \epsilon, \delta, w) \mid p = (a(u, \alpha) \leftarrow \text{cond}(u, \alpha, a)) : \\ F_{\text{obl}}(\text{obligate}, s, u, \delta, \epsilon, \delta, w) \wedge (p \in P) \end{array} \right\} \] Definition 10 ($\Pi$ function). $\Pi$ is a function that takes as input a set of obligations $B$ and a fixed set of policy rules $P$ and returns a set of sets of obligations $B$ in which each element is a possible set of obligations that all the obliga- tions of $B$ can incur. In short, $B$ is the set containing all possible combination of obligations that $B$ can incur. The formal specification of $\Pi$ and its type are shown below. \[ \Pi : FP(B) \times FP(P) \rightarrow FP(FP(B)) \] \[ \Pi(B, P) = \left\{ B \subseteq B \mid \forall i \in 1 \ldots n. \Psi(b_i, P) \end{array} \rightarrow \exists f \in \Psi(b_i, P), f \subseteq BB \]\n Definition 11 ($\Xi$ function). $\Xi$ is a function that takes as input a set of sets of obligations and a set of policy rules and applies $\Pi$ to each of set of obligations and then combines the results. This allows us to find the set of all possible sets of obligations generated by a given set of possible obligations. For simplicity in later definitions, we also include in the out- put sets, the original sets which generated those obligations. \[ \Xi : FP(FP(B)) \times FP(P) \rightarrow FP(FP(B)) \] \[ \Xi(B, P) = \left\{ \forall B \subseteq B \cup \bigcup_{B \in \Pi(B)} \right\} \] Note that, each action $a$ in our system can be authorized by multiple policy rules. Each of the policy rules authorizing $a$ can incur different obligations. Furthermore, it can be the case that among different possible obligations incurred due to $a$, some of them maintain accountability and some of them do not. Provided that the policy allows infinite cascading obligations and $a$ is authorized by multiple policy rules, each of which incurs different obligations, then all possible ob- missions incurred due to $a$ can be modeled as a tree (possibly infinite). Based on this, we can have two interpretations of strong accountability, existential and universal. The ex- sential interpretation requires that there exists a single path in the tree in which all the obligatory actions maintain ac- countability when added to the current pool of obligations. The universal interpretation is the dual and requires that all the paths in the tree maintain strong accountability. We think the universal interpretation is too strong. As a result however, the following definition can be extended to express the universal interpretation of strong accountability. is NP-hard in the size of \( B, \gamma, \) and \( \Phi \), where \( B_e \) is the set of cascading obligations incurred by \( b \). 4.4 Special Cases of Cascading Obligation As in section 4.3, deciding accountability in presence of cascading obligations is NP-hard. Our goal is to find certain special cases of cascading obligations for which the accountability decision is tractable. This section introduces two such special cases. 4.4.1 Finite Cascading Obligation In this special case of cascading obligation, we consider that the policy is written in a way that the maximum number of new obligations incurred by a single obligation is bounded by a constant (see appendix A). Furthermore, we also consider that each action, object pair is authorized by only one policy rule. We also assume that the policy rules are free of cycles prohibiting infinite cascading. This can be achieved by a static checking for cycles in the policy. 4.4.2 Repetitive Obligation Repetitive obligations occur recurrently after a fixed amount of time. A real life example of repetitive obligation can be found in the chapter 6803(a) of Gramm-Leach-Bliley Act (GLBA) \[1\]. According to the regulation, a financial institution must send a customer an annual privacy notice as long as the individual is a customer. Note that, we cannot specify repetitive obligations in our model directly. For this, we follow Ni et al. \[18\] to augment our obligations with an extra field that specifies the number of repetition (denoted by \( \rho \)). We allow both finite and infinite repetitive obligation. Now, let us consider an obligation \( b = \{u, a, \delta, t_e, t_e, \delta, \rho, w \} \). This obligation is considered to be infinite repetitive when \( \rho = I \) or finite repetitive when \( \rho \in N \) and \( \rho > 1 \). Finite Repetitive Obligations. This kind of obligation recurs finitely after a fixed amount of time. For instance, \( b = \{Bob, check, log, t_e = 5, t_e = 8, \delta = 2, \rho = 3, w = 3\} \) will generate 3 obligations \{Bob, check, log, 5, 8\}, \{Bob, check, log, 10, 13\}, and \{Bob, check, log, 15, 18\}. Infinite Repetitive Obligations. This kind of obligations on the other hand recurs indefinitely. For example, \( b = \{Bob, check, log, t_e = 5, t_e = 8, \delta = 2, \rho = I, w = 3\} \) will generate the following infinite number of obligations: \{Bob, check, log, 5, 8\}, \{Bob, check, log, 10, 13\}, \ldots. 4.5 Algorithm As deciding accountability in presence of cascading obligations is NP-hard, we simplify our accountability decision problem by imposing several restrictions on the problem. The restrictions are: (1) We consider each action, object pair is authorized by one policy rule, prohibiting disjunctive choices. (2) We require that the policy is free of cycles which prohibits obligations which incur an infinite number of new obligations. (3) We disallow role expressions to specify the obligee of the new obligation. (4) We also disallow finite cascading obligations which incur repetitive obligations. (5) We also disallow repetitive obligations which incur non-repetitive cascading obligations. Under restrictions, strong accountability can be decided in polynomial time of the policy size, number of obligations, and the number of new obligations that need to be considered. The algorithm (algorithm 1) decides whether adding an obligation to an accountable pool of obligations maintains accountability. The algorithm takes as input the account- able pool of obligations $B$ (containing the finite cascading, finite repetitive, and infinite repetitive obligations), the current authorization state $\gamma$ of the system, a mini-ARBAC policy $\Phi$, and the new obligation $b$. It returns true when adding $B \cup \{b\} \cup B_i$ is strongly accountable where $B_i$ is the new set of obligations incurred by $b$. Note that, the time complexity of the algorithm additionally depends on the type of the obligation to be added and the number of infinite repetitive obligations that need to be unrolled. The complexity of the algorithm is precisely described in appendix C. In the algorithm 1, the new obligation $b$ can either incur no new obligations, finite cascading obligations, finite repetitive obligations, or infinite repetitive obligations. Based on what kind of new obligation(s) $b$ incurs, we have to take different course of actions. The main idea behind the algorithm is to unroll a finite amount of new obligations and use the non-incremental algorithm presented by Pontual et al. [20] to decide whether the original pool of obligation in addition with the new obligation and finitely unrolled obligation is strongly accountable. The way in which each type of obligation is unrolled is presented in the following discussion. **Algorithm 1 StrongAccountableCascading ($\gamma, \Phi, B, b$)** **Input:** A policy ($\gamma, \Phi$), a strongly accountable obligation set $B$, and a new obligation $b$ that generates cascading obligations. **Output:** returns true if addition of $b$ to the system preserves strong accountability. 1: if $b, \rho = 1$ then 2: $B_{final} := B \cup UnrollCascading(\gamma, \Phi, b);$ 3: else if $b, \rho = 1$ then 4: $B_{final} := B \cup \{b\};$ 5: else 6: $B_{final} := B \cup UnrollFiniteRepetitive(\gamma, \Phi, b);$ 7: $m := MaxEndTime(B_{final});$ 8: $B_{final} := B_{final} \cup UnrollInfiniteRepetitive(\gamma, \Phi, B_{final} - m);$ 9: for each obligation $b^* \in B_{final}$ do 10: if $b^*, a = grant$ or revoke then 11: InsertIntoDataStructure($b^*$); 12: for each obligation $b^* \in B_{final}$ do 13: if $Authorised(\gamma, \Phi, B_{final}, b^*) = false$ then 14: return false 15: return true **Unrolling Finite Cascading Obligations.** To unroll the chain of cascading obligations incurred by $b$, Algorithm 1 uses procedure UnrollCascading described in Algorithm 2. This procedure is an adapted breadth-first search algorithm. Recall that we disallow infinite cascading obligations which guarantees that the procedure UnrollCascading will terminate. Furthermore, we also impose the restriction that each action, object pair can be authorized by only one policy rule. Thus, the new obligations incurred by a fixed obligation will be finite and fixed. For this, we use the function $\Psi$ (discussed in section 4.2) that takes an obligation $b$ and set of policy rules and returns a set of set of obligations which can be possibly incurred by $b$. Due to the restriction above, the result of $\Psi$ will be a single set of obligations $B_j$ that can be incurred by $b$. The different fields of each obligation $b \in B_j$ will depend of the fields of $b$ and the policy rule that authorizes $b$. **Unrolling Finite Repetitive Obligations.** When the new obligation we want to add ($b$) is a finite repetitive obligation ($b, \rho \in \mathbb{N}$ and $b, \rho > 1$), we use the procedure UnrollFiniteRepetitive described in Algorithm 3 to unroll it appropriately. We follow the procedure presented in appendix B to unroll finite repetitive obligations. Thus, for the obligation $b$, the procedure UnrollFiniteRepetitive clones $b$, varying only the time intervals of the new obligations based on $b, \delta$. The exact number of copies of $b$ that are unrolled will depend on $b, \rho$. **Algorithm 2 UnrollCascading ($\gamma, \Phi, B, b$)** **Input:** A policy ($\gamma, \Phi$) and a new obligation $b$. **Output:** returns a set of cascading obligations $B$ that is generated by $b$. 1: $B = \emptyset;$ 2: queue < obligation > $q;$ 3: q.push($b$); 4: while q.empty() do 5: $b = q.front(); B = B \cup \{b\};$ 6: q.pop(); $B' = \Psi(b, \Phi);$ 7: for each obligation $b^* \in B'$ do 8: q.push($b^*$); 9: return $B$ **Figure 3: Computing Period of Infinite Repetitive rollFiniteRepetitive** described in Algorithm 3 to unroll it appropriately. We follow the procedure presented in appendix B to unroll finite repetitive obligations. Thus, for the obligation $b$, the procedure UnrollFiniteRepetitive clones $b$, varying only the time intervals of the new obligations based on $b, \delta$. The exact number of copies of $b$ that are unrolled will depend on $b, \rho$. **Algorithm 3 UnrollFiniteRepetitive ($\gamma, \Phi, b$)** **Input:** A policy ($\gamma, \Phi$) and a finite repetitive obligation $b$. **Output:** returns a set of unrolled obligations $B$ that is generated by $b$. 1: $B = \emptyset;$ 2: $i := 1;$ 3: while $i \leq b, \rho$ do 4: $b_{i} := b; b_{i + \alpha} := i + b, \alpha - b, \delta;$ 5: $i := i + 1;$ 6: return $B$ **Unrolling Infinite Repetitive Obligations.** When the obligation we want to add ($b$) is an infinite repetitive obligation, Algorithm 1 uses procedure UnrollInfiniteRepetitive, described in algorithm 4, to unroll a finite amount of it. Let us consider $B, \subseteq B$ is the set of infinite repetitive obligations. Note that, $b \in B_i$. First, we find the overall period of all the obligations in $B_i$ at which the infinite repetitive obligations repeat themselves. In figure 3 we have two infinite repetitive obligations, $b_1 = \{u_1, a, o, t_s = 1, t_e = 5, \delta = 1, \rho = I, w = 4\}$ and $b_2 = \{u_1, a, o, t_s = 1, t_e = 10, \delta = 1, \rho = I, w = 9\}$. It is clear that after time 11, we see a pattern formed by the obligations, this is the overall period. The overall period is the least common multiple (LCM) of the periods of each $b_i \in B_i$. For each infinite repetitive obligation $b_i$, the period of $b_i$ is given by $b_i, \delta + b_i, w$. Once the period is computed, we check to see whether the overall period is greater than the maximum end time of the finite obligations (repetitive or non-repetitive). If this is the case, we just need to unroll the infinite repetitive obligations three periods (to be safe). Otherwise, we unroll the infinite obligations until the maximum time, and then we unroll two additional periods (figure 4). In the current pool of obligations let us assume that the only type of obligations present are the infinite repetitive obligations. When we have calculated the overall period of these infinite repetitive obligations, part of the authorization state influencing the permissibility of the infinite repetitive obligations, after each of these period should be equivalent to the authorization state before, if the system is accountable. If the authorization state is not necessarily equivalent, this will be revealed when the second repetition is analyzed. Thus, we do not need to analyze the infinite repetitive obligations beyond two repetitions. Similarly, when we have other types of obligations residing in the current pool of obligations, we can safely unroll the infinite repetitive obligations for two additional period after the maximum end time of the finite obligations and soundly decide accountability. **Algorithm 4 UnrollInfiniteRepetitive (γ, Φ, B, m)** **Input:** A policy (γ, Φ), a set of obligations, where B ⊆ B is a set of infinite repetitive obligations, and m, representing the last time point where a non-infinite obligation happens. **Output:** returns a set of unrolled obligations B' that is generated by B. 1. \( B' = \emptyset; \ period = \text{LCM}(B) \) 2. if \( \text{period} > m \) then 3. \( \text{finalTime} := \text{period} * 3; \) 4. else 5. \( \text{finalTime} := \left(\lceil (m/\text{period}) \rceil + 2\right) \times \text{period}; \) 6. for each obligation \( b' \in B \) do 7. \( \text{end} := b'.t_e; \) 8. while \( \text{end} < \text{finalTime} \) do 9. \( b_i := b'; b_i.t_e := (b'_i . w - b'_i . \delta) \times i + b'_i . t_e - b'_i . \delta; \) 10. \( b_i.t_e := b_i.t_e - w; B' = B' \cup \{b_i\}; \ end := b_i.t_e; \) 11. return \( B' \) We now briefly summarize the non-incremental algorithm for deciding strong accountability due to Pontual et al. [20] which we use as a procedure for deciding accountability in presence of special cases of cascading obligations. We refer readers to Pontual et al. [20] for a detailed presentation. The non-incremental algorithm takes as input a set of obligations, an authorization state, and a mini-ARBAC policy and returns true when the set of obligations is strong accountable. For this, the algorithm inserts all the administrative obligations in the set to a modified interval search tree. Then it checks whether each of the obligation is authorized in its whole time interval. To do this, the algorithm inspects whether the user performing the obligation has the necessary roles in the whole time interval. For simplicity, let us consider the user u needs the role r to perform the obligation. Then, the algorithm checks whether u has role r in the current authorization state. If so, then it checks whether there is an obligation overlapping with the current obligation that revokes r. If not, then u is guaranteed to have role r in the whole time interval. In case, u currently does not have role r, then the algorithm checks whether there is a grant of the role r to u and no one is revoking it. If that is the case, then u is guaranteed to have role r in the whole time interval. **5. EMPIRICAL EVALUATION** The goal of the empirical evaluations is to determine whether strong accountability can be decided efficiently for some special cases of cascading obligations. For those cases, our empirical evaluations illustrate that it is actually feasible to decide the strong accountability property. The algorithm for deciding strong accountability for special cases of cascading obligations is implemented using C++ and compiled with g++ version 4.4.3. All experiments are performed using an Intel i7 2.0GHz computer with 6GB of memory running Ubuntu 11.10. **5.1 Input Instance Generation** As in the case for many security researchers, we do not have access to real life access control policies that contain obligations. Thus, we synthetically generate problem instances for our empirical evaluations. We believe the values of the different parameters we assume are appropriate for a medium sized organization. In our experiments, we consider 1007 users, 1051 objects, and 551 roles. We also consider 53 types of actions, 2 of which are administrative (grant and revoke). We handcrafted a mini-RBAC and mini-ARBAC policy with 1251 permission assignment rules, 560 role assignment rules (maximum 5 pre-conditions in each), and 560 role revocation rules. Among the policy rules, 100 of them can incur new obligations. Each of which can incur a maximum of 10 new obligations totaling 1000 new cascading obligations. To generate the obligations, we handcrafted 6 strongly accountable sets of obligations in which each set has 50 obligations. Each set has a different ratio of administrative to non-administrative obligations (rat). We then replicated each set of obligations for different users to obtain the desired number of obligations. Similarly, we generate the infinite and finite repetitive obligations, we use 6 sets of repetitive obligations that are strongly accountable. The execution times shown are the average of 100 runs of each experiment. **5.2 Empirical Results** Our accountability decision procedure takes as input an accountable pool of obligations \( B \), the current authorization state \( \gamma \), a mini-ARBAC policy \( \Phi \), and a new obligation \( b \). It returns true when adding \( b \) and its associated new obligations maintain accountability. In these empirical evaluations, we consider cases where \( b \) can incur a finite amount of new obligations and can be finitely (infinitely) repetitive. **Finite Cascading Obligations.** In this case, we add an obligation to a strongly accountable set of obligations. This obligation in turn incurs 1000 new obligations. Then, the algorithm needs to decide whether these 1000 obligations along with the original strongly accountable obligation set is still strongly accountable. Figure 5 presents the results for the strong accountability algorithm for this case. Although the number of cascading obligations is fixed (1000) throughout this experiment, we vary the number of obligations by changing the number of pending obligations in the pool from 0 to 99000. We follow the same strategy for all the other cases. The time required by the strong accountability algorithm grows roughly linearly in the number of obligations. In the worst case (99,000 administrative obligations plus 1000 finite cascading obligations), the algorithm runs in 103 milliseconds to determine that the set is strongly accountable. This is roughly two times slower than the non-incremental strong accountability algorithm presented by Pontual et al. [20] without cascading of obligations. This is due to the overhead of unfolding the cascading obligations (algorithm 3). As the algorithm must inspect every obligation following each administrative obligation, rat influences the execution time of the algorithm. In addition, we have also simulated (not shown) the same case when the original set of obligations have infinite repetitive obligations, in this case the worst execution time is still 103 milliseconds. This is due to the fact that the time of procedure UnrollCascading dominates the time of procedure UnrollInfiniteRepetitive. Finite Repetitive Obligations. In this experiment, we add a finite repetitive obligation to a strongly accountable obligation set. This new obligation repeats 1000 times ($\rho = 1000$). The algorithm decides whether the old set of obligations plus the 1000 copies of the repetitive obligation is strongly accountable. The execution time of the strong accountability algorithm grows roughly linearly in the number of obligations. In the worst case, the algorithm runs in 66 milliseconds to decide whether the set is strongly accountable. In general, if the number of obligations generated by the finite repetitive obligations is not too large (when compared with the original set), the time necessary to decide accountability is not affected by the addition of finite repetitive obligations. As algorithm 3 can unroll the repetitive obligations in a trivial way, the overhead of this procedure will be small provided that the number of repetition is small. In addition, we have also simulated (not shown) the same case when the original set of obligations have infinite repetitive obligations. The worst case execution time, for this case, is 66 milliseconds. Infinite Repetitive Obligations. In these experiments, we add an infinite repetitive obligation to a strongly accountable obligation set that already contains some infinite repetitive obligations. These infinite repetitive obligations together with $b$ is cloned for a total of 519 times. Figure 6 shows the results for the strong accountability algorithm for this case. The execution time of the strong accountability algorithm grows roughly linearly in the number of obligations. In the worst case, the algorithm runs in 66 milliseconds. Figure 5: Finite Cascading Obligations. Figure 6: Infinite Repetitive Obligations. 6. RELATED WORK Obligations have received a lot of attention from different researchers [3,4,6,7,10,12–19,21,25,26]. Some of them are interested in efficiently specifying obligatory requirements [3, 4, 6, 15, 19, 25, 26] and others are interested in the management of obligations [3,7,10,12,14,18,21]. Ni et al. [18] presented a user obligation model based on an extended role based access control for privacy preserving data mining (PRBAC) [19]. Their model supports repeated obligations, cascading obligations, pre and post-obligations and also conditional obligations. In addition, they also present how to detect infinite obligation cascading in a policy. Their work is complimentary to ours, since we study the impact of different types of cascading obligations when deciding accountability. Ali et al. [2] presented an enforcement mechanism for obligations in service oriented architectures. Their model supports repetitive obligations, conditional and pre-obligations, but do not support finite cascading obligations. Although their model is more expressive than ours, they assume that obligations have all the necessary permissions. Elrakaiby et al. [8] borrow the concepts of Event Condition Action from the area of database to present an obligation model. It supports pre and post-obligations, on-going, and continuous obligations. Obligations can have relative or absolute deadlines. To cope with violations, conflicts, and lack of permissions, they adopt a set of strategies such as sanctions for users that violate obligations, cancellation of obligations, delay of obligations, and re-compensation for users that fulfill their obligations. In contrast, we use accountability to detect violations before they occur. Li et al. [14] extended XACML [26] to support a richer notion of obligations. They view obligations as state machines and can express pre-obligations, post-obligations, stateful-obligations, etc. However, they do not consider obligations requiring authorizations and in turn do not concentrate on deciding accountability. In this sense, our view of managing obligations is different than theirs. 7. CONCLUSION AND FUTURE WORK In current work, we have refined the notion of strong accountability due to Irwin et al. [12] to allow cascading obligations. We also enhance the obligation model used by Pontual et al. [20] to support the specification of cascading obligations. We present several proposals to specify the obligation in the policy. We then show that deciding accountability in general is NP-hard. Thus, we consider several simplifications for which the strong accountability decision becomes tractable. We provide an algorithm, its complexity, and also present empirical evaluations of the algorithm. Our experiments show that accountability can be efficiently decided for special cases of cascading obligations. We want to explore other approaches for obligatee specification and understand their impact on accountability decision. Furthermore, we want to explore how to specify different kinds of obligations, namely, negative obligations, stateful obligations, group obligations, etc., in our model and also study their impact on accountability decision. 8. ACKNOWLEDGEMENT Ting Yu is partially supported by NSF grant CNS-0716210. Jianwei Niu is partially supported by NSF grant CNS-0964710. We would like to thank the anonymous reviewers and Andreas Gampe for their helpful suggestions. 9. REFERENCES [18] Q. Ni, E. Bertino, and J. Lobo. An obligation model bridging access control policies and privacy policies. In SACMAT ’08, New York, NY, USA. ACM. APPENDIX A. CASCADING OBLIGATIONS EXAMPLE Let us assume the following policy rules. Policy rule $p_1$ allows a registered user to submit a paper and this in turn creates an obligation for a user (obligatee) to submit the review of the paper. Rule $p_2$ authorizes a user in role reviewer to submit a review of a paper and it incurs an obligation for a user in the role $PC_{chair}$ that requires him to make a decision on the paper. Rule $p_3$ authorizes a user in role $PC_{chair}$ to submit a decision for a paper and it incurs an obligation for the same user submitting the decision to notify the corresponding author. Rule $p_4$ authorizes a user in the role $PC_{chair}$ to notify the author of a paper. Now, $p_1: submit(u, paper) \leftarrow (u \in \text{registeredUser})$ $F_{ob}(\text{reviewer}, s, u, paper, 2 \text{ days}, 1 \text{ week})$ \{ (Choose \ u_1 \text{ such that } u_1 \in \text{reviewer}) \text{ submitReview}(u_1, (u, \text{paper})) \} $p_2: \text{submitReview}(u, \langle \text{author, paper} \rangle) \leftarrow (u \in \text{reviewer})$ $F_{ob}(\text{PC_{Chair}}, s, u, \langle \text{author, paper} \rangle, 1 \text{ day}, 1 \text{ day})$ \{ (Choose \ u_1 \text{ such that } u_1 \in \text{PC_{Chair}}) \text{ submitDecision}(u_1, (\text{author, paper})); \} $p_3: \text{submitDecision}(u, \langle \text{author, paper} \rangle) \leftarrow (u \in \text{PC_{Chair}})$ $F_{ob}(\text{Self, s, u, \langle \text{author, paper} \rangle, 1 \text{ day}, 1 \text{ day})$ \{ \text{notify}(u, (\text{author, paper})) \} $p_4: \text{notify}(u, (\text{author, paper})) \leftarrow (u \in \text{PC_{Chair}}): \emptyset$ Consider the following situation. The set of current users of the system is $\gamma.U = \{\text{Alice, Bob, Carol}\}$ and their current role assignments are $\gamma.UA = \{\text{Alice, registeredUser}, \text{Bob, reviewer}, \text{Carol, PC_{Chair}}\}$. Let us assume Alice submits a paper on 07/01/2012 and according to $p_1$ Bob (in role reviewer) will get the following obligation ($\text{Bob, submitReview, Alice, paper}$, 07/03/2012, 07/10/2012). According to $p_2$, this obligation in turn will incur the obligation ($\text{Carol, submitDecision, Alice, paper}$, 07/11/2012, 07/12/2012) for Carol (in role $PC_{chair}$). According to $p_3$ when Carol submits the decision, she incurs the obligation ($\text{Carol, notify, Alice, paper}$, 07/13/2012, 07/14/2012). B. REPETITIVE OBLIGATIONS Let us consider an obligation $b = \{u, a, \delta, t_a, t_e, \rho, w\}$. This obligation is considered to be infinite repetitive when $\rho = 1$ or finite repetitive when $\rho \in \mathbb{N}$ and $\rho > 1$. For finite and infinite repetition of the obligation the possible time intervals of the recurring obligation are the following. - **Infinite Repetitive**: $[t_a, t_e], [t_e + \delta, t_e + \delta + w], \ldots [t_a + (n-1)(w+\delta), t_e + (n-1)(w+\delta)] \ldots$ where $n \in \mathbb{N}$. C. COMPLEXITY ANALYSIS OF THE ALGORITHM Let us consider the current pending pool of obligations is $B$ where $|B| = n$. Moreover, let us consider $B_i \subseteq B$ denotes the set of infinite repetitive obligations in the current pending pool of obligations where $|B_i| = d$. Let us consider the number of policy rules $\Phi$ is $k$. (1) When the new obligation $b$ we want to add incurs a finite number of cascading obligations, the number of finite cascading obligations due to $b$ can be approximated by $k$. This is due to our restriction that our policies are free of cycles. Furthermore, let us consider that the number of times the infinite repetitive obligations are unrolled is $\alpha$. Thus, the total number of obligations for which we need to check accountability in this case is $\eta_c = \alpha \times d + k + (n - d)$. Then, we check each of the $\eta$ obligations are all authorized, which can be done using the non-incremental algorithm presented by Pontual et al. [20] in $O(kn^2 \times \log(\eta_c))$. (2) In the case $b$ being a finite repetitive obligation, the number of times $b$ needs to be unrolled is $b, p$. Let us denote it by $m$. Thus, the total number of obligations for which we need to check accountability in this case is $\eta_f = \alpha \times d + m + (n - d)$. The resulting complexity of the algorithm in this case will be $O(kn^2 \times \log(\eta_f))$ (3) For the case, $b$ is an infinite repetitive obligation, we have to compute the overall period of the obligations in $B_i$ and $b$. Let, $\beta$ denote the number of times the obligations in $B_i$ and $b$ needs to be unrolled. Thus, the total number of obligations for which we need to check accountability in this case is $\eta_i = \beta \times (d + 1) + (n - d)$. This results in a time complexity of $O(kn^2 \times \log(\eta_i))$.
{"Source-Url": "http://homepage.divms.uiowa.edu/~comarhaider/publications/obligation-sacmat12.pdf", "len_cl100k_base": 13656, "olmocr-version": "0.1.50", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 45288, "total-output-tokens": 16213, "length": "2e13", "weborganizer": {"__label__adult": 0.0004475116729736328, "__label__art_design": 0.00064849853515625, "__label__crime_law": 0.002056121826171875, "__label__education_jobs": 0.002956390380859375, "__label__entertainment": 0.00013375282287597656, "__label__fashion_beauty": 0.00030493736267089844, "__label__finance_business": 0.003261566162109375, "__label__food_dining": 0.0003910064697265625, "__label__games": 0.0011987686157226562, "__label__hardware": 0.0014371871948242188, "__label__health": 0.0019702911376953125, "__label__history": 0.0005712509155273438, "__label__home_hobbies": 0.00022220611572265625, "__label__industrial": 0.0007762908935546875, "__label__literature": 0.0005092620849609375, "__label__politics": 0.0008282661437988281, "__label__religion": 0.0004940032958984375, "__label__science_tech": 0.401611328125, "__label__social_life": 0.00016450881958007812, "__label__software": 0.040313720703125, "__label__software_dev": 0.53857421875, "__label__sports_fitness": 0.00025200843811035156, "__label__transportation": 0.0006356239318847656, "__label__travel": 0.0002281665802001953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60193, 0.02027]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60193, 0.29985]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60193, 0.8616]], "google_gemma-3-12b-it_contains_pii": [[0, 3766, false], [3766, 10679, null], [10679, 14750, null], [14750, 21237, null], [21237, 28175, null], [28175, 31668, null], [31668, 38050, null], [38050, 44549, null], [44549, 49739, null], [49739, 55404, null], [55404, 60193, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3766, true], [3766, 10679, null], [10679, 14750, null], [14750, 21237, null], [21237, 28175, null], [28175, 31668, null], [31668, 38050, null], [38050, 44549, null], [44549, 49739, null], [49739, 55404, null], [55404, 60193, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60193, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60193, null]], "pdf_page_numbers": [[0, 3766, 1], [3766, 10679, 2], [10679, 14750, 3], [14750, 21237, 4], [21237, 28175, 5], [28175, 31668, 6], [31668, 38050, 7], [38050, 44549, 8], [44549, 49739, 9], [49739, 55404, 10], [55404, 60193, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60193, 0.0]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
3fba86f5e5fc34287e87b662fb75cfb97d93a260
Learning concise pattern for interlinking with extended version space Zhengjie Fan, Jérôme Euzenat, François Scharffe To cite this version: HAL Id: hal-01180918 https://hal.archives-ouvertes.fr/hal-01180918 Submitted on 28 Jul 2015 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Learning Concise Pattern for Interlinking with Extended Version Space Zhengjie Fan INRIA & LIG 655, avenue de l’Europe Montbonnot Saint Martin 38334 Saint-Ismier, France Email: zjfanster@gmail.com Jérôme Euzenat INRIA & LIG 655, avenue de l’Europe Montbonnot Saint Martin 38334 Saint-Ismier, France Email: Jerome.Euzenat@inria.fr François Scharffe LIRMM 161 rue Ada 34095 Montpellier Cedex 5, France Email: francois.scharffe@lirmm.fr Abstract—Many data sets on the web contain analogous data which represent the same resources in the world, so it is helpful to interlink different data sets for sharing information. However, finding correct links is very challenging because there are many instances to compare. In this paper, an interlinking method is proposed to interlink instances across different data sets. The input is class correspondences, property correspondences and a set of sample links that are assessed by users as either “positive” or “negative”. We apply a machine learning method, Version Space, in order to construct a classifier, which is called interlinking pattern, that can justify correct links and incorrect links for both data sets. We improve the learning method so that it resolves the no-conjunctive-pattern problem. We call it Extended Version Space. Experiments confirm that our interlinking method with only 1% of sample links already reaches a high F-measure (around 0.96-0.99). The F-measure quickly converges, being improved by nearly 10% than other comparable approaches. I. INTRODUCTION Nowadays, many organizations and individuals publish RDF data sets on the web1, which tend to be more and more heterogeneous. Integrating heterogeneous data sets can help search web data efficiently. For example, without interlinking across library databases, a librarian has to manually browse different library databases to find a requested book, leading to response delay and mistakes. Many existing solutions are being used for interlinking. (1) One straightforward idea is to compare the property values of instances for identifying links [1], yet it is impossible to compare all possible pairs of property values. (2) Another common strategy is to compare instances’ property values with respect to property correspondences found by instance-based ontology matching [2], [3], [4], [5], [6], [7], [8], which can generate property correspondences based on instances. However, it is hard to identify the same instances across data sets, because there are the same instances whose property values of some property correspondences are not the same. (3) Many existing solutions [9], [10], [11] leverage Genetic Programming to construct interlinking patterns for comparing instances, however they spend long running times for gaining high F-masures. In order to link instances across two data sets precisely and efficiently, we design an interlinking method, which employs a supervised learning method, called Version Space [12], to generate a classifier for the interlinking task, which can cover all assessed correct links (or positive links) and exclude all assessed incorrect links (or negative links) meanwhile. This classifier is called an interlinking pattern. Assume that we are going to find out the same instances that refer to the same people from two data sets. One data set is in English, the other data set is in French. All pairs of the same instances contain two property correspondences name ↔ nom and sex ↔ gender. The interlinking pattern can be expressed as a conjunction of these two correspondences. Such a conjunctive formula can help classify pairs of instances into two classes. The pairs of instances that satisfy such a formula will be recognized as a link. The ones that do not satisfy such a formula will not be recognized as a link. The Version Space method is able to construct an interlinking pattern from a set of assessed links and a set of property correspondences across two corresponding classes as input. Nevertheless, it suffers from a serious limitation. It can only build the interlinking pattern that is represented by a conjunctive pattern, a conjunction of property correspondences that satisfies all positive links. If there is not such a conjunctive pattern, Version Space cannot produce any interlinking pattern, but a null result instead. Disjunctive Version Space is one model designed to overcome such a limitation. It is able to express the cases that cannot be represented by a conjunctive pattern, via a disjunction of conjunctive patterns. When there are several conjunctive patterns each of which satisfies only some but not all positive links, the interlinking pattern can be expressed into a disjunction of conjunctive patterns by Disjunctive Version Space. Whereas, the interlinking pattern it learns is often a long expression, which will significantly increase the interlinking running time. To this end, we propose an Extended Version Space algorithm, which includes (excludes) all positive links (negative links), with a much more concise expression than Disjunctive Version Space, which speeds up interlinking in turn. We evaluate the proposed interlinking method and other comparable methods using a set of large-scale data sets and make comparisons on the F-measure and running time. Experiments confirm that our interlinking method with only 1% sample links can already return a fairly precise link set. The F-measures quickly converge to a higher level by nearly 10% than other interlinking approaches. 1http://lod-cloud.net/ The remainder of the paper is organized as follows. We formulate the interlinking problem in Section II, and introduce related works in Section III. In Section IV and Section V, we describe Version Space and the Extended Version Space algorithm respectively. Section VI presents the experimental results based on different data sets. Finally, we conclude the paper with the future work in Section VII. II. THE DATA INTERLINKING PROBLEM Given two data sets being RDF graphs $g$ and $g'$ described by ontology $o$ and $o'$, and an alignment between classes and properties of two ontologies $o$ and $o'$, the objective is to find an interlinking pattern that covers a set of links $L$ such that $i \text{owl:sameAs} i'$ if and only if $<i,i'> \in L$. We assume that a set of class correspondences and all property correspondences across each pair of corresponding classes are available for two interlinking data sets. Since an interlinking pattern can be transferred into an interlinking script, which is executed by the semi-automatic interlinking tool Silk\(^3\) for generating links across two RDF data sets, our work will focus on leveraging the given correspondences and a set of sample user-assessed links to build a concise and precise interlinking pattern for the two data sets. III. RELATED WORK There are a group of related works that use Machine Learning\([13],[14],[15],[10],[11]\) for learning the interlinking pattern. Genetic Programming\([16]\) is a supervised learning method that is used for learning interlinking patterns in some interlinking methods\([9],[11],[10],[13]\). A genetic programming algorithm is proposed in the interlinking method of \[9\]. The method improves the interlinking patterns by changing the aggregation methods of combining property correspondences, so as to let the patterns be able to classify more assessed links. One of the most recent works on interlinking is proposed by Ngonga Ngomo et al.\([10]\). The method uses not only Genetic Programming but also Active Learning\([17]\) to construct and improve the interlinking pattern. Active Learning is a learning strategy that actively chooses unlabeled examples which bring the biggest information and change to the classifier\([17]\). It helps speed up the learning process when there are a large amount of assessed links to be learned. The interlinking approach in this paper outperforms many other solutions like\([13]\) and\([9]\). The F-measure of generated link set grows higher with the same amount of assessed links than\([13]\) and\([9]\). Another recent work on interlinking by learning the interlinking pattern is proposed by Isele et al.\([11]\). It utilizes Genetic Programming to initialize a set of candidate interlinking patterns. A variety of changes are permitted to be applied on the selected patterns when crossing over and mutating fragments of the patterns. Nevertheless, Genetic Programming is not a method suitable for interlinking at runtime. In each learning round, more than one interlinking pattern should be evaluated. The process of evaluating each interlinking pattern is to interlink the data sets with the interlinking pattern and compute the Precision, Recall and F-measure of the generated link set. When interlinking data sets with each interlinking pattern, the computer should query each data set at least once in order to get instances’ property values. The queries require I/O operations of the computer, which take a lot of running times. \[14\] is another interlinking work that uses Machine Learning for interlinking. The authors design a boolean classifier to distinguish correct links and incorrect links that are assessed by users. The boolean classifier is a conjunction of several property correspondences. However, there are many interlinking tasks whose links do not share the same set of property correspondences. Therefore, this method cannot interlink the data sets that cannot be classified by such a boolean classifier. To conclude, a learning method that costs shorter time and is able to generate interlinking patterns for all interlinking tasks is required. IV. VERSION SPACE Version Space\([12],[18]\) is a supervised learning method that constructs and improves a set of classifiers by learning labeled examples one by one. The entire objective is to build a composition of some conditions such that all labeled examples are compatible with, which is called a hypothesis. During the learning process, there are two sets of hypotheses always being maintained. One is a set of the most strict compositions of the conditions that cover all positive examples being learned, and they are called Specialized Hypotheses. The other is a set of the most general compositions of conditions that cover all cases which exclude the negative examples being learned, and they are called Generalized Hypotheses. With more positive examples being learned, the specialized hypotheses become more general. When more negative examples are learned, the generalized hypotheses become stricter. After learning all labeled examples (including positive ones and negative ones), the two sets finally converge into one set in Version Space. The learning process of Version Space can build several interlinking patterns (i.e., hypotheses for the interlinking task) which are able to precisely distinguish all assessed links across the data sets. More specifically, given a set of sample links assessed as either positive or negative by users, it can construct several interlinking patterns with several property correspondences being compatible with all of positive links and conflicting to all of negative links. For each pair of instances $i$ and $i'$ that builds an assessed link, we apply an $l$-tuple $(B^{(j)})$, $j = 1,\ldots,l$ with a sequence of bit values to denote the similarities between property values of $l$ pairs of corresponding properties. The bit value (denoted by $B^{(j)}$) is defined in Formula (1), where $\equiv$ and $\not\equiv$ refer to similarity and non-similarity between two property values $i.p_j$ and $i'.p'_j$ respectively. Each property comparison is determined by some similarity metric (such as “Levenshtein”\([19]\) and “Jaccard”\([20]\)). The bit value is equal to 0 or 1 (denoted by 0/1 in the following text), representing non-similarity and similarity respectively. For example, if there are three property correspondences across two corresponding classes, then $l$ is equal to 3, and then there will be eight possible tuples of similarity values, $(0,0,0),(0,0,1),\ldots,(1,1,1)$ for all instance pairs between the two classes. \[ B^{(j)} = \begin{cases} 1 & \text{if } i.p_j \equiv i'.p'_j \\ 0 & \text{if } i.p_j \not\equiv i'.p'_j \end{cases} \quad \text{where } j = 1,\ldots,l \quad (1) \] For each pair of corresponding properties between two corresponding classes, its similarity value is either 1 if the two property values \( i.p_1 \text{ and } i.p_2 \) on an assessed link are the same based on a similarity metric or 0 otherwise. Then, a **binary similarity sequence** (BSS) for the property pair is shown in Formula (2), where \( PC_1, PC_2, \ldots, PC_l \) stand for \( l \) property correspondences, each either being equal to 1 (equal) or 0 (non-equal). \[ (PC_1, PC_2, \ldots, PC_l) \] **Binary Similarity Sequence** = (0,1,0,1,0) (2) In general, the computed similarity of two property values may not exactly be equal to 0 or 1, but another decimal number in \([0,1]\), such as 0.75. In our design, we always convert the similarity to a binary value with a threshold \( T \). If the computed similarity value is larger than \( T \), we assume that the similarity is 1. If the computed similarity value is equal to or smaller than \( T \), we assume that the similarity is 0. The input of the Version Space learning process is a set of binary similarity sequences. The output of the Version Space learning process is one or several interlinking patterns that cover all positive links and filter all negative links simultaneously, each of which is a conjunction of property correspondences. In machine learning, the input and output of a supervised learning algorithm are expressed with instance language and generalization language respectively [12]. With respect to the interlinking problem, the instance language of Version Space is a binary similarity sequence. Each bit of the instances’ binary similarity sequences is either 0 or 1. The generalization language is also a binary similarity sequence, called a conjunctive pattern, but each bit of such a binary similarity sequence is 0, 1 or \( \times \), where \( \times = 0/1 \). **A. Problem of Version Space** In practice, there are many interlinking problem cannot be built an interlinking pattern by Version Space. In other words, it is possible that there is no conjunctive pattern that can cover all positive links and filter all negative links. An example is shown below: there are four assessed links, each having five property correspondences \( PC_1, PC_2, PC_3, PC_4, PC_5 \). <table> <thead> <tr> <th>Link No.</th> <th>Type</th> <th>( PC_1 )</th> <th>( PC_2 )</th> <th>( PC_3 )</th> <th>( PC_4 )</th> <th>( PC_5 )</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Positive</td> <td>0</td> <td>1</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>2</td> <td>Positive</td> <td>0</td> <td>0</td> <td>1</td> <td>1</td> <td>0</td> </tr> <tr> <td>3</td> <td>Negative</td> <td>1</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>4</td> <td>Negative</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>0</td> </tr> </tbody> </table> In this example, with the two positive links, there is only one specialized pattern can be produced, which is \( (0,\times,1,\times,0) \). Given a negative link, we can derive a generalized pattern by traversing all binary similarity sequences that are conflicting to the negative link with at least one bit (e.g., property correspondence \( PC_5 \)). For the above example, based on the third assessed link (a negative link), the candidate generalized patterns are binary similarity sequences: \( (0,\times,\times,\times,\times), (\times,1,\times,\times,\times), (\times,\times,0,\times,\times), (\times,\times,\times,1,\times), (\times,\times,\times,\times,1) \). Then, the generalized pattern with the first three links is supposed to be \( (0,\times,\times,\times,\times) \), in that only \( (0,\times,\times,\times,\times) \) contains all positive links that have been learned. When combining the fourth assessed link, however, a conflict arises, because there is no feasible conjunctive pattern that covers all the positive links and filters all the negative links simultaneously. Disjunctive Version Space [18] adopted disjunctive constructor to solve the above problem. The instance language of Disjunctive Version Space is a binary similarity sequence. Each bit of the instances’ binary similarity sequences is either 0 or 1. The generalization language is a disjunction of these binary similarity sequences. However, its output is represented in a more complicated format with a large number of binary similarity sequences, because the binary similarity sequences in the pattern cannot induce a more concise expression. The generalized pattern of Disjunctive Version Space of Example 3 is \( (0,0,0,0,\times),(0,0,0,1,0),(0,0,0,1,1),(0,0,1,0,1),(0,0,1,0,0),(0,0,1,1,1),(0,0,1,1,0),(0,0,1,1,1),(0,1,0,0,0),(0,1,0,0,1),(0,1,0,1,0),(0,1,0,1,1),(0,1,1,0,0),(0,1,1,0,1),(0,1,1,1,0),(0,1,1,1,1),(1,0,0,0,0),(1,0,0,0,1),(1,0,0,1,0),(1,0,0,1,1),(1,0,1,0,0),(1,0,1,0,1),(1,0,1,1,0),(1,0,1,1,1),(1,1,0,0,0),(1,1,0,0,1),(1,1,0,1,0),(1,1,0,1,1),(1,1,1,0,0),(1,1,1,0,1),(1,1,1,1,0),(1,1,1,1,1) \). In contrast, Extended Version Space, can not only cover all positive links and filter all negative links simultaneously, but we show that its expression is in a very concise representation. Extended Version Space deploys two operations MERGE and RESELECT, which are not used in Disjunctive Version Space, to construct a more concise interlinking pattern. **V. CONSTRUCTION OF AN INTERLINKING PATTERN VIA EXTENDED VERSION SPACE** The instance language of Extended Version Space is a binary similarity sequence. Each bit of the instances’ binary similarity sequences is either 0 or 1. The generalization language is a disjunction of binary similarity sequences, called a disjunctive pattern. Each bit of the binary similarity sequences in the generalization language can be \( 0, 1 \) or \( \times \). A disjunctive pattern can be recursively represented as Formula (4), where \( (B^{(j)}) \) represents a binary similarity sequence with \( l \) bits, \( j = 1, \ldots, l \). \[ \text{Pattern} := (B^{(j)}) \mid \text{Pattern} \cup (B^{(j)}) \] In this formula, \( \cup \) denotes the union operation (i.e. disjunction) in set theory. This formula means that a pattern is either a binary similarity sequence, or a union of such sequences. We give a simple example based on the definition. Assume there are two data sets which are represented in English and French respectively, and we are given two sample links, each of which connects two instances and there are three property correspondences (name+nom, sex+gender, and supervisor+directeur) to compare, i.e., three bits per binary similarity sequence. Assume these two links can be represented as binary similarity sequences \((1,1,0)\) and \((1,1,1)\) respectively, and they are both assessed as positive by users, implying that they are correct links. Then, the disjunctive pattern that satisfies both of the two links can be written as \((1,1,0) \cup (1,1,1)\), or in a concise format \((1,1,\times)\). A disjunctive pattern defined in Formula (4) can take over the cases Version Space cannot handle. As for Example 3, the disjunctive pattern can be written as \((0,1,\times,\times,\times) \cup 0,0,1,1,\times)\). This pattern can cover all positive links and filter all negative links, with a concise format. This method is called Extended Version Space. Note that neither the specialized pattern nor the generalized pattern of Extended Version Space is a set of interlinking patterns, each one maintains only one interlinking pattern whenever a new assessed link is learned. The reason is that when the disjunction operator is applied, we can always find out the most whether the checked sample link is assessed as positive or not. The whole algorithm is split into two parts, based on strict/general pattern whenever an assessed link is learned. The pseudo-code of the Extended Version Space method is shown in Algorithm 1. Algorithm 1 Extended Version Space Input: Binary Similarity Sequences of All Assessed Links Output: A Disjunctive Generalized Pattern \( Pat_G \) 1: \( Pat_S = \emptyset \); /*empty set*/ 2: \( Pat_G = (\beta(i))_{i \in 1} \times \), where \( \beta(i) = x \), \( i = 1, 2, \ldots, l \); /*universal set*/ 3: \( Pat_{Ori} = (\varphi(i))_{i \in 1} \times \), where \( \varphi(i) = x \), \( i = 1, 2, \ldots, l \); 4: for (each assessed link (denoted by \( BSS_{link} \)) do 5: if \( (BSS_{link} \) is marked as “positive”) then 6: \( \text{MERGE}(Pat_S, BSS_{link}) \); 7: \( \text{MERGE}(Pat_G, BSS_{link}) \); 8: end if 9: if \( (BSS_{link} \) is marked as “negative”) then 10: \( \text{MERGE}(Pat_{Ori}, BSS_{new}) \); 11: end if 12: end for 13: \( Pat_G = \text{RESELECT}(Pat_{Ori}, Pat_S) \); 14: end if 15: end for Algorithm 1 aims at generating a disjunctive pattern in the form of Formula (4). It separately processes assessed links one by one. The whole algorithm is split into two parts, based on whether the checked sample link is assessed as positive or not. The details are described below. - If the current link is assessed as a **positive** one, the algorithm will check if it is covered by the current patterns \( Pat_S \) and \( Pat_G \). Such a checking step is defined in the MERGE function. If yes, the specialized pattern and the current generalized pattern \( Pat_G \) will stay unchanged. If not, we will merge the link represented in the form of binary similarity sequence (denoted as \( BSS_{link} \) in the following text) into \( Pat_S \) such that the newly added link can be included by \( Pat_S \). In the meantime, \( Pat_S \) will be reconstructed if the newly added link can induce a more concise expression, for example, replacing \((0,1,1,1,0)\) and \((1,1,1,1,0)\) by \((x,1,1,1,0)\). Note that we should also revise \( Pat_G \) to make sure \( Pat_S \subseteq Pat_G \). So we should also merge \( BSS_{link} \) into \( Pat_G \), if it cannot be included by \( Pat_G \). Finally, we reconstruct \( Pat_G \) to be more concise as the way that \( Pat_S \) is done. - If the current link is assessed as a **negative** one, we need to check if it can be included by \( Pat_{Ori} \). If not, \( Pat_{Ori} \) stays the same. If yes, we need to delete the \( BSS_{link} \) from \( Pat_{Ori} \) such that the negative link can be excluded by the new \( Pat_{Ori} \). We should find out the \( BSS \) that is contained in \( Pat_{Ori} \), which contains \( BSS_{link} \). Then, we need to delete \( BSS_{link} \) from \( BSS \). We also need to delete \( BSS \) from \( Pat_{Ori} \). Afterwards, we should add the rest binary similarity sequences that are contained in \( BSS \) into \( Pat_{Ori} \). Then, \( Pat_{Ori} \) should be reconstructed further into a more concise expression (if possible). Finally, a \( \text{RESELECT} \) step removes from \( Pat_{Ori} \) the binary similarity sequences that cannot cover any binary similarity sequence in \( Pat_S \), otherwise the number of binary similarity sequences in \( Pat_G \) would increase exponentially with more negative links learned. In general, this is not a must-do step, but Silk will perform quite slowly if too many binary similarity sequences are transformed in the script. In this algorithm, we assume that there is no intersection between all positive links and all negative links. It means that users never mark wrongly. Therefore, all positive links are included by \( Pat_{Ori} \), no matter whether they are included by \( Pat_S \). Similarly, all negative links are not included by \( Pat_S \), no matter whether they are included by \( Pat_{Ori} \). Therefore, when a positive link is not included by \( Pat_S \), we do not need to merge the link into \( Pat_{Ori} \). Similarly, when a negative link is included by \( Pat_{Ori} \), we do not need to remove it from \( Pat_S \). The key operations appearing in Algorithm 1 are described below. 1) MERGE operation: The MERGE operation (denoted by \( \text{MERGE}(Pat, BSS_{link}) \)) is used to check if the newly added \( BSS_{link} \) is supposed to be inserted and merged with some binary similarity sequences in the pattern (denoted by \( BSS_{pat} \)), such that the whole pattern can be represented in a more succinct way. This operation is one key difference between Extended Version Space and Disjunctive Version Space, which makes the interlinking pattern be represented in a more concise format. In order to formally define this operation, two other operations should be introduced. - The first one is denoted by \( \text{BSSMERGE}(BSS_{pat}^i, BSS_{pat}^j) \), with respect to two binary similarity sequences, such as \( BSS_{pat}^i \) and \( BSS_{pat}^j \). Its formal definition is shown below. \[ \text{BSSMERGE}(BSS_{pat}^i, BSS_{pat}^j) = (b_1, b_2, \ldots, b_l) \] where \( b_k = \text{BITMERGE}(\beta_i^{(k)}, \beta_j^{(k)}) \) \[ \text{BITMERGE}(\beta_i^{(k)}, \beta_j^{(k)}) = \begin{cases} \beta_i^{(k)}, & \text{if } \beta_i^{(k)} = \beta_j^{(k)} \\ \times, & \text{if } \beta_i^{(k)} \neq \beta_j^{(k)} \end{cases} \] where \( \beta_i^{(k)} \) denotes the \( k \)th bit of the pattern \( BSS_{pat}^i \). \( \text{BITMERGE} \) in the above formula is a critical operation. Two examples are given to illustrate it here. (1) If \( BSS_{pat}^i = (x,1,1,1) \) and \( BSS_{link} = (0,1,1,1) \), then \( \text{BITMERGE}(BSS_{pat}^i, BSS_{link}) = (x,1,1,1) \). (2) If \( BSS_{pat}^i = (0,\times,1,1) \) and \( BSS_{link} = (1,\times,1,1) \), then \( \text{BITMERGE}(BSS_{pat}^i, BSS_{link}) = (x,\times,1,1) \). Obviously, the core of \( \text{BITMERGE} \) is to construct a concise pattern which is compatible with the given binary similarity sequences. - The second one is called \( \text{DIFF} \) operation, also with respect to two binary similarity sequences, such as \( BSS_{pat}^i \) and \( BSS_{pat}^j \). \( \text{DIFF}(BSS_{pat}^i, BSS_{pat}^j) \) is a function to compute the number of different bits between the two binary similarity sequences. For example, \( \text{DIFF}((0,1,1,1),(0,1,0,1)) = 1 \) and \( \text{DIFF}((0,0,\times,1),(0,1,0,0)) = 3 \). Based on the definitions of BSSMERGE and DIFF, MERGE(Pat, BSS_{link}) can be formally represented as a recursive function. Some examples are given to illustrate it later. \[ \text{MERGE}(\text{Pat}, \text{BSS}_{\text{link}}) = \\ \begin{cases} \text{Pat}, & \text{if } \exists \text{BSS}_{\text{Pat}} \in \text{Pat}, \ \text{DIFF} (\text{BSS}_{\text{Pat}}, \text{BSS}_{\text{link}}) = 0 \\ \text{Pat} \cup \text{BSS}_{\text{link}}, & \text{if } \forall \text{BSS}_{\text{Pat}} \in \text{Pat}, \ \text{DIFF} (\text{BSS}_{\text{Pat}}, \text{BSS}_{\text{link}}) \geq 2 \end{cases} \] (6) \[ \text{MERGE}(\text{Pat} - \text{BSS}_{\text{Pat}}, \text{BSSMERGE}(\text{BSS}_{\text{Pat}}, \text{BSS}_{\text{link}})), \] \[ \text{if } \exists \text{BSS}_{\text{Pat}} \in \text{Pat}, \ \text{DIFF} (\text{BSS}_{\text{Pat}}, \text{BSS}_{\text{link}}) = 1 \] \[ \text{Pat} \cup \text{BSS}_{\text{link}}, \text{ if } \text{Pat} = \emptyset \] In Formula (6), the notation “−” means the difference operation on sets. In the above formula, if there exists a binary similarity sequence in the pattern which is equal to the link’s binary similarity sequence, then the pattern stays unchanged. This means that the link is covered by the pattern. If all binary similarity sequences in the pattern that have more than one different bit with the link’s binary similarity sequence, then the link should be inserted into the pattern. If there exists one binary similarity sequence in the pattern that has one different bit with the link’s binary similarity sequence, then the link should be merged with such a binary similarity sequence. The newly produced binary similarity sequence should be further merged with other binary similarity sequences in the pattern if possible. The computation is recursively performed until there are no binary similarity sequences to merge. Finally, the new produced binary similarity sequence is inserted into the pattern. If the pattern is empty, then the link should be inserted into the pattern. Here, several examples are given to illustrate the computation of \text{MERGE}(\text{Pat}, \text{BSS}_{\text{link}}), supposing the current pattern \text{Pat} = (0,1,1,\times,\times) \cup (1,0,1,0,0). - If \text{BSS}_{\text{link}} = (1,0,1,0,0), since there exists one binary similarity sequence (1,0,1,0,0) in the current pattern such that \text{DIFF}(\text{BSS}_{\text{link}},(1,0,1,0,0))=0, the returned new pattern stays unchanged (i.e., the first situation in Formula (6)). - If \text{BSS}_{\text{link}} = (1,1,1,0,1), since \text{DIFF} value is always no less than 2 for any binary similarity sequence in the current pattern, the new pattern should be represented as \text{Pat} \cup \text{BSS}_{\text{link}} = (0,1,1,\times,\times) \cup (1,0,1,0,0) \cup (1,1,1,0,1). - If \text{BSS}_{\text{link}} = (1,1,1,0,0), since \text{DIFF}(1,0,1,0,0), \text{DIFF}(1,1,1,0,0)) = 1, the new pattern should be (0,1,1,\times,\times) \cup (1,\times,\times,0,0). 2) RESELECT operation: The RESELECT operation removes from \text{Pat}_{\text{Ori}} the binary similarity sequences that cannot cover any binary similarity sequence in \text{Pat}_{\text{S}}. This operation is the other key difference between Extended Version Space and Disjunctive Version Space, which also makes the interlinking pattern be represented in a more concise format. It can be formally defined as follows, where BSS_{\text{Pat}_{\text{Ori}}} and BSS_{\text{Pat}_{\text{S}}} are referred to as the binary similarity sequence in \text{Pat}_{\text{Ori}} and the binary similarity sequence in \text{Pat}_{\text{S}} respectively. \[ \text{RESELECT}(\text{Pat}_{\text{Ori}}, \text{Pat}_{\text{S}}) = \\ \{ \text{BSS}_{\text{Pat}_{\text{Ori}}}, \text{if } \exists \text{BSS}_{\text{Pat}_{\text{S}}}, \text{BSS}_{\text{Pat}_{\text{S}}} \subseteq \text{BSS}_{\text{Pat}_{\text{Ori}}} \} \cup \\ \{ \text{BSS}_{\text{Pat}_{\text{S}}}, \text{if } \nexists \text{BSS}_{\text{Pat}_{\text{Ori}}}, \text{BSS}_{\text{Pat}_{\text{S}}} \subseteq \text{BSS}_{\text{Pat}_{\text{Ori}}} \} \] (7) The \text{RESELECT} operation is used to reduce the size of \text{Pat}_{\text{S}}: the binary similarity sequence in \text{Pat}_{\text{Ori}} can be maintained if and only if it covers at least one binary similarity sequence belonging to \text{Pat}_{\text{S}}. Although the existence of other irrelevant binary similarity sequences in \text{Pat}_{\text{Ori}} does not break the relationship \text{Pat}_{\text{S}} \subseteq \text{Pat}_{\text{Ori}}, these binary similarity sequences will degrade the Silk interlinking speed. Hence, it is necessary to maintain the relevant binary similarity sequences in \text{Pat}_{\text{Ori}} and remove irrelevant ones meanwhile. Besides, the binary similarity sequences in \text{Pat}_{\text{S}} that are not subsumed by any binary similarity sequence in \text{Pat}_{\text{Ori}} should also be added into \text{Pat}_{\text{G}}. In the end of Algorithm 1, the converged generalized pattern will act as the final output. The algorithm will terminate when there is no assessed link to be learned. The soundness of the algorithm has been proved [21]. But it is not sure if there exist a pattern, the algorithm will find it (completeness). We did not encounter a case when doing interlinking experiments that are described in Section VI, in which the algorithm does not find a pattern while there exist one. VI. Evaluation The interlinking method in this paper is evaluated based on public data sets mainly downloaded from IM@OAEI 2010\(^3\) (data sets Person1 and Person2), IM@OAEI 2012\(^4\) (data sets Sandbox001) and CKAN\(^5\) (geographical data sets INSEE and EUROSTAT). Silk is used here to generate a link set across two RDF data sets by executing an interlinking script that is transferred from an interlinking pattern, because it is an open source software. A. Experimental Setting A set of sample links are created for constructing and improving the interlinking pattern by Extended Version Space. We use K-medoids clustering method to cluster the properties of every class for each data set based on the statistics (e.g., the average value of properties), and then determine which pairs of properties between two classes across data sets can be regarded as potential property correspondences. The sample links are generated by Silk according to a pattern that combines all property correspondences into a disjunction of property correspondences. It means that any instance pair that have the same property values of any potential property correspondences will be linked as a sample link. These sample links are assessed by users and used to construct and improve an interlinking pattern afterwards. The F-measure and runtime are computed every 10 assessed links. If the interlinking procedure stops before learning 100 assessed links, we assume that the F-measure and runtime keep on the same level as the one when the procedure stopped, in order to evaluate our interlinking method with other works when the learning process stops with 100 assessed links. The experiments in Section VI-B1 are performed on each data set 5 times with a single thread and allocated maximally \(^3\)http://oaie.ontologymatching.org/2010/im/index.html \(^4\)http://www.instancematching.org/oaei/ \(^5\)http://datahub.io/ 2GB of RAM. The experiments in Section VI-B2 are performed on each data set 5 times with 4 threads and allocated maximally 2GB of RAM. Active Learning [22] is applied to select sample links to be assessed by users for reducing the number of assessed links. There are different links that are used to improve the interlinking pattern for different experiments. Thus, the precisions and recalls of generated link sets and running times of each interlinking task to be shown are the average values under 5 experiments. F-measures of generated link sets are computed with regard to the average precisions and average recalls of each interlinking task. The F-measures and running times of Extended Version Space are computed by executing interlinking with interlinking patterns when the assessed links are transferred into binary similarity sequences with the threshold \( T=0.5 \). According to our experiment, this threshold can lead to a relatively higher F-measures and lower running times of Extended Version Space than other thresholds. Our interlinking method is implemented by Java 1.6+, and the experiments are performed on a desktop computer (2.5GHz 8-core CPU, memory size=32GB, 64-bit operating system). The experimental results are stored in RDF files. B. Evaluation Results 1) Comparison with Genetic Programming: This section compares the F-measure and running time of Extended Version Space with related works [10], [9] that use Genetic Programming for interlinking. Through Fig. 1 and Fig. 2, we can observe that the interlinking method of this paper performs better than the approaches proposed by Ngonga Ngomo et al. [10], [9], based on the same two data sets Person1 and Person2. In both figures, our method is denoted as EVS. The three comparable methods of Ngonga Ngomo et al. are denoted as EAGLE, CL, WD respectively. CL and WD are two interlinking methods that combines EAGLE with two different Active Learning methods. Both Active Learning methods classify sample links into several groups according to the similarity sequence that are composed of similarities of property values according to each property correspondence. The figures show the best convergence results that are presented in their paper [10]. We compare F-measures and running times of Extended Version Space with the ones of the related works when they achieve their best F-measures with 100 initial population of Genetic Programming. We do not implement EAGLE, CL and WD, because the correspondence discovering method [23] required by the three methods is not a open-source method. The only difference on execution is that Extended Version Space is executed with a CPU of 2.5GHz, while the other three works are executed with a CPU of 2.0GHz. Since most of running time is spent on I/O operations, which are required to extract data from data sets, the difference of CPU does not influence the running times of both interlinking methods. Fig. 1 shows the F-measure comparisons on two interlinking tasks Person1 and Person2. With respect to the data set Person1, the final converged F-measure under EVS is much higher than the best ones of EAGLE, CL and WD (0.99 versus 0.86, 0.88 and 0.89 respectively). The F-measure of EVS stays on a high level when there are more than 20 assessed links. For the interlinking task Person2, the final converged F-measure of EVS is 0.96, while the ones of EAGLE, CL and WD are all roughly 0.77. ![Fig. 1. F-measures of Extended Version Space and Genetic Programming](image1.png) Extended Version Space achieves better F-measures in the interlinking task Person1 and Person2 than EAGLE, CL and WD. We can also observe that Extended Version Space converges faster than EAGLE, CL and WD. Extended Version Space has better F-measures than Ngonga Ngomo et al.’s work by about 10% in both interlinking tasks. This is mainly due to the fact that Extended Version Space builds a disjunctive pattern, which can cover positive links and filter out negative links more comprehensively. However, the operations mutation and crossover of Genetic Programming make some changes on some randomly-chosen parts of the interlinking pattern. These two operations may cause the interlinking pattern to cover less positive links and filter less negative links, so that F-measures decrease accordingly. Note that there are about 10,446 sample links and 6845 sample links for the two data sets respectively while there are 60 sample links and 80 sample links used by Extended Version Space for improving the interlinking pattern (only 1% of the total sample links), which means a quite high interlinking efficiency. ![Fig. 2. Running Times of Extended Version Space and Genetic Programming](image2.png) Fig. 2 shows the comparisons of the running time on two interlinking tasks. Extended Version Space reaches high F-measures with shorter running times than other related works on both interlinking tasks. As for the interlinking task Person1, Extended Version Space spends shorter time than other works when there are more than 10 assessed link. The interlinking procedure stops after learning 60 assessed links, because there is no more binary similarity sequences that have not been learned. There are totally 57 different binary similarity sequences in the interlinking task Person1. The running time of Extended Version Space stays at 73 seconds with a higher F-measure of 0.99 by referring to Fig. 1 (a). Thus, comparing to other interlinking methods, Extended Version Space reaches higher F-measures with a relatively shorter time in Person1. As for data set Person2, the running times of Extended Version Space are shorter than other related works after learning 10 assessed links. The interlinking procedure stops after learning 80 assessed links, in that there is no more binary similarity sequences that have not been learned. There are totally 71 different binary similarity sequences in the interlinking task Person2. The reason for the efficiency of Extended Version Space is that it executes only one interlinking pattern in each round, but Genetic Programming executes more than one interlinking pattern, which requires more running times. Thus, Extended Version Space can reach high F-measures with shorter time. We also can observe that Extended Version Space spends less time on the interlinking task Person1 than the interlinking task Person2. Because there are fewer different binary similarity sequences of the interlinking task Person1 than the ones of the interlinking task Person2. Since the interlinking pattern is composed of different binary similarity sequences of assessed links, the size of the interlinking pattern is decided by the number of different binary similarity sequences. In Person1, all correct links are transferred into 17 different binary similarity sequence groups. While in Person2, all correct links are transferred into 46 different binary similarity sequence groups. Thus, the interlinking pattern of Person2 will definitely become larger than the one of Person1 when more assessed links are learned. When the interlinking pattern is larger, there are more I/O operations that are required by Silk script when generating links. Therefore, the running times of Person2 become longer than the ones of Person1 when more assessed links are learned. To conclude, Extended Version Space performs better than other related works because of the following reasons. Genetic Programming searches for the suitable interlinking pattern by evaluating more than one interlinking patterns during each learning round. The evaluation is realized by executing each interlinking pattern to generate a link set, which will increase a lot of running time with many I/O operations. Furthermore, crossover and mutation operations of Genetic Programming easily cause the instability of the interlinking pattern, which will make the F-measure decrease in the meanwhile. In contrast, Extended Version Space does not need to evaluate more than one interlinking pattern during each learning round. It does not change the interlinking pattern with crossover and mutation operations but with informative assessed links. Therefore, it reaches high F-measure with shorter time than other related works. 2) Comparison with Disjunctive Version Space: This section compares F-measures and running times of Extended Version Space and the ones of Disjunctive Version Space on different data sets. The F-measures and running times of Extended Version Space and Disjunctive Version Space are computed by executing interlinking with the generalized patterns of both learning methods when the assessed links are transferred into binary similarity sequences with the threshold $T=0.5$. There is an exception. If there is no negative link’s binary similarity sequence being learned, the generalized pattern is a universal expression which contains all correct and incorrect links. Thus, it cannot be used for generating links. In this case, we compute the F-measures by executing interlinking with the specialized patterns of both methods. We do not generate links with the generalized pattern of Disjunctive Version Space but with the one of Disjunctive Version Space after the operation MERGE of Extended Version Space. The operation is defined in Section V-1. On the one hand, the F-measures of the generated link set by executing the generalized pattern after merging are the same with the one before merging. On the other hand, the running times of the generalized pattern before merging are definitely longer than the ones of the generalized pattern after merging. If we can show that the running times of the generalized pattern after merging are longer than the ones of Extended Version Space, the running times of Extended Version Space will definitely be shorter than the ones of Disjunctive Version Space. Extended Version Space converges faster than merged Disjunctive Version Space when interlinking Person1 and Person2 in Fig. 3. In Fig. 3(a), the F-measure of Extended Version Space increases to 0.98 when there are 20 assessed links. While merged Disjunctive Version Space should learn 60 assessed links so as to reach the similar level of F-measure. As for running time, Disjunctive Version Space spends 2300 more seconds to reach the similar F-measure as Extended Version Space when there are 60 assessed links. In Fig. 3(b), the F-measure of Extended Version Space reaches 0.96 when there are 50 assessed links, but merged Disjunctive Version Space should learn 70 assessed links to gain the same F-measure. As for running time, Disjunctive Version Space spends 1300 more seconds to reach the same F-measure of Extended Version Space when there are 70 assessed links. Extended Version Space converges faster than merged Disjunctive Version Space when interlinking the data sets INSEE and EUROSTAT and Sandbox001 in Fig. 4. In Fig. 4(a), Extended Version Space converges at the same speed with merged Disjunctive Version Space. Both of their F-measure reach 0.99 when there are 10 assessed links. But merged Disjunctive Version Space spends longer running time than Extended Version Space. In Fig. 4(b), the F-measure of merged Disjunctive Version Space is 0.07 no matter how many assessed links are learned. In contrast, the F-measure of Extended Version Space reaches 0.94 when there are 10 assessed links. F-measure of Extended Version Space is always much higher than the one of merged Disjunctive Version Space in each learning round, although merged Disjunctive Version Space spends nearly 90 seconds more to improve the interlinking pattern. To conclude, Extended Version Space converges faster to a higher F-measure with shorter running times than Disjunctive Version Space. Since there is a RESELECT operation in Extended Version Space, only binary similarity sequences that are relevant to assessed correct links are maintained in the generalized pattern of Extended Version Space (i.e., $Pat_C$). However, the generalized pattern of merged Disjunctive Version Space (i.e., $Pat_{C\tau_1}$) contains not only relevant binary similarity sequences but also irrelevant ones that cover many incorrect links. Furthermore, the generalized pattern of Extended Version Space is usually more concise than the one of merged Disjunctive Version Space, which requires less I/O operations for querying data sets when generating links. Thus, the running time of Extended Version Space is less than the one of merged Disjunctive Version Space. Since the generalized pattern of Disjunctive Version Space definitely spends longer running time than the one of merged Disjunctive Version Space, Extended Version Space converges to a higher F-measure with shorter running times than Disjunctive Version Space. VII. CONCLUSION AND FUTURE WORK In this paper, we proposed Extended Version Space to construct an interlinking pattern across two RDF data sets. The advantage of our design is its high F-measure as well as processing efficiency with relatively short running time. We evaluate different solutions using various public data sets. Experiments confirm that our method with only 1% of sample links already reaches a high F-measure (around 0.96-0.99). The F-measure quickly converges in our solution, which improves by nearly 10% on other interlinking approaches. In the future, we plan to evaluate our interlinking method with more data sets, which have different qualities on class/property correspondences. We also plan to implement our interlinking method in an ontology matching tool so as to help improve the generated ontology alignment. ACKNOWLEDGMENT This work is partially supported by ANR project Datalif (2010 CORD 009). REFERENCES
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01180918/document", "len_cl100k_base": 11836, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 33516, "total-output-tokens": 14099, "length": "2e13", "weborganizer": {"__label__adult": 0.00042366981506347656, "__label__art_design": 0.00087738037109375, "__label__crime_law": 0.0005521774291992188, "__label__education_jobs": 0.0100555419921875, "__label__entertainment": 0.00023305416107177737, "__label__fashion_beauty": 0.000339508056640625, "__label__finance_business": 0.0010118484497070312, "__label__food_dining": 0.00041103363037109375, "__label__games": 0.0010004043579101562, "__label__hardware": 0.0009250640869140624, "__label__health": 0.0007219314575195312, "__label__history": 0.000949859619140625, "__label__home_hobbies": 0.00026798248291015625, "__label__industrial": 0.0006890296936035156, "__label__literature": 0.001529693603515625, "__label__politics": 0.0005450248718261719, "__label__religion": 0.00072479248046875, "__label__science_tech": 0.43017578125, "__label__social_life": 0.0003666877746582031, "__label__software": 0.0538330078125, "__label__software_dev": 0.4931640625, "__label__sports_fitness": 0.0002803802490234375, "__label__transportation": 0.0005927085876464844, "__label__travel": 0.0003216266632080078}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52707, 0.03518]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52707, 0.88485]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52707, 0.86975]], "google_gemma-3-12b-it_contains_pii": [[0, 1073, false], [1073, 6628, null], [6628, 13406, null], [13406, 20928, null], [20928, 27354, null], [27354, 34667, null], [34667, 39994, null], [39994, 45377, null], [45377, 52707, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1073, true], [1073, 6628, null], [6628, 13406, null], [13406, 20928, null], [20928, 27354, null], [27354, 34667, null], [34667, 39994, null], [39994, 45377, null], [45377, 52707, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52707, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52707, null]], "pdf_page_numbers": [[0, 1073, 1], [1073, 6628, 2], [6628, 13406, 3], [13406, 20928, 4], [20928, 27354, 5], [27354, 34667, 6], [34667, 39994, 7], [39994, 45377, 8], [45377, 52707, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52707, 0.02941]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
c918307999a91e0a5c3afb969335a290bf275c29
Standardization of Bug Validation Viktor Austli, Elin Hernborg Bachelor's thesis in technology, 15 credits Halmstad 2017-07-03 Abstract The usage of the Internet is widely implemented all over the world in a number of concepts. This generates a demand of establishing security as to sustain the integrity of data. In this thesis a service will be presented which can be used to identify various web vulnerabilities in order to regulate these and therefore prevent exploitation. As the world is today the increase of technical implementation provides with a growing amount of security flaws, this affect the organizations which may have to increase their resource financing in an effort to counter these. But what if a tremendous amount of work could be automated and avoid organizations having to spend an enormous amount of finances validating security flaws reported to them? What if these flaws could be validated in a more effective manner? With this tool being establish an individual will no longer require advanced technical knowledge in order to identify whether a web vulnerability is present or not but instead have an automated test perform the procedure for them. Acknowledgements We would like to express our greatest gratitude towards Detectify for their unlimited support in the process of developing the standardized language, parser and tests. We are especially thankful for the support received by Johan Norman and Frans Rosén which has put their interest and time into this project. None the less, we would also like to acknowledge Eric Järpe from whom we have received valuable guidance supporting us when composing this thesis. Definitions Command A word, or phrase, executed in order to achieve what the specified command represent. Data structure This is a method of organizing information within a system in order to rationalize the wielding of it. DNS Domain Name System, this is a system which simplify the addressing process of a computer within an IP-network such as the Internet. It works in the manner of an IP-address being connected with a domain name which may be used throughout the connection instead of the IP-address itself. Domain A domain is a way of organizing a group of systems in order for them to share a common communication address. HTTP Hypertext Transfer Protocol, is a protocol handling communication to transfer websites within the information network WWW, World Wide Web, on the Internet. IDE Integrated Development Environment is a computer program which usually contain a text editor, compiler and a debugger together with various functions regarding programming. JavaScript This is a scripting language which is dynamic, high-level and the use is mainly client-oriented regarding web applications. Open source The definition of an open sourced program is that the source code of the software is accessible for any user to inspect, modify and enhance. OWASP The Open Web Application Security Project is a global organization specialized in security regarding software applications, most commonly web applications. Parser A parser is a program, which commonly is a part of a compiler, which receive input and sort it into data structures in order to simplify the translation between different programming languages. Regex This is used to describe the value of strings and is composed by syntax rules. It is commonly used in programming languages and text editors as a method to search for, and manipulate, text. Security flaw A security flaw is a complication which pose a threat to the security of a program, system, file etcetera. Standardized language A standardized language is developed to create a structured process to perform a given task. Source code Computer instructions written in an human readable format. Trouble-shooting An act performed with the purpose of identifying a complication. URI Uniform Resource Identifier, this identifies a resource, file location within a uniform format. Web Application A web application is software accessible by the communication with a web browser. XML Extensible Markup Language, this is a markup language which both the human eye and the machine will be able to read. Contents Abstract i Acknowledgements iii Definitions v 1 Introduction 1 1.1 Related articles 2 2 Background 4 2.1 Motivation 5 2.2 Purpose and Project Goal 6 2.3 Limitations 7 2.4 Tools 7 2.5 Problematization 7 3 Method 9 3.1 Theoretical studies 9 3.2 Development .................................................. 10 3.3 Validation ..................................................... 10 3.4 Problematization of Method ................................. 11 3.5 Ethical Considerations ....................................... 13 4 Theory 14 4.1 Selection of Vulnerability Coverage ......................... 14 4.2 Vulnerability Coverage ........................................ 14 4.2.1 SQL-injection ............................................. 15 4.2.2 LFI-vulnerability .......................................... 15 4.2.3 IDOR-vulnerability ......................................... 15 4.2.4 Subdomain takeover ........................................ 16 4.2.5 .git- directory disclosure ................................. 16 4.2.6 Stored XSS- & Blind Stored XSS-Injection ............ 16 4.2.7 Reflected XSS .............................................. 17 5 Experiment 18 5.1 Selection of tools ............................................ 18 5.2 Development .................................................. 19 5.2.1 Standardized language ................................. 19 5.2.2 Parser ..................................................... 20 5.2.3 Vulnerability tests ....................................... 21 5.2.3.1 SQL-Injection .................. 21 5.2.3.2 LFI-vulnerability .............. 22 5.2.3.3 IDOR-vulnerability .......... 22 5.2.3.4 Subdomain takeover .......... 22 5.2.3.5 .git-directory disclosure .... 23 5.2.3.6 Stored XSS- & Blind Stored XSS-Injection 23 5.2.3.7 Reflected XSS ............... 23 5.2.4 XML-specification ............... 24 5.2.5 General code ................... 24 5.2.5.1 SQL-injection ............... 27 5.2.5.2 IDOR-vulnerability .......... 27 5.2.5.3 .git-directory disclosure .... 28 5.2.5.4 Stored XSS-, Blind Stored XSS-Injection & Reflected XSS ............... 29 6 Results .......................... 30 7 Discussion ........................ 32 8 Conclusion ........................ 35 8.1 Future Work ..................... 36 Bibliography ....................... 39 A Pseudo code A.1 Main .................................................. 44 A.2 XMLParser ........................................... 45 A.3 Test .................................................... 45 A.4 HeaderCall .......................................... 47 B Examples B.1 SQL-Injection ......................................... 48 B.2 LFI-vulnerability ..................................... 54 B.3 .git- directory disclosure ........................... 60 B.4 Stored XSS-Injection ................................. 64 B.5 Reflected XSS ......................................... 69 1. Introduction Along with the evolvement of technology occurrence of security flaws will be a certainty. If these security flaws are overlooked, or omitted, they may pose a threat to an entire IT-infrastructure since there is a risk that they can be exploited through e.g. cyber attacks. There have been major security flaws reported in different applications throughout time which have affected a great deal of users. One well-known incident concerning this was The Heartbleed Bug which enabled exploitation of user information regarding credit card numbers, passwords etc [1]. There are major organizations such as Adobe, Linkedin, Sony and Microsoft that have fallen victim to exploitation of security loopholes which also affected a wide range of their users [2]. To be able to patch these security loopholes they have to be discovered. There are multiple methods in order to achieve detection of security flaws, for instance the use of a Bug Bounty can be applied. Microsoft is one of the organizations which have implemented the use of a Bug Bounty-program, this allow users to hack their organization in order to expose the security flaws and if the users are successful they may receive a payment as compensation [3]. When a security flaw is discovered it is critical to adjust it, in order to guarantee that this process is executed in a proper manner an established approach is in need. This is of high significance since the individual reporting the identified security flaw may possess a higher level of knowledge than the individual receiving the material. Greater organizations are usually in possession of a well established security de- partment with the knowledge essential to administer these findings in contrast to smaller organizations which may not. Smaller organizations are in need to retain the security as well but may not value this as highly, this does not mean that it is not crucial. This issue is brought up in the thesis *Investigation the current state of security for small sized web applications* by Lundberg [4]. 1.1 Related articles Along with the development of technology web applications continues to be targeted for security attacks, this is a major issue yet to be resolved. Since the technology evolve the number of approaches to employ grow along with it, this create a high demand on security updates to withstand the high number of security attacks possible to perform. This issue is brought up in [5] where different hacking techniques and a vulnerability analysis is presented. This is where the vulnerability scanners may come in handy for an individual, or organization with or without bad intentions. By using these a security flaw may be detected and either exploited, reported or patched. There are different ways of detecting security flaws in web applications by using vulnerability scanners, this is brought up in [6]. A description of the process which is carried out when an individual identifies security flaws with a bug bounty program is found in [7], in this thesis the deficient process regarding validation of the reported loophole is evident. As mentioned earlier different approaches to exploit applications are discovered constantly which is brought up in [8], therefore procedures to correct these security flaws is of crucial manner. This is also discussed in [9], the issue regarding lack of knowledge among individuals to accommodate security flaws is also mentioned. There have been a numerous methodologies and tools constructed to perpetuate web security but as mentioned earlier the lack of knowledge remains an issue. In [10] the fact that the diversity in tools and methodologies accessible for assessment of security is not fully utilized is brought up, this may be a consequence due to absence of sufficient knowledge. In order to detect the security flaws which may pose a threat to an entire organization there are multiple methods to achieve this, penetration testing is a well established method and this procedure is expounded in [11]. To avoid the possibility of exploitation of applications maintenance shall be of high priority, the issue regarding this is brought up in [12]. Deficiency concerning detection of security flaws may be costly for organizations due to the absence of adequate security which enables exploitation of various nature, in [13] this potential situation is mentioned. Since human interaction is a common necessity when detecting web vulnerabilities sufficient education and knowledge may be crucial. This is brought in [14] where the demand of the participation of an individual to ensure the accuracy when performing a web vulnerability test is pointed out. As noted in [15] critical security flaws are frequently detected in web applications and one of the most dire grade of these vulnerabilities are SQL-injections. These are commonly exploited but could be obviated which is explained in [16]. Web application security is a prominent topic in the world of technology since this may affect an immense quantity of users and organizations. Projects are initiated frequently to increment security measurements although this may not unfailingly be prioritized. In [17] HTML5 is reviewed to resolve whether it has been constructed to make web applications more secure or not. 2. Background This project has been developed through collaboration with an organization named Detectify which specializes in web security. Throughout time the development in technology has peaked in a tremendous matter during the 21st century since it was first created, almost 40 years earlier, in the 1960s. In 1988 one of the first web security threats was spread across the Internet, the Morris worm named after its creator Robert Tappan Morris. This is considered as a significant milestone in the development of malware [18]. The Internet has been downright implemented in our society and every individual, or organization, is in many ways highly dependent on the functionality of the technology to survive. Both categories are reliant on the technology in manners of communication, economy, health care etcetera [19]. Along with the technical evolvement threats towards the industry arise, these may target the individual, organization or a wider range of users. Web applications are subjects to the attackers and by studying data presented by the SANS institute this is easy to cognize. SANS institute estimate that more than 80% of all cyber security incidents are due to already known web vulnerabilities, this is confirmed by similar data presented by the Verizon Data Breach Investigation report [20], [21]. This generate a high demand on appropriate security being advanced to attain a standard reliable to undertake these attacks. On the Internet there are no national borders which may provoke difficulties 2.1. Motivation in how to counter the constant security threats, this create a requirement on the individuals and organizations to institute their own security measurements. If these security faults are not administrated the loss for an organization may be devastating. The Computer Security Institute has performed a survey presenting the casualties of security breaches which resulted in $445 million loss, these catastrophic numbers were presented after a review of only 223 computer professionals [22]. These facts all point to one major necessity, the implementation of sufficient security measurements and a structured process to administrate these. The web vulnerabilities has to be managed before an attack occur to ensure that the integrity of data is being sustained. 2.1 Motivation There is no structured process of reporting a security flaw detected by an external individual to the organization involved. IT-resources and knowledge in the range of Microsoft is not a possibility for all organizations which make the phase of reporting a flaw complex in some situations. This problem may result in a security issue being neglected, if even understood. The communication between the penetration tester and the organization need to be adequate in order to guarantee the resolution of a reported security issue. There have been experiments concerning the accuracy of a vulnerability scan for example Alexander Norström examine this in his thesis *Measuring Accurancy* [sic] of Vulnerability Scanners: An Evaluation with SQL Injections although he does not cope with the complication in validating the reported flaws for an organization [15]. Since the current approaches regarding administration of reports is a major issue, concerning discoveries of security flaws, an automated method of conducting this may be of great interest for a numerous organizations which does not possess the resources essential to perform this process themselves. There is no method for performing this process in an automated manner during the present time which may generate a demand for this service. 2.2 Purpose and Project Goal The purpose of the thesis is to establish a tool with the potential to evaluate whether a reported web vulnerability exists or not. This should be able to test for specific vulnerabilities of different variety. It also has to be user friendly since an advanced technical knowledge should not be necessary in order to utilize the tool. The test which will be accessible for the user to execute will be an automated test, therefore the user itself does not have to possess any knowledge concerning security flaws or programming etc. To ensure that the product developed will reach the target of being user friendly a standardized language will be established, this code will have to cover a numerous assortment of previously known web vulnerabilities. The standardized language will collaborate with a parser created to enable the evaluation of web vulnerabilities, this parser should be able to read parameters from the standardized language and therefore evaluate whether a vulnerability is present or not. The following is to be designed and evaluated during this thesis: - A standardized language-independent specification for reporting web vulnerability. - A parser that can interpret the specifications into automated security tests. - Evaluate the coverage of the parser towards a set of common categories of web vulnerabilities. 2.3 Limitations The product developed will only detect the web vulnerabilities defined in standardized language, these test may or may not require additional information specified by the test conductor, therefore this is not a general vulnerability identifier. 2.4 Tools This project does not require any huge assortment of tools but primarily a tool to enable the communication between the parser and any web application, defined in the standardized language, which toward the test will be conducted. An IDE, Integrated Development Environment, will be used to develop the standardized language and parser. The IDE should be efficient and effortless for the user to facilitate the process of developing the codes. 2.5 Problematization In order to achieve the project goal of this thesis the development of a parser is crucial but to accomplish this the standardized language is essential. The conclusion of the complications concerning this thesis is that each part is necessary for a successful result. If the parser is not customized properly for the standardized language it will not be of any functionality, this represent a considerable issue therefore it will have to be developed meticulously to avoid time loss and other potential obstacles. Major issues can also occur regarding the source code, these are unpredicted and may result in time loss which can therefore pose a threat to the thesis being completed within the set time frame. The quality of the application is in need to be verified since it will handle the validation of security flaws and therefore it is critical that it will be accurate. The biggest component of this thesis experiment is the development of the standardized language and this is also crucial in order to complete the other objectives of the project goal. The language has to be accurate in order to assure valid results and furthermore be compatible with the parser. Therefore the process of the standardized language will require a larger amount of time for development, evaluation and potentially trouble-shooting and corrections. If this is not performed accurately the entire project goal may be at stake. 3. Method The thesis will be accomplished by performing three steps; research to acquire knowledge, develop a standardized language and a parser and finally validate the functionality of the finalized product. The project will be performed with the structure of research, implementation and evaluation based on a similar structure of [23] and [6]. 3.1 Theoretical studies Theoretical studies will occur to receive knowledge concerning the area to enable the process of creating the standardization which needs to be readable for both the human eye and a machine. These will be performed by reading related articles to retrieve knowledge within the specific area, furthermore contact with an organization which possess relevant expertise will also occur. Regarding the theoretical studies they will be focused on theses with a higher standard rather than news articles etc. Platforms such as DiVa and IEEE Xplore will be used to acquire knowledge from previous completed theses concerning web vulnerabilities, therefore search phrases such as ”Web vulnerabilities”, ”Automatic vulnerability check”, ”standardized language”, ”XML”, ”SQL-Injection” etcetera will be applied. The knowledge obtained will be processed to determine the approach used for the development of the standardized language and parser. This will also be helpful while performing the validation of the functionality and if found necessary complementary research will be carried out. Collaboration with an organization specialized in web security will occur throughout the project and will be of high value regarding acquisition of necessary knowledge to fulfill the ambitions stated. 3.2 Development The standardized language will be developed with the requirement of being user friendly in the aspect of the user not necessarily possessing advanced knowledge regarding programming but also the demand of covering a numerous assortment of known web vulnerabilities. This is an important factor since the ambition of this project is to create a tool helpful, to identify web vulnerabilities, for any individual with or without technical knowledge. The prerequisite of the parser is the functionality regarding parameters and structure. The parser is required to enable the receiving of parameters originating from the standardized code. These parameters should afterwards be structured in a manner suitable to enable the initiation of the vulnerability test. This is of high importance in order for the test to be accurate and avoid complications regarding the programming of the test itself. 3.3 Validation Throughout the establishment of the tool there will be continuously validation issued to ensure its functionality in order to minimize the risk of an error being overlooked. The process of guaranteeing that the code being precise will be followed up when the code is complete with a validation procedure. To evaluate the accuracy of the tests executed, a numerous variation of tests containing web vulnerabilities will be performed which is of significant importance in order to confirm the functionality of the tool. Since the tests will be issued by a user to identify if a vulnerability is present or not the validation process has to be authentic and executed meticulously. An open sourced program will be used as a communication tool between the parser and the web application to increase the effectivity of certain tests. This will avoid any complications regarding the development of the parser since it otherwise would have to be able to execute JavaScripts and handle sessions. If no such tool would be accessible an enormous amount of extra programming would be essential. \textbf{3.4 Problematization of Method} When gathering intelligence regarding the subject of this project the demand of high quality references is in need. This may be time-consuming since various theses and other projects often collect their knowledge from varied sources, therefore it is required to perform this process meticulously to ensure the authenticity of the information acquired. The requirement of a user friendly standardized language has to be achieved or the complete project is compromised, therefore this has to be established scrupulously with precaution. If the parser is not developed scrutinizingly this may result in a numerous complications, these could be time-consuming and lead to delay of the entire project. Therefore it is of high importance to assure that this is fulfilled throughout the project development. When carrying out the validation of the finalized product this has to be done with precision, otherwise this may result in the entire project being inaccurate and therefore not useful for any individual. When validating the different tests some may be slightly harder to validate, it will although be possible to achieve but it might require a greater deal of work. If there is no possibility to acquire access to an open sourced tool, which can handle the communication between the parser and the web application, it may be devastating for the time plan. This is due to the fact that it would require a great deal of extra code to enable various functions in order to establish this sort of communication. Since the source code of this project will be confidential any reader of this thesis may not be able to reconstruct the tool created. An experience individual may however, from reading about the XML-code and requirements, create something similar. This is a disadvantage considering validation of the tool actually working, however it is an advantage when controlling the release of the tool and the possibilities to extend the coverage before the implementation of external use. As for the approach of developing the vulnerability scanner there are many different methods at hand but in order to optimize the selection a method proposed in an earlier work of similar character should be in use. In [6] they propose the usage of obtaining knowledge from OWASP which also will be applied in this project. The main difference between the projects proposed here is that this concern vulnerability scanners detecting unknown vulnerabilities while the tool which will be developed throughout this project will be used to identify and report a known or supposed security flaw. Although the project conducted in the thesis is evaluated by testing different scenarios to ensure the creditability of the results, this is something of high value in a project of this nature. Therefore this procedure will be applied to this project to ensure that the veracity of the results achieve a high accuracy and credibility. In order 3.5 Ethical Considerations to develop the scanner itself a method equivalent to the one presented in [24] will be applied, this is due to the characteristics of the product being developed in this thesis is incredibly similar to the one which will be developed in this experiment. The program presented is very similar in the sections of going through entire web pages in order to scan them for specific issues. Therefore this method, that has been shown successful, will suit the approach of the project presented in this thesis. 3.5 Ethical Considerations Although this tool will be established with the intention of helping an organization or individual to prevent security flaws being exploited it may be used in a scenario driven by bad intentions. This tool will however not be a general vulnerability scanner and therefore a new vulnerability most likely will not be identified but rather already known vulnerabilities. A user with bad intentions may however use the tool to determine whether a vulnerability has been patched or if it is still available for exploitation. On the other hand the organization, or individual, containing the security flaw may also use the tool to identify whether it has been administrated correctly. With these potential scenarios the organization, which contain the security flaw, has every possibility to patch it against security attacks and will not be left without any opportunities to secure their web application. 4. Theory 4.1 Selection of Vulnerability Coverage In the process of coverage selection there are a number of different attributes to take into account. Web vulnerabilities which pose a crucial threat to the administration of a web application is of high interest to confront. The security flaws presented below are considered to hold a high threat status towards web applications, some of them are also well-known and rated highly upon the list of web vulnerabilities by OWASP. The most common web vulnerabilities are not necessarily the most crucial, some of the selected security flaws may not have been prominent but still constitute a high threat status. Therefore a mixture of common web vulnerabilities with the threat they may pose towards a web application will be applied to achieve a satisfying web vulnerability coverage. 4.2 Vulnerability Coverage There will be a various number of vulnerabilities possible to validate using the automated test developed. In this section these vulnerabilities will be listed and elucidated. 4.2. Vulnerability Coverage 4.2.1 SQL-injection SQL-injection is a security flaw on account of unsanitized user input and is rated in the top ten security flaws by OWASP, as late as 2013 it was considered the leading vulnerability in web security. The security flaw issue a threat where a unauthorized user may insert SQL statements by exploiting user input data through a web-based application. Through exploitment of this security flaw a user can access the entire backbone database [25], [26]. 4.2.2 LFI-vulnerability LFI-vulnerability, Local File Inclusion, is a security flaw within a web application where various files may be included by an unauthorized user. These files can be included on the server machine, within the web application. The security flaw occur when there is insufficient programming to regulate the built-in methods and functions which therefore enable a user to pass selected parameters with these not being validated to ensure the privileges of the user [27], [28]. 4.2.3 IDOR-vulnerability IDOR-vulnerability, Insecure Direct Object References, may arise in a situation where the developer of an application endanger a reference of the internal implementation such as a file, directory or database key. This occur when the user is able to circumvent the authorization process by manipulating the references and may therefore acquire access to data to which they have no proper authorization [29], [30]. 4.2.4 Subdomain takeover When a domain lack validation it pose a threat to the website if it has a DNS entry pointing towards a domain that has not been claimed. If the domain has not yet been claimed there is a possibility that an outsider, rather than the organization itself, claims it and therefore acquire the possibility of serving their own content [31]. 4.2.5 .git- directory disclosure This security flaw is present if the access to .git-folders is not denied, if a production server has directory listing enabled it is also susceptible to exploitation. An unauthorized user may acquire data by issuing only one command, this is a major security issue due to the entire source code of a website would be accessible for the attacker. If the directory listing would be disabled there is a way for the more knowledgeable user to access the repository but this demand further cunning regarding how git manage this [32], [33]. 4.2.6 Stored XSS- & Blind Stored XSS-Injection This vulnerability is exploited in a method where a web application store potentially malicious input from a user. If the input that is stored is not filtered thoroughly it can lead to disastrous consequences since the data will occur to be part of the web site and will therefore be run as if it would be by the web browser of a user. Since the data appears to be part of the web site the privileges of this will be set to the same as the web application. The blind stored XSS-vulnerability is basically the same as the classic XSS-flaw, the major difference is that the attacker will not possess any knowledge of when, or where, the payload is executed. 4.2. Vulnerability Coverage The attacker instead has to wait until the administrator of the website execute the malicious script. [34], [35]. 4.2.7 Reflected XSS This security flaw occur when an unauthorized user inject code which is browser executable within a HTTP response. The exploit pose a threat to users opening a malicious link or third-party web page exclusively due to the injection not being stored within the web application. The attacker include the attack string as a component of the URI or HTTP parameters and is subsequently processed erroneous by the web application and finally returned to the user [34], [36], [37]. 5. Experiment The ambition of this experiment is to establish a tool which can validated the given web vulnerabilities presented below. This project should be user friendly and may be evolved in the future to cover a wider range of web vulnerabilities. 5.1 Selection of tools During the development of the standardized language XML-coding will be implemented, this due to the fact that XML is a well-known language managed by a wide range of users. This yield the opportunity to gather information, concerning the language, in order to assist the development of the project during a possible phase where additional knowledge may have to be acquired to fulfill the requirements of the code. XML-code is also a widely implemented language among projects concerning web applications and such. The programming will be issued in IntelliJ IDEA which is an IDE, Integrated Development Environment, where the language XML, Extensible Markup Language, will be applied. The reason for this choice pedicate in the benefits of this IDE which primarily are the user-friendly environment established for the developer. During the development of the code IntelliJ IDEA will support the user by finishing inaugurated commands 5.2. Development To increase the effectiveness of the project. The structure will be managed in an apparent manner which includes coloring and auto-indenting of the code and the program will assist the developer in debugging of the code. To enable the establishment between the parser and the web application to conduct the necessary tests an open sourced program will be used, the tool of choice is called Selenium. Selenium allow the parser to send the commands through the web browser in order to perform the specified tests. The primary argue to use Selenium, during the development of this project, is because the program is well implemented. This contribute with a higher security of an accurate program due to the higher number of users and bugs being detected and managed in a wider range compared to a supposedly newly created program. 5.2 Development Throughout the development phase the tests created to validate the given web vulnerabilities will remain confidential and no unauthorized individual will gain access to the programming code, this include the presentation of the project in this thesis. The tests developed will be discussed in a manner where their functionality and outcome is explained in the situation of being executed by a test performer and which aspects that has been kept in mind. 5.2.1 Standardized language When developing the standardize language the basics regarding the URL, Uniform Resource Locator, and the port number was the first line of action. These will be used in the manner of deciding which web application the test will be conducted within and therefore needed to be established as a ground pillar for the project. As a second approach in developing the language the possibility of including information such as login name and password was essential which will be inserted into the web application. In this step the location of the web application, where the login in will be handled, has to be specified by the test performer in order to enable the establishment a connection. When the user has specified the basic parameters the option of performing tests within the application will be possible. This may be accomplished by defining the parameters such as files and paths of the web application which shall be included in the test conducted. If necessary the forms need to be specified with further information, to ensure that the test executes correctly, which will later on be sent to the web application although this may not be essential in every test. In order to determine whether the test was successful or not the user has to compare the code expected to be faulty with the outcome, this may be performed using regex or plain text. This comparison is performed by specifying the expected outcome in the standardized language. If the outcome present that the expected code is faulty as suspected this will be displayed with the expected flawed code and a notification reporting to the user that the security flaw do exist within the web application. If the situation is the opposite and the security flaw does not exist nothing will be displayed by the outcome other than a notification that will inform the user of the vulnerability not being active within the web application. 5.2.2 Parser In order to enable the execution of the tests the parser has been developed with the possibility of retrieving the input from the XML-file containing the standardized language given by the user. The parameters specified by the user in the XML-file will be sorted into data structures to create an unequivocal architecture which improve the management of the parameters. Certain tests require the usage of Selenium in order to be executed to make the process more effective. The communication with Selenium works in a way where the parser contact the tool and present the given parameters. These parameters are received by Selenium which forwards it to the web application specified in the XML-file. When the web application has been approached Selenium initiate the tests given and the parser scan the outcome which it afterwards present to the user. For the tests not using Selenium only a request is specified in the XML-file which the parser manage by connecting to the web application and then compare the given information with the response retrieved from the application. 5.2.3 Vulnerability tests For any given vulnerability the outcome of the test will indicate whether a security flaw is present or not. The user which perform the test should have no administrator privilege but instead act as an unauthorized user in order for the results of the tests to be accurate. The received outcome, which the test performer receives from each individual test, will give an unambiguous response to whether the security flaw is present or not by the lines ”The security flaw is present” or ”The security flaw is not present”. 5.2.3.1 SQL-Injection To discover if a web application is susceptible to a SQL-Injection attack the test developed will navigate to the website where a suspected vulnerability exist. When in association with the website a SQL-request will be initiated to determine whether the security flaw is present or not. The outcome depends on whether the executed SQL-request will initiate the SQL-code given or not, if this code is executed and consummated correctly the security flaw is present and has to be managed. 5.2.3.2 LFI-vulnerability This vulnerability is rather straightforward when it comes to determine whether it is present or not. To conclude if this security flaw is active within a web application the performer of the test has to specify any file, within the test, which an unauthorized user normally should not gain access to and if the user may acquire permission of this file the security flaw is present. 5.2.3.3 IDOR-vulnerability The test conducted in order to identify if this vulnerability exist or not is very similar to the solution of performing a test for the LFI, Local File Inclusion, -vulnerability. In this case the test is merely evolved around the reference of the web application rather than the files. The user performing the test solely has to specify a reference within the test that an unauthorized user should not have admission to, if the test is successful and the user acquire access to the specified reference the IDOR-vulnerability is present. 5.2.3.4 Subdomain takeover When performing the test to identify whether a takeover is possible to conduct towards a subdomain the entire content will be reviewed. This is to determine if the content within the subdomain correspond to the specifics inserted within the test by the user. If the two sections conform with one another the subdomain is recipient for takeover. 5.2. Development 5.2.3.5 .git-directory disclosure When determining whether this security flaw exist within a web application or not a test which perform a check has to be executed. This check has to determined if the file ".git/HEAD" exist within the route of the web application to enable further analysis to detect the authenticity of the file, the analysis is only feasible to perform if the file is present. If a file would not be discovered by the check the security flaw is not present, therefore further scrutiny would not be necessary. If the file would be found by the check regex will be used to determine if the file is authentic or not, if so the vulnerability is present and has to be adjusted by an administrator. The correction of a vulnerability of this extent is critical due to the possibility of an attacker being able to access and download the entire source code of the website, this is rated as one of the most crucial security flaws. 5.2.3.6 Stored XSS- & Blind Stored XSS-Injection To investigate the possibility of these vulnerabilities being present a test has to be executed within the web application where these are suspected to exist. Within this web application a JavaScript will be inserted, if this script is not initiated the security flaw is not present. On other hand, if the script is executed correctly the vulnerability exist and has to be dealt with by the administrator. 5.2.3.7 Reflected XSS The reflected XSS-vulnerability is discovered by a test with the same characteristics as when identifying a Stored, or Blind Stored, XSS-Injection. The test has to be performed within the web application, where the security flaw is expected to be contained, in order to be able to identify it. When located in the area of the web application where the security flaw is suspected to exist a JavaScript will be executed. The script will however not be initiated if the security flaw is not present, the test performer will in this situation be notified about the absence of this sort of vulnerability. 5.2.4 XML-specification In this section the XML-code developed to enable vulnerability detection of the listed security flaws will be elucidated. 5.2.5 General code This section list all the general code which is included within all the tests. This is code which state the language in use, the paths etcetera. Sets XML version and text encoding used. ```xml <?xml version="1.0" encoding="UTF-8"?> ``` This is the root node of the xml file. ```xml <webvup> ``` This define the web application which the test will be run towards and which port the server is listening on. ```xml <site url="http://localhost/" port="80"> ``` This is the first step node, the steps run in an ascending order. ```xml <step> ``` 5.2. Development If the step would solely perform a header request, a header parameter can be set with requested a method. ```xml <step header="GET"/> ``` If it is required for a user to be logged in to be able to execute a test the user can define on which page the login form is located. The user is also obligated to state the name of the form, username- and password field. Afterwards the user has to insert additional data to define which username and password will be in use. ```xml <form url="login.php" name="login"> <field name="username">admin</field> <field name="password">password</field> </form> ``` This is the end of the first step node. ```xml </step> ``` The second step node. ```xml <step> This is the start of the variable node which define the variables which are to be used in this step. ```xml <variables> This is the path which will be used in the URL. The data currently inserted will set the URL as http://localhost/fistdir/seconddir/. ```xml <paths> <path>firstdir</path> <path>seconddir</path> ``` Chapter 5. Experiment This define which parameters that are to be used in the URL. The present data will set the URL as http://localhost/fistdir/seconddir/?id=5&color=green. ```xml <parameters> <parameter name="id">5</parameter> <parameter name="color">green</parameter> </parameters> ``` This form define a form which should be specified by the user with name and method, POST/GET can also take additional data from the user. The desirable fields may be specified by the individual performing the test. ```xml <input> <form name="" method="POST"> <field name="id">input data</field> </form> </input> ``` The end of the variable node. ```xml </variables> ``` This is the expected response if the execution of the test is performed with success. This can be defined by the type TAG, ALERT or HEADER. If the tag is of the sort HTML it may be defined by the type of tag and name/id of the tag. ```xml <expected_response type="tag" container="div" name="payload">"Cleartext or REGEX"</expected_response> ``` 5.2. Development This is the end of the second step and this close the last nodes. ``` </step> </site> </webvup> ``` ### 5.2.5.1 SQL-injection To perform a test which evaluate whether a SQL-Injection vulnerability is present or not a SQL-command has to be entered at the position within a web application where the vulnerability is suspected to exist. ``` <variables> <input> <form> <field name="id">%' or '0'='0'; SELECT @@version;--'</field> </form> </input> </variables> ``` This is the expected outcome from the SQL-injection test which should give the version and name of the database the test was executed towards if the test is successful. ``` <expected_response type="tag" container="pre">MariaDB</expected_response> ``` ### 5.2.5.2 IDOR-vulnerability In this case the *page* parameter is used to fetch specified files to present them in the web browser. By traversing back three steps and entering the *etc* folder the passwd file of the server is available to be fetched. <parameters> <parameter name="page">../../../etc/passwd</parameter> </parameters> If the string root:x:0:0 exist on the page the passwd file was sucessfully found and displayed. <expected_response type="tag" name="content" container="div">root:x:0:0</expected_response> 5.2.5.3 .git-directory disclosure To detect a .git-directory disclosure solely one header step has to be performed. <step header="GET"> This will perform a search for the file HEAD in the folder .git. <variables> <paths> <path>.git</path> <path>HEAD</path> </paths> </variables> If the returned header acquired a successful code 200, the requested HEAD file and the regular expression is found the threat is definite. <expected_response type="header" code="200">.*([a-f0-9]{40}|ref:.*).*/</expected_response> 5.2.5.4 Stored XSS-, Blind Stored XSS-Injection & Reflected XSS To perform a test to evaluate whether a XSS-Injection is present or not a small JavaScript is posted through a form. ```html <form name="XSS"> <field name="name"><script>alert ("The script has been stored and executed");</script></field> </form> ``` If the JavaScript is executed with the outcome where the alert message shows the vulnerability exist. ```html <expected_response type="alert">The script has been stored and executed</expected_response> ``` 6. Results When developing this tool to enable automated tests for validation of web vulnerabilities a variety of characteristics had to be taken into account. For example the standardized language should be user friendly, the parser should be able to handle different parameters and the accuracy of the tests performed has to be validated and insured. In order for the standardized language fulfilling the function of being user friendly this has been programmed with a clear and straightforward structure in order for the user to effortlessly understand and have the ability to utilize this. Solely by overlooking the language a user can locate the sections where additional information has to be inserted in an uncomplicated manner and also distinguish which sort of information. The test performed may be saved as a XML-file and therefore sent to an individual, or organization, which the security flaw concerns. The receiver can afterwards execute the file and the process of administrating the vulnerability may begin. This function makes the process very easy and no technical knowledge is demanded in order to retrieve the evidence but may instead just be passed on to the individual which will resolve the issue. This function and possibility makes the tool extremely user-friendly and easy to use and may save an organization a tremendous amount of resources. More to the point a handbook will be created to support any user feeling insecure or confused due to the lack of knowledge during the performance of the tests. The handbook will cover the entire range of the available tests which can be performed with the tool presented in this thesis. This is of crucial importance due to the process performing these tests being possible to execute for any user possessing no certain level of technical knowledge. This handbook will be enclosed for any individual with authority to access this tool. The insurance of the parser fulfilling its functionality when managing the parameters is a crucial matter, this due to the test not being performed accurately if at all. This has been validated through a number of different tests and have an impeccable result. The tests performed have been issued using Selenium and have been successful and a more detailed view of the process is given in the Appendix B and the pseudo code of the project is given in Appendix C. Every parameter has reached the web application in order to perform the given tests and has also been rendered accurately. As mentioned earlier in this thesis it is of highest priority to guarantee the validity of the outcome and this has been conducted by performing the tests in an environment where the web vulnerabilities being present and where they are not. Depending on the web application where the tests will be conducted the demands of specified input within the standardized language will vary. For example will some web applications require the input of login information, parameters, forms and paths which will depend on which test, or tests, that will be performed and towards which web application. These aspects are something the user performing the test, or test, has to handle which may include acquiring further knowledge of the web application being investigated. For the tests which demand navigation and forms Selenium will be used but for tests solely examine whether a file or page exist requests will be used instead, for one example the .git-vulnerability is one of these situations. 7. Discussion The technology of today might be out-dated tomorrow, this due to the evolvement constantly taking place. This contribute to the necessity of up-to-date security measurements to prevent security flaws from arising along with the technological evolvement. To ensure that this does not occur the usage of the product presented in this thesis can be used, the maintenance of the security system is reckoned to be equally important as the implementation. Alatalo and Vallgren agree with these thoughts according to their thesis, which has been mentioned earlier, Anpass- ningar till standardisering inom Software Configuration Management: En fallstudie om standardisering inom mjukvarukonfigurationshantering [12]. In order to execute the web vulnerability scanning selected by the user human interaction is in need. This create a possibility for the user to specify the test which will be executed but also demand interaction to complete the test which may be seen as a disadvantage. As noted by Ahlberg in his thesis Generating web applications containing XSS and CSRF vulnerabilities the interaction of an individual is critical to detect vulnerabilities in web applications to ensure the validity and this is something we agree upon [14]. The code presented in this thesis is, as stated earlier, not a general vulnerability scanner but an option to perform specified tests within a web application. Therefore management by a user is crucial to execute these tests since the code is dependent on the data inserted by this individual to ensure that it has been performed accurately. Since the interaction of an individual is in need to perform the test the handbook is crucial to maintain the goal of this process being user-friendly. The reason why we have prioritized this highly is due to the fact that web security may be badly affected by the insufficient knowledge concerning the individuals which are dependent on these test to detect and confirm the web vulnerabilities. This is a major issue which is presented in Web security and common shortfalls: the state of knowledge among developer by Strandberg and Lyckne [9]. Their thesis show devastating results in the lack of knowledge among developers which may affect the necessity of detection of vulnerabilities being available. In their thesis they have performed tests among different developers with different levels of education and work experience and some of these perform no better than 1 correct answer among 19 questions concerning web vulnerabilities. We find these results startling due to the fact that educated individuals lack the possession of the knowledge necessary concerning a variety of different web vulnerabilities, some of these individuals possess more than 20 years of work experience. Their results make it clear to us that the handbook, which we will create to enable the usage of the code presented in this thesis, will be of crucial matter. This will support any individual, with or without any technical knowledge, to execute the tests accurately. The web vulnerability scanner produced and presented in this thesis may prevent organizations from incidents with catastrophic consequences due to lack of security. It is of common knowledge that security flaws within web applications are exploited and many individuals all around the world have some time been affected. We find that these security flaws does not only pose a threat to an organization but to individuals as well. If an organization, which possess sensitive data about individuals, is affected all the data at their disposal may be at risk which also will pose a threat towards the entire clientele with data within their network. As stated by Easttom in *Computer Security Fundamentals* security flaws within web applications may contribute with sky high bills for an organization if these are not detected and managed [22]. This confirm the need of a vulnerability scanner and in some cases it might even be a matter of survival for an organization to have a possibility to adjust the present security flaws within their web applications. We agree upon that the web applications are in crucial need of new tools and methods in order to sustain the demand of sufficient security measurements. There are new security flaws constantly presented to the world of technology, therefore vulnerability scanners will be an optimal tool for an organization in need of assistance concerning vulnerability detection. 8. Conclusion Throughout this project the goal has been to create a web vulnerability scanner which enable a user to specify the test towards the web application which the individual want to detect the specified vulnerability within. The vulnerability scanner would have to be user-friendly and contain a numerous different vulnerability test which would execute in an accurate manner to ensure the validity of the results. The web vulnerability scanner presented in this thesis has achieved all the desirable characteristics and is therefore considered to be satisfying in an operational perspective. It would be beneficial if the individual, which will perform these test, would not have to interact with the tool to conduct the vulnerability scans but this is, at this moment, not possible since this would compromise the assurance of an accurate result. The tool will make the process of reporting security flaws much less complicated due to the possibility of just sending a XML-file with the parameters set to perform the test which point towards the vulnerability. The receiver can execute the file and watch the test be performed and identifying the alleged security flaw. This eliminate the necessity of a middle-man normally having to search and find the bug, report back to the authority that it does exist and afterwards wait for instructions. With this step being eliminated the individual receiving this bug report immediately can instruct the administrators to patch this security flaw and also refer to the XML-file for exact information about the issue. The tool will be presented to the users with a handbook which will support them in the usage of the tool. This will prevent mis-usage and therefore it will not require an immense amount of resources being spent on additional support for the users. Since the code is compiled in a manner which enable it to be expanded additional test may be added, this is beneficial since various security flaws most certain will occur in the future. These web vulnerabilities may be crucial for an individual or organization to detect and it will be optional to add these as features. Web vulnerabilities are often expensive to manage for organizations, many of these may not possess necessary resources to manage these. This service open up an opportunity for anyone to perform the detection themselves, this will prevent expensive investigations. Instead the organizations can focus on the management of the security flaws in order to avoid devastating exploitations. The product developed throughout this thesis allow an organization to invest an inferior amount of resources such as time when validating whether a web vulnerability reported is present or not. With the aspects of user friendly, effective, accurate and with a coverage of multiple web vulnerabilities the tool developed has reached beyond the requirements stated earlier in this thesis. Therefore this project has fulfilled the goal of the development and may contribute tremendously in an organizations effort in securing their web environment. 8.1 Future Work The web vulnerability scanner presented in this thesis may be evolved in the future to cover a wider range of vulnerabilities. Every day there are new security risks discovered, these threats may be included in this scanner to enable detection depending on the demand. Bibliography A. Pseudo code Figure A.1: Dependencies diagram A.1 Main DEFINE BOOLEAN answer AS false DEFINE LIST stepList CALL XMLParser WITH xmlfile INTO stepList CREATE Test OBJECT WITH URL and Port FROM stepList CALL Test.Connect A.2 XMLParser FOR all testParameters IN stepList IF is header step THEN CALL HeaderCall WITH testParameters INTO answer ELSE IF login information exist THEN CALL Test.LogIn WITH login information END IF CALL Test.TraverseSite WITH paths and parameters CALL Test.postForms WITH form information CALL test.checkResponse WITH expected value INTO answer END IF IF expects response AND answer EQUALS true THEN vulnerability exist END IF END FOR A.2 XMLParser FUNCTION XMLParser ( xmlfile ) CREATE testParameters OBJECT CREATE XMLReader OBJECT WITH xmlfile FOR all xml nodes in XMLReader INSERT current node INTO testParameter.currentNode END FOR END FUNCTION A.3 Test FUNCTION Test ( URL and Port ) DEFINE STRING url AS URL DEFINE INTEGER port AS Port CREATE Selenium OBJECT FUNCTION connect () CALL Selenium.Connect WITH url and port END FUNCTION FUNCTION logIn ( login information ) CALL Selenium.goTo WITH login page FROM login information CALL Selenium.post WITH name and password FROM login information END FUNCTION FUNCTION TraverseSite ( paths and parameters ) CALL Selenium.goTo WITH paths and parameters END FUNCTION FUNCTION postForms ( form information ) CALL Selenium.post WITH form information FROM login information END FUNCTION FUNCTION checkResponse ( expected value ) IF expected value is in a tag THEN RETURN true IF expected value is in tag ELSE false ELSE IF expected value is in a alert THEN IF alert is present AND alert got the expected text THEN RETURN true ELSE RETURN false END IF END IF END IF FUNCTION HeaderCall (testParameters) DEFINE STRING path AS paths and parameters FROM testParameters DEFINE RESPONSE response CREATE httpConnection OBJECT WITH URL, paths and port FROM testParameters CALL httpConnection.connect WITH headermethod FROM testParameters INTO response IF response.code EQUALS testParameters.expectedcode AND response.text EQUALS testParameters.expectedtext THEN RETURN true ELSE RETURN false END IF END FUNCTION B. Examples B.1 SQL-Injection Figure B.1: Inputs login-form fields names, username and password. Figure B.2: Inputs path to the vulnerability. Figure B.3: Input a valid SQL-injection. Figure B.4: Input expected response that should exist if vulnerability exist. Figure B.5: Vulnerability found. B.2 LFI-vulnerability Figure B.6: Inputs login-form fields names, username and password. Figure B.7: Inputs path to the vulnerability. Figure B.8: Input vulnerable URL parameter. Figure B.9: Input expected response that should exist if vulnerability exist. Figure B.10: Full XML code. Figure B.11: The test is executed and vulnerability is found. B.3 .git- directory disclosure Figure B.12: Create a header step. B.3. .git- directory disclosure Figure B.13: Inputs path to the vulnerability. Figure B.14: Input the expected response if the file exists. Figure B.15: The test is executed and vulnerability is found. B.4 Stored XSS-Injection Figure B.16: Inputs login-form fields names, username and password. Figure B.17: Inputs path to the vulnerability. Figure B.18: Fill in the vulnerable form with an exploitable JavaScript. Figure B.19: Input expected response that should exist if vulnerability exist, in this case an alert pop-up. Figure B.20: The alert is executed and the vulnerability exist. B.5 Reflected XSS Figure B.21: Inputs login-form fields names, username and password Figure B.22: Inputs path to the vulnerability Figure B.23: Fill in the vulnerable form with an exploitable JavaScript. Figure B.24: Input expected response that should exist if vulnerability exist, in this case an alert pop-up. Figure B.25: The alert is executed and the vulnerability exist. Elin Hernborg Viktor Austli
{"Source-Url": "http://hh.diva-portal.org/smash/get/diva2:1136597/FULLTEXT02.pdf", "len_cl100k_base": 12291, "olmocr-version": "0.1.53", "pdf-total-pages": 87, "total-fallback-pages": 0, "total-input-tokens": 126363, "total-output-tokens": 17784, "length": "2e13", "weborganizer": {"__label__adult": 0.0004835128784179687, "__label__art_design": 0.0006651878356933594, "__label__crime_law": 0.001773834228515625, "__label__education_jobs": 0.0027484893798828125, "__label__entertainment": 0.00013816356658935547, "__label__fashion_beauty": 0.00021982192993164065, "__label__finance_business": 0.00031638145446777344, "__label__food_dining": 0.0003178119659423828, "__label__games": 0.0008983612060546875, "__label__hardware": 0.0013227462768554688, "__label__health": 0.0005359649658203125, "__label__history": 0.00034427642822265625, "__label__home_hobbies": 0.00011593103408813477, "__label__industrial": 0.0004215240478515625, "__label__literature": 0.0005145072937011719, "__label__politics": 0.0003521442413330078, "__label__religion": 0.0003719329833984375, "__label__science_tech": 0.07421875, "__label__social_life": 0.0001652240753173828, "__label__software": 0.0266265869140625, "__label__software_dev": 0.88671875, "__label__sports_fitness": 0.00023829936981201172, "__label__transportation": 0.00033092498779296875, "__label__travel": 0.0001614093780517578}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 69732, 0.03302]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 69732, 0.42615]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 69732, 0.90631]], "google_gemma-3-12b-it_contains_pii": [[0, 130, false], [130, 130, null], [130, 1180, null], [1180, 1180, null], [1180, 1655, null], [1655, 1655, null], [1655, 3082, null], [3082, 4204, null], [4204, 4477, null], [4477, 5773, null], [5773, 6581, null], [6581, 7172, null], [7172, 8828, null], [8828, 10807, null], [10807, 12464, null], [12464, 13990, null], [13990, 15979, null], [15979, 17454, null], [17454, 18910, null], [18910, 19611, null], [19611, 20854, null], [20854, 22403, null], [22403, 24196, null], [24196, 26251, null], [26251, 27713, null], [27713, 28753, null], [28753, 30193, null], [30193, 31832, null], [31832, 32472, null], [32472, 33686, null], [33686, 35310, null], [35310, 37298, null], [37298, 39024, null], [39024, 40437, null], [40437, 42156, null], [42156, 43196, null], [43196, 44242, null], [44242, 45278, null], [45278, 46309, null], [46309, 47113, null], [47113, 47639, null], [47639, 49271, null], [49271, 51120, null], [51120, 52630, null], [52630, 54758, null], [54758, 55596, null], [55596, 57169, null], [57169, 58907, null], [58907, 58960, null], [58960, 58960, null], [58960, 60199, null], [60199, 61863, null], [61863, 63457, null], [63457, 65144, null], [65144, 65576, null], [65576, 65801, null], [65801, 66580, null], [66580, 67539, null], [67539, 68025, null], [68025, 68056, null], [68056, 68123, null], [68123, 68169, null], [68169, 68210, null], [68210, 68288, null], [68288, 68321, null], [68321, 68411, null], [68411, 68457, null], [68457, 68501, null], [68501, 68579, null], [68579, 68607, null], [68607, 68669, null], [68669, 68736, null], [68736, 68816, null], [68816, 68877, null], [68877, 68939, null], [68939, 69033, null], [69033, 69080, null], [69080, 69153, null], [69153, 69262, null], [69262, 69326, null], [69326, 69412, null], [69412, 69458, null], [69458, 69531, null], [69531, 69640, null], [69640, 69704, null], [69704, 69704, null], [69704, 69732, null]], "google_gemma-3-12b-it_is_public_document": [[0, 130, true], [130, 130, null], [130, 1180, null], [1180, 1180, null], [1180, 1655, null], [1655, 1655, null], [1655, 3082, null], [3082, 4204, null], [4204, 4477, null], [4477, 5773, null], [5773, 6581, null], [6581, 7172, null], [7172, 8828, null], [8828, 10807, null], [10807, 12464, null], [12464, 13990, null], [13990, 15979, null], [15979, 17454, null], [17454, 18910, null], [18910, 19611, null], [19611, 20854, null], [20854, 22403, null], [22403, 24196, null], [24196, 26251, null], [26251, 27713, null], [27713, 28753, null], [28753, 30193, null], [30193, 31832, null], [31832, 32472, null], [32472, 33686, null], [33686, 35310, null], [35310, 37298, null], [37298, 39024, null], [39024, 40437, null], [40437, 42156, null], [42156, 43196, null], [43196, 44242, null], [44242, 45278, null], [45278, 46309, null], [46309, 47113, null], [47113, 47639, null], [47639, 49271, null], [49271, 51120, null], [51120, 52630, null], [52630, 54758, null], [54758, 55596, null], [55596, 57169, null], [57169, 58907, null], [58907, 58960, null], [58960, 58960, null], [58960, 60199, null], [60199, 61863, null], [61863, 63457, null], [63457, 65144, null], [65144, 65576, null], [65576, 65801, null], [65801, 66580, null], [66580, 67539, null], [67539, 68025, null], [68025, 68056, null], [68056, 68123, null], [68123, 68169, null], [68169, 68210, null], [68210, 68288, null], [68288, 68321, null], [68321, 68411, null], [68411, 68457, null], [68457, 68501, null], [68501, 68579, null], [68579, 68607, null], [68607, 68669, null], [68669, 68736, null], [68736, 68816, null], [68816, 68877, null], [68877, 68939, null], [68939, 69033, null], [69033, 69080, null], [69080, 69153, null], [69153, 69262, null], [69262, 69326, null], [69326, 69412, null], [69412, 69458, null], [69458, 69531, null], [69531, 69640, null], [69640, 69704, null], [69704, 69704, null], [69704, 69732, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 69732, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 69732, null]], "pdf_page_numbers": [[0, 130, 1], [130, 130, 2], [130, 1180, 3], [1180, 1180, 4], [1180, 1655, 5], [1655, 1655, 6], [1655, 3082, 7], [3082, 4204, 8], [4204, 4477, 9], [4477, 5773, 10], [5773, 6581, 11], [6581, 7172, 12], [7172, 8828, 13], [8828, 10807, 14], [10807, 12464, 15], [12464, 13990, 16], [13990, 15979, 17], [15979, 17454, 18], [17454, 18910, 19], [18910, 19611, 20], [19611, 20854, 21], [20854, 22403, 22], [22403, 24196, 23], [24196, 26251, 24], [26251, 27713, 25], [27713, 28753, 26], [28753, 30193, 27], [30193, 31832, 28], [31832, 32472, 29], [32472, 33686, 30], [33686, 35310, 31], [35310, 37298, 32], [37298, 39024, 33], [39024, 40437, 34], [40437, 42156, 35], [42156, 43196, 36], [43196, 44242, 37], [44242, 45278, 38], [45278, 46309, 39], [46309, 47113, 40], [47113, 47639, 41], [47639, 49271, 42], [49271, 51120, 43], [51120, 52630, 44], [52630, 54758, 45], [54758, 55596, 46], [55596, 57169, 47], [57169, 58907, 48], [58907, 58960, 49], [58960, 58960, 50], [58960, 60199, 51], [60199, 61863, 52], [61863, 63457, 53], [63457, 65144, 54], [65144, 65576, 55], [65576, 65801, 56], [65801, 66580, 57], [66580, 67539, 58], [67539, 68025, 59], [68025, 68056, 60], [68056, 68123, 61], [68123, 68169, 62], [68169, 68210, 63], [68210, 68288, 64], [68288, 68321, 65], [68321, 68411, 66], [68411, 68457, 67], [68457, 68501, 68], [68501, 68579, 69], [68579, 68607, 70], [68607, 68669, 71], [68669, 68736, 72], [68736, 68816, 73], [68816, 68877, 74], [68877, 68939, 75], [68939, 69033, 76], [69033, 69080, 77], [69080, 69153, 78], [69153, 69262, 79], [69262, 69326, 80], [69326, 69412, 81], [69412, 69458, 82], [69458, 69531, 83], [69531, 69640, 84], [69640, 69704, 85], [69704, 69704, 86], [69704, 69732, 87]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 69732, 0.0]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
4ddd0d0ed4ad4b5c11073a09f92ab2126f52a75b
[REMOVED]
{"Source-Url": "http://user.it.uu.se/~kaati/pub/treebisim.pdf", "len_cl100k_base": 15588, "olmocr-version": "0.1.50", "pdf-total-pages": 17, "total-fallback-pages": 0, "total-input-tokens": 68642, "total-output-tokens": 17437, "length": "2e13", "weborganizer": {"__label__adult": 0.0004839897155761719, "__label__art_design": 0.0006985664367675781, "__label__crime_law": 0.0005693435668945312, "__label__education_jobs": 0.0016489028930664062, "__label__entertainment": 0.0002090930938720703, "__label__fashion_beauty": 0.00028228759765625, "__label__finance_business": 0.0005841255187988281, "__label__food_dining": 0.0005650520324707031, "__label__games": 0.00160980224609375, "__label__hardware": 0.0016222000122070312, "__label__health": 0.00116729736328125, "__label__history": 0.0006346702575683594, "__label__home_hobbies": 0.00019121170043945312, "__label__industrial": 0.0010509490966796875, "__label__literature": 0.0007791519165039062, "__label__politics": 0.00057220458984375, "__label__religion": 0.001018524169921875, "__label__science_tech": 0.45166015625, "__label__social_life": 0.00015544891357421875, "__label__software": 0.00870513916015625, "__label__software_dev": 0.52392578125, "__label__sports_fitness": 0.00039505958557128906, "__label__transportation": 0.00109100341796875, "__label__travel": 0.0002779960632324219}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 51709, 0.02351]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 51709, 0.47311]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 51709, 0.8286]], "google_gemma-3-12b-it_contains_pii": [[0, 2768, false], [2768, 6685, null], [6685, 9851, null], [9851, 13411, null], [13411, 15703, null], [15703, 18752, null], [18752, 21858, null], [21858, 25302, null], [25302, 28962, null], [28962, 32018, null], [32018, 36062, null], [36062, 39686, null], [39686, 43143, null], [43143, 44765, null], [44765, 46693, null], [46693, 49702, null], [49702, 51709, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2768, true], [2768, 6685, null], [6685, 9851, null], [9851, 13411, null], [13411, 15703, null], [15703, 18752, null], [18752, 21858, null], [21858, 25302, null], [25302, 28962, null], [28962, 32018, null], [32018, 36062, null], [36062, 39686, null], [39686, 43143, null], [43143, 44765, null], [44765, 46693, null], [46693, 49702, null], [49702, 51709, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 51709, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 51709, null]], "pdf_page_numbers": [[0, 2768, 1], [2768, 6685, 2], [6685, 9851, 3], [9851, 13411, 4], [13411, 15703, 5], [15703, 18752, 6], [18752, 21858, 7], [21858, 25302, 8], [25302, 28962, 9], [28962, 32018, 10], [32018, 36062, 11], [36062, 39686, 12], [39686, 43143, 13], [43143, 44765, 14], [44765, 46693, 15], [46693, 49702, 16], [49702, 51709, 17]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 51709, 0.03828]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
9377495dd5fe5c4e6a4004e40c263b7a9e45e2f7
Crowd-Logic: Implementing and Optimizing Human Computation Algorithms using Logic Programming Hao Lü and James Fogarty Computer Science & Engineering DUB Group, University of Washington Seattle, WA 98195 {hlv, jfogarty}@cs.washington.edu ABSTRACT Human computation is a powerful approach to addressing problems that remain beyond the reach of traditional computing and has been demonstrated in a variety of applications. However, implementing human computation programs remains challenging. We present Crowd-Logic, a general-purpose tool for implementing human computation algorithms, which allows application developers to declaratively specify the high-level control flow of algorithms using logic programming and implement human computation units using imperative programming (e.g., Java). The logical representation allows Crowd-Logic to maximally reuse the results from prior human computation, optimize the control flow, and reduce the general cost of human computation. We validate our optimization techniques on two sample applications: sorting a list of reviews using human judgment and shortening text using human rewrites. Keywords: Crowdsourcing, logic programming, planning, machine learning INTRODUCTION Human computation is a powerful approach to addressing problems that remain hard for computers but easy for humans to solve. Markets for human computation, such as Amazon Mechanical Turk (MTurk) [2], allow developers to programmatically post tasks that can be completed by human workers in return for payment. Programs can thus integrate human computation into their algorithms. Recent systems have used human computation to answer visual questions from blind people posted from their mobile phones [4], shorten and proofread texts, and run scripts in natural languages [3]. However, implementing human computation programs introduces new challenges. First, human feedback is slow; it takes time to both find a worker and for that worker to complete a task. Second, calls to human workers can introduce monetary cost, which can quickly accumulate over time. Third, human feedback is unreliable, which means systems must be architected such that some human workers verify or improve the work of others [3]. Developers therefore have to manage tradeoffs between speed, money, and reliability in designing their algorithms. For example, additional verification steps can improve reliability but increase monetary costs and reduce speed. These challenges also introduce new opportunities for traditional computation. Since human computation can become the new computation bottleneck, developers may prefer to spend more computational resources on the human computation if this reduces delays, saves money, or improves reliability. For example, one such opportunity is to reuse results from prior human computations. Existing general-purpose human computation tools have focused on APIs for easily accessing human computation markets [2,9] and managing long running programs [9]. TurKit [9], for example, enables a program to efficiently pause and continue in order to improve the stability of the program over time. To our knowledge, no prior work has focused on tool that supports managing the cost of traditional computation against the cost of human computation. We present Crowd-Logic, a general-purpose tool for implementing human computation algorithms. In Crowd-Logic, the high-level structure of an algorithm is specified using logic programming and human computations are encapsulated into logical primitives, which are implemented via imperative programming (e.g., Java). The logical representation of algorithms allows Crowd-Logic to maximally reuse the results from prior human computation. It also introduces opportunities for traditional computation to optimize algorithms for reducing the general cost of human computation. In this paper, we first show how developers can implement a human computation algorithm in Crowd-Logic. We then show how Crowd-Logic can maximally reuse the results of prior human computation. Next, we discuss the techniques for optimizing algorithms to reduce the general cost of human computation. We then validate our optimization techniques in two sample applications: sorting a list of restaurant reviews using human judgment and shortening text using human rewrites. Finally, we discuss the current limitations and opportunities for future work. Our main contributions are: - Crowd-Logic, a general-purpose tool for implementing human computation algorithms that maximally enables reuse of prior human computation, and - A set of techniques for optimizing algorithms to reduce the general cost of human computation. **IMPLEMENTING AN ALGORITHM WITH CROWD-LOGIC** In this section, we present an overview of Crowd-Logic via an example of using Crowd-Logic to implement a common human computation use case, DescribeImage: generating plain text descriptions for images. More specifically, in this image description problem, the task is to generate a good plain text description for a given image by asking human workers to describe the image. Previous research has looked at this problem [9,12]. A common approach is to use an iterative improvement workflow as shown in Figure 1a. The workflow iterates over improving a description ("improve") and verifying the improvement ("is better"). In each round of the iteration, first, a human worker is asked to improve an old description for the image by writing a new description. Then, a few human workers are asked to vote on if the new description is indeed better than the old one. The better version will then be improved on in the next round. The iteration terminates after a predetermined number of rounds. The workflow in Figure 1a can be broken down into two parts: the control flow and two basic human computation units (e.g., "improve" and "is better"). Correspondingly, the Crowd-Logic implementation of the above workflow has two parts: a logic programming part for specifying the control flow (shown in Figure 1b), and a Java part that implements the basic human computation units (shown in Figure 1c). The logic programming part contains four logic rules. Rule 1 specifies the control flow of a single round of the iteration ("one_round"), which consists of two sequential steps: "improve" and "is_better". Rule 2 specifies that the take the original description should be used if a better description is not found in Rule 1. Rule 3 and 4 specify recursively the iteration with N rounds of "one_round". The Java part contains two functions that implement the two human computation units of the same names in the logic program. Figure 1c shows the skeleton of their implementation. Each human computation unit is implemented in its corresponding method of the library class. Crowd-Logic will load the library and scan for methods that implement human computation units. The annotation "@HumanPrimitive" is used on Java methods to indicate that a particular method is an implementation of a human computation unit. The name of the method is same as its logical counterpart. Some metadata can be specified in the annotation. For example, the code in Figure 1c specifies the cost of "improve" is 1 and the cost of "is_better" is 3. The definition of the cost is up to the developers. The annotation "@Out" applies on the parameters of the Java methods to indicate that a parameter is intended for storing an output value from human workers (an output parameter). For example, the "newText" parameter of "improve" is to store the rewrite of the old description. In contrast, the method "is_better" does not have such output parameters. The result of its human computation is communicated back via its return value. The above demonstrates how Crowd-Logic combines logic programming and imperative programming. An imperative implementation could have a similar structure to Figure 1, however, when Crowd-Logic runs, one advantage is that it can maximally reuse the prior results of "improve" and "is_better", for example, if there are K rounds of improvement in the past, Crowd-Logic will start from the K+1 round. Logic Programming In the rest of this subsection, we introduce the basic notions in logic programming that will be used in this paper. More details can be found in [15]. Logic programming has two basic constructs. Terms are the single recursive data structure in logic programming. A term can be: - **Number**: strings in number form, i.e., 0, 3.14. - **Variable**: strings that start with an upper-case letter or underscore, i.e., Image, Text, N. At runtime, a variable can be assigned a value by binding it to another term. - **Atom**: general strings with no other meanings, i.e., true, 'a.png'. - **Compound Term**: which are composed of an atom (name) and a list of terms (arguments), i.e., improve(Image, Text, NewText). A compound term can mean: - **Predicate**, can be true or false depending on the values of its arguments. - **Primitive**, a predicate that is defined outside the logic programs and usually in an imperative program. They provide abstractions that are difficult to express in logic programs. In Crowd-Logic, we use human primitive when it provides an abstraction to some human computation. - **List**: a special compound term to represent a list. The following two are equivalent in representing a list that consists of 1, 2 and 3: [1,2,3], [1|[2, 3]]. Rules take the following form: ``` A :- B₁, B₂, ..., Bₜ. ``` This states that A (the head of the rule) is true if all the Bi's (the body of the rule) are true. A and Bi's are all logical predicates. A rule with an empty body is called a fact, which states that the head predicate is always true. A rule with no head predicate is called a query, which initiates the computation. In logic programming, the computation is done interpretively. To solve a query, the interpreter will search for a proof (a sequence of logical deductions from the facts) for its body and the bindings for all its variables. To get a text description for an image using DescribeImage, we can input a query to Crowd-Logic. For example, the following query will generate a description for the image 'a.png' using 10 iterations: ``` :- iterate(10, 'a.png', '', Text), write(Text). ``` (The predicate "write" is a built-in primitive that outputs the value of "Text" to the console.) There are many existing search procedures for logic programs. Crowd-Logic adopts the goal-reduction search procedure. Each predicate is interpreted as a goal. Rules are interpreted as ways to reduce a goal (head of the rule) into a sequence of sub-goals (body of the rule). The facts and primitives are terminals and are reduced to an empty sequence. The procedure of searching for a proof is interpreted as searching for a sequence of reductions from the initial sequence of goals to an empty one. The search space is a tree structure with each state corresponding to a goal sequence. The first goal of a state is always the active goal, which is to be reduced next. We will refer to this search tree as a proof search tree. The search strategy is backtracking, e.g., traversing the tree in depth-first order. A sample proof search tree is shown in Figure 2. The initial query is turned into state 1 with two goals. Rule 4 can reduce the active (first) goal in state 1 into two sub-goals and result in state 2. Both Rule 1 and Rule 2 can reduce the first goal of state 2 and transition to state 3 and state 6 respectively. Since Rule 1 is specified before Rule 2 in the logic program, it has a higher priority and the search process will try Rule 1 first. The search process will then evaluate the human primitives in states 3 and 4, as they are the active goals. If the result of "is_better" is false, the search process will backtrack to state 2 and try Rule 2. This search process will eventually reach a state "iterate(0, ..., write(....)" in which the first goal is a fact and second goal is a primitive. While logic programming languages are simple yet as expressive as imperative languages, most developers are unfamiliar with logic programming. In addition, the API support for logic programming languages to access existing human computation markets is lacking. These make it a high threshold to implement a human computation algorithm entirely in logic programs. However, logic programming has the benefit of enabling effective reuse and optimization in human computation. Crowd-Logic lowers such threshold by allowing developers to only specify the high-level algorithms in logic programs. **REUSE HUMAN COMPUTATION** Since human computation can be slow, unreliable and expensive, the opportunity to reuse results from prior human computation becomes valuable. Crowd-Logic assumes that the results from human primitives are reusable unless otherwise specified. When the interpreter searches for a solution, it always tries to reuse the prior results of the human primitives when possible. Consider the task of sorting a list of restaurant reviews based on their sentiments. One solution is to implement the quicksort algorithm and ask human to compare the sentiments of two reviews. During the sorting, many comparisons between two reviews may have already been done before. They can result from situations when new reviews have been added and the old reviews have already been sorted. They can result from the previous runs that have terminated unexpectedly. They can also result from other tasks that share the same human comparison unit. These comparisons can reuse the prior comparison results rather than asking human to compare them again. The above is the simplest case of reusing prior human computation results. It can be realized by storing all prior comparisons in a local database and every time a human comparison is required, the interpreter reuses the prior result if the same comparison is recorded in the database. Consider a more complex example. In DescribeImage, the interpreter can encounter the two sequential primitives as shown in Figure 3a when searching for a solution. When it is at the first primitive, e.g., "improve", assuming that the same human computation (improving an empty description of 'a.png') has been done a few times before, the interpreter has to make a decision on whether or not to reuse the prior results and if so, which result to be used. However, the interpreter does not have enough information to make such a decision. It is until when it sees the next primitive, e.g., "is_better", does the interpreter know that it can reuse a result that is better than the empty description. If no such reuse is possible, the interpreter should then invoke the "improve" primitive to get a new human rewrite. Things will get more complicated when multiple rounds of improvements are concerned as shown in Figure 3b. To enable reuse in the general case, Crowd-Logic introduces a constraint solver and sees all human primitives as constraints. For example, the primitive "improve('a.png', T1, T2)" in Figure 3b is interpreted as a constraint that constrains the values of the two variables T1 and T2 to have both occurred in one of the prior runs of the primitive. A constraint can be satisfied if such values exist. Constraints can have dependencies between each other via variables. For example, the constraint "improve('a.png', T1, T2)" depends on the other constraint "improve('a.png', ',', T1)", because its argument T1 is an output from the latter. A dependency graph can be obtained by representing constraints as nodes and dependencies as edges. Figure 3c shows the dependency graph of the constraints in Figure 3b. The interpreter stores a list of constraints and maintains a dependency graph for them. When it encounters a constraint, the interpreter adds the constraint to its list of constraints. If the constraint solver determines that the resulting constraints are no longer satisfied, the interpreter then backtracks. A set of constraints is satisfied when there exists an assignment for each variable such that each constraint is satisfied. When a constraint is backtracked, the interpreter decides whether or not to invoke the human computation depending on whether it depends on other constraints (from the same rule in the logic program). When a constrained variable is to be used in a non-constrained way, such as invoking human computation, or print its content, the constraint solver will find all its possible assignments and the interpreter will backtrack on all its assignments. We have described how constraints and the constraint solver are used in the interpreter. In the rest of this section, we examine the implementation of our constraint solver. Since checking if a set of constraints can be satisfied is equivalent to checking if there are possible assignments for all variables, we only describe the algorithm used for finding all possible assignments of a variable. Crowd-Logic stores all the prior results from human primitives in a local relational database. Each human primitive is managed in its own database table. For example, the primitive "improve" is managed in the table "improve". Each entry of a database table records a prior computation indexed by their ids. To find all possible assignments of a constrained variable, the constraint solver first finds all the constraints that contain the variable. Then, it computes a connected component in the dependency graph that contains this set of constraints. It then translates the constraints into the joins of corresponding database tables. The possible assignments of the variable are the values from the column of the joint table that corresponds to the output of the variable. For example, the finding of all possible assignments of variable T in constraints shown in Figure 3a can be translated into the following SQL query: ``` SELECT improve.col_3 FROM improve, is_better WHERE improve.col_3 = is_better.col_2 AND improve.col_1 = 'a.png' AND improve.col_2 = '' AND is_better.col_1 = 'a.png' AND is_better.col_3 = '' ``` The use of constraint solver essentially allows the decision on what value to be reused to be much delayed, so that the computation can get much more efficient and the reuse of prior human computation can be maximized. **OPTIMIZATION AND DECLARATIVE APPROACH** Human computation introduces new potential for tradeoffs between the costs of traditional computation and the costs of human tasks. A developer may prefer to spend large amounts of traditional computational resources if this reduces delay or cost, or improves quality associated with human tasks. For example, TurKontrol [5] uses a planning algorithm to control the quality of a task. In Crowd-Logic, such new tradeoffs allow our interpreter to use more traditional computational resources to optimize the execution of the logic programs. Logic programs have a declarative, logical interpretation, which specifies the computation without describing the actual control flow. It gives the interpreter some freedom in deciding how to execute a program. The interpreter can optimize an algorithm by choosing the best control flow based on factors such as delay and monetary cost. In the next section, we examine how Crowd-Logic optimizes for the general cost of human computation. **OPTIMIZING FOR COST** As a simple example, the following logic program provides two rules to determine if X is in one of the two given groups (assuming "in_group" is a human primitive): ``` in_group2(X, A, B) :- in_group(X, A). in_group2(X, A, B) :- in_group(X, B). ``` In its declarative interpretation, the interpreter has two choices of control flows: either test the first rule first or test the second rule first. Consider the situation where "in_group(X, A)" (or "in_group(X, A)") is previously computed, the interpreter can reduce the cost of human computation by choosing to test the second (or first) rule first as it will directly reuse the prior result and potentially eliminate the need to test the other rule. In a more difficult situation where no reuse is available, e.g., neither "in_group(X, A)" nor "in_group(X, B)" is ever computed, if however the interpreter can predict which group X is more likely to be in, it can reduce the average cost of human computation by choosing to test the more likely group first. Such prediction can be enabled through a statistical machine learning system trained on the previous results of computing "in_group". The above two situations illustrate how Crowd-Logic optimizes control flows to reduce the cost of human computation. To realize such strategy, Crowd-Logic implements a set of techniques, including introducing two new nondeterministic predicates and a best-first search strategy with heuristics from a lookahead algorithm. **Nondeterministic Predicates** Though a logic program could have a declarative interpretation with only partial control flow, the language specification usually forces a procedural interpretation with a deterministic control flow. In the "in_group2" example, a common procedural interpretation assumes the first rule will always be tested first. Such assumption is indeed important to many logic programs, for example, in Figure 1, the order of Rule 1 and Rule 2 is rigorous and the semantics will change if they are interchanged. In order to enable a partial control flow, Crowd-Logic introduces two new primitives, "nondeterministic" and "choose". Developers can use them to specify where they want the nondeterministic semantics. The primitive "nondeterministic" takes the name of a predicate as argument. It informs the interpreter that when in the search for a proof for the given predicate, the order of the rules to be tried can be arbitrary. For example, to make the aforementioned "in_group2" example work in Crowd-Logic, the developer can add the following query: ``` :- nondeterministic(in_group2). ``` The primitive choose will choose an item from a list in any nondeterministic order. For example, "in_group2" can be rewritten in a single rule with "choose": ``` in_group(X, [A, B]) :- choose([A, B], G), in_group(X, G). ``` It is a handy shortcut for specifying nondeterministic behavior with lists. In theory, "choose" can be specified by "nondeterministic". However, implementing it as a primitive is much more efficient. With the introduction of the above two predicates, the interpreter is allowed to make decisions upon nondeterministic predicates about which action to take in its search for a proof. Essentially, we would like to find the decisions that minimize the cost of human computation. Such minimization is possible with small search space, as in the "in_group2" example. However, it is not always possible when the search space is large. Crowd-Logic takes a best-first search strategy when solving a query: when there are multiple actions available for a nondeterministic predicate, it computes a heuristic for each action and try the best action first. The challenge is to find good heuristics. Many good heuristics come from the domain knowledge. However, being a general programming language, the domain knowledge of the program is not readily available. In the next section, we describe a lookahead algorithm, which is able to generate a partial probabilistic lookahead tree and compute some useful heuristics. A Lookahead Algorithm The idea of our lookahead algorithm is to look ahead in the proof search tree so that the interpreter can estimate the cost of going down different paths. The more states it can look ahead, the better such estimation could be. The sub tree that the lookahead process has traversed is called the lookahead tree. We use the quicksort algorithm as an example to introduce a variety of techniques that our lookahead algorithm employs to deal with human primitives and state explosion. Our quicksort implementation is shown in Figure 4. The predicate "le" is a human primitive that compares two items using human judgment. We use "choose(Xs, X)" to pick a pivot, which allows the interpreter to choose a better pivot to reduce the cost of human computation: when the interpreter encounters a state of choosing a pivot, it looks ahead in the proof search tree to compute heuristics for each pivot candidate. It then picks the best pivot and continues. When the lookahead process tries to traverse the proof search tree from a state of choosing a pivot, it will quickly find many human primitives as illustrated in Figure 5a. The interpreter does not know whether a never-encountered human comparison, e.g., "le(H, X)", will return true or false before executing it. Stopping the lookahead process at these human comparisons will lead to bad heuristics because the lookahead tree is too restricted. To address this problem, we introduce probabilistic edges. When a never-encountered human comparison is found in the lookahead process, we keep expanding the lookahead tree as if the comparison would return true and assign the probability of this comparison being true to the expanded edge. The lookahead tree in Figure 5a can be expanded into Figure 5b. Without any knowledge about the comparisons, we assign the probability of the edge to be 0.5. The probabilities allow us to estimate the average cost. Though the probabilistic approach enables more states to be explored in the lookahead process, the ability to look down all the paths in the proof tree could generate a tree that grows exponentially. It soon becomes intractable to explore much deeper as illustrated in Figure 5b. To address this problem, we limit the number of active paths that can be explored in the lookahead process under each choice state, e.g., pivot. If at any time the number of active paths exceeds this limit, we prune the least likely paths based on their probabilities. Figure 5c shows a limit of 2 active paths. ![Figure 4: Quicksort (using human judgment for comparison) implemented in Crowd-Logic.](image) ![Figure 5: Lookahead trees: (a) Non-probabilistic. (b) Probabilistic. (c) Probabilistic with sampling. (d) States can still explode on hard problems.](image) ```plaintext @Classifier(key="le") public double lessThan( BindingTable bt, CTerm a, CTerm b) { // Call the statistical machine learning // system to classify if a is less than b. } ``` ![Figure 6: Annotation "@Classifier" to offer probability estimation for human comparisons that enables more informed sampling in the lookahead.](image) Using Better Probabilities Since the sampling method is based on the probabilities of the paths, it will be more effective if we have a better prediction than 0.5 for the human primitives. The better prediction could also produce better heuristics. One way to obtain a better prediction is to use a statistical machine learning system. For example, we can compute a set of features for a pair of two items and train a statistical classifier on the prior comparison results. We can then use the probability from the classification result. Crowd-Logic allows developers to provide such probability via an annotated Java method, as shown in Figure 6. The developer implements a method that takes the same parameters as the actual implementation of the human primitive to be predicted. The method returns a probability. In order to inform the interpreter about the availability such prediction, the method needs to be annotated using "@Classifier" with the corresponding human primitive as "key". When the library is loaded, the interpreter will scan for such methods and use them to predict human primitives in the lookahead process. Bounded or Further Pruning However, even with the perfect prediction and sampling, the lookahead process still cannot explore all the paths. In sorting, with perfect prediction, all the states for choosing pivots will still remain active in the lookahead process as illustrated in Figure 5d. There is still an exponential number of paths can be explored. There two options under such situation, both are available in Crowd-Logic. One option is to stop the lookahead after certain depth of "choose" states. For example, in sorting, we can only look ahead the next three possible pivots. The other option is to further prune down the size of tree by only keeping the best paths. The goodness of a path can be measured by their cost efficiency. Cost efficiency is the cost in human computation versus the progress it has contributed. The more progress has made with less human computation cost, the better the path is. In sorting, we can use the number of pivots have been picked as progress. However, in general, the progress information requires domain knowledge. Crowd-Logic allows developers to provide the progress information in their logic programs. Developers can inform the interpreter about the new progress by using primitive "progress". The primitive "progress" takes a number as argument. The interpreter will track the total progress in each state. The meaning of the progress is up to developers. In our quicksort example, we can use the number of partitions have been made as progress by adding "progress(1)" after each "partition". Human Primitives with Output Parameters We now look at human primitives with output variables. Consider the primitive "improve" in DescribeImage example. In the lookahead process, there is little can be said about the new text that the human worker will produce before actually we actually run it. The lookahead bind these unknown human output variables process to placeholders. The placeholder saves the information about where its value comes from. When the logic program requires computation on the placeholder, such as the length of a string and the value of an integer, the lookahead process will stop unless the developers can provide a Java method to compute it. We will see a concrete example in our validation section. Computing Heuristics from the Lookahead Tree After generating a probabilistic lookahead tree, the next step is to compute heuristics from it. Based on the heuristics, the interpreter will decide which path to take to solve the query. The heuristic \( f \) can be the average cost or average cost efficiency (cost/progress), which can be computed recursively. Let \( c(i) \) be the cost of the selected goal at \( i \), and \( c'(i) \) be the cost of the sub-tree under state \( i \). When \( i \) is deterministic, we have: \[ c'(i) = c(i) + \sum_{p(i,j)=1} \left( c'(j) \times p(i,j) \times \prod_{p(k)=1,k < j} p_{fail}(k) \right) \] \( p(i,j) \) is the probability of the transition from \( i \) to \( j \), which can be less than 1 when the selected goal at \( i \) is a human primitive. \( p_{fail} \) is the probability that a proof cannot be found under that state. When \( i \) is deterministic, its children have a linear order. \( k \) is a left sibling of \( j \). \( p_{fail} \) can be computed recursively by: \[ p_{fail}(i) = \prod_{p(i,j)=1} p_{fail}(j) \times p(i,j) \] When \( i \) is nondeterministic, \( c'(i) \) and \( p_{fail}(i) \) can take the value of its best child: \[ c'(i) = c'(j) \land p_{fail}(i) = p_{fail}(j), j = \arg\max_{p(i,k)=1} f(k) \] The function \( f \) is the heuristic function. The average progress can be computed similarly as the average cost. IMPLEMENTATION Crowd-Logic is implemented in Java. It implements a subset of standard Prolog. It uses Java DB (Derby) to manage its local databases. All the human primitives from the examples are also implemented in Java. In the evaluation, the human tasks are implemented on MTurk using its Java SDK to manage HITs and Amazon S3 to store question HTML. VALIDATION In this section, we validate Crowd-Logic and its optimization techniques by implementing two human computation algorithms, sorting a list of reviews using human judgment and shortening text using human rewrites. Quicksort The first algorithm is sorting a list of reviews by their sentiments using the quicksort algorithm. We want to validate that our optimization is able to optimize the control flow to reduce the cost of human computation when there are opportunities for reuse and better prediction for human primitives. We have already examined the quicksort implementation in Crowd-Logic in the previous sections (and in Figure 4). For comparison, a similar imperative implementation can be found in [9]. The implementation of the human primitive "is" can be as simple as asking three people if one review is more positive than the other. A classifier can be learned from a set of prior comparison results. However, what is more interesting about this quicksort algorithm is how much our optimization algorithm can reduce the cost of human computation, i.e., the number of human comparisons. More specifically, we examine how the quicksort algorithm performs with our optimization under different conditions: the combinations of different amounts of re-usable data, e.g., 0%, 20%, 40%, 60% and 80% of the total comparisons, and classifiers with different accuracies, e.g., 0.5 (a random guess), 0.8 and 1.0 (an oracle), and a baseline condition where the quicksort algorithm always chooses the first element as the pivot. Reuse is enabled for all conditions. We conduct an experiment on sorting a list of 20 reviews. The experiment contains a total of 100 runs. In each run, the list is first randomized and then sorted by the quicksort algorithm across all conditions. The percentage of total amount reduction in human comparisons from the baseline is computed for each condition and then averaged over the 100 runs. For the purpose of our experiment, we simulate the human comparison by assuming a total order of the reviews. We also simulate the predictions from the classifier. For a classifier of accuracy 0.8, we first compute a distorted order of the reviews from their total order so that only 80% of the comparisons between two reviews remain the same. The probability that one review is better than the other is 0.8 if it is consistent with the distorted order and 0.2 otherwise. The result of the experiment is shown in Figure 7. The more prior results that are available or the more accurate the classifier is, the more reduction can be gained from the optimization. The accuracy of 0.8 is quite common between machine learning systems, yet it is almost as helpful as the oracle. With a common classifier and some prior results, the optimization algorithm can produce 20% to 30% reductions. When no prior results can be reused, a common classifier can still give us about 15% reductions, and when no classifier is available, a random guess can still give us about 15% reductions. These results validates that our optimization algorithm is effective. Shortening Text We want to validate that our optimization is able to reduce the amount of human computation by a significant amount. For this purpose, we simulate the human comparison by assuming a total order of the reviews. We also simulate the predictions from the classifier. For a classifier of accuracy 0.8, we first compute a distorted order of the reviews from their total order so that only 80% of the comparisons between two reviews remain the same. The probability that one review is better than the other is 0.8 if it is consistent with the distorted order and 0.2 otherwise. The result of the experiment is shown in Figure 7. The more prior results that are available or the more accurate the classifier is, the more reduction can be gained from the optimization. The accuracy of 0.8 is quite common between machine learning systems, yet it is almost as helpful as the oracle. With a common classifier and some prior results, the optimization algorithm can produce 20% to 30% reductions. When no prior results can be reused, a common classifier can still give us about 15% reductions, and when no classifier is available, a random guess can still give us about 15% reductions. These results validates that our optimization algorithm is effective. Figure 8 The logical representation of ShortenText in Crowd-Logic announced Java method as shown in Figure 9. We provide a "shorten" first with the estimation about how much a range will terminate once the paragraph is short enough. The interpreter is also able to prioritize which range to be shortened, we show that Crowd-Logic allows this to be done easily: by adding R0. The interpreter will terminate once the paragraph is short enough. The interpreter is also able to prioritize which range to shorten first with the estimation about how much a range can be shortened. The estimation can be provided via an annotated Java method as shown in Figure 9. We provide a simple estimation that the length of the new text is 80% of the original text length. The interpreter is able to provide additional information about how to calculate the maximal shorten length is required Figure 9 An annotated Java method that could provide additional information about how to compute with a placeholder. To validate the optimization, we run ShortenText on 50 paragraphs from TOEFL writing test. For our purpose (to validate the optimization), we use simulation for "find", "fix" and "verify", rather than asking human to perform the tasks, as the purpose our experiment is not to validate if text can be shortened using human computation which has been validated in Soylent [3]. To simulate "find" we randomly generate 4 to 8 text ranges with varying length from 10 to 50. To simulate "fix", we generate a string with a random length between 50% and 90% of the original length. To simulate "verify", we assume that probability of a good answer to be 70%. We assume "fix" costing 0.05 USD and "verify" costing 0.12 USD (three votes, each 0.04 USD). We only measure the cost of "fix" and "verify" with and without estimation. ("find" is the always same under both conditions) and vary the lengths to be shortened: 20%, 40%, 60%, 80% and 100% of the max possible shortening length. The result is shown in Figure 10. It validates that the optimization is able to better optimize the cost of human computation with the help of estimation. RELATED WORK Multiple tools have been proposed for making programming human computation easier. MTurk provides a basic API [2] for managing human tasks on its crowdsourcing platform. TurkKit [9] provides a thin Java/JavaScript API wrapper around MTurk API. It also introduces a crash-and-rerun programming model to avoid running redundant human tasks when re-running a program. However, since it is implemented by restoring the program state, unlike Crowd-Logic, it does not actually reuse redundant human tasks. The same human tasks will be run again if the program or the data input changes. CrowdForge [8] is a general purpose framework for crowdsourcing complex tasks by splitting and recombining complex human computation. Jabberwocky [8] provides a similar framework, ManReduce. In addition, it implements a human and machine resource management system and a high-level procedural programming language for programming in ManReduce. Crowd-Logic allows a human computation program to be built on any crowdsourcing platform including Jabberwocky, and is not designed towards any particular framework. The declarative approach to human computation has received much interest in the database research. CrowdDB [1] is a database system that processes queries using human computation. Both the queries and data models are specified in the declarative language SQL. Deco [7] is a similar system that uses a simple extension to SQL to pose queries. Qurk [14] is another SQL query system enables human-based processing. All these systems enable reuse of prior human computation as in Crowd-Logic. However, unlike the SQL-like query languages, the logic programming language in Crowd-Logic allows developers to implement general human computation algorithms. ```java @Estimator(key="shorten") public Term estimate( BindingTable bt, CTerm arg) { // If arg is 'length(placeholder)', where // the placeholder is for the output text // from fix, // return the original length * 4 / 5. } ``` Figure 10 Cost when only a certain percentage of the maximal possible shortening length optimize the control flow to reduce the cost of human computation when the estimation of human answers is available. Soylent [3] demonstrates that human computation can be used to shorten text paragraphs without changing their meanings by using a proper workflow (Find-Fix-Verify). We implemented ShortenText to accomplish the same task with the same workflow as in Soylent. The logic programming part of ShortenText is shown in Figure 8. There are three human primitives: "find", "fix", and "verify". The human computation is realized via MTurk. In the task of shortening a text, progress can be represented by how much has been shortened. Thus, in ShortenText, when a rewrite is verified, the change in length is reported as progress through primitive "progress". In Soylent, although the interface provides a slider to let the user control how much to be shortened, the algorithm for shortening is unaware of the how much to be shortened. It always tries to find all possible rewrites even when the user only wants to shorten text by a couple of words. While the original algorithm can be modified to take into account how much to be shortened, we show that Crowd-Logic allows this to be done easily: by adding R0. The interpreter will terminate once the paragraph is short enough. The interpreter is also able to prioritize which range to shorten first with the estimation about how much a range can be shortened. The estimation can be provided via an annotated Java method as shown in Figure 9. We provide a simple estimation that the length of the new text is 80% of the original text length. In the task of shortening a text, progress can be represented by how much has been shortened. Thus, in ShortenText, when a rewrite is verified, the change in length is reported as progress through primitive "progress". In Soylent, although the interface provides a slider to let the user control how much to be shortened, the algorithm for shortening is unaware of the how much to be shortened. It always tries to find all possible rewrites even when the user only wants to shorten text by a couple of words. While the original algorithm can be modified to take into account how much to be shortened, we show that Crowd-Logic allows this to be done easily: by adding R0. The interpreter will terminate once the paragraph is short enough. The interpreter is also able to prioritize which range to shorten first with the estimation about how much a range can be shortened. The estimation can be provided via an annotated Java method as shown in Figure 9. We provide a simple estimation that the length of the new text is 80% of the original text length. To validate the optimization, we run ShortenText on 50 paragraphs from TOEFL writing test. For our purpose (to validate the optimization), we use simulation for "find", "fix" and "verify", rather than asking human to perform the tasks, as the purpose our experiment is not to validate if text can be shortened using human computation which has been validated in Soylent [3]. To simulate "find" we randomly generate 4 to 8 text ranges with varying length from 10 to 50. To simulate "fix", we generate a string with a random length between 50% and 90% of the original length. To simulate "verify", we assume that probability of a good answer to be 70%. We assume "fix" costing 0.05 USD and "verify" costing 0.12 USD (three votes, each 0.04 USD). We only measure the cost of "fix" and "verify" with and without estimation. ("find" is the always same under both conditions) and vary the lengths to be shortened: 20%, 40%, 60%, 80% and 100% of the max possible shortening length. The result is shown in Figure 10. It validates that the optimization is able to better optimize the cost of human computation with the help of estimation. RELATED WORK Multiple tools have been proposed for making programming human computation easier. MTurk provides a basic API [2] for managing human tasks on its crowdsourcing platform. TurkKit [9] provides a thin Java/JavaScript API wrapper around MTurk API. It also introduces a crash-and-rerun programming model to avoid running redundant human tasks when re-running a program. However, since it is implemented by restoring the program state, unlike Crowd-Logic, it does not actually reuse redundant human tasks. The same human tasks will be run again if the program or the data input changes. CrowdForge [8] is a general purpose framework for crowdsourcing complex tasks by splitting and recombining complex human computation. Jabberwocky [8] provides a similar framework, ManReduce. In addition, it implements a human and machine resource management system and a high-level procedural programming language for programming in ManReduce. Crowd-Logic allows a human computation program to be built on any crowdsourcing platform including Jabberwocky, and is not designed towards any particular framework. The declarative approach to human computation has received much interest in the database research. CrowdDB [1] is a database system that processes queries using human computation. Both the queries and data models are specified in the declarative language SQL. Deco [7] is a similar system that uses a simple extension to SQL to pose queries. Qurk [14] is another SQL query system enables human-based processing. All these systems enable reuse of prior human computation as in Crowd-Logic. However, unlike the SQL-like query languages, the logic programming language in Crowd-Logic allows developers to implement general human computation algorithms. Much work has explored optimization techniques for human computation tasks. TurKontrol [10,11] is a planner that uses a decision-theoretical model to learn and optimize the iterative improvement workflow for better utility. Marcus A., Wu E. and et al. [5,6] studied the various algorithms for sorting and joining in Qurk. CrowdScreen [10] studied the optimization problem of filtering data based on a set of human-verifiable properties. In contrast, Crowd-Logic is agnostic to the tasks to be optimized. The input to our optimization process is the actual code that specifies the algorithm. DISCUSSION The Boundary of Logic Programming In our hybrid framework, the separation of what is implemented in logic programming and what is implemented in imperative programming is not strictly defined. It is up to the developers to decide where to set the boundary. In the DescribeImage example, the implementation of the primitive "is_better" computes the majority from multiple human votes. It hides the actual voting process from the iterative improvement workflow. An alternative is to specify the voting process in logic rules and implement a single vote as a human primitive in imperative language. There are two obvious extremes here. On one side, a developer can implement the entire human computation algorithm using imperative programming as a single human primitive. Then it loses all the benefits from Crowd-Logic, e.g., reusing human computation and optimization cost. On the other side, a developer can put as much as they can into the logic programs and only implements basic API to the crowdsourcing platforms in imperative programs. This would cause a much larger state space in proof search tree and degrade the performance of the optimization process. Both extremes are not good practices. Parallelism Crowd-Logic did not look at enabling and optimizing for parallelism in workflows. However, logic programs offer intrinsic parallelism and parallel logic programming is one of the heavily explored topics in logic programming [13]. An easy approach is to find the independent goals in the search state and then search them concurrently. More sophisticated approach is to use lookahead to optimize for the speed rather cost, and find a much larger set of human computations to run in parallel. These suggest an avenue of future work for Crowd-Logic. Reuse and Pure Logic Programming The reuse of human computation is essential to the declarative approach. Consider the implementation of "an input agreement": an answer is agreed when two people have both verified. One plausible specification can be the following rule (where "verify" is a human primitive that asks a person to verify a given answer): \[ \text{agree2}(A) :- \text{verify}(A), \text{verify}(A). \] We presented Crowd-Logic, a tool for implementing and optimizing human computation algorithms using logic programming. It enables maximally reusing prior human computation results by using constraint solving. We also explored adding nondeterministic choices to the logic programming and optimizing control flows on these choices to reduce the general human cost in human computation algorithms. REFERENCES 7. Franklin, M.J., Kossmann, D., Kraska, T., Ramesh, S., and Xin, R. CrowdDB: answering queries with Crowdforge: Crowdsourcing complex work. Proc. UIST 2011, 43–52. 9. Little, G., Chilton, L.B., Goldman, M., and Miller, R.C. TurKit: Human Computation Algorithms on 10. Marcus, A., Wu, E., Karger, D., Madden, S., and Miller, R. Human-powered sorts and joins. Proceedings of the 11. Marcus, A., Wu, E., Karger, D.R., Madden, S., and Miller, R.C. Demonstration of Qurk: A Query Processor for Human Operators. Proc. SIGMOD 2011, 1315- 1318. PlateMate: Crowdsourcing Nutrition Analysis from 13. Parameswaran, A., Garcia-molina, H., Park, H., and Widom, J. CrowdScreen: Algorithms for Filtering Data 14. Parameswaran, A., Park, H., Garcia-Molina, H., Polyzotis, N., and Widom, J. Deco: Declarative 15. Sterling, L. and Shapiro, E. The Art of Prolog: Advanced Programming Techniques. The MIT Press, 1986.
{"Source-Url": "https://www.cs.washington.edu/tr/2012/11/UW-CSE-12-11-01.PDF", "len_cl100k_base": 10462, "olmocr-version": "0.1.49", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 34499, "total-output-tokens": 11618, "length": "2e13", "weborganizer": {"__label__adult": 0.00035119056701660156, "__label__art_design": 0.0003027915954589844, "__label__crime_law": 0.0003859996795654297, "__label__education_jobs": 0.00091552734375, "__label__entertainment": 8.666515350341797e-05, "__label__fashion_beauty": 0.00017070770263671875, "__label__finance_business": 0.00022494792938232425, "__label__food_dining": 0.00034809112548828125, "__label__games": 0.0006856918334960938, "__label__hardware": 0.0006690025329589844, "__label__health": 0.0005421638488769531, "__label__history": 0.00022935867309570312, "__label__home_hobbies": 8.916854858398438e-05, "__label__industrial": 0.0004019737243652344, "__label__literature": 0.0003695487976074219, "__label__politics": 0.00028252601623535156, "__label__religion": 0.0004818439483642578, "__label__science_tech": 0.03436279296875, "__label__social_life": 9.834766387939452e-05, "__label__software": 0.007175445556640625, "__label__software_dev": 0.95068359375, "__label__sports_fitness": 0.000301361083984375, "__label__transportation": 0.0005626678466796875, "__label__travel": 0.0001709461212158203}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 50941, 0.02339]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 50941, 0.80646]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 50941, 0.90276]], "google_gemma-3-12b-it_contains_pii": [[0, 4414, false], [4414, 7743, null], [7743, 12489, null], [12489, 17615, null], [17615, 22366, null], [22366, 26509, null], [26509, 31901, null], [31901, 36090, null], [36090, 45797, null], [45797, 49703, null], [49703, 50941, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4414, true], [4414, 7743, null], [7743, 12489, null], [12489, 17615, null], [17615, 22366, null], [22366, 26509, null], [26509, 31901, null], [31901, 36090, null], [36090, 45797, null], [45797, 49703, null], [49703, 50941, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 50941, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 50941, null]], "pdf_page_numbers": [[0, 4414, 1], [4414, 7743, 2], [7743, 12489, 3], [12489, 17615, 4], [17615, 22366, 5], [22366, 26509, 6], [26509, 31901, 7], [31901, 36090, 8], [36090, 45797, 9], [45797, 49703, 10], [49703, 50941, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 50941, 0.0]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
3b03e92635a6876066a3f1431e288edd2edc55e9
Sampling Effect on Performance Prediction of Configurable Systems: A Case Study Juliana Alves Pereira, Mathieu Acher, Hugo Martin, Jean-Marc Jézéquel To cite this version: HAL Id: hal-02356290v3 https://inria.hal.science/hal-02356290v3 Submitted on 21 Apr 2020 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Sampling Effect on Performance Prediction of Configurable Systems: A Case Study Juliana Alves Pereira Univ Rennes, Inria, CNRS, IRISA Rennes, France juliana.alves-pereira@irisa.fr Hugo Martin Univ Rennes, Inria, CNRS, IRISA Rennes, France hugo.martin@irisa.fr Mathieu Acher Univ Rennes, Inria, CNRS, IRISA Rennes, France mathieu.acher@irisa.fr Jean-Marc Jézéquel Univ Rennes, Inria, CNRS, IRISA Rennes, France jean-marc.jezequel@irisa.fr ABSTRACT Numerous software systems are highly configurable and provide a myriad of configuration options that users can tune to fit their functional and performance requirements (e.g., execution time). Measuring all configurations of a system is the most obvious way to understand the effect of options and their interactions, but is too costly or infeasible in practice. Numerous works thus propose to measure only a few configurations (a sample) to learn and predict the performance of any combination of options’ values. A challenging issue is to sample a small and representative set of configurations that leads to a good accuracy of performance prediction models. A recent study devised a new algorithm, called distance-based sampling, that obtains state-of-the-art accurate performance predictions on different subject systems. In this paper, we replicate this study through an in-depth analysis of x264, a popular and configurable video encoder. We systematically measure all 1,152 configurations of x264 with 17 input videos and two quantitative properties (encoding time and encoding size). Our goal is to understand whether there is a dominant sampling strategy over the very same subject system (x264), i.e., whatever the workload and targeted performance properties. The findings from this study show that random sampling leads to more accurate performance models. However, without considering random, there is no single “dominant” sampling, instead different strategies perform best on different inputs and non-functional properties, further challenging practitioners and researchers. KEYWORDS Software Product Lines, Configurable Systems, Machine Learning, Performance Prediction 1 INTRODUCTION Configurable software systems offer a multitude of configuration options that can be combined to tailor the systems’ functional behavior and performance (e.g., execution time, memory consumption). Options often have a significant influence on performance properties that are hard to know and model a priori. There are numerous possible options values, logical constraints between options, and subtle interactions among options [15, 25, 46, 51, 52] that can have an effect while quantitative properties such as execution time are themselves challenging to comprehend. Measuring all configurations of a configurable system is the most obvious path to e.g., find a well-suited configuration, but is too costly or infeasible in practice. Machine-learning techniques address this issue by measuring only a subset of configurations (known as sample) and then using these configurations’ measurements to build a performance model capable of predicting the performance of other configurations (i.e., configurations not measured before). Several works thus follow a “sampling, measuring, learning” process [3, 15, 20–23, 27, 40, 42, 43, 46, 51, 52, 60, 63, 64]. A crucial step is the way the sampling is realized, since it can drastically affect the performance model accuracy [25, 46]. Ideally, the sample should be small to reduce the cost of measurements and representative of the configuration space to reduce prediction errors. The sampling phase involves a number of difficult activities: (1) picking configurations that are valid and conform to constraints among options – one needs to resolve a satisfiability problem; (2) instrumenting the executions and observations of software for a variety of configurations – it might have a high computational cost especially when measuring performance aspects of software; (3) guaranteeing a coverage of the configuration space to obtain a representative sample set. An ideal coverage includes all influential configuration options by covering different kinds of interactions relevant to performance. Otherwise, the learning may hardly generalize to the whole configuration space. With the promise to select a small and representative sample set of valid configurations, several sampling strategies have been devised in the last years [46]. For example, random sampling aims to cover the configuration space uniformly while coverage-oriented sampling selects the sample set according to a coverage criterion (e.g., t-wise sampling to cover all combinations of t selected options). Recently, Kaltenecker et al. [25] analyzed 10 popular real-world software systems and found that their novel proposed sampling strategy, called diversified distance-based sampling, dominates five other sampling strategies by decreasing the cost of labelling software configurations while minimizing the prediction errors. In this paper, we conduct a replication of this preliminary study by exclusively considering the x264 case, a configurable video encoder. Though we only consider one particular configurable system, we make vary its workloads (with the use of 17 input videos) and measured two performance properties (encoding time and encoding size) over 1,152 configurations. Interestingly, Kaltenecker et al. [25] also analyzed the same 1,152 configurations of x264, but a fixed input video was used and only the time was considered. The goal of our experiments is to determine whether sampling strategies considered in [25] over different subject systems are as effective on the same configurable system, but with different factors possibly influencing the distribution of the configuration space. A hypothesis is that practitioners of a configurable system can rely on a one-size-fits-all sampling strategy that is cost-effective whatever the factors influencing the distribution of its configuration space. On the contrary, another hypothesis is that practitioners should change their sampling strategy each time an input (here: videos) or a performance property is targeted. We investigate to what extent sampling strategies are sensitive to different workloads of the x264 configurable system and different performance properties: What are the most effective sampling strategies? Is random sampling a strong baseline? Is there a dominant sampling strategy that practitioners can always rely on? To this end, we systematically report the influence of sampling strategies on the accuracy of performance predictions and on the robustness of prediction accuracy. Our contributions are as follows: - We rank six sampling strategies based on a unified benchmark over seventeen different inputs and two non-functional properties. We show that the ranking of non-random sampling strategies is quite unstable, being heavily sensitive to input video and targeted performance property. We gather preliminary insights about the effectiveness of some sampling strategies on some videos and performances; - We compare our results to the previous study of x264 [25], that was based on the use of a single input video and measurements of encoding time. Through our experimental results, we find that for the non-functional property encoding time uniform random sampling dominates all the others sampling strategies w.r.t. prediction accuracy for a majority of cases, as in Kallenecker et al. [25]; - We have made all the artifacts from our replication study publicly available at https://github.com/julianapesreira/ICPE2020. With respect to the categorized research methods by Stol et al. [57], our paper mainly contributes to a knowledge-seeking study. Specifically, we perform a field experiment of x264, a highly-configurable system and mature project. We gain insights about performance properties using a large corpus of configurations and input videos. Audience. Researchers and practitioners in configurable systems and performance engineering shall benefit from our sampling experiments and insights. We discuss impacts of our results for practitioners (How to choose a sampling strategy?) and for the research community (e.g., on the design and assessment of sampling strategies). 2 BACKGROUND AND RELATED WORK In this section, we introduce basic concepts of configurable software systems and motivate the use of learning techniques in this field. Furthermore, we briefly describe six state-of-the-art sampling strategies used in our experiments. 2.1 Learning Software Configuration Spaces x264 is a command-line tool to encode video streams into the H.264/MPEG-4 AVC format. Users can configure x264 through the selection of numerous options, some having an effect on the time needed to encode a video, on the quality or the size of the output video, etc. A configuration of x264 is an assignment of values to options. In our study and as in [25], we only consider Boolean options that can be selected or deselected. As in most configurable systems, not all combinations of options are valid due to constraints among options. For instance, ref_1, ref_5, and ref_9 are mutually exclusive and at least one of these options should be selected. Executing and measuring every valid configuration to know about its performance or identify the performance-optimal one is often unfeasible or costly. To overcome this problem, machine learning techniques rely on a small and representative sample of configurations (see Figure 1). Each configuration of the sample is executed and labelled with a performance measurement (e.g., encoding time). The sample is then used for training a learning algorithm (i.e., a regressor) that builds a performance model capable of predicting the performance of unmeasured configurations. The performance model may lead to prediction errors. The overall goal is to obtain high accuracy roughly computed as the difference between actual performances and predicted performances (more details are given hereafter). How to efficiently sample, measure, and learn is subject to intensive research [46]. In case important (interactions among options are not included in the training set, the learning phase can hardly generalize to the whole population of configurations. Hence, sampling is a crucial step of the overall learning process with an effect on the accuracy of the prediction model. 2.2 Sampling Strategies Several sampling strategies have been proposed in the literature about software product lines and configurable systems [46, 62, 66]. Sampling for testing. Some works consider sampling for the specific case of testing configurations. There is not necessarily a learning phase and the goal of sampling is mostly to find and cover as many faults as possible. For instance, Medeiros et al. compared 10 sampling algorithms to detect different faults in configurable systems [35]. Arcuri et al. theoretically demonstrate that a uniform random sampling strategy may outperform coverage-based sampling [5] (see hereafter). Halin et al. demonstrated that uniform random sampling forms a strong baseline for faults and failure efficiency on the JHipster case [17]. Varshosaz et al. [66] conducted a survey of sampling for testing configurable systems. Though the purpose differs, some of these sampling strategies are also relevant and considered in the context of performance prediction. Sampling for learning. Pereira et al. [46] review several sampling strategies specifically used for learning configuration spaces. We now present an overview of six sampling strategies also considered in [25] and used in our study. All strategies have the merit of being agnostic of the domain (no specific knowledge or prior analysis are needed) and are directly applicable to any configurable system. Random sampling aims to cover the configuration space uniformly. Throughout the paper, we refer to random as uniform random sampling. The challenge is to select one configuration amongst all the valid ones in such a way each configuration receives an equal probability to be included in the sample. An obvious solution is to enumerate all valid configurations and randomly pick a sample from the whole population. However, enumerative approaches... quickly do not scale with a large number of configurations. Oh et al. [43] rely on binary decision diagrams to compactly represent a configuration space, which may not scale for very large systems [36]. Another line of research is to rely on satisfiability (SAT) solvers. For instance, UniGen [8, 9] uses a hashing-based function to synthesize samples in a nearly uniform manner with strong theoretical guarantees. These theoretical properties come at a cost: the hashing-based approach requires adding large clauses to formulas. Plazar et al. [47] showed that state-of-the-art algorithms are either not able to produce any sample or unable to generate uniform samples for the SAT instances considered. Overall, a true uniform random sampling may be hard to realize, especially for large configurable systems. At the scale of the x264 study [25], though, uniform sampling is possible (the whole population is 1,152 configurations). The specific question we explore here is whether random is effective for learning (in case it is applicable as in x264). When random sampling is not applicable, several alternate techniques have been proposed typically by sacrificing some uniformity for a substantial increase in performance. **Solver-based.** Many works rely on off-the-shelf constraint solver, such as SAT4J [31] or Z3 [12], for sampling. For instance, a random seed can be set to the Z3 solver and internally influences the variable selection heuristics, which can have an effect on the exploration of valid configurations. Henard et al. noticed that solvers’ internal order yields non-uniform (and predictable) exploration of the configuration space [18]. Hence, these strategies do not guarantee true randomness as in uniform random sampling. Often the sample set consists of a locally clustered set of configurations. **Randomized solver-based.** To weaken the locality drawback of solver-based sampling, Henard et al. change the order of variables and constraints at each solver run. This strategy, called randomized solver-based sampling in Kaltenecker et al. [25], increases diversity of configurations. Though it cannot give any guarantees about randomness, the diversity may help to capture important interactions between options for performance prediction. **Coverage-based sampling** aims to optimize the sample with regards to a coverage criterion. Many criteria can be considered such as statement coverage that requires the analysis of the source code. In this paper and as in Kaltenecker et al. [25], we rely on t-wise sampling [11, 24, 30]. This sampling strategy selects configurations to cover all combinations of t selected options. For instance, pair-wise (t=2) sampling covers all pairwise combinations of options being selected. There are different methods to compute t-wise sampling. As in [25], we rely on the implementation of Siegmund et al. [53]. **Distance-based.** Kaltenecker et al. [25] propose distance-based sampling. The idea is to cover the configuration space by selecting configurations according to a given probability distribution (typically a uniform distribution) and a distance metric. The underlying benefit is that distance-based sampling can better scale compared to an enumerative-based random sampling, while the generated samples are closed to those obtained with a uniform random. **Diversified distance-based sampling** is a variant of distance-based sampling [25]. The principle is to increase diversity of the sample set by iteratively adding configurations that contain the least frequently selected options. The intended benefit is to avoid missing the inclusion of some (important) options in the process. ### 2.3 Sampling Effect on x264 This paper aims to replicate the study of Kaltenecker et al. [25]. While Kalteneker et al. analyse a wide variety of systems from different domains, we focus on the analysis of a single configurable system. Compared to that paper, our study enables a deeper analysis of sampling strategies over the possible influences of inputs and performance properties. Specifically, we analyze a set of seventeen input videos and two non-functional properties. As in [25], we collect results of 100 independent experiments to increase statistical confidence and external validity. We aim at exploring whether the results obtained in [25] may be generalized over different variations of a single configurable system. Interestingly, numerous papers have specifically considered the x264 configurable system for assessing their proposals [15, 21, 22, 43, 46, 51, 58, 63, 64], but a fixed performance property or input video is usually considered. Jamshidi et al. [21] explore the impacts of versions, workloads, and hardware of several configurable systems, including x264. However, the effect of sampling strategies was not considered. In [22], sampling We aim to understand what sampling strategy to use and whether diversified distance-based sampling also dominates across distributions over two input videos for the performance property size (in bytes) of an output video in the H.264 format. Figure 2: The size distribution of 1,152 configurations of x264 over two input videos Strategies for transfer learning were investigated; we are not considering such scenarios in our study. Overall, given a configurable system like x264, practitioners face the problem of choosing the right techniques for ‘sampling, measuring, learning’. Specifically, we aim to understand what sampling strategy to use and whether there exists a sampling to rule any configuration space of x264. The use of different input videos obviously changes the raw and absolute performance values, but it can also change the overall distribution of configuration measurements. Figure 2 gives two distributions over two input videos for the performance property size for the whole population of valid configurations. Pearson correlation between the performance measurements of x2642 and x26415 is -0.35, suggesting a weak, negative correlation. The differences among distributions question the existence of a one-size-fits-all sampling capable of generating a representative sample set whatever the input videos or performance properties. Another hypothesis is that the way the sampling is done can pay off for some distributions but not for all. Given the vast variety of possible input videos and performance properties that may be considered, the performance variability of configurations grows even more. Our aim is to investigate how such factors affect the overall prediction accuracy of different sampling strategies: Is there a dominant sampling strategy for performance prediction of the same configurable system? 3 DESIGN STUDY In this section, we introduce our research questions, the considered subject system, and the experiment setup. 3.1 Research Questions We conducted a series of experiments to evaluate six sampling strategies and to compare our results to the original results in [25]. We aim at answering the following two research questions: - (RQ1) What is the influence of using different sampling strategies on the accuracy of performance predictions over different inputs and non-functional properties? - (RQ2) What is the influence of randomness of using different sampling strategies on the robustness of prediction accuracy? It is not new the claim that the prediction accuracy of machine learning extensively depends on the sampling strategy. The originality of the research question is to what extent are performance prediction models of the same configurable system (here: x264) sensitive to other factors, such as different inputs and non-functional properties. To address RQ1, we analyze the sensitivity of the prediction accuracy of sampling strategies to these factors. Since most of the considered sampling strategies use randomness, which may considerably affect the prediction accuracy, RQ2 quantitatively compares whether the variances (over 100 runs) on prediction accuracy between different sampling strategies and sample sizes differ significantly. We show that the sampling prediction accuracy and robustness hardly depend on the definition of performance (i.e., encoding time or encoding size). As in Kaltenecker et al. [25], we have excluded t-wise sampling from RQ2, as it is also deterministic in our setting and does not lead to variations. 3.2 Subject System We conduct an in-depth study of x264, a popular and highly configurable video encoder implemented in C. We choose x264 instead of the other case studies documented in Kaltenecker et al. [25] because x264 demonstrated more promising accuracy results to the newest proposed sampling approach (i.e., diversified distance-based sampling). With this study, we aim at investigating, for instance, whether diversified distance-based sampling also dominates across different variations of x264 (i.e., inputs, performance properties). As benchmark, we encoded 17 different input videos from raw YUV to the H.264 codec and measured two quantitative properties (encoding time and encoding size). - Encoding time (in short time): how many seconds x264 takes to encode a video. - Encoding size of the output video (in short size): compression size (in bytes) of an output video in the H.264 format. All measurements have been performed over the same version of x264 and on a grid computing infrastructure called IGRIDA1. Importantly, we used the same hardware characteristics for all performance measurements. In Table 1, we provide an overview of the encoded input videos. This number of inputs allows us to draw conclusions about the practicality of sampling strategies for diversified conditions of x264. To control measurement bias while measuring execution time, we have repeated the measurements several times. We report in Table 1 how many times we have repeated the time measurements of all 1,152 configurations for each video input. the number of 1http://igrida.gforge.inria.fr/ we conducted experiments using three different sample sizes. To ensure we have a stable set of measurements (according to RSD results), independent of the machine. <table> <thead> <tr> <th>video</th> <th>#times</th> <th>stability</th> </tr> </thead> <tbody> <tr> <td>x264_0</td> <td>5</td> <td>0.010127</td> </tr> <tr> <td>x264_1</td> <td>5</td> <td>0.0044476</td> </tr> <tr> <td>x264_2</td> <td>5</td> <td>0.036826</td> </tr> <tr> <td>x264_3</td> <td>5</td> <td>0.086958</td> </tr> <tr> <td>x264_4</td> <td>9</td> <td>0.009481</td> </tr> <tr> <td>x264_5</td> <td>5</td> <td>0.029640</td> </tr> <tr> <td>x264_6</td> <td>3</td> <td>0.005503</td> </tr> <tr> <td>x264_7</td> <td>8</td> <td>0.010468</td> </tr> <tr> <td>x264_8</td> <td>11</td> <td>0.011258</td> </tr> <tr> <td>x264_9</td> <td>4</td> <td>0.006066</td> </tr> <tr> <td>x264_10</td> <td>23</td> <td>0.014536</td> </tr> <tr> <td>x264_11</td> <td>5</td> <td>0.009892</td> </tr> <tr> <td>x264_12</td> <td>5</td> <td>0.028564</td> </tr> <tr> <td>x264_13</td> <td>5</td> <td>0.044731</td> </tr> <tr> <td>x264_14</td> <td>3</td> <td>0.007625</td> </tr> <tr> <td>x264_15</td> <td>8</td> <td>0.010531</td> </tr> <tr> <td>x264_16</td> <td>16</td> <td>0.011847</td> </tr> </tbody> </table> Table 1: Overview of encoded input videos including the number of times we measured the encoding time in order to ensure we have a stable set of measurements (according to RSD results), independent of the machine. repetitions has been increased to reach a standard deviation of less than 10%. Since measurements are costly, we set the repetition to up 30 times given 1-hour restriction from where we got the #times in Table 1. We repeated the measurements at least three times and at most 23 times and retained the average execution time for each configuration. The stability column reports whether the configuration measurements for a given input video are stable (Relative Standard Deviation - RSD). For example, measurements present low RSD of \( \approx 1\% \). Although the RSD measure for Video 3 (claire_qcif.y4m) is higher compared to the others, the deviation still remains lower than 10% (i.e., RSD \( \approx 8.7\% \)). We provide the variability model and the measured values of each video input for encoding time and encoding size on our supplementary website. ### 3.3 Experiment Setup In our experiments, the independent variables are the choice of the input videos, the predicted non-functional-property, the sample strategies and the sample sizes. For comparison, we used the same experiment design than in Kaltenecker et al. [25]. To evaluate the accuracy of different sampling strategies over different inputs and non-functional-properties, we conducted experiments using three different sample sizes. To be able to use the same sample sizes for all sampling strategies, we consider the sizes from t-wise sampling with \( t=1, t=2, \) and \( t=3 \). As described in Section 2.2, t-wise sampling covers all combinations of \( t \) configuration options being selected. We learn a performance model based on the sample sets along with the corresponding performance measurements defined by the different sampling strategies. Although several machine-learning techniques have been proposed in the literature with this purpose [46], such as linear regression [10, 20, 21, 25–27, 33, 39, 50, 52, 54, 67], classification and regression trees (CART) [2, 16, 21, 28, 39–42, 48, 51, 56, 58, 60, 63, 64, 68–71], and random forest [3, 6, 49, 61, 63]. In this paper, we use stepwise multiple linear regression [52] as in Kaltenecker et al. [25]. According to Kaltenecker et al. [25], multiple linear regression is often as accurate as CART and random forests. To calculate the prediction error rate, we use the resulting performance models to predict the performance of the entire dataset of valid configurations \( C \). We calculate the error rate of a prediction model in terms of the mean relative error (MRE - Equation 1). MRE is used to estimate the accuracy between the exact measurements and the predicted one. \[ MRE = \frac{1}{|C|} \sum_{c \in C} \left| \frac{\text{measured}_c - \text{predicted}_c}{\text{measured}_c} \right| \] Where \( C \) is the set of all valid configurations used as the validation set, and \( \text{measured}_c \) and \( \text{predicted}_c \) indicate the measured and predicted values of performance for configuration \( c \) with \( c \in C \), respectively. The exact value of \( \text{measured}_c \) is measured at runtime while running the configuration \( c \), and the predicted values of \( \text{predicted}_c \) is computed based on the model built with a sample of configurations \( t \) (see Section 2.2). To address RQ1, we computed the mean error rate for each input video and sample size. A lower error rate indicates a higher accuracy. Then, we use a Kruskal-Wallis test [29] and pair-wise one-sided Mann-Whitney \( U \) tests [34] to identify whether the error rate of two sampling strategies differs significantly \( (p < 0.05) \) [4]. In addition, we compute the effect size \( A_{12} \) [65] (small\( <0.56 \), medium\( <0.64 \), and large\( >0.71 \)) to easily compare the error rates of two sampling strategies. To address RQ2, we compute the variance across the error rates over 100 runs. A lower variance indicates higher robustness. First, we use Levene’s test [32] to identify whether the variances of two sampling strategies differ significantly from each other. Then, for these sampling strategies, we perform a one-sided F-tests [55] to compare pair-wisely the variance between sampling strategies. All sampling and learning experiments have been performed on the same machine with Intel Core i7 CPU 2.2 GHz and 4GB RAM. To reduce fluctuations in the values of dependent variables caused by randomness (e.g., the random generation of input samples), we evaluated each combination of the independent variables 100 times. That is, for each input video, non-functional property, sampling strategy and sampling size, we instantiated our experimental settings and measured the values of all dependent variables 100 times with random seeds from 1 to 100. ### 4 RESULTS We compare six sampling strategies: t-wise, solver-based, randomized solver-based, distance-based, diversified distance-based, and random. Next, we present the results regarding prediction accuracy (RQ1, Section 4.1) and robustness (RQ2, Section 4.2). Table 2: Error rates of t-wise, (randomized) solver-based, (diversified) distance-based, and random sampling for the prediction of encoding time for 17 input videos of x264. The bottom row contains the MRE mean across all input videos. The best results per input video and sample size are highlighted in bold if the Mann-Whitney U test reported a significant difference ($p < 0.05$). <table> <thead> <tr> <th>Video</th> <th>Coverage-based</th> <th>Solver-based</th> <th>Randomized solver-based</th> <th>Distance-based</th> <th>Diversified distance-based</th> <th>Random</th> </tr> </thead> <tbody> <tr> <td>t = 1</td> <td>t = 2</td> <td>t = 3</td> <td>t = 1</td> <td>t = 2</td> <td>t = 3</td> <td>t = 1</td> </tr> <tr> <td>x264 1</td> <td>18.2%</td> <td>13.9%</td> <td>13.4%</td> <td>24.0%</td> <td>27.0%</td> <td>27.5%</td> </tr> <tr> <td>x264 2</td> <td>15.4%</td> <td>13.2%</td> <td>12.1%</td> <td>26.9%</td> <td>23.7%</td> <td>24.9%</td> </tr> <tr> <td>x264 3</td> <td>29.3%</td> <td>10.3%</td> <td>9.7%</td> <td>21.4%</td> <td>19.4%</td> <td>16.4%</td> </tr> <tr> <td>x264 4</td> <td>21.4%</td> <td>13.7%</td> <td>10.1%</td> <td>25.2%</td> <td>25.3%</td> <td>26.4%</td> </tr> <tr> <td>x264 5</td> <td>21.8%</td> <td>12.3%</td> <td>14.4%</td> <td>23.9%</td> <td>21.2%</td> <td>22.0%</td> </tr> <tr> <td>x264 6</td> <td>26.1%</td> <td>14.1%</td> <td>13.2%</td> <td>28.8%</td> <td>23.2%</td> <td>24.1%</td> </tr> <tr> <td>x264 7</td> <td>25.9%</td> <td>18.1%</td> <td>8.6%</td> <td>21.6%</td> <td>21.6%</td> <td>24.9%</td> </tr> <tr> <td>x264 8</td> <td>23.3%</td> <td>14.2%</td> <td>12.6%</td> <td>20.2%</td> <td>25.3%</td> <td>26.4%</td> </tr> <tr> <td>x264 9</td> <td>20.8%</td> <td>13.1%</td> <td>11.5%</td> <td>20.5%</td> <td>22.6%</td> <td>23.8%</td> </tr> <tr> <td>x264 10</td> <td>23.4%</td> <td>13.2%</td> <td>5.6%</td> <td>22.2%</td> <td>28.6%</td> <td>29.7%</td> </tr> <tr> <td>x264 11</td> <td>21.9%</td> <td>12.5%</td> <td>9.3%</td> <td>22.6%</td> <td>23.2%</td> <td>24.0%</td> </tr> <tr> <td>x264 12</td> <td>21.1%</td> <td>12.6%</td> <td>10.3%</td> <td>25.7%</td> <td>23.5%</td> <td>23.6%</td> </tr> <tr> <td>x264 13</td> <td>25.4%</td> <td>13.4%</td> <td>10.4%</td> <td>26.2%</td> <td>21.2%</td> <td>21.6%</td> </tr> <tr> <td>x264 14</td> <td>16.4%</td> <td>10.5%</td> <td>10.0%</td> <td>20.6%</td> <td>18.8%</td> <td>19.1%</td> </tr> <tr> <td>x264 15</td> <td>20.7%</td> <td>16.9%</td> <td>15.8%</td> <td>34.3%</td> <td>39.5%</td> <td>40.6%</td> </tr> <tr> <td>x264 16</td> <td>26.2%</td> <td>12.7%</td> <td>11.1%</td> <td>23.2%</td> <td>26.5%</td> <td>27.2%</td> </tr> <tr> <td>x264 17</td> <td>22.9%</td> <td>12.3%</td> <td>8.4%</td> <td>22.1%</td> <td>24.5%</td> <td>25.2%</td> </tr> </tbody> </table> Table 3: $p$ values from a one-sided pair-wise Mann-Whitney $U$ test for the property encoding time, where we tested pair-wisely whether the error rate of the sampling strategy from the row is significantly lower than the error rate of the sampling strategy from the column for different sample sizes. The effect size is included for every significant result ($p < 0.05$), where we consider the effect as small, medium, and large when $\hat{A}_{12}$ is over 0.56, 0.64, and 0.71, respectively. 4.1 Results RQ1—Prediction Accuracy In Tables 2 and 4, we show the MRE for the different sampling strategies and sample sizes for both encoding time and encoding size, respectively. In the bottom row, we provide the MRE mean over all input videos. As in Kalteniecek et al. [25], for each input video and sample-set size we highlight the lowest, statistically significant MRE in bold. 4.1.1 Input Sensitivity: Encoding Time. Random sampling performs best to all other sampling strategies or similar to the best one for $t=1, t=2$ and $t=3$ (except for a few input videos -- x2641, x2643, x2647, x2649, x2642, x2644, x26410, x26441 for $t=1$). We observe that for $t=1$ diversified distance-based sampling outperforms random sampling for seven input videos (x2642, x2643, x2647, x2648, x2649, x26410, x26441). Overall, diversified distance-based sampling produces partially good results (close to random sampling). Diversified distance-based sampling outperforms the pure distance based sampling, however their error rates are very similar for $t=1$. Solver-based sampling results in inaccurate performance models for all input videos and sample-set sizes. t-wise sampling performs overall better than solver-based sampling; randomized solver-based sampling performs best when only a very limited number of samples are considered (i.e., $t=1$). Table 3 reports the $p$ value ($\hat{A}_{12}$) of the Mann-Whitney U test. This table shows whether the sampling strategy of the row has a significantly lower error rate than the sampling strategy of the column. To this end, we first performed Kruskal-Wallis tests for all sample sizes ($t=1, t=2$, and $t=3$). Then, whether we identified $p$ values less than 0.05, indicating that, at least, two strategies differ significantly for each sample size [25], we performed one-sided Mann-Whitney U tests pair-wisely and, if significant ($p < 0.05$), we report the effect sizes in Table 3. The first row shows that $t$-wise sampling has significantly lower error rates than solver-based sampling and randomized solver-based sampling for $t=2$ and $t=3$, with large effect sizes. In the second and third rows, we observe that solver-based sampling performs Table 4: Error rates of t-wise, (randomized) solver-based, (diversified) distance-based, and random sampling for the prediction of encoding size for 17 input videos of x264. The bottom row contains the MRE mean across all input videos. The best results per input video and sample size are highlighted in bold if the Mann-Whitney U test reported a significant difference (p < 0.05). Table 5: p values from a one-sided pair-wise Mann-Whitney U test for the property encoding size, where we tested pair-wisely whether the error rate of the sampling strategy from the row is significantly lower than the error rate of the sampling strategy from the column, for different sample sizes. The effect size is included for every significant result (p < 0.05), where we consider the effect as small, medium, and large when $\hat{A}_{12}$ is over 0.56, 0.64, and 0.71, respectively. significantly better than randomized solver-based sampling for t=3 with medium effect sizes; and randomized solver-based leads to lower error rates than t-wise sampling for t=1, with a large effect size. In the last three rows, we see that (diversified) distance-based sampling and random sampling lead to lower error rates than t-wise sampling, solver-based sampling, and randomized solver-based sampling for t=1, t=2 and t=3, with large effect sizes. The pure distance-based sampling leads to higher error rates than diversified distance-based sampling and random sampling, for all sample sizes. However, comparing diversified distance-based sampling to random sampling, we see in the last row that random sampling has significantly lower error rates with small effect sizes for all sample sizes. The small effect sizes indicate that diversified distance-based sampling can reach nearly the same error rates as random sampling. For the property encoding time, uniform random sampling yields the most accurate performance models. Diversified distance-based sampling produces good results when a very limited number of samples are considered (i.e., t=1) and almost reaches the accuracy of random when the sample sizes increase. 4.1.2 Input Sensitivity: Encoding Size. Random sampling and randomized solver-based sampling perform best to all other sampling strategies or similar to the best sampling for all input videos for sample sizes t=2 and t=3 (except for x264_1). For these sample sizes, most of the error rates of solver-based and diversified distance-based come close to random and randomized solver-based (e.g., x264 and x264_1). For t=1, solver-based sampling leads to lower error rates for most of the inputs. It is important to notice that the results in Table 4 are quite unstable compared to the results in Table 2. For example, random is the best sampling strategy for the input video x264_12, while a randomized solver-based sampling win for the input video x2641, and t-wise sampling win for the input video x26415. Also, the accuracy heavily depends on the sampling size. For example, for the input video x26414, for $t=1$ randomized solver-based sampling yields the most accurate performance models; while for $t=2$ and $t=3$ solver-based outperforms the other sampling strategies. In Table 5, we apply one-sided Mann-Whitney $U$ tests pair-wisely to compare pairs of sampling strategies. The first row shows that t-wise sampling has a significantly lower error rate than distance-based sampling for $t=1$, $t=2$, and $t=3$ with small, large and medium effect sizes, respectively; t-wise sampling has also significantly lower error rates than diversified distance-based for $t=1$. In the second row, we see that solver-based sampling leads to lower error rates than all other sampling strategies for $t=1$ with medium and large effect sizes. Solver-based, randomized solver-based, and diversified distance-based lead to lower error rates than t-wise for $t=2$ and $t=3$; and distance-based for $t=1$, $t=2$ and $t=3$. Overall, distance-based sampling leads to higher or similar error rates than other sampling strategies. Finally, we can notice that on average random leads to significantly lower error rates than all other strategies (except for solver-based sampling for $t=1$). For the property encoding size, random sampling and randomized solver-based sampling outperform all other sampling strategies for most of the input videos with sample sizes $t=2$ and $t=3$; and solver-based sampling outperforms for sample sizes $t=1$. Overall, random, randomized solver-based, solver-based, and diversified distance-based present good and similar accuracy for $t=2$ and $t=3$. Differently from our previous results (for time), there is not a clear winner. ### 4.2 Results RQ2—Robustness We repeated each experiment 100 times for each sampling strategy and sample size, from which we obtained the distribution of mean error rates. We use the Levene’s test to check whether there are significantly different variances between sampling strategies. In cases where we found significant variances, we performed pair-wisely one-sided F-tests. We show the results in Tables 6 and 7. Notice that we excluded t-wise sampling as it is a deterministic sampling and does not lead to any variations. #### 4.2.1 Encoding Time In the second and third rows of Table 6, we can see that randomized solver-based sampling and distance-based sampling have a significantly lower variance than solver-based sampling for $t=1$ and $t=2$; the same also applies for random with $t=1$. In the two last rows, we observe that diversified distance-based and random have a lower variance than solver-based for $t=1$; both sampling have also lower variance than randomized solver-based and distance-based, for $t=2$ and $t=3$. Diversified distance-based has a significantly lower variance than random sampling for all sample sizes. Finally, random has a lower variance than t-wise for $t=1$; and randomized solver-based and distance-based for $t=2$ and $t=3$. For the property encoding time, diversified distance-based sampling is more robust than the other sampling strategies. #### 4.2.2 Encoding Size In the first row of Table 7, we can see that solver-based sampling has a significantly lower variance than distance-based for $t=2$. In the second row, we can see that randomized solver-based sampling has a significantly lower variance than solver-based sampling on all sample sizes. Randomized solver-based sampling has also a significantly lower variance than distance-based sampling for $t=2$ and $t=3$; and diversified distance-based sampling for $t=2$. When it comes to the diversified distance-based sampling, it leads to a significantly lower variance than the other sampling strategies, except for randomized solver-based \((t=2)\) and random. In the last row, we observe that random has the lowest variance. For the property encoding size, uniform random sampling is more robust than the other sampling strategies. 5 DISCUSSION The surprising effectiveness of coverage-based sampling. Why is \(t\)-wise sampling more effective for the input video \(x264\)? For \(x264\), the performance distribution is rather unique compared to the others (see Figure 2b, page 4). To investigate why \(t\)-wise is more effective on this distribution, we analyzed the set of selected features by \(t\)-wise. We aim at understanding which features are frequently included in the sampling and how their frequencies differ from random. We recall that \(t\)-wise sampling is not subject to randomness and is the same for any video and for encoding time or size. We observed that the \(t\)-wise sampling prioritizes the feature \(no\_mbtree\) to false, \(i.e., no\_mbtree\) is most of the time deactivated (it is not the case in random that has a good balance). To better understand the importance of \(no\_mbtree\) for \(x264\), we use (1) a random forest for computing so-called feature importance [7, 13, 37, 45] and (2) polynomial regressions for computing coefficients of options and pair-wise interactions among options [14, 50, 68]. We found that \(no\_mbtree\) has a feature importance of 0.97 (out of 1) for encoding size (see our supplementary website). We also found that the feature \(no\_mbtree\) has a strong negative effect on video \(x264\). As for solver-based sampling, \(t\)-wise sampling relies on clustered zones (see Section 2.2) that luckily cover the most influential options. The clustering mostly contain features with low significance which may explain the worst accuracy results. The surprising effectiveness of solver-based sampling. For the property encoding size, we observe good accuracy predictions for three sampling strategies: random, randomized solver-based, and solver-based. Why solver-based sampling strategies are sometimes more effective than random for size? We further analyzed the set of frequently selected features by these strategies for both experiments of time and size. We observe that the randomized solver-based and solver-based strategies were very effective to capture "clustered" effects of important options for size. In particular, randomized solver-based tend to follow a similar strategy as \(t\)-wise: \(no\_mbtree\) option is most of the time false in the sample set. For \(t=1, no\_mbtree\) option is even always set to false. The employed solver-based sampling strategy relies on a random seed which defines clustering zones (see Section 2.2) that luckily cover the most influential options. We did observe strong deviations of options’ frequencies in the samples of solver-based sampling strategy compared to random (see our supplementary website). For the prediction of encoding time, the clustering mostly contain features with low significance which may explain the worst accuracy results. There are several solvers available and each solver has its own particularities, \(i.e., the way they pick and thus cluster configurations can drastically change. The assumption that a certain sampling is the best one by comparing it to a solver-based sampling is not reliable since solver-based strategies may cluster by accident the (un-)important options to a specific performance property. Our study calls to propose sampling strategies with predictable and documented properties of the frequencies of options in the sample \((e.g., uniform random sampling or distance-based sampling).\) Is there a "dominant" sampling strategy when the system performance is measured over the variation of hardware and the version of the target system? We compare our results with the results obtained in Kaltenecker et al. [25] to encode the same \(x264\) input video Sintel trailer (734 MB). Their measurements were performed on different hardware (Intel Core Q6600 with 4 GB RAM (Ubuntu 14.04)) and over a different version of \(x264\). Diversity distance-based sampling yields the best performance in their settings. In our case, random sampling outperforms diversity distance-based sampling (see Table 8). Thus, we can hypothesize that sampling strategies are also sensitive to different hardware characteristics and software versions \((in addition to targeted performance properties and input videos). Further experiments on different hardware and versions are needed though to confirm this hypothesis. There are several questions that arise from this: To what extent are sampling strategies sensitive to different hardware characteristics and software versions? Are the interactions and influence of configuration options on performance consistent across different software versions? Do we experience the same for different performance properties? Answering RQ1 (accuracy) Is there a "dominant" sampling strategy for the \(x264\) configurable system whatever inputs and targeted quantitative properties? For the property encoding time, there is a dominant sampling strategy \((i.e., uniform random sampling)\) as shown in Kaltenecker et al. [25], and thus the sampling can be reused whatever the input video is. For the property encoding size, although the results are similar around some sampling strategies, they differ in a noticeable way from encoding time and suggest a higher input sensitivity. Overall, random is the state-of-the-art sampling strategy but is not a dominant sampling strategy in all <table> <thead> <tr> <th>Video</th> <th>Coverage-based</th> <th>Solver-based</th> <th>Randomized solver-based</th> <th>Distance-based</th> <th>Diversified distance-based</th> <th>Random</th> </tr> </thead> <tbody> <tr> <td>sinetel_trailer (x264)</td> <td>21.8%</td> <td>12.3%</td> <td>14.4%</td> <td>23.9%</td> <td>21.2%</td> <td>22.0%</td> </tr> <tr> <td>sinetel_trailer (x264)</td> <td>26.2%</td> <td>10.9%</td> <td>19.5%</td> <td>26.2%</td> <td>42.2%</td> <td>35.2%</td> </tr> </tbody> </table> Table 8: Error rates of \(t\)-wise, \((\text{randomized})\) solver-based, \((\text{diversified})\) distance-based, and random sampling for the prediction of encoding time for the Sintel trailer input video (734 MB). The best results are highlighted in bold if the Mann-Whitney \(U\) test reported a significant difference \((p < 0.05)\). cases, i.e., the ranking of dominance changes significantly given different inputs, properties and sample sizes. A possible hypothesis is that individual options and their interactions can be more or less influential depending on input videos, thus explaining the variations’ effect of sampling over the accuracy. Our results pose a new challenge for researchers: Identifying what sampling strategy is the best given the possible factors influencing the configurations’ performances of a system. Answering RQ2 (robustness). We have quantitatively analyzed the effect of a sampling strategy over the prediction variance. Overall, random (for size) and diversified distance-based (for time and size) have higher robustness. We make the observation that uniform random sampling is not necessarily the best choice when robustness should be considered (but it is for accuracy). In practical terms, practitioners may have to find the right balance between the two objectives. As a sweet-spot between accuracy and robustness, diversified distance-based sampling (for time), and either random or randomized solver-based sampling (for size) are the best candidates. We miss however an actionable metric that could take both accuracy and robustness into account. Our recommendations for practitioners are as follows: - uniform random sampling is a very strong baseline whatever the inputs and performance properties. In the absence of specific knowledge, practitioners should rely on this dominant strategy for reaching high accuracy; - in case uniform random sampling is computationally infeasible, distance-based sampling strategies are interesting alternatives; - the use of other sampling strategies does not pay off in terms of prediction accuracy. When robustness is considered as important, uniform random sampling is not the best choice and here we recommend diversified distance-based sampling. The impacts of our results on configuration and performance engineering research are as follows: - as uniform random sampling is effective for learning performance prediction models, additional research effort is worth doing to make it scalable for large instances. Recent results [19, 38, 44, 47] show some improvements, but the question is still open for very large systems (e.g., Linux [1]); - some sampling strategies are surprisingly effective for specific inputs and performance properties. Our insights suggest the existence of specific sampling strategies that could prioritize specific important (interactions between) options. An open issue is to discover them for any input or performance property; - performance measurements with similar distributions may be grouped together to enable the search for dominant sampling strategies; - beating random is possible but highly challenging in all situations; - it is unclear how factors such as the version or the hardware influence the sensitivity of the sampling effectiveness (and how such influence differs from inputs and performance properties); - we warn researchers that the effectiveness of sampling strategies for a given configurable system can be biased by the workload and the performance property used. 6 THREATS TO VALIDITY Despite the effort spent on the replication of the experiments in Kallenecker et al. [25], we describe below some internal and external threats to the validity of this study. Internal Validity. A threat to the internal validity of this study is the selection of the learning algorithm and its parameter settings which may affect the performance of the sampling strategy. We used the state-of-the-art step-wise multiple linear regression algorithm from [52] which has shown promising results in this field [25, 46]. However, we acknowledge that the use of another algorithm may lead to different results. Still, conducting experiments with other algorithms and tuning parameters is an important next step, which is part of our future work. As another internal threat to validity, our results can be subject to measurement bias. While the property encoding size is stable, the measurement of the property encoding time deserves careful attention. To mitigate any measurement bias, we measured the time from all different input videos multiple times and used the average in our learning procedure. Also, we control external factors like the hardware and workload of the machine by using a grid computing infrastructure called IGRIDA. We take care of using the same hardware and mitigate network-related factors. Using a public grid instead of a private cloud allows us to have control of the resources we used for measuring time. To additionally quantify the influence of measurement bias on our results, we also analyzed their Relative Standard Deviation to prove we have a stable set of measurements. To assess the accuracy of the sampling strategies and the effect of different inputs, we used MRE since most of the state-of-the-art works use this metric [46]. As in [25], we compute MRE based on the whole population of all valid configurations, i.e., we include the sample used as training to the testing set for comparing sampling strategies. However, according to several authors [16, 40, 41, 46][51, 58–60] the prediction error rate on new data is the most important measurement, i.e., the error rate should not be computed over the training set t used to build the model. As future work, we plan to explore the effectiveness between four well-established resampling methods [46]: hold-out, cross-validation, bootstrapping, and dynamic sector validation. External Validity. A threat to external validity is related to the used case study and the discussion of the results. Because we rely on a specific system and two performance properties, the results may be subject to this system and properties. However, we focused on a single system to be able at making robust and reliable statements about whether a specific sampling strategy can be used for different inputs and performance measurements. We conducted a discussion with all authors of the paper to avoid any confusing interpretation or misunderstanding of the results. Once we are able to demonstrate evidences to x264, we can then perform such an analysis also over other systems and properties to generalize our findings. 2http://igrida.gforge.inria.fr/ We set our dataset to up seventeen input videos and two properties due to budget restrictions. As with all studies, there is an inherent risk to not generalize our findings for other input videos and performance properties (e.g., energy consumption). While the seventeen videos cover a wide range of different input particularities and provided consistent results across the experiments, this is a preliminary study in this direction and future work should consider additional inputs based on an in-depth qualitative study of video characteristics. 7 CONCLUSION Finding a small sample that represents the important characteristics of the set of all valid configurations of a configurable system is a challenging task. Numerous sampling strategies have been proposed [46] and a recent study [25] have designed an experiment to compare six sampling strategies. However, this study did not investigate whether the strategies developed so far generalize across different inputs and performance properties of the same configurable system. To this end, we replicated this study to investigate the individual effects of 17 input videos on the prediction accuracy of two performance properties. Our results demonstrated that uniform random sampling dominates for most input videos and both performance properties, time and size. There are some cases for which random sampling can be beaten with specific sampling. However, for the other sampling strategies, the prediction accuracy (i.e., the ranking of sampling strategies) can dramatically change based on the input video and sampling size. It has practical implications since users of configurable systems feed different inputs and deal with different definitions of performance. Thus, we warn researchers about the sensitivity of a sampling strategy over workloads and performance properties of a configurable system. This work provides a new view of random sampling based on its effective dominance across different inputs and performance properties. Distance-based sampling strategies are other relevant alternatives. Our replication of the original experiment design is a promising starting point for future studies of other configurable systems, consideration of other influential factors (versions, hardware), and the use of specific (e.g., white-box) sampling strategies. ACKNOWLEDGMENTS This research was funded by the ANR-17-CE25-0010-01 VaryVary project. We thank the anonymous reviewers of ICPE. We also thank Arnaud Blouin, Luc Lesoil, and Gilles Perrouin for their comments on an early draft of this paper. REFERENCES Sampling Effect on Performance Prediction of Configurable Systems: A Case Study (Artifact) ABSTRACT This document contains a stable URL to the artifacts associated with the paper "Sampling Effect on Performance Prediction of Configurable Systems: A Case Study" and provides general instructions to reproduce the presented results and reuse the datasets. 1 STABLE URL WITH THE ARTIFACTS All resources, artifacts, and detailed procedures to replicate the paper results are available at github.com/jualvespereira/ICPE2020. 2 RESOURCES AND ARTIFACTS The README.md file contains a detailed roadmap on the technical requirements of how to set up and run the experiments. It is structured into two parts: (1) performance prediction, and (2) aggregation and visualization of results. 2.1 Performance Prediction To reproduce our results, users must follow the steps below: - Install Docker: https://docs.docker.com/install/ - Download the container: docker pull hmartinirisa/icpe2020:latest (by invoking this script, all required resources are installed, which might take several minutes). - Run the container: sudo docker run -it -v "$(pwd)":/docker hmartinirisa/icpe2020 bash - Go either to the directory Distance-Based_Data_Time or Distance-Based_Data_Size. From the main repository, the user must add the case-study name case_x into the files SPLConquerorExecutor.py and analyzeRuns.py, and add files FeatureModel.xml and measurements.xml at a new folder case_x into the directory Distance-Based_Data_Time/SupplementaryWebsite/MeasuredPerformanceValues (as an example see these files for x264 case study—more information about the format of these files can be also found at github.com/se-passau/SPLConqueror). - The directory SupplementaryWebsite/PerformancePredictions/AllExperiments contains a set of prediction log files with the experiment results (i.e., error rate). Each sampling error rate is computed 100 times using different random seeds for each input video. - To learn how to use the SPL Conqueror, we provide the following commands. To learn more about these commands see github.com/se-passau/SPLConqueror. - `learn <sampling-approach> <sampling-size>:a` file containing a list of all input commands used to run SPL Conqueror. - `out <sampling-approach> <sampling-size>:log` file containing the error rate of applying a sampling strategy with a certain sample size on an input video (the error rate is the last number in the last line before 'Analyse finished'). - `sampledConfigurations <sampling-approach> <sampling-size>:csv` file containing the set of configurations used as input sample to the machine-learning technique. 2.2 Aggregation and Visualization of Results analyzeRuns.py and ErrorRateTableCreator.py are the main scripts to aggregate and visualize the results. analyzeRuns.py collects all error rates from all 100 runs of all case studies in an unique file all_error <sampling-approaches> <sampling-size>:text (see directory PerformancePredictions/AllSummary). Then, the script ErrorRateTableCreator.py reads this file and uses PerformKruskalWallis.8 to generate the visualization data available in Tables 2-8 from the paper (see the output tex-files at the directory latex). - `./analyzeRuns.py <run_directory> <output_directory> - ./ErrorRateTableCreator.py <input_directory> <sampling-approaches> <labels> <output-text` <run_directory> is the directory where all runs of all case studies are stored. <output_directory> and <input_directory> are the directories where the aggregated results should be written to and read from, respectively. <sampling-approaches> and <labels> contain the list of sampling approaches to consider and the labels that should be used in the table. <output-text> contains the directory where the tex-files should be written to. For detailed explanation on these commands see github.com/se-passau/SPLConqueror. <1>For detailed explanation on these commands see github.com/se-passau/SPLConqueror. <2>In the replication process, the generated error rates on this directory must be the same as the provided ones on the directory AllSummary of our GitHub repository for the same sampling approach, sample sizes and random seeds. <3>see these command lines example at our repository (README.md).
{"Source-Url": "https://inria.hal.science/hal-02356290/file/ICPE2020_x264_withAppendix.pdf", "len_cl100k_base": 13628, "olmocr-version": "0.1.50", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 53021, "total-output-tokens": 16554, "length": "2e13", "weborganizer": {"__label__adult": 0.00035858154296875, "__label__art_design": 0.0007491111755371094, "__label__crime_law": 0.00026917457580566406, "__label__education_jobs": 0.0028171539306640625, "__label__entertainment": 0.0001558065414428711, "__label__fashion_beauty": 0.00018155574798583984, "__label__finance_business": 0.00032258033752441406, "__label__food_dining": 0.0002694129943847656, "__label__games": 0.0008969306945800781, "__label__hardware": 0.0010061264038085938, "__label__health": 0.0003528594970703125, "__label__history": 0.00037932395935058594, "__label__home_hobbies": 0.00012022256851196288, "__label__industrial": 0.0003497600555419922, "__label__literature": 0.0005254745483398438, "__label__politics": 0.0002377033233642578, "__label__religion": 0.0004146099090576172, "__label__science_tech": 0.06658935546875, "__label__social_life": 0.00015211105346679688, "__label__software": 0.0213775634765625, "__label__software_dev": 0.90185546875, "__label__sports_fitness": 0.00020265579223632812, "__label__transportation": 0.0003592967987060547, "__label__travel": 0.0001939535140991211}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 67702, 0.05929]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 67702, 0.1897]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 67702, 0.88472]], "google_gemma-3-12b-it_contains_pii": [[0, 1095, false], [1095, 6584, null], [6584, 13383, null], [13383, 18225, null], [18225, 23341, null], [23341, 29461, null], [29461, 35061, null], [35061, 37855, null], [37855, 41652, null], [41652, 48184, null], [48184, 54504, null], [54504, 63444, null], [63444, 63444, null], [63444, 67702, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1095, true], [1095, 6584, null], [6584, 13383, null], [13383, 18225, null], [18225, 23341, null], [23341, 29461, null], [29461, 35061, null], [35061, 37855, null], [37855, 41652, null], [41652, 48184, null], [48184, 54504, null], [54504, 63444, null], [63444, 63444, null], [63444, 67702, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 67702, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 67702, null]], "pdf_page_numbers": [[0, 1095, 1], [1095, 6584, 2], [6584, 13383, 3], [13383, 18225, 4], [18225, 23341, 5], [23341, 29461, 6], [29461, 35061, 7], [35061, 37855, 8], [37855, 41652, 9], [41652, 48184, 10], [48184, 54504, 11], [54504, 63444, 12], [63444, 63444, 13], [63444, 67702, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 67702, 0.17131]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
5a09d105466fad380dbb6e12c7bf2b297b2450b7
[REMOVED]
{"len_cl100k_base": 15284, "olmocr-version": "0.1.50", "pdf-total-pages": 20, "total-fallback-pages": 0, "total-input-tokens": 68865, "total-output-tokens": 17327, "length": "2e13", "weborganizer": {"__label__adult": 0.0005826950073242188, "__label__art_design": 0.0006132125854492188, "__label__crime_law": 0.0019626617431640625, "__label__education_jobs": 0.0021343231201171875, "__label__entertainment": 0.0001825094223022461, "__label__fashion_beauty": 0.0002815723419189453, "__label__finance_business": 0.013336181640625, "__label__food_dining": 0.0005078315734863281, "__label__games": 0.0021038055419921875, "__label__hardware": 0.0027484893798828125, "__label__health": 0.0010042190551757812, "__label__history": 0.0004580020904541016, "__label__home_hobbies": 0.0002460479736328125, "__label__industrial": 0.000965118408203125, "__label__literature": 0.0004274845123291016, "__label__politics": 0.0006399154663085938, "__label__religion": 0.0004553794860839844, "__label__science_tech": 0.180908203125, "__label__social_life": 0.00013327598571777344, "__label__software": 0.08447265625, "__label__software_dev": 0.7041015625, "__label__sports_fitness": 0.000286102294921875, "__label__transportation": 0.0010461807250976562, "__label__travel": 0.0002875328063964844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 67747, 0.02578]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 67747, 0.2051]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 67747, 0.85093]], "google_gemma-3-12b-it_contains_pii": [[0, 3816, false], [3816, 8816, null], [8816, 11474, null], [11474, 16802, null], [16802, 18100, null], [18100, 22413, null], [22413, 25678, null], [25678, 28308, null], [28308, 32701, null], [32701, 37068, null], [37068, 41289, null], [41289, 46182, null], [46182, 50986, null], [50986, 53962, null], [53962, 55514, null], [55514, 58748, null], [58748, 60128, null], [60128, 63025, null], [63025, 65860, null], [65860, 67747, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3816, true], [3816, 8816, null], [8816, 11474, null], [11474, 16802, null], [16802, 18100, null], [18100, 22413, null], [22413, 25678, null], [25678, 28308, null], [28308, 32701, null], [32701, 37068, null], [37068, 41289, null], [41289, 46182, null], [46182, 50986, null], [50986, 53962, null], [53962, 55514, null], [55514, 58748, null], [58748, 60128, null], [60128, 63025, null], [63025, 65860, null], [65860, 67747, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 67747, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 67747, null]], "pdf_page_numbers": [[0, 3816, 1], [3816, 8816, 2], [8816, 11474, 3], [11474, 16802, 4], [16802, 18100, 5], [18100, 22413, 6], [22413, 25678, 7], [25678, 28308, 8], [28308, 32701, 9], [32701, 37068, 10], [37068, 41289, 11], [41289, 46182, 12], [46182, 50986, 13], [50986, 53962, 14], [53962, 55514, 15], [55514, 58748, 16], [58748, 60128, 17], [60128, 63025, 18], [63025, 65860, 19], [65860, 67747, 20]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 67747, 0.12267]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
1d27d744b93f98996cccab6834d0ae57e5eba704
REMOTE COLLABORATION SYSTEM FOR SELECTIVELY LOCKING THE DISPLAY AT REMOTE COMPUTERS TO PREVENT ANNOTATION OF THE DISPLAY BY USERS OF THE REMOTE COMPUTERS Inventors: Catherine M. FitzPatrick, Winfield; Theresa M. Pommier, Westmont; Krista S. Schwartz, Batavia; Allison A. Carleton, Lisle, all of Ill. Assignee: NCR Corporation, Dayton, Ohio Filed: Mar. 19, 1993 Int. Cl. * ............................... G06F 13/00 U.S. Cl. ............................... 395/200.34; 370/260; 370/202 Field of Search .......................... 395/200, 650, 395/700, 275, 200.34, 200.35; 364/200, 514; 370/200; 370/202 References Cited U.S. PATENT DOCUMENTS 4,962,468 10/1990 Beauregard et al. ................. 395/129 5,247,615 9/1993 Mori et al. .................... 395/200 5,293,619 3/1994 Dean ................................. 395/650 5,375,068 12/1994 Palmer et al. ...................... 364/514 5,379,174 1/1995 Ishizaki et al. ....................... 395/155 5,379,374 1/1995 Ishizaki et al. ....................... 395/155 5,392,400 2/1995 Berkowitz et al. ..................... 395/200 5,446,902 8/1995 Islam ................................. 395/700 5,485,570 1/1996 Binsboom et al. ..................... 395/161 5,504,928 4/1996 Cook et al. .......................... 395/882 5,537,548 7/1996 Fin et al. ........................... 395/200.32 FOREIGN PATENT DOCUMENTS COPY OF HOST'S CURSOR LOOKS DIFFERENT ON REMOTES CALCULATOR PROGRAM DOES NOT SEE MOUSE CLICK MODE ANNOTATION COPY OF HOST'S CURSOR MOVES CLICK REMOTE HOST PROGRAM IS RUNNING HERE REMOTE OTHER PUBLICATIONS “In—Synch provides practical”, by Poor, Alfred, PC Week, V4, N38, PC 12(2), Sep. 1987. Newbridge Networks, “Inverse Multiplexing and So Much More”, pp. 1–6. Newbridge Networks, “Product Overview”, pp. 7–32. Newbridge Networks, “4600 Main Street”, pp. 37–41. Newbridge Networks, “3604 Main Street”, pp. 42–45. Newbridge Networks, “3612 Main Street”, pp. 46–49. Newbridge Networks, “3624 Main Street”, pp. 50–53. Newbridge Networks, “8230 Main Street”, pp. 54–57. (List continued on next page.) Primary Examiner—Moustafa M. Meky Attorney, Agent, or Firm—Gregory A. Welte ABSTRACT The invention concerns using multiple computers to hold a conference. Under the invention, an application program can run on a single computer, yet remote participants can issue commands to the program. Remote participants can watch the program operate, because the invention replicates the display window of the running program onto the displays of the remote computers. Any participant can make annotations on the participant’s own computer display. The invention copies the annotations to the displays of the other participants. 7 Claims, 15 Drawing Sheets OTHER PUBLICATIONS Compression Labs, Inc. (CLI), Special Report, Aug. 20, 1993, pp. 66–69. Compression Labs, Inc. (CLI), Letter entitled “Pacific Data Images Uses New Radiance Videoconferencing System to Increase Efficiency of Client Contact”, p. 76. PicturesTel Corporation, “PicturesTel Live PCS 100 Personal Visual Communications Systems” pp. 89–90. ShareVision Technology Inc.; Feb. 1993; “Create A Meeting of the Minds”. GMD; Gesellschaft Für Mathematik Und Datenverarbeitung MBH; Arbeitspapiere der GMD 498; “The Object Oriented Approach In CSCW”, Igor Hawryszkiewycz; Jan. 1991. Northern Telecom; VISIT Video; “VISIT Video Product Highlights”. Campus News, MMR•Summer 1990; “Texaco Contributes to Group Decision Support Services Project”; p. 23. Patricia Seybold’s Office Computing Group, 1988; vol. 11, No. 9; Technology That Supports Meetings “We Can’t Go On Meeting Like This!”, John Kelly; Sep. 1988. Technology; “Software Catches The Team Spirit”, Louis Richman; Reprinted from Fortune, 1987 Time Inc. “Meeting Support—An Emerging Market”; pp. 69, 72–75. Creative Classroom Corp., 1991; ENTENTE Turnkey Electronic Classroom; “It’s Hard To Get Lost In This Classroom”. Info World; vol. 11, Issue 49; Case Tools; Workgroup Computing; IBM Study: PCs Aid In Decision Process; pp. 1, 8. Raymond Panko, Patterns of Organizational Communication; pp. 1–3; Tables: Use of Study Time; pp. 1–4. The University of Arizona, Dept. of Management Information Systems; “Bibliography—Group Decision Support Systems”. FIG. 5 MODE: APPLICATION HOST SCREEN IS COPIED TO REMOTES CALCULATOR BEHAVES NORMALLY CLICK HOST PROGRAM IS RUNNING HERE REMOTE REMOTE FIG. 10 MODE: ANNOTATION DRAW BOX CLICK 1 REMOTE CLICK 2 HOST PROGRAM IS RUNNING HERE REMOTE REMOOTES DRAW BOX ALSO FIG. 11 MODE: APPLICATION PROGRAM RUNNING ON HOST BEHAVES AS THOUGH HOST CLICKED BUTTON HOST SCREEN IS COPIED TO REMOTES CLICK REMOTE REMOTE REMOTE HOST PROGRAM IS RUNNING HERE REMOTE COLLABORATION SYSTEM FOR SELECTIVELY LOCKING THE DISPLAY AT REMOTE COMPUTERS TO PREVENT ANNOTATION OF THE DISPLAY BY USERS OF THE REMOTE COMPUTERS The invention concerns systems which allow multiple users to remotely operate a single computer program. The invention generates a common visual image which is distributed to all computers. The users can make annotations on the common display. When they do, the invention replicates the annotations on all displays. Annotations can be kept private by users, if desired. CROSS-REFERENCE TO RELATED APPLICATIONS This application is related to: Application Ser. No. 08/035,092, entitled “Remote Collaboration System,” filed on same date herewith by Carleton et al. and assigned to the assignee of this application, and now U.S. Pat. No. 5,649,104; Application Ser. No. 08/033,602, entitled “Remote Collaboration System,” filed on same date herewith by Pommier et al. and assigned to the assignee of this application, still pending; and Application Ser. No. 08/034,313, entitled “Remote Collaboration System,” filed on same date herewith by Schwartz et al. and assigned to the assignee of this application, now U.S. Pat. No. 5,608,872. REFERENCE TO A MICROFICHE APPENDIX A microfiche appendix, containing 2 microfiche and 142 total frames is filed herewith. BACKGROUND OF THE INVENTION Modern telephone systems allow multiple parties at different locations to hold a conference. However, telephone conferences do not provide all of the conveniences of a face-to-face conference, where participants all meet at a common table in a meeting room. For example, in a meeting room, participants can view an object of interest, such as a drawing or a product. Such viewing is not possible in a telephone conference. The invention provides a system which duplicates many of the conveniences of a conference where people are physically present, but allows them to be at remote locations. OBJECTS OF THE INVENTION It is an object of the invention to provide an improved electronic conferencing system. It is a further object of the invention to provide a system which allows users to remotely operate a computer program. It is a further object of the invention to provide a system which allows multiple computers to operate a single program residing on one of the computers. It is a further object of the invention to provide a system which allows multiple computer users to view and annotate a common display. SUMMARY OF THE INVENTION In one form of the invention, multiple computers are linked together. The invention causes one window in each computer to display the same image. The invention has four basic modes of operation: 1. Application Mode Any user of any of the three computers in FIG. 1 can issue commands to the Application program. For example, assume the Application program is one which simulates a hand-held calculator. The initial situation is shown in FIG. 2, where each computer display shows the calculator. Assume that the following events occur: - The user of the Host presses the "3" button on the calculator (either by keyboard input, or mouse input, depending upon the design of the calculator program). - In response, each calculator, in its display area, shows a "3". - The user of one Remote presses "+". - The user of the other Remote presses "6". - The user of the Host presses "=". At this point, all calculators will display "9", which is the sum of 3 and 6. The users collectively operated the calculator program, and the display of each shows the result. - The calculator program does not care which users pressed the buttons, nor whether some users pressed no buttons, provided a legal sequence of buttons was received. (It is assumed that the users are cooperative, and that no users try to sabotage operation of the calculator.) 2. Annotation Mode Any user can draw on the user's own, local, display, using drawing tools similar to those found in a "paint" program. The user can draw boxes, circles, arcs, text, ellipses, and so on. The user can also erase items on the display. - The invention can replicate the user's annotations on all other displays, so that all users view similar displays. - However, the displays could be different, because of the following factors: - (A) Different display monitors have different properties, such as resolution and color capability. - (B) Different display protocols (EGA, VGA, etc.) represent graphics images differently, and have different color capabilities. - (C) Different GUIs, or different versions of the same GUI, may have different display conventions. Different computers in FIG. 1 could run the different GUIs. - (D) Some users have changed the size of the window in which their calculator is displayed, causing a deviation in scaling. These differences can cause differences in the appearance of the displayed images, relative to each other, but the basic content of all displays should be the same. To accommodate size differences, the invention draws to different scales as appropriate. 3. Local Annotation Mode A user can annotate the local display, but the annotations are kept private, and no other user can see the annotations. 4. View Mode No users can annotate, nor can they issue commands. However, an action resembling annotation can be taken. Users can move their cursors, and others will see the movement, allowing remote pointing. View Mode is useful in one embodiment, wherein, for example, Annotate Mode is in force, but a specific user's mode is designated as View. In this embodiment, all users can annotate, but the "View" user can only watch, and cannot annotate. Explanation of Individual Nodes FIGS. 3-14 will illustrate the different modes, by way of example, using the calculator program. Assume that the user of the host computer draws a box over the calculator. (The box is shown overly large, for emphasis. It is preferred that the box not extend beyond the calculator itself.) The invention replicates the box on the remote computers. (The box is drawn using annotation tools, which are not shown.) In terms of FIG. 15, INPUT ROUTER directs the logic flow to ANNOTATION. ANNOTATION calls the proper GDI functions to draw the box. Also, ANNOTATION sends “annotation messages” to CONNECTION API, which delivers the annotation messages to the Remotes. ANNOTATION in FIG. 15A receives the annotation messages. This ANNOTATION block represents the logic executed at each remote computer. This ANNOTATION calls the proper GDI functions, via the block GDI. “GDI” is an acronym for Graphical Device Interface. “GDI functions” are small programs, contained in a larger program of the GUI called GDLEXE. A GDI function, when called, draws a specific graphic image, such as a circle, box, or text, based on subsequent input from the user. Other GDI functions perform other tasks, such as selecting pen widths. FIG. 5 Host Runs Application Program Mode is “Application” User Input is at Host Computer User Attempts to Use Calculator The user of the Host moves the cursor over the calculator key “3” and clicks the mouse. The GUI generates a mouse message and places it into the queue. The invention reads the mouse message, and passes the message to the Application program (i.e., the calculator program), which responds by (1) showing that the key “3” is depressed and (2) drawing the numeral “3” in the calculator’s display, using GDI calls. The Application program also records the fact that the user enters a “3,” for its own internal operations. The invention also intercepts the GDI calls made by the Application program in drawing the “3” in the calculator, and in drawing the depressed “3” button. The invention notifies the other computers of the GDI calls. The other computers replicate the Host display, by executing the same GDI functions. Greater detail concerning this GDI interception is given later, in the section entitled “General Considerations.” Thus, all users simultaneously see the user of the Host operate the calculator. (The action is not exactly simultaneous, because extremely short delays are involved. However, a human probably could not detect the delays if the Host and the Remote were operating side-by-side.) In terms of FIG. 15, the INPUT ROUTER recognizes that the mouse messages should be directed to the Application program, and directs the logic flow to APPLICATION (i.e., the calculator program). APPLICATION (1) draws a depressed “3” key and (2) writes the numeral “3” in the calculator’s display, by calling appropriate GDI functions. However, the invention, via GDI CAPTURE in FIG. 15, captures the Application program’s GDI calls, before they are executed. The invention does two things with the captured calls. One, it notifies the other computers of these calls, via the block CONNECTION API. This action leads to block CAPTURED GDI DISPLAY in FIG. 15A, which causes each Remote to execute the same GDI functions, as indicated by block GDI. Two, the invention allows the GDI functions, called by the Application program, to be executed at the host, via the block GDI in FIG. 15. Therefore, the invention captures GDI function calls made by the Application Program. The invention notifies the Remote computers of the captured calls, so that the Remotes can duplicate them. The invention allows the captured calls to be executed as intended on the Host. FIG. 6 Host Runs Application Program Mode is “Local Annotation” User Input is at Host Computer User Attempts to Operate Calculator Assume that in Annotation Mode, there is no default annotation tool given to the user. Under this assumption, if the user moves the cursor to a calculator button, and tries to “press” the button, the INPUT ROUTER in FIG. 15 passes the mouse message to the ANNOTATION block. Since the mouse click is not part of a valid annotation input sequence (no tool was selected), ANNOTATION draws nothing. Further, the Remote computers do not show the movement of the cursor corresponding to the Host computer’s mouse, as indicated, because line 5 in FIG. 15 does not send any Annotation Messages to the other computers when Local Annotation is in force. Further still, the calculator button is not re-drawn as a depressed button on the Host display, in response to the attempt to press it, because APPLICATION did not receive the mouse message. APPLICATION is responsible for drawing depressed calculator buttons. If a default annotation is assigned to the user in Local Annotation Mode, the user’s mouse click would initiate drawing by that tool. When the user realized the mistake, the user would terminate the drawing, in a known manner. FIG. 7 Host Runs Application Program Mode is “Local Annotation” User Input is at Host Computer User Attempts to Annotate Calculator Under these conditions, the INPUT ROUTER in FIG. 15 recognizes a valid attempt to perform annotation, as by drawing a box. The INPUT ROUTER directs the logic flow to the ANNOTATION block, which calls the proper GDI functions for drawing the annotation, namely, a box, as shown in FIG. 7. However, because the annotation is local, no boxes are drawn on remote computers, as indicated in FIG. 7. No data is sent along data path 5 in FIG. 15. FIG. 8 Host Runs Application Program Mode is “View” User Input is at Host Computer User Attempts to Operate Calculator As FIG. 8 indicates, the mouse click is ignored, and nothing happens at the Remotes. In FIG. 15, the INPUT ROUTER reads the mouse message, but blocks it from APPLICATION, because the current mode is “view.” FIG. 9 Host Runs Application Program Mode is “ANNOTATION” User Input is at Remote Computer User Attempts to Operate Calculator Assume that the user moves the mouse cursor over a calculator button and clicks the mouse. The mouse click is ignored. The other computers (Host and the other Remote) show the motion of the user’s cursor, but nothing else, because no tool has been selected. In FIG. 15A, the INPUT ROUTER blocks the mouse message from reaching APPLICATION. The logic is directed to ANNOTATION, which draws a cursor on the user’s Remote display, via block GDI. ANNOTATION also sends data to CONNECTION API, which directs the logic to ANNOTATION in FIG. 15. This ANNOTATION represents the annotation logic present on the two other computers: the Host and the other Remote. These ANNOTATION blocks draw cursors corresponding to the users cursor, at corresponding positions, via the GDI block in FIG. 15, which represents GDI function calls. The Host can use one tool, such as a box-drawing tool, while a Remote can use a different tool, such as a circle-drawing tool. FIG. 10 Host Runs Application Program Mode is “ANNOTATION” User Input is at Remote Computer User Attempts to Annotate Calculator Assume that the annotation is a box. A box is drawn on all displays. In FIG. 15A, the INPUT ROUTER at the user’s Remote directs the mouse messages to the block ANNOTATION. ANNOTATION does two things. One, it calls the proper GDI functions to perform the annotation, namely, drawing the box. Two, ANNOTATION sends annotation messages to CONNECTION API, which delivers the annotation messages to the other computers. However, one of these is the Host, and the other is a Remote. The logic at the Host reaches ANNOTATION in FIG. 15, and the logic at the other Remote reaches ANNOTATION in FIG. 15A. Both of these ANNOTATION blocks cause the proper GDI functions to be called, to draw an annotation corresponding to the user’s annotation. However, in the Host, logic path 5 is not taken at this time, because it is not necessary to replicate the Host’s annotations at other computers. FIG. 11 Host Runs Application Program Mode is “APPLICATION” User Input is at Remote Computer User Attempts to Operate Calculator The reader is reminded that the calculator program is loaded only on the host, while a Remote user wishes to operate it. The Remote user’s INPUT ROUTER in FIG. 15A routes the mouse messages to CONNECTION API. The Host receives these messages, which are delivered to the Host’s INPUT ROUTER in FIG. 15. The Host’s INPUT ROUTER directs the messages to the block APPLICATION (i.e., to the Application program, namely, the calculator program), which does two important things. The calculator program treats the messages as though they were issued by the Host’s mouse, even though a Remote mouse caused them. The calculator program responds in its usual way, which includes (1) showing a depressed calculator button “3”, (2) writing the numeral “3” in the calculator’s display, and (3) performing its own internal computations when it learns that the user entered data (namely, the “3”). However, before the calculator program can execute (1) and (2) in the previous paragraph, the Invention first captures the GDI functions which the calculator program calls. This capture is illustrated in block GDI CAPTURE in FIG. 15. During this capture, the Invention, in effect, does two things. One, it sends these GDI functions to CONNECTION API (for the other computers to use). At the user’s Remote, CONNECTION API in FIG. 15A directs the GDI functions to CAPTURED GDI DISPLAY, which replicates the Host’s display. Two, it causes the GDI functions to be executed at the Host (via block GDI in FIG. 15). Therefore, the general sequence of events is the following: The Remote user attempts to press a calculator button. The invention running on the Remote detects this attempt, and sends data to the calculator program running on the host. The data takes the form of messages, which the calculator program “thinks” come from the Host’s mouse. The calculator program performs as usual, and draws images on the Host display, via GDI calls. The invention captures the GDI calls, and draws images on the remote display, as if the GDI calls were generated by the same hardware as the Host. The Remotes replicate the Host’s window. The Remote user thus can remotely operate the calculator program running on the Host. Summarizing in a different way: The invention generates mouse messages at the Host, based on mouse messages at the Remote. The calculator program (running on the Host) responds to the mouse messages as though they were generated at the Host. The invention intercepts the GDI calls made by the calculator program, and executes the same GDI calls at the Remote, thereby replicating the Host’s display at the Remote. FIG. 12 Host Runs Application Program Mode is “Local Annotation” User Input is at Remote Computer User Attempts to Operate Calculator The user’s mouse click is ignored. Nothing appears on the other displays in response to the mouse movement, because of failure to select a tool. FIG. 13 Host Runs Application Program Mode is “Local Annotation” User Input is at Remote Computer User Attempts to Annotate Calculator The annotation is drawn on the user’s display, as indicated. No annotation occurs on the other displays. FIG. 14 Host Runs Application Program Mode is “View” User Input is at Remote Computer User Attempts to Operate Calculator As indicated, the mouse cursor moves at the user’s display, but the mouse click is ignored. Further, the other two displays do not show the movement of the user’s mouse cursor. General Considerations 1. Different Programs Draw Different Parts of Overall Display. The displays are drawn using GDI functions. However, different parts of a display are drawn by different programs. Despite the fact that all these drawing operations are undertaken using GDI functions, GDI functions are not the exclusive medium of communication between computers for replicating the displays. Annotation Involves One Type of Data Transfer Among Computers Drawing by an Application Program Involves Another Type. For example, when a user performs annotation, the user’s mouse messages are replicated, as Messages, at the other computers, via path 5 in Fig. 15. These replicated messages then cause the respective Annotation blocks (at the other computers) to issue the proper GDI calls for drawing the annotation. That is, GDI calls are not sent directly from the user performing the annotation to the other computers. In contrast, when an application program causes a graphic image to be drawn on a display, the invention intercepts GDI calls (via GDI CAPTURE in Fig. 15) and causes the GDI calls to be replicated on the other computers. Reason for Difference A major reason for the two different procedures (replicating mouse messages and replicating GDI calls) is that annotations are stored in memory at different locations than the display information. That is, returning to the calculator of Fig. 2, the application program stores the image of the calculator in the following general way. Annotation data is stored by the invention; Application program data is stored by the Application program (at the host). Each image of a key is stored as data from which a GDI function can draw the key. The data includes information such as position, size, color, and so on. Each key includes an associated number. The number can be stored as a text character, with information as to position, size, font type, and so on. Annotation data is stored at a different location, but in the same general way. If either the annotation or the Application program needs bitmaps, the bitmaps are stored in a conventional, known manner, by the GUI. The invention combines the annotation images with the Application’s images by the known technique of masking. That is, the invention, at a Remote, plays (or executes) the received GDI functions into a bitmap. The invention plays the received annotation information into a different bitmap. The two bitmaps are masked together. The annotation data is kept separate from the application data so that, for example, a user can see an Application image, but without annotations. Alternately, a user can save annotation data alone, or save an annotated display. As another example, keeping the annotation data separate facilitates drawing a display having no annotation data. If the annotation data were intermingled with the calculator image data, elimination of the annotation data would be difficult, if not impossible. If GDI calls were transmitted exclusively (i.e., no message replication were undertaken), then extra effort would be required to construct annotation data for separate storage. 2. GDI Interception, or Capture. GDI interception can be understood as follows. A. On start-up, the invention replaces the first five bytes of each GDI function with a JUMP instruction to a particular program, namely, Trap.GDI. B. Trap.GDI gets the parameters for the desired graphics image (e.g., in the case of a box, the locations of the two diagonal corners) and calls the sub-program PkgDispCall. Trap.GDI also replaces the first five bytes. C. PkgDispCall accepts the parameters from Trap.GDI and generates an object structure. This object structure is a block of data containing everything necessary for the other computers to draw the box. For example, the object structure contains information as to size and position of the box. Further, the GUI draws images within a “context.” The context includes things such as pen width, color, and other features. The invention tracks the contexts of the individual computers. If the context of the box drawn is different from the contexts of the remote computers, PkgDispCall includes data necessary for the other computers to create the correct contexts. D. The object structure is shipped to the other computers, which then execute the same GDI functions. E. The invention executes the original GDI functions. 3. Displays are not Transferred in entirety. The displays are not replicated bit-by-bit. For example, the image of the calculator in Fig. 2 could be transferred between computers in bitwise fashion. If the calculator occupied a space of 200x300 pixels, then information regarding 60,000 (i.e., 200x300) pixels must be sent. Instead, the particular calculator image shown in Fig. 2 is treated as eighteen rectangles, plus a text character for each of sixteen of the rectangles, giving a total of 34 objects. Each object requires parameters, such as size and position. The number of parameters is small, in the range of three to ten. Assuming ten parameters, then 340 pieces of data must be sent. Of course, the size of each piece depends on many factors, but a small number of bytes for each piece may be assumed. Therefore, the invention reduces the 60,000 pieces of data needed for bitwise replication to 340 pieces maximum for object replication. Of course, some objects may take the form of bitmaps, and must be sent bit-by-bit. However, in general, bitmaps are expected to be rare. Further, it is expected that, in general, bitmaps, when sent, need be sent only once. Further, the object data is compressed when possible. That is, every transmission between computers is of compressed data, when possible. Compression is known in the art. 4. Types of Data Link. Communication among computers can take several forms. Commercially available networks, local and wide area, can be used. Commercially available ISDN telephone service, provided by local telephone companies, can be used. Modem communication can be used. 5. Prior Art Message Detection. There are commercially available packages which detect messages generated by the GUI in response to an input device. One such package is WINSIGHT, available from Borland International. However, it is believed that such packages do not inform remote computers of the messages. 6. Alternate GDI Capture. An alternate approach to the graphics capture described above is the following. The system-provided GDI is replaced by a separate procedure which processes GDI calls before calling the actual system GDI. The system GDI name is changed to prevent confusion. between the two modules. The same technique is also used on USR.EXE to also capture GDI calls made through system-provided modules. 7. More than One Computer can Run Application Programs. A given computer can act as a Host for one program and a Remote for another. For example, one computer can run a word processing program. Another computer can run a CAD drawing program. Each is Host for its respective program. Since the invention’s software on each computer is identical, or substantially identical, all users can run either the word processing program or the CAD program, in the manner described above. 8. “Real” Cursors and “Pseudo” Cursors. There are two types of “cursor.” Each GUI generates its own “real” cursor. The real cursor is not generated by GDI functions, but by an independent function in the GUI. The reader can view the cursor as a bitmap which the GUI moves in response to mouse motion. In addition to the real cursor, which is controlled by the local mouse, the invention generates a “pseudo” cursor for each remote participant. The pseudo cursors are generated using GDI functions. Sometimes a real cursor changes shape as the cursor moves. For example, it can take the form of an arrow when lying on a tool bar, and then change to a hand when lying on a client area. Sometimes this change is under the control of the Application program. Therefore, if a Remote user is controlling an Application program running on a Host machine (as in FIG. 11), the Application program may change the cursor on the Host machine, but without using GDI calls. Consequently, the GDI capture of FIGS. 15 and 15A will be ineffective to replicate the changed on the Remote display. To confront this problem, the invention watches for the functions which change the real cursor (eg, the SetCursor command). The invention replicates the cursor change on the Remote computer. One way is to execute the same SetCursor command. An alternate approach would be to change the Remote cursor by executing a proper sequence of GDI calls, or to draw a bitmap, when the Host cursor changes. 9. Entire Display not Replicated. The invention only replicates windows which the user of a display identifies. That is, the user can keep a workspace, such as a notepad, private during a conference. GDI calls use a task handle. If the task handle does not refer to a shared item, the GDI calls are not shared. 10. Computer Code. Computer code in microfiche form is attached. A description of files contained therein is contained in the following Table. (See the end of tgapp.c for a description of how invention starts up, and the order in which things are initialized.) TABLE (about.c Relevant to About Dialog Box. about.h - Contains named identifiers for Annotation Messages. - Contains Limits on the maximum number of machines that may share, and the maximum number of Applications they may jointly share. - Contains definitions of structures that hold data for Annotation Messages and information about Shared Applications. - Contains some prototypes of functions from sautil.cpp and draw.cpp 5 amtb.c Contains code which operates the Annotation ToolBar. amtb.h - Contains named identifiers for parts of Annotation ToolBar and a few function prototypes for amtb.c. amvid.c - Contains functions relating to when video is placed in the annotations toolbar. amvid.h - Contains named identifiers for amvid.c. audio.c - Contains a function to update the Audio Button. audio.h - Contains function prototypes for audio.c. bitmap.h - Contains function prototypes for all sorts of routines to do all sorts of things to Bitmaps. cache.c - Relates to interception and caching CreateDC. dirutil.c - Contains functions to support an ISDN audio/video phone directory. dirutil.h - Contains named identifiers and function prototypes for dirutil.c. disp.c - Contains a list of GDI functions to intercept and the Package functions to which they correspond. disp.h - Contains functions to install and remove the changes to GDI required to do the intercepting. disp.h - Contains a function to look up the Package function corresponding to the intercepted functions. disp.h - Contains the Package functions themselves including a couple that don’t correspond to GDI intercepts, and one which corresponds to the WinExec function of the USER module, which is also intercepted. draw.cpp - Contains functions to manipulate, save, and restore the Bitmaps which represent Application Windows and Annotation Windows. draw.h - Contains functions to Compose the Annotations over the Screen image. dirutil.c - Contains functions to update the User’s Annotation Tool choices and update them on the Remote PCs as well. dirutil.h - Contains functions to actually do the drawing on the Annotation Bitmaps (including drawing text). editdir.c - Contains functions to Package and send arbitrary data to Remote Users. eddir.h - Contains functions for editing the entries in the ISDN phone directory maintained in dirutil.c. eddir.h - Contains named identifiers and function prototypes for editdir.c. edmu.h - Contains named identifiers for the Menu used by editdir.c. filetrans.c - Contains functions to support File Transfer over TeleMedia, which handles communication among computers. filetrans.h - Contains named identifiers and function prototypes for filetrans.c. fsm.h - Contains named identifiers and function prototypes to support the Phone Client Finite State Machine. fsmu.h Contains named identifiers for the File Transfer Menu. ftprog.c Contains functions to support the File Transfer Progress Dialog Box. ftprog.h Contains named identifiers and function prototypes for ftprog.c. ftset.c Contains functions to support the File Transfer Settings Dialog Box. ftset.h Contains named identifiers and function prototypes for ftset.c. gdiobj.h Contains definitions of structures to hold information about GDI objects, notably size information. gdiobjp.c Contains functions to collect the parts of GDI objects into one place and determine the size of the result. gdiobjp.h Contains functions to produce actual GDI objects in memory from their packaged descriptions, and return Handles to those objects. Contains some functions which do maintenance of DCs (Device Contexts) in relation to the creation of other GDI objects. gdiobjp.cy Declarations of functions in gdiobjp.c. globals.c Contains declarations of some variables related to GDI capture and Message capture. Contains extern declarations of the others. globals.h Extern declarations of the variables in globals.c. iconapp.c Contains functions for creating and manipulating Icons. iconapp.h Contains named identifiers and function prototypes for iconapp.h. iconwin.c This contains a Window Procedure for a Dialog Box related to Icons. incoming.c Contains functions to support Incoming Call Dialog Box. incoming.h Contains named identifiers and function prototypes for incoming.c. inputrtr.cpp Contains structures concerning cursors. Contains functions to initialize Input Router Library. Contains functions for intercepting Messages. Contains functions for simulating Mouse and Key events. Contains Window Procedures for the Input Router and the Shared Application Window (which echoes the real Application’s appearance). Contains functions to handle Annotation Messages, and User Input Messages destined for a Remote Application. Contains functions to translate coordinates from the Host to Remote. intercept.asm Contains TRAPGDI and TRAPCACHE which handle identifying the address of the call which was intercepted and which Package function we want to call as a result of that. isdnapp.c Contains functions to support ISDN calls, though most are stubs at this point. line.c Contains functions to support a Dialog Box for selecting Line characteristics. line.h Contains named identifiers and function prototypes for line.c. linklist.c Maintain linked lists of information structures for intercepted calls and tasks corresponding to the Applications we are sharing. mcs_ctrl.h Contains named identifiers and function prototypes related to MCS Control. newdir.c A Window Procedure for a Dialog Box. The identifiers in newdir.h suggest this is to add a new entry to the ISDN directory. newdir.h Contains named identifiers and function prototypes for newdir.c. perm.c Contains functions (Window Procedure) related to a Dialog Box for setting Shared Application Permissions. perm.h Contains named identifiers and function prototypes for perm.c. phone.c Contains functions to support the Phone Dialog Box, including the Window Procedure. phone.h Contains named identifiers and function prototypes for phone.c. phmenu.h Contains named identifiers for use with Phone Menu. phonepref.c Contains functions to support Phone Preferences Dialog Box. phonep pref.h Contains named identifiers and function prototypes for phonep pref.c. pkg.c Contains functions which manage the Package Queue and take care of sending data from it to remote machines. pkgtags.h Contains named identifiers for everything that can be sent in a Package to a remote PC. proto.h Contains function prototypes for all publicly accessible functions in modules tmnapt.c, gdiobjp.c, pkg.c, linklist.c, intercept.asm, disp.c, cache.c, and some Undocumented Windows functions. sautif.cpp Contains functions to get the index of a given Application in our array of shared Applications, add such an Application to the array, and do the same thing for Annotation Bitmaps and Masks. Contains functions for examining and changing Permissions and Modes of Host and Remote Users. Contains functions for changing which Application is the current one. Contains functions for adjusting the size and position of Remote Shared Application Windows. scroll.h Contains named identifiers and structures supporting Video Sliders (Red, Green, Blue, Bright, Contrast). sfset.c Contains functions to support SFSet Dialog Box (Shared File Settings). sfset.h Contains named identifiers and function prototypes for sfset.c. televid.c Contains functions to support various aspects of Video transmission among other things. At least one function is a Dialog Box Window Procedure. televid.h Contains named identifiers and function prototypes for televid.c. telegraf.c Contains functions to Initialize TeleGraphics, handle Messages meant for it, and add a Shareable Application. telegraf.h Contains named identifiers for telegraf.c. telegraf.h Contains named identifiers for all TeleGraphics Messages. Contains prototypes for some functions in inputtrc.c, sautil.cpp, and draw.cpp. tgapp.c Contains functions to Initialize a Shared Application and add it to the list of Shared Applications. Contains functions to add an Annotation Channel, Initiate GDI capture. tgapp.h Contains named identifiers, structure definitions and function prototypes for tgapp.c. tgini.h Contains named strings for interpreting the TeleGraphics INI file. tgmmu.h Contains named identifiers for TeleGraphics Menu. tm3d.c Contains functions to create a 3D box, a 3D line, and a "slab". tm_mcs.c This is the TeleMedia Manager and MCS Controller. There is some explanation in the file of their usage. Contains Window Procedures for MCS and some Channel related functions. tmapp.c Contains functions to support DDE things related to MCS, File Transfer, and WhiteBoards. tmapp.h Contains function prototypes for tmapp.c. tmcap.c Contains functions to capture Messages going through CallWndProc and GetMessage. tmcap.h Declarations of functions in tmcap.c. tmcaptp.h Contains definitions of structures for storing the parameters of all GDI and USER intercepted functions. Contains definition of structures related to captured Window Procedure calls, information about Tasks and Calls, and Packaging. tmmgsf.h Contains named Messages for TeleMedia. tmplay.c Contains functions to decode Packaged GDI calls and Play them through our local GDI. tmplay.h Declarations of functions in tmplay.c. tmscreen.c Contains functions which support the TeleMedia screen and controls (Buttons, etc.). tmutil.c Contains some minor functions client Applications use to communicate with the user interface (Error Functions). tmutil.h Contains named identifiers, named Messages, and function prototypes for tmutil.c. trms.h Contains several function prototypes. trmsrat.e Contains functions to support a Dialog Box to modify the Transfer Rate. trmsrate.h Contains named identifiers and function prototypes for trmsrate.c. tvbottom.c Contains functions to support a Dialog Box whose concern relates to TeleVideo. tvbottom.h Contains named identifiers and function prototypes for tvbottom.c. tvmmu.h Contains named identifiers for TeleVideo Menu. tvpanel.c Contains functions to support a Dialog Box which handles the video controls (Contrast, Brightness, etc.). tvpanel.h Contains named identifiers and function prototypes for tvpanel.c. tvvideo.c Contains a Dialog Box Procedure for TeleVideo which seems concerned with Video calls, transfers, and captures. Contains subsidiary functions that handle the above mentioned captures, transfers, and other necessary transactions. tvvideo.h Contains a couple of variable declarations and function prototypes for tvvideo.c. tvvideo.h Contains definitions of structures for maintaining information relevant to storing temporary GDI objects along with those actual objects. ump.c Contains main program of TeleMedia, and its Window Procedure. ump.h Contains named identifiers and function prototypes for umb.c. umpmmu.h Contains named identifiers for the umb Menu. userpref.c Contains functions for a Dialog Box concerned with User Preferences. userpref.h Contains named identifiers, variable declarations, and function prototypes for userpref.c. victcall.c Contains functions for a Dialog Box for making Video Calls. victcall.h Contains named identifiers, variable declarations, and function prototypes for victcall.c. videonum.c Contains code for a Dialog Box relating to modifying the permissions of video channels. videonum.h Contains named identifiers, variable declarations, and function prototypes for videonum.c. vidmsrm.f Contains named identifiers and function prototypes for the TeleVideo Finite State Machine. vidset.c Contains functions to support a Dialog Box to modify speech quality and resolution of video. vidset.h Contains named identifiers, variable declarations, and function prototypes for vidset.c. vidwin.c Contains functions for opening a Video Window, Playing video into it, capturing frames, adjusting the color, contrast, and such, and adjusting the size of the window. vidwin.h Contains named identifiers and function prototypes for vidwin.c. Numerous substitutions and modifications can be undertaken without departing from the true spirit and scope of the invention. What is desired to be secured by Letters Patent is the invention as defined in the following claims. What is claimed is: 1. A computer system, comprising: a) a host computer and one or more remote computers, all of which have displays, and wherein a single application program runs, which is shared by the computers; b) means for providing communication among the computers; c) means for replicating the display of the host computer on the displays of the remote computers; and d) means for selectively locking the display at the remote computers to prevent annotation of the display by users of the remote computers, and thereby prevent interaction in real time. 2. A computer system, comprising: a) a host computer and one or more remote computers, all of which have displays, and wherein a single application program runs, which is shared by the computers; b) means for providing communication among the computers; c) means for replicating the display of the host computer on the displays of the remote computers; d) means for selectively permitting the remote computers to effectively pointing only at a selected section of the display without permitting annotation of the display; and e) means for selectively preventing annotation of the display by users of the remote computers, and thereby for preventing interaction in real time. 3. A computer system, comprising: a) a host computer and one or more remote computers, all of which have displays, and wherein a single application program runs, which is shared by the computers; b) means for providing communication among the computers; c) means for replicating the display of the host computer on the displays of the remote computers; d) means for providing annotation of the display by the host computer and the remote computers; and e) means for selectively permitting the annotations to be saved separately from the display without annotations or saved together with the display. 4. A computer system, comprising: a) a host computer and one or more remote computers, all of which have displays, and wherein a single application program runs, which is shared by the computers; b) means for providing communication among the computers; c) means for replicating the display of the host computer on the displays of the remote computers; d) means for providing annotation of the display by the host computer and the remote computers; e) means for combining annotations and a display image by masking; and f) means for selectively locking the display at the remote computers to prevent annotation of the display by users of the remote computers, and thereby prevent interaction in real time. 5. A computer system, comprising: a) a host computer and remote computers, all of which have displays, and wherein a single application program runs, which is shared by the computers; b) means for providing communication among the computers; c) means for replicating the display of the host computer on the displays of the remote computers; d) means for applying a first cursor to certain annotations by a host computer or remote computers different to a local remote computer; e) means for applying a second cursor to control annotations locally at each remote computer; and f) means for selectively locking the display at the remote computers to prevent annotation of the display by users of the remote computers, and thereby prevent interaction in real time. 6. A computer system as claimed in claim 5 including means for selectively preventing annotation of the display by users of the remote computers, and thereby for preventing interaction in real time. 7. A computer system, comprising: a) a host computer and one or more remote computers, all of which have displays, and wherein a single application program runs, which is shared by the computers; b) means for providing communication among the computers; c) means for replicating the display of the host computer on the displays of the remote computers; d) means for selectively locking the display at the remote computers to prevent annotation of the display by users of the remote computers, and thereby prevent interaction in real time; e) means for selectively permitting the remote computers to affect pointing at a selected section of the display without permitting annotation of the display; f) means for selectively permitting the annotations to be saved separately from the display without annotations; and g) means for applying a first cursor to certain annotations by a host computer or remote computers different to a local remote computer, and means for applying a second cursor to control the annotations locally at each remote computer.
{"Source-Url": "https://patentimages.storage.googleapis.com/c4/6b/45/35a17ffb0dec07/US5835713.pdf", "len_cl100k_base": 10448, "olmocr-version": "0.1.50", "pdf-total-pages": 26, "total-fallback-pages": 0, "total-input-tokens": 30590, "total-output-tokens": 13984, "length": "2e13", "weborganizer": {"__label__adult": 0.0005865097045898438, "__label__art_design": 0.000918865203857422, "__label__crime_law": 0.0015840530395507812, "__label__education_jobs": 0.0036678314208984375, "__label__entertainment": 0.0002491474151611328, "__label__fashion_beauty": 0.0002429485321044922, "__label__finance_business": 0.003631591796875, "__label__food_dining": 0.0003643035888671875, "__label__games": 0.0017404556274414062, "__label__hardware": 0.0657958984375, "__label__health": 0.0004119873046875, "__label__history": 0.0004673004150390625, "__label__home_hobbies": 0.0001914501190185547, "__label__industrial": 0.0015859603881835938, "__label__literature": 0.0004363059997558594, "__label__politics": 0.00031828880310058594, "__label__religion": 0.0004756450653076172, "__label__science_tech": 0.137939453125, "__label__social_life": 8.183717727661133e-05, "__label__software": 0.320556640625, "__label__software_dev": 0.45751953125, "__label__sports_fitness": 0.0002081394195556641, "__label__transportation": 0.0007276535034179688, "__label__travel": 0.00019633769989013672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 53703, 0.03064]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 53703, 0.4716]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 53703, 0.88007]], "google_gemma-3-12b-it_contains_pii": [[0, 3791, false], [3791, 9408, null], [9408, 9408, null], [9408, 9408, null], [9408, 9408, null], [9408, 9408, null], [9408, 9550, null], [9550, 9550, null], [9550, 9550, null], [9550, 9550, null], [9550, 9550, null], [9550, 9674, null], [9674, 9860, null], [9860, 9860, null], [9860, 9860, null], [9860, 9860, null], [9860, 9860, null], [9860, 12498, null], [12498, 15691, null], [15691, 21767, null], [21767, 27440, null], [27440, 34069, null], [34069, 39518, null], [39518, 44102, null], [44102, 48267, null], [48267, 53703, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3791, true], [3791, 9408, null], [9408, 9408, null], [9408, 9408, null], [9408, 9408, null], [9408, 9408, null], [9408, 9550, null], [9550, 9550, null], [9550, 9550, null], [9550, 9550, null], [9550, 9550, null], [9550, 9674, null], [9674, 9860, null], [9860, 9860, null], [9860, 9860, null], [9860, 9860, null], [9860, 9860, null], [9860, 12498, null], [12498, 15691, null], [15691, 21767, null], [21767, 27440, null], [27440, 34069, null], [34069, 39518, null], [39518, 44102, null], [44102, 48267, null], [48267, 53703, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 53703, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 53703, null]], "pdf_page_numbers": [[0, 3791, 1], [3791, 9408, 2], [9408, 9408, 3], [9408, 9408, 4], [9408, 9408, 5], [9408, 9408, 6], [9408, 9550, 7], [9550, 9550, 8], [9550, 9550, 9], [9550, 9550, 10], [9550, 9550, 11], [9550, 9674, 12], [9674, 9860, 13], [9860, 9860, 14], [9860, 9860, 15], [9860, 9860, 16], [9860, 9860, 17], [9860, 12498, 18], [12498, 15691, 19], [15691, 21767, 20], [21767, 27440, 21], [27440, 34069, 22], [34069, 39518, 23], [39518, 44102, 24], [44102, 48267, 25], [48267, 53703, 26]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 53703, 0.0]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
0c09ded5f6f74affb50d6912d7a356190392b3f6
Multi-threading support in deal.II Wolfgang Bangerth University of Heidelberg March 2000 Abstract In this report, we describe the implementational techniques of multi-threading support in deal.II, which we use for the parallelisation of independent operations. Writing threaded programs in C++ is obstructed by two problems: operating system dependent interfaces and that these interfaces are created for C programs rather than for C++. We present our solutions to these problems and describe first experiences using multi-threading in deal.II. 1 Background Realistic finite element simulations tend to use enormous amounts of computing time and memory. Scientists and programmers have therefore long tried to use the combined power of several processors or computers to tackle these problems. The usual approach is to use physically separated computers (e.g. clusters) or computing units (e.g. processor nodes in a parallel computer), each of which is equipped with its own memory, and split the problem at hand into separate parts which are then solved on these computing units. Unfortunately, this approach tends to pose significant problems, both for the mathematical formulation as well as for the application programmer, which make the development of such programs overly difficult and expensive. For these reasons, parallelized implementations and their mathematical background are still subject to intense research. In recent years, however, multi-processor machines have been developed, which pose a reasonable alternative to small parallel computers with the advantage of simple programming and the possibility to use the same mathematical formulation that can also be used for single-processor machines. These computers typically have between two and eight processors that can access the global memory at equal cost. Due to this uniform memory access (UMA) architecture, communication can be performed in the global memory and is no more costly than access to any other memory location. Thus, there is also no more need to change the mathematical formulation to reduce communication, and programs using this architecture look very much like programs written for single processor machines. The purpose of this report is to explain the techniques used in deal.II (see [1, 2]) by which we try to program these computers. We will first give a brief introduction in what threads are and what the problems are which we have to solve when we want to use multi-threading. The third section takes an in-depth look at the way in which the functionality of the operating system is represented in a C++ program in order to allow simple and robust programming; in particular, we describe the design decisions which led us to implement these parts of the library in the way they are implemented. In the fourth section, we show several examples of parallelization and explain how they work. Readers who are more interested in actually using the framework laid out in this report, rather than the internals, may skip Section 3 and go directly to the applications in Section 4 (page 15). 2 Threads The basic entity for programming multi-processor machines are threads. They represent parts of the program which are executed in parallel. Threads can be considered as separate programs that work on the same main memory. On single-processor machines, they are simulated by letting each thread run for some time (usually a few milliseconds) before switching to the next thread. On multi-processor machines, threads can truly be executed in parallel. In order to let programs use more than one thread (which would be the regular sequential program), several aspects need to be covered: - How do we assign operations to different threads? Of course, operations which depend on each other must not be executed in reverse order. This can be achieved by only letting independent operations run on different threads, or by using synchronization methods. This is mostly a question of program design and thus problem dependent, which is why both aspects will only be briefly touched below. - How does the operating system and the whole programming environment support this? As mentioned, only the second aspect can be canonicalized, so we will treat it first. Some examples of actual parallelized applications are discussed in Section 4. 3 Creating and managing threads 3.1 Operating system dependence and ACE While all relevant operating systems now support multi-threaded programs, they all have different notions on what threads actually are on an operating system level, how they shall be managed and created. Even on Unix systems, which are usually well-standardized, there are at least three different and mutually incompatible interfaces to threads: POSIX threads [6], Solaris threads [5], and Linux threads. Some operating systems support more than one interface, but there is no interface that is supported by all operating systems. Furthermore, other systems like Microsoft Windows have interfaces that are incompatible to all Unix systems [3]. Writing multi-threaded programs based on the operating system interfaces is therefore something inherently incompatible unless much effort is spent to port it to a new system. To avoid this, we chose to use the ACE (Adaptive Communication Environment, see [7, 8, 4]) library which encapsulates the operating system dependence and offers a uniform interface to the user. We chose ACE over other libraries, since it runs on almost all relevant platforms, including most Unix systems and Microsoft Windows, and since it is to our knowledge the only library which is actively developed by a large group. Furthermore, it also is significantly larger than only thread management, offering interprocess communication and communication between different computers, as well as many other services. Contrary to most other libraries, it therefore offers both the ability to support a growing deal.II as well as the prospect to support independence also with respect to future platforms. 3.2 C interface to threads versus C++ While ACE encapsulates almost all of the synchronization and interprocess interface into C++ classes, it for some reason does not do so for thread creation. Rather it only offers the basic C interface: when creating a new thread, a function is called which has the following signature: Code sample 1 ```c void * f (void * arg); ``` Thus, only functions which take a single parameter of type void* and return a void* may be called. Further, these functions must be global or static member functions, as opposed to true member functions of classes. This is not in line with the C++ philosophy and in fact does not fit well into deal.II as well: there is not a single function in the library that has this signature. The task of multi-threading support in deal.II is therefore to encapsulate member functions, arbitrary types and numbers of parameters, and return types of functions into mechanisms built atop of ACE. This has been done twice for deal.II, and we will explain both approaches. At present, i.e. with version 3.0, only the first approach is distributed with deal.II, since the second is still experimental and due to the high complexity. The latter approach, however, has clear advantages over the first one, and it is planned to switch to it in the next major version of deal.II. 3.3 First approach The first idea is the following: assume that we have a class TestClass Code sample 2 ```cpp class TestClass { public: void test_function (int i, double d); }; ``` and we would like to call `test_object.test_function(1, 3.1415926)` on a newly created thread, where `test_object` is an object of type `TestClass`. We then need an object that encapsulates the address of the member function, a pointer to the object for which we want to call the function, and both parameters. This class would be suitable: Code sample 3 ```cpp struct MemFunData { typedef void (TestClass::*MemFunPtr) (int, double); MemFunPtr mem_fun_ptr; TestClass *object; int arg1; double arg2; }; ``` We further need a function that satisfies the signature required by the operating systems (or ACE, respectively), see Code Sample 1, and that can call the member function if we pass it an object of type `MemFunData`: Code sample 4 ```cpp void * start_thread (void *arg_ptr) { // first reinterpret the void* as a // pointer to the object which // encapsulates the arguments // and addresses: MemFunData *mem_fun_data = reinterpret_cast<MemFunData *>(arg_ptr); // then call the member function: (mem_fun_data->object) ->*(mem_fun_data->mem_fun_ptr) (mem_fun_data->arg1, mem_fun_data->arg2); // since the function does not return // a value, we do so ourselves: return 0; }; ``` Such functions are called *trampoline functions* since they only serve as jump-off point for other functions. We can then perform the desired call using the following sequence of commands: ```cpp MemFunData mem_fun_data; mem_fun_data.mem_fun_ptr = &TestClass::test_function; ``` mem_fun_data.object = &test_object; mem_fun_data.arg1 = 1; mem_fun_data.arg2 = 3.1415926; ACE_Thread_Manager::spawn (&start_thread, (void*) &mem_fun_data); ACE_Thread_Manager::spawn is the function from ACE that actually calls the operating system and tells it to create a new thread and call the function which it is given as first parameter (here: start_thread) with the parameter which is given as second parameter. start_thread, when called, will then get the address of the function which we wanted to call from its parameter, and call it with the values we wanted as arguments. In practice, this would mean that we needed a structure like MemFunData and a function like start_thread for each class TestClass and all functions test_function with different signatures. This is clearly not feasible in practice and places an inappropriate burden on the programmer who wants to use multiple threads in his program. Fortunately, C++ offers an elegant way for this problem, in the form of templates: we first define a data type which encapsulates address and arguments for all binary functions: **Code sample 5** ```cpp template <typename Class, typename Arg1, typename Arg2> struct MemFunData { typedef void (Class::*MemFunPtr)(Arg1, Arg2); MemFunPtr mem_fun_ptr; Class *object; Arg1 arg1; Arg2 arg2; }; ``` Next, we need a function that can process these arguments: **Code sample 6** ```cpp template <typename Class, typename Arg1, typename Arg2> void * start_thread (void *arg_ptr) { MemFunData<Class,Arg1,Arg2> *mem_fun_data = reinterpret_cast<MemFunData<Class,Arg1,Arg2>*>(arg_ptr); (mem_fun_data->object) ->*(mem_fun_data->mem_fun_ptr) (mem_fun_data->arg1, mem_fun_data->arg2); return 0; } ``` Then we can start the thread as follows: ```cpp MemFunData<TestClass,int,double> mem_fun_data; mem_fun_data.mem_fun_ptr = &TestClass::test_function; mem_fun_data.object = &test_object; mem_fun_data.arg1 = 1; mem_fun_data.arg2 = 3.1415926; ACE_Thread_Manager::spawn (&start_thread<TestClass,int,double>, (void*) &mem_fun_data); ``` Here we first create an object which is suitable to encapsulate the parameters of a binary function that is a member function of the TestClass class and takes an integer and a double. Then we start the thread using the correct trampoline function. It is the user’s responsibility to choose the correct trampoline function (i.e. to specify the correct template parameters) since the compiler only sees a void* and cannot do any type checking. We can further simplify the process and remove the user responsibility by defining the following class and function: **Code sample 7** ```cpp class ThreadManager : public ACE_Thread_Manager { public: template <typename Class, typename Arg1, typename Arg2> static void spawn (MemFunData<Class, Arg1, Arg2> &MemFunData) { ACE_Thread_Manager::spawn (&start_thread<Class, Arg1, Arg2>, (void*)&MemFunData); } }; ``` This way, we can call ```cpp ThreadManager::spawn (mem_fun_data); ``` and the compiler will figure out which the right trampoline function is, since it knows the data type of `mem_fun_data` and therefore the values of the template parameters in the `ThreadManager::spawn` function. The way described above is basically the way which is used in deal.II version 3.0. Some care has to be paid to details, however. In particular, C++ functions often pass references as arguments, which however are not assignabe after initialization. Therefore, the `MemFunData` class needs to have a constructor, and arguments must be set through it. Assume, for example, `TestClass` had a second member function ```cpp void f (int &i, double &d); ``` Then, we would have to use `MemFunData<TestClass, int&, double&>`, which in a form without templates would look like this: ```cpp struct MemFunData { typedef void (TestClass::*MemFunPtr) (int &, double &); MemFunPtr mem_fun_ptr; TestClass *object; int &arg1; double &arg2; }; ``` The compiler would require us to initialize the references to the two parameters at construction time of the `MemFunData` object, since it is not possible in C++ to change to which object a reference points to after initialization. Adding a constructor to the `MemFunData` class would then enable us to write ```cpp int i = 1; double d = 3.1415926; MemFunData<TestClass, int&, double&> mem_fun_data (&test_object, i, d, &TestClass::f); ``` Non-reference arguments could then still be changed after construction. For historical reasons, the pointer to the member function is passed as last parameter here. The last point is that this interface is only usable for functions with two parameters. Basically, the whole process has to be reiterated for any number of parameters which we want to support. In `deal.II`, we therefore have classes `MemFunData0` through `MemFunData10`, corresponding to member function that do not take parameters through functions that take ten parameters. Equivalently, we need the respective number of trampoline functions. Additional thoughts need to be taken on virtual member functions and constant functions. While the first are handled by the compiler (member function pointers can also be to virtual functions, without explicitly stating so), the latter can be achieved by writing `MemFunData< const TestClass, int, double >`, which would be the correct object if we had declared `test_function` constant. Finally we note that it is often the case that one member function starts a new thread by calling another member function of the same object. Thus, the declaration most often used is the following: ```cpp MemFunData<TestClass, int, double> mem_fun_data (this, 1, 3.1415926, &TestClass::f); ``` Here, instead of an arbitrary `test_object`, the present object is used, which is represented by the this pointer. ### 3.4 Second approach While the approach outlined above works satisfactorily, it has one serious drawback: the programmer has to provide the data types of the arguments of the member function himself. While this seems to be a simple task, in practice it is often not, as will be explained in the sequel. To expose the problem, we take an example from one of our application programs where we would like to call the function ```cpp template <int dim> void DoFHandler<dim>::distribute_dofs (const FiniteElement<dim> &, const unsigned int); ``` on a new thread. Correspondingly, we would need to use ```cpp MemFunData2<DoFHandler<dim>, const FiniteElement<dim> &, unsigned int> mem_fun_data (dof_handler, fe, 0, &DoFHandler<dim>::distribute_dofs); ``` to encapsulate the parameters. However, if one forgets the `const` specifier on the second template parameter, one receives the following error message (using gcc 2.95.2): ```cpp test.cc: In method ‘void InterstepData<2>:::wake_up(unsigned int, InterstepData<2>:::PresentAction)’: test.cc:683: instantiated from here test.cc:186: no matching function for call to ‘ThreadManager::Mem_Fun_Data2<DoFHandler<2>,FiniteElement<2> &,unsigned int>::MemFunData2 (DoFHandler<2> *, FiniteElement<2> &, int, void (DoFHandler<2>:::*)(const FiniteElement<2> &, unsigned int))’ /home/atlas1/wolf/program/newdeal/deal.II/base/include/base/thread_manager.h:470: candidates are: ThreadManager::MemFunData2<DoFHandler<2>,FiniteElement<2> &,unsigned int>::MemFunData2 (DoFHandler<2> *, FiniteElement<2> &, unsigned int, void * (DoFHandler<2>:::*)(FiniteElement<2> &, unsigned int)) /home/atlas1/wolf/program/newdeal/deal.II/base/include/base/thread_manager.h:480: ThreadManager::MemFunData2<DoFHandler<2>,FiniteElement<2> &,unsigned int>::MemFunData2 (DoFHandler<2> *, FiniteElement<2> &, unsigned int, void (DoFHandler<2>::*)(FiniteElement<2> &, unsigned int)) /home/atlas1/wolf/program/newdeal/deal.II/base/include/base/thread_manager While the compiler is certainly right to complain, the message is not very helpful. Furthermore, since interfaces to functions sometimes change, for example by adding additional default parameters that do not show up in usual code, programs that used to compile do no more so with messages as shown above. Due to the lengthy and complex error messages, even very experienced programmers usually need between five and ten minutes until they get an expression like this correct. In most cases, they don't get it right in the first attempt, so the time used for the right declaration dominates the whole setup of starting a new thread. To circumvent this bottleneck at least in most cases, we chose to implement a second strategy at encapsulating the parameters of member functions. This is done in several steps: first let the compiler find out about the right template parameters, then encapsulate the parameters, use the objects, and finally solve some technical problems with virtual constructors and locking of destruction. We will treat these steps sequentially in the following. 3.4.1 Finding the correct template parameters. C++ offers the possibility of templatized functions that deduce their template arguments themselves. In fact, we have used them in the ThreadManager::spawn function in Code Sample 7 already. Here, this can be used as follows: assume we have a function encapsulation class ```cpp template <typename Class, typename Arg1, typename Arg2> class MemFunData { ... }; ``` as above, and a function ```cpp template <typename Class, typename Arg1, typename Arg2> MemFunData<Class,Arg1,Arg2> encapsulate (void (Class::*mem_fun_ptr)(Arg1, Arg2)) { return MemFunData<Class,Arg1,Arg2> (mem_fun_ptr); }; ``` Then, if we call this function with the test class of Code Sample 2 like this: ```cpp encapsulate (&TestClass::test_function); ``` it can unambiguously determine the template parameters to be Class=TestClass, Arg1=int, Arg2=double. 3.4.2 Encapsulating the parameters. We should not try to include the argument values for the new thread right away, for example by declaring encapsulate like this: ```cpp template <typename Class, typename Arg1, typename Arg2> MemFunData<Class,Arg1,Arg2> encapsulate (void (Class::*mem_fun_ptr)(Arg1, Arg2), Arg1 arg1, Arg2 arg2, Class object) { return MemFunData<Class,Arg1,Arg2> (mem_fun_ptr, object, arg1, arg2); }; ``` The reason is that for template functions, no parameter promotion is performed. Thus, if we called this function as in encapsulate (&TestClass::test_function, 1, 3, test_object); then the compiler would refuse this since from the function pointer it must deduce that Arg2 = double, but from the parameter “3” it must assume that Arg2 = int. The resulting error message would be similarly lengthy as the one shown above. One could instead write MemFunData like this: template<typename Class, typename Arg1, typename Arg2> class MemFunData { public: typedef void (Class::*MemFunPtr)(Arg1, Arg2); MemFunData (MemFunPtr mem_fun_ptr_) { mem_fun_ptr = mem_fun_ptr_;} void collect_args (Class *object_, Arg1 arg1_, Arg2 arg2_) { object = object_; arg1 = arg1_; arg2 = arg2_; } MemFunPtr mem_fun_ptr; Class *object; Arg1 arg1; Arg2 arg2; }; One would then create an object of this type including the parameters to be passed as follows: encapsulate(&TestClass::test_function).collect_args(test_object, 1, 3); Here, the first function call creates an object with the right template parameters and storing the member function pointer, and the second one, calling a member function, fills in the function arguments. Unfortunately, this way does not work: if one or more of the parameter types is a reference, then the respective reference variable needs to be initialized by the constructor, not by collect_args. It needs to be known which object the reference references at construction time, since later on only the referenced object can be assigned, not the reference itself anymore. Since we feel that we are close to a solution, we introduce one more indirection, which indeed will be the last one: **Code sample 8** template<typename Class, typename Arg1, typename Arg2> class MemFunData { public: typedef void (Class::*MemFunPtr)(Arg1, Arg2); MemFunData (MemFunPtr mem_fun_ptr_, Class *object_, Arg1 arg1_, Arg2 arg2_): mem_fun_ptr (mem_fun_ptr_), object (object_), arg1 (arg1_), arg2 (arg2_) {}; MemFunPtr mem_fun_ptr; Class *object; Arg1 arg1; Arg2 arg2; }; template <typename Class, typename Arg1, typename Arg2> struct ArgCollector { typedef void (Class::*MemFunPtr)(Arg1, Arg2); ArgCollector (MemFunPtr mem_fun_ptr_) { mem_fun_ptr = mem_fun_ptr_; } }; MemFunData<Class,Arg1,Arg2> collect_args (Class *object_, Arg1 arg1_, Arg2 arg2_) { return MemFunData<Class,Arg1,Arg2> (mem_fun_ptr, object, arg1, arg2); }; MemFunPtr mem_fun_ptr; }; template <typename Class, typename Arg1, typename Arg2> ArgCollector<Class,Arg1,Arg2> encapsulate (void (Class::*mem_fun_ptr)(Arg1, Arg2)) { return ArgCollector<Class,Arg1,Arg2> (mem_fun_ptr); }; Now we can indeed write for the test class of Code Sample 2: encapsulate(&TestClass::test_function).collect_args(test_object, 1, 3); The first call creates an object of type ArgCollector<...> with the right parameters and storing the member function pointer, while the second call, a call to a member function of that intermediate class, generates the final object we are interested in, including the member function pointer and all necessary parameters. Since collect_args already has its template parameters fixed from encapsulate, it can convert between data types. ### 3.4.3 Using these objects. Now we have an object of the correct type automatically generated, without the need to type in any template parameters by hand. What can we do with that? First, we can’t assign it to a variable of that type, e.g. for use in several spawn commands: MemFunData mem_fun_data = encapsulate(...).collect_args(...); Why? Since we would then have to write the data type of that variable by hand: the correct data type is not MemFunData as written above, but MemFunData<TestClass,int,double>. Specifying all these template arguments was exactly what we wanted to avoid. However, we can do some such thing if the variable to which we assign the result is of a type which is a base class of MemFunData<...>. Unfortunately, the data values that MemFunData<...> encapsulates depend on the template parameters, so the respective variables in which we store the values can only be placed in the derived class and could not be copied when we assign the variable to a base class object, since that does not have these variables. What can we do here? Assume we have the following class structure: **Code sample 9** class FunDataBase {} template <...> class MemFunData : public FunDataBase { /* as above */ }; class FunEncapsulation { public: FunEncapsulation (FunDataBase *f) : fun_data_base (f) {} FunDataBase *fun_data_base; }; template <typename Class, typename Arg1, typename Arg2> FunEncapsulation ArgCollector<Class,Arg1,Arg2>::collect_args (Class *object_, Arg1 arg1_, Arg2 arg2_) { return new MemFunData<Class,Arg1,Arg2> (mem_fun_ptr, object_, arg1, arg2); }; Note that in the return statement of the collect_args function, first a cast from MemFunData* to FunDataBase*, and then a constructor call to FunEncapsulation :: FunEncapsulation (FunDataBase*) was performed. In the example above, the call to encapsulate(...).collect_args(...) generates an object of type FunEncapsulation, which in turn stores a pointer to an object of type FunDataBase, here to MemFunData<...> with the correct template parameters. We can assign the result to a variable the type of which does not contain any template parameters any more, as desired: FunEncapsulation fun_encapsulation = encapsulate (&TestClass::test_function) .collect_args(test_object, 1, 3); But how can we start a thread with this object if we have lost the full information about the data types? This can be done as follows: add a variable to FunDataBase which contains the address of a function that knows what to do. This function is usually implemented in the derived classes, and its address is passed to the constructor: **Code sample 10** class FunDataBase { public: typedef void * (*ThreadEntryPoint) (void *); FunDataBase (ThreadEntryPoint t) : thread_entry_point (t) {}; ThreadEntryPoint thread_entry_point; }; template <...> class MemFunData : public FunDataBase { public: // among other things, the constructor now does this: MemFunData () : FunDataBase (&start_thread) {}; static void * start_thread (void *args) { // do the same as in Code Sample 4 above } }; void spawn (ACE_Thread_Manager &thread_manager, FunEncapsulation &fun_encapsulation) { thread_manager.spawn (*fun_encapsulation.fun_data_base ->thread_entry_point, &fun_data_base); } fun_encapsulation.fun_data_base->thread_entry_point is given by the derived class as that function that knows how to handle objects of the type which we are presently using. Thus, we can now write the whole sequence of function calls (assuming we have an object thread_manager of type ACE_Thread_Manager): FunEncapsulation fun_encapsulation = encapsulate (&TestClass::test_function) .collect_args(test_object, 1, 3); spawn (thread_manager, fun_encapsulation); This solves our problem in that no template parameters need to be specified by hand any more. The only source for lengthy compiler error messages is if the parameters to collect_args are in the wrong order or can not be casted to the parameters of the member function which we want to call. These problems, however, are much more unlikely in our experience, and are also much quicker sorted out. 3.4.4 Virtual constructors. While the basic techniques have been fully developed now, there are some aspects which we still have to take care of. The basic problem here is that the FunEncapsulation objects store a pointer to an object that was created using the new operator. To prevent a memory leak, we need to destroy this object at some time, preferably in the destructor of FunEncapsulation: FunEncapsulation::FunEncapsulation () { delete fun_data_base; }; However, what happens if we have copied the object before? In particular, this is always the case using the functions above: collect_args generates a temporary object of type FunEncapsulation, but there could be other sources of copies as well. If we do not take special precautions, only the pointer to the object is copied around, and we end up with stale pointers pointing to invalid locations in memory once the first object has been destroyed. What we obviously need to do when copying objects of type FunEncapsulation is to not copy the pointer but to copy the object which it points to. Unfortunately, the following copy constructor is not possible: ```cpp FunEncapsulation::FunEncapsulation (const FunEncapsulation &m) { fun_data_base = new FunDataBase (*m.fun_data_base); }; ``` The reason, of course, is that we do not want to copy that part of the object belonging to the abstract base class. But we can emulate something like this in the following way (this programming idiom is called “virtual constructors”): **Code sample 11** ```cpp class FunDataBase { public: // as above virtual FunDataBase * clone () const = 0; }; template <...> class MemFunData : public FunDataBase { public: // as above // copy constructor: MemFunData (const MemFunData<...> &mem_fun_data) {...}; // clone the present object, i.e. // create an exact copy: virtual FunDataBase * clone () const { return new MemFunData<...>(*this); } }; }; FunEncapsulation::FunEncapsulation (const FunEncapsulation &m) { fun_data_base = m.fun_data_base->clone () }; ``` Thus, whenever the FunEncapsulation object is copied, it creates a copy of the object it harbors (the MemFunData<...> object), and therefore always owns its copy. When the destructor is called, it is free to delete its copy without affecting other objects (from which it may have been copied, or to which it was copied). Similar to the copy constructor, we have to modify the copy operator, as well. ### 3.4.5 Spawning independent threads. Often, one wants to spawn a thread which will have its own existence until it finishes, but is in no way linked to the creating thread any more. An example would be the following, assuming a function TestClass::compress_file(const string file_name) exists and that there is an object thread_manager not local to this function: ```cpp ... string file_name; ... // write some output to a file ``` // now create a thread which runs 'gzip' on that output file to reduce // disk space requirements. don't care about that thread any more // after creation, i.e. don't wait for its return FunEncapsulation fun_encapsulation = encapsulate (&TestClass::compress_file) .collect_args(test_object, file_name); spawn (thread_manager, fun_encapsulation); // quit the present function return; The problem here is that the object fun_encapsulation goes out of scope when we quit the present function, and therefore also deletes its pointer to the data which we need to start the new thread. If in this case the operating system was a bit lazy in creating the new thread, the function start_thread would at best find a pointer pointing to an object which is already deleted. Further, but this is obvious, if the function is taking references or pointers to other objects, it is to be made sure that these objects persist at least as long as the spawned thread runs. What one would need to do here at least, is wait until the thread is started for sure, before deletion of the FunEncapsulation is allowed. To this end, we need to use a “Mutex”, to allow for exclusive operations. A Mutex (short for mutually exclusive) is an object managed by the operating system and which can only be “owned” by one thread at a time. You can try to “acquire” a Mutex, and you can later “release” it. If you try to acquire it, but the Mutex is owned by another thread, then your thread is blocked until the present owner releases it. Mutexes (plural of “Mutex”) are therefore most often used to guarantee that only one thread is presently accessing some object: a thread that wants to access that object acquires a Mutex related to that object and only releases it once the access if finished; if in the meantime another thread wants to access that object as well, it has to acquire the Mutex, but since the Mutex is presently owned already, the second thread is blocked until the first one has finished its access. Alternatively, one can use Mutexes to synchronize things. We will use it for the following purpose: the Mutex is acquired by the starting thread; when later the destructor of the FunEncapsulation class (running on the same thread) is called, it tries to acquire the lock again; it will thus only continue its operations once the Mutex has been released by someone, which we do on the spawned thread once we don’t need the data of the FunEncapsulation object any more and destruction is safe. All this can then be done in the following way: Code sample 12 class FunEncapsulation { public: ... // as before FunEncapsulation (){ } }; class FunDataBase { public: ... // as before Mutex lock; }; template <typename Class, typename Arg1, typename Arg2> void * start_thread (void *arg_ptr) { MemFunData<Class,Arg1,Arg2> *mem_fun_data = reinterpret_cast<MemFunData *>(arg_ptr); // copy the data arguments: MemFunData<Class, Arg1, Arg2>::MemFunPtr mem_fun_ptr = mem_fun_data->mem_fun_ptr; Class * object = mem_fun_data->object; Arg1 arg1 = mem_fun_data->arg1; Arg2 arg2 = mem_fun_data->arg2; // data is now copied, so the original object may be deleted: mem_fun_data->lock.release(); // now call the thread function: object->*mem_fun_ptr (arg1, arg2); return 0; }; FunEncapsulation::FunEncapsulation () { // wait until the data is copied by the new thread and // 'release' is called by 'start_thread': fun_data_base->lock.acquire (); // now delete the object which is no more needed delete fun_data_base; }; void spawn (ACE_Thread_Manager &thread_manager, FunEncapsulation &fun_encapsulation) { // lock the fun_encapsulation object fun_encapsulation.fun_data_base->lock.acquire (); thread_manager.spawn (*fun_encapsulation.fun_data_base ->thread_entry_point, &fun_data_base); }; When we call spawn, we set a lock on the destruction of the FunEncapsulation object just before we start the new thread. This lock is only released when inside the new thread (i.e. inside the start_thread function) all arguments have been copied to a safe place. Now we have local copies and don’t need the ones from the fun_encapsulation object any more, which we indicate by releasing the lock. Inside the destructor of that object, we wait until we can obtain the lock, which is only after it has been released by the newly started thread; after having waited till this moment, the destruction can go on safely, and we can exit the function from which the thread was started, if we like so. The scheme just described also works if we start multiple threads using only one object of type FunEncapsulation: FunEncapsulation fun_encapsulation = encapsulate (&TestClass::test_function) .collect_args(test_object, arg_value); spawn (thread_manager, fun_encapsulation); spawn (thread_manager, fun_encapsulation); // quit the present function return; Here, when starting the second thread the spawn function has to wait until the newly started first thread has released its lock on the object; however, this delay is small and should not pose a noticeable problem. Thus no special treatment of this case is necessary, and we can in a simple way emulate the spawnN function provided by most operating systems, which spawns several new threads at once: ```c void spawnN (ACE_Thread_Manager &thread_manager, FunEncapsulation &fun_encapsulation, const unsigned int n_threads) { for (unsigned int i=0; i<n_threads; ++i) spawn (thread_manager, fun_encapsulation); } ``` A direct support of the spawn function of the operating system would be difficult, though, since each of the new threads would call lock.release(), even though the lock was only acquired once. Since we have now made sure that objects are not deleted too early, even the following sequence is possible, which does not involve any named variables at all, only a temporary one, which immediately released after the call to spawn: **Code sample 13** ```c spawn (thread_manager, encapsulate (&TestClass::test_function) .collect_args(test_object, arg_value)); ``` We most often use this very short idiom in the applications in Section 4 and in our own programs. ### 3.4.6 Number of parameters. Non-member functions. Above, we have explained how we can define classes for a binary member function. This approach is easily extended to member functions taking any number of parameters. We simply have to write classes `MemFunData0`, `MemFunData1`, and so on, which encapsulate member functions that take zero, one, etc parameters. Likewise, we have to have classes `ArgCollectorN` for each number of parameters, and functions `encapsulate` that return an object of type `ArgCollectorN`. Since functions can be overloaded on their argument types, we need not call the `encapsulate` functions differently. All of which has been said above can also easily be adopted to global functions or static member functions. Instead of the classes `MemFunDataN` we can then use classes `FunDataN` that are also derived from `FunDataBase`. The respective `ArgCollector` classes then collect only the arguments, not the object on which we will operate. The class, `FunEncapsulation` is not affected by this, nor is `FunDataBase`. ## 4 Applications In the next few subsections, we will show usual applications of multi-threading in the `deal.II` library. The programs already use the new scheme discussed in Section 3.4. ### 4.1 Writing output detached to disk The output classes, i.e. basically the classes `DataOut` and `DataOutStack` and their base classes, follow a strictly hierarchical model of data flow. The two terminal classes know about such things as triangulations, degrees of freedom, or finite elements, but they translate this structured information into a rather simple intermediate format. This conversion is done in the `build_patches` functions of these classes. The actual output routines only convert this intermediate format into one of the supported graphics formats, which is then a relatively simple task. This separation of processing of structured data and actual output of the intermediate format was chosen since the actual output routines became rather complex with growing scope of the whole library. For example, we had to update all output functions when vector-valued finite elements were supported, and we had to do so again when discontinuous elements were developed. This became an unmanageable burden with the growing number of output formats, and we decided that an intermediate format would be more appropriate, which is created by only one function, but can be written to output formats by a number of different functions. In the present context, this has the following implications: once the intermediate data is created by the build_patches function, we need no more preserve the data from which it was made (i.e. the grid which it was computed on, or the vector holding the actual solution values) and we can go on with computing on the next finer grid, or the next time step, while the intermediate data is converted to a graphics format file detached from the main process. The only thing which we must make sure is that the program only terminates after all detached output threads are finished. This can be done in the following way: ```c++ // somewhere define a thread manager that keeps track of all // detached ('global') threads ACE_Thread_Manager global_thread_manager; // This is the class which does the computations: class MainClass { ... // now two functions, the first is called from the main program // for output, the second will manage detached output void write_solution () { void write_detached (DataOut<dim> *data_out); void MainClass::write_solution () { DataOut<dim> *data_out = new DataOut<dim>(); // attach DoFHandler, add data vectors, ... data_out->build_patches (); // now everything is in place, and we can write the data detached // Note that we transfer ownership of 'data_out' to the other thread Threads::spawn (global_thread_manager, Threads::encapsulate(&MainClass<dim>::write_detached) .collect_args(this, data_out)); void MainClass::write_detached (DataOut<dim> *data_out) { ofstream output_file ("abc"); data_out->write_gnuplot (output_file); // now delete the object which we got from the starting thread delete data_out; ``` int main () { // do all the work // now wait for all detached threads to finish global_thread_manager.wait (); }; Note that the functions spawn and encapsulate are prefixed by Threads:: since in the actual implementation in deal.II they are declared within a namespace of that name. It should be noted that if you want to write output detached from the main thread, and from the main thread at the same time, you need a version of the C++ standard library delivered with your compiler that supports parallel output. For the GCC compiler, this can be obtained by configuring it with the flag --enable-threads at build time. 4.2 Assembling the matrix Setting up the system matrix is usually done by looping over all cells and computing the contributions of each cell separately. While the computations of the local contributions is strictly independent, we need to transfer these contributions to the global matrix afterward. This transfer has to be synchronized, in order to avoid that one thread overwrites values that another thread has just written. In most cases, building the system matrix in parallel will look like the following template: ```cpp void MainClass::build_matrix () { // define how many threads will be used (here: 4) const unsigned int n_threads = 4; const unsigned int n_cells_per_thread = triangulation.n_active_cells () / n_threads; // define the Mutex that will be used to synchronise // accesses to the matrix ACE_Thread_Mutex mutex; // define thread manager ACE_Thread_Manager thread_manager; vector<DoFHandler<dim>::active_cell_iterator> first_cells (n_threads), end_cells (n_threads); DoFHandler<dim>::active_cell_iterator present_cell = dof_handler.begin_active (); for (unsigned int thread=0; thread<n_threads; ++thread) { // for each thread: first determine the range of cells on // which it shall operate: first_cells[thread] = present_cell; end_cells[thread] = first_cells[thread]; if (thread != n_threads-1) for (unsigned int i=0; i<n_cells_per_thread; ++i) ++end_cells[thread]; else end_cells[thread] = dof_handler.end(); ``` // now start a new thread that builds the contributions of // the cells in the given range Threads::spawn(thread_manager, Threads::encapsulate(MainClass::build_matrix_threaded) .collect_args(this, first_cells[thread], end_cells[thread], mutex)); // set start iterator for next thread present_cell = end_cells[thread]; }; void MainClass::build_matrix_threaded (const DoFHandler<dim>::active_cell_iterator &first_cell, const DoFHandler<dim>::active_cell_iterator &end_cell, ACE_Thread_Mutex &mutex) { FullMatrix<double> cell_matrix; vector<unsigned int> local_dof_indices; DoFHandler<dim>::active_cell_iterator cell; for (cell=first_cell; cell!=end_cell; ++cell) { // compute the elements of the cell matrix ... // get the indices of the DoFs of this cell cell->get_dof_indices(local_dof_indices); // now transfer local matrix into the global one. // synchronise this with the other threads mutex.acquire(); for (unsigned int i=0; i<dofs_per_cell; ++i) for (unsigned int j=0; j<dofs_per_cell; ++j) global_matrix.add(local_dof_indices[i], local_dof_indices[j], cell_matrix(i,j)); mutex.release(); } } Note that since the build_matrix_threaded function takes its arguments as references, we have to make sure that the variables to which these references point live at least as long as the spawned threads. It is thus not possible to use the same variables for start and end iterator for all threads, as the following example would do: .... DoFHandler<dim>::active_cell_iterator first_cell = dof_handler.begin_active(); 18 for (unsigned int thread=0; thread<n_threads; ++thread) { // for each thread: first determine the range of threads on // which it shall operate: DoFHandler<dim>::active_cell_iterator end_cell = first_cell; if (thread != n_threads-1) for (unsigned int i=0; i<n_cells_per_thread; ++i) ++end_cell; else end_cell = dof_handler.end(); // now start a new thread that builds the contributions of // the cells in the given range Threads::spawn (thread_manager, Threads::encapsulate(&MainClass::build_matrix_threaded) .collect_args (this, first_cell, end_cell, mutex)); // set start iterator for next thread first_cell = end_cell; }; .... Since splitting a range of iterators (for example the range begin_active() to end()) is a very common task when setting up threads, there is a function template <typename ForwardIterator> vector<pair<ForwardIterator,ForwardIterator> > split_range (const ForwardIterator &begin, const ForwardIterator &end, const unsigned int n_intervals); in the Threads namespace that splits the range [begin,end) into n_intervals subintervals of approximately the same size. Using this function, the thread creation function can now be written as follows: void MainClass::build_matrix () { const unsigned int n_threads = 4; ACE_Thread_Mutex mutex; ACE_Thread_Manager thread_manager; // define starting and end point for each thread typedef DoFHandler<dim>::active_cell_iterator active_cell_iterator; vector<pair<active_cell_iterator,active_cell_iterator> > thread_ranges = split_range<active_cell_iterator> (dof_handler.begin_active (), dof_handler.end (), n_threads); for (unsigned int thread=0; thread<n_threads; ++thread) spawn (thread_manager, encapsulate(&MainClass::build_matrix_threaded) .collect_args (this, thread_ranges[thread].first, thread_ranges[thread].second, mutex)); thread_manager.wait(); }; We have here omitted the Threads:: prefix to make things more readable. Note that we had to explicitly specify the iterator type active_cell_iterator to the split_range function, since the two iterators given have different type (dof_handler.end() has type DoFHandler<dim>::raw_cell_iterator, which can be converted to DoFHandler<dim>::active_cell_iterator) and C++ requires that either the type is explicitly given or the type be unique. A word of caution is in place here: since usually in finite element computations, the system matrix is ill-conditioned, small changes in a data vector or the matrix can lead to significant changes in the output. Unfortunately, since the order in which contributions to elements of the matrix or vector are computed cannot be predicted when using multiple threads, round-off can come into play here. For example, taken from a real-world program, the following contributions for an element of a right hand side vector are computed from four cells: \(-3.255208333333328815, -3.255208333333328694, -3.255208333333328694, -3.255208333333328694\); however, due to round-off the sum of these numbers depends on the order in which they are summed up, such that the resulting element of the vector differed depending on the number of threads used, the number of other programs on the computer, and other random sources. In subsequent runs of exactly the same programs, the sum was either \(-13.02083333333332827\) or \(-13.02083333333332810\). Although the difference is still only in the range of round-off error, it caused a change in the fourth digit of a derived, very ill-conditioned quantity after the matrix was inverted several times (this accuracy in this quantity was not really needed, but it showed up in the output and also led to different grid refinement due to comparison with other values of almost the same size). Tracking down the source of such problems is extremely difficult and frustrating, since they occur non-deterministically in subsequent runs of the same program, and it can take several days until the actual cause is found. One possible work-around is to reduce the accuracy of the summation such that the value of the sum becomes irrespective of the order of the summands. One, rather crude method is to use a conversion to data type float and back; the update loop from above would then look as follows: ```cpp for (unsigned int i=0; i<dofs_per_cell; ++i) for (unsigned int j=0; j<dofs_per_cell; ++j) global_matrix.add (local_dof_indices[i], local_dof_indices[j], static_cast<float>(cell_matrix(i,j))); ``` Note that the cast back to double is performed here implicitly. The question whether a reduction in accuracy in the order shown here is tolerable, is problem dependent. There are methods that lose less accuracy than shown above. The other, less computationally costly possibility would be to decrease the accuracy of the resulting sum, in the hope that all accumulated round-off error is deleted. However, this is unsafe since the order dependence remains and may even be amplified if the values of the sum lie around a boundary where values are rounded up or down when reducing the accuracy. Furthermore, problems arise if the summands have different signs and the result of summation consists of round-off error only. ### 4.3 Parallel Jacobi preconditioning When preconditioning a matrix, for example in a Conjugate Gradients solver, one may choose the Jacobi scheme for preconditioning. The preconditioned vector \( \tilde{v} \) is computed from the vector \( v \) using the following relationship: \[ \tilde{v}_i = \frac{1}{a_{ii}} v_i, \] where \( a_{ii} \) are the diagonal elements of the matrix which we are presently inverting. As is obvious, the result of preconditioning one element of \( v \) is entirely independent of all other elements, so this operation is trivially parallelizable. In practice, this is done by splitting the interval \([0,n)\) into equal parts \([n_i, n_{i+1})\), \(i = 0, \ldots, p - 1\), where \(n\) is the size of the matrix, and \(p\) is the number of processors. Obviously, \(n_0 = 0, n_p = n\), and \(n_i < n_{i+1}\). Just like for splitting a range of iterators using the function \texttt{split\_range} used above, there is a function \begin{verbatim} vector<pair<unsigned int, unsigned int>> split_interval (const unsigned int &begin, const unsigned int &end, const unsigned int n_intervals); \end{verbatim} that splits the interval \([\text{begin}, \text{end})\) into \(n\_intervals\) equal parts. This function will be used to assign each processor its share of elements \(v_i\). Furthermore, we will use some functionality provided by the \texttt{MultithreadInfo} class in deal.II. Upon start-up of the library, the static variable \texttt{multithread\_info.n\_cpus} is set to the number of processors in the computer the program is presently running on. \texttt{multithread\_info} is a global variable of type \texttt{MultithreadInfo} available in all parts of the library. Furthermore, there is a variable \texttt{multithread\_info.n\_default\_threads}, which by default is set to \texttt{n\_cpus}, but which can be changed by the user; it denotes the default number of threads which the library shall use whenever multi-threading is implemented for some operation. We will use this variable to decide how many threads shall be used to precondition the vector. The implementation of the preconditioning function then looks like this: ``` // define an abbreviatory data type for an interval typedef pair<unsigned int, unsigned int> Interval; void Preconditioner::precondition_jacobi (const Matrix &m, const Vector &v, Vector &v_tilde) { // define an abbreviation to the number // of threads which we will use const unsigned int n_threads = multithread_info.n_default_threads; // first split the interval into equal pieces vector<Interval> intervals = Threads::split_interval (0, m.rows(), n_threads); // then define a thread manager ACE_Thread_Manager thread_manager; // and finally start all the threads: for (unsigned int i=0; i<n_threads; ++i) Threads::spawn (thread_manager, Threads::encapsulate (&Preconditioner::threaded_jacobi) .collect_args (this, m, v, v_tilde, intervals[i])); // wait for all the threads to finish thread_manager.wait (); }; void Preconditioner::threaded_jacobi (const Matrix &m, const Vector &v, Vector &v_tilde, const Interval &interval) { // apply the preconditioner in the given interval for (unsigned int i=interval.first; i<interval.second; ++i) v_tilde(i) = v(i) / m(i,i); } ``` It is noted, however, that more practical preconditioners are usually not easily parallelized. However, matrix-vector and vector-vector operations can often be reduced to independent parts and can then be implemented using multiple threads. 5 Conclusions We have shown how multi-threading is supported in deal.II and how it can be used in several examples occurring in common finite element programs. It was demonstrated that implementing a usable C++ interface poses several difficulties, both from the aspect of user friendliness as well as program correctness. In order to overcome these difficulties, first the more simple framework implemented in deal.II version 3.0 was discussed, followed by a rather complex scheme which will be the base of implementations in future versions. The second framework features a more complicated hierarchy of classes as well as intricate use of templates and synchronization mechanisms, which however led to a design in which threads can be created in a user friendly, system independent, C++ like way suitable for common programs. The use of this framework is inherently safe and does not require special knowledge of the internals by the user, and is simple to use. By using it, the overhead required for programming multi-threaded applications is reduced to a minimum and the programmer can concentrate on the task of getting the semantics of multi-threaded programs right, in particular managing concurrent access to data and distributing work to different threads. The framework has been used in several application programs and has shown that with only marginally increased programming effort, finite element programs can be made significantly faster on multi-processor machines. Acknowledgments. The author would like to thank Thomas Richter for his work in parallelizing several parts of the deal.II library, and Ralf Hartmann for help in the preparation of this report. References
{"Source-Url": "http://www.math.colostate.edu/~bangerth/publications/2000-mtreport.pdf", "len_cl100k_base": 12426, "olmocr-version": "0.1.53", "pdf-total-pages": 22, "total-fallback-pages": 0, "total-input-tokens": 146896, "total-output-tokens": 14424, "length": "2e13", "weborganizer": {"__label__adult": 0.00028324127197265625, "__label__art_design": 0.0002868175506591797, "__label__crime_law": 0.00026869773864746094, "__label__education_jobs": 0.0005884170532226562, "__label__entertainment": 5.459785461425781e-05, "__label__fashion_beauty": 0.00011527538299560548, "__label__finance_business": 0.00015437602996826172, "__label__food_dining": 0.0002987384796142578, "__label__games": 0.0005860328674316406, "__label__hardware": 0.0010986328125, "__label__health": 0.0003330707550048828, "__label__history": 0.000247955322265625, "__label__home_hobbies": 9.077787399291992e-05, "__label__industrial": 0.0004336833953857422, "__label__literature": 0.0001537799835205078, "__label__politics": 0.00023627281188964844, "__label__religion": 0.0004749298095703125, "__label__science_tech": 0.019622802734375, "__label__social_life": 7.31348991394043e-05, "__label__software": 0.00579833984375, "__label__software_dev": 0.9677734375, "__label__sports_fitness": 0.00029397010803222656, "__label__transportation": 0.0005636215209960938, "__label__travel": 0.0002073049545288086}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 57529, 0.01518]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 57529, 0.78872]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 57529, 0.85456]], "google_gemma-3-12b-it_contains_pii": [[0, 3390, false], [3390, 7071, null], [7071, 9118, null], [9118, 11511, null], [11511, 14070, null], [14070, 17013, null], [17013, 19543, null], [19543, 21675, null], [21675, 23360, null], [23360, 25811, null], [25811, 28163, null], [28163, 30312, null], [30312, 33321, null], [33321, 35354, null], [35354, 38539, null], [38539, 41010, null], [41010, 43262, null], [43262, 45049, null], [45049, 47274, null], [47274, 51296, null], [51296, 54235, null], [54235, 57529, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3390, true], [3390, 7071, null], [7071, 9118, null], [9118, 11511, null], [11511, 14070, null], [14070, 17013, null], [17013, 19543, null], [19543, 21675, null], [21675, 23360, null], [23360, 25811, null], [25811, 28163, null], [28163, 30312, null], [30312, 33321, null], [33321, 35354, null], [35354, 38539, null], [38539, 41010, null], [41010, 43262, null], [43262, 45049, null], [45049, 47274, null], [47274, 51296, null], [51296, 54235, null], [54235, 57529, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 57529, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 57529, null]], "pdf_page_numbers": [[0, 3390, 1], [3390, 7071, 2], [7071, 9118, 3], [9118, 11511, 4], [11511, 14070, 5], [14070, 17013, 6], [17013, 19543, 7], [19543, 21675, 8], [21675, 23360, 9], [23360, 25811, 10], [25811, 28163, 11], [28163, 30312, 12], [30312, 33321, 13], [33321, 35354, 14], [35354, 38539, 15], [38539, 41010, 16], [41010, 43262, 17], [43262, 45049, 18], [45049, 47274, 19], [47274, 51296, 20], [51296, 54235, 21], [54235, 57529, 22]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 57529, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
fecf1017a59899d19021387d66a8fbd9a841936f
A Decision Making Pattern for Guiding the Enterprise Knowledge Development Process Colette Rolland, Selmin Nurcan, Georges Grosz To cite this version: HAL Id: hal-00707096 https://hal.archives-ouvertes.fr/hal-00707096 Submitted on 16 Jun 2012 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Abstract During enterprise knowledge development in any organisation, developers and stakeholders are faced with situations that require them to make decisions in order to reach their intentions. To help the decision making process, guidance is required. Enterprise Knowledge Development (EKD) is a method offering a guided knowledge development process. The guidance provided by the EKD method is based on a decision making pattern promoting a situation and intention oriented view of enterprise knowledge development processes. The pattern is iteratively repeated through the EKD process using different types of guiding knowledge. Consequently, the EKD process is systematically guided. The presentation of the decision making pattern is the purpose of this paper. Keywords: Decision Making, Enterprise Knowledge Engineering, Guidance, Change Process, Re-use. 1. Introduction Software engineering and requirement engineering methods were classically focused on the product aspect of systems development and have paid less attention to the description of formally defined processes which could be supported by CASE environments. Existing approaches to enterprise knowledge modelling can be classified into two categories. In the first category, an organisation is represented as a set of interrelated elements satisfying collaboratively common objectives [4], [8], [9]. For instance, VSM [8] allows us to model an organisation as a set of "viable" sub-systems representing respectively the operation, co-ordination, control, intelligence (reasoning, analysis) and politics (strategy) aspects of an organisation. In the second category, the focus is given to developing different views of the organisation dealing respectively on actors, roles, resources, business processes, objectives, rules, etc. [2], [6], [13], [14]. The development processes suggested by these approaches are descriptive, remain at a very high level of abstraction and do not provide effective guidance. Existing approaches to organisational change management propose sequences of activities in order to change the organisation from its current state to a desired future state. Many of them are adaptations and/or extensions of the three steps proposed by Lewin [18]: (1) to de-freeze business processes as a sign of preparation and disposition to change, (2) to implement the change, (3) to standardise (freeze) new processes, structures and systems. Other authors have extended this approach by describing more precisely these three steps and propose again sequential processes [10], [16]. In all these approaches, change process descriptions are coarse grained and described as sequences of steps. They have not associated product models. Clearly, there is a high need for methods and tools which offer process guidance to provide advice on which activities are appropriate under which situations and how to perform them [7], [12], [36], [28], [29] to handle change management. In [30] we proposed a method, namely Enterprise Knowledge Development (EKD) which intends to provide such guidance. The EKD method has been applied, in the context of the ESPRIT project ELEKTRA\(^1\) [37] for re-organising electricity companies and designing new solutions [20], [21]. The EKD framework is composed of three complementary elements: (1) a set of models used for describing the system to be constructed and the organisation in which it will operate, (2) a process supporting the usage of concepts, (3) a set of tools supporting the EKD process. The focus of this paper is given to point (2), the readers shall refer to [3, 20] for point (1) and [11] for point (2). The EKD process supports the enterprise knowledge development in a systematic manner. It provides advice on what should be considered during the design process (goals, roles, etc.), why and how it should be analysed (goal decomposition, role dependency study, etc.) following some relevant techniques (brainstorming, SWOT analysis, etc.). We distinguish three levels in process modelling: - At the instance level, process traces are recorded. A process is a description of the route followed to construct a product. The output of a process is a product, it can be a requirements specification, a conceptual schema or a set of business goals. A process and its related product are specific to an application. - At the type level, process models are defined. A process model is an anticipation of what the process will look like. A process is then, an instantiation of the process model. A process model is specific to a method. - At the meta-type level, we define the generic concepts used to represent any process model. Along with their relationships, those concepts constitute the process meta-model. Process models are therefore, instances of the process meta-model. A process meta-model is method independent. The EKD process is a guided process made of steps resulting each in the application of the same pattern for decision making. This paper is dedicated to the presentation of the EKD decision making pattern which aims at supporting the EKD engineer while performing the --- \(^1\) This work is partially supported by the ESPRIT project ELEKTRA (N° 22927) funded by the EEC in the context of the Framework 4 programme. decision making process when studying the impact of change in an organisation. It is organised as follows. Section 2 sets the aim and objectives of the pattern and presents the concepts used to represent it. Section 3 illustrates the use of the pattern through different examples, putting forward the different types of guidance it provides. Finally, section 4 gives an overview of the method specific guidelines used in the EKD framework, and illustrates some of them. Section 5 concludes this paper. 2. The EKD decision making pattern 2.1. The EKD method and the underlying EKD models The purpose of the EKD method is to provide a clear and unambiguous picture of (1) how the enterprise functions currently, (2) what are the requirements for change and the reasons for change, (3) what alternatives could be envisaged in order to meet these requirements, and (4) what are the criteria and arguments for evaluating these alternatives [3], [21]. The models underlying the EKD method are based on the use of Enterprise Models [2] which purpose is to represent various views of an enterprise. A detailed presentation of the EKD Models can be found in [3] and [20]. The goal model aims to represent the goals of the enterprise. Its purpose is to describe what the enterprise wants to achieve or to avoid. The business rules model is used to define business rules consistent with the goals model. Business rules can be seen as operationalisation of goals. The object model is used to define the enterprise entities, attributes and relationships. The actor/role model aims to describe how actors are related to each other and also to goals. The role/activity model is used to define enterprise processes, the way they consume/produce resources. The information system model is used when the EKD method is applied to define the requirements for an information system. In this model, the focus is the computerised system which has to support the goals, the processes and the actors of the enterprise as defined in the previous models. These set of EKD models can be visualised in three levels of concern as shown in figure 1: business objectives, business processes, information systems [20]. In using the EKD method, one can start at any level and move on to other levels, depending on the situation. The EKD method can be used for the purposes of both business engineering and information system engineering [20] allowing: (a) business process reengineering (from business processes level to the business objectives for change [31]) (b) reverse engineering (from legacy information systems to the information system level which may be than used to model the business processes level [15]) (c) forward engineering (from business objectives to business processes and from business processes to information systems development). 2.2. Aim and scopes of the decision making pattern The EKD process aims at constructing a description of the Enterprise Knowledge in terms of EKD models. The EKD decision making pattern is the key element underlying the EKD process. It aims at providing a reasoning mechanism to support the complexity of change processes. It is based on two assumptions. First, change processes are non deterministic and unpredictable and therefore, must be regarded as decision making processes which cannot be planned in advance. However, changes can be sometimes performed by analogy to other changes, particularly if they occurred in the same domain (e.g. Air Traffic Control (ATC), electricity distribution, etc.). This supports the belief that it exists a corpus of both generic and domain specific method knowledge (i.e. knowledge on how to proceed for change) that can be looked after, identified and capitalised from experiences. Based on these assumptions, the decision making pattern sets the following objectives: - to give to the EKD engineer the freedom to move forward in a dynamic manner depending on the situation he/she is faced to and the intention he/she wants to achieve, - to provide guidance based on the capitalised generic and specific method knowledge, - to support the decomposition of complex processes. In order to meet these objectives, the decision making pattern: 1. promotes a contextual perspective in decision making where decisions are made with a clear understanding of their organisational context. The contextual approach relies on the notion of context which couples an intention to be achieved by the EKD engineer and the organisational situation which justifies this intention and clarifies the context in which the decision has to be made, 2. offers guidance at three levels: the generic level, the EKD level and the domain specific level. Each corresponds to a specific type of method knowledge. Generic knowledge is characteristic of any decision making process performed following the contextual paradigm. EKD knowledge is typical to the process models defined to work with the EKD concepts and models. Domain specific knowledge is defined at the instance level. Examples of such knowledge are Air Traffic Control knowledge or Command and Control systems development knowledge, (3) supports the view of an iterative and dynamic process. The process is iterative as it results from the repetition of the decision making pattern which is applied iteratively to any situation arising in the process and requiring decisions to be made. Its dynamicity comes from the fact that the EKD engineer is free to dynamically choose the context he/she wants to work on. Therefore, every step corresponds to one application of the EKD decision making pattern and steps are dynamically linked. 2.3. Definition The EKD decision making pattern is a reasoning mechanism supporting decision making using a library of guidelines and an enactment mechanism (see figure 2). The enactment mechanism plays a double role. First, it helps in the retrieval of the appropriated guideline from the library supporting decision making at any stage of the process, i.e. in the current situation at hand as defined in the next paragraph. Second, it is used to guide the decision making according to the selected guideline (see [33] for details). As shown in figure 2, the input and the output of the enactment mechanism are contexts. The decision is made in a given context (the input), may affect the product under development and generate one or more new situations motivating new decisions to be made (the output contexts). The decision making pattern is tailored to provide guidance in all cases. In some cases, the pattern offers a domain specific guidance. This happens when the library contains domain specific knowledge which matches the current context of the EKD process. For instance, the library may contain a guideline in the ATC domain suggesting to decompose the goal "Minimise risk of befalling aircrafts" into the two sub-goals "Maintain separation standards" and "Decrease risk of human errors". If during the process of an air traffic control project the intention of operationalising the goal "Minimise risk of befalling aircrafts" is raised, the library will be able to offer a domain specific guideline. ![Diagram of the EKD decision making pattern](image) **Figure 2: The EKD decision making pattern** The library contains EKD specific guidelines which are tailored to the way the EKD method suggests to work with the different EKD models (see section 2.1). Such guidelines suggest, for instance, different techniques for supporting the emergence of goals, the operationalisation of goals, the classification of goals etc.. These guidelines are independent of any particular domain but are based on EKD method knowledge. Thus, if for example, the current context asks for the classification of a specific goal, the EKD guideline for goal classification can be applied. Finally, if none of the two previous types of guidelines matches the current context of work, the generic guideline may operate. There is one single generic guideline. It is a generic rule for supporting decision making in change processes when neither EKD specific guidelines nor domain specific guidelines apply. Section 3 will illustrate in more details the three types of guidance with the ATC case study. Taking into account the guidance focus of the decision making pattern, we can view the reasoning mechanism offered by the pattern as consisting of two main steps: selecting first, from the library the relevant guideline for the current situation and intention and, then making decision according to the guideline. A guideline may be looked upon as a strategy for decision making in a given situation with an intention in mind. Applying the guideline provides the tactics for decision making. Enacting the tactics leads to actions that may change the product under development and generate new situations and new intentions, i.e. new contexts. Consequently, the decision making pattern can be viewed as suggesting a reasoning loop as shown in figure 3. Starting from an intention motivated by a given situation, a strategy must be selected, then converted into a tactics - which implements the strategy - leading to trigger the execution of actions generating new situations motivating new intentions. ![Figure 3: The reasoning loop](image) The reasoning loop will be exemplified in section 3, when we will illustrate the three types of guidance, together with the usage of this loop. 2.4. Clarifying the concepts used to describe the EKD decision making pattern The EKD decision making pattern is defined at the type level of process modelling (see section 1). We present in this section the concepts (defined at the meta-type level) used to describe the EKD decision making pattern. During this presentation, we follow a bottom up approach starting with the concept of context, moving to the concept of product and its related sub-concepts and ending up with an overall view of the concepts progressively introduced. We will refer to this set of concepts as the process meta-model [12]. The presentation uses an extended binary entity-relationship notation [34], based on entity types, relationship types, cardinalities, "is_a" links and objectified relationship types (an abstraction mechanism allowing us to view a relationship type as an entity type). 2.4.1. The concept of context The key concept underlying the process modelling approach is the one of context. A context is defined as a pair <situation, intention> which couples a given situation and the intention one may wish to fulfil with regards to the situation, the goal. As a matter of fact, most of the time, it is the situation which motivates an intention. For example, it is because the "Paris airport is loosing money" (the current situation) that the goal of "Increasing the number of passenger" is raised. Similarly the "availability of reliable bar-codes" (the situation) suggests to "Change the customer identification of baggage tags" (the goal). In addition, a goal is not sufficient in itself as its interpretation and meaning may vary according to the situation it is associated with. The London airport might have the same goal of "Reorganising the airport in order to increase passenger traffic" but it will be achieved in a totally different way as the situation which raises this goal is that "The airport can afford a larger number of passenger". Acting in a context corresponds to a step in the EKD process. Below are some examples of contexts which introduce our notations. <"The Paris-Roissy Airport is loosing money", Reorganise the airport in order to increase passenger traffic> <"The London Airport can afford a larger number of passenger", Reorganise the airport in order to increase passenger traffic> <Goal G1 "Minimise risk of befalling aircrafts", Operationalise Goal G1 > <Goal G1 "Minimise risk of befalling aircrafts", Define the type for Goal G1 > We note that the same intention can be associated to different situations and conversely, the same situation can be associated to different intentions. The excerpt of the meta-model presented in figure 4 models the notion of context as an objectified relationship type. It is illustrated with the third examples. Figure 4: An example of context Let us detail first the concept of situation which will lead us to introduce the related concept of product. Then, we will detail the concept of intention. 2.4.2. Situation, product and product parts Whilst progressing during the change process, the EKD engineer focuses on different situations. As the EKD process is entirely based on artefacts (the so-called product), all situations which are referred to in the process are built over *product parts*. A *situation* comprises the set of product parts that are relevant for making the decision in the context in hand. For instance, a situation can be made of a single *goal* or a *set of activities*, a *hierarchy of actors*, etc.. all these being parts of the product. This leads to model the relationship *built over* between situation and product part as shown and exemplified in figure 5 and to define the product as *made of* product parts. The product describes the current and/or the desired states of the enterprise. It is modelled in terms of the concepts provided by the various EKD models, and therefore product parts are instances of the concepts of EKD models. Situations can be expressed at different levels of granularity. It can be a single goal like in figure 5 or the entire product. We classify situations as *simple* or *complex*. A simple situation refers to a single element of the product (e.g. a goal) whereas a complex situation is composed of a set of product elements. ![Figure 5: Modelling situations with product part and product](image) **Figure 5**: *Modelling situations with product part and product* Figure 6 is the final view of the situation and product concepts as introduced at this stage. ![Figure 6: The final view on the concepts of situation, product part and product](image) **Figure 6**: *The final view on the concepts of situation, product part and product* 2.4.3. Intention When an EKD engineer considers a situation, he/she does it all the time with some purpose in mind, we say with some intention. An intention is a goal. Note that in this case the goal is not related to the organisation and therefore part of the EKD product but it is a goal of the EKD process. For instance, an engineer may want to operationalise a goal, to create a new goal, to set an issue, etc. "Operationalise goal", "Create a new goal", "Set issue" are intentions. An intention has always a target which describes the expected result of the fulfilment of the intention. Most of the time, the target is implicitly named in the intention. For instance, the target of "Create a new goal" is obviously the goal to be created. Targets are built over product parts. Having to explicitly describe the target of an intention may facilitate the understanding as well as the fulfilment of the intention. This leads to extend the meta-model as shown in figure 7. ![Figure 7: Modelling the intention and its associated target](image) 2.4.4. Overview of the process meta-model Figure 8 depicts the process meta-model as currently defined. It shows the emphasis on the concept of context being a pair <situation, intention>. ![Figure 8: Overview of the process meta-model](image) 3. Three types of guidance applying the decision making pattern We shall describe in this section, how to work with these concepts using the EKD decision making pattern in order to get guidance and support in decision making. We shall focus in turn on the three types of guidance and illustrate the use of the pattern with the same example as an input: the context <Goal G1: "Minimise risk of befalling aircrafts", Operationalise goal G1>. 3.1. Generic guidance This section is devoted to the application of the decision making pattern, pattern for short, using generic guidance. 3.1.1. Using generic guidance As mentioned before, the library of guidelines comprises only one generic guideline that we refer to as the generic method guideline or simply generic guideline. The guideline is applicable in situations where the two other types of guidelines do not hold for fulfilling the input contexts’ intention, i.e. when there is no domain specific guideline available, nor EKD guideline meeting the current situation and intention. The guideline aims to fulfil the intention and is method independent. It proposes three options for progressing in the EKD process: - The do option corresponds to a strait-forward resolution strategy. It should be chosen when the engineer knows exactly what needs to be done in order to fulfil the context's intention. - The choose option corresponds to a resolution strategy which requires the exploration of alternative paths. It should be selected when the engineer thinks about different alternative ways for progressing with regard to the input context but has not make up his/her mind about the one to select. - The plan option follows a planning strategy. The engineer has in mind a plan for achieving the context's intention. In this case, following a divide and conquer tactics, the EKD engineer will progress by building a plan of decisions to be made. The two last options correspond to the classical reduction operator in the problem reduction approach to problem solving [23]. In the following, we exemplify the three options in turn with the example of the context <Goal G1: "Minimise risk of befalling aircrafts", Operationalise goal G1>, according to the steps of the reasoning loop introduced in section 2.3 (figure 3). Case 1: The EKD engineer knows how to proceed to operationalise the goal G1 "Minimise risk of befalling aircrafts" We can assume for example, that he/she has already worked on a similar problem or that a trace of a similar process is available and thus, he/she knows that the way to operationalise the goal is to reduce it into two other goals, G2: "Maintain separation standards" and G3: "Decrease risk of human error". After having selected the do strategy, the EKD engineer is guided towards its implementation. The do strategy corresponds to an input context which we refer to as an executable context, i.e. a context whose intention is directly applicable through design actions implying changes on the product. The generic guideline encapsulates the tactics corresponding to this case. Therefore, the EKD engineer is asked to specify the action(s) to be performed on the product. In our example, the engineer describes (1) the creation of the two goals G2 and G3, and (2) therefore, the EKD engineer is asked to specify the action(s) to be performed on the product. In our example, the engineer describes (1) the creation of the two goals G2 and G3, and (2) the reduction structure expressing that G1 is decomposed into G2 and G3. This is shown in figure 9 together with the extension of the process meta-model related to the specialisation of context into executable context. Enacting the defined tactics consists of executing the action(s) and leads to the modification of the product under development as shown on figure 9. The do strategy is associated to the characterisation of the input context as an executable context. A context is executable when its intention does not need any refinement and can be implemented immediately through actions on the product, i.e. in terms of modifications of the EKD models elements (creation of a goal, a rule, deletion of an element, etc.). Working with the do strategy means that the EKD engineer is able on the spot, to specify the actions which operationalise the process intention and to execute them immediately after. The process is constructed dynamically, the generic guideline helping in identifying the case in hand (the do strategy) and providing the procedure to be followed in this case (specifying actions and their impact on the product). As shown in figure 9, an action can be either simple or complex. A simple action leads to modify a single element in the product whereas a complex action leads to changing several elements of the product and is composed of several simple or complex actions. In our example, the action is complex because it is composed of three simple actions (creation of goal G2, creation of goal G3, and creation of the AND structure). Case 2: The EKD engineer has choices in mind to operationalise the goal G1 "Minimise risk of befalling aircrafts". The EKD engineer selects this strategy when he/she does not have a clear idea on how to deal with the input context, but has in mind different alternative ways of achieving its intention (the one of the input context). However, his/her analysis is not yet deep enough for deciding for the most appropriate one. The input context in this case is called a choice context. Assume in our example that while operationalising the goal "Minimise risk of befalling aircrafts", the engineer hesitates between (1) performing an AND reduction with two goals G2: "Maintain separation standards" and G3: "Decrease risk of human errors" and (2) performing an OR reduction with the same two goals G2 and G3. This is a case where the choose strategy proposed by the generic guideline should be selected. In this case, guidance based on this strategy suggests the following tactics. (1) to define the different alternative ways in terms of contexts. These are, in our example: (2) to express pros and cons arguments for each alternative. These arguments will ground the final decision for the selection of the most appropriate alternative. In our example, the arguments could be: Pro arguments for alternative 1: - Fulfilling both goals would reduce the company insurance fee - G3 must be fulfilled to conform the state law N°1234 -... Pro arguments for alternative 2: - The cost of fulfilling G2 and G3 is too high (according to Mr Smith’s document) - Fulfilling both goals G2 and G3 will make impossible to increase the traffic during summer. -... The final decision is based on the arguments expressed to support or object to the identified alternatives. The output of the step in this case is a new context, the selected alternative context. Assume that the EKD engineer selects the AND reduction (i.e. alternative 1). This leads to generate the context < G1: "Minimise risk befalling aircrafts", Perform AND decomposition with G2: "Decrease risk of human errors" and G3: "Maintain separation standards"> as an output of the process step. In the following step where this context will be the input, the do strategy will be selected (in fact, this context is an executable one) and the step will proceed similarly to what we exemplified for case 1. The end result of this second step will be a modification on the product leading to introduce an AND reduction for goal G1 with G2 and G3 as sub-goals (see figure 9). Figure 10 graphically depicts the extension of the process meta-model required by the introduction of the new type of context, the choice context along with the instances describing our example. The thick black lines between the studied choice context and its alternatives is the graphical convention we used to represent the alternative relationship. Again, in case 2, there exists a relationship between the strategy suggested by the generic guideline and the type of context, the choose strategy being applicable when the context is a choice context. Unlike the executable context (which application is strait forward), the choice context offers several choices, i.e. different ways to achieve the intention the EKD engineer has in mind at this precise point in time. As mentioned in case 1, the EKD process is here again dynamically constructed in a guided manner. Finally, we can notice that two turns in the reasoning loop are necessary in this case to fulfil the initial intention: a first one for refining the intention and a second one for implementing the refined intention by executing the consequent actions on the product. ![Figure 10: Choose strategy and choice context](image) **Case 3:** The EKD engineer realises that the fulfilment of the current context's intention requires the definition and the implementation of a plan of decisions. The so-called plan strategy is selected when the achievement of the intention requires a composite decision making process but that is made up in the mind of the EKD engineer. In the example at hand, this case could correspond to a situation where the engineer has several hypotheses for reducing the goal "Minimise risk befalling aircrafts". He/she needs to set up and think about before being able to decide. His/her position is more confuse than in case 1 and even case 2, but he/she can built a plan for supporting his/her decision making. The type of context associated to this strategy is called a *plan context*. In this case, several stages of decision making must be followed. Assume that the EKD engineer has no clue on how to operationalise the goal G1: "Minimise risk befalling aircrafts". The guidance provided by the plan strategy of the generic guideline suggests the following *tactics*: (1) identify the different hypotheses he/she can think of, and express them using contexts. These are for our example: < G1: "Minimise risk befalling aircrafts", Identify Hypothesis H1: "Maintain separation standards"> < G1: "Minimise risk befalling aircrafts", Identify Hypothesis H2: "Decrease risk of human error"> < G1: "Minimise risk befalling aircrafts", Identify Hypothesis H3: "Limit the number of aircrafts allowed to cross controlled airspace"> (2) express the arguments for and against each hypothesis. This is again expressed using contexts: < G1: "Minimise risk befalling aircrafts", Express positive arguments for H1: "We have had accidents due to separation standard violations"> < G1: "Minimise risk befalling aircrafts", Express positive arguments for H2: "We have had accidents due to controller misjudgements"> < G1: "Minimise risk befalling aircrafts", Express positive arguments for H3: "We have had accidents due to heavy traffic in the controlled airspace"> < G1: "Minimise risk befalling aircrafts", Express negative arguments for H3: "Air traffic increased a lot during summer"> (3) define the appropriate goal reduction: < G1: "Minimise risk befalling aircrafts", Define the appropriate reduction for G1 as G2: "Maintain separation standards" AND G3: "Decrease risk of human error"> The output of this reasoning loop is a context (< G1: "Minimise risk befalling aircrafts", Define the appropriate reduction for G1 as G2: "Maintain separation standards" AND G3: "Decrease risk of human error">) which is the input of the following loop. As this context is an executable one, its enactment will proceed as presented in case 1 or shall lead to change the product by creating the two goals G2 and G3 and relating them to G1 with AND reduction links. Figure 11: Plan strategy and plan context Figure 11 graphically depicts the extension of the process meta-model required to support the plan strategy along with the instances describing our example. The rake is used to graphically represent the "composed of" relationship between the studied plan context and its components. The plan context corresponds to a well-known approach in strategic decision making which is "state a plan and then execute the plan" [35]. Again, this is made here in a dynamic and guided manner. The EKD engineer working in a plan context will state the components of the plan he/she has in mind as new contexts and will enact them immediately after. 3.1.2. Remarks First, it should be noted that the use of generic knowledge presented here corresponds to the weakest mode of guidance, it is the default mode and is suggested when there is no possibility of using neither EKD knowledge nor domain specific knowledge. In fact, the generic knowledge consists of using the process meta-model as a shell for structuring the way of progressing through the EKD process in a situation and intention oriented manner. Second, we would like to stress the difference between the process and the product. We deliberately used the same example of context <Goal G1: "Minimise risk of befalling aircrafts", Operationalise goal G1> to demonstrate how the different strategies can be applied. In each case, the resulting product is identical, it consists in creating an AND reduction structure for the goal G1, with G2 and G3 as sub-goals. However, the process followed in each case is different and this can be recorded in the process trace. In the first case, following the do strategy, there was no hesitation at all from the EKD engineer. In the second case, following the choose strategy, the process required two turns in the reasoning loop, one for deciding how to proceed and the second one to do. The do part is the same in case 1 and in case 2 but the process trace in case 2 will record, in addition, the fact that the engineer envisioned two alternative ways of proceeding for the reduction of goal G1. The process trace keeps track, in this case, of the alternatives considered, the arguments expressed, and the alternative chosen. In the third case, following the plan strategy, the process trace shows the process that has been followed: the description of plan set by the engineer including the set of possible hypotheses he/she envisaged, the set of arguments and their relations with the hypotheses, and the selected reduction he/she came up with. Process traces are different in each case even if the resulting product is identical. Keeping track of the process is useful for re-use in similar but different applications. In fact, domain specific knowledge will be extracted from process traces using, for instance, a case based learning approach [26]. Furthermore, the examples also bring out the analogy between the structure of the EKD process goals (we call them intentions for avoiding confusion) and the structure of the business goals in the product (described in the EKD goal model). In both cases, goals are reduced with either an AND or an OR structure or are directly implementable - through executable contexts and actions for the process and operationalised goals for the product. 3.1.3. Revising the process meta-model The figure 12 summarises the different concepts completing the version of the process meta model we presented in figure 8. The new elements are in bold face. The different types of contexts, namely executable, choice and plan context, are modelled as sub-types of the concept of context and therefore share the same structure <situation, intention>. The different components (respectively alternatives) of a plan context (respectively choice context) are contexts too. This provides the means to construct hierarchies of contexts which are necessary to represent complex decision based processes. It may be argue that this process meta model is complex, or event too complex. However, the following principle is at the core of several machine learning system [17]: "The more knowledge at the meta level, the more knowledge based guidance can be provided to acquire requirements fragments at the domain level." ![Figure 12: The revised process meta-model](image-url) 3.1.4. Formalising the generic method guideline As illustrated previously, the generic method guideline offers three different working strategies (to do, to choose and to plan) to help the EKD engineer when neither EKD nor specific guidance is applicable to fulfil an intention in a given situation. The reader understands that we advocate a formal representation of the generic guideline based on the process meta-model. In fact, our proposal is for a representation of all method guidelines in the library using the concepts of the process meta-model as defined now in figure 12. Figure 13 visualises the generic guideline as a choice context using our graphical notations. The three strategies are the three choices proposed by the context together with their related arguments. The guidance provided by the generic guideline can be simply summarised by three questions to the EKD engineer: - Is your intention operationalisable through design actions? - Can you set alternative ways for fulfilling your intention? - Do you need a plan for making your mind and achieve your intention? The generic guideline has a fourth strategy which is dedicated to the modelling of co-operative processes and is not discussed in this paper: "Brainstorm during a co-operative session". This strategy led us also to perform several extensions on the meta-model. Those aspects were developed in [24]. **Figure 13: Representing the generic knowledge with a choice context** The alternative contexts shown in figure 13 are executable contexts whose associated actions guide the EKD engineer in doing things according to the option he/she chose. 3.2. EKD guidance EKD guidance is based on EKD knowledge, i.e. knowledge specific to the EKD method for supporting EKD engineers to specifically undertake the change process in an organisation using the EKD models. Using this type of knowledge allows us to considerably speed up EKD processes because it concentrates on the resolution of EKD specific problems. The quality of guidance is very high specially when supported by a tool environment [11]. 3.2.1. Modelling EKD Knowledge The EKD knowledge supports for example, the construction of the different models representing the initial enterprise state as well as the future enterprise state of the organisation, the expression of alternative strategies for change, the evaluation of these strategies, as well as other kinds of activity such as brainstorming, co-operative work, etc.. Section 4 introduces a wide variety of EKD guidelines and details some of them. We express this knowledge as we did for the generic knowledge, i.e. using the process meta-model and the different types of context, namely executable, plan and choice contexts. However there is one major difference: the EKD knowledge is expressed at the type level i.e. the level of specific classes of EKD concepts such as "Identifying goals", "Operationalising goals", "Finding design models meeting specific goals" etc.. The type level is distinct from the instance level where one speaks of a specific goal or of a specific design model. It has also, to be differentiated from the meta-level dealing with generic concepts such as "product part" and "intention". The so-called generic knowledge is at the meta-level whereas the EKD knowledge is at the type level. As an example, let us assume that the reasoning followed for operationalising the goal "Minimise risk of befalling aircraft" - where hypotheses and arguments have been expressed first, followed by the definition of the appropriate reduction - was observed in similar forms in different change processes. The experience gained by the EKD engineers suggests a generalisation of the plan followed (depicted in figure 11, section 3.1.1) into an EKD guideline expressed at the type level with a plan context having a goal G as situation and "Operationalise goal G" as intention. Associated to this plan context is a set of component contexts for describing the different decisions to be made in order to fulfil the intention "Operationalise goal G". The guideline is expressed at the type level as it does not deal with a specific situation (a specific company goal) and a specific intention, but a class of situations (the class of company goals) and a class of intentions (the set of "Operationalise goal" intentions). As it is expressed at the type level, this plan can be re-used in many contexts: all the contexts dealing with the operationalisation of a goal. Figure 14 graphically depicts the guideline obtained by generalisation of the plan stated in case 3, section 3.1.1. The bottom of figure 14 depicts also what we call a dependency graph. This graph should be defined for each plan context in the EKD method base. It provides information about the various possible ordering paths for decision making within the plan. This information is helpful for providing more advanced guidance as it offers more flexibility in the process of decision making than the usual sequential ordering of steps. The dependency graph permits to describe iteration, backtrack as well as parallelism. Concerning the operationalisation of a goal, the graph suggests to iterate on hypotheses identification until all of them have been identified (argument A1), then to iterate on argument expression (argument not A3). Note that at this point it is possible to resume hypothesis identification and to go back and forth between the two contexts. The plan ends with the definition of the appropriate decomposition of goal G. ![Figure 14: An EKD guideline for operationalising a goal](image) The EKD knowledge can be re-used for decision based guidance in many different change processes within different companies. An EKD guideline is re-usable any time the situation type matches elements of a specific design product and the intention type matches the current intention of the EKD engineer. ### 3.2.2. Using EKD guidance The way EKD knowledge is used within the EKD decision pattern is similar to what we have illustrated for the generic guidance. The main difference lies in the retrieval of the guideline. The retrieval of an EKD guideline is based on pattern matching. Assuming that the engineer has chosen the input context, he/she has to select an EKD guideline where (1) the situation type matches the input context's situation and (2) the intention of the guideline matches the input context's intention. This selection is facilitated by the use of a software tool [11]. The remaining part of the reasoning loop associated to the application of the EKD decision making pattern is similar to what we presented for using the generic knowledge but the EKD engineer is more guided: - the tactics is provided by the EKD guideline. However, in this case, the EKD engineer is only required to instantiate the guideline. He/she does not have to find himself/herself the way of resolving the issue he/she is faced to, but he/she is just required to follow the predefined resolution approach provided by the guideline. If the guideline is a choice context, the EKD engineer will have to instantiate the alternative contexts whereas he/she will do the same for the component contexts of a plan; he/she does not have any thing to do at this stage if the context is executable. the enactment is identical to what we presented earlier. The EKD engineer makes decisions according to the pre-defined tactics, i.e. selecting the most appropriate alternative based on the arguments provided by the guideline in case of a choice context; selecting the adequate path in the precedence graph to execute a plan context and performing the action(s) of an executable context to modify the design product accordingly to the decision made. Let us demonstrate the use of EKD guidance in the case of our example with the context <Goal G1 "Minimise risk befalling aircrafts", Operationalise Goal G1>. The context matches the situation and decision of the guideline depicted in figure 14. The instantiation of the predefined component contexts is illustrated in figure 15. The enactment is identical to what was presented in section 3.1.1 (case 3). In fact, the guideline shown in figure 15 was obtained by generalising the plan context that has been previously constructed using the generic guidance. ![Figure 15: Instantiating the EKD guideline depicted in figure 3.14](image) By following the heuristical knowledge embedded in the EKD guideline, the engineer is constantly guided. Part of the solution he/she has to find is provided by the guideline. Suggestions are made on the alternative strategies he/she can follow, pre-defined arguments supporting or objecting to these strategies are provided, predefined plans he/she can use for reaching his/her decision are ready-made, he/she is told what to do next, etc.. 3.3. Domain specific guidance *Domain specific guidance* is based on *domain specific knowledge*. The domain specific knowledge aims at providing guidance to EKD engineers for solving very well focused problems related to a specific domain. It is grounded on experience based knowledge and suggests to re-use and to adapt concrete and already tested solutions which have shown their efficiency and feasibility in different organisational settings of the same domain. The benefits of using this type of knowledge is that it considerably shortens the decision process of solving domain specific problems by offering ready to use solutions. 3.3.1. Modelling domain specific knowledge For instance, in the context of air traffic control, domain specific knowledge could suggest that the operationalisation of the goal G1: "Minimise risk of befalling aircraft" can be achieved in two alternative ways. It can be either a decomposition of G1 into two complementary goals G2: "Maintain separation standards" and G3: "Decrease risk of human error" or a decomposition with G3 and G4: "Limit the number of aircrafts allowed to cross controlled airspace". Similarly to generic and EKD knowledge, domain specific knowledge is captured in guidelines expressed as hierarchies of contexts of the three different types. However, domain specific knowledge is described at the instance level. It deals with process intentions related to concrete facts such as the intention of operationalising the airport goal of "Minimising the risk of befalling aircraft" or the intention of modelling the design solution based on "the identification of customers' baggage using bar-codes". Figure 16 depicts the guideline related to the operationalisation of the goal G1 as introduced above. In addition to the two alternative contexts describing the two ways of operationalising the goal "Minimise risk of befalling aircrafts", an argument is provided (A1) to help the selection of the most appropriate alternative. Figure 16: An example of a domain specific guideline 3.3.2. Using domain specific guidance The use of domain specific knowledge within the EKD decision making pattern is very close to what has been presented in 3.2 for EKD guidance. The difference lies in the fact that domain specific guidelines are defined at the instance level and therefore do not have to be instanciated while being used. The reasoning loop starts with the retrieval of the domain specific guideline matching the input context. This can be made manually by the EKD engineer who browses the library and looks for a guidelines where the situation is the input context's situation and the intention is the input context's intention. It is more easily made with the use of the EKD tool environment which could realise the matching automatically [11], this has not been implemented yet. If there exists a guideline that matches, the EKD engineer can decide to use it. The guideline provides tactics for fulfilling the intention. The engineer has just to implement the them. Let us reconsider our example with the input context <Goal G1 "Minimise risk of befalling aircrafts", Operationalise Goal G1>. Because this context is the same than the top context of the domain specific guideline depicted in figure 16, this guideline can be selected by the engineer. Enacting the guideline consists in studying the two suggested alternatives, evaluating the argument - that is to find out if "the rate of human errors is bellow the international norm N°1234" and then, selecting the alternative he/she believes to be the most appropriate. Assume the airport has a high rate of human errors, therefore the engineer chooses the alternative suggesting to perform an AND reduction on goal G1 with the two goals G2: "Decrease risk of human errors" and G3: "Maintain separation standards". This alternative is an executable context and its associated action precisely describes how to modify the design product in order to get the adequate reduction for goal G1 in the product. 4. EKD guidelines overview As presented in section 3, guidelines are modelled with our process meta-model in terms of contexts and trees of contexts. Besides they are clustered in three classes: (1) The generic guideline, (2) EKD guidelines, (3) Domain specific guidelines. As highlighted in section 3, each class of guideline is used by the decision making pattern to provide a specific type of guidance (generic guidance, EKD guidance and domain specific guidance, respectively). This section aims (1) to present a brief overview of the EKD guidelines and (2) to demonstrate the use of some of them. 4.1. The EKD guidelines matrix We use a matrix presentation to overview the collection of EKD guidelines. These guidelines are the matrix elements. The columns of the matrix are intentions which arise during the EKD process. "Operationalise goal", "Classify goal" "Identify goal" are examples of such intentions. For the sake of readability, we use only intention names whereas of the full context heading, i.e. a situation name + an intention name, is really meant. 5 main intentions are identified: (1) Model the current enterprise state, (2) Acquire goal, (3) Operationalise goal, (4) Generate design models, (5) Validate design models. Some of them are decomposed in a number of sub-intentions which are visualised in the matrix as sub-columns. The rows of the matrix are techniques used in the guidelines. The same technique can be used in different ways in different guidelines. For example, SWOT analysis is a technique which might be used for satisfying the intention of "Analyse the context of change" and for "Argument reduction (of a goal)" as well. The matrix of figure 17 summarises how techniques are embedded in EKD guidelines to support the various EKD process intentions. As we have seen in section 3.2.1, the EKD guidelines presented in the matrix are domain independent. They can support the construction of the EKD Models for a given company, the expression of alternative strategies for change, brainstorming activities, etc.. The knowledge embedded in the EKD guidelines is expressed using the process meta-model developed in section 3.1. These guidelines can be re-used for decision based guidance in different change processes within different companies. <table> <thead> <tr> <th>Context</th> <th>(1) Model the current enterprise state</th> <th>(2) Acquire goal</th> <th>(3) Operationalise goal</th> <th>(4) Generate design model</th> <th>(5) Validate design model</th> </tr> </thead> <tbody> <tr> <td>EM construction strategy</td> <td>21</td> <td>5</td> <td>12</td> <td>22</td> <td>30</td> </tr> <tr> <td>SWOT analysis</td> <td>2</td> <td>15</td> <td>22</td> <td></td> <td></td> </tr> <tr> <td>Categorizer</td> <td>3</td> <td>10</td> <td>22</td> <td>30</td> <td></td> </tr> <tr> <td>Goal typology</td> <td>6</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pair-Wise comparison</td> <td>7</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Theorem proof</td> <td>8</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Do/Choose/Plan strategies</td> <td>9</td> <td>13</td> <td>19</td> <td>22</td> <td></td> </tr> <tr> <td>Goal template</td> <td>14</td> <td>18</td> <td>22</td> <td></td> <td></td> </tr> <tr> <td>Brainstorming strategy</td> <td>11</td> <td>17</td> <td>24</td> <td></td> <td></td> </tr> <tr> <td>Graph construction strategy</td> <td>20</td> <td>25</td> <td></td> <td></td> <td></td> </tr> <tr> <td>View models</td> <td>21</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Scenario</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Argument based reasoning</td> <td>26</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Process trace</td> <td>27</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Cost/resource evaluation</td> <td>28</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Agent Dependency model</td> <td>29</td> <td>31</td> <td></td> <td></td> <td></td> </tr> </tbody> </table> **Figure 17: The EKD guidelines** ### 4.2. Illustrating the set of guidelines supporting the "Classify goal" intention This section presents the set of guidelines provided for classifying goals. Goal classification occurs after goal acquisition. The aim of the classification is to produce some partial views of the problem, each category focusing on different aspects of change and thus conforming to different needs. By doing so, the different stakeholders are able to concentrate on different facets of change separately and to improve their overall understanding of the problem, this leading to the possible identification of new goals. Goal classification leads to organise goals into coherent clusters. Four guidelines are available for the intention "Classify goal". The first one does not suggest to use any pre-defined category [19] whereas the two others are based on existing categories proposed in the literature [5], [1], and are relevant for classifying goal in the context of supporting the change process in an organisation. We present these guidelines in turn and illustrate how they provide guidance through some examples. 4.2.1. Classifying goals with user defined categories According to [19], goal classification based on user defined categories is relevant for handling changes and for structuring a complex domain with users defined views. Guiding such a classification is supported by the guideline depicted in figure 18. The top context is: \(<(\text{Goal } G + \text{ a set of user defined categories}), \text{ classify } G\>). The situation comprises a goal G and a set (possibly empty) of already defined categories. The guideline suggests to follow a plan having two components: (1) to start by defining the appropriate category and (2) to place the goal in the category. However, as shown on the dependency graph, it is possible to directly place the goal being studied in an existing category (if A3 is true). Furthermore, after having categorised a goal, it may be necessary to re-organise categories if one category contains too many goals (if A2 is true). In this case, the engineer is guided to define sub-categories and then re-organising the classification scheme. Finally, a goal can belong to several categories, the EKD engineer is guided towards multiple classification thanks to the loop put on context \(<(\text{Goal } G + \text{ a set of categories } C), \text{ Place } G \text{ in } C\)> (if A4 is true). Let us consider that the goal acquisition phase has led to the emergence of the following list of goals: (G1) Improve air-traffic flow, (G2) Reduce demands placed on controllers, (G3) Minimise risk of befalling aircrafts, (G4) Reduce delays, (G5) Reduce noise, (G6) Reduce fuel consumption. Assuming that no category has been defined so far, classifying goal G1 "Improve air-traffic flow" would be guided as follows. First, category definition is asked (because A3 is false), this leads to the identification of the "Efficiency" category. Then, the guideline suggests to place G1 in a category, i.e. "Efficiency". Similarly, goal G2 is placed in two new categories called "Controller" and "Safety". The classification of goal G3 leads to directly place it in the existing "Safety" category. Similarly, goals G4 and G5 are put in the existing category "Efficiency". While classifying goal G6, the EKD engineer is suggested to refine the category "Efficiency" and is guided towards the identification of more specialised categories, such as "Cost efficiency", "Noise efficiency", etc. 4.2.2. Classifying goals following a behaviour oriented classification The following guideline is based on the classification proposed in [5]. This classification suggests to cluster goals according to the impacts they have on the set of possible behaviours of the system. Five categories are advocated: Achieve, Cease, Maintain, Avoid and Optimise. Achieve and Maintain generate behaviours, Cease and Avoid restrict behaviours, whereas Optimise compares behaviours. The guideline suggests to study five alternatives for classifying a goal with regards to its impacts of the system behaviour. The different arguments provided for each alternative shall be carefully studied. Indeed, arguments are provided to help in the selection of the most appropriate one. Each alternative context is an executable context, its associated action adds the corresponding category to the goal description. Let us apply this guideline to the goal "No passenger should miss his/her correspondence". Let us assume that, after a careful study of the different arguments, the EKD engineer decides that the argument 3 applies, i.e. "this goal must be fulfilled all the time in the future. The enactment of the corresponding alternative adds the category "Maintenance goal" to the description of the goal "No passenger should miss his/her correspondence". 4.2.3. Classifying goals into private goals and different types of system goals This guideline advocates to distinguish between private goals and system goals and to refine systems goals. It is based on the classification proposed in [5]. Private goals are goals that might be achieved by the system. System goals are application specific goals that must be achieved by the system. Furthermore, several sub-categories have been defined for system goals, namely, Satisfaction goals, Information goals, Robustness goals, Consistency goals, Safety goals and Privacy goals. Satisfaction goals are concerned with satisfying agent requests. Information goals are concerned with getting agents informed about object states. Robustness goals are concerned with recovering from foibles of human agents or from breakdowns of automated agents. Consistency goals are concerned with maintaining the consistency between the automated and physical part of the system. Safety goals and Privacy goals are concerned with maintaining agents in states which are safe and observable under restricted conditions respectively. The guideline embedding such a knowledge is depicted in figure 20. The top level context is a choice context with two alternatives, each alternative corresponding to respectively private and system goals. The context <Goal G, Classify G as system goal> is a choice context. It has six alternatives, each one related to one of the categories we just mentioned. Indeed, arguments are provided for each alternative, they are based on the definition of each goal category. All the other contexts depicted in figure 20 are executable contexts, their actions add a category to the goal described in the situation. Let us take two examples showing how guidance can be provided by this guideline. We first consider the goal "Maintain safe transportation". The guideline suggests to decide if the goal must or might be fulfilled. Evidently, this goal must be fulfilled. Therefore the alternative <Goal "Maintain safe transportation", Classify as System goal> is selected. Then, the guideline suggests to consider the arguments of the six alternatives and to decide on those applicable. In our example, it is clear that argument 7 applies (Goal G is concerned with maintaining agents in a safe state. Therefore, the context <Goal "Maintain safe transportation", Classify as Safety goal> is selected. As this context is an executable context, its enactment leads to automatically add two categories to the goal "Maintain safe transportation": "System" and "Safety". Let us now consider the goal "Avoid plane departure delay". As a matter of fact, plane departure delay may be due to several unpredictable and external causes (the plane is not ready for taking off, the captain is not arrived on time, etc.) and therefore its fulfilment cannot be insured. Having taken into account these consideration, the EKD engineer decides to select the first alternative of the top choice context: the context <Goal "Avoid plane departure delay", Classify as Private goal>. As this context is an executable context, its enactment leads to add the "Private" category to the goal "Avoid plane departure delay". 5. Conclusion This paper advocates for effective guidance to conduct enterprise knowledge modelling and enterprise change management. To this end, we propose: - An intention based framework for describing guidelines for constructing enterprise models expressed in a process meta-model, - A repository of guidelines described as method guidelines at three levels of abstraction: domain specific guidelines, EKD guidelines and a generic guideline that shall be used when no other type of guideline is applicable, - A decision making pattern using the repository of guidelines and an enactment mechanism, - A tool implementing the decision making pattern comprising EKD guidelines [11], - An electronic guidebook providing a set of guidelines to understand the EKD method and to guide stakeholders involved in the change process to manage it [25]. The process meta-model allows us to deal with many different situations in a flexible, decision-oriented manner [28], [24]. Moreover, it can support different levels of granularity in decision making as well as non-determinism in process performance. It identifies a decision in context as the basic building block of process models and permits their grouping into meaningful modules. Parallelism of decisions and ordering constraints are also supported. The decision making pattern is tailored to provide guidance in all cases. In some cases, the pattern offers a domain specific guidance. This happens when the library contains knowledge about the domain of the project which matches the current context of work. The library contains EKD specific guidelines which are tailored to the way the EKD method 2 http://www.univ-paris1.fr/CRINFO/EKD-CMMRoadMap suggests to work with the different EKD models. These guidelines are independent of any particular domain but are based on EKD method knowledge. Finally, if none of the two previous types of guidelines matches the current context of work, the generic guideline may operate. It is the default option in some sense. Clearly, making guidance more specific increases its efficiency. However, the generic guideline, by offering a general frame for decision making, makes the EKD process entirely based on guidance. Taking into account the guidance focus of the decision making pattern, we can view the reasoning mechanism offered by the pattern as consisting of two main steps: selecting first, from the library the relevant guideline for the current situation and intention and, then making decision according to the guideline. To sum-up, the EKD process model suggests an incremental production of the enterprise knowledge description. It has two major advantages: it makes change traceable and it helps stakeholders in the change process to share awareness by making the product under construction being discussed, visible and explicit. The result of this work has been effectively used in the context of the ELEKTRA project (ESPRIT project No 22927) for handling the change in electricity companies due to the deregulation rules set by the E.C. The EKD guidelines have been used to produce part of the models describing both the current state and some future states of two electricity companies (see [22] for details). Furthermore, in this context, domain specific guidelines have been expressed following the proposed framework as change process patterns [27], [32]. References <table> <thead> <tr> <th>FIG.</th> <th>Legend</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>1</td> <td><em>EKD models</em></td> <td></td> </tr> <tr> <td>2</td> <td>The EKD decision making pattern</td> <td></td> </tr> <tr> <td>3</td> <td>The reasoning loop</td> <td></td> </tr> <tr> <td>4</td> <td>An example of context</td> <td></td> </tr> <tr> <td>5</td> <td>Modelling situations with product part and product</td> <td></td> </tr> <tr> <td>6</td> <td>The final view on the concepts of situation, product part and product</td> <td></td> </tr> <tr> <td>7</td> <td>Modelling the intention and its associated target</td> <td></td> </tr> <tr> <td>8</td> <td>Overview of the process meta-model</td> <td></td> </tr> <tr> <td>9</td> <td>Do strategy and executable context</td> <td></td> </tr> <tr> <td>10</td> <td>Choose strategy and choice context</td> <td></td> </tr> <tr> <td>11</td> <td>Plan strategy and plan context</td> <td></td> </tr> <tr> <td>12</td> <td>The revised process meta-model</td> <td></td> </tr> <tr> <td>13</td> <td>Representing the generic knowledge with a choice context</td> <td></td> </tr> <tr> <td>14</td> <td>An EKD guideline for operationalising a goal</td> <td></td> </tr> <tr> <td>15</td> <td>Instantiating the EKD guideline depicted in figure 14</td> <td></td> </tr> <tr> <td>16</td> <td>An example of a domain specific guideline</td> <td></td> </tr> <tr> <td>17</td> <td>The EKD guidelines</td> <td></td> </tr> <tr> <td>18</td> <td>The guideline for classifying a goal using user defined categories</td> <td></td> </tr> <tr> <td>19</td> <td>The guideline for behaviour oriented classification</td> <td></td> </tr> <tr> <td>20</td> <td>The guideline differentiating private and system goals and refining system goals</td> <td></td> </tr> </tbody> </table>
{"Source-Url": "https://hal.archives-ouvertes.fr/file/index/docid/707096/filename/IS_T_selmin_.pdf", "len_cl100k_base": 14301, "olmocr-version": "0.1.53", "pdf-total-pages": 32, "total-fallback-pages": 0, "total-input-tokens": 84037, "total-output-tokens": 17320, "length": "2e13", "weborganizer": {"__label__adult": 0.00045371055603027344, "__label__art_design": 0.0022754669189453125, "__label__crime_law": 0.0005478858947753906, "__label__education_jobs": 0.02716064453125, "__label__entertainment": 0.00023627281188964844, "__label__fashion_beauty": 0.00036454200744628906, "__label__finance_business": 0.0106201171875, "__label__food_dining": 0.000484466552734375, "__label__games": 0.0012149810791015625, "__label__hardware": 0.0014410018920898438, "__label__health": 0.0006918907165527344, "__label__history": 0.0010318756103515625, "__label__home_hobbies": 0.0003762245178222656, "__label__industrial": 0.00247955322265625, "__label__literature": 0.0011796951293945312, "__label__politics": 0.0005440711975097656, "__label__religion": 0.0007014274597167969, "__label__science_tech": 0.251220703125, "__label__social_life": 0.0002276897430419922, "__label__software": 0.041015625, "__label__software_dev": 0.65380859375, "__label__sports_fitness": 0.0003952980041503906, "__label__transportation": 0.00107574462890625, "__label__travel": 0.00031685829162597656}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 73689, 0.02608]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 73689, 0.50742]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 73689, 0.90926]], "google_gemma-3-12b-it_contains_pii": [[0, 1001, false], [1001, 3343, null], [3343, 6283, null], [6283, 9112, null], [9112, 11310, null], [11310, 13803, null], [13803, 16435, null], [16435, 18727, null], [18727, 20389, null], [20389, 21683, null], [21683, 24080, null], [24080, 26539, null], [26539, 29324, null], [29324, 31471, null], [31471, 33615, null], [33615, 35550, null], [35550, 37954, null], [37954, 39870, null], [39870, 43292, null], [43292, 45241, null], [45241, 47063, null], [47063, 49438, null], [49438, 52595, null], [52595, 54948, null], [54948, 57505, null], [57505, 58841, null], [58841, 60917, null], [60917, 63741, null], [63741, 67006, null], [67006, 71009, null], [71009, 71721, null], [71721, 73689, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1001, true], [1001, 3343, null], [3343, 6283, null], [6283, 9112, null], [9112, 11310, null], [11310, 13803, null], [13803, 16435, null], [16435, 18727, null], [18727, 20389, null], [20389, 21683, null], [21683, 24080, null], [24080, 26539, null], [26539, 29324, null], [29324, 31471, null], [31471, 33615, null], [33615, 35550, null], [35550, 37954, null], [37954, 39870, null], [39870, 43292, null], [43292, 45241, null], [45241, 47063, null], [47063, 49438, null], [49438, 52595, null], [52595, 54948, null], [54948, 57505, null], [57505, 58841, null], [58841, 60917, null], [60917, 63741, null], [63741, 67006, null], [67006, 71009, null], [71009, 71721, null], [71721, 73689, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 73689, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 73689, null]], "pdf_page_numbers": [[0, 1001, 1], [1001, 3343, 2], [3343, 6283, 3], [6283, 9112, 4], [9112, 11310, 5], [11310, 13803, 6], [13803, 16435, 7], [16435, 18727, 8], [18727, 20389, 9], [20389, 21683, 10], [21683, 24080, 11], [24080, 26539, 12], [26539, 29324, 13], [29324, 31471, 14], [31471, 33615, 15], [33615, 35550, 16], [35550, 37954, 17], [37954, 39870, 18], [39870, 43292, 19], [43292, 45241, 20], [45241, 47063, 21], [47063, 49438, 22], [49438, 52595, 23], [52595, 54948, 24], [54948, 57505, 25], [57505, 58841, 26], [58841, 60917, 27], [60917, 63741, 28], [63741, 67006, 29], [67006, 71009, 30], [71009, 71721, 31], [71721, 73689, 32]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 73689, 0.10811]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
851b30cda965df73cc3d226ed1ab585cdfbc52bb
Mining Subclassing Directives to Improve Framework Reuse Marcel Bruch, Mira Mezini, Martin Monperrus To cite this version: Marcel Bruch, Mira Mezini, Martin Monperrus. Mining Subclassing Directives to Improve Framework Reuse. Proceedings of the 7th IEEE Working Conference on Mining Software Repositories, 2010, Cape Town, South Africa. 2010, <10.1109/MSR.2010.5463347>. <hal-01575347> HAL Id: hal-01575347 https://hal.archives-ouvertes.fr/hal-01575347 Submitted on 20 Sep 2018 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Mining Subclassing Directives to Improve Framework Reuse Marcel Bruch Mira Mezini Martin Monperrus Darmstadt University of Technology {bruch,mezini,monperrus}@st.informatik.tu-darmstadt.de Abstract—To help developers in using frameworks, good documentation is crucial. However, it is a challenge to create high quality documentation especially of hotspots in white-box frameworks. This paper presents an approach to documentation of object-oriented white-box frameworks which mines from client code four different kinds of documentation items, which we call subclassing directives. A case study on the Eclipse JFace user interface framework shows that the approach can improve the state of API documentation w.r.t. subclassing directives. I. INTRODUCTION Object-oriented frameworks are a great vehicle in supporting code reuse [11], [5]. White-box frameworks are those frameworks that use inheritance, i.e. application-specific code consists of subclasses of framework classes [18]. White-box frameworks, while very flexible, are difficult to learn and use [6], [15], [14]. For example, instantiating the JFace white-box framework to program a user interface requires that the developer identifies the right classes to extend among 203 available public classes and that she correctly overrides methods among 20 overridable methods per class in average. To help developers in using frameworks good documentation is crucial. However, it is a challenge to create high quality documentation for white-box frameworks [1], especially given the complexity of today’s frameworks [8]. As a result, framework users often miss the correct piece of documentation as recently shown by Robillard [14]. The documentation of object-oriented frameworks may contain different kinds of information [5]: high-level description of the architecture (e.g., used design patterns and class diagrams), information about what the code does, code snippets, directives stating how to use framework classes or methods, etc. This paper focuses on directives stating how to use the framework. More specifically, we use the term “subclassing directive” to designate pieces of documentation related to how to subclass a framework class or how to override a framework method. We present an approach to improve the quality of “subclassing directives” of white-box frameworks. The core idea is that subclassing directives can be reverse-engineered from application-specific code (called in this paper client code), i.e. that how-to-use documentation of a particular software artifact can be inferred from how it is actually used. Bloch [1] (Item 17, pp. 87-92) urges developers of extensible classes to test them by writing subclasses before delivering them, arguing that it is the actual extensions of a base class that reveal the relevant hotspots and not only those that are exposed and documented. This fits with our intuition that actual usages found in existing clients are a good source for mining subclassing directives. These mined directives can be used by developers of new clients as a complementary source of information in addition to the API documentation delivered with the framework. They can also be used by framework developers who can peruse the list of inferred subclassing directives to eventually identify incorrect or incomplete documentation, to update the existing documentation, and improve the quality of framework subclassing directives. An directive may be incorrect if its formulation clashes with actual usages. For instance, a method that is documented as Subclasses may override whereas 100% of client code do override it, is probably incorrect. Documentation is incomplete when some directives are not documented at all: for instance our approach finds directives of the form Subclasses may override, but must call the super implementation (100% of client code does so) which are not documented in the API documentation. More specifically, our contributions are as follows: 1) We propose four different kinds of subclassing directives and present arguments for them. We show that they are complementary and that having just one or the other is not sufficient. We argue that when developers do not have this information they lose time in understanding how to use a framework or in solving a bug related to a violation of an undocumented directive. 2) We present an approach to mine framework subclassing directives from client code. We present one mining technique per proposed subclassing directives. Three of these techniques are based on metrics gathered from client code, the fourth one is based on a machine learning clustering algorithm. 3) We present a case-study to validate the proposed approach. The subject of the case study is the Eclipse JFace framework, a powerful, open-source, and industry-proven framework developed by IBM. This case study shows that our approach improves both the correctness and the completeness of subclassing directives present. A subclassing directive is a piece of documentation stating how to subclass a framework class. They can be of different kinds. In this paper, we claim that the documentation of white-box frameworks requires four types of subclassing directives. In the following, we define them and give rationales for having each of them by discussing possible consequences if they are missing or if developers overlook them. A. Method Overriding Directives To instantiate a white-box framework, the developers need to know which framework classes are designed to be subclassed and which methods therein are designed to be overridden in an application-specific manner. A method overriding directive is a piece of documentation stating whether a framework method is designed to be overridden by client code. A class is documented as designed for subclassing if it contains at least one method overriding directive. Method overriding directives are part of Johnson’s patterns to document frameworks [6], as shown by the following excerpt: *Each drawing element in a HotDraw application is a subclass of Figure, and must implement displayOn, origin, extent, and translateBy.* In certain programming languages, some method overriding directives are enforced by the language itself. For instance, in Java, the `abstract` modifier for methods forces subclasses to override it, and the keyword `final` forces subclasses to use the framework implementation of the method. Method overriding directives can be found in the API documentation of framework (an example is given in figure 1). B. Method Extension Directives A method extension directive is a piece of documentation stating whether a method overriding a framework method should call the super-implementation. If the client-specific implementation of a framework method does not call the super-implementation when required, it may violate internal framework protocols resulting in runtime problems. For instance, if a programmer does not call the super implementation of the method `Dialog.close` of JFace when overriding it, she gets an unclosable window which totally hangs the application. Also, she does not get a stack trace to localize the error. This shows the importance of having documented method extension directives. To homogenize these directives, the programmers of Eclipse published a guideline to explain how to document them [4]. Programmers should use one of the following expressions: subclasses may extend this method or subclasses may re-implement this method. Extending means that subclasses have to call the super-implementation. Re-implementing means that subclasses must not call the super-implementation. Note that both directives are not supported by Java modifiers hence they have to be in the API documentation. Also, by default, a directive of the form “Subclasses may override this method” means that subclasses may or may not call the super-implementation. C. Method Call Directives Although the hotspot overriding is fully application-specific, frameworks may have expectations in terms of framework methods that should be called by the overriding code. A method call directive is associated to an overridable framework method and states which methods should be called inside client implementations of this framework method. For illustration, consider an Eclipse JFace wizard page that creates some visual components to display information. The `createContents()` method is the place where to create application-specific components. The framework expects the developer to call `WizardPage.setControl()` somewhere in the body of the overriding `createContents()` in order to register the application-specific control. Omitting this call leads to a cryptic runtime error (“Assertion failed”) and no stack trace to localize the error. Even if it’s not explicit in Johnson’s description of documentation patterns [6], there are such directives in the real patterns he presents: *However, methods that change some attribute of a figure must notify the objects that depend on it. This is done by sending the willChange message to itself before changing the attribute, and sending the changed message to itself afterwards.* D. Class Extension Scenarios The directives discussed so far concern individual methods. However, just giving a novice user of a white-box framework a "flat" set of methods that could be overridden leaves her with many open questions. Which methods should she actually override? The methods with a computed likelihood higher than a threshold? Or, are there other togetherness criteria determining "typical units of co-overridden methods"? The criteria to choose subsets of methods to override together may depend on the framework and on the class. This is the rationale for defining a class extension scenario\(^3\) as a set of typically co-overridden methods. Class extension scenarios are ready-to-use. Developers who have never extended a particular class, can rely on them to choose the set of methods to override together. Without them, developers lose time in answering the boundary problem aforementioned. The Eclipse website has a section containing tutorial articles. Some of them are about how to typically subclass framework classes (e.g. the tutorial about PreferencePage\(^4\)). ### E. Importance Level There is a concern which crosscuts the four aforementioned directives: whether the directive is a strong requirement (e.g. Subclass must call the super implementation) or a weak one (e.g. This method may be overridden). We can identify two ways of indicating importance levels. First, they can be expressed with modal verbs (e.g. may, should, must, etc.). This approach fits well with natural language and fuzzy expert knowledge. Johnson [6] uses them, and the Eclipse guidelines for subclassing directives as well [4]. Second, previous work about the mining of subclassing directives [13], [22], [20] generally uses importance values (e.g. probability). ### F. Recapitulation We have presented four important subclassing directives (i.e. kinds of documentation required to extend a framework). For each of them, to attest their usefulness: a) we explained what may happen if they are missing and b) we showed that real world documentation already contains some of them. ### III. TECHNIQUES TO MINE SUBCLASSING DIRECTIVES We now define techniques to mine subclassing directives from client code of white-box frameworks. Mined directives can be used by framework developers to improve the quality of the documentation and by framework users to find the pieces of information they need to correctly use the framework, thus complementing the documentation delivered with the framework. #### A. Mining Overriding Directives To determine the likelihood that a method is designed for being overridden, we define a metric called ovLikelihood, which represents the importance of overriding a framework method. A method overriding directive is created for each method whose value of ovLikelihood is not null. In the following, we give its definition and illustrate that it is meaningful by considering cases where we know the likelihood value. The definition of ovLikelihood is as follows: \[ \text{ovLikelihood}(\text{fwMeth}) = \frac{\sum_{clCl} \text{ovCl, fwMeth}}{\sum_{clCl} \text{ovCl, fwMeth} + \sum_{clCl} \text{notCl, fwMeth}} \] Thereby, for any framework class fwCl, framework method fwMeth, and non-abstract client subclass cCl: \(\text{ovCl, fwMeth} = 1\), if cCl overrides fwMeth directly or inherits an overriding implementation from an intermediate client superclass; \(\text{notCl, fwMeth} = 1\), if cCl does not override fwMeth at all. To understand the properties of this metric, let us now consider the class diagram depicted in figure 2. FWClass is a framework class, A is a class in client code that overrides FWClass and that it abstract. There is also z concrete classes (\(Z_1 \ldots Z_n\)) that override FWClass and x concrete classes (\(X_1 \ldots X_n\)) that override A. Method k is an abstract framework method that must be overridden. Hence, its value has to be 100% (\(\text{ovLikelihood}_k = \frac{z + 1}{z + 2} = 100\%\)). Method k also illustrates the rationale of discarding abstract client classes from the counting: if we do not discard them, then \(\text{ovLikelihood}_k = \frac{z + 1}{z + 2} < 100\%\) which is incorrect. Even if l is overridden in an intermediate abstract client class A, it counts as actually overridden in all concrete subclasses of A; hence the value of ovLikelihood must be 100% and this is indeed what our metric calculates (\(\text{ovLikelihood}_l = \frac{x + 1}{x + 2} = 100\%\)). Method n is never overridden, hence the value of \(\text{ovLikelihood}_n\) must be 0% (\(\text{ovLikelihood}_n = \frac{x}{x + z + 2} = 0\%\)). #### B. Mining Extension Directives To mine extension directives, we propose a metric that counts the number of methods that override a framework --- \(^3\)In this paper, we will use the italian plural form, scenarii, of this italian word. \(^4\)http://www.eclipse.org/articles/Article-Preferences/preferences.htm --- This preprint is provided by the contributing authors to ensure timely dissemination of scholarly and technical work. class A extends Page{ @override void createContents(){ } @override void performOk() } Fig. 3. Mapping Code to a Binary Space to Mine Extension Scenarii with LCA method and call the super-implementation (i.e., extend the framework method): \[ exLikelihood(fwMeth) = \frac{\sum_{clCl} superMeth, fwMeth}{\sum_{clCl} ovMeth, fwMeth} \] where \( ov_{clCl, fwMeth} = 1 \), if \( clCl \) contains a method \( clMeth \) which overrides \( fwMeth \); \( super_{clCl, fwMeth} = 1 \), if \( clCl \) contains a method \( fwMeth \) which overrides \( fwMeth \) and call the super implementation. A method extension directive is created for each method whose value of \( exLikelihood \) is not null. C. Mining Call Directives To mine a call directive for a framework method \( fwMeth \), we propose to collect all self-calls executed within the control flow starting from each method overriding \( fwMeth \). The following defines a metric which represents the importance of calling a framework method \( fwMeth2 \) in the control flow of another framework method \( fwMeth1 \) \[ clLikelihood(fwMeth1, fwMeth2) = \frac{\sum_{clCl} call_{clCl, fwMeth1, fwMeth1}, fwMeth2}{\sum_{clCl} ov_{clCl, fwMeth}} \] where \( ov_{clCl, fwMeth} = 1 \), if \( clCl \) contains a method which overrides \( fwMeth \); \( call_{clCl, fwMeth1, fwMeth1}, fwMeth2 = 1 \), if \( clCl \) contains a method which overrides \( fwMeth1 \) and calls \( fwMeth2 \) in its control flow. A call directive is created for each pair of framework methods, whose value of \( clLikelihood \) is not null. D. Mining Class Extension Scenarii We propose to use a clustering algorithm on client code to mine the set of methods commonly overridden together. For each framework class \( fwCl \), one selects the client classes that subclass \( fwCl \) and clusters the methods that are often overridden together. As with other subclassing directives, mining existing clients enables to discover extension scenarii that have not been covered by tutorials. For each framework class \( fwCl \) a binary matrix is build. Each row of the matrix represents a subclass of \( fwCl \); each column represents an overridable method of \( fwCl \). Whenever a subclass \( i \) overrides a framework method \( j \) the position \((i, j)\) of the binary matrix is 1, it is 0 otherwise. For illustration, figure 3 shows the binary matrix of a class \( Page \) and elaborates on the row for a subclass \( A \), whose code is shown on the left-hand side. Since the data grounding the clustering algorithm is binary, we use a data mining algorithm called Latent Class Analysis (LCA) appropriate to such binary data \([10]\). For each framework class, the algorithm outputs zero or more class extension scenarii. We define a default extension scenario as a scenario which covers at least 5 percent of the data, a heuristic which gives satisfying results according to our experience. If several scenarii satisfy these constraints, the default scenario is simply the one that has the greatest probability (as given by LCA). E. Defining Importance Levels As discussed in II-E, the importance level of each directive can be represented by modal verbs or importance values. We propose to give the programmers both, for instance, Subclass may override this method (32%). Our rationales are 1) modal verbs are intuitive and accessible to novice users and 2) importance values are useful for users who know how to interpret them. We propose the following heuristics to map importance values to modal: 100%-MUST; 80%-100%-SHOULD, 20%-80%-MAY; 1%-20%-RARELY. It seems satisfactory according to our own experience and according to the users of the tool. Validating them by a controlled user study is left out of the scope of this paper and one of the areas for future work. F. Implementation We have implemented a static analysis for each technique described above. The analyses target Java bytecode and use the Wala bytecode toolkit\(^5\). The implementations of \( ovLikelihood \) and \( exLikelihood \) are simple countings on a direct representation of the code. The implementation of \( clLikelihood \) is based on call graphs. To cluster the co-overridden methods (the class extension scenarii), we have reused an implementation of LCA provided by NASA: Autoclass\(^6\). IV. CASE-STUDY: IMPROVING THE DOCUMENTATION QUALITY OF A MATURE FRAMEWORK In this section, we evaluate whether our system is able to improve the quality of the API documentation of a real-world framework with respect to subclassing directives. A. Set Up and Overview of the Results The subject of the study is JFace, a white-box framework dedicated to user interfaces. It is a representative of heavily used frameworks: it grounds the Eclipse IDE, it is more than 6 years old, and it is used daily by hundreds of developers. So, one can expect its documentation to be already improved several time and hence of good quality. We postulate that if our approach is able to produce directives that complement \(^5\)http://wala.sf.net \(^6\)see http://ti.arc.nasa.gov/project/autoclass/. JFace’s documentation or to produce directives that are more precise, it can do so for documentation of less quality as well. For the study, we compared the subclassing directives in the API documentation of JFace with directives that were automatically extracted by applying our system to client code of JFace. The client code used for the study consisted of 600 MB of mature available Eclipse plugins. Since our codebase is composed of mature code only, we can consider that the extracted directives are correct by construction. Also, note that our implementation was thoroughly tested. To obtain the list of subclassing directives that are already present in the documentation of JFace, we analyzed the documentation of JFace by performing the following process. 1) We wrote a trivial static analysis which counts the number of public classes and their respective overridable methods (i.e., public/protected and not final methods). We found a total of 203 public classes which have an average 20 overridable methods. 2) We analyzed the collected client code and listed those framework classes that are extended at least ten times. Altogether there were 45 such classes (i.e., approx. one fourth of public classes). 3) We read the Javadoc documentation of each framework method of the collected classes as well as the Javadoc documentation of the containing class and reported the overriding directives, whenever available. Altogether 632 methods were analyzed. We found a total of 237 documented directives. Since step 3 is manual and error-prone, we performed them twice by two of the authors of this paper and consolidated the results. Table I presents an overview of the results of comparing subclassing directives of the JFace API documentation with subclassing directives automatically mined by our system. The first part gives an overview of the documentation (of the 45 classes manually analyzed). The second part reports on agreeing documented and mined directives. The third part concerns disagreeing documented and mined directives. The fourth part is dedicated to documented directives that have no correspondence in the mined directives. Finally, the last row in the table concerns mined directives for which we could not find corresponding directives in the documentation. One finding that is not reported in Table I but which we find interesting to emphasize is that only 30% of overridable methods are actually overridden. This is an empirical proof that the visibility modifiers alone are not sufficient as subclassing directives. In the following subsections, we first elaborate on the findings reported in parts three, four, and five of Table I. Subsequently, we evaluate the mined extension scenarios. We conclude this section by presenting and discussing the viewpoint of Boris Bokowski, leader of the JFace development team at IBM Canada, further called the expert, who kindly agreed to comment a sample of directives mined by our system that we sent to him. B. Disagreeing Documented and Mined Directives In this section, we elaborate on the set of documented directives with corresponding mined directives, but with mismatching importance levels. This set breaks down as follows: - There are 3 methods that are documented as *Subclasses must override* or *Subclasses should override* whereas the overriding frequency in client code is less than 40%. Along the same line, we found 2 *Subclasses must override*, while client code does not always follow them (importance values: 93% and 94%), this indicates a possible change from *must override* to *should override*. - We found 3 methods that are documented as *Subclasses may override*, while their overriding importance in client code is greater than 80%. Those methods should be documented as *Subclasses should override*. Furthermore, two of them have an importance value of 100% (all client classes overridden them) which would literally mean a *Subclasses must override*. Since we could not state whether it is really a “must” contract or a particularity of our code base, we prefer generating a *Subclasses should override*. - For extension directives, there are 9 directives of the form *Subclasses must extend* or *Subclasses should extend* in the documentation, while the actual extension frequency in the codebase is less than 80%. - Further, there are 28 directives of the form *Subclasses may extend* in the documentation, while their mined importance is higher than 80%. The discussion above reveals non-negligible discrepancy between the importance level of documented directives and importance levels deduced from existing clients. Given that <table> <thead> <tr> <th>Directive</th> <th>#</th> </tr> </thead> <tbody> <tr> <td>Documented</td> <td>237</td> </tr> <tr> <td>Overriding Directive</td> <td>153</td> </tr> <tr> <td>Extension Directive</td> <td>69</td> </tr> <tr> <td>Call Directive</td> <td>15</td> </tr> <tr> <td>Agreeing Documented and Mined</td> <td>181</td> </tr> <tr> <td>Overriding Directive</td> <td>138</td> </tr> <tr> <td>Extension Directive</td> <td>32</td> </tr> <tr> <td>Call Directive</td> <td>11</td> </tr> <tr> <td>Disagreeing Documented and Mined</td> <td>45</td> </tr> <tr> <td>Overriding Directive</td> <td>8</td> </tr> <tr> <td>Extension Directive</td> <td>37</td> </tr> <tr> <td>Call Directive</td> <td>0</td> </tr> <tr> <td>Documented and Not Mined</td> <td>11</td> </tr> <tr> <td>Overriding Directive</td> <td>7</td> </tr> <tr> <td>Extension Directive</td> <td>0</td> </tr> <tr> <td>Call Directive</td> <td>4</td> </tr> <tr> <td>Not documented and Important in Actual Usages (importance &gt; 80%)</td> <td>129</td> </tr> <tr> <td>Overriding Directive</td> <td>4</td> </tr> <tr> <td>Extension Directive</td> <td>67</td> </tr> <tr> <td>Call Directive</td> <td>58</td> </tr> </tbody> </table> Table I **IMPROVING THE SUBCLASING DIRECTIVES OF THE JFace FRAMEWORK** For sake of replicability, the complete list of plugin ids and versions is available upon request. the codebase that we use consists of production-level client code, the mined directives reflect information that was actually needed at a point in time by the developers of the codebase. Hence, we consider the disagreeing documented directives misleading: Developers probably lose some of their valuable time in investigating and finding out that the misleading directives in the documentation are not useful for them. Hence, we conclude that the results reported in this sub-section show that our system is able to improve the correctness of the API documentation w.r.t. subclassing directives. C. Documented and Not Mined Directives There are documented subclassing directives of JFace which are never followed in client code. In the following, we present them and some possible explanations. - There are 7 methods documented as Subclasses may override, which are never overridden in client code. It seems that JFace designers thought that it could be useful to make these methods overridable, but the reality somehow invalidated their assumptions. As emphasized by Bloch [1], it is really difficult to know a priori which hotspots to provide in a base class. - There are no unused extension directives. - There are 4 call directives which are never followed in client code. - One directive is expressed as “Use removeAll for clean up references”. We assume that the scope of this directive is not subclasses but external users of this class. - Two directives are expressed as “Subclasses should call this method at appropriate times”. The vagueness of the directive indicates that its author did not have a precise contract in mind. - One directive is expressed as “This method is really only useful for subclasses to call in their constructor”. As for overriding directives, this may be an incorrect guess of the method usages at design time of the framework. D. Not Documented Important Directives In this subsection, we discuss in more detail the mined directives with a high importance level that are missing in the API documentation. For each of them, we looked in the corresponding API documentation whether it is documented or not (in both the method-level and the class-level documentation). The results of this study are as follows: - There are 4 overriding directives extracted from client code with an importance of greater than 80% which are missing in the documentation. - The system extracts 50 must extension directives that are not documented (and 17 undocumented Subclasses should call the super-implementation). We assume that this kind of contracts is widely yet implicitly used by framework designers while not being integrated as a documentation best practice. Developers probably lose some of their valuable time in finding out that they are expected to call the super-implementation for these particular methods. - There are 58 called call directives with clLikelihood > 80% which are not documented. This clearly indicates that framework designers often use implicit call contracts while they (or framework documenters) often do not document them, or are not aware of their importance for the client code. We further made the following qualitative observations: - We expected to find more informal tutorials from technology guru’s blogs or community-based sites. We were surprised to find so many reference scenarii in the Eclipse and IBM websites. This indicates that authoritative sources (Eclipse and IBM) consider extension scenarii as an important documentation artifact. - However, these authoritative tutorials cover only 10 classes of JFace. There are many more of importance E. Relevance of Class Extension Scenarii We used internet tutorials about JFace to evaluate the relevance of class extension scenarii mined by our system. We carefully read the available tutorials (both text and code snippets) to extract what are the recommended methods to override, which together form a reference extension scenario. We then compared the reference scenarii with the mined ones. For instance, the official Eclipse tutorial “Preferences in the Eclipse Workbench UI”8 explains how to subclass PreferencePage by overriding three methods (createContents, performDefaults, performOk). This reference scenario perfectly matches the mined one for PreferencePage. In all we analyzed 31 different tutorials from the IBM developer website9, the Eclipse website 10 and Javaworld 11. We found 14 tutorials that contain 25 different reference extension scenarii for JFace. Table II presents the results of this evaluation. Each row in the table is about a different JFace class. The first column shows the name of the class and the tutorials that were used for finding reference scenarii for that class. The second column shows the mined extension scenarii in italics (there could be several mined and reference scenarii per framework classes) followed by different reference scenarii. The third column indicates whether the reference scenarii match the mined scenarii. A quantitative summary of the data in the table II is as follows: a) 18 mined scenarii perfectly match the reference. a) 5 mined scenarii partly match the reference counterparts (they are either superset or subset of overridden methods); b) 2 reference scenarii do not have a mined counterpart; We further made the following qualitative observations: - We expected to find more informal tutorials from technology guru’s blogs or community-based sites. We were surprised to find so many reference scenarii in the Eclipse and IBM websites. This indicates that authoritative sources (Eclipse and IBM) consider extension scenarii as an important documentation artifact. - However, these authoritative tutorials cover only 10 classes of JFace. There are many more of importance --- 8http://www.eclipse.org/articles/Article-Preferences/preferences.htm 9http://www.ibm.com/developerworks 10http://www.eclipse.org/articles/ 11provides “Solutions for Java developers”, see http://www.javaworld.com which are not documented by an extension scenario. This is exactly where our approach makes its contribution, by providing default extension scenarios when no others are available. \[ TABLE II \] <table> <thead> <tr> <th>Context, Tutorial Title and Source</th> <th>Mined (in italic) &amp; Reference Scenario</th> <th>Evaluation</th> </tr> </thead> <tbody> <tr> <td>Class Wizard</td> <td>Extending the Generic Workbench (IBM developerWorks)</td> <td></td> </tr> <tr> <td>Creating JFace Wizards (Eclipse)</td> <td>addPages, performFinish</td> <td>OK</td> </tr> <tr> <td></td> <td>addPages, performFinish</td> <td>OK</td> </tr> <tr> <td>Class WizardPage</td> <td>Extending the Generic Workbench (IBM developerWorks)</td> <td></td> </tr> <tr> <td>Customizing Eclipse RCP applications (IBM developerWorks)</td> <td></td> <td></td> </tr> <tr> <td>Creating JFace Wizards (Eclipse)</td> <td>createControl</td> <td>OK</td> </tr> <tr> <td></td> <td>createControl</td> <td>OK</td> </tr> <tr> <td></td> <td>createControl, canFlipToNextPage, getNextPage (opt)</td> <td>x</td> </tr> <tr> <td>Class LabelProvider</td> <td>Using Images in the Eclipse UI (Eclipse)</td> <td></td> </tr> <tr> <td>Using the JFace Image Registry (IBM developerWorks)</td> <td></td> <td></td> </tr> <tr> <td>Using the Eclipse GUI outside the Eclipse Workbench, Part 1: Using JFace and SWT in stand-alone mode (IBM developerWorks)</td> <td></td> <td></td> </tr> <tr> <td></td> <td>getImage, getText</td> <td>x</td> </tr> <tr> <td></td> <td>getText, dispose</td> <td>OK</td> </tr> <tr> <td></td> <td>getImage, getText</td> <td>x</td> </tr> <tr> <td>Class ViewerSorter</td> <td>Using the JFace Image Registry (IBM developerWorks)</td> <td></td> </tr> <tr> <td>How to use the JFace Tree Viewer (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td>How to use the JFace Tree Viewer (Eclipse) Building and delivering a table editor with SWT/JFace (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td></td> <td>pattern1: category; pattern2: compare</td> <td>OK</td> </tr> <tr> <td></td> <td>category</td> <td>OK</td> </tr> <tr> <td></td> <td>category</td> <td>OK</td> </tr> <tr> <td></td> <td>compare</td> <td>OK</td> </tr> <tr> <td></td> <td>compare</td> <td>OK</td> </tr> <tr> <td>Class ViewerFilter</td> <td>Using the JFace Image Registry (IBM developerWorks)</td> <td></td> </tr> <tr> <td>Customizing Eclipse RCP applications (IBM developerWorks)</td> <td></td> <td></td> </tr> <tr> <td>How to use the JFace Tree Viewer (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td></td> <td>select</td> <td>OK</td> </tr> <tr> <td></td> <td>select</td> <td>OK</td> </tr> <tr> <td></td> <td>select</td> <td>OK</td> </tr> <tr> <td>Class Action</td> <td>Rich clients with the SWT and JFace (JavaWorld)</td> <td></td> </tr> <tr> <td>Creating an Eclipse View (Eclipse)</td> <td>run</td> <td>OK</td> </tr> <tr> <td>run</td> <td>OK</td> <td></td> </tr> <tr> <td>Class DialogCellEditor</td> <td>Take Control of Your Properties (Eclipse)</td> <td></td> </tr> <tr> <td>Extending The Visual Editor: Enabling support for a custom widget (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td></td> <td>-</td> <td>not enough subclasses to mine a pattern</td> </tr> <tr> <td></td> <td>openDialogBox, doSetValue, updateContents</td> <td>not enough subclasses to mine a pattern</td> </tr> <tr> <td>Class PreferencePage</td> <td>Preferences in the Eclipse Workbench UI</td> <td></td> </tr> <tr> <td>Simplifying Preference Pages with Field Editors (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td></td> <td>createContents, performOK, performDefaults</td> <td>OK</td> </tr> <tr> <td></td> <td>createContents, performDefaults, performOK</td> <td>OK</td> </tr> <tr> <td></td> <td>createContents, performDefaults, performOK, performDefaults</td> <td>OK</td> </tr> <tr> <td>Class FieldEditorPreferencePage</td> <td>Simplifying Preference Pages with Field Editors (Eclipse)</td> <td></td> </tr> <tr> <td>Mutatis mutandis - Using Preference Pages as Property Pages (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td>Mutatis mutandis - Using Preference Pages as Property Pages (Eclipse)</td> <td></td> <td></td> </tr> <tr> <td></td> <td>createFieldEditors</td> <td>OK</td> </tr> <tr> <td></td> <td>createFieldEditors</td> <td>x</td> </tr> <tr> <td></td> <td>addField, performOK, createContent createFieldEditors</td> <td>OK</td> </tr> <tr> <td>Class TitleAreaDialog</td> <td>Extending The Visual Editor: Enabling support for a custom widget (Eclipse)</td> <td></td> </tr> <tr> <td></td> <td>createDialogArea, okPressed, configureShell, createButtonsForButton, createContents createDialogArea</td> <td>x</td> </tr> <tr> <td></td> <td>createContents, createDialogArea</td> <td>x</td> </tr> </tbody> </table> **F. The Expert Viewpoint** To get an unbiased view on the observed differences between mined and documented directives, we asked Boris Bokowski, leader of the JFace development team at IBM Canada, to comment on a sample of mined directives, which we formulated as suggestions of change to the API documentation. The size of the sample (9 items) was chosen so that the questionnaire can be answered in less than 20 minutes. The directives we included in the sample were selected according to the following characteristics: 1) they are related to an important and known class of JFace so as to be sure that the expert is fluent with this class 2) they have a very high importance value so as to reflect the added value of using our approach to find important incorrect or missing directives. In This preprint is provided by the contributing authors to ensure timely dissemination of scholarly and technical work. the following, we summarize the feedback that we got from the expert. The expert agreed on two suggestions to change two "Subclasses may override" directives in the API documentation to "Subclasses should override" directives, as mined by our system. He asked us to fill respective entries in the bug repository of Eclipse, which we did. For illustration, we elaborate on one of these changes. The API documentation states for PreferencePage.performOk that Subclasses may override. However, since our algorithm found out that the method was actually overridden in 84% of the client subclasses, we suggested to change the directive to Subclasses should override. We sent the expert three suggestions for changes concerning three different "Subclasses may extend" directives found in the documentation. According to the Eclipse guidelines this actually means "may override, should extend". Our system mined three different directives: (1) "may override, must extend", (2) "should override, may extend", and (3) "may override, should extend" for the respective three methods. The expert basically agreed that the first two suggestions were meaningful. Yet, he argued for not performing the first change we suggested as "it would render existing code incompatible with the specification". He disagreed on the third suggestion arguing that our suggestion was merely making explicit the actual meaning of "Subclasses may extend" according to the Eclipse guidelines. While this is somehow a matter of taste, we still find that dissociating overriding and extension directives makes the directives more clear. The fact that we mined three different interpretations of the "Subclasses may extend" directive, which the expert principally agreed on, indicates that simply stating "Subclasses may extend" is very misleading. The expert reviewed an extension directive with a very high importance (i.e. Subclasses should call super), for which he answers "I don't see why we would require subclasses to call the super implementation". We analyzed the client classes that support this mined directive. It turned out that 1) the support of this directive is low (11) and 2) the clients override this method just to add some application-specific logic, which makes sense to be called at this point in the framework control-flow, but which is not related to the initial intent of this method. This motivated us to set up a higher filter on the support of each directive in newer versions of the tool. The expert reviewed 2 mined method call directives. Unfortunately, due to the specific directives selected for review and some unclarity in the expert's comments, we can not derive any generalizable conclusions. The expert reviewed 1 mined default extension scenario. It is about extending the class TrayDialog which extends Dialog. While the documentation of Dialog related to subclassing is quite comprehensive, the subclassing documentation of TrayDialog is really scarce. The mined default extension scenario for TrayDialog consists of 11 methods to override. The expert answered that “documentation items like this are useful.” In addition, he noted that they are “probably better suited for a tutorial rather than the API specification.” The second part of the expert comment raises questions about where to put subclassing directives. In API documentation? In tutorials? Should we duplicate documentation at the class level documentation and at the method level? How to handle documentation that targets different kinds of users (novice versus experts), etc.? A thorough investigation of these questions is out of scope of this paper. For now, our answer to these questions is that subclassing directives should be integral part of the API documentation in a way that we elaborate on in the next section. Further investigations involving user studies are out of the scope of this paper. V. INTEGRATING SUBCLASSING DIRECTIVES IN IDES Subclassing directives are of primary importance for framework users and hence should be tightly integrated into the development environments so that developers find and use them easily. In the following, we present an integration proposal of our mined subclassing directives into the Eclipse IDE. First, the initial documentation written by the framework developers is the primary source of information. It contains a lot of valuable information, e.g., the functional goal of a method, its design rationales, etc. The mined directives complement the original API documentation. Second, since there is already a Javadoc viewer in every default Eclipse installation and that developers may already use it, we propose to extend this viewer by enriching the initial API documentation with the mined subclassing directives (and not to create a new view). Finally, since mined directives are relevant at both the class level and the method level API documentation, the extended viewer supports both. When developers browse the class level documentation, they are shown the list of overriding directives, the list of method call directives, and the extension scenarios that have a high support. Directives are shown in natural language (e.g., Subclasses may override) together with the underlying importance value. Figure 4 shows a screenshot of our viewer displaying the API documentation (both hand-written and generated directives) for the class PreferencePage of the JFace framework. When developers browse the method level documentation, the documentation view acts differently. It gives the initial documentation, and in addition adds the mined overriding directive, the extension directive, and the method call directives, if any. Figure 5 shows an example of the method level documentation. Note that both screenshots show directives for real classes of JFace and that real data underlies them. This integration is seamless with respect to the IDE and the usual way of programming with Eclipse. Developers have new information at the place they naturally would look at: the Javadoc viewer. If no information is available for certain classes or certain frameworks, the viewer is simply the default one and shows only the initial API documentation. VI. RELATED WORK For Pree, hotspot mining is a manual activity that consists of examining maintenance data, investigating framework use cases and questioning the framework experts. On the contrary, our approach to hotspot mining is fully automated. Schauer et al. [17] presented a method and a tool to automatically recover hotspots from C++ code. In particular, their approach is able to differentiate between inheritance hotspots (IHS - based on the design pattern Inheritance Template Method) and composition hotspots (CHS - based on the design pattern Composition Template Method). Their approach is based on the source code analysis of the framework. On the contrary, our approach is based on instantiation code, which enables us to have concrete information about how the framework under study is actually used. From a functional viewpoint, our approach provides more information to the user, namely the extension and the call directives. Tourwe and Mens [21] address the problem of framework reuse by making explicit framework contracts by so-called metapatterns. This approach requires (a) a development environment that supports metapatterns, and (b) that framework designers enrich their code with the formal description of the metapatterns. Along the same lines, previous approaches [7], [9], [12], [19] address the framework evolution problem and propose different techniques for specifying, checking, and enforcing explicit specialization interfaces for frameworks. On the contrary, our approach does not require additional work from framework designers, who can use the tool to improve the current state of documentation. Schaefer et al. [16] address the problem of framework evolution, i.e., how client code should change in response to a new version of the framework. Like with our approach, they mine instantiation code to mine knowledge. However, the problem scope is different: Their tool produces a list of changes to do in order to adapt existing client code to changes in the framework API, our tool produces a list of subclassing directives to support the development of new framework clients. Michail [13] proposes an approach to mining subclassing directives based on association rules mining. There are two important differences between this proposal and ours. First, the proposal by Michail [13] does not address extension directives. Further, it provides coarse-grained call directives, at the class level, i.e., of the form “call a framework method when extending a framework class.” In previous work [2], we also presented an approach that provides the same coarse-grained call directives. On the contrary, our call directives are context-dependent. We tell the user that she has to call method X inside the body of method Y: this is very important to create code that respects the framework internal control flow. TABLE III <table> <thead> <tr> <th></th> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> <td>Smalltalk</td> <td>+</td> </tr> <tr> <td></td> <td></td> <td></td> <td>C++</td> <td>+</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Java source code</td> <td>+</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Java bytecode</td> <td>+</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Google CodeSearch</td> <td>+</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Java Bytecode</td> <td>+</td> </tr> </tbody> </table> This preprint is provided by the contributing authors to ensure timely dissemination of scholarly and technical work. References This preprint is provided by the contributing authors to ensure timely dissemination of scholarly and technical work. Demeyer [3], Viljamaa [22] and Thummalapenta et al. [20] also describe mining-based approaches to hotspot detection. Table III compares our contributions compared to these close papers including [13] and [2]. Programming with white-box frameworks requires all subclassing directives together since having just one or the other is not sufficient. We contribute with a comprehensive and unified approach on mining subclassing directives and especially we provide extension directives and well-scoped call directives: both document essential parts of the logic of today’s white-box frameworks. VII. Conclusion We presented a new approach to improve the quality of white-box framework documentation. For each framework class, our system mines from client code a set of subclassing directives that are all required to quickly and correctly extend the framework: 1) what methods to override 2) should the overriding method call the super implementation 3) is the overriding method expected to call certain framework methods, and 4) what are the methods usually overridden together. This approach is complementary to manually written API documentation. Framework developers can update the documentation accordingly and framework users can access to the mined directives as an add-on to the original documentation in the IDE. A case study evaluates the approach. We mined subclassing directives for the Eclipse’s JFace framework for user-interfaces. We found that the existing API documentation is both incorrect (45 incorrect pieces of documentation) and incomplete (129 missing high-importance directives) compared to current usages of JFace. Our current work goes in two directions. First we try to automate the analysis of existing documentation with natural language processing techniques. Then, it will be possible to automatically detect erroneous and missing documentation related to subclassing. Second, when developers are given a particular directive, they still need the intent behind the directive (e.g. Subclasses may override to change the color of the widget). We are studying how to mine not only the directive, but also the rationale behind each subclassing directive, based on e.g. framework code, symbol names and existing documentation (at least to the extent possible); we imagine illustrating such mined intents with generated code snippets.
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01575347/document", "len_cl100k_base": 11083, "olmocr-version": "0.1.49", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 35521, "total-output-tokens": 12019, "length": "2e13", "weborganizer": {"__label__adult": 0.00032973289489746094, "__label__art_design": 0.00025725364685058594, "__label__crime_law": 0.0002853870391845703, "__label__education_jobs": 0.0008077621459960938, "__label__entertainment": 4.07099723815918e-05, "__label__fashion_beauty": 0.00011485815048217772, "__label__finance_business": 0.00015854835510253906, "__label__food_dining": 0.0002036094665527344, "__label__games": 0.0003659725189208984, "__label__hardware": 0.0003693103790283203, "__label__health": 0.0002225637435913086, "__label__history": 0.00014460086822509766, "__label__home_hobbies": 5.984306335449219e-05, "__label__industrial": 0.00018477439880371096, "__label__literature": 0.0001888275146484375, "__label__politics": 0.0001970529556274414, "__label__religion": 0.0003139972686767578, "__label__science_tech": 0.00183868408203125, "__label__social_life": 8.064508438110352e-05, "__label__software": 0.00457763671875, "__label__software_dev": 0.98876953125, "__label__sports_fitness": 0.0001908540725708008, "__label__transportation": 0.00024235248565673828, "__label__travel": 0.0001474618911743164}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 53823, 0.0175]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 53823, 0.2659]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 53823, 0.88229]], "google_gemma-3-12b-it_contains_pii": [[0, 1024, false], [1024, 6001, null], [6001, 10411, null], [10411, 15352, null], [15352, 20468, null], [20468, 25954, null], [25954, 31952, null], [31952, 37607, null], [37607, 40577, null], [40577, 46856, null], [46856, 53823, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1024, true], [1024, 6001, null], [6001, 10411, null], [10411, 15352, null], [15352, 20468, null], [20468, 25954, null], [25954, 31952, null], [31952, 37607, null], [37607, 40577, null], [40577, 46856, null], [46856, 53823, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 53823, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 53823, null]], "pdf_page_numbers": [[0, 1024, 1], [1024, 6001, 2], [6001, 10411, 3], [10411, 15352, 4], [15352, 20468, 5], [20468, 25954, 6], [25954, 31952, 7], [31952, 37607, 8], [37607, 40577, 9], [40577, 46856, 10], [46856, 53823, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 53823, 0.27273]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
af10dda7eaedbe542b151adce99ca1aa19c2f0eb
[REMOVED]
{"len_cl100k_base": 16054, "olmocr-version": "0.1.53", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 48967, "total-output-tokens": 20440, "length": "2e13", "weborganizer": {"__label__adult": 0.00037789344787597656, "__label__art_design": 0.0004756450653076172, "__label__crime_law": 0.0002104043960571289, "__label__education_jobs": 0.0008802413940429688, "__label__entertainment": 8.767843246459961e-05, "__label__fashion_beauty": 0.0001735687255859375, "__label__finance_business": 0.00018656253814697263, "__label__food_dining": 0.0004527568817138672, "__label__games": 0.0006761550903320312, "__label__hardware": 0.0012063980102539062, "__label__health": 0.0004782676696777344, "__label__history": 0.00032520294189453125, "__label__home_hobbies": 0.0001341104507446289, "__label__industrial": 0.0005412101745605469, "__label__literature": 0.0004107952117919922, "__label__politics": 0.00025653839111328125, "__label__religion": 0.000720977783203125, "__label__science_tech": 0.0294647216796875, "__label__social_life": 0.00010114908218383788, "__label__software": 0.00444793701171875, "__label__software_dev": 0.95703125, "__label__sports_fitness": 0.00032210350036621094, "__label__transportation": 0.0007395744323730469, "__label__travel": 0.00022518634796142575}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 63311, 0.0112]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 63311, 0.38271]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 63311, 0.77931]], "google_gemma-3-12b-it_contains_pii": [[0, 3572, false], [3572, 8701, null], [8701, 15016, null], [15016, 19932, null], [19932, 26865, null], [26865, 32900, null], [32900, 39641, null], [39641, 46166, null], [46166, 51496, null], [51496, 57647, null], [57647, 63311, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3572, true], [3572, 8701, null], [8701, 15016, null], [15016, 19932, null], [19932, 26865, null], [26865, 32900, null], [32900, 39641, null], [39641, 46166, null], [46166, 51496, null], [51496, 57647, null], [57647, 63311, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 63311, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 63311, null]], "pdf_page_numbers": [[0, 3572, 1], [3572, 8701, 2], [8701, 15016, 3], [15016, 19932, 4], [19932, 26865, 5], [26865, 32900, 6], [32900, 39641, 7], [39641, 46166, 8], [46166, 51496, 9], [51496, 57647, 10], [57647, 63311, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 63311, 0.0]]}
olmocr_science_pdfs
2024-12-12
2024-12-12
50994b8aa9faba0d235184fdb3327701d9d2f988
Reasoning about Program Composition* K. Mani Chandy† Beverly A. Sanders ‡ UF CISE Technical Report 96-035 November 18, 1996 Abstract This paper presents a theory for concurrent program composition based on a predicate transformer call the the weakest guarantee and a corresponding binary relation guarantees. The theory stems from a novel view of rely-guarantee techniques for reasoning about program composition and provides a general and uniform framework for handling temporal properties as well as other kinds of program properties such as refinement and encapsulation. 1 Introduction The contribution of this paper is a predicate-transformer based theory for reasoning about the composition of concurrent programs. This section contains the motivation for this contribution and a discussion of the central issues. The predicate transformers $wp$ and $wlp$ provide an elegant basis for reasoning about sequential programs because they focus attention on the most fundamental aspects of these programs: their initial and final states [DS90]. By identifying a program with its predicate transformer, we can reason about programs using the universal notation of the predicate calculus. Predicate transformer theory is the fundamental theory of sequential programming; so extending the theory to concurrent composition is of interest. Concurrent programs cannot be specified exclusively in terms of initial and final states. Temporal logic, which deals with computations of programs, [Pnu81, CM88, Lam94, MP91] has been used for specifying and reasoning about concurrent programs. Our theory uses concepts from temporal logic, but our contribution is to extend predicate transformer theory to concurrent programming. --- *Supported in part by U.S. Air Force Office of Scientific Research and the University of Florida. †Department of Computer Science, California Institute of Technology, m/c 256-80, Pasadena, CA 91125, mani@cs.caltech.edu. ‡Department of Computer and Information Science and Engineering, P.O. Box 116120, University of Florida, Gainesville, FL 32611-6120, sanders@cise.ufl.edu. Temporal properties are not usually compositional. Even if all computations of programs \( F \) and \( G \) satisfy a temporal logic formula, computations of \( F \parallel G \) may not (where \( \parallel \) is a program composition operator). We propose a common theoretical foundation, based on predicate transformers, for proving properties of composed programs from properties of their components. In the literature on program composition, components have been specified with properties variously called rely/guarantee [Jon83, Sta85], hypothesis/conclusion [CM88], assumption/commitment [Col94, CK95], offers/using [LS94, LS92] and assumption/guarantee [AL93, AL95]. The common idea is that assumptions about the environment form part of the specification of a component. In this paper, we develop this idea using predicate-transformers and a different view of how to specify the environment. This leads to a simple theory of program composition. The main aspects of our approach are summarized next: 1. We define a program property as a predicate on programs. Our theory uses predicates on both programs and states. 2. Our theory provides a uniform framework for handling temporal properties and other kinds of program properties such as refinement and encapsulation. 3. We specify program components with the dyadic operator \( \textit{guarantees} \) on program properties where for a program \( F \) and properties \( X \) and \( Y \), \( (X \textit{guarantees} Y) \) is a property of program \( F \) if and only if all programs that have \( F \) as a component and have \( X \) as a property also have \( Y \) as a property. In contrast to the semantics for rely/guarantee specifications in the literature, the antecedent \( X \) is a property of the system \( F \parallel H \) in which the component \( F \) is embedded, not the environment \( H \); likewise the consequent \( Y \) is also a property of the same system \( F \parallel H \). The \( \textit{guarantees} \) property has many of the nice properties of implication because both \( X \) and \( Y \) in \( (X \textit{guarantees} Y) \) are properties of the same system. Theories in which \( X \) refers to one program and \( Y \) refers to another program appear to be more complex than our theory and often restrict \( X \) to be safety properties. 4. In analogy with the \( wp.F \) calculus, we define a property transformer \( wg \) where for a program \( F \) and properties \( X \) and \( Y \): \( wg.F.Y \) is the weakest \( X \) such that \( (X \textit{guarantees} Y) \) is a property of \( F \). The property transformer \( wg.F \) is monotonic, universally conjunctive, and idempotent. Like \( wp \) in sequential programming, \( wg \) anchors the theory of guarantees properties in the predicate calculus. 5. We explore simple compositional properties called \textit{all-component} and \textit{exists-component} properties. A program has an all-component property if and only if all its components have that property. A program has an exists-component property if there exists a component that has that property. We also propose compositional methods of proving properties that are neither all-component nor exists-component by using the guarantees operator. 6. We propose a method for specifying and reasoning about program components that has two parts: - The theory for guarantees properties that relies on simple properties of $\parallel$ such as associativity and existence of an identity and is largely independent of any particular program model. - Model-specific proof rules for showing that a program satisfies a guarantees property. This aspect of our approach is reminiscent of the algebraic specification method Larch [GHW85] which also has a two-tiered approach with language-independent and language-specific parts. In the remainder of the paper, we develop the theory of guarantees and wg, give an example of model-specific proof rules using a programming model similar to UNITY, and develop an example program in the model. We conclude with some observations. 2 Preliminary definitions We employ predicates on states and predicates on programs. A program property is a predicate on programs, and a state predicate is a predicate on states. We use letters $X$, $Y$ and $Z$ for program properties, $p$, $q$ and $r$ for state predicates, and $F$, $G$ and $H$ for programs. The application of a function $f$ to an argument $x$ is denoted by $f.x$ and function application associates to the left. Therefore, for a program property $Z$ and a program $F$, the value of $Z.F$ is boolean: $Z.F$ has value true if and only if property $Z$ holds for program $F$. A fundamental property of a program is whether or not it conforms to some criteria. The precise definition of conforms depends on the program model, but typically involves satisfaction of the kinds of typing and encapsulation constraints found in many programming languages and enforced by compilers. We restrict our theory to conformant programs. For instance, a conformant program can be defined as one that compiles successfully, and we do not want our theory to have to deal with programs that do not compile. We introduce a property conforms, where $\text{conforms}.F$ holds if and only if program $F$ conforms to the criteria of interest. A program is a state transition system. A computation of a program is an infinite sequence of state transitions that satisfies certain restrictions, discussed later. An important kind of program property is a predicate on computations that holds for all computations of the program. For example, for state predicates \( p \) and \( q \), we define a predicate \( p \sim q \) on computations as follows: \( p \sim q \) holds for a computation \( c \) exactly when, for each point in \( c \) at which \( p \) holds, \( q \) holds at that point or a later point in \( c \) [Lam94, CM88]. The program property \( p \sim q \) holds for a program \( F \) exactly when \( p \sim q \) holds for all computations of \( F \). The notion of a property is not, however, restricted to temporal properties such as \( \sim \). Examples of other kinds of properties will be seen in the paper. We use formulae that have both state-predicates and program properties, as, for instance in: \[ (p \sim q).F \land (q \sim r).F \Rightarrow (p \sim r).F \] As in [DS90] we use \([p]\) to denote the boolean: state predicate \( p \) holds in all states. Similarly, we use \([X]\) to denote the boolean: program property \( X \) holds for all conformant programs. For instance, the previous formula which holds for all programs \( F \) can be expressed as: \[ [(p \sim q) \land (q \sim r) \Rightarrow (p \sim r)] \] If there is any possibility of ambiguity when using \([X]\), we use the explicit notation: \((\forall F : \text{conforms} . F : X.F)\). 3 Program Composition and the Guarantees Operator 3.1 Parallel composition In this section, we assume the existence of a program composition operator \(||\), and use it to define an operator, called guarantees, on program properties. We require \(||\) to be associative and have an identity \( \text{SKIP} \). We also require that \(||\) and \(\text{conforms}\) satisfy \[ (\forall F,G : \text{conforms} . F || G \Rightarrow \text{conforms} . F \land \text{conforms} . G) \] (1) An immediate consequence of (1) is that either \( \text{SKIP} \) is conformant or there are no conformant programs. Note that \(||\) has higher binding power than function application. Most theorems require that \(||\) be commutative as well, and in such cases we make the commutativity assumption explicit. For commutative \(||\), we postulate the following pairwise property: if the composition of each pair of programs in a set is conformant, then the composition of all programs in the set is conformant as well: For any set of programs $G$: \[ (\forall G, G' : G, G' \in G : \text{conforms}.(G||G') \Rightarrow \text{conforms}.(\|G : g \in G : G)) \] (2) From (1) and (2): \[ (\forall G, G' : G, G' \in G : \text{conforms}.(G||G') = \text{conforms}.(\|G : g \in G : G)) \] (3) In this paper, we are only interested in conformant programs. For brevity, we often leave the restriction to conformant programs implicit. For example, we may write quantification over a set of programs as $(\forall H : \text{conforms}.(F||H) \Rightarrow Y.(F||H))$, instead of $(\forall H : \text{conforms}.(F||H) : X.(F||H) \Rightarrow Y.(F||H))$. 3.2 Definition of guarantees The dyadic operator $\text{guarantees}$ on program properties is defined as follows. For program properties $X$ and $Y$, we define a program property $(X \text{ guarantees } Y)$ as: \[ (X \text{ guarantees } Y).F \equiv (\forall H : \text{conforms}.F||H : X.F||H \Rightarrow Y.(F||H)) \] (4) Therefore, $(X \text{ guarantees } Y)$ is a property of a program $F$ if and only if all conformant programs that have $F$ as a component and have $X$ as a property also have $Y$ as a property. From the definition of guarantees: \[ [X \Rightarrow Y] \Rightarrow [X \text{ guarantees } Y] \] (5) We are, however, interested in cases where the fact that $F$ is a component allows the left side of the guarantees properties to be weaker than the right. In contrast to the rely/guarantee specifications mentioned in the introduction, the meaning of $(X \text{ guarantees } Y).F$ is not that if the environment $H$ of $F$ has property $X$ then the composed system $F||H$ has property $Y$ — it is that if the composed system $F||H$ has property $X$ then the composed system $F||H$ has property $Y$. By using only properties of the composed system instead of the properties of the environment, we obtain a simple theory in which $\text{guarantees}$ enjoys many of the properties of implication. 3.3 Theorems about Guarantees The proofs of these theorems are straightforward and are not given here. In these theorems, we use $\mathcal{X}$ and $\mathcal{Y}$ to denote sets of program properties. The next five properties are analogous to properties of implication. Universally Disjunctive for Left Operand \[ [(\forall X : X \in \mathcal{X} : X \text{ guarantees } Y)] \equiv (\exists X : X \in \mathcal{X} : X \text{ guarantees } Y] \] Universally Conjunctive for Right Operand \[ (\forall Y : Y \in \mathcal{Y} : X \text{ guarantees } Y) \equiv X \text{ guarantees } (\forall Y : Y \in \mathcal{Y} : Y) \] Transitive \[ ((X \text{ guarantees } Y) \land (Y \text{ guarantees } Z) \Rightarrow (X \text{ guarantees } Z)) \] Shunting \[ ((X \text{ guarantees } Y) \equiv (\text{true guarantees } (X \Rightarrow Y))) \] Contrapositive \[ ((X \text{ guarantees } Y) \equiv (\neg Y \text{ guarantees } \neg X)) \] Exists-component. Guarantees properties are exists-component properties. \[ (X \text{ guarantees } Y).G \equiv (\forall H : (X \text{ guarantees } Y).G \| H) \] Therefore, guarantees properties of a program \( G \) are inherited by all programs that have \( G \) as a component. 4 Weakest guarantees 4.1 Definition of component We define a function \( \text{component} \) from programs to program properties as follows: For a program \( F \), \( \text{component}.F \) is a property that holds for all programs that have \( F \) as a component and only such programs. \[ \text{component}.F.H \equiv (\exists G : \text{conforms}.F\|G : F\|G = H) \] The definition of equality of programs depends on the program model and how parallel composition is defined. From the definition of \( \text{component} \): \[ \text{component}.G.H \land \text{component}.H.F \Rightarrow \text{component}.G.F \] \[ (\forall F :: \text{component}.F.F) \] and for commutative \( \| \): \[ [\text{component}.F\|H \Rightarrow \text{component}.F \land \text{component}.H]. \] Next, we prove the following formula that is helpful in deriving theorems about the weakest guarantee. \[ (X \text{ guarantees } Y).F \equiv [X \Rightarrow (\text{component}.F \Rightarrow Y)] \] (6) Proof: \[(X \text{ guarantees } Y).F\] \[\equiv\quad \{ \text{definition of guarantees}\ \}\] \[\quad (\forall H :: X.H \land \text{component}.F.H \Rightarrow Y.H)\] \[\equiv\quad \{ \text{meaning of } []\ \}\] \[\quad [X \land \text{component}.F \Rightarrow Y]\] \[\equiv\quad \{ \text{predicate calculus}\ \}\] \[\quad [X \Rightarrow (\text{component}.F \Rightarrow Y)]\] 4.2 The property transformer \(wg.F\) A predicate transformer is a function from predicates to predicates. Likewise, a property transformer is a function from properties to properties. Motivated by the weakest precondition, \(wp\), we define \(\text{weakest guarantee}, \text{wg}\), and present theorems about \(\text{wg}\). For a program \(F\), \(\text{wg}.F\) is a property transformer defined as follows: for a property \(Y\), \(\text{wg}.F.Y\) is the weakest property \(X\) such that \((X \text{ guarantees } Y).F\): \[\text{wg}.F.Y = \text{weakest } X : (X \text{ guarantees } Y).F\] From (6): \[\text{wg}.F.Y \equiv \text{component}.F \Rightarrow Y\] From this definition, it follows that the property transformer \(\text{wg}.F\) is monotonic, universally conjunctive, and idempotent. 4.3 Theorems about \(\text{wg}\) We give several theorems about \(\text{wg}\). (We omit straightforward proofs.) **Component theorem** \[\text{[component}.F \Rightarrow (\text{wg}.F.Y \equiv Y)]\] (8) **Conjunction, disjunction and composition theorem** For commutative \(\|\), program property \(X\), and nonempty set of programs \(\mathcal{F}\): \[(\exists F :: F \in \mathcal{F} : \text{wg}.F.X).(\|F :: F \in \mathcal{F} : F) \equiv X.(\|F :: F \in \mathcal{F} : F)\] and \[(\forall F :: F \in \mathcal{F} : \text{wg}.F.X).(\|F :: F \in \mathcal{F} : F) \equiv X.(\|F :: F \in \mathcal{F} : F)\] Proof: Let \( \mathcal{F} = (\{F : F \in \mathcal{F} : F\} \). Then \[ true \Rightarrow \{ (8) \} \] \[ (\forall F : F \in \mathcal{F} : component.F.\mathcal{F} \Rightarrow (wg.F.X.\mathcal{F} \equiv X.\mathcal{F})) \] \[ \Rightarrow \{ || \text{ commutative, thus } F \in \mathcal{F} \Rightarrow component.F.\mathcal{F} \} \] \[ (\forall F : F \in \mathcal{F} : (wg.F.X.\mathcal{F} \equiv X.\mathcal{F})) \] \[ \Rightarrow \{ \text{ predicate calculus} \} \] \[ (\forall F : F \in \mathcal{F} : wg.F.X.\mathcal{F}) = X.\mathcal{F} \] \[ \land \] \[ (\exists F : F \in \mathcal{F} : wg.F.X.\mathcal{F}) = X.\mathcal{F} \] **Corollary: Properties in isolation** The next result shows that \( wg \) is sufficient to specify a program in isolation. From the component theorem (8), and using \( component.F.F \): \[ wg.F.Y.F \equiv Y.F \] 5 Towards compositional specifications We seek compositional proof techniques that allow us to prove properties of composed programs from properties of their components. Next we identify classes of properties that are useful for constructing compositional proofs. 5.1 Exists-Component Properties A program property \( X \) is an exists-component property if and only if, \[ X.G \equiv (\forall H :: X.G || H) \] (9) Therefore, for any set \( \mathcal{G} \) of programs, any exists-component property \( X \), and commutative \( || \): \[ (\exists G : G \in \mathcal{G} : X.G) \Rightarrow X.(|| G : G \in \mathcal{G} : G) \] (10) If there exists a component of a program that satisfies an exists-component property then the program itself also satisfies that property. **Theorem** For any exists-component property \( X \) and any program \( F \): \[ X.F \equiv [wg.F.X] \] Proof: \[ X.F \equiv \{ \text{ definition of exists-component } \} \] \[(\forall H :: X.F \| H) \equiv \{ \text{definition of component} \} \quad (\forall G :: \text{component}.F.G \Rightarrow X.G) \equiv \{ \text{definitions of } [] \text{ and } wg \} \quad [wg.F.X] \] As noted in section 3.3, guarantees properties are exists-component properties. For some properties and program models, the implication in (10) can be strengthened to equivalence; we call such properties strong exists-component properties. Thus, a property \(X\) is a strong exists-component property if and only if \[(\exists G : G \in \mathcal{G} : X.G) \equiv X.(||G : G \in \mathcal{G} : G) \quad (11)\] Setting \(\mathcal{G}\) to the empty set in this equation, we observe (false \(\equiv X.SKIP\)) that the program \(SKIP\) does not have any strong exists-component properties. We use strong exists-component properties in discussing refinement. ### 5.2 All-component properties For commutative \(\|\), a program property \(X\) is an all-component property if and only if, for any set \(\mathcal{G}\) of programs: \[(\forall G : G \in \mathcal{G} : X.G) \equiv X.(||G : G \in \mathcal{G} : G) \quad (12)\] A program has an all-component property if and only if all components of the program have that property [CS95]. From the definition, setting \(\mathcal{G}\) to the empty set, it follows that all-component properties are properties of the program \(SKIP\). **Theorem** For any all-component property \(X\) and any program \(F\): \[ (\exists H : \text{component}.F.H : X.H) \equiv X.F \] Proof is by implication in both directions: \[ X.F \\ \Rightarrow \{ \text{component}.F.F \} \\ (\exists H : \text{component}.F.H : X.H) \\ \Rightarrow \{ \text{definition of component} \} \\ (\exists G : F||G = H : X.H) \\ \Rightarrow \{ \text{definition of all-component property} \} \\ (\exists G : F||G = H : X.F \land X.G) \\ \Rightarrow \{ \text{predicate calculus} \} \\ X.F \] Theorem For any all-component property $X$ and any programs $F$ and $H$: $$\text{wg}.F.X.H \equiv (\forall G : F||G \equiv H : X.F \land X.G)$$ Proof: \[ (\forall G : F||G = H : X.F \land X.G) \\ \equiv \text{\{ definition of all-component \}} \\ (\forall G : F||G = H : X.H) \\ \equiv \text{\{ predicate calculus \}} \\ (\exists G : F||G = H) \Rightarrow X.H \\ \equiv \text{\{ definition of component \}} \\ \text{component}.F.H \Rightarrow X.H \\ \equiv \text{\{ definition of \text{wg} \}} \\ \text{wg}.F.X.H \] 5.3 Properties of the environment 5.3.1 The property transformer $\text{env}$ Often, for a program $F$, $\text{conforms}.F||G$ implies that program $G$ has a property that can be exploited in proofs. A common example is a program $F$ that encapsulates a locally-modifiable variable $u$, defined to be a variable that can only be modified by $F$. In this case $\text{conforms}.F||G$ implies that $G$ has the property that it leaves $u$ unchanged. To capture this, we introduce a new property transformer $\text{environment}$, denoted by $\text{env}$, where $\text{env}.X$ is a property of a program $F$ means that $X$ is a property of all programs that can be composed with $F$ in a conformant way. \[ (\forall F, X : \text{conforms}.F : \text{env}.X.F \equiv (\forall H : \text{conforms}.F||H : X.H)). (13) \] 5.3.2 Theorems about $\text{env}$ $\text{env}$ is universally conjunctive with respect to properties \[ [\text{env}.(\forall X : X \in \mathcal{X} : X) \equiv (\forall X : X \in \mathcal{X} : \text{env}.X)] \] As a consequence, $\text{env}$ is monotonic with respect to properties and strict with respect to property $\text{true}$. $\text{env}$ is strict with respect to property $\text{false}$ \[ [\text{env}.\text{false} \equiv \text{false}] \] **env. X is an exists-component property** For commutative \( \parallel : env. X. F = (\forall G : \text{conforms}. F|G : env. X. F||G) \) Proof: The proof uses a “ping-pong” style, proving implications in both directions. \[ \begin{align*} & (\forall G : \text{conforms}. F||G : env. X. F||G \\ & \quad \{ \text{definition of env (13) } \} \\ & = (\forall G : \text{conforms}. F||G : (\forall H : \text{conforms}. F||G||H : X.H)) \\ & \quad \{ \text{predicate calculus } \} \\ & = (\forall G, H : \text{conforms}. F||G \land \text{conforms}. F||G||H : X.H) \\ & \quad \{ \text{From (1) } \} \text{ conforms}. F||G||H \Rightarrow \text{conforms}. F||G \\ & \Rightarrow (\forall G, H : \text{conforms}. F||G||H : X.H) \\ & \quad \{ \text{let } G := \text{SKIP } \} \\ & = (\forall H : \text{conforms}. F||H : X.H) \\ & \quad \{ \text{definition of env } \} \\ & env. X. F \\ & \Rightarrow (\forall G : \text{conforms}. F||G||H \Rightarrow \text{conforms}. F||G, \parallel \text{ commutative } ) \\ & = (\forall G, H : \text{conforms}. F||G||H : X.H) \\ & \quad \{ \text{definition of env } \} \\ & (\forall G : \text{conforms}. F ||G : env. X. F||G \\ \end{align*} \] **Environment factorization** For all-component properties \(Y\) and \(Z\), \[ [env. X \land [X \land Y \Rightarrow Z] \land Z \Rightarrow Y \text{ guarantees Z}] \quad (14) \] **Left-side weakening** For any all-component property \(X\), \[ [env. X \land X \land (X \text{ guarantees } Y) \Rightarrow (\text{true guarantees } Y)] \quad (15) \] ## 6 Refinement We can replace one component of a program by another component if the replacement does not violate program correctness. If the specification of a program \(F||H\) is that the program must satisfy property \(X\), then we can replace component \(F\) by \(G\) if \(G||H\) also has property \(X\). We refer to \(H\) as the environment of \(F\) in the composed program \(F||H\). We define refinement of a program \(F\) by a program \(G\) with respect to a property \(X\) over an environment \(H\) as follows: \(F\) is refined by \(G\) with respect to \(X\) and \(H\) if and only if: \[ X.F||H \Rightarrow X.G||H \] \(F\) is refined by \(G\) with respect to \(X\) and all environments if the above formula holds for all programs \(H\). \(F\) is refined by \(G\) with respect to \(X\) in isolation if the above formula holds with \( H = \text{SKIP} \); therefore, \( F \) is refined by \( G \) with respect to \( X \) in isolation if and only if: \[ X.F \Rightarrow X.G \] The refinement theorem relates refinement in isolation and refinement over all environments. **The Refinement Theorem** Let \( X \) be any property that is a conjunction of all-component and strong exists-component properties. \( G \) refines \( F \) with respect to \( X \) and all environments if and only if \( G \) refines \( F \) with respect to \( X \) in isolation. \[ (\forall H :: X.F||H \Rightarrow X.G||H) \equiv (X.F \Rightarrow X.G) \tag{16} \] Proof: We prove the theorem by proving it for all-component properties; the proof for strong exists-component properties is similar and is omitted. **Lemma: Strong exists-component property refinement** Let \( X \) be a strong exists-component property. Then \[ (\forall H :: X.F||H \Rightarrow X.G||H) \equiv X.F \Rightarrow X.G \] Proof: \[ \begin{align*} (\forall H :: X.F||H \Rightarrow X.G||H) \\ \equiv (\forall H :: X.F \lor X.H \Rightarrow X.G \lor X.H) \\ \equiv (\forall H :: X.F \Rightarrow X.G \lor X.H) \\ \equiv (X.F \Rightarrow X.G \lor X.H \lor (\forall H :: X.F \Rightarrow X.G \lor X.H)) \\ \equiv (X.F \Rightarrow X.G \lor (\forall H :: X.F \Rightarrow X.G \lor X.H)) \\ \equiv (X.F \Rightarrow X.G \lor (\forall H :: X.F \Rightarrow X.G \lor X.H)) \\ \equiv (X.F \Rightarrow X.G \lor (\forall H :: X.F \Rightarrow X.G \lor X.H)) \\ \equiv (X.F \Rightarrow X.G) \end{align*} \] **Lemma: All-component refinement** For any all-component property \( X \): \[ (\forall H :: X.F||H \Rightarrow X.G||H) \equiv X.F \Rightarrow X.G \] Proof: \[ \begin{align*} (\forall H :: X.F||H \Rightarrow X.G||H) \\ \equiv (X.F \Rightarrow X.G) \\ \equiv (X.F \land X.H \Rightarrow X.G \land X.H) \end{align*} \] \[ \equiv \{ \text{predicate calculus} \} \] \[ (\forall H :: X.H \Rightarrow (X.F \Rightarrow X.G)) \] \[ \equiv \{ \text{predicate calculus} \} \] \[ (\exists H :: X.H \Rightarrow (X.F \Rightarrow X.G)) \] \[ \equiv \{ X \text{ is all-component, thus } X.SKIP, \text{ and setting } H := SKIP \} \] \[ \text{true} \Rightarrow (X.F \Rightarrow X.G) \] \[ \equiv \{ \text{predicate calculus} \} \] \[ X.F \Rightarrow X.G \] 7 Model-specific theory: an example We present a model which is a small generalization of the operational model in UNITY. This operational model helps to motivate our use of predicate transformers. The predicate transformers can also be used for models in addition to the one presented here. 7.1 Operational model A program is a 4-tuple \((V, L, C, D)\) where 1. \(V\) is a set of typed variables. This set of variables defines a state space in a state-transition system. Each state in the system is given by the values of the variables in \(V\). 2. \(L\) is a subset of \(V\). \(L\) is the set of locally modifiable variables. Local variables play a role in the definition of conformant composition. 3. \(C\) is a set of commands where each command terminates when initiated in any state, and each command has bounded nondeterminism. \(C\) includes the \textit{skip} command which leaves the state unchanged. The computation proceeds by nondeterministically selecting any command in \(C\), and executing it. 4. \(D\) is a subset of \(C\). The fairness requirement is that commands in \(D\) are executed infinitely often. (There is no fairness requirement for commands in \(C\) that are not in \(D\).) \[ (F = G) = (V_F = V_G \land L_F = L_G \land C_F = C_G \land D_F = D_G) \] Computations A program describes a state-transition system. There exists a transition from state $s$ to state $t$ in the state transition system if and only if there exists a command $c$ in $C$ where the execution of $c$ can take the system from $s$ to $t$. A computation is an infinite sequence of states $s_j$, $j \geq 0$, where: 1. There exists a transition in the state transition system from each state in the computation to the next. 2. For every command $d$ in $D$, there exists an infinite number of pairs of successive states $s_i, s_{i+1}$ in the computation such that execution of $d$ can take the system from $s_i$ to $s_{i+1}$. Parallel composition Letting $F = (V_F, L_F, C_F, D_F)$ and $G = (V_G, L_G, C_G, D_G)$, we define the parallel composition operator as follows: $$ F \parallel G = (V_F \cup V_G, L_F \cup L_G, C_F \cup C_G, D_F \cup D_G). $$ where $F \parallel G$ is conformant if and only if variables with the same name in $V_F \cup V_G$ have the same types, and variables in $L_F$ are modified only by commands in $C_F$ (which includes commands common to $C_F$ and $C_G$), and likewise variables in $L_G$ are modified only by commands in $C_G$. Some consequences of the definition are that $\parallel$ is commutative, associative and idempotent. The unit element for parallel composition is the program $\text{SKIP}$ where $$ \text{SKIP} = (\phi, \phi, \text{skip}, \phi) $$ In this model, the definition of component is $$ \text{component}. F.H \equiv (V_F \subseteq V_H) \land (L_F \subseteq L_H) \land (C_F \subseteq C_H) \land (D_F \subseteq D_H) $$ 7.2 Program properties of interest: Safety The State Predicate Transformer $awp.F$ For a program $F = (V, L, C, D)$ define a state-predicate transformer $awp.F$ as follows: $$ awp.F \equiv (\forall c : c \in C : wp.c) $$ (The letters in $awp$ stand for all wp because $awp.F$ is the conjunction of all the transformers $wp.c$.) Since all commands $c$ in $C$ terminate when initiated in any state, and since $c$ has bounded nondeterminism, $wp.c$ is a universally-conjunctive, or-continuous, state-predicate transformer. Therefore, $awp.F$ is likewise a universally-conjunctive or-continuous, state-predicate transformer. Since, $[wp.\text{skip}.q \equiv q]$, for all $q$: $$ [awp.F.q \Rightarrow q] $$ From the definition of parallel composition, \[ \text{awp} \cdot F || H \cdot q \equiv \text{awp} \cdot F \cdot q \land \text{awp} \cdot H \cdot q \] (17) **Next properties** For state predicates \( p \) and \( q \) we define a property \((p \text{ next } q)\) as follows: For a program \( F \), \[(p \text{ next } q) \cdot F \equiv [p \Rightarrow \text{awp} \cdot F \cdot q]\] Since \( \text{skip} \in C \), we have \[(p \text{ next } q) \cdot F \Rightarrow [p \Rightarrow q]\] The next property describes the next state relation of a program. (This property is based on Misra’s \( \alpha \) property [Mis95b], but there are some slight differences due to differences in the programming model.) The property \( p \text{ next } q \) holds for a program exactly when for all points in all computations of the program at which (state predicate) \( p \) holds, \( q \) holds at the next point in the computation. Therefore, \( p \text{ next } q \) holds for a program exactly when all transitions of the program from states in which \( p \) holds are to states in which \( q \) holds. **Lemma:** \( p \text{ next } q \) is an all-component property. Proof: Follows from the definition of \( \text{next} \). \[ (p \text{ next } q) \cdot F || H \\ \equiv \{ \text{definition of } \text{next} \} \\ [p \Rightarrow \text{awp} \cdot F || H \cdot q] \\ \equiv \{ \text{17} \} \\ [p \Rightarrow \text{awp} \cdot F \cdot q \land \text{awp} \cdot H \cdot q] \\ \equiv \{ \text{predicate calculus} \} \\ [p \Rightarrow \text{awp} \cdot F \cdot q] \land [p \Rightarrow \text{awp} \cdot H \cdot q] \\ \equiv \{ \text{definition of } \text{next} \} \\ (p \text{ next } q) \cdot F \land (p \text{ next } q) \cdot H \] **Stable** We define a useful function \( \text{stable} \) from state predicates to program properties as follows: \[ [\text{stable} \cdot q \equiv (q \text{ next } q)] \] If \( \text{stable} \cdot q \) holds for a program \( F \) then all transitions from states in which \( q \) holds are to states in which \( q \) holds. Since \( q \text{ next } q \) is an all-component property it follows that \( \text{stable} \cdot q \) is also an all-component property. **Initial States and Always** In our theory, the predicate that holds on initial states is a property that can be asserted about a program. Thus initially \( q \) is the property that asserts that all computations begin in a state satisfying \( q \). We typically have properties of the form (initially \( q \) guarantees \( X \)). The property always \( q \) is defined as follows: \[ \text{always} \ q \ = \ \text{stable} \ q \land \text{initially} \ q \] This property indicates that \( q \) holds at every point in all computations. As a result, we obtain the so-called substitution axiom [CM88, San91, SC96] that allows true and \( q \) to be interchanged in program properties\(^1\) \[ \text{always} \ q \ \Rightarrow \ (X = X|_{\text{true}}) \land (X = X|_{\text{true}}^q) \] A more complete discussion is given in [SC96]. ### 7.3 Program properties of interest: Progress **Transient** Transience [Mis95a] is a basic progress property of a system that follows from fairness assumptions. Let \( F = (V, L, C, D) \); we define a function transient from state predicates to program properties, as follows: \[ \text{transient} \ p \ F \ = \ (\exists d : d \in D : [p \Rightarrow \text{wp} \ d \ eg p]) \] Operationally, \( p \) is false infinitely often in every computation of every program that has \( F \) as a component because each command \( d \) in \( D \) is executed infinitely often, and there exists at least one command that establishes \( \neg p \) if \( p \) holds. From the definition of transient: transient \( p \) is a strong exists-component property. Therefore, \[ [\text{transient} \ p \Rightarrow (\text{true} \ \text{guarantees} \ \text{transient} \ p)] \] **Leads-to (\( \leadsto \)) properties** Leads-to properties are useful for describing progress. Operationally, \( (p \leadsto q) \ F \) holds if in every computation of \( F \), if \( p \) holds at some point in the computation, then \( q \) holds then or at a later point. Leads-to properties can be derived from transient and next properties. In [CM88], leads-to is defined as the strongest relation satisfying 3 axioms based on a simple progress property ensures. This axiomatization has been shown to be sound and relatively complete [San91, Rao91, Pac92]. A problem is that ‘ensures”, the key element in UNITY theory about progress is neither an all-component nor an exist component property. Below, we list an alternative axiomatization of leads-to that allows leads-to properties to be derived only from all-component and exist-component properties. \(^1\)We use the notation \( X|_r \) to indicate textual substitution of \( q \) with \( r \). 1. **Transient rule** \[ \text{transient } q \Rightarrow q \rightsquigarrow \neg q \] 2. **Implication rule** \[ q \Rightarrow r \Rightarrow [q \rightsquigarrow r] \] 3. **Disjunction rule** For arbitrary set of predicates \( Q \): \[ (\forall q : q \in Q : q \rightsquigarrow r) \Rightarrow (\exists q : q \in Q : q \rightsquigarrow r) \] 4. **Transitivitv rule** \[ q \rightsquigarrow r \land r \rightsquigarrow s \Rightarrow q \rightsquigarrow s \] 5. **PSP rule** \[ q \rightsquigarrow r \land s \text{ next } t \Rightarrow (q \land s) \rightsquigarrow (r \land s) \lor (\neg s \land t) \] The straightforward proof that these axioms are equivalent to those of [CM88], and thus sound and relatively complete, is omitted. From the axioms, we obtain \[ [\text{transient.} p \Rightarrow ((p \text{ next } p \lor q) \text{ guarantees } (p \rightsquigarrow q))] \] (18) ### 7.4 Properties of environment **Constant expressions** For any expression \( e \), we define the property \( \text{constant.} e \) as follows: \( \text{constant.} e . F \) holds if and only if all computations of \( F \) leave the value of \( e \) unchanged. Therefore \[ [\text{constant.} e = (\forall k : \text{stable.} (e = k))] \] Since locally modifiable variables are unchanged by other components: \[ (v \in L) \Rightarrow \text{env.}(\text{constant.} v).F \] **Local predicates** For a predicate \( p \), \( \text{local.} p \) is a property that holds if \( p \) mentions only variables in \( L \). We have \[ [\text{local.} p \Rightarrow \text{env.}(\text{constant.} p)] \] and from (15) and \([\text{constant.} p \Rightarrow p \text{ next } q]\), \[ [p \text{ next } q \land \text{local.} p \Rightarrow (\text{true guarantees } (p \text{ next } q))] \] (19) **Program properties** Let \( v \) be an integer variable. We define a property \( \text{nondecreasing}. v \) for a program to mean that the value of \( v \) does not decrease during computations of the program. Formally, this is expressed as \[ \text{nondecreasing}. v \equiv (\forall k :: \text{stable}. (v \geq k)) \] For two integer variables \( v \) and \( w \), we define a property \( w \text{ follows } v \), as: \[ w \text{ follows } v \equiv (\forall k :: v \geq k \implies w \geq k) \] From the proof rules for \( \implies \), \( \text{follows} \) is transitive. These properties are useful in developing compositional proofs of properties of composed programs. 8 Example 8.1 Overview We consider the following problem: The members of a committee, who are located at two or more sites, need to determine the earliest time, \( e \) at or after some given time \( t \), at which they can all meet.\(^2\) We structure the solution by dividing the members into geographic areas and letting each area determine the earliest meeting time that all members associated with that area can meet after some proposed time. The earliest times are combined to generate a new proposed meeting time until a time is found when all members can meet. This problem is simple enough to be handled easily without modularity. However, since different areas may use different techniques to determine the earliest meeting time of their subset of committee members, modular reasoning based on specifications of components is helpful, and also serves to illustrates our approach. 8.2 Specification **Definitions** For simplicity, we represent time as a non-negative integer. For each member \( m \) there is a function \( m.\text{earliest} \) mapping time to time such that \[ m.\text{earliest}.t = \text{earliest time at least } t \text{ when } m \text{ can meet.} \] \( m.\text{earliest} \) is monotonic and idempotent, and for technical reasons, we assume \( m.\text{earliest}.0 = 0 \). We define a boolean function \[ m.\text{free}.t \equiv (m.\text{earliest}.t = t) \] thus \( m.\text{free}.t \) holds if and only if \( m \) can meet at time \( t \). \(^2\)This is a special case of the problem of asynchronous computation of fixed points. Let $Com$ be the set of members of the committee and $S \subseteq Com$. Then $S.earliest.t$ is the earliest time at least $t$ that all members in $S$ can meet. $$S.earliest.t = (\min u : u \geq t : S.free.u)$$ where $$S.free.t = (\forall m : m \in S : m.free.t)$$ We assume that $Com.earliest.t$ exists for all $t$. **Components** $G(t,e,S)$ is a program that finds the earliest time $e$ at or after $t$ at which all members in set $S$ can meet. Let $S_i$ be subsets of members so that $S = (\cup i : S_i)$, and the cardinality of each subset is strictly smaller than that of $S$. (Subsets can have common members.) We propose to implement $G(t,e,S)$ as a parallel composition of components $G(u,a_i,S_i)$ for each subset $S_i$, and a coordinator program that computes the meeting time $e$ for all sites from the meeting times $a_i$ of subset $S_i$, all $i$. The coordinator is $C(t,e,u,A)$, where $A = (\cup i : \{a_i\})$. $$G(t,e,S) = C(t,e,u,A) || (\forall i : G(u,a_i,S_i))$$ First we define the locally-modifiable variables and their initial values. $S$ is a fixed set, $e$ is a locally-modifiable variable with initial value 0, and $t$ is unmodified by $G(t,e,S)$. The same restrictions (with appropriate actual variables) applies to $G(u,a_i,S_i)$. Variables $u$ and $e$ are locally-modifiable in $C(t,e,u,A)$, and their initial values are set by $C$ to be 0. $C$ leaves $t$ and $A$ unchanged. All shared variables are passed explicitly as parameters; so, for instance, $G(u,a_i,S_i)$ does not access $t$. These restrictions allow $C(t,e,u,A)$ and $G(u,a_i,S_i)$ all $i$ to be composed in parallel. Now, we give the guarantees properties in a table where the left column is the antecedent and the right column is the consequent. All entries in a box are to be conjoined and all items mentioning subscript $i$ are implicitly quantified over all $i$. **Guarantees Properties for $G(t,e,S)$** | nondecreasing $t$ | always ($e \leq S.earliest.t$) \[ (20) \] | true | always ($S.free.e$) \[ nondecreasing.e \] From the above properties, the value of $S.earliest.T$ for any time $T$ can be determined in the following way: the environment of $G$ sets $t$ to $T$, and leaves $t$ unchanged until $e \geq t$, at which point, $e = S.earliest.T$. 19 Guarantees Properties for \( C(t,e,u,A) \) <table> <thead> <tr> <th>true</th> <th>nondecreasing.e</th> <th>nondecreasing.u</th> </tr> </thead> <tbody> <tr> <td>nondecreasing.t</td> <td>always ((e \leq S.earliest.t))</td> <td>always ((S.free.e))</td> </tr> <tr> <td>nondecreasing.a_i</td> <td>(a_i) follows (S.earliest.u)</td> <td>(e) follows (S.earliest.t) (\text{(21)})</td> </tr> <tr> <td>always (\left((a_i \leq S.earliest.u)\right))</td> <td>always (\left((S.free.a_i)\right))</td> <td>(a_i) follows (S.earliest.u)</td> </tr> <tr> <td>always (\left((S.free.a_i)\right))</td> <td>(a_i) follows (S.earliest.u)</td> <td>(\text{true guarantees} \ nondecreasing.u)</td> </tr> <tr> <td>(a_i) follows (S.earliest.u)</td> <td>(\text{true guarantees} \ nondecreasing.u)</td> <td>(\text{true guarantees} \ nondecreasing.u)</td> </tr> </tbody> </table> 8.3 Proof of the composed program The properties of the program \( G(t,e,S) \) are derived from properties of its components. The proofs are straightforward, for the purposes of illustration, we give a detailed proof of (20). **Proof of (20)**: Since guarantees is an exist component property, the following component properties hold in \( G \): \[ (\forall i :: \text{nondecreasing.u guarantees} \ (a_i \text{ follows } S.earliest.u)) \tag{22} \] \[ \text{nondecreasing.t } \land (\forall i :: (e_i \text{ follows } S.earliest.u)) \] \[ \text{guarantees} \ (e \text{ follows } S.earliest.t) \tag{23} \] \[ \text{true guarantees} \ nondecreasing.u \tag{24} \] Now, we have \[ \text{true} \quad \Rightarrow \quad (\forall i :: \text{true guarantees} \ (a_i \text{ follows } S.earliest.u)) \] \[ (\forall i :: \text{true guarantees} \ (a_i \text{ follows } S.earliest.u)) \] \[ (\text{true guarantees} \ (\forall i :: (a_i \text{ follows } S.earliest.u))) \] \[ (\text{true guarantees} \ (\forall i :: (a_i \text{ follows } S.earliest.u))) \] \[ (\text{true guarantees} \ (\forall i :: (a_i \text{ follows } S.earliest.u))) \] \[ (\text{true guarantees} \ (\forall i :: (a_i \text{ follows } S.earliest.u))) \] \[ (\text{true guarantees} \ (\forall i :: (a_i \text{ follows } S.earliest.u))) \] The previous proof illustrated how the proof rules for guarantees, which can be used to prove the properties of a program from guarantees properties of its components. Note that once we used the exist component rule to lift the properties of the components to \( G \), the other proof rules needed were the same as rules for implication. 8.4 Implementation of the Program Components Implementation of $C(t,e,u,A)$ Now, we give possible implementation of $C(t,e,u,A)$. Initially $e = 0$ and $u = 0$. The program has two commands both of which are executed infinitely often: 1. if $(\forall i :: u = a_i)$ then \{ $e := \max(u,e); u := \max(u,t);$ \} 2. if $u < \max_i \{a_i\}$ then $u := \max_i \{a_i\}$ The proofs are straightforward, except for the progress property (21). This proof required proof of two transient properties and induction and is sketched in the appendix. This property illustrates one of the advantages of our approach. Many rely/guarantee approaches require the left side to be a safety property, and the right side to be a property that holds for the component in isolation. For this example, that would have forced us to do the induction after each program composition, rather than doing it once and capturing the results of the complicated proof in the specification of $C$. Implementations of $G$ Singleton Sets If $S$ has only a single member, then a design for program $G(t,e,S)$ is as follows. Initially $e = 0$. The program has the following single command which is executed infinitely often: $e < S.F.t \rightarrow e := S.F.t$ Sets with more than one member If $S$ has more than one member, then partition $S$ into $k$ nonempty subsets, $S_i$ where the cardinality of each subset $S_i$ is strictly less than the cardinality of $S$. Implement $G(t,e,S)$ as a parallel composition of a program $C(t,e,u,A)$ where $A = (\cup : 0 \leq i < k : \{a_i\})$, and program $G(u,a_i,S_i)$, for $0 \leq i < k$. Process $G(u,a_i,S_i)$ computes the earliest time at or after $u$ at which all members of set $S_i$ can meet. Process $C$ computes the meeting time for the entire set $S$ from the meeting times of each of the subsets $S_i$. 9 Related work Predicate transformers The relationship between Hoare logic [Hoa69] and $wp$ was a motivation for our definition of $wg$. Just as the triple (or property) $\{p\}F\{q\}$ can be defined as $[p \Rightarrow wp.F.q]$ for a sequential program $F$, we have defined the property $X$ guarantees $Y$ as $[X \Rightarrow wg.F.Y]$. Since Dijkstra's initial formulation of predicate transformers for the language of guarded commands, weakest precondition predicate transformers have been developed for other sequential constructs such as recursion and various notions of fairness [Nel89, Hes92, BN94]. For concurrency, additional predicate transformers such as sin, win [Lam90] and several temporal properties [JKR89, CS95, DS96] have been proposed. Predicate transformers have also been used as a basis for defining program refinement [BvW89, Bac89, GM91, San96] for both sequential and concurrent programs. The advantage of this work is that once appropriate predicate transformers have been defined, reasoning can be carried out in the familiar context of predicate calculus. The treatment of properties as predicates on programs, and the use of both predicates on programs and predicates on states in formulae, is found in [CS95]. This approach coupled with the results on predicate transformers led to our idea of a predicate transformer for dealing with parallel program composition. Variants of rely/guarantee specifications have been proposed in numerous papers including [Jon83, AL93, MS96], for layered systems in [LS94, LS92], in temporal logic frameworks in [Pnu84, Sta85], and for TLA in particular in [AL95]. The temporal logic approaches are more expressive than ours in the sense that the specifications are statements about individual computations. For example, in [AL95], \( E \uparrow \rightarrow M \) means that for each computation, the component will satisfy \( M \) for at least one step longer than the environment satisfies \( E \), where \( E \) is a safety property. In contrast, a similar specification in our approach would be essentially: If all computations satisfy \( E \), then all computations satisfy \( M \). A difference is that both the property relied upon and the property guaranteed, in our theory, are properties of the composed system: we do not use one property for the environment and the other for the component or system, and our model does not have restrictions on sharing of state between components. An axiomatic semantics based on predicate transformers for rely/guarantee properties for UNITY with local variables has been given in [Col94, CK95]. They define properties of the form \( F \text{ sat } P \text{ w.r.t. } R \) where \( F \) is a program, \( P \) is a UNITY property such as leads-to, and \( R \) is an interference predicate constraining the next state relation of the environment. Two components cooperare with respect to their interference predicates if neither violates the interference predicate of the other. Proof rules allow rely/guarantee properties of compositions that cooperate with respect to the interference predicates to be derived from the rely/guarantee properties of the components. Our ideas, particularly with regard to the all-component and exists-component properties are directly influenced by UNITY. The point of departure is that our guarantees properties do not deal with properties of environments and components. 10 Summary Predicate-transformers form the basis for axiomatic semantics for sequential programming. Many researchers have contributed to a deep and elegant theory of transformers. This paper applied the theory to an associative program composition operator $\|$ which has an identity element. Our theory uses predicates on states of programs, and predicates on programs. We defined a program property as a predicate on programs. We introduced a dyadic operator \( \texttt{guarantees} \) on program properties where \( X \texttt{ guarantees} Y \) has a different meaning than the traditional meaning of guarantee \( Y \) relying on \( X \). The \( \texttt{guarantees} \) operator has many of the properties of implication. We identified three useful kinds of properties, \( \texttt{exists-component} \) properties, \( \texttt{all-component} \) properties, and encapsulation properties. We defined a property transformer \( \texttt{weakest guarantee} \), and presented theorems about the property, and showed how it can help in modular reasoning about programs composed with $\|$. Experience has shown that the theory of predicate transformers is very valuable in sequential programming. Using predicate transformers for $\|$ has the advantage that the powerful theory, developed initially for sequential programming, can be applied to a different program composition operator. A unified theory for a collection of program composition operators has benefits. References [CK95] Pierre Collette and Edgar Knapp. Logical foundations for compositional verification and development of concurrent programs in UNITY. In Fourth International Conference on Algebraic Methodology and Software Technology, 95. 11 Appendix We sketch the proof of (21), omitting steps that are just applications of UNITY-style proof rules in order to focus on compositional reasoning as presented in this paper. The desired property is \((e \text{ follows } Searliest.t). C\). In the interest of brevity, we will omit the argument \(C\) in the following. **Lemma 1** \[ X \land Y \land \text{nondecreasing}.t \text{ guarantees } e \text{ follows } Searliest.t \] where \[ X = (u = k \leadsto (\forall i : a_i = u) \land u = Searliest.k) \] and \[ Y = ((\forall i : a_i = u) \land u = Searliest.k \leadsto e \geq Searliest.k \land u \geq t). \] **Lemma 2** From the text of \(C\), \[ \text{transient}.((\forall i : u = a_i) \land u = k \land \neg(e \geq k \land u \geq t)) \] **Lemma 3** From lemma 2 and (18), \[ Z \text{ guarantees } (\forall i : a_i = u) \land u = k \leadsto e \geq k \land u \geq t \] where \[ Z = (\forall i : u = a_i) \land u = k \land \neg(e \geq k \land u \geq t) \] \[ \text{next} \] \[ ((\forall i : u = a_i) \land u = k) \lor (e \geq k \land u \geq t) \] Lemma 5 From lemmas 1 and 3, \[ X \land Z \land \text{nondecreasing } t \text{ guarantees e follows } S.earliest.t \] Lemma 6 From the text of \( C \), \[ Z.\!C \] Lemma 7 \[ [\text{always} (a_i \leq S_i.earliest.u) \land \text{nondecreasing } a_i \land \text{always } (S_i.free.a_i) \land \text{constant } u \implies Z] \] Lemma 8 From lemmas 6 and 7 with 14 and \( env \cdot \text{constant } u \), \[ (\forall i :: \text{always } a_i \leq S_i.earliest.u) \land (\forall i :: \text{nondecreasing } a_i) \land (\forall i :: \text{always } (S_i.free.a_i)) \text{ guarantees } Z \] Now, it remains to find a convenient guarantees properties for \( X \). Lemma 9 From the text of \( C \), \[ \text{transient} . (\max_i a_i \geq k) \land u < l \] Lemma 10 From lemma 9 and (18), \[ (\forall i :: \text{nondecreasing } a_i) \text{ guarantees } \max_i \{a_i\} \geq k \implies u \geq k \] Lemma 11 \[ (\forall i :: a_i \text{ follows } S_i.earliest.u) \land (\forall i :: \text{nondecreasing } a_i) \text{ guarantees } u \geq k \implies \max_i \{a_i\} \geq \max_i \{(S_i.earliest.k)\} \] Lemma 12 From lemmas 10 and 11, and induction, \[ (\forall i :: a_i \text{ follows } S_i.earliest.u) \land (\forall i :: \text{nondecreasing } a_i) \text{ guarantees } u \geq k \implies u \geq S.earliest.k \] Lemma 13 From lemma 12 and \((\forall l : k \leq l \leq S.earliest.k : S.earliest.l = S.earliest.k)\), \[ (u \geq k \land u \leq S.earliest.k \land (\forall i :: a_i = u) \land next.u \leq S.earliest.k \wedge (\forall i :: always(S_i.free.a_i)) \wedge (\forall i :: always(a_i \leq S_i.earliest.a_i)) \wedge (\forall i :: a_i follows S_i.earliest.u) \wedge (\forall i :: nondecreasing.a_i)) guarantees X \] The right side of the next property only mentions \(u\), which is locally-modifiable in \(C\). The property therefore holds if it holds in \(C\). Since this is indeed the case, we can simplify the above to Lemma 14 \[ (\forall i :: always(S_i.free.a_i)) \wedge (\forall i :: always(a_i \leq S_i.earliest.a_i)) \wedge (\forall i :: a_i follows S_i.earliest.u) \wedge (\forall i :: nondecreasing.a_i) guarantees X \] From lemmas 5 and 14, we conclude (21).
{"Source-Url": "http://ufdcimages.uflib.ufl.edu/UF/00/09/53/95/00001/1996233.pdf", "len_cl100k_base": 14938, "olmocr-version": "0.1.50", "pdf-total-pages": 28, "total-fallback-pages": 0, "total-input-tokens": 95983, "total-output-tokens": 18999, "length": "2e13", "weborganizer": {"__label__adult": 0.0004143714904785156, "__label__art_design": 0.0004687309265136719, "__label__crime_law": 0.0004944801330566406, "__label__education_jobs": 0.0017614364624023438, "__label__entertainment": 9.506940841674803e-05, "__label__fashion_beauty": 0.00019073486328125, "__label__finance_business": 0.0004737377166748047, "__label__food_dining": 0.0004673004150390625, "__label__games": 0.0011205673217773438, "__label__hardware": 0.000918865203857422, "__label__health": 0.0008749961853027344, "__label__history": 0.0003275871276855469, "__label__home_hobbies": 0.0001589059829711914, "__label__industrial": 0.000591278076171875, "__label__literature": 0.0006728172302246094, "__label__politics": 0.0003719329833984375, "__label__religion": 0.0006995201110839844, "__label__science_tech": 0.06298828125, "__label__social_life": 0.0001176595687866211, "__label__software": 0.00702667236328125, "__label__software_dev": 0.91845703125, "__label__sports_fitness": 0.0002913475036621094, "__label__transportation": 0.0007214546203613281, "__label__travel": 0.00019812583923339844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 58791, 0.02238]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 58791, 0.38979]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 58791, 0.78727]], "google_gemma-3-12b-it_contains_pii": [[0, 2107, false], [2107, 5065, null], [5065, 7415, null], [7415, 9942, null], [9942, 12334, null], [12334, 14077, null], [14077, 15858, null], [15858, 17649, null], [17649, 19547, null], [19547, 21334, null], [21334, 23703, null], [23703, 25558, null], [25558, 27358, null], [27358, 29658, null], [29658, 31842, null], [31842, 34495, null], [34495, 36274, null], [36274, 38519, null], [38519, 40787, null], [40787, 43133, null], [43133, 45293, null], [45293, 48370, null], [48370, 50716, null], [50716, 52825, null], [52825, 54757, null], [54757, 56605, null], [56605, 57925, null], [57925, 58791, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2107, true], [2107, 5065, null], [5065, 7415, null], [7415, 9942, null], [9942, 12334, null], [12334, 14077, null], [14077, 15858, null], [15858, 17649, null], [17649, 19547, null], [19547, 21334, null], [21334, 23703, null], [23703, 25558, null], [25558, 27358, null], [27358, 29658, null], [29658, 31842, null], [31842, 34495, null], [34495, 36274, null], [36274, 38519, null], [38519, 40787, null], [40787, 43133, null], [43133, 45293, null], [45293, 48370, null], [48370, 50716, null], [50716, 52825, null], [52825, 54757, null], [54757, 56605, null], [56605, 57925, null], [57925, 58791, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 58791, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 58791, null]], "pdf_page_numbers": [[0, 2107, 1], [2107, 5065, 2], [5065, 7415, 3], [7415, 9942, 4], [9942, 12334, 5], [12334, 14077, 6], [14077, 15858, 7], [15858, 17649, 8], [17649, 19547, 9], [19547, 21334, 10], [21334, 23703, 11], [23703, 25558, 12], [25558, 27358, 13], [27358, 29658, 14], [29658, 31842, 15], [31842, 34495, 16], [34495, 36274, 17], [36274, 38519, 18], [38519, 40787, 19], [40787, 43133, 20], [43133, 45293, 21], [45293, 48370, 22], [48370, 50716, 23], [50716, 52825, 24], [52825, 54757, 25], [54757, 56605, 26], [56605, 57925, 27], [57925, 58791, 28]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 58791, 0.01113]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
11c76f3319e62f2a69d07ac0592cafc91e86873d
ABSTRACT Goals are central to the design and implementation of intelligent software agents. Much of the literature on goals and reasoning about goals in agent programming frameworks only deals with a limited set of goal types, typically achievement goals, and sometimes maintenance goals. In this paper we extend a previously proposed unifying framework for goals with additional richer goal types that are explicitly represented as Linear Temporal Logic (LTL) formulae. We show that these goal types can be modelled as a combination of achieve and maintain goals. This is done by providing an operationalization of these new goal types, and showing that the operationalization generates computation traces that satisfy the temporal formula. Categories and Subject Descriptors I.2.11 [Artificial Intelligence]: Distributed Artificial Intelligence—Intelligent agents, languages and structures; I.2.5 [Artificial Intelligence]: Programming Languages and Software; F.3.3 [Logics and Meaning of Programs]: Studies of Program Constructs; D.3.3 [Programming Languages]: Language Constructs and Features General Terms Theory, Languages Keywords Agent Programming, Goals, Formal Semantics 1. INTRODUCTION A widely-accepted approach to designing and programming agents is the cognitive approach, where agents are modeled in terms of mental concepts such as beliefs, goals, plans and intentions. Of the various concepts that have been used for cognitive agents, a key concept is goals. This is because agents are (by common definition) proactive, and goals are what allow agents to be proactive. It is also noteworthy that (the existence of explicitly represented) goals is one of the clearer differences between (proactive) agents and active objects. Goals have been extensively studied in artificial intelligence and multi-agent systems (e.g. [2, 13, 16, 21]). Earlier work focused mostly on achievement goals, which represent a desired state that the agent wants to reach. However, increasingly other goal types are being studied such as maintenance goals, which represent a state the agent wants to maintain, and perform goals, which represent the goal to execute certain actions (e.g., [4, 7, 8, 11]). However, only considering a small number of goal types can be limiting, since in practical applications there may be goals that cannot be captured well by achievement or maintenance or perform goals. To make this discussion more concrete, consider a personal assistant agent that manages a user’s calendar and tasks. One goal the agent may have is booking a meeting. This would typically be modelled as an achievement goal that aims to bring about a state where all required participants have the meeting in their calendar. However, in practice, diaries change, and we want to ensure that the meeting remains in participants’ diaries, and that should a key participant become unable to attend, a new time will be negotiated. This is not captured by an achievement goal. Rather, it is better modelled by a combined “achieve then maintain” goal which achieves a certain condition, and then maintains it over a certain time period. Another task that we might want the agent to undertake is to ensure that booking travel is not done until the budget is approved. Note that budget approval may be under the control (or perhaps just influence) of the agent, i.e. the agent may have plans for attempting to have the budget approved. Alternatively, it may be completely outside the agent’s control, in which case the agent can just wait for it to happen and then enable the travel booking process. Temporal logic is also used by MertakuM [10], but it is used directly for agent execution, whereas we use temporal logic as a design framework for specifying goal types which are mapped to existing implementations of achieve and maintenance goals. Additionally, MertakuM requires a particular format for its rules: all rules are in one of the three forms: start \( \rightarrow \varphi \), or \( \psi \rightarrow \neg \varphi \) or \( \psi \rightarrow \varphi \) where \( \varphi \) is a disjunction of literals, \( \psi \) is a conjunction of literals, and \( \varphi \) is a positive literal. In this paper, we propose an approach that is somewhere in between those focusing on a limited set of goal types and those in which arbitrary LTL formulae can be taken as goals. We propose an approach in which goals that are represented by relatively complex LTL formulae are operationalized by translating these LTL formulae to more basic achieve and maintain goals. The advantage of this approach is that the goal types can be integrated in existing agent programming frameworks that already have an operationalization of achieve and maintain goals. We illustrate the approach by showing how a number of LTL formulae can be translated to achieve and maintain goals. This paper builds on previous work [19] which presented a unifying framework for goals based on viewing goals as LTL formulae that described desired progressions. This previous work captured existing basic goal types, whereas we propose a framework that allows the use of richer goal types. Section 2 provides a brief description of the unifying framework on which we build. Section 3 presents the new goal types which are formalized and realised in sections 4 and 5. Finally, in Section 6 we conclude the paper and discuss some future directions. 2. A UNIFYING FRAMEWORK FOR GOAL TYPES This paper builds on the framework of van Riemsdijk et al. [19] in which a goal type is informally considered as a property characterising a set of computation traces. The framework is explained in terms of an abstract architecture for operationalizing goals such as achieve and maintain goals. In particular, the operationalized architecture aims to capture essential aspects of goals in agent programming frameworks in terms of properties of computation traces, abstracting from particular goal types. The framework models goals as follows. The state includes state-related propositions, which capture the state of the world, as well as propositions of the form done,(a) which capture the performance of actions. This approach takes an abstract view of a goal type as a particular pattern, or structure, of a formula in Linear Temporal Logic (LTL). A given LTL formula corresponds to a set of traces which make it true, and is viewed as a goal in that it allows a given system trace to be classified as satisfying the goal or not. van Riemsdijk et al. [19] defined four commonly-used goal types: achievement goal, (reactive) maintenance goal1, perform goal, and query goal. These goals are classified into a taxonomy (below), and an operationalization is provided for them within a single framework, using a simple execution cycle which was extended with additional rules of the form (condition, action) where actions could be to SUSPEND, ACTIVATE or DROP a goal. A key feature of this approach is that it balances flexibility with being structured enough to ensure desired properties of goals, and hence for it to make sense for the resulting constructs to be called “goals”. A range of desired properties of goals have been identified in the literature. Winikoff et al. [21, Section 2] survey existing literature and, based on this, identify the following desired properties of goals: 1. Persistent: goals should only be dropped for a good reason. 2. Unachieved: goals should not already hold; alternatively, they are dropped when they are achieved. 3. Possible: goals should be dropped when they are impossible to achieve. 4. Known: the agent should be aware of its goals. In implementation terms, this implies a measure of reflectiveness. 5. Consistent: goals should not be in conflict with other adopted goals. A number of additional properties are identified by [4]. Some of these (Producible/Terminable and Suspendable) simply correspond to the existence of a goal life-cycle. The others (Variable Duration and Action Decoupled) relate to the notion of long term goals that they argue for. One advantage of the proposed goals framework is that the properties representing a specific goal type can be dealt with in a general and systematic way. Suppose we have a goal φ of a certain type. The framework maps φ to a goal construct g(R,...) where R is a collection of rules (derived from φ) that govern transitions between goal states. We can then show that the goal’s realization meets the properties of being persistent, unachieved, and possible, by requiring that the operationalization of g(R,...) results in the goal being dropped exactly when φ becomes known to be true, or known to be impossible. For example, consider the goal to achieve p. This is mapped [19, Section 3.3.1] to g(R,...) where R consists of two rules: one to activate the goal when it is adopted, and one to drop the goal when s ∨ f becomes true, where s is the “success condition”, i.e. when the goal is succeeded, here s = p; and f is a description of a condition under which the goal becomes impossible to achieve. Here f depends on properties of p, but may be simply false, if it always remains possible to achieve p. Then it is straightforward to show that, under the operational semantics for goals defined by [19], the goal g(R,...) is dropped exactly when p becomes known to be true, or known to be impossible (properties 1–3, above). The property of being known (property 4) is achieved by having an explicit goal base which allows the agent to reflect on which goals it has. Consistency (property 5) concerns interactions between goals, and is beyond the scope of this paper. 3. NEW GOAL TYPES In this paper, goals are represented explicitly as specific formulae in Linear Temporal Logic (LTL) [9]. While [19] defined the notion of goal as representing preferred progressions, and informally referred to LTL to explain this, the operationalization itself did not use LTL explicitly in the representation of goals. The LTL formulae that we use to represent goals are defined by the following grammar. In addition to basic propositions (p), and standard propositional connectives, it has the temporal connectives ⊢ (“eventually”), □ (“always”), and U (“until”). We use standard abbreviations such as ⊢ p ⊢ ¬p and φ1 ⊢ φ2 pro¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬‐ We use $M_i$ to denote the $i$th state in $M$. \[ \begin{align*} M_i, i & \models p \quad \text{iff} \quad p \in M_i \\ M_i, i & \models \neg \phi \quad \text{iff} \quad M_i, i \not\models \phi \\ M_i, i & \models \phi_1 \land \phi_2 \quad \text{iff} \quad M_i, i \models \phi_1 \quad \text{and} \quad M_i, i \models \phi_2 \\ M_i, i & \models \phi \quad \text{iff} \quad \exists k \geq i : M_i, k \models \phi \\ M_i, i & \models \neg \phi \quad \text{iff} \quad \forall k \geq i : M_i, k \models \phi \\ M_i, i & \models \phi_1 \land \phi_2 \quad \text{iff} \quad \exists k \geq i : M_i, k \models \phi_2 \quad \text{and} \\ & \quad \forall j \text{ such that } i \leq j < k : M_i, j \models \phi_1 \end{align*} \] We now extend the taxonomy of [19] with additional goal types, including those discussed in the introduction. Specifically, the personal assistant agent example introduced new goal types. The first, booking a meeting and then maintaining participant availability, can be formalised as follows. Let $pa$ be short for participantsAvailable, $ms$ be short for meetingScheduled, and $mo$ be short for meetingOccurs, then we represent the goal of booking a meeting as the following LTL formula: \[\diamond (ms \land (pa \land mo))\] Considering the second goal, not booking travel until the budget has been approved, this can be formalised as: \[\neg \text{bookTravel} \land \text{budgetApproved}\] Abstracting from the specific goal instances to general goal types, we have defined goal types of the form $\diamond (\phi_1 \land (\phi_2 \land \tau))$ (achieve $\phi_1$ and then maintain $\phi_2$ until $\tau$), and $\phi \land \tau$ (maintain $\phi$ until $\tau$). We now generalise these goal types by considering a range of ways in which a (non-temporal) property $\phi$ can be required to hold over a number of states. Consider a multiple-state goal where a (non-temporal) property $\phi$ is required to hold over a number of states in the trace. The taxonomy in the previous section (from [19]) only supports a single multiple-state goal. However, there are a number of ways in which a goal pattern can apply to a sequence of states. It can apply: 1. to all states: $\Box \phi$; 2. at the start of the trace: $\phi \land \tau$, where $\tau$ is a formula that describes the state at which $\phi$ is no longer required to be true; 3. at the end of the trace: $\Diamond (\tau \land \Box \phi)$, where $\tau$ is a “trigger” formula that describes the state at which $\phi$ begins to be required to be true; or 4. in the middle of the trace: $\Diamond (\tau \land (\phi \land \tau'))$, where $\tau$ is the starting trigger and $\tau'$ the ending trigger; or 5. it can apply to a number of sub-sequences of states: $\Box (\tau \land (\phi \land \tau'))$, where $\tau$ is a trigger that describes a state at which $\phi$ begins to be required to hold, and $\tau'$ describes the states at which $\phi$ is no longer required to hold. These cases for multiple-state goal types are summarised in Figure 1. Note that in all cases we require that $\phi$ hold at all states within the specified region. Considering the personal assistant example, the first goal $\Diamond (ms \land (pa \land mo))$ corresponds to the fourth case above and the second goal corresponds to the second case above. Note that we could also consider a goal where $\neg \text{bookTravel}$ must hold on different sequences of states, e.g., that once there is no more money in the budget ($nmm$) then travel cannot be booked until a (new) budget is approved, formally: $\Box (nmm \rightarrow (\neg \text{bookTravel} \land \text{budgetApproved}))$. --- This goal would be expected to be used in conjunction with a goal to book travel, $\diamond \text{bookTravel}$. --- **4. REALISING THE NEW GOAL TYPES** The most characterising feature of our programming approach is to represent goals explicitly as temporal formulae and to operationalize these formulae in terms of achieve and maintain goals. The advantage of this approach is that achieve and maintain goal types have already well-defined operational semantics in some of the existing agent programming frameworks (e.g., 2APL [6], Jaclan [15], and J ACK [5]) such that our goal types can be used to extend these frameworks. In order to realise the new goal types in an operational setting, we assume that an agent configuration comprises a belief base, consisting of propositional atoms, and two goal bases. The first goal base, called the temporal goal base, contains goals specified by temporal LTL formulae. The second goal base, called the basic goal base, consists of achieve goals of the form $A(\phi)$ (read as: $\phi$ should be achieved) and maintain goals of the form $M(\phi, \tau)$ (read as: $\phi$ should be maintained until $\tau$), where $\phi$ and $\tau$ are propositional formulae. The maintain goal $M(\phi, \tau)$ represents that $\phi$ should be maintained indefinitely. The operationalization of temporal goal types can then be defined in terms of operations on temporal and basic goal bases. In this paper, we assume that the achieve and maintain goals have a correct operationalization. In particular, for the achieve goal we assume that if $A(\phi)$ is in the basic goal base, then the agent belief base will eventually entail $\phi$, and for the maintain goals we assume that if $M(\phi, \tau)$ is in the basic goal base, then the agent belief base entails $\phi$ until $\tau$ is entailed by the belief base. The latter assumption thus ensures that there is no need for reachieving $\phi$ (typically referred to as reactive maintain goals), since we assume it does not become false once the basic maintain goal has been adopted. basic maintain goal is thus interpreted as proactive avoiding the violation of desired states. Clearly, our assumption for the achieve goal is realistic as many agent programming languages such as 2APL [6] provide already programming constructs to implement achieve goals with the correct interpretation. Also, our assumption for the maintain goal is realistic as there exist operationalization proposals for the maintain goals [11] that perform lookahead steps to avoid generating execution paths where the goal is violated. For the purposes of this paper we want to show that our framework realises temporal goals correctly if we have correct operationalization of achieve and maintain goals. The idea is that the temporal goal $\Diamond \phi$ can be operationalised by adding the achieve goal $A(\phi)$ to the basic goal base. Similarly, the temporal goal $\phi \cup \tau$ can be operationalised by adding the maintain goal $M(\phi, \tau)$ to the basic goal base. More complex temporal goals can be operationalized by adding both achieve and maintain goals to the basic goal base, as will be shown in the sequel. In our framework, goals have a life cycle as illustrated in Figure 2. Both temporal (top) and basic (bottom) goals begin in an initial state (I), and can then be either in active (A) or suspended (S) states. For the reasons explained in the next section, a temporal goal can be adopted entering in a suspended state and a basic goal (either an achieve or a maintain goal) can be adopted entering in the active state. A temporal goal in a suspended state can be activated after which it can be either suspended again or dropped. A basic goal in an active state can be either suspended or dropped. While temporal goals are assumed to be given by an agent program (specified by an agent programmer), the basic (achieve and maintain) goals are adopted as a consequence of processing temporal goals. In our framework, a temporal goal is dropped if it can be satisfied by adopting an achieve or a maintain goal. A temporal goal is suspended if it can be partially satisfied by adopting an achieve or a maintain goal. For this reason, the actions $Drop(X)$ and $Suspend(X)$ drop and suspend the corresponding temporal goals and, at the same time, add the basic goal $X$ to the basic goal base. This notation should not be confused and read as parameterised drop and suspend actions. Finally, the actions $Drop(\emptyset)$ and $Suspend(\emptyset)$ remove a temporal goal from temporal goal base and leave the basic goal base unchanged. ### 4.1 Life Cycle for Temporal Goals In order to specify the state transitions of temporal goals, a set of condition-action pairs is assigned to each temporal goal. The condition of such a pair is a test on an agent’s belief base and the action is to change the goal’s state. The condition-action pairs can be either generic or domain related. A generic condition-action pair specifies a transition for all instances of a goal type while a domain related condition-action pair specifies a transition for a specific instance of a goal type depending on the application at hand. ![Figure 2: Temporal (top) and basic (bottom) goal life cycles](image) The domain related condition-action pairs can be used for various purposes, e.g., to activate temporal goals in domain specific situations in which the goals are likely to be realised (in addition to the generic ones) or to suspend them in situations in which the goals are not likely to be realised (in addition to the generic ones). These domain related condition-action pairs should be designed carefully since otherwise they may cause undesirable behavior. We assume domain related condition-action pairs are assigned to each temporal goal by the agent programmer in order to influence the life cycle of temporal goal based on domain dependent knowledge. We use $\delta_2(\phi)$ to refer to the set of generic condition-action pairs of temporal goal $\phi$ as specified in Figure 3. It is important to note that these condition-action pairs are only applicable when goals are in specific states, e.g., goals can only be dropped when they are active and activated when they are suspended. The suspension condition-action pairs can not only fire in the active state, but also when a goal is adopted (which moves the goal into the suspended state). The applicability of condition-action pairs are formally specified by the transition rules in Section 5.1. The first temporal goal type is characterised as $\Diamond \phi$, where $\phi$ is a non-temporal formula. The first generic condition-action pair assigned to this goal indicates that when $\Diamond \phi$ is entailed by the agent’s beliefs in its current state, then the goal $\Diamond \phi$ can be dropped and no basic goal is added to the basic goal base. In this case, the temporal goal is already believed to be satisfied. The second condition-action pair indicates that if $\phi$ is not entailed by the agent’s beliefs in its current state, then the goal $\Diamond \phi$ can be dropped, but simultaneously the agent adopts the achieve goal $A(\phi)$ by adding it to its basic goal base. Our assumption that the achieve goal is operationalized correctly ensures that the temporal goal $\Diamond \phi$ will be satisfied by the agent execution. As we will see later on, these drop actions only take place if the temporal goal is in its active state. It should be noticed that there is no condition-action pair to activate this temporal goal. We assume such a condition-action pair is added as a domain related pair by the programmer. An example of such a pair is $(\top, Activate)$, which is a strong activation condition as it indicates that the temporal goal should always be activated. The second temporal goal is characterised by $\Box \phi$, where $\phi$ is a non-temporal formula. The first condition-action pair drops the temporal goal and adopts the maintain goal, adding it at the same time to the basic goal base. Again, our assumption of correct operationalisation of maintain goals ensures that the temporal goal will be satisfied, which is why we can drop the temporal when adopting the basic maintain goal. That is, there is no need to suspend and reactivate this temporal goal should \( \phi \) no longer be believed, since the latter is assumed not to occur once the basic maintain goal is adopted. Note that a maintain goal \( M(\phi, \bot) \) is adopted in a state that satisfies the maintain condition \( \phi \). The second condition-action pair indicates that the temporal goal \( \Box \phi \) should be suspended if \( \phi \) is not entailed by the current agent’s beliefs, while adopting the achieve goal \( A(\phi) \) to pursue a state from which the maintain goal can be maintained. This can occur only when adopting this temporal goal while \( \phi \) does not hold. Since this temporal goal is dropped after activation, it cannot be suspended again from the active state. The third pair ensures that the temporal goal is activated again upon achievement of \( \phi \). The operationalisation of the third temporal goal type is very much similar to the second one since \( [\phi] \) is equivalent to \( \phi \cup \bot \), i.e., the only difference is that \( \phi \) should be maintained until \( \tau \) holds, and thus not indefinitely as was the case with \( \Box \phi \). The fourth temporal goal type is characterised by \( \diamond (\tau \land [\phi \cup \tau]) \). The first condition-action pair ensures that \( \phi \) is maintained indefinitely if the agent’s current beliefs entails \( \phi \land \tau \). However, if either \( \phi \) or \( \tau \) do not hold, then the temporal goal is suspended and the achieve goal \( A(\phi \land \tau) \) is added to the basic goal base. This ensures that the agent will pursue the condition before maintaining \( \phi \) indefinitely. The third pair ensures that the goal is activated again once the condition \( \phi \land \tau \) is satisfied. We adopt a goal to achieve both \( \phi \) and \( \tau \), and not just \( \tau \), because in the state in which the agent transitions from achieving \( \tau \) to maintaining \( \phi \), we want \( \phi \) to be true (so it can be maintained). This is also the reason why the third condition-action pair has a condition of \( \phi \land \tau \), and not just \( \tau \). These points also apply to the following temporal goal types. The fifth temporal goal type is characterised by \( \diamond (\tau \land [\phi \cup \tau^\prime]) \). The first condition-action pair indicates that if \( \phi \land \tau \) holds, then the temporal goal can be dropped and at the same time the basic maintain goal \( M(\phi, \tau^\prime) \) is adopted. Note that if \( \phi \land \tau \) holds, the maintain goal \( M(\phi, \tau^\prime) \) ensures that \( \phi \) is maintained until \( \tau^\prime \) is achieved. The second condition-action pair covers the situation where either \( \phi \) or \( \tau \) does not hold. In such a situation, the temporal goal cannot be realized. The temporal goal is therefore suspended, but the basic achievement goal \( A(\phi \land \tau) \) is added in order to achieve the condition for the first condition-action pair and the goal is activated again once this condition is satisfied. Finally, the sixth temporal goal type is characterized by \( \Box (\tau \rightarrow (\phi \land \tau^\prime)) \). The first condition-action pair specifies that when \( \phi \land \tau \) is entailed by an agent’s belief base the temporal goal can be suspended (not dropped) and the basic maintain goal \( M(\phi, \tau^\prime) \) adopted. The adopted maintain goal ensures the maintenance of \( \phi \) until \( \tau^\prime \). Note that the temporal goal can be pursued again since it was suspended, instead of being dropped. The second condition-action pair is to activate the temporal goal. Note that the condition of this pair is the same as the condition of the first pair, but that the first pair is applicable only to active goals and the second only to suspended goals. However, in order to avoid a loop (suspend, activate, suspend, . . . ) we impose an additional condition that a suspended goal of this type cannot be activated again until the plan generated for the goal has been performed. Formalising this restriction is straightforward but is omitted for space reasons. 4.2 Life Cycle for Basic Goals Generic condition-action pairs are also assigned to basic goals when they are adopted for a temporal goal. As we will see later, these condition-action pairs implement the generic relation between beliefs and goals, e.g., an achieve goal \( A(\phi) \) is dropped when \( \phi \) is believed and a maintain goal \( M(\phi, \tau) \) is dropped if \( \tau \) is believed. Note that the second condition-action pair for basic maintenance goals, which activates the goal, is only applicable to suspended goals (as defined in the transition rules in Section 5.2). On the other hand, the last condition-action pair, which drops a basic maintenance goal, can only be applied to an active basic maintenance goal. It should also be observed that our assumption about correct operationalisation of maintain goals implies that the condition of the suspend action is never satisfied, and therefore the basic maintain goal never gets into the suspended state. This condition-action pair is used in cases where the assumption that maintenance goals are correctly operationalised does not hold. Additionally, a set of domain related condition-action pairs are assigned to each basic goal. Like temporal goals, domain related condition-action pairs for basic goals should be used with care since otherwise they may cause undesirable behavior. The condition-action pairs for basic goals may seem redundant as they do not contribute to the operationalisation of temporal goals. However, these condition-action pairs generalise the presented framework, thus allowing for the design of arbitrary basic goal behaviors, which may be useful for a variety of domain dependent applications. For example, a robot with an achieve goal to be at a certain position will suspend its achieve goal when its battery charge is not sufficient. 5. OPERATIONAL SEMANTICS The operationalization of goal types is accomplished by operational semantics, which indicate possible transitions between agent configurations due to goal processing. Definition 1 The agent configuration is defined as a tuple \( (\sigma, \gamma, \gamma_0) \), where \( \sigma \) is the agent’s belief base (a finite set of propositional atoms), \( \gamma \) is the temporal goal base (a finite set of triples of the form \( (\phi, \text{state}, \Delta) \) where \( \phi \) is a temporal formula, state is the state of the temporal goal (init, active or suspended)), and \( \Delta \) is the set of condition-action pairs governing the life cycle, and \( \gamma_0 \) is the basic goal base (a finite set of triples of the form \( (g, \text{state}, \Delta) \) where \( g \) is one of \( A(\phi) \) or \( M(\phi, \tau) \), or \( M(\phi, \bot) \), and the remaining components are the same as for the temporal goal base). \( A(\phi) \) and \( M(\phi, \tau) \) denote goals to achieve and maintain the non-temporal formula \( \phi \), respectively. The maintain goal \( M(\phi, \tau) \) has an additional argument, a proposition \( \tau \), that indicates the deadline until which \( \phi \) should be maintained. The operational semantics defines how the agent pursues complex temporal goals in terms of the pursuit of basic achievement and maintenance goals. How the agent pursues basic achievement and maintenance goals is not defined here, and can be found elsewhere (e.g. [19]). We make assumptions about the pursuit of achievement and maintenance goals being operationalised correctly, and then show that, given these assumptions, the semantics given here correctly achieve complex temporal goals. 5.1 Transition Rules for Temporal Goals Below, we specify transition rules for individual temporal goals, and after that transition rules that lift these to sets of temporal goals. Let \( \phi \) be a temporal goal, \( \delta_\lambda \) a set of domain related condition-action pair for \( \phi \), and \( \delta(\phi) \) be the set of generic condition-action pairs as defined in Section 4.1. Let \( \lambda \) be the generic condition-action pair. <table> <thead> <tr> <th>BGoal</th> <th>Condition – Action Pairs</th> <th>( \lambda )</th> </tr> </thead> <tbody> <tr> <td>A(\phi)</td> <td>( (\phi, \text{Drop}) )</td> <td>---</td> </tr> <tr> <td>M(\phi, \tau)</td> <td>( (\Box(\phi \land \neg \tau, \text{Suspend}), (\phi \lor \tau, \text{Activate}), (\tau, \text{Drop}) )</td> <td>---</td> </tr> </tbody> </table> for basic goals as defined in Figure 4. We define $(X, \gamma_b)$ (i.e., $\gamma_b$ extended with basic goal $X$) as follows (note that we do not add any domain related condition-action pair to basic goals): - $+(0, \gamma_b) = \gamma_b$ - $+(X, \gamma_b) = \gamma_b \cup \{(X, active, \lambda)\}$ The first two rules below (Adopt1 and Adopt2) define the adoption of a temporal goal $(\phi, init, \delta_b)$, firstly in the case where there is a condition-action pair to suspend the goal while adopting a basic goal, and secondly where there is no applicable condition-action pair to suspend the goal (no basic goal is added). Note that in both cases, temporal goals are adopted entering in the suspended state. Temporal goals are initially suspended in order to ensure that their corresponding maintain goal is added to the basic goal base only in states where their maintain condition is satisfied. This can be verified by observing the condition-action pairs that add maintain goals to the basic goal base in Figure 3. Note that the application of the first transition rule adds a maintain goal to the basic goal base only for the sixth goal type and only when the condition of the to be added maintain goal is satisfied. In other cases, the temporal goals that would add a maintain goal are suspended without adding the maintain goal to the basic goal base until the maintain conditions are satisfied. In contrast to temporal goals, basic goals are adopted in an active state (see above in the definition of $(X, \gamma_b)$). This is because achieve goals can always be activated, i.e., there is no reason why they should be suspended at the start. A maintain goal can also start in an active state since its adoption condition ensures its maintain condition holds as explained above. It is also important to notice that in the first two transition rules we use generic condition-action pairs only from $\delta_b$ (not from $\Delta$). This is because domain related condition-action pairs are only used for activation and dropping of the goals, not for their adoption. Finally, observe that the first five transition rules allow transitions from one single temporal goal to a set of temporal goals. This means that these transition rules cannot be applied consecutively. However, the last transition rule is designed to manage the processing of a set of temporal goals in terms of transitions that are derivable from the first five transition rules. \[ \langle c, Suspend(X) \rangle \in \delta_b(\phi) \quad \sigma \models c \quad \text{Adopt1} \] \[ \langle \sigma, (\phi, init, \delta_b), \gamma_b \rangle \rightarrow \langle \sigma, \{(\phi, suspend, \delta_b \cup \delta_b(\phi)), \gamma_b\} \rangle, \ (X, \gamma_b) \rangle \] \[ \neg \exists \langle c, Suspend(X) \rangle \in \delta_b(\phi) : \sigma \models c \] \[ \langle \sigma, (\phi, suspend, \delta_b), \gamma_b \rangle \rightarrow \langle \sigma, \{(\phi, suspend, \delta_b \cup \delta_b(\phi)), \gamma_b\} \rangle \] The following rule activates a suspended temporal goal. \[ \langle c, Activate \rangle \in \Delta \quad \sigma \models c \] \[ \langle \sigma, (\phi, suspend, \Delta), \gamma_b \rangle \rightarrow \langle \sigma, \{(\phi, active, \Delta)\}, \gamma_b \rangle \] The following rule suspends an active temporal goal and (possibly) adds a basic goal to the basic goal base. \[ \langle c, Suspend(X) \rangle \in \Delta \quad \sigma \models c \] \[ \langle \sigma, (\phi, active, \Delta), \gamma_b \rangle \rightarrow \langle \sigma, \{(\phi, suspend, \Delta)\}, \gamma_b \rangle \] The following rule drops a temporal goal and (possibly) adds a basic goal to the basic goal base. \[ \langle c, Drop(X) \rangle \in \Delta \quad \sigma \models c \] \[ \langle \sigma, (\phi, active, \Delta), \gamma_b \rangle \rightarrow \langle \sigma, \{\}, \gamma_b \rangle, \ (X, \gamma_b) \rangle \] The following transition rule specifies how the above rules for single temporal goals (denoted as $g$) can be lifted to temporal goal bases. Note that whereas $g$ is a single goal (a tuple), $g'$ is a set of goals (either singleton or empty). \[ g \in \gamma_1 \quad (\sigma, g, \gamma_b) \rightarrow (\sigma, g', \gamma_b') \quad \text{Lift} \] \[ \langle \sigma, (\gamma, \gamma_b) \rangle \rightarrow \langle (\sigma, (\gamma \setminus \{g\}) \cup g', \gamma_b') \rangle \] ### 5.2 Transition Rules for Basic Goals The following rules specify the life cycle of a basic goal $X$. The $DropBasic$ rule indicates that if a basic goal is in an active state, then it can be dropped if there is a corresponding condition-action pair for which the condition is satisfied in the current state and the action is a drop action. It should be noted that for a basic achievement goal we have $\langle \phi, Drop \rangle$, which indicates that the basic goal $M(\phi)$ can be dropped when $\phi$ holds. Similarly, for a basic maintain goal we have $\langle \tau, Drop \rangle$, which indicates that the maintain goal $M(\phi, \tau)$ can be dropped if $\phi$ or $\tau$ holds in the current state. \[ \langle c, Drop \rangle \in \Delta \quad \sigma \models c \] \[ \langle \sigma, (\gamma, (X, active, \Delta)) \rangle \rightarrow \langle (\sigma, (\gamma \setminus \{\}) \cup g', \gamma_b') \rangle \] The following transition rule $(SuspB)$ specifies that a goal in an active state can be suspended. Note that the corresponding condition-action pair for a maintain goal indicates that a maintain goal can be suspended if neither $\phi$ nor $\tau$ hold in the current state. \[ \langle (c, Susp) \rangle \in \Delta \quad \sigma \models c \] \[ \langle \sigma, (\gamma, (X, susp, \Delta)) \rangle \rightarrow \langle \sigma, (\gamma, ((X, susp, \Delta)) \rangle \] The next transition rule is designed to manage the transition of a basic goal from suspended to active state. Note that the corresponding condition-action pair for a maintain goal states that the basic maintain goal $M(\phi, \tau)$ can be activated if either $\phi$ or $\tau$ hold in the current state. \[ \langle (c, Activate) \rangle \in \Delta \quad \sigma \models c \] \[ \langle \sigma, (\gamma, (X, active, \Delta)) \rangle \rightarrow \langle \sigma, (\gamma, ((X, active, \Delta)) \rangle \] Finally, as for temporal goals, we have a transition rule that specifies how the above rules for single basic goals (denoted as $g$) can be lifted to basic goal bases. Note again that whereas $g$ is a single basic goal (a tuple), $g'$ is a set of basic goals (either singleton or empty). \[ g \in \gamma_b \quad (\sigma, g, \gamma_b) \rightarrow (\sigma, g', \gamma_b') \quad \text{Lift} \] \[ \langle \sigma, (\gamma, \gamma_b) \rangle \rightarrow \langle (\sigma, \gamma, (\gamma \setminus \{\}) \cup g', \gamma_b') \rangle \] ### 5.3 Properties In the following, we use $P$ to denote the set of non-temporal propositional formulae, and we use $\models$, $\models_{cwa}$, and $\models_{LT L}$ to respectively denote propositional entailment, propositional entailment based on the closed-world assumption, and LTL entailment. We define the transition system $\Sigma$ to include the rules defined earlier in this section. It is important to observe that the transition system $\Sigma$ contains other transition rules in addition to those presented in sections 5.1 and 5.2. In particular, $\Sigma$ is assumed to contain transition rules for action execution, which may change the belief states. As the application of transition rules may be interleaved, possible belief changes may influence the goal life cycles. One assumption that we make about the details of transition system $\Sigma$ is that the rules defined earlier in this section have a higher priority than other rules. So for instance, if there are two applicable transition rules, say one for deriving/allowing an action execution transition, and the other for the application of a condition-action pair of a goal, then the second transition rule is applied to derive/allow the transition of goal life cycle. This assumption is crucial to show the properties of our transition system in the rest of this section. Definition 2 Let S = (s₁, y₁, s₂, y₂) → (s₃, y₃, s₄, y₄) → ... be an infinite sequence of configurations generated by the transition system Σ. In this sequence, the transition (sᵢ, yᵢ, sᵢ₊₁, yᵢ₊₁) → (sᵢ₊₁, yᵢ₊₁, sᵢ₊₂, yᵢ₊₂) is derived by the application of a transition rule of Σ. The sequence S is called a trace of Σ. The trace S of Σ is called a fair trace if it is generated by a fair run of the transition system, that is, a run in which every transition rule that is enabled infinitely often, is also applied infinitely often. Note that every finite trace is a fair trace. Furthermore, the priority assumption does not affect fairness, since in any given configuration, there is only a finite number of goal-related transitions that can be applied. In the following, we consider only infinite traces (which can be guaranteed by adding an “idling” rule that transitions a configuration to itself if no other transition rules are applicable). We use σᵢ, yᵢ, and γᵢ to denote the ingredients of the i-th state of a trace S. Definition 3 Let S be a trace of Σ. We define B(S), called the belief trace of S, to be the LTFl-trace s₁ s₂ s₃ ... (where sᵢ is a state assigning a truth value to each atomic proposition), if the following condition holds: ∀ϕ ∈ Φ, ∀i ∈ N : σᵢ |= cwa ϕ ⇒ sᵢ |= ϕ Furthermore, observe that since ϕ is non-temporal, we also have that sᵢ |= ϕ ⇒ B(S), i |= LTFl ϕ. The following proposition states that for every trace there is one unique belief trace possible. Proposition 1 Let S be a trace of Σ. The belief trace B(S) is uniquely determined by S. Proof: This proposition is the direct consequence of matching belief bases σᵢ with states sᵢ using the closed-world assumption. I.e., state sᵢ assigns the truth value of propositions based on their truth values in σᵢ using closed-world assumption. Assumption 1 The achieve goal A(ϕ) is properly operationalized by a transition system S if the following condition holds for every trace S of Σ: ∀i : (A(ϕ), active, Δ) ∈ yᵢ ⇒ ∃j ≥ i : σᵢ |= cwa ϕ Assumption 2 The maintain goal M(ϕ, τ) is properly operationalized by a transition system S if the following condition holds for every trace S of Σ: ∀i : (M(ϕ, τ), active, Δ) ∈ yᵢ ⇒ (∃j ≥ i : σᵢ |= cwa τ) ∧ (∀i ≤ k < j : σₖ |= cwa ϕ) or τ = ⊥ ∧ (∀k ≥ i : σₖ |= cwa ϕ) The following propositions show that the operational semantics defined in section 5 correctly operationalize complex temporal goals (in γᵢ) using the basic achievement and maintenance goals (in yᵢ). Generally, correct realisation is the property that if a temporal LTFl formula γ is in the temporal goal base of state i and is active, formally (γ, active, Δ) ∈ yᵢ, then B(S), i |= LTFl γ. However, since this only holds for the particular goal patterns that have been operationalized, we prove this for each case separately. All propositions are based on assumptions 1 and 2. Proposition 2 If (ϕ, active, Δ) ∈ yᵢ, then B(S), i |= LTFl ϕ for all fair traces S of Σ. Proof: Case 1: Assume that σᵢ |= cwa ϕ. By the definition of the condition-action pairs for ϕ and the transition rule for Drop, we have that, since ϕ ∈ γᵢ, we must have that A(ϕ) ∈ yᵢ⁺₁. Therefore by assumption 1 (and definition 3) we have that ∃j ≥ i + 1 : B(S), j |= LTFl ϕ and hence by the semantics of LTFl that B(S), i |= LTFl ϕ. Case 2: Assume that σᵢ |= cwa ϕ. Hence B(S), i |= LTFl ϕ and trivially B(S), i |= LTFl ϕ. The following proposition states that a property can be maintained if it already holds. Proposition 3 If (ϕ, active, Δ) ∈ yᵢ⁺₁ and σᵢ |= cwa ϕ, then B(S), i |= LTFl ϕ for all fair traces S of Σ. Proof: Since (ϕ, active, Δ) ∈ yᵢ⁺₁, by the definition of the condition-action rules and the transition rule for Drop, we have that M(ϕ, τ), i ∈ LTFl ϕ. By assumption 2 (and definition 3), since σᵢ |= cwa ϕ and ∀j ≥ i + 1 : σᵢ |= cwa ϕ, we have ∀j ≥ i : B(S), j |= LTFl ϕ and hence B(S), i |= LTFl ϕ. The following proposition shows that φ U τ is correctly operationalized. It assumes that τ ⊄ Δ, since φ U τ is false in LTFl. Proposition 4 If (φ U τ, active, Δ) ∈ yᵢ⁺₁, and σᵢ₊₁ |= cwa ϕ, then B(S), i |= LTFl (φ U τ) for all fair traces S of Σ. Proof (sketch): Since (φ U τ) ∈ yᵢ⁺₁, by the definition of the condition-action pairs and of the transition rules, we have M(φ, τ), i ∈ LTFl ϕ. By assumption 2 the trace S at configuration i + 1 satisfies ∃j ≥ i + 1 : σᵢ₊₁ |= cwa τ ∧ ∃k : i + 1 ≤ k < j : σᵢ₊₁ |= cwa ϕ. From this condition together with the definition 3 and the fact that B(S), i |= LTFl ϕ, it is easy to see that B(S), i |= LTFl (φ U τ). Proposition 5 If (τ ∧ ∃ϕ), active, Δ) ∈ yᵢ⁺₁, then B(S), i |= LTFl (τ ∧ ∃ϕ) for all fair traces S of Σ. Proof (sketch): We consider two cases in configuration i. Case 1: τ ∈ LTFl τ ∧ ∃ϕ (either φ or τ is not believed in the current configuration). Since τ ∧ ∃ϕ ∈ yᵢ⁺₁, by the definition of the condition-action pairs and of the transition rules, we have A(ϕ ∧ τ), i ∈ LTFl ϕ. By assumption 1 (and definition 3), we have that ∃j ≥ i + 1 : B(S), j |= LTFl ϕ ∧ τ. Since τ ∧ ∃ϕ is never removed from the temporal goal base (the condition-action pairs always suspend, and never drop it), we have τ ∧ ∃ϕ ∈ yᵢ⁺₁. By the definition of the condition-action pairs and of the transition rules, and because τ ∈ LTFl τ ∧ τ, we have M(ϕ ∧ τ), i ∈ LTFl ϕ. From τ ∈ LTFl ϕ, assumption 2 and the definition 3, we have B(S), j |= LTFl ϕ ∧ τ and hence B(S), i |= LTFl (τ ∧ ∃ϕ). Case 2: τ ∈ LTFl ϕ ∧ τ. It is easy to see that the proposition holds in this case by having i = j in the proof sketch of case 1. Proposition 6 If (τ ∧ (φ U τ')), active, Δ) ∈ yᵢ⁺₁, then B(S), i |= LTFl (τ ∧ (φ U τ')) for all fair traces S of Σ. Proof (sketch): The proof is similar to the proof of the previous proposition. The following proposition assumes that τ → ϕ. The justification for this assumption is that we want to show that the temporal goal is correctly realised. In the case where τ becomes true but ϕ does not hold, the temporal goal immediately fails, i.e. no operationalisation is able to realise the goal. We thus exclude this case. Proposition 7 If (ϕ U τ), active, Δ) ∈ yᵢ⁺₁ and τ → ϕ, then B(S), i |= LTFl (ϕ U τ) for all fair traces S of Σ. Proof (sketch): We want to show that B(S), i |= LTFl (ϕ U τ) for all fair traces S of Σ. There are two cases. Case 1: τ ∈ LTFl τ. In this case the implication trivially holds. Case 2: τ ∈ LTFl τ. Since τ → ϕ, we have τ ∈ LTFl ϕ. Since the temporal goal is always suspended and never dropped, (ϕ U τ) ∈ yᵢ⁺₁ for all j ≥ i. Thus, by the definition of the condition-action pairs and of the transition rules, and since \( \sigma^j \models_{\text{tax}} \tau \land \phi \), we have \( M(\phi, \tau^j) \in \gamma^j_{\text{tax}} \). By assumption 2 the trace \( S \) at configuration \( j + 1 \) ensures that \( \phi \) will be entailed by the belief base until \( \tau^j \) is entailed. Because \( \sigma^j \models_{\text{tax}} \phi \), trace \( S \) at configuration \( j \) ensures that \( \phi \) is entailed by the belief base until \( \tau^j \) is entailed, i.e. \( B(S), j \models_{\text{tax}} \phi \cup \tau^j \), from which \( B(S), j \models_{\text{tax}} (\tau \rightarrow (\phi \cup \tau^j)) \) trivially follows. 6. DISCUSSION In this paper we built on a temporal logic view of agent goals by defining new, novel, goal types, and showing how these new goal types could be operationalized in terms of existing base goal types (achievement and maintenance). The operationalization is based on a goal life cycle where transitions between states of goals are governed by condition-action pairs. We show that the operationalization realizes traces on which the temporal goals are satisfied, assuming satisfaction of the basic goal types. Through this we have provided a flexible framework for operationalizing rich goal types. Other goal types can be added by providing their translation to the basic goal types. Although we have provided several examples in the paper, future work will have to show which goal types are particularly useful in practice. This may also depend on the domain that is modelled. An important topic for future work to allow gaining more practical experience with the framework is implementing it on top of conventional agent-oriented programming languages, such as 2APL [6], Jadex [15], Jason [3], JACK [5] etc. It is interesting to note that the proposed framework appears to be a good match with rule-based systems, as used in Opal [20]. Also, we aim to extend the framework to include subgoals along the lines of [14], and then using this as a basis for incorporating goal suspension/resumption and abortion (based on [17, 18]). 7. REFERENCES
{"Source-Url": "http://ii.tudelft.nl/~birna/publications/2011/dastani11aamas.pdf", "len_cl100k_base": 12403, "olmocr-version": "0.1.53", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 32509, "total-output-tokens": 14490, "length": "2e13", "weborganizer": {"__label__adult": 0.00037169456481933594, "__label__art_design": 0.00042057037353515625, "__label__crime_law": 0.0005044937133789062, "__label__education_jobs": 0.0010318756103515625, "__label__entertainment": 8.046627044677734e-05, "__label__fashion_beauty": 0.0002015829086303711, "__label__finance_business": 0.0003542900085449219, "__label__food_dining": 0.0004224777221679687, "__label__games": 0.0008363723754882812, "__label__hardware": 0.0007519721984863281, "__label__health": 0.000797271728515625, "__label__history": 0.0002777576446533203, "__label__home_hobbies": 0.0001214146614074707, "__label__industrial": 0.0005164146423339844, "__label__literature": 0.000408172607421875, "__label__politics": 0.00037789344787597656, "__label__religion": 0.0005078315734863281, "__label__science_tech": 0.045166015625, "__label__social_life": 8.64863395690918e-05, "__label__software": 0.00595855712890625, "__label__software_dev": 0.939453125, "__label__sports_fitness": 0.00032830238342285156, "__label__transportation": 0.0007014274597167969, "__label__travel": 0.0002124309539794922}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52642, 0.0117]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52642, 0.56256]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52642, 0.88218]], "google_gemma-3-12b-it_contains_pii": [[0, 4643, false], [4643, 11105, null], [11105, 16805, null], [16805, 23028, null], [23028, 31492, null], [31492, 39621, null], [39621, 46142, null], [46142, 52642, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4643, true], [4643, 11105, null], [11105, 16805, null], [16805, 23028, null], [23028, 31492, null], [31492, 39621, null], [39621, 46142, null], [46142, 52642, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52642, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52642, null]], "pdf_page_numbers": [[0, 4643, 1], [4643, 11105, 2], [11105, 16805, 3], [16805, 23028, 4], [23028, 31492, 5], [31492, 39621, 6], [39621, 46142, 7], [46142, 52642, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52642, 0.01747]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
6fa344e1d4928319e695397114e9c1f479b52a60
Digital PIV (DPIV) Software Analysis System James L. Blackshire ViGYAN, Inc., Hampton, Virginia December 1997 Since its founding, NASA has been dedicated to the advancement of aeronautics and space science. The NASA Scientific and Technical Information (STI) Program Office plays a key part in helping NASA maintain this important role. The NASA STI Program Office is operated by Langley Research Center, the lead center for NASA's scientific and technical information. The NASA STI Program Office provides access to the NASA STI Database, the largest collection of aeronautical and space science STI in the world. The Program Office is also NASA's institutional mechanism for disseminating the results of its research and development activities. These results are published by NASA in the NASA STI Report Series, which includes the following report types: - **TECHNICAL PUBLICATION.** Reports of completed research or a major significant phase of research that present the results of NASA programs and include extensive data or theoretical analysis. Includes compilations of significant scientific and technical data and information deemed to be of continuing reference value. NASA counter-part of peer reviewed formal professional papers, but having less stringent limitations on manuscript length and extent of graphic presentations. - **TECHNICAL MEMORANDUM.** Scientific and technical findings that are preliminary or of specialized interest, e.g., quick release reports, working papers, and bibliographies that contain minimal annotation. Does not contain extensive analysis. - **CONTRACTOR REPORT.** Scientific and technical findings by NASA-sponsored contractors and grantees. - **CONFERENCE PUBLICATION.** Collected papers from scientific and technical conferences, symposia, seminars, or other meetings sponsored or co-sponsored by NASA. - **SPECIAL PUBLICATION.** Scientific, technical, or historical information from NASA programs, projects, and missions, often concerned with subjects having substantial public interest. - **TECHNICAL TRANSLATION.** English-language translations of foreign scientific and technical material pertinent to NASA's mission. Specialized services that help round out the STI Program Office's diverse offerings include creating custom thesauri, building customized databases, organizing and publishing research results ... even providing videos. For more information about the NASA STI Program Office, see the following: - E-mail your question via the Internet to help@sti.nasa.gov - Fax your question to the NASA Access Help Desk at (301) 621-0134 - Phone the NASA Access Help Desk at (301) 621-0390 - Write to: NASA Access Help Desk NASA Center for AeroSpace Information 800 Elkridge Landing Road Linthicum Heights, MD 21090-2934 Digital PIV (DPIV) Software Analysis System James L. Blackshire ViGYAN, Inc., Hampton, Virginia National Aeronautics and Space Administration Langley Research Center Hampton, Virginia 23681-2199 Prepared for Langley Research Center under Contract NAS1-19505 December 1997 Available from the following: NASA Center for AeroSpace Information (CASI) 800 Elkridge Landing Road Linthicum Heights, MD 21090-2934 (301) 621-0390 National Technical Information Service (NTIS) 5285 Port Royal Road Springfield, VA 22161-2171 (703) 487-4650 Digital PIV (DPIV) Software Analysis System Abstract A software package was developed to provide a Digital PIV (DPIV) capability for RTG/FMAD/MSTB at NASA LaRC. The system provides an automated image capture, test correlation, and autocorrelation analysis capability for the Kodak Megaplus 1.4 digital camera system for PIV measurements. The package includes three separate programs that, when used together with the PIV data validation algorithm, constitute a complete DPIV analysis capability. The programs are run on an IBM PC/AT host computer running under either Microsoft Windows v3.1 or Windows 95 using a 'quickwin' format that allows simple user interface and output capabilities to the windows environment. Acknowledgments The author wishes to thank several people for assistance and input to the software development. Foremost of all are Mr. William Humphreys and Mr. Scott Bartram, who provided technical support and guidance with PIV theory and practice. Their patience and helpfulness are greatly appreciated. The author also wishes to acknowledge Dr. C.S. Yao, Mr. Keith Pascal, and Dr. Mark Wernet for helpful insight into development of the autocorrelation code development. Finally, I gratefully acknowledge the support provided by the Measurement Science and Technology Branch at NASA Langley Research Center, Hampton, VA 23681, under contract No. NAS1-19505. # Contents Abstract ........................................................................................................... i Acknowledgments .......................................................................................... ii 1.0 Introduction ................................................................................................. 1 2.0 Hardware and Software Interface Description ........................................... 1 3.0 Software Description .................................................................................. 2 3.1 General Software Description ................................................................ 2 3.2 Detailed Software Description ................................................................ 5 4.0 Software Use and Procedures .................................................................... 12 4.1 DPIV.EXE Use and Procedures ............................................................... 12 4.2 COR.EXE Use and Procedures ............................................................... 13 4.3 ANALYZE.EXE Use and Procedures ....................................................... 15 5.0 Software Development Issues .................................................................... 16 Digital PIV (DPIV) Software Analysis System 1.0 Introduction The Digital PIV (DPIV) image capture, test correlation, and autocorrelation analysis algorithms provide the capability for using the Kodak Megaplus 1.4 digital camera system for PIV measurements. The algorithms include three separate programs that, when used with the PIV data validation algorithm, constitute a complete DPIV analysis capability. The programs described in this document include 1) the digital image capture program DPIV.exe, 2) the DPIV test correlation program COR.EXE, and 3) the DPIV analysis program ANALYZE.EXE. The data validation program VALIDATE.EXE is described in NASA Contractor Report 201701. Each of the three algorithms are completely automated with the exception of user input to a configuration file prior to analysis execution for update of various system parameters. The programs are run on an IBM PC/AT host computer running under Microsoft Windows v3.1 and Windows 95 using a 'quickwin' format that allows simple user interface and output capabilities to the windows environment. 2.0 Hardware and Software Interface Description The hardware used in the DPIV PC/AT system include two basic subsystems. They include 1) the Kodak Megaplus v1.4 digital camera and Epix frame grabber 4MEG video subsystem for transfer of the digital image data to PC memory, and 2) the Alacron FT200-AT array processor subsystem for calculating the 128x128 two-dimensional autocorrelations. Three hardware libraries are linked in for control of the Epix framegrabber and Alacron array processor systems; two for the Epix system and one for the Alacron, respectively. The Epix libraries include m4obm7wl.lib and pxipm7wl.lib. The Alacron links in w3slv860.lib which actually points to the dll -> w3slv860.dll. In addition, the Alacron array processor system is run in slave processor mode which requires code to be run on the Alacron board to be compiled and linked on that system using the Portland Group Compiler and Linker supplied by Alacron. The hardware and software versions used in the software development for each subsystem include: 1) Kodak Megaplus Digital Camera System v1.4 1992 3.0 Software Description 3.1 General Software Description The software is broken down into three separate programs with different functionality. The first program is called DPIV.EXE and provides the capability for capturing multiple high-resolution digital images with the Kodak Megaplus camera system. Digital images are captured at 1320x1035 pixel resolution, 8-bit gray-levels, and stored away in raw binary format to file. The user provides three pieces of information in the configuration file DPIV.CFG, including 1) the Kodak Megaplus Camera exposure level in milliseconds, 2) the number of files to save away, and 3) the base filename for the output files. The files are stored away with incrementing file extensions from *.000 to *.MAX, where MAX is the number of files the user wanted stored away. The files store away at a speed of about 7 seconds per file. The EPIX framegrabber 4mip.exe program is typically used just prior to execution of the DPIV.EXE program to determine the appropriate camera exposure level, and to evaluate image field-of-view, flair, and seed levels present. Once the configuration is setup and saved away, the user runs the DPIV.EXE program in an automated fashion. The second DPIV program is called COR.EXE. This program provides the capability to test correlate the DPIV binary images just captured. It performs a 2D FFT autocorrelation process on the digital image field in 128x128 pixel subregions of the full 1320x1035 image field. The program displays the 128x128 image subregion on an RS-170 monitor, performs the spatial autocorrelation using the Alacron array processor system, and displays the autocorrelation image field results on the monitor for that subregion. The user provides various parameters to the program through the configuration file COR.CFG. This information includes two types including 1) correlation enhancement parameters, and 2) image file information. The correlation enhancement parameters include such things as image threshold cutoff levels and search box limits. The file information includes the input filename and the number of test correlations to perform. The maximum number of correlations to perform is 285. This number is the result of the 128x128 subimage correlation size and the 50% oversampling that is applied to the analysis. The oversampling shifts the correlation region 64 pixels for each adjacent image region horizontally and vertically. This results in a 19x15 correlation vector grid available for analysis or 285 possible correlations. The user can choose from between 1 and 285 test correlations, of which the system begins correlating in the top left corner of the field-of-view, and continues correlating adjacent image regions horizontally and then down vertically until the MAX number of test correlations provided by the user is reached. The primary use of this program is to optimize the correlation patterns and Signal-to-Noise Ratios of the correlated field by adjusting the correlation parameters. This is a trial and error process and is used primarily to setup the analysis parameter set for the third program ANALYZE.EXE. The third program, ANALYZE.EXE, is the main analysis program for the DPIV system. It is an automated program that performs the 2d FFT autocorrelation analysis of subregions of the captured DPIV binary images, as described in the COR.EXE procedures above. The user again provides two basic pieces of information in the configuration file ANALYZE.CFG, including 1) correlation enhancement parameters, and 2) image file information. The correlation enhancement parameters should be identical to the optimized parameters determined in the test correlation process described above. The file information needed by the program includes three things including 1) the base filename for the input DPIV files, 2) the output analyzed vector base filename, and 3) the number of incremented files to analyze. The program outputs the top three correlations (and the relative intensity of each) for each of the available 285 image field positions in ASCII text format. This again is determined by the 128x128 pixel subregion sizes and the 50% oversampling, which produces a 19x15 spatially resolved vector grid as the output for each file. The process takes about 1 minute per input image file. The program reads in the configuration file information, and automatically analyzes the number of files input by the user, incrementing from file extension *.000 to *.MAX, as described above. Each of the three software packages is modular in nature and applies the various hardware and software control functions in a sequential manner. The order of program execution for the DPIV.EXE program typically involves the following steps: 1) system initialization 2) read in configuration file parameters 3) capture high-res DPIV images and write to files 4) free up memory and close hardware The order of program execution for the COR.EXE program typically involves the following steps: 1) system initialization 2) read in configuration file parameters 3) initialize the i860 array processor and load i860 program 4) calculate the FFT weight functions on the i860 5) initialize the EPIX framegrabber and Kodak Megaplus systems 6) send analysis parameters to i860 7) Begin main analysis loop which involves: a) capture subimage using framegrabber b) transfer position information to i860 c) transfer image data to i860 d) calculate the 2-d autocorrelation of the subimages which involves: I.) compute and apply active threshold on raw image data II.) check for totally white or black image field III.) apply default peak values IV.) calculate forward 2d fft V.) autocorrelate the 2d fft field VI.) center the final correlation field VII.) calculate the inverse 2d fft VIII.) zero out DC peak region IX.) scale output correlation field to 0-255 X.) apply search box thresholding XI.) send correlation image field back to main program f) retrieve the final correlation image and display on monitor 10) free up memory and close hardware The order of program execution for the ANALYZE.EXE program is similar to the COR.EXE program and typically involves the following steps: 1) system initialization 2) read in configuration file parameters 3) initialize the i860 array processor and load i860 program 4) calculate the FFT weight functions on the i860 5) initialize the EPIX framegrabber and Kodak Megaplus systems 6) send analysis parameters to i860 7) Begin main analysis loop which involves: a) capture subimage using framegrabber b) transfer position information to i860 c) transfer image data to i860 d) calculate the 2-d autocorrelation of the 285 subimages which involves: I.) compute and apply active threshold on raw image data II.) check for totally white or black image field III.) apply default peak values IV.) calculate forward 2d fft V.) autocorrelate the 2d fft field VI.) center the final correlation field VII.) calculate the inverse 2d fft VIII.) zero out DC peak region IX.) scale output correlation field to 0-255 X.) apply search box thresholding XI.) calculate the top three centroid positions XII.) write the results to output file f) retrieve the final correlation number 285 and display on monitor 10) free up memory and close hardware 3.2 Detailed Software Description The DPIV.EXE program is made up of two ‘c’ source files, and three resource files. The program is of a Windows ‘quickwin’ type which allows it to be run in Windows 3.1 or Windows 95, but allows minimal user interaction. Interaction and control of various program execution parameters is provided by a configuration file as described in the previous sections. The user edits the configuration file before program execution, and when the program is run, the configuration parameters are read in from that file. The program then displays the parameters on the monitor in a quickwin window and begins the analysis with no further user input. The source file DPIV.C is the main program, and provides the image capture and storage capability. It’s contents will be detailed in the following section. The source file DPIVw.C develops and displays the quickwin window and will not be detailed here. The user is referred to the commented listing provided. The three additional resource files will also not be detailed here. The source file DPIV.C contains four modular functions that perform the various initialization and control operations for the system. The main() function begins and ends program execution and performs memory allocation, initialization, and control functionality. Its first task is to call the read_config0 function which reads the configuration file parameters into global variables for use later in the program. The main() function then continues on and prints the configuration parameters in the quickwin windows, followed by a single data array memory allocation call. The function do_open0 is then called to open and initialize the EPIX framegrabber system. This function calls two EPIX framegrabber hardware control functions: pxd_m4open() and pxd_chkfault(). The function pxd_m4open() reads in a configuration file called 'videk' which contains various Kodak Megaplus camera configuration parameters. The function also initializes the framegrabber board, and calls pxd_chkfault() if there is a problem. If there is a problem at this point, the function do_open() returns an error message, allowing the user an opportunity to exit the program. If all is OK, the program continues on and captures a test image using the EPIX functions pxd_videkset(), pxd_videkdo(), and pxd_video(). These functions setup the Kodak Megaplus camera for high resolution capture mode, set the capture type and exposure level, and setup the display, respectively. The program then enters a looping sequence which involves: 1) capturing a high resolution Kodak Megaplus image, 2) setup and open the output filename for binary write using fopen(), 3) read the image data from the EPIX framegrabber buffer using pxd_iopen() and pxd_io() a line at a time, and 4) write the binary image field a line a time out to file using the function fwrite(). Once all of the data has been read and written to file, the memory is freed up and the hardware is closed. The COR.EXE and ANALYZE.EXE programs are similar in nature and will be described here together. Detailed listings of the source code files for the programs are presented at the end of this document. Each program is made up of three ‘c’ source files, and three resource files. The program is of a Windows ‘quickwin’ type which allows it to be run in Windows 3.1 or Windows 95, but allows minimal user interaction. Interaction and control of various program execution parameters is provided by a configuration file as described in the previous sections. The user edits the configuration file before program execution, and when the program is run, the configuration parameters are read in from that file. The program then displays the parameters on the monitor in a quickwin window and begins the analysis with no further user input. The source files COR.C and ANALYZE.C are the primary 'control' programs, and the source files CORp.C and ANALYZp.C are 'slave' programs run on the i860 array processor. Each of these will be detailed in the following section. The source files CORw.C and ANALYZw.C develop and display the quickwin windows and will not be detailed here. The user is referred to the commented listing provided. The three additional resource files for each program will also not be detailed here. The source files COR.C and ANALYZE.C each contain six modular functions. The main() function begins and ends program execution and performs memory allocation, initialization, and control functionality. Its first task in each program is to call the read_config() function which reads the configuration file parameters into global variables for use later in the program. The main() function then continues on and prints the configuration parameters in the quickwin windows, followed by data array memory allocation calls. The Alacron i860 array processor board is then initialized and opened with the functions alopen() and aldev(), respectively. The i860 slave programs 'corp' and 'analyzp' are then loaded by each respective program into i860 memory using the function almapload(). Memory is then initialized and allocated using the function i860malloc() and malloc() functions. A call to the i860 slave function dowts() is then made using the master function alcall(). This function calculates the FFT weight functions needed for the autocorrelation routine. The function alwait() prevents further program execution until the alcall() function returns from the i860. The EPIX 4MEG video framegrabber and Kodak Megaplus systems are then initialized and opened using the do_open() and pxd_m4open() functions. An initialization image is then captured using the pxd_videkset() and pxd_videkdo() functions. The correlation analysis parameter set for each program is then sent to the i860 using the functions alsetla() and alsetba() functions. This includes 9 long integer values and a character string containing the output filename for the COR.EXE program, and 12 long integer values and a character string containing the output filename for the ANALYZE.EXE program. Each program then calls the Alacron functions alsetla(), which in turn call the i860 slave functions params(), to transfer the correlation parameter sets to i860 memory. The programs then diverge slightly with the COR.EXE program calling alcall() and alwait(), in turn, which call the i860 slave function sendparams() which sets up the correlation parameters in i860 memory. The test correlation program then captures a test image using the EPIX functions pxd_videkdo() and pxd_video(). The ANALYZE.EXE program in the mean time has called the function onetenhund() to set up the output file extension number for the current file being read in. It has also used various string manipulation functions to assemble the full input and output filenames. Each of the programs then call the function fopen() to set up the input DPIV data file for binary read. Image data is then read in from file and transferred to PC memory, and then transferred from the PC memory to the i860 memory in a piece-wise manner. This is based on the fact that the EPIX function pxd_io() and Alacron function alsetba() are limited to transferring 32000 bytes of information at a time. This requires the transfer of image data in forty-one pieces 25 rows by 1320 pixels long. The image data read from file and transferred to PC memory is accomplished with the read_array() function, which in turn calls the fread() function for transfer of the binary image data to a temporary PC memory buffer. Transfer from the PC memory to i860 memory is then done with the Alacron alsetba() function. The relative read-in and write-out image locations is sent with each chunk of image data as it is sent to the i860 memory arrays. A call to the i860 slave function senddata() is then required to reassemble the image field to a full 1320x1035 from its forty-one transferred pieces. Once the image and analysis parameter sets have been sent and reassembled in i860 memory, the two programs diverge slightly again. The COR.EXE program sets up for display of the image subregion using the EPIX function pxd_video() and the function delay(). It then enters a looping scheme to first display the image field, calculate the autocorrelation field, and then display the result. The display of the current image field is done by calling the i860 function doshow() which reads the current 128x128 image and sends it back to PC memory, and the framebuffer for display. This display process also involves calling the functions algetba(), array_to_buf(), and delay(). The main() function then calls the i860 function dofft() to perform the autocorrelation of the subimage, followed by a retrieval of the correlation image field information for display using the functions just described. This looping sequence is repeated for the user-defined number of test correlations. The ANALYZE.EXE program in the mean time has called the function alsetba() to send the output filename to i860 memory for the analyzed vector data set. This is followed by a call to the i860 slave function goparam() which reassembles the correlation parameter set and output filename in i860 memory. The i860 slave function dofft() is then called to perform the autocorrelation analyses of the entire 285 image subregions of the 1320x1035 image field. The dofft() autocorrelation process for each program begins with a determination of the weighted mean pixel level for the 128x128 subimage region being evaluated: Weighted Mean = \left( \sum_{i=0,j=0}^{i=128,j=128} I_{\text{pixel}} \right) \times \text{Weight} \over 16384 where $I$ is the 8-bit pixel intensities (0-255), and weight is the user input weighting amount usually set to between 0.65 and 1.25. If a pixel value is found to be greater than the weighted mean value it is set to zero, and if found less than or equal to the weighted mean value it is set to its compliment value. This produces an image field of bright white particle image dots on a black background. A count of bright and dark levels in the current image field is kept so that if excessive bright or dark areas are present the frame can be zeroed out for easier data validation efforts later. This condition typically occurs in boundary regions, image flair regions, or non-seeded regions. On a similar theme, a default correlation peak set is introduced into the image field to aid in data validation efforts later. This is done by setting a series of six pixels to an intensity level of 20 corresponding to a set of three particle image pairs that will correlate if the entire image field is black. The user elects to introduce these default peaks and chooses their relative locations. The minimal 20 pixel intensity level causes no adverse affects on a legitimate PIV image field, which has particle image peak intensities near 255 and contrast levels in excess of 50:1. Following the active threshold (weighted mean) implementation, the forward 2-dimensional Fourier transform is applied to the data set using the Alacron provided function cfft2d(). The 2d FFT is then autocorrelated with itself: $$\mathbb{F}[R(\alpha, \beta)] = \mathbb{F}[f^*(x,y) \otimes f(x,y)] = |F(p,q)|^2$$ which basically reduces to squaring the real and imaginary parts of the FFT and adding them together: $$|F(p,q)|^2 = A_F(p,q)e^{i(px+qy)} \times A_F(p,q)e^{-i(px+qy)} = (|\text{Re}[F(p,q)]|^2 + |\text{Im}[F(p,q)]|^2$$ where $F(p,q)$ is the complex 2d forward FFT of the image field. The correlated image field is then centered in the image field by taking advantage of the translation property of the Fourier transform which sets the origin of the Fourier transform of $f(x,y)$ to the center of its corresponding NxN frequency square by multiplying \( f(x,y) \) by \((-1)^{x+y}\). This is coded up by multiplying the x and y frequency components values of \( f(x) \) and \( f(y) \) by \((-1)^x\) and \((-1)^y\) respectively. Mathematically, this is represented by: \[ f(x,y)(-1)^{x+y} \Leftrightarrow F(u-N/2,v-N/2) \] The inverse Fourier transform is then obtained to produce the desired PIV autocorrelation pattern, which takes the form of a self-correlation peak centered in the image field, and symmetric satellite correlation peaks about the center of the image field representing the average particle image displacement present in the field. Following the successful completing of the autocorrelation processing steps, a determination of the locations of the satellite peaks needs to be conducted. This first involves applying a filter to the self-correlation peak centered in the image field. The DC peak extent value provided by the user is used to zero-out values extending from the center of the image field out to the peak extent level. This basically zeroes out a square box pattern centered around pixels (64,64). The correlation field is then scaled to 8-bit levels (0-255) for display and storage later. This involves calculating the minimum and maximum pixel intensity values in the image field and applying: \[ \text{Scaled Pixel Intensity} = \frac{\text{Pixel Intensity} + (-1.0 \times \text{Minimum})}{\text{Maximum} + (-1.0 \times \text{Minimum})} \times 255 \] The user supplied search box values are then used to apply a hard threshold level within the search box boundaries. An additional 0-255 scaling operation is done before the hard threshold to enhance the dynamic range levels within the search box. The hard threshold level is then applied so that if the pixel value is less than the user threshold it is zeroed. The COR.EXE program at this point simply sends the resulting correlation image field back to the main() PC memory and framegrabber buffer for display, concluding its execution. The ANALYZE.EXE program, however, remains in the i860 slave program for evaluation of the autocorrelation centroid values in the search box region. The custom set of image centroid functions and procedures begin by calling the i860 slave function main_search0 from within the dofft0 function. A series of three dynamic centroid storage arrays are used to store potential centroid values, of which the top three intensity levels will be saved away. The main_search0 function checks the pixel intensity levels from the top left portion of the search box to the bottom right, and calls blob_search0 if it finds a pixel above the threshold level. The blob_search0 function in turn looks for connected neighbors that are above the threshold level and stores away the (x,y) positions and the intensity value for each pixel associated with a given blob. Once the entire blob extent has been determined, its centroid is evaluated using the i860 slave function find_centroid() which uses a weighted mean average routine to determine the x, y, and intensity levels of the blob. A comparison of its weighted mean intensity level is then made with the top three centroids, and if it beats any of the three, it is placed ahead of them in the final centroid arrays. Returning to the main_search() function, and following the determination of the top three centroid positions within the search box, the centroid x and y positions are scaled relative to the center of the image field, to give the relative displacement away from the self-correlation peak (which is the average displacement of the particle pairs in the field). The magnification and laser pulse separation are then taken into account using the user defined values to transform the final centroid pixel displacements to velocity according to: $$ Velocity \ Level = \frac{(Pixel \ Displacement \ Level) \times (Analysis \ Scale \ Factor)}{(Acquisition \ Magnification \ Level) \times (Laser \ Pulse \ Separation)} $$ where the analysis scale factor, acquisition magnification level, and laser pulse separation are determined by, and supplied by the user. The x and y position is also scaled at this point in the program according to: $$ Scaled \ Position_{x,y} = \frac{[Position_{x,y} \times (Analysis \ Scale \ Factor)]}{(Acquisition \ Magnification \ Level)} + Shift_{x,y} $$ where the $Shift_{x,y}$ represents the amount of x or y shift between image capture frames. The top three autocorrelation centroid positions are then written out to file along with the 8-bit (0-255) correlation peak intensity level, and the x and y position. The output file format takes the following form of eleven columns of data across: <table> <thead> <tr> <th>column 1</th> <th>column2</th> <th>column3</th> <th>column4</th> <th>column5</th> <th>column6</th> <th>column7</th> <th>column8</th> <th>column9</th> <th>column10</th> <th>column11</th> </tr> </thead> <tbody> <tr> <td>x position</td> <td>y position</td> <td>1st u</td> <td>1st v</td> <td>1st peak</td> <td>2nd u</td> <td>2nd v</td> <td>2nd peak</td> <td>3rd u</td> <td>3rd v</td> <td>3rd peak</td> </tr> </tbody> </table> where u and v are the u and v velocity components, respectively, and peak is the relative centroid correlation peak height recorded during the analysis process. The 1st, 2nd, and 3rd designations represent the strongest, 2nd strongest, and 3rd strongest correlation peak heights, respectively. Following the autocorrelation analysis and data write-out to file, the ANALYZE.EXE program returns to the master program's control and the main() function. Memory is then freed up, hardware/output data files are closed, and program execution is terminated. 4.0 Software Use and Procedures The following section is provided as a guide for using the three DPIV programs. The basic procedure for all three involves first editing the configuration file for each respective program and saving the resulting text file away, and then running the automated executable program which reads in the configuration file for needed information. 4.1 DPIV.EXE Use and Procedures The first program, DPIV.EXE, captures and stores away high resolution Kodak Megaplus digital images. The first step usually involves using the EPIX framegrabber system's 4MIP.EXE program to view the image field and to make any needed adjustments regarding things such as flair, seed density, reflections, focus, particle image shift amount, timing adjustments, and for the purposes of the DPIV.EXE program the Kodak Megaplus camera exposure level that will be used for the capture sequence. The typical exposure level is between 20-1000 microseconds, with most cases falling in the 100-300 microsecond range. The second step involves setting up the configuration file DPIV.CFG. An example configuration file input is provided below: <table> <thead> <tr> <th>Software_Version_Number</th> <th>1.2</th> </tr> </thead> <tbody> <tr> <td>Exposure_Level(ms)</td> <td>100</td> </tr> <tr> <td>Output_Datafile_Base_Name</td> <td>may1sh</td> </tr> <tr> <td>Number_of_Files_to_Save</td> <td>30</td> </tr> </tbody> </table> DPIV digital image capture system configuration file: DPIV.CFG The file supplies three system parameters needed for processing. These include 1) the Kodak Megaplus camera exposure level determined in step #1, 2) the output base filenames the user would like to use for the digital images to be stored, and 3) the number of images to store away. Once the configuration file is properly setup, it is saved away, and the DPIV.EXE program is run. This process starts the automated digital image capture routine that captures and stores away the DPIV image files. The parameters that were read in from the configuration file are displayed in the ‘quickwin’ box supplied by the program, and the current file number being saved away is updated as the program executes. The system is currently capable of storing files away at about 7 seconds each. 4.2 COR.EXE Use and Procedures The second program, COR.EXE, allows the user to test the autocorrelation patterns of a captured DPIV image field, and adjust various correlation parameters to enhance the correlation SNR levels. It first involves setting up the configuration file COR.CFG, which provides three basic types of information to the program. An example configuration file input is provided below: ``` Software_Version_Number 1.2 Image_Threshold_Scale_Level(0.65-1.25) 0.9 FP_DC_Peak_Extent(1-20) 10 Search_Box_xmin(0-128) 55 Search_Box_xmax(0-128) 85 Search_Box_ymin(0-128) 20 Search_Box_ymax(0-128) 45 Default_Peak_xpos(0-64) 2 Default_Peak_ypos(0-64) 2 Centroid_Threshold_Level(0-255) 250 Input_DPIV_Filename may1sh.005 Number_of_Test_Correlations 15 ``` DPIV test correlation program configuration file: COR.CFG The first piece of information that needs to be edited or updated is the input DPIV filename that the user would like to evaluate. (The full filename is required for this program, unlike the DPIV.CFG and ANALYZE.CFG files which use only the file basenames.) The second piece of information required is the number of test correlations the user would like to view. This can range from 1 to 285. The subimage and corresponding test correlations always begin in the upper left corner of the full 1320x1035 high resolution image and increment to the right and then downward in a 19x15 grid. The image fields and correlation fields are displayed as 128x128 image fields on the RS170 monitor one after the other, and from one position to the next. The correlations take about 4-5 seconds to cycle through for each, so that if the user chose 15 test correlations to view, the process would take a little over a minute to execute totally. If all 285 available subimage regions were viewed the process would take approximately 15-20 minutes. The main utility of this program, however, involves changing the various correlation parameters to enhance the Signal-to-Noise Ratio of the resulting particle correlation patterns. There are nine variables that can be changed and adjusted, including two image thresholding variables, a self-correlation extent variable, two default peak correlation variables, and four correlation search box variables. The image threshold scaling factor applies a threshold to the raw image before FFT processing based on the average pixel intensity (weighted mean) in the image. The user picks a value typically between 0.9 to 1.05 to scale the raw image field cutoff level and enhance the image contrast level before FFT processing begins. The centroid threshold level limits the centroid search to pixel intensity values above a certain level. A typical correlation peak has a peak intensity level above 240 (out of a possible 255), but in low seed density images, or noisy image fields, the peak intensity levels can be closer to 200. The user should pick a value that allows strong particle correlation patterns to extend out 2-10 pixel units radially from the correlation peak center. The self-correlation and search box variables, tend to block out or limit extraneous correlation pattern influences that may swamp-out or saturate weak correlation patterns in low SNR instances. The self-correlation peak extent variable zeroes-out a square box region in the center of the correlation image field, effectively blocking out the self-correlation peak position. The user determines, in pixel units, the radial extent of the DC peak correlation pattern by trial and error, and chooses a level that blocks out the entire self correlation pattern. The extent typically ranges from 2-14 pixels out from the center, and is based on particle sizes, magnification levels, aberrations, and other imaging parameters. The centroid search box extent variables place a limit on the region the centroid algorithm will look for valid image centroid images. The four variables are referenced to the upper left corner (0,0) of the 128x128 pixel field, where the center of the image field is (64,64). If the user picks (0,0), (0,128), (128,0) and (128,128) for the four search box variables, respectively, the entire FFT image field will be available for the centroid evaluation process. A typical search box region, however, extends only about 20-30 pixels in each direction. Both the DC peak extent and search box extents are displayed in the FFT correlation image field for evaluation purposes. The user should be liberal with the extents of the search box, and should test several different image fields and positions in the flow, to allow for a wide dynamic range of correlation peak positions. The final variable set involves the insertion of default peak positions, in the event that there is a totally white, or totally black image field. The default peaks are usually chosen to be just inside one of the corners of the search box region, so that they correlate and are detected by the centroiding algorithm. The default peak values show up as known correlation values in the final data set and help in the data validation processing steps. The user can decide to not use the default peak values by choosing values that correlation out of the search box region, or by choosing (0,0). The use of the COR.EXE program is typically an iterative process, involving the adjusting of a variable in the configuration file, and seeing how it affects the correlation pattern. The configuration file is edited each time, saved away, and then the COR.EXE program is run to view the correlation patterns. This procedure continues until the user is happy with the correlation SNR levels for a given image file, and then for several image files in a given analysis set. 4.3 ANALYZE.EXE Use and Procedures The final DPIV program, ANALYZE.EXE, automatically analyses multiple DPIV image files based on the input of its configuration file ANALYZE.CFG. An example configuration file input is provided below: <table> <thead> <tr> <th>Software_Version_Number</th> <th>1.2</th> </tr> </thead> <tbody> <tr> <td>Image_Threshold_Scale_Level(0.65-1.25)</td> <td>0.8</td> </tr> <tr> <td>FP_DC_Peak_Extent(1-20)</td> <td>14</td> </tr> <tr> <td>Search_Box_xmin(0-128)</td> <td>50</td> </tr> <tr> <td>Search_Box_xmax(0-128)</td> <td>80</td> </tr> <tr> <td>Search_Box_ymin(0-128)</td> <td>20</td> </tr> <tr> <td>Search_Box_ymax(0-128)</td> <td>45</td> </tr> <tr> <td>Default_Peak_xpos(0-64)</td> <td>50</td> </tr> <tr> <td>Default_Peak_ypos(0-64)</td> <td>50</td> </tr> <tr> <td>Centroid_Threshold_Level(0-255)</td> <td>240</td> </tr> <tr> <td>Pixel_Scale_Factor(microns/pixel)</td> <td>5.0</td> </tr> <tr> <td>Laser_Pulse_Separation(microsec)</td> <td>10.0</td> </tr> <tr> <td>Input_DPIV_Binary_Base_Filename(s)</td> <td>try1</td> </tr> <tr> <td>Output_Vector_Base_Filename(s)</td> <td>atry1</td> </tr> <tr> <td>Number_of_Files_to_Analyze</td> <td>2</td> </tr> </tbody> </table> DPIV Analysis program configuration file: ANALYZE.CFG Four types of information are input to the file including: 1) the input and output DPIV raw and analyzed file basenames, 2) the number of files to be analyzed, 3) the system magnification and laser pulse separation times, and 4) the correlation parameter set determined by the COR.EXE program described above. The first piece of information that needs to be edited or updated is the input DPIV file basename(s) that the user would like to analyze, and what the output analyzed file basename(s) should be. The second piece of information required is the number of files to analyze. The analysis process takes about 1 minute per file, so a typical set of 30 file would take \( \frac{1}{2} \) hour to analyze. The third piece of information needing input involves the system pixel scaling factor (magnification level), and the laser pulse separation timing. These values were probably determined before the data was taken, and scale the output vector position, and vector length data to the appropriate levels. The final type of information that needs to be edited in the configuration file involves updating the correlation parameter set that was determined previously with the COR.EXE program. These variables include the threshold, search box, DC peak extent, and default correlation values found in that process to optimize the SNR of the correlation pattern. Once the configuration file has been updated and saved away, the ANALYZE.EXE program is run. This process starts the automated digital PIV analysis routine that reads in DPIV image fields, autocorrelates the image, and stores away the output vector field to the user supplied output file names. The parameters that were read in from the configuration file are displayed in the ‘quickwin’ box supplied by the program, and the current file number being analyzed is updated as the program executes. The approximate time left in the processing is also displayed on the screen. 5.0 Software Development Issues The three Digital PIV software packages were written in a Microsoft ‘quickwin’ format, which allows the program to be run in Windows 3.1 or Windows 95, but which doesn’t allow any user interaction with the program while it is running. Each of the packages has a number of files needed for successful compiling and linking. The DPIV.EXE program requires the following five files: 1) DPIV.c - The program’s main control source file 2) DPIVw.c - The quickwin source file 3) DPIV.def - The definition file for the program 4) DPIV.rc - The resource file for the program 5) DPIV.ico - The bitmap icon for the program In addition, a command line batch file has been developed to simplify the compile, link, and resource compiler stages of the build process. This file's name is DPIV.bat. The program was compiled with Microsoft C compiler version v8.00, linker version v5.5, and resource compiler v3.11. Editing of the code to add new functionality, or to change existing capabilities is relatively straightforward. The modular nature of the code allows this. The quickwin source file DPIVw.c, definition file DPIV.def, resource file DPIV.rc, and icon file DPIV.ico should not require any changes and should be left alone if possible. A copy of the compile/link batch file listing is provided below: ``` cl -c -AL_Gsw -Zpe -DC_MSC -Dmain=Cmain dpivw.c link /NOD/NOE dpiv+dpivw,,lilbw Lilbecw m4obM7WL pxtpM7WL,dpiv.def rc -K dpiv.rc dpiv.exe ``` It calls the Microsoft compiler, linker, and resource compiler, with various switches setup for a quickwin application. The COR.EXE program requires the following six files: 1) COR.c - The program's 'master' control source file 2) CORp.c - The program's i860 array processor 'slave' source file 3) CORw.c - The quickwin source file 4) COR.def - The definition file for the program 5) COR.rc - The resource file for the program 6) COR.ico - The bitmap icon for the program The command line batch file for this program is called COR.bat. The program was also compiled with Microsoft C compiler version v8.00, linker version v5.5, and resource compiler v3.11. Editing of the code to add new functionality, or to change existing capabilities should again be relatively straightforward due to the modular nature of the code. But again, the quickwin source file CORw.c, definition file COR.def, resource file COR.rc, and icon file COR.ico should not require any changes and should be left alone if possible. A copy of the compile/link batch file listing for COR.EXE is provided below: It calls the Portland Group Compiler for compiling on the i860 processor board, followed by the Microsoft compiler, linker, and resource compiler, with various switches setup for a quickwin application. The ANALYZE.EXE program requires the following six files: 1) ANALYZE.c - The program’s ‘master’ control source file 2) ANALYZp.c - The program’s i860 array processor ‘slave’ source file 3) ANALYZw.c - The quickwin source file 4) ANALZYE.def - The definition file for the program 5) ANALYZE.rc - The resource file for the program 6) ANALYZE.ico - The bitmap icon for the program The command line batch file for this program is called ANALYZE.bat. The program was compiled with Microsoft C compiler version v8.00, linker version v5.5, and resource compiler v3.11. Editing of the code to add new functionality, or to change existing capabilities is once again a relatively straight forward. The quickwin source file ANALYZEw.c, definition file ANALZYE.def, resource file ANALYZE.rc, and icon file ANALYZE.ico should, however, not require any changes and should be left alone if possible. A copy of the compile/link batch file listing is provided below: pgcc -Mreentrant -o analyzp analyzp.c i860lib.a pgcnl.a libm.a c -c -AL -Gsw -Zpe -DC_MSC -Dmain=Cmain analyzp.c link /NOD /NOE analyzep+analyzw,,,w3slv860 libw Llibcww m4obM7WL pxlpM7WL,analyzep.def rc -K analyze.rc analyze.exe It also calls the Portland Group Compiler for compiling on the i860 processor board, and then the Microsoft compiler, linker, and resource compiler, with various switches setup for a quickwin application. This software package was developed under contract to NASA. Requests for copies of the source and executable codes described in this report should be directed in writing to one of the following: NASA Langley Research Center Technology Applications Group Mail Stop 118 Hampton, Virginia 23681-0001 or Vigyan, Inc. Aeronautical Research Group 30 Research Drive Hampton, Virginia 23666-1325 A software package was developed to provide a Digital PIV (DPIV) capability for NASA LaRC. The system provides an automated image capture, test correlation, and autocorrelation analysis capability for the Kodak Megaplus 1.4 digital camera system for PIV measurements. The package includes three separate programs that, when used together with the PIV data validation algorithm, constitutes a complete DPIV analysis capability. The programs are run on an IBM PC/AT host computer running either Microsoft Windows 3.1 or Windows 95 using a 'quickwin' format that allows simple user interface and output capabilities to the windows environment.
{"Source-Url": "https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19980008541.pdf", "len_cl100k_base": 10992, "olmocr-version": "0.1.50", "pdf-total-pages": 28, "total-fallback-pages": 0, "total-input-tokens": 54583, "total-output-tokens": 12236, "length": "2e13", "weborganizer": {"__label__adult": 0.0003204345703125, "__label__art_design": 0.0005269050598144531, "__label__crime_law": 0.0003008842468261719, "__label__education_jobs": 0.0008449554443359375, "__label__entertainment": 0.00012028217315673828, "__label__fashion_beauty": 0.000217437744140625, "__label__finance_business": 0.0003664493560791016, "__label__food_dining": 0.00038051605224609375, "__label__games": 0.0008606910705566406, "__label__hardware": 0.005947113037109375, "__label__health": 0.0003666877746582031, "__label__history": 0.0005521774291992188, "__label__home_hobbies": 0.00017523765563964844, "__label__industrial": 0.00150299072265625, "__label__literature": 0.00022935867309570312, "__label__politics": 0.00031566619873046875, "__label__religion": 0.0005307197570800781, "__label__science_tech": 0.291015625, "__label__social_life": 8.922815322875977e-05, "__label__software": 0.0428466796875, "__label__software_dev": 0.65087890625, "__label__sports_fitness": 0.0004534721374511719, "__label__transportation": 0.0011873245239257812, "__label__travel": 0.00023949146270751953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 48877, 0.04669]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 48877, 0.72286]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 48877, 0.83484]], "google_gemma-3-12b-it_contains_pii": [[0, 112, false], [112, 2890, null], [2890, 3174, null], [3174, 3434, null], [3434, 4153, null], [4153, 4816, null], [4816, 6088, null], [6088, 6088, null], [6088, 8263, null], [8263, 10501, null], [10501, 13162, null], [13162, 14764, null], [14764, 16750, null], [16750, 19377, null], [19377, 22254, null], [22254, 25199, null], [25199, 27397, null], [27397, 30130, null], [30130, 32741, null], [32741, 34663, null], [34663, 36752, null], [36752, 39626, null], [39626, 41751, null], [41751, 44192, null], [44192, 46252, null], [46252, 47846, null], [47846, 48237, null], [48237, 48877, null]], "google_gemma-3-12b-it_is_public_document": [[0, 112, true], [112, 2890, null], [2890, 3174, null], [3174, 3434, null], [3434, 4153, null], [4153, 4816, null], [4816, 6088, null], [6088, 6088, null], [6088, 8263, null], [8263, 10501, null], [10501, 13162, null], [13162, 14764, null], [14764, 16750, null], [16750, 19377, null], [19377, 22254, null], [22254, 25199, null], [25199, 27397, null], [27397, 30130, null], [30130, 32741, null], [32741, 34663, null], [34663, 36752, null], [36752, 39626, null], [39626, 41751, null], [41751, 44192, null], [44192, 46252, null], [46252, 47846, null], [47846, 48237, null], [48237, 48877, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 48877, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 48877, null]], "pdf_page_numbers": [[0, 112, 1], [112, 2890, 2], [2890, 3174, 3], [3174, 3434, 4], [3434, 4153, 5], [4153, 4816, 6], [4816, 6088, 7], [6088, 6088, 8], [6088, 8263, 9], [8263, 10501, 10], [10501, 13162, 11], [13162, 14764, 12], [14764, 16750, 13], [16750, 19377, 14], [19377, 22254, 15], [22254, 25199, 16], [25199, 27397, 17], [27397, 30130, 18], [30130, 32741, 19], [32741, 34663, 20], [34663, 36752, 21], [36752, 39626, 22], [39626, 41751, 23], [41751, 44192, 24], [44192, 46252, 25], [46252, 47846, 26], [47846, 48237, 27], [48237, 48877, 28]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 48877, 0.07692]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
f76bbac7246749fa8f68212922beb50aae395782
FP-Hadoop: Efficient Processing of Skewed MapReduce Jobs Miguel Liroz-Gistau, Reza Akbarinia, Divyakant Agrawal, Patrick Valduriez To cite this version: Miguel Liroz-Gistau, Reza Akbarinia, Divyakant Agrawal, Patrick Valduriez. FP-Hadoop: Efficient Processing of Skewed MapReduce Jobs. Information Systems, 2016, 60, pp.69-84. 10.1016/j.is.2016.03.008. lirmm-01377715 HAL Id: lirmm-01377715 https://hal-lirmm.ccsd.cnrs.fr/lirmm-01377715 Submitted on 7 Oct 2016 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Abstract Nowadays, we are witnessing the fast production of very large amount of data, particularly by the users of online systems on the Web. However, processing this big data is very challenging since both space and computational requirements are hard to satisfy. One solution for dealing with such requirements is to take advantage of parallel frameworks, such as MapReduce or Spark, that allow to make powerful computing and storage units on top of ordinary machines. Although these key-based frameworks have been praised for their high scalability and fault tolerance, they show poor performance in the case of data skew. There are important cases where a high percentage of processing in the reduce side ends up being done by only one node. In this paper, we present FP-Hadoop, a Hadoop-based system that renders the reduce side of MapReduce more parallel by efficiently tackling the problem of reduce data skew. FP-Hadoop introduces a new phase, denoted intermediate reduce (IR), where blocks of intermediate values are processed by intermediate reduce workers in parallel. With this approach, even when all intermediate values are associated to the same key, the main part of the reducing work can be performed in parallel taking benefit of the computing power of all available workers. We implemented a prototype of FP-Hadoop, and conducted extensive experiments over synthetic and real datasets. We achieved excellent performance gains compared to native Hadoop, e.g. more than 10 times in reduce time and 5 times in total execution time. Keywords: MapReduce, Data Skew, Parallel Data Processing 1. Introduction In the past few years, advances in the Web have made it possible for the users of information systems to produce large amount of data. However, processing this big data is very challenging since both space and computational requirements are hard to satisfy. One solution for dealing with such requirements is to take advantage of parallel frameworks, such as MapReduce [1] or its IO-efficient versions such as Spark [2], that allow to make powerful computing and storage units on top of ordinary machines. The idea behind MapReduce is simple and elegant. Given an input file of key-value pairs, and two functions, map and reduce, each MapReduce job is executed in two main phases. In the first phase, called map, the input data is divided into a set of splits, and each split is processed by a map task in a given worker node. These tasks apply the map function on every key-value pair of their split and generate a set of intermediate pairs. In the second phase, called reduce, all the values of each intermediate key are grouped and assigned to a reduce task. Reduce tasks are also assigned to worker machines and apply the reduce function on the created groups to produce the final results. Although MapReduce and Spark frameworks have been praised for their high scalability and fault tolerance, they show poor performance in the case of data skew. There are important cases where a high percentage of processing in the reduce side ends up being done by only one node. Let’s illustrate this by an example. Example 1. Top accessed pages in Wikipedia. Suppose we want to analyze the statistics that the free encyclopedia, Wikipedia, has published about the visits of its pages by users. In the statistics, for every hour, there is a file in which for each visited page, there is a line containing some information including, among others, its URL, language and the number of visits. Given a file, we want to return for each language, the top-k% accessed pages, e.g., top 1%. To answer this query, we can write a simple program as in the following Algorithm [3]. 1http://dumps.wikimedia.org/other/pagecounts-raw/ 3This program is just for illustration; actually, it is possible to write a more efficient code by leveraging on the sorting mechanisms of MapReduce. map( id : K₁, content : V₁ ) | foreach line (lang, page_id, num_visits, ...) in content do | emit (lang, page_info = (num_visits, page_id)) end reduce( lang : K₂, pages_info : list(V₂) ) | Sort pages_info by num_visits | foreach page_info in top k% do | emit (lang, page_id) end Algorithm 1: Map and reduce functions for Example 1 In this example, the load of reduce workers may be highly skewed. In particular, the worker that is responsible for reducing the English language will receive a lot of values. According to the statistics published by Wikipedia\textsuperscript{3}, the percentage of English pages over total was more than 70\% in 2002 and more than 25\% in 2007. This means for example that if we use the pages published up to 2007, when the number of reduce workers is more than 4, then we have no way for balancing the load because one of the nodes would receive more than 1/4 of the data. The situation is even worse when the number of reduce tasks is high, e.g., 100, in which case after some time, all reduce workers but one would finish their assigned task, and the job has to wait for the responsible of English pages to finish. In this case, the execution time of the reduce phase is at least equal to the execution time of this task, no matter the size of the cluster. There have been some proposals to deal with the problem of reduce side data skew. One of the main approaches is to try to uniformly distribute the intermediate values to the reduce tasks, e.g., by dynamically repartitioning the keys to the reduce workers \textsuperscript{2}. However, this approach is not efficient in many cases, e.g., when there is only one single intermediate key, or when most of the values correspond to one of the keys. One solution for decreasing the reduce side skew is to filter the intermediate data as much as possible in the map side, e.g., by using a combiner function. However, the input of the combiner function is restricted to the data of one map task, thus its filtering power is very limited for some applications. Let’s illustrate this by using our problem of top-1\%. Suppose we have 1TB of Wikipedia data, and 200 nodes for processing them. To be able to filter some intermediate data by the combiner function, we should have more than 1\% of the total values of at least one key (language) in the map task. Thus, if we use the default splits of Hadoop (64 MB size), the combiner function can filter no data. The solution is to increase significantly the size of input splits, e.g., more than 10GB (1\% of total). However, using big splits is not advised since it decreases significantly the MapReduce performance due to the following disadvantages: 1) more map-side skew: with big splits, there may be some map tasks that take too much time (e.g., because of their slow CPU), and this would increase significantly the total MapReduce execution time; 2) less parallelism: big split size means small number of map tasks, so several nodes (or at least some of their computing slots) may have nothing to do in the map phase. In our example, with 10GB splits, there will be only 100 map tasks, thus half of the nodes are idle. This performance degradation is confirmed by our experimental results reported in Section 5.11. In this paper, we propose FP-Hadoop, a Hadoop-based system that uses a novel approach for dealing with the data skew in reduce side. In FP-Hadoop, there is a new phase, called intermediate reduce (IR), whose objective is to make the reduce side of MapReduce more parallel. More specifically, the programmer replaces his reduce function by two functions: intermediate reduce (IR) and final reduce (FR) functions. Then, FP-Hadoop executes the job in three phases, each phase corresponding to one of the functions: map, intermediate reduce (IR) and final reduce (FR) phases. In the IR phase, even if all intermediate values belong to only one key (i.e., the extreme case of skew), the reducing work is done by using the computing power of all available workers. Briefly, the data reducing in the IR phase has the following distinguishing features: - **Parallel reducing of each key:** The intermediate values of each key can be processed in parallel by using multiple intermediate reduce workers. - **Distributed intermediate block construction:** The input of each intermediate worker is a block composed of intermediate values distributed over multiple nodes of the system, and chosen using a scheduling strategy, e.g., locality-aware. - **Hierarchical execution:** The processing of intermediate values in the IR phase can be done in several levels (iterations). This permits to perform hierarchical execution plans for jobs such as top-k% queries, in order to decrease the size of the intermediate data more and more. - **Non-overwhelming reducing:** The size of the intermediate blocks is bounded by configurable maximum value that prevents the intermediate reducers to be overwhelmed by very large blocks of intermediate data. We implemented a prototype of FP-Hadoop, and conducted extensive experiments over synthetic and real datasets. The results show excellent performance gains of FP-Hadoop compared to native Hadoop. For example, in a cluster of 20 nodes with 120GB of input data, FP-Hadoop outperformed Hadoop by a factor of about 10 in reduce time, and a factor of 5 in total execution time. This paper is a major extension of \textsuperscript{3} and \textsuperscript{5}, with at least 30\% of new materials. In the current paper, we \textsuperscript{5} propose a fault-tolerance mechanism that assures the correctness of the results in the case of failures, and reduces the amount of data to be re-processed compared to the native Hadoop. Additionally, we describe the design in more details and provide a more extensive experimental evaluation. The rest of this paper is organized as follows. In Section 2, we explain how Hadoop’s MapReduce works and give the necessary details to present our approach. In Section 3, we present the principles of FP-Hadoop including its programming model. Then, in Section 4, we give more details about its design. In Section 5, we report the results of our experiments done to evaluate the performance of FP-Hadoop. In Section 6, we discuss related work, and Section 7 concludes. 2. MapReduce Background In this section, we first briefly explain how MapReduce works in Hadoop. This will be useful to understand the technical details of FP-Hadoop. Then, we give an abstract view of the MapReduce execution. This abstract view is useful to better understand the main differences between the programming models of Hadoop and FP-Hadoop. 2.1. Job Execution in Hadoop In Hadoop, for executing a MapReduce job, we need a master node for coordinating the job execution, and some worker nodes for executing the map and reduce tasks. The worker nodes can be configured with a predefined number of slots for map and reduce tasks, so that each slot is able to execute a single task at a given time. When a MapReduce job is submitted to a node, it computes the input splits. The number of input splits can be personalized, but typically there is a one-to-one relationship between splits and file chunks in the filesystem, which by default have a size of 64MB. The location of these splits and some information about the job are submitted to the master that creates a job object with all the necessary information about the job are submitted to the master that creates a job object with all the necessary information, including the map and reduce tasks to be executed. One map task is created per input split. When a map task is assigned to a worker, it executes a Java Virtual Machine (JVM). The task reads the corresponding input split, applies the map function on each input element (e.g., line), and generates intermediate key-value pairs, which are firstly maintained in a buffer in main memory. When the content of the buffer reaches a threshold (by default 80% of its size), the buffered data is stored on the disk in a file called spill. Before writing the content of the buffer into the spill, the keys are divided into several partitions (as many as reduce tasks) using a partitioning function, and then the values of each key are sorted and written to its corresponding partition in the spill. An optional combiner function may be applied on the buffer data just before they are written into the spills. The objective of this function is to decrease the size of intermediate data that should be transferred to the reduce workers. Once a map task is completed, the generated spills are merged into a final output file and the master is notified. In the reduce phase, each partition is assigned to one of the reduce tasks. Each reduce task retrieves the key-value pairs corresponding to its partition from all the map output files, and merges them using the merge-sort algorithm. The transfer of data from map workers to the reduce workers is called shuffling, and can be started when a map task finishes its work. However, the reduce function cannot be applied until all the map tasks have finished and their outputs merged and grouped. Each reduce task groups the values of the same key, applies the reduce function on the corresponding values, and generates the final output results. When, all reduce tasks of a job are completed successfully, the user is notified by the master. 2.2. An Abstract View In an abstract view, the input of the map phase in MapReduce can be considered as a set of data splits, which should be processed by all workers. Thus, each map worker takes one split, processes it, and then takes another one until there are no splits in the set. Thus, we can hope for good parallelism in the map side, since no worker is idle until there is any split in the split set. But, in the reduce side, there is not such a parallelism, because the values of each key should be processed by one reduce worker. Thus, there may be situations where a high volume of the work is done by a single worker or a few number of workers, while the others are idle. We have made FP-Hadoop more parallel and efficient than Hadoop since all reduce workers can contribute in reducing the map output even if the output belong to only one key. 3. FP-Hadoop Principles In this section, we introduce the programming model of FP-Hadoop, its main phases, and the functions that are necessary for executing jobs. The design details of FP-Hadoop development are given in the next section. 3.1. Programming Model In FP-Hadoop, the output of the map tasks is organized as a set of blocks (splits) which are consumed by the reduce workers. More specifically, the intermediate key-value pairs are dynamically grouped into splits, called Intermediate Result Splits (IR splits for short). The size of an IR split is bounded between two values, MinIRSize and MaxIRSize, configurable by the user. Formally, each IR split is a set of (k, V) pairs such that k is an intermediate key and V is a subset of the values generated for k by the map tasks. FP-Hadoop executes the jobs in three different phases (see Figure 1): map, intermediate reduce, and final reduce. The map phase is almost the same as that of Hadoop in the sense that the map workers apply the map function on the input splits, and produce intermediate key-value pairs. The only difference is that in FP-Hadoop, the map output is managed as a set of IR fragments that are used for constructing IR splits. There are two different reduce functions: intermediate reduce (IR) and final reduce (FR) functions. In the intermediate reduce phase, the IR function is executed in parallel by reduce workers on the IR splits, which are constructed using a scheduling strategy from the intermediate values distributed over the nodes. More specifically, in this phase, each ready reduce worker takes an IR split as input, applies the IR function on it, and produces a set of key-value pairs which may be used for constructing future IR splits. When a reduce worker finishes its input split, it takes another split and so on until there is no more IR splits. In general, programming the IR function is not very complicated; it can be done in a similar way as the combiner function of Hadoop. In Section 3.2, we give more details about the IR function, and how it can be programmed. The intermediate reduce phase can be repeated in several iterations, to apply the IR function several times on the intermediate data and reduce incrementally the final splits consumed by the FR function (see Figure 2). The maximum number of iterations can be specified by the programmer, or be chosen adaptively, i.e., until the intermediate reduce tasks input/output size ratio is higher than a given threshold. In the final reduce phase, the FR function is applied on the IR splits generated as the output of the intermediate reduce phase. The FR function is in charge of performing the final grouping and production of the results of the job. Like in Hadoop, the keys are assigned to the reduce tasks according to a partitioning function. Each reduce worker pulls all IR splits corresponding to its keys, merges them, applies the FR function on the values of each key, and generates the final job results. Since in FP-Hadoop the final reduce workers receive the values on which the intermediate workers have worked, the load of the final reduce workers in FP-Hadoop is usually much lower than that of the reduce workers in Hadoop. In the next subsection, we give more details about the IR and FR functions, and explain how they can be programmed. 3.2. IR and FR Functions To take advantage of the intermediate reduce phase, the programmer should replace his/her reduce function by intermediate and final reduce functions. Formally, the input and output of map (M), intermediate (IR) and final reduce (FR) functions is as follows: - $M : (K_1, V_1) \rightarrow list(K_2, V_2)$ - $IR : (K_2, partial\_list(V_2)) \rightarrow (K_2, partial\_list(V_2))$ - $FR : (K_2, list(V_2)) \rightarrow list(K_3, V_3)$ Notice that in IR function, any partial set of intermediate values can be received as input. However, in FR function, all values of an intermediate key are passed to the function. Given a reduce function, to write the IR and FR functions, the programmer should separate the sections that can be processed in parallel and put them in IR function, and the rest in FR function. Formally, given a reduce function $R$, the programmer should find two functions $IR$ and $FR$, such that for any intermediate key $k$ and its list of values $S$, we have: $$R(k, S) = FR(k, \langle IR(k, S_1), ..., IR(k, S_n) \rangle)$$ for every partition $S_1 \cup ... \cup S_n = S$ In Table 1 we enumerate some important functions, and show their intermediate and FR functions. There are many functions for which we can use the original reduce Figure 2: Example of hierarchical job execution in FP-Hadoop. In this example, there are two intermediate keys, and the intermediate values are shown by blue (for key1) and yellow (for key2) colors. The intermediate values of key2 (yellow) are reduced directly by a final reducer just after the map phase (i.e., without an intermediate phase), because their size is small. But those of key1 (blue) are processed in two iterations in the intermediate phase. For planning such hierarchical executions, it is sufficient to set a maximum number of iterations, e.g., more than 2, and then everything is done automatically by FP-Hadoop. Table 1: Examples of some reduce functions and their equivalent intermediate and final functions <table> <thead> <tr> <th>Reduce (R) Function</th> <th>Intermediate (IR) and Final (FR) Functions</th> </tr> </thead> <tbody> <tr> <td>R = Top-k</td> <td>IR = FR = Top-k</td> </tr> <tr> <td>R = Skyline</td> <td>IR = FR = Skyline</td> </tr> <tr> <td>R = Union</td> <td>IR = FR = Union</td> </tr> <tr> <td>R = Sum</td> <td>IR = FR = Sum</td> </tr> <tr> <td>R = Max</td> <td>IR = FR = Max</td> </tr> <tr> <td>R = Min</td> <td>IR = FR = Min</td> </tr> <tr> <td>R = Avg</td> <td>IR = (Sum, Count), FR = (Sum, Count) THEN Sum/Count</td> </tr> </tbody> </table> function both in the intermediate and final reduce phases, i.e., we have \( IR = FR = R \). Examples of such functions are \( Top-k, SkyLine, Union \) and \( Sum \). The following example shows how a Top-k query can be implemented in FP-Hadoop using the same function for IR and FR. **Example 2. Top-k.** Consider a job that given a scoring function computes the top-k tuples of a big table. In this job, the map function computes the score of each read tuple, and emits \( \text{key}, \{\text{tupleID}, \text{score}\} \), where key is the identifier of the set of values on which we want to find the top-k values. Then, both IR and FR functions can be implemented as a function that, given a set of \( \{\text{tupleID}, \text{score}\} \) pairs, returns the \( k \) pairs that have the highest scores. Thus, in practice, the intermediate reduce workers generate partial top-k results (top-k tuples of their input IR splits), and the FR function produces the final results from intermediate partial results. If the value of \( k \) is big, e.g., 1% of the input as in our motivating example in Introduction, then we may need more iterations in the intermediate phase to reduce the intermediate data more and more. In this case, the execution of the job for overloaded key(s) can be hierarchical as in Figure 2. To plan such executions, it is sufficient to set the maximum number of iterations to the required level, and then FP-Hadoop organizes multiple iterations for overloaded keys when it is needed. A class of functions that can usually take advantage of the intermediate reduce phase is that of aggregate functions. Examples of such functions are \( Sum, Min/Max \) (using the same function as IR and FR), \( Avg \) and \( STD \) (using different functions for IR and FR). Aggregate functions can be classified into three groups: - **Definition 1 (Distributive).** Let \( F \) be a reduce function, and \( S \) a set of values, and \( S_1, ..., S_n \) a partitioning over \( S \). \( F \) is distributive if there is a function \( G \) such that \( F(S) = G((F(S_1), ..., F(S_n))) \). - **Definition 2 (Algebraic).** Let \( F \) be a reduce function, and \( S \) a set of values, and \( S_1, ... , S_n \) a partitioning over \( S \). \( F \) is Algebraic if there is a \( m \)-valued function \( G \) and a function \( H \) such that \( F(S) = H((G(S_1), ..., G(S_{n_1})), ..., (G(S_1), ..., G(S_{n_m}))) \). Intuitively, a function is **distributive** if it can be computed in a distributed manner. Examples of such functions are COUNT, SUM, MIN, and MAX. Distributive functions can particularly benefit from the usage of intermediate reduce tasks, as they usually reduce the data size significantly. Algebraic functions are the functions that can be computed by using a bounded number of distributive functions. Examples of algebraic functions are AVG and STD. These functions can also take advantage of intermediate reduce tasks. In holistic functions, there is no constant bound on the storage size needed to describe a sub-aggregate. Some holistic functions, such as SkyLine, may take great advantage of running an intermediate phase. For some other holistic functions, it may be difficult to find an efficient intermediate function. We precise that if it is difficult to find an efficient IR function for a job, it is sufficient to specify no IR function, then the final reduce phase starts just after the map phase, i.e., like in Hadoop. 4. Design Details In this section, we describe our design choices in FP-Hadoop. We focus on the activities that do not exist in Hadoop or are very different in FP-Hadoop, particularly: 1) management of IR fragments used for making IR splits; 2) intermediate task scheduling; 3) intermediate and final reduce task creation; 4) management of multiple iterations in the intermediate reduce phase. 4.1. IR Fragments for Constructing IR Splits In this subsection, we describe our approach for constructing the IR splits that are the working blocks of the reducers in the intermediate reduce phase. In Hadoop, the output of the map tasks is kept in the form of temporary files (called spills). Each spill contains a set of partitions, such that each partition involves a set of keys and their values. These spills are merged at the end of the map task, and the data of each partition is sent to one of the reducers. In FP-Hadoop, the spills are not merged. Each partition of a spill generates an IR fragment, and the IR fragments are used for making IR splits. When a spill is produced by a map task, the information about the spill’s IR fragments, which we call IRF metadata, is sent to the master node by using the heartbeat message passing mechanism. An IR fragment is uniquely identified by the task which produced it, its spill number and the partition. The data flow between FP-Hadoop components is shown in Figure 3. Notice that the choice of using spills as the output unit of the map phase provides the following advantages. The intermediate phase may start as soon as sufficient spills have been produced, even if no map task has yet finished, thus increasing the parallelism. Moreover, the fact that spills are bounded in size guarantees that IR split maximum size is respected. This would not be the case if the whole output of a map task is used, since its size is unbounded and could be by itself bigger than the IR split limit. For keeping IRF metadata, the master of FP-Hadoop uses a specific data structure called IR fragment table (IRF Table). Each partition has an entry in IRF Table that points to a list keeping the IR fragment metadata of the partition, e.g., size, spill and the ID of the map worker where the IR fragment has been produced. The master uses the information in IRF Table for constructing IR splits and assigning them to ready reduce workers. This is done mainly based on the scheduling strategies described in the next subsection. 4.2. Scheduling Strategies The master node is responsible for scheduling the intermediate and final reduce tasks. For this, it uses a component called Reduce Scheduler that schedules the tasks by using a customizable scheduling strategy. Here we describe the scheduling strategies which are used in FP-Hadoop; we present the details of Reduce Scheduler in Section 4.3. For scheduling an intermediate reduce task, the most important issue is to choose the IR fragments that belong to the IR split that should be processed by the task. The strategies, which are currently implemented in FP-Hadoop are: - **Greedy**: In this strategy, IR fragments are chosen from within the biggest partition, i.e., the partition whose IR fragments account for the highest total size. In the IRF Table, for each partition, along with the list of IR fragments we store its total size, allowing to chose the partition by a simple vertical scan of IRF Table. After choosing the partition, we select IR fragments starting from the head of the list until reaching the MaxIRSize value, i.e., the upper bound size for an IR split. This strategy is the default strategy in FP-Hadoop. - **Locality-aware**: In this strategy, the objective is to choose for a worker w the IR fragments that are on its local disk or close to it. Consequently, we chose the partition p for which the IR fragments produced in w account for the biggest size, provided that p’s total size is at least MinIRSize. From the partition’s fragments, we select those local to w until reaching 4 This mechanism is used for communication between the master and workers. MaxIRSize. If their total size is inferior to MinIRSize we keep taking fragments until reaching MinIRSize, first choosing from those produced in the same rack as \( w \) and then from the same data center. 4.3. Multiple Iterations FP-Hadoop can be configured to execute the intermediate reduce phase in several iterations, in such a way that the output of each iteration is consumed by the next iteration. Notice that the output of IR tasks in phase \( n \) produces the IR fragments that are to be consumed in phase \( n+1 \). An example of Top-k query execution over Wikipedia data (described in Section 5) is shown in Figure 3 where each phase is depicted as a rectangle whose height represents its input size and its length the execution time in seconds. In this example, there are two iterations for the intermediate reduce phase (shown with gray rectangles). We can see how each iteration further reduces the intermediate data size so that when the final reduce phase (in blue) is executed, its input size is sufficiently small. In FP-Hadoop, there is a parameter MaxNumIter that defines the maximum number of iterations. Notice that this parameter just establishes the maximum number, but in practice each partition may be processed in a different number of iterations, for instance depending on its size, input/output ratio or skew. FP-Hadoop provides the following strategies for configuring the number of iterations: - **Size-based:** In this approach, an iteration is launched only if its input size is more than a given threshold, MinIterSize. By default, FP-Hadoop uses the same value as MinIRSize (i.e. the minimum size of IR splits). The actual number of iterations may vary among partitions, and the maximum number may not be reached, e.g. if the size of intermedi- ate data was originally small or has been sufficiently reduced during previous iterations. The extreme scenario corresponds to the case when the map output for a given partition is less than $\text{MinIterSize}$. In this case, the final reduce phase is directly launched. - **Input/Output-Ratio-based**: In this approach, an iteration is launched when the ratio between the input and output size of the previous iteration is greater than a system parameter $\text{IORatio}$. The rationale is that if the input/output ratio is lower than some value, then further intermediate iterations will not help reducing the size of the partition in consideration, and hence, will not improve the job execution performance. - **Skew-based**: In this approach, an intermediate iteration is launched for a given partition if its size is $\text{SkewRatio}$ times higher than the average partition size. Thus it only executes more iterations for the overloaded partitions. For example by setting $\text{SkewRatio}$ equal to 2, only the partitions whose size is at least twice the average size are consumed in a new iteration, and the others are sent to the final reduce phase. ### 4.4. Reduce Scheduler To schedule the intermediate and final reduce tasks, the master node uses a component called Reduce Scheduler. The scheduling is done using a generic algorithm whose pseudo-code is shown in Algorithm 2. The algorithm scans $\text{IRF Table}$, and selects the best partition for constructing the IR split which should be consumed by the worker. Then, based on the size of the data in the partition and the maximum number of iterations, it decides whether to launch a final reduce task or an intermediate task. If it decides to launch a final reduce task, it uses all IR fragments of the partition. In the other case, i.e., an intermediate reduce task, it chooses the fragments of the IR split from the best partition based on the scheduling strategy. The main functions that are used in the generic scheduling algorithm (Algorithm 2) are as follows: - **$\text{isBestPartition()}$**: Based on the scheduling strategy, this function selects a partition from which the IR fragments of the task will be chosen. For example, with the Greedy strategy, it selects the partition that has the biggest data size among the partitions satisfying the scheduling constraints, i.e., their total size is at least $\text{MinIRSize}$, and the number of fragments of the partition are at least $\text{MinIRFs}$, which can be configured by the user. - **$\text{shouldRunFR()}$**: This function decides if the final reduce task should be scheduled for the data of a partition. The decision depends on the number of iterations that should be executed in the intermediate reduce phase. If the current iteration for a partition is the last iteration to be done, and the tasks of the iteration have finished successfully, the final reduce task can be scheduled. - **$\text{create_FR_Task()}$**: This function creates a final reduce task. It simply uses all the IR fragments from the partition given by $\text{isBestPartition}$ function. - **$\text{create_IR_Task()}$**: This function creates an intermediate reduce task. It takes the partition given by $\text{isBestPartition}$ function, and chooses a set of IR fragments as the IR split of the task. The fragments are chosen based on the scheduling strategy, for instance local fragments would be favored in the locality-aware strategy, whereas in the basic Greedy scheduling strategy, IR fragments are added to the task’s IR split while they do not surpass $\text{MaxIRSize}$. The task metadata are sent to the ready worker (see Figure 2). To implement new scheduling strategies in Reduce Scheduler, usually it is sufficient to change the above functions. For instance, to implement locality-aware strategy instead of Greedy strategy, we changed $\text{isBestPartition}$ function (that selects the partition to use) in such a way that it gives the priority to the partition that has the maximum IR fragments generated in the ready worker, and then changed $\text{generateIntermediateRT}$ function to choose the IR fragments accordingly, e.g., favor local fragments. ### 4.5. Fault Tolerance In Hadoop, the master marks a task as failed either if an error is reported (e.g., an Exception of the program or a sudden exit of the JVM) or if it has not received a progress update from the task for a given period [1]. In both cases, the task is scheduled for re-execution, if possible in a different node. During the execution of a job, the output of completed map tasks should be kept available in the workers’ disks until the job finishes. The reason is that any reduce task reads data from all map tasks’ output. If a worker fails, intermediate data stored on its disk is not available any more. Consequently, in addition to running tasks, all successfully completed map tasks executed in the worker need to be rescheduled to make their output available again. In FP-Hadoop, the behavior in the case of failure is slightly different, because we have to consider intermediate reduce tasks and we can also profit from the fact that they only read data from a subset of the map tasks. As in Hadoop, we distinguish two scenarios: task failure and worker failure. 4.5.1. Task Failure For map and final reduce tasks, the behavior is exactly the same as in native Hadoop, that is, the failed task is scheduled for re-execution, if possible in a different node. In the case of IR tasks, we need to re-inject their input IR fragments metadata into the IRF Table. Then, the fragments will be assigned to another task, not necessarily grouped in the same IR Split. Since new IRFs may be available, the reduce scheduler may choose to combine them in different ways. The case of an IR task failure is illustrated in the example shown in Figure 5. The state of the IRF list corresponding to a given partition $p$ in the IRF Table is presented before and after each event. In time $t = t_1$ task $ir_i$ is scheduled with input fragments $f_1$ and $f_2$. Then, in time $t = t_2$ the task fails and, consequently, its input fragments are injected back in the list. Notice that since $t_1$ some fragments have already been consumed (e.g. $f_3$) and new fragments inserted (e.g. $f_6$). Finally, when an idle worker asks for a new task in time $t = t_3$, fragments are grouped differently and its input is composed of fragments $f_6$ and $f_1$. In Figure 5: Task failure example. **Figure 5: Task failure example.** <table> <thead> <tr> <th>Before</th> <th>Event</th> <th>After</th> </tr> </thead> <tbody> <tr> <td>$t = t_1$</td> <td><img src="image" alt="Task ir_i is scheduled with input fragments f_1 and f_2." /></td> <td><img src="image" alt="Task ir_i fails." /></td> </tr> <tr> <td>$t = t_2$</td> <td><img src="image" alt="Task ir_i fails." /></td> <td><img src="image" alt="Task ir_i fails." /></td> </tr> <tr> <td>$t = t_3$</td> <td><img src="image" alt="Task ir_i is scheduled with input fragments f_6 and f_1." /></td> <td><img src="image" alt="Task ir_i is scheduled with input fragments f_6 and f_1." /></td> </tr> </tbody> </table> **Figure 6: Worker failure example.** In the case of IR tasks, we need to re-inject their input IR fragments metadata into the IRF Table. Then, the fragments will be assigned to another task, not necessarily grouped in the same IR Split. Since new IRFs may be available, the reduce scheduler may choose to combine them in different ways. The case of an IR task failure is illustrated in the example shown in Figure 5. The state of the IRFs list corresponding to a given partition $p$ in the IRF Table is presented before and after each event. In time $t = t_1$ task $ir_i$ is scheduled with input fragments $f_1$ and $f_2$. Then, in time $t = t_2$ the task fails and, consequently, its input fragments are injected back in the list. Notice that since $t_1$ some fragments have already been consumed (e.g. $f_3$) and new fragments inserted (e.g. $f_6$). Finally, when an idle worker asks for a new task in time $t = t_3$, fragments are grouped differently and its input is composed of fragments $f_6$ and $f_1$. In Figure 6: Worker failure example. 4.5.2. Worker Failure If a worker node fails, if in the node there were running tasks, they need to be re-scheduled. Map tasks are simply re-executed and the input fragments of intermediate and final reduce tasks are re-inserted into the IRF Table. In FP-Hadoop, as opposed to native Hadoop, not all completed tasks’ output is needed in the future, since their data may have already been consumed and reduced by intermediate reduce tasks in subsequent iterations of the execution tree. Indeed, FP-Hadoop uses a mechanism that only requires the re-execution of a minimal amount of tasks in the case of a worker failure. Each IR fragment stores within its metadata the information about their provenance, that is, a reference to the fragments that were used on its generation. In the failure of a worker, just after input IR fragments of running tasks are re-inserted to the IRF Table, each fragment stored in the failed node is replaced by the fragments that were used on its construction. If within those fragments, there are some fragments that are stored in the failed node, they are replaced by their predecessors as well. Fragments are replaced recursively by their predecessors until they are available or they have been generated in a map task. Only in that case, the map task is scheduled for re-execution. Re-inserted fragments can be consumed by new IR tasks following the standard procedure. Let’s illustrate this with the example of Figure 6, in which the execution tree for a given partition \( p \) is shown. Reduce task \( r \) was running in the worker node when it failed. IR fragments stored in the failed node are shadowed. The input fragments \( f_{12} \) and \( f_{14} \) are re-inserted to the IRF Table as in a single task failure. Then, unavailable fragments are replaced recursively by their predecessors. In this way, \( f_{14} \) is replaced by \( f_{11} \) and \( f_{12} \) and then \( f_{12} \) by \( f_7 \) and \( f_8 \). No map task needs to be re-executed and the re-inserted fragments can be consumed again by new tasks. FP-Hadoop recovery strategy only re-processes the data that is needed to finish the execution of the job, as opposed to native Hadoop, which needs to re-execute all map tasks and non-finished reduce tasks executed in the failed worker. Furthermore, as IR tasks have already reduced the size of the intermediate data, the amount of data to be treated is reduced even more, thus accelerating the recovery process. 5. Performance Evaluation We implemented a prototype of FP-Hadoop by modifying Hadoop’s components. In this section, we report on the results of our experiments for evaluating the performance of FP-Hadoop.\(^5\) We first discuss the experimental setup such as the datasets, queries and the experimental platform. Then, we discuss the results of our tests done to study the performance of FP-Hadoop in different situations, particularly by varying parameters such as the number of nodes in the cluster, the size of input data, etc. 5.1. Setup We run the experiments in the Grid5000 platform\(^6\) in a cluster with up to 50 nodes. The nodes are provided with Intel Quad-Core Xeon L5335 processors with 4 cores each, and 16GB of RAM. Nodes are connected through a switch providing a Gigabit ethernet connection to each node. We compare FP-Hadoop with standard Apache Hadoop and SkewTune\(^7\) which is the closest related work to ours (see a brief description in Related Work Section). In all our experiments, we use a combiner function (for Hadoop, FP-Hadoop and SkewTune) that is executed on the results of map tasks before sending them to the reduce tasks. This function is use to decrease the amount of data transferred from map to reduce workers, and so to decrease the load of reduce workers. The results of the experiments are the average of three runs. We measure two metrics: - **Execution time.** This is the time interval (in seconds) between the moment when the job is launched and the moment when it ends. This is our default metrics reported for most of the results. - **Reduce time.** We use this metric to consider the time that is used only for shuffling and reducing. It is measured as the time interval between the moment when the last map task is finished and the end of the job. With respect to Hadoop’s configuration, the number of slots was set to the number of cores. All the experiments are executed with a number of reduce workers equal to the number of machines. We change **io.sort.factor** to 100, as advised in \(^8\), which actually favors Hadoop. For the rest of the parameters, we employ Hadoop’s default values. The default values for the parameters which we employ in our experiments are as follows. The default number of nodes which we use in our cluster is 20. Unless otherwise specified, the input data size in the experiments is 20 GB. In FP-Hadoop, we use the default Greedy scheduling strategy as the high throughput of the network limits the impact of the locality-aware strategy. The default value for **MinIRSize** is set to 512 MB. The value of **MaxIRSize** is always twice as that of **MinIRSize**, and the maximum number of iterations is set to 1. 5.2. Queries and Datasets We use the following combinations of MapReduce jobs and datasets to assess the performance of our prototype: Top-k% (TK). This job, which is our default job in the experiments, corresponds to the query from the Wikipedia example described in the introduction of the paper. The input dataset is stored in the form of lines with the schema: \[ \text{Visits}(\text{language, article, num\_views, other\_data}) \] Our query consists on retrieving for each language the k% most visited articles. The default value of k is 1, i.e., by default the query returns 1% of the input data. We have used real-world and synthetic datasets. The real-world dataset (TK-RD) is obtained from the logs about Wikipedia page visits\(^7\) consisting of a set of files each containing the statistics collected for a single hour. We also produced two synthetic datasets, in which we can control the number of keys and their skew. In the first synthetic dataset (TK-SK), which is the default dataset, the number of articles per language follows a Zipfian distribution function \[ f(l, S, N) = \frac{1/l^s}{\sum_{n=1}^{N}(1/n^s)} \] that returns the frequency of rank l, where S and N are the parameters that define the distribution, i.e., \(f(1, S, N)\) returns the frequency of the most popular language. The default value for Zipf exponent parameter (S) is 1, and the parameter N is equal to the number of languages (10 by default). In the second synthetic dataset (TK-U), the articles are uniformly distributed in the keys. We perform several tests varying the data size, among other parameters, up to 120GB. The query is implemented using a secondary sort\(^8\), where intermediate keys are sorted first by language and then by the article’s number of visits, but only grouped by language. Inverted Index (II). This job consists of generating an inverted index with the words of the English Wikipedia articles\(^9\) as in\(^9\). We use a RADIX partitioner to map letters of the alphabet to reduce tasks and produce a lexicographically ordered output. We execute the job with a dataset containing 20GB of Wikipedia articles. PageRank (PR). This query applies the PageRank\(^8\) algorithm to a graph in order to assign weights to the vertices. As in\(^8\) we use the implementation provided by Cloud\(^8\). And as dataset, we use the PLD graph from Web Data Commons\(^10\) whose size is about 2.8GB. Wordcount (WC). Finally, we use the wordcount job provided in Hadoop standard framework. We apply it to a dataset generated with the RandomWriter job provided in the Hadoop distribution. We test this job with a 100GB dataset. 5.3. Scalability We investigate the effect of the input size on the performance of FP-Hadoop compared to Hadoop. Using TK-SK dataset, Figures\(^7\) and\(^7\) show the reduce time and execution time respectively, by varying the input size up to 120 GB, MinIRSize set to 5 GB, and other parameters set as default values described in Section 5.1. Figures\(^7\) and\(^7\) show the performance using TK-RD dataset with sizes up to 100 GB, while other parameters as default values described in Section 5.1. As expected, increasing the input size increases the execution time of both Hadoop and FP-Hadoop, because more data should be processed by map and reduce workers. However, the performance of FP-Hadoop is much better than Hadoop when we increase the size of input data. For example, in Figure\(^7\) the speed-up of FP-Hadoop vs Hadoop on execution time is around 1.4 for input size of 20GB, but this gain increases to around 5 when the input size is 120GB. For the latter data size, the reduce time of FP-Hadoop is more than 10 times lower than Hadoop. The reason for this significant performance gain is that in the intermediate reduce phase of FP-Hadoop the reduce workers collaborate on processing the values of the keys containing a high number of values while in Hadoop a single task has to process all this data. This is illustrated in Figures\(^7\) and\(^7\) where we compare the execution time of the longest reduce tasks of Hadoop and FP-Hadoop for TK-RD and 20GB. We can see that the longest task in Hadoop is the responsible of the poor performance in the reduce phase, which explains the total execution time. In FP-Hadoop, the longest task is 4 times shorter, and this is a consequence of the improved parallelism. 5.4. Effect of Cluster Size We study the effect of the number of nodes of the cluster on performance. Figure\(^8\) shows the execution time by varying the number of nodes, and other parameters set as default values described in Section 5.1. Increasing the number of nodes decreases the execution time of both Hadoop and FP-Hadoop. However, FP-Hadoop benefits more from the increasing number of nodes. In Figure\(^8\) with 5 nodes, FP-Hadoop outperforms Hadoop by a factor of around 1.75. However, when the number of nodes is equal to 50, the improvement factor is around 4. This increase in the gain can be explained by the fact that when there are more nodes in the system, more nodes can collaborate on the values of hot keys in FP-Hadoop. In opposition, in Hadoop, although using higher number of nodes can decrease the execution time of the map phase, it cannot significantly decrease the reduce phase time, in particular if there are intermediate keys with high number of values. 5.5. Effect of the Number of Intermediate Keys In our tests, we use the attribute language as the intermediate key for grouping the intermediate values. Here, \(^7\)http://dumps.wikimedia.org/other/pagecounts-run/ \(^8\)http://dumps.wikimedia.org/enwiki/latest/ \(^9\)http://www.umlcs.umd.edu/~jimmylin/Cloud9/docs/index.html \(^10\)http://webdatacommons.org/hyperlinkgraph/ Figure 7: Scalability of FP-Hadoop: With TK-SK (a) reduce time and (b) execution time; with TK-RD (c) execution time, (d) reduce time and longest reduce tasks with 20GB for (e) Hadoop and (f) FP-Hadoop. Figure 8: Effect of several parameters on the performance of FP-Hadoop: (a) number of intermediate keys, (b) zipfian exponent, (c) data skew and queries, (d) cluster size, (e) intermediate data filtering we report the results of our experiments done to study the effect of this parameter on the performance of FP-Hadoop and Hadoop. Figure 8a shows the execution time with varying the number of keys (languages) from 50 to 5, and other parameters set as default values. When the number of keys is lower than 20, Hadoop cannot take advantage of all available reduce nodes (there were 20 cluster nodes in this test). However, in FP-Hadoop, the intermediate reduce workers can contribute in processing the values of the keys that have high numbers of values. This is why there is a significant difference between the execution time of FP-Hadoop and Hadoop in these cases. Even for the cases where the number of keys is higher than the number of nodes (i.e., 20), the execution time of FP-Hadoop is better than that of Hadoop, because in these cases, there are keys with high number of values, and Hadoop cannot well balance the load of reduce workers. For Hadoop, when increasing the number of keys, the execution time decreases until some number of keys and then it becomes constant. We performed our tests with up to 200 keys, and observed that after 60 keys, there is no decrease in the execution time of Hadoop. 5.6. Effect of High Skew in Reduce Workers Load Here, we study the effect of high data skew on performance by varying the zipf exponent (S) used for generating synthetic datasets with Zipfian distribution. The higher is S, the higher is the skew in the size of the data (articles) assigned to the keys (languages). Figure 8b shows the execution time with varying zipf exponent S from 1 to 5, and other parameters set as default values. The figure shows that the data skew has a big negative impact on the performance of Hadoop, but its impact on FP-Hadoop is slight. The gain factor of FP-Hadoop increases by increasing S. The reason is that by increasing S, there will be intermediate keys with higher number of intermediate values, and these keys are the bottlenecks in Hadoop, because the values of each key are processed by only one reduce worker. 5.7. Effect of Data Skew on Different Queries Figure 8c shows the total execution time of FP-Hadoop by using several queries and their corresponding data as described in Section 5.1. The results show that FP-Hadoop outperforms Hadoop, in all cases except for the word-count query (WC). The extent of the gain depends on the amount of reduction that can be performed in the intermediate phase as a result of the partial aggregation. This explains why the best case is for TK-Sk, where each IR task can reduce the data back to k tuples and also while the reduction in PR is small, since only the mass contributions can be aggregated while the node structure has to be passed along untouched. For the word-count query, the execution time of FP-Hadoop is a little bit (3%) higher than Hadoop, and this increase corresponds to the overhead of the intermediate reduce phase. Indeed, in this query, there is no skew in the reduce side, because the partitioner can balance well the reduce load among workers. FP-Hadoop spends some time to detect that there is no skew in the intermediate results, and then launches the final reduce phase. Thus, its execution time is slightly higher than Hadoop. Notice that even this small overhead can be avoided by disabling the intermediate reduce phase. 5.8. Effect of Intermediate Data Filtering Using parameter k in the top-k% query, we can control the amount of data that may be filtered by the intermediate reduce tasks. In fact, in the top-k% query we return k% of the data that have the highest values. Thus, in the output of a map task or input data of an intermediate reduce task, if the amount of data is higher than k% of the total data, then we can keep the k% highest ranked data and filter the rest. Therefore, the lower is k, the higher is the capacity of data filtering by intermediate reduce tasks. Figure 8d shows the performance of the two systems by varying k in top-k% query and other parameters set as default values. The figure shows that the lower is k, the better is the performance gain of FP-Hadoop. The reason is that with lower k values, the intermediate reduce tasks can filter more intermediate values. In particular, for values lower than 10%, FP-Hadoop can profit well from the filtering in intermediate reduce workers. For values higher than 10%, the data filtering by intermediate reduce workers decreases significantly, this is why the gain of FP-Hadoop reduces. However, even for k values higher than 10%, there is a significant difference between the execution time of FP-Hadoop and Hadoop. 5.9. Analysis of FP-Hadoop Parameters We investigate the effect of the MinIRSize parameter on the performance of FP-Hadoop. For this, we use two configurations: 1) FP-Hadoop: the default configuration described in Section 5.1, with one iteration in the intermediate reduce phase; 2) FP-Hadoop-Iterations: in this configuration, we set the maximum number of iterations to be 10. As discussed in Section 4.3, the real number of iterations may be lower than this maximum value, e.g. because in an iteration the size of a partition may be lower than MinIRSize. By varying MinIRSize, Figure 9a shows the execution time of FP-Hadoop and FP-Hadoop-Iterations by varying the MinIRSize parameter for processing an input of size 100GB, and other parameters set as default values. The results show that in FP-Hadoop with one iteration, when we set MinIRSize to small values (e.g., lower than 128MB), the execution time is not very good. This suggests to not choose very small values for MinIRSize, when using only one iteration. The reason is that in these cases, we cannot well take advantage of the one iteration in the intermediate reduce phase, since with very small IR Splits the amount of data that can be filtered by intermediate tasks may not be large. However, by using more iterations in FP-Hadoop-Iterations, even with small MinIRSize values, the response time is good, since it uses more iterations to take advantage of the intermediate phase. Figure 10b shows the number of iterations done by FP-Hadoop-Iterations, when using different MinIRSize values. We observe that as MinIRSize increases, less iterations are needed to complete the intermediate phase. In our experiments, when using FP-Hadoop with one iteration, the best configuration for MinIRSize is in the cases where it is close to the ratio of the map output size over the number of reduce workers. We also study the number of IR tasks launched by the Reduce Scheduler. Figure 9 depicts the number of scheduled IR tasks vs. the partition sizes for TK-SK with 100GB with MinIRSize of 500MB and 1GB. The relation is clear: the bigger the partition, the higher the number of scheduled IR tasks. This is an expected behavior of FP-Hadoop, which tries to fully take advantage of parallelism for the overloaded partitions. 5.10. Comparison with SkewTune Here, we compare FP-Hadoop with SkewTune [3]. Figures 11a and 11b show the reduce time and execution time of both approaches, using the data and parameters described in Section 5.1. For these experiments, we downloaded the SkewTune prototype that is publicly accessible[1]. The data which we used are the default data and sizes described in Section 5.1 (e.g. 20GB of data for TK-SK). As the results show, FP-Hadoop can outperform SkewTune with significant factors. This is particularly noticeable for TK-SK, where SkewTune cannot divide the execution of the most popular key into several tasks. 5.11. Effect of Map Split Size As discussed in Introduction of this paper, in order to use the combiner function to decrease the reduce skew in the jobs such as Top-k%, we need to increase the size of the map splits significantly, giving more chance to the combiner function to filter the intermediate data. In this section, we study the effect of increasing the map split size on performance of Hadoop and FP-Hadoop. Notice that in our previous experiments for all compared systems, we used the combiner function, and the default map split size was 64MB which was the default value in Hadoop. Figures 11a and 11b show the execution times for top-k% and II queries, respectively. We varied the map split size from 64MB to 4GB, and other parameters set as default values described in Section 5.1. In order to do so, we re-injected the input data with the corresponding file system block size, as in Hadoop the default behavior creates a map split for each file block. For top-k% query, we observe a slight improvement in performance at the beginning (until the size of 256MB) for both Hadoop and FP-Hadoop. But, the performance degrades significantly for higher split sizes. For the inverted index (II) query, increasing the map split size has also a negative impact. The reason is that although increasing the size of the splits in the map phase may increase the chance of the combiner function to filter more intermediate data, using big size splits increases significantly the execution time of this phase, particularly because less map workers may participate in the map phase. Thus, the conclusion is that the combiner function can not make Hadoop as efficient as FP-Hadoop in processing high skewed data (e.g. in top-k% query), even by using big size map splits. 5.12. Discussion Overall the performance results show the effectiveness of FP-Hadoop for dealing with the data skew in the reduce side. For example, the results show that for 120GB of input data, FP-Hadoop can outperform Hadoop with factors of 10 and 5 in reduce time and total execution time respectively. This gain increases when augmenting the data size. The results also show that increasing the number of nodes of the cluster can significantly increase the gain of FP-Hadoop compared to Hadoop. The results also show that there are jobs for which the IR phase has no benefits. This occurs particularly... in the cases where there is no skew in the intermediate data or the skew can be significantly decreased in the map phase by using a combiner function, e.g., in the word count job which we tested. In these cases, it is sufficient to not declare an IR function, then FP-Hadoop executes the job without performing the IR phase. 6. Related Work In the literature, there have been many efforts to improve MapReduce [3], particularly by supporting high level languages on top of it, e.g., Pig [10], optimizing I/O cost, e.g., by using column-oriented techniques for data storage [11, 12, 13], supporting loops [14], adding index [15], caching intermediate data [16], supporting special operations such as join and Skyline [17, 18, 19, 21, 22, 23, 24], balancing data skew [25, 26], etc. Hereafter, we briefly present some of them that are the most related to our work. The approach proposed in [27] tries to balance data skew in reduce tasks by subdividing keys with large value sets. It requires some user interaction or user knowledge of statistics or sampling, in order to estimate in advance the values size of each key, and then subdivide the keys with large values. Gufler et al. [25] propose an adaptive approach which detects straggling reduce tasks and dynamically repartitions their input keys among the reduce workers. However, these approaches are not efficient when all or a big part of the intermediate values belong to only one key or a few number of keys (i.e., less than the number of reduce workers). SkewTune [3] adopts an on-the-fly approach that detects straggling reduce tasks and dynamically repartitions their input keys among the reduce workers that have completed their work. This approach can be efficient in the cases where the slow progress of a reduce task is due to inappropriate initial partitioning of the key-values to reduce tasks. But, it does not allow the collaboration of reduce workers on the same key. Haloop [14] extends MapReduce to serve applications that need iterative programs. Although iterative programs in MapReduce can be done by executing a sequence of MapReduce jobs, they may suffer from big data transfer between reduce and map workers of successive iterations. Haloop offers a programming interface to express iterative programs and implements a task scheduling that enables data reuse across iterations. However, it does not allow hierarchical execution plans for reducing the intermediate values of one key, as in our intermediate reduce phase. Memory Map Reduce (M3R) [28] is an implementation of Hadoop that keeps the results of map tasks in memory and transfers them to the reduce tasks via message passing, i.e., without passing via the local disks. M3R is very efficient, but can be used only for the applications in which intermediate key-values can fit in memory. SpongeFiles is a system that uses the available memory of nodes in the cluster to construct a distributed-memory, for minimizing the disk spilling in MapReduce jobs, and thereby improving performance. The idea of using main memory for data storage has been also exploited in Spark, an alternative to MapReduce, that uses the concept of Resilient Distributed Datasets (RDDs) to transparently store data in memory and persist it to disc only when needed. The concept of intermediate reduce phase proposed in FP-Hadoop can be used as a complementary mechanism in the systems such as Haloop, M3R, SpongeFiles and Spark, to resolve the problem of data skew when reducing the intermediate data. In MapReduce Online, instead of waiting for reduce tasks to pull the map outputs, the map tasks push their results periodically to the reduce tasks. This allows to increase the overlap between the map and shuffle phases, and consequently to reduce the total execution time. Similarly, we also benefit from an increased overlap as we do not need to wait for the end of a map task in order to start transferring its output. But, MapReduce Online does not resolve the problem of data skew in overloaded keys. There have been systems proposing new phases to MapReduce in order to deal with special problems. For example in Map-Reduce-Merge, in addition to the map and reduce phases, a third phase called merge is added to MapReduce in order to merge the reduce outputs of two different MapReduce jobs. The merge phase is particularly used for implementing multi-join operations. However, Map-Reduce-Merge and other solutions proposed for join query processing, e.g., cannot be used for resolving the problem of data skew due to overloaded keys. In general, none of the existing solutions in the literature can deal with data skew in the cases when most of the intermediate values correspond to a single key, or when the number of keys is less than the number of reduce workers. But, FP-Hadoop addresses this problem by enabling the reducers to work in the IR phase on dynamically generated blocks of intermediate values, which can belong to a single key. 7. Conclusion In this paper, we presented FP-Hadoop, a system that brings more parallelism to the MapReduce job processing by allowing the reduce workers to collaborate on processing the intermediate values of a key. We added a new phase to the job processing, called intermediate reduce phase, in which the input of reduce workers is considered as a set of IR Splits (blocks). The reduce workers collaborate on processing IR splits until finishing them, thus no reduce worker becomes idle in this phase. In the final reduce phase, we just group the results of the intermediate reduce phase. By enabling the collaboration of reduce workers on the values of each key, FP-Hadoop improves significantly the performance of jobs, in particular in the case of skew in the values assigned to the intermediate keys, and this is done without requiring any statistical information about the distribution of values. We evaluated the performance of FP-Hadoop through experiments over synthetic and real datasets. The results show excellent gains compared to Hadoop. For example, over a cluster of 20 nodes with 120GB of input data, FP-Hadoop can outperform Hadoop by a factor of about 10 in reduce time, and a factor of 5 in total execution time. The results show that the higher is the number of nodes, the higher can be the gain of FP-Hadoop. They also show that the bigger is the size of the input data, the higher can be the improvement gain of FP-Hadoop. Aknowledgements Experiments presented in this paper were carried out using the Grid'5000 experimental testbed, being developed under the INRIA ALADDIN development action with support from CNRS, RENATER and several universities as well as other funding bodies (see https://www.grid5000.fr). References [14] Y. Bu, B. Howe, M. Balazinska, M. D. Ernst, The haloop approach to large-scale iterative data analysis, VLDB J. 21 (2).
{"Source-Url": "https://hal-lirmm.ccsd.cnrs.fr/lirmm-01377715/file/infsys.pdf", "len_cl100k_base": 14888, "olmocr-version": "0.1.49", "pdf-total-pages": 18, "total-fallback-pages": 0, "total-input-tokens": 61835, "total-output-tokens": 17517, "length": "2e13", "weborganizer": {"__label__adult": 0.0003001689910888672, "__label__art_design": 0.0005092620849609375, "__label__crime_law": 0.0003936290740966797, "__label__education_jobs": 0.0031757354736328125, "__label__entertainment": 0.0001901388168334961, "__label__fashion_beauty": 0.00019609928131103516, "__label__finance_business": 0.0008230209350585938, "__label__food_dining": 0.0004246234893798828, "__label__games": 0.000705718994140625, "__label__hardware": 0.0017080307006835938, "__label__health": 0.0006246566772460938, "__label__history": 0.0005578994750976562, "__label__home_hobbies": 0.0001494884490966797, "__label__industrial": 0.0007343292236328125, "__label__literature": 0.0004377365112304687, "__label__politics": 0.0003986358642578125, "__label__religion": 0.0005097389221191406, "__label__science_tech": 0.44970703125, "__label__social_life": 0.00020515918731689453, "__label__software": 0.054962158203125, "__label__software_dev": 0.482421875, "__label__sports_fitness": 0.00020039081573486328, "__label__transportation": 0.00054168701171875, "__label__travel": 0.0002391338348388672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 71054, 0.02596]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 71054, 0.63681]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 71054, 0.89925]], "google_gemma-3-12b-it_contains_pii": [[0, 1007, false], [1007, 4905, null], [4905, 10523, null], [10523, 16213, null], [16213, 19866, null], [19866, 23646, null], [23646, 28770, null], [28770, 30558, null], [30558, 35165, null], [35165, 38526, null], [38526, 43838, null], [43838, 49435, null], [49435, 49843, null], [49843, 55658, null], [55658, 59772, null], [59772, 62327, null], [62327, 68285, null], [68285, 71054, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1007, true], [1007, 4905, null], [4905, 10523, null], [10523, 16213, null], [16213, 19866, null], [19866, 23646, null], [23646, 28770, null], [28770, 30558, null], [30558, 35165, null], [35165, 38526, null], [38526, 43838, null], [43838, 49435, null], [49435, 49843, null], [49843, 55658, null], [55658, 59772, null], [59772, 62327, null], [62327, 68285, null], [68285, 71054, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 71054, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 71054, null]], "pdf_page_numbers": [[0, 1007, 1], [1007, 4905, 2], [4905, 10523, 3], [10523, 16213, 4], [16213, 19866, 5], [19866, 23646, 6], [23646, 28770, 7], [28770, 30558, 8], [30558, 35165, 9], [35165, 38526, 10], [38526, 43838, 11], [43838, 49435, 12], [49435, 49843, 13], [49843, 55658, 14], [55658, 59772, 15], [59772, 62327, 16], [62327, 68285, 17], [68285, 71054, 18]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 71054, 0.05283]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
4ad88fc6658943049db9d6dc6300559dbbd67a0a
Embedded processors often need to be programmed in situations where JTAG cannot be used to program the target device. In these cases, the engineer needs to rely on serial programming solutions. C2000™ devices aid in this endeavor through the inclusion of several program loading utilities in ROM. These utilities are useful, but only solve half of the programming problem because they only allow loading application code into RAM. This application report builds on these ROM loaders by using a flash kernel. A flash kernel is loaded to RAM using a ROM loader - it is then executed and used to program the target device’s on-chip Flash memory with the end application. This document details one possible implementation for C2000 devices and provides PC utilities to evaluate the solution with. Table 5-11. CM Kernel Commands Trademarks C2000™ and Code Composer Studio™ are trademarks of Texas Instruments. Microsoft Visual Studio® is a registered trademark of Microsoft Corporation in the United States and/or other countries. All trademarks are the property of their respective owners. 1 Introduction As applications grow in complexity, the need to fix bugs, add features, and otherwise modify embedded firmware is increasingly critical in end applications. Enabling functionality like this can be easily and inexpensively accomplished through the use of bootloaders. A bootloader, also referred to as a ROM loader or simply loader, is a small piece of code that resides in the target device's boot-ROM memory that allows the loading and execution of code from an external host. In most cases, a communication peripheral such as Universal Asynchronous Receiver/Transmitter (UART) or Controller Area Network (CAN) is used to load code into the device rather than JTAG, which requires an expensive specialized tool. Boot Pins are used to configure different boot modes using various peripherals that determine which ROM loader is invoked. In this report, the peripheral used is Serial Communications Interface (SCI, generally referred to as UART). The boot modes that are associated with the boot pins refer to the first instance of the peripheral - for SCI, the boot mode would be associated with SCI.A. C2000 devices partially solve the problem of firmware updates by including some basic loading utilities in ROM. Depending on the device and the communications peripherals present, code can be loaded into on-chip RAM using UART, Serial Peripheral Interface (SPI), Inter-Integrated Circuit (I2C), Ethernet, CAN, and a parallel mode using General Purpose Input/Outputs (GPIOs). A subset of these loaders is present in every C2000 device and they are very easy to use, but they can only load code into RAM. How does one bridge the gap and program their application code into non-volatile memory? This application report aims to solve this problem by using a flash kernel. Flash kernels have been around for some time, but this document discusses the specifics of the kernels and the host application tool found in C2000Ware. While this implementation is targeted at C2000 devices using the SCI peripheral, the same principles apply to all devices in the C2000 product line and all communications options supported by the ROM loaders. A command line tool is provided to parse and transmit the application image from the host PC (Windows only) to the embedded device. In summary, application programming to non-volatile memory like flash requires two steps: 1. Use the SCI ROM bootloader to download a flash kernel to RAM. 2. Run the flash kernel in RAM to download the application to flash. ![Figure 1-1. Flash Kernel Flow](image-url) 2 Programming Fundamentals Before programming a device, it is necessary to understand how the non-volatile memory of C2000 devices works. Flash is a non-volatile memory that allows users to easily erase and re-program it. Erase operations set all the bits in a sector to '1' while programming operations selectively clear bits to '0'. Flash on certain devices can only be erased one sector at a time, but others have bank erase options. The term serial flash used in this report - serial flash kernels, serial flash programmer, and so forth only refers to the serial communication interface (SCI). Flash operations on all C2000 devices are performed using the CPU. Algorithms are loaded into RAM and executed by the CPU to perform any flash operation. For example, erasing or programming the flash of a C2000 device with Code Composer Studio™ entails loading flash algorithms into RAM and letting the processor execute them. There are no special JTAG commands that are used. All flash operations are performed using the flash application programming interface (API). Because all flash operations are done using the CPU, there are many possibilities for device programming. Irrespective of how the kernels and application are brought into the device, flash is programmed using the CPU. 3 ROM Bootloader At the beginning, the device boots and, based on the boot mode, decides if it should execute code already programmed into the Flash memory or load in code using one of the ROM loaders. This application report focuses on the boot execution path when the emulator is not connected. Note This section is based on the TMS320F28004x device. Specific information for a particular device can be found in the Boot ROM section of the device-specific technical reference manual (TRM). <table> <thead> <tr> <th>Boot Mode</th> <th>GPIO24 (default boot mode select pin 1)</th> <th>GPIO32 (default boot mode select pin 0)</th> </tr> </thead> <tbody> <tr> <td>Parallel I/O</td> <td>0</td> <td>0</td> </tr> <tr> <td>SCI/Wait boot</td> <td>0</td> <td>1</td> </tr> <tr> <td>CAN</td> <td>1</td> <td>0</td> </tr> <tr> <td>Flash</td> <td>1</td> <td>1</td> </tr> </tbody> </table> After the boot ROM readies the device for use, it decides where it should start executing. In the case of a standalone boot, it does this by examining the state of two GPIOs (as seen in Table 3-1, the default choices are GPIO 24 and 32). In some cases, two values programmed into one time programmable (OTP) memory can be examined. In the implementation described in this application report, the SCI loader is used, so at power up GPIO 32 must be forced high and GPIO 24 must be forced low. If this is the case when the device boots, the SCI loader in ROM begins executing and waits to autobaud lock with the host (for a character to be received in order to determine the baud rate at which the communications will occur). At this point, the device is ready to receive code from the host. The ROM loader requires data to be presented to it in a specific structure. The structure is common to all ROM loaders and is described in detail in the Bootloader Data Stream Structure section of [1]. You can easily generate your application in this format by using the hex2000 utility included with the TI C2000 compiler. This file format can even be generated as part of the Code Composer Studio build process by adding a post-build step with the following options: "${CG_TOOL_HEX}" "$[BuildArtifactFileName]" -boot -sc1i8 -a -o "$[BuildArtifactFileBaseName].txt" For the CM core in F2838x, the following command can be used: "${CG_TOOL_HEX}" "$[BuildArtifactFileName]" -boot -GPIO8 -a -o "$[BuildArtifactFileBaseName].txt" Alternatively, you can use the TI hex2000 utility to convert COFF and EABI .out files into the correct boot hex format. To do this, you need to enable the C2000 Hex Utility under Project Properties. The command is below: ``` hex2000.exe -boot -sci8 -a -o <file.txt> <file.out> ``` For the CM core in F2838x, the following command can be used: ``` armhex.exe -boot -gpio8 -a -o <file.txt> <file.out> ``` As stated before, ROM loaders can only load code into RAM, which is why they are used to load in flash kernels, which will be described in Section 4 and Section 5. ### 4 Flash Kernel A Flash Kernel A runs on: - TMS320F2802x - TMS320F2803x - TMS320F2805x - TMS320F2806x - TMS320F2833x To find the location of the flash kernel projects for these devices, see Section 7. #### 4.1 Implementation Flash Kernel A is based off SCI ROM loader sources. To enable this code to erase and program flash, flash APIs must be incorporated, which is done by linking the flash APIs. Before any application data is received, the flash kernel erases the flash of the device readying it for programming. A buffer is used to hold the received contiguous blocks of application code. When the buffer is full or a new block of noncontiguous data is detected, the code in the buffer is programmed. This continues until the entire application is received. The protocol used to transfer the application data has been slightly modified from the SCI ROM loader protocol. This was done to improve the speed of programming while also ensuring robust communications. With the original SCI ROM loader protocol, most of the time is spent not transferring data, but waiting for the data to propagate through the different layers of the operating system. This problem is compounded by the fact that data must be sent a single byte at a time with the SCI ROM loader (due to the echo based flow control), so every byte incurs the OS transport delay. The flash kernel uses the same protocol but calculates a checksum that is sent after every block of data. This allows the PC side application to send many bytes at a time through the different layers of the operating system, substantially decreasing the latency of communications. This flash kernel can be used with a CSM locked device. If the device is locked, the serial flash programmer can still be used by loading the flash kernel into unsecure RAM and modifying the kernel to unlock the device before it erases and programs the flash. In that case, `CsmUnlock()` (present in `<device_name>_SysCtrl.c`) should be modified to write the correct CSM passwords to the CSM registers. This will unlock the device. If the user does not want to unlock CSM while programming the device, flash APIs will have to be in flash (not ROM) and be copied to Secure RAM from where they can program/erase secure flash sectors without unlocking the device. #### 4.1.1 Application Load This section walks through the entire flow of programming an application into flash using the SCI boot mode. Ensure the device is ready for SCI communications by resetting the device while ensuring the boot mode pins are in the proper state to select SCI Boot mode. These are the steps that follow: 1. The device receives the autobaud character that determines the baud rate at which the load will take place. This happens soon after the host initiates a transfer command. 2. The flash kernel is transferred to the device, waiting for the character to be echoed before sending the next. Make sure the flash kernel is built and linked to RAM alone. 3. The ROM transfers control and the flash kernel begins to execute. There is a small delay in which the kernel must prepare the device for flash programming before it is ready to begin communications, and in this time the kernel configures the PLL and flash wait states. 4. The kernel enters an autobaud mode and waits for the autobaud character to be received. This potentially allows the kernel to communicate at a higher speed than was used for the ROM loader because the PLL is configured for a higher speed by the kernel. SCI has an autobaud lock that allows the host to send any baud rate they want - a single baud rate does not need to be agreed on for both sides. 5. Once the baud rate is locked, the application can be downloaded using the same format as the flash kernel. At the beginning of the download process, a key, a few reserved fields, and the application entry point are transferred before the actual application code. 6. After the entry point is received, the kernel begins to erase the flash. Erasing flash can take a few seconds, so it is important to note that while it looks like the application load may have failed, it is likely that the flash is just being erased. 7. Once the flash is erased, the application load continues by transferring each block of application code and programming it to flash. 8. After a block of data is programmed into flash, a checksum is sent back to the host PC to ensure that all of the data was correctly received by the embedded device. This process continues until the entire application has been programmed into flash. Now that the application is programmed into flash, the flash kernel attempts to run the application by branching to the entry point that was transferred to it at the start of the application load process. A device reset is needed for this. ### 5 Flash Kernel B Flash Kernel B runs on: - TMS320F2807x - TMS320F2837xD - TMS320F2837xS - TMS320F28004x - TMS320F2838 - TMS320F28002x - TMS320F28003x - TMS320F280013x - TMS320F280015x To find the location of the flash kernel projects for these devices, see Section 7. #### 5.1 Implementation Flash Kernel B is more robust than Kernel A. It communicates with the host PC application provided in C2000Ware (<C2000Ware_x_xx_xx_xx > utilities > flash_programmers > serial_flash_programmer>) and provides feedback to the host on the receiving of packets and completion of commands given to it. After loading the kernel into RAM and executing it via the SCI ROM bootloader, the kernel first initializes the PLLs of the device, initializes SCIA, and takes control of the flash pump, if necessary. It then waits for an 'a' or 'A' from the host in order to perform an auto baud lock with the host. After this, the kernel begins a while loop, which waits on commands from the host, executes the commands, and sends a status packet back to the host. This while loop breaks when a Run or Reset command is sent. Commands are sent in a packet described in Table 5-1 and each packet is either acknowledged or not-acknowledged. All commands, except for Run and Reset, send a packet after completion with the status of the operation. The status packet sends a 16-bit status code and 32-bit address. In case of an error, the address in the data specifies the address of the first error. In case of NO_COMMAND_ERROR, the address is 0x12345678. In the case of a Device Firmware Upgrade (DFU) command, the following steps take place: 1. The kernel receives a file in the hex boot format byte-by-byte from the SCI module and calculates a checksum over the block size. After receiving the block of data, it sends back the checksum. 2. After receiving a block of data and storing it in a buffer, the kernel erases the sector if it has not been previously erased, and programs the data into flash at the correct address along with ECC using flash API library. 3. Afterwards, the kernel verifies that the data and ECC were programmed correctly into flash. Note This kernel only erases sectors that are needed to program the application and data into flash. This is different from Flash Kernel A that erases the entire flash at the start of kernel execution. However, Flash Kernel B also supports an erase command independent of the DFU command, which gives the user the ability to erase specific sectors or the entire flash of the device. Similarly, the verify command receives a file in the hex boot format and in place of erasing and programming the flash, it only verifies the contents of the flash. 5.1.1 Packet Format Packets are sent in a standard format between the host and device. The packet allows for a variable amount of data to be sent while ensuring correct transmission and reception of the packet. The header, footer and checksum fields help to ensure that the data was not corrupted during transmission. The checksum is the summation of the bytes in the command and data fields. <table> <thead> <tr> <th>Table 5-1. Packet Format</th> </tr> </thead> <tbody> <tr> <td><strong>Header</strong></td> </tr> <tr> <td>2 Bytes</td> </tr> <tr> <td>0x1BE4</td> </tr> </tbody> </table> The host and the device both send packets one word at a time (16-bits), the LSB followed by the MSB. Both the host and device respond to a packet with an ACK or NAK. <table> <thead> <tr> <th>Table 5-2. ACK/NAK Values</th> </tr> </thead> <tbody> <tr> <td><strong>ACK</strong></td> </tr> <tr> <td>0x2D</td> </tr> </tbody> </table> 5.1.2 CPU1 Kernel Commands CPU1 commands for the dual core F2837xD are acceptable for the F2807x, F28004x, and F2837xS single core device kernels excluding the Run CPU1 Boot CPU2 and Reset CPU1 Boot CPU2. A brief description of the command codes are provided in Table 5-3. <table> <thead> <tr> <th>Table 5-3. CPU1 Kernel Commands</th> </tr> </thead> <tbody> <tr> <td><strong>Kernel Commands</strong></td> </tr> <tr> <td>DFU CPU1</td> </tr> <tr> <td>Erase CPU1</td> </tr> <tr> <td>Verify CPU1</td> </tr> </tbody> </table> Table 5-3. CPU1 Kernel Commands (continued) <table> <thead> <tr> <th>Kernel Commands</th> <th>Command Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Unlock CPU1 – Zone 1</td> <td>0x000A</td> <td>1. Receive the packet with 128-bit data (described in Section 5.1.4)</td> </tr> <tr> <td></td> <td></td> <td>2. Write the password to the DCSM Key Registers</td> </tr> <tr> <td></td> <td></td> <td>3. Check to see if Zone 1 is unlocked</td> </tr> <tr> <td></td> <td></td> <td>4. Send status packet</td> </tr> <tr> <td>Unlock CPU1 – Zone 2</td> <td>0x000B</td> <td>1. Receive the packet with 128-bit data (described in Section 5.1.4)</td> </tr> <tr> <td></td> <td></td> <td>2. Write the password to the DCSM Key Registers</td> </tr> <tr> <td></td> <td></td> <td>3. Check to see if Zone 2 is unlocked</td> </tr> <tr> <td></td> <td></td> <td>4. Send status packet</td> </tr> <tr> <td>Run CPU1</td> <td>0x000E</td> <td>1. Receive the packet with a 32-bit address (described in Section 5.1.4)</td> </tr> <tr> <td></td> <td></td> <td>2. Branch to the 32-bit address</td> </tr> <tr> <td>Reset CPU1</td> <td>0x000F</td> <td>1. Receive the packet with no data</td> </tr> <tr> <td></td> <td></td> <td>2. Branch to the 32-bit address</td> </tr> <tr> <td>Run CPU1 Boot CPU2 (1)</td> <td>0x0004</td> <td>1. Receive the packet with 32-bit address</td> </tr> <tr> <td></td> <td></td> <td>2. Release the flash pump, boot CPU2 by IPC to SCI boot mode, give CPU2 control of SCI and shared RAM, and then wait for CPU2 to signal.</td> </tr> <tr> <td></td> <td></td> <td>3. Branch to the address</td> </tr> <tr> <td>Reset CPU1 Boot CPU2 (1)</td> <td>0x0007</td> <td>1. Receive the packet with no data</td> </tr> <tr> <td></td> <td></td> <td>2. Release the flash pump, boot CPU2 by IPC to SCI boot mode, give CPU2 control of SCI and shared RAM, and then wait for CPU2 to signal.</td> </tr> <tr> <td></td> <td></td> <td>3. Break the while loop and enable WatchDog Timer to time-out and reset</td> </tr> </tbody> </table> (1) This command is not available to F2807x, F2837xS, and F28004x single core device kernels. 5.1.3 CPU2 Kernel Commands Table 5-4 shows the functions, command codes, and descriptions for the CPU2 commands used on dual core F2837xD device kernel. Table 5-4. CPU2 Kernel Commands <table> <thead> <tr> <th>Kernel Commands</th> <th>Command Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>DFU CPU2</td> <td>0x0200</td> <td>1. Receive the packet with no data</td> </tr> <tr> <td></td> <td></td> <td>2. Receive the flash application byte-by-byte in boot hex format</td> </tr> <tr> <td></td> <td></td> <td>3. Selective Erase, Program, and Verify</td> </tr> <tr> <td></td> <td></td> <td>4. Send status packet</td> </tr> <tr> <td></td> <td></td> <td>If successful, the address sent in the status packet is the entry point address of the programmed flash application</td> </tr> <tr> <td>Erase CPU2</td> <td>0x0400</td> <td>1. Receive the packet with 32-bit data (described in Section 5.1.4)</td> </tr> <tr> <td></td> <td></td> <td>2. Selective erase the sectors specified in the data</td> </tr> <tr> <td></td> <td></td> <td>3. Send status packet</td> </tr> <tr> <td>Verify CPU2</td> <td>0x0600</td> <td>1. Receive the packet with no data</td> </tr> <tr> <td></td> <td></td> <td>2. Receive the flash application byte-by-byte in boot hex format</td> </tr> <tr> <td></td> <td></td> <td>3. Verify flash contents</td> </tr> <tr> <td></td> <td></td> <td>4. Send status packet</td> </tr> <tr> <td>Unlock CPU2 – Zone 1</td> <td>0x000C</td> <td>1. Receive the packet with 128-bit data (described in Section 5.1.4)</td> </tr> <tr> <td></td> <td></td> <td>2. Write the password to the DCSM Key Registers</td> </tr> <tr> <td></td> <td></td> <td>3. Check to see if Zone 1 is unlocked</td> </tr> <tr> <td></td> <td></td> <td>4. Send status packet</td> </tr> </tbody> </table> Table 5-4. CPU2 Kernel Commands (continued) <table> <thead> <tr> <th>Kernel Commands</th> <th>Command Code</th> <th>Description</th> </tr> </thead> </table> | Unlock CPU2 – Zone 2 | 0x000D | 1. Receive the packet with 128-bit data (described in Section 5.1.4) 2. Write the password to the DCSM Key Registers 3. Check to see if Zone 2 is unlocked 4. Send status packet | | Run CPU2 | 0x0010 | 1. Receive the packet with a 32-bit address (described in Section 5.1.4) 2. Branch to the 32-bit address | | Reset CPU2 | 0x000F | 1. Receive the packet with no data 2. Break the while loop and enable WatchDog Timer to time-out and reset | 5.1.4 Packet Data This section describes the data expected for the commands that require data to be sent to the device. • **Erase** Each bit of the 32-bit data sent with the erase command corresponds to a sector. – Data Bit 0 – Sector A – Data Bit 1 – Sector B – And, so forth <table> <thead> <tr> <th>Table 5-5. Erase Packet</th> </tr> </thead> <tbody> <tr> <td><strong>Header</strong></td> </tr> <tr> <td>0x1BE4</td> </tr> </tbody> </table> • **Unlock** – 1st 32 bits is Key 1 – 2nd 32 bits is Key 2 – 3rd 32 bits is Key 3 – 4th 32 bits is Key 4 <table> <thead> <tr> <th>Table 5-6. Unlock Packet</th> </tr> </thead> <tbody> <tr> <td><strong>Header</strong></td> </tr> </tbody> </table> | 0x1BE4 | 4 (bytes) | 0x000A CPU1 Z1 0x000B CPU1 Z2 0x000C CPU2 Z1 0x000D CPU2 Z2 | 128-bit Data | Checksum of Command and Data | 0xE41B | • **Run** – 32-bit address <table> <thead> <tr> <th>Table 5-7. Run Packet</th> </tr> </thead> <tbody> <tr> <td><strong>Header</strong></td> </tr> <tr> <td>0x1BE4</td> </tr> </tbody> </table> 5.1.5 Status Codes After a command is completed, the kernel sends a status packet to the host with the same format as the host-to-device packet. This lets the host know if an error occurred, what type of error, and where the error occurred. The command field is the command last completed. The data field consists of a 16-bit status code followed by a 32-bit address where the error occurs. If there is no error the address is 0x12345678 unless it is responding to a DFU command in which case the address is the entry point address of the hex boot format file of the application just programmed into flash. This address could then be used for the RUN command, which tells the CPU which address to branch to and begin executing code. Table 5-8 displays the status codes. <table> <thead> <tr> <th>Status Code</th> <th>Value</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>NO_COMMAND_ERROR</td> <td>0x1000</td> <td>Return on Success</td> </tr> <tr> <td>BLANK_ERROR</td> <td>0x2000</td> <td>Return on Erase Error</td> </tr> <tr> <td>VERIFY_ERROR</td> <td>0x3000</td> <td>Return on Verify Error</td> </tr> <tr> <td>PROGRAM_ERROR</td> <td>0x4000</td> <td>Return on Programming Error</td> </tr> <tr> <td>COMMAND_ERROR</td> <td>0x5000</td> <td>Return on Invalid Command Error</td> </tr> <tr> <td>UNLOCK_ERROR</td> <td>0x6000</td> <td>Return on Unsuccessful Unlock</td> </tr> </tbody> </table> For Program, Erase and Verify commands, if a Flash API error is detected, it will be displayed on the console. If an FMSTAT error is detected, the FMSTAT register contents will be displayed. <table> <thead> <tr> <th>Status Code</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>INCORRECT_DATA_BUFFER_LENGTH</td> <td>0x7000</td> </tr> <tr> <td>INCORRECT_ECC_BUFFER_LENGTH</td> <td>0x8000</td> </tr> <tr> <td>DATA_ECC_BUFFER_LENGTH_MISMATCH</td> <td>0x9000</td> </tr> <tr> <td>FLASH_REGS_NOT_WRITABLE</td> <td>0xA000</td> </tr> <tr> <td>FEATURE_NOT_AVAILABLE</td> <td>0xB000</td> </tr> <tr> <td>INVALID_ADDRESS</td> <td>0xC000</td> </tr> <tr> <td>INVALID_CPUID</td> <td>0xD000</td> </tr> <tr> <td>FAILURE</td> <td>0xE000</td> </tr> </tbody> </table> For more details on the errors, see the device-specific Flash API guide. 5.2 F2838x SCI Flash Kernels The following section will give an overview of the F2838x SCI Flash kernels and how to use them. 5.2.1 CPU1-CPU2 Kernels The F2838x CPU1-CPU2 kernel projects utilize the SCI ROM Bootloader in CPU1 to download the CPU1 project and a modified bootloader to download the CPU2 project. The CPU1 and CPU2 kernel and application files are entered as parameters to the serial_flash_programmer utility, and the CPU1 kernel is downloaded once the host has completed the autobaud lock with the CPU1 SCI ROM Bootloader. Once the CPU1 kernel has been downloaded, normal kernel operations can start such as DFU, Erase, etc. Once the CPU1 operations are completed, the CPU2 kernel can be downloaded by selecting either the "Run CPU1 Load CPU2" or "Reset CPU1 Load CPU2" commands. For F2838x, there is not a SCI ROM Bootloader for CPU2, so CPU1 writes the CPU2 kernel into shared RAM for CPU2. There is also an instruction to branch to the CPU2 entry point placed in CPU1TOCPU2MSGRAM that is copied into M1RAM during the CPU2 boot sequence. After the branch instruction is written to M1RAM and the CPU2 boot sequence is complete, CPU2 starts execution from M1RAM and branches to the kernel entry point. Once the CPU2 kernel has been downloaded, normal kernel operations can start. The CPU1 kernel will be waiting for CPU2 to finish its kernel commands before proceeding to either the application address or a reset based on if "Run CPU1 Load CPU2" or "Reset CPU1 Load CPU2" was selected. 5.2.1 Kernel Commands Most of the commands are the same as previous devices, there are two new commands for CPU1: Run CPU1 Load CPU2 and Reset CPU1 Load CPU2. Table 5-9 describes how each command works. <table> <thead> <tr> <th>Kernel Command</th> <th>Command Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Run CPU1 Load CPU2</td> <td>0x0004</td> <td>1. Receive the packet with 32 bit address.</td> </tr> <tr> <td></td> <td></td> <td>2. Load the CPU2 kernel into GSRAM sections as specified by the CPU2 kernel</td> </tr> <tr> <td></td> <td></td> <td>3. Linker command file.</td> </tr> <tr> <td></td> <td></td> <td>4. Load the CPU2 kernel into GSRAM sections as specified by the CPU2 kernel</td> </tr> <tr> <td></td> <td></td> <td>5. Transfer control of SCI and shared RAM to CPU2.</td> </tr> <tr> <td></td> <td></td> <td>6. Branch to address.</td> </tr> <tr> <td>Reset CPU1 Load CPU2</td> <td>0x0007</td> <td>1. Receive the packet with no address.</td> </tr> <tr> <td></td> <td></td> <td>2. Load the CPU2 kernel into GSRAM sections as specified by the CPU2 kernel</td> </tr> <tr> <td></td> <td></td> <td>3. Linker command file.</td> </tr> <tr> <td></td> <td></td> <td>4. Load the CPU2 kernel into GSRAM sections as specified by the CPU2 kernel</td> </tr> <tr> <td></td> <td></td> <td>5. Transfer control of SCI and shared RAM to CPU2.</td> </tr> <tr> <td></td> <td></td> <td>6. Branch to address.</td> </tr> </tbody> </table> 5.2.2 CPU1-CM Kernels The F2838x CPU1-CM kernel projects utilize the SCI Bootloader to download the CPU1 project and a modified bootloader to download the CM project. The CPU1 and CM kernel and application files are entered as parameters to the serial_flash_programmer utility, and the CPU1 kernel is downloaded once the host has completed the autobaud lock with the CPU1 SCI ROM Bootloader. Once the CPU1 kernel has been downloaded, normal kernel operations can start such as DFU, Erase, etc. Once the CPU1 operations are completed, the CM kernel can be downloaded by selecting either "Run CPU1 Load CM" or "Reset CPU1 Load CM". CPU1 first writes the CM boot mode needed to download the kernel. After setting the boot mode for CM, CPU1 jumps to a copy function where it takes in the CM kernel being sent via SCI from the host and copies it over to a buffer in CPU1 to CM IPC Message RAM. Once it has filled up the buffer, it signals CM which will then copy over the contents of the buffer into the intended address in CM RAM. A copy function for the CM side that communicates with the CPU1 copy function is written into S0RAM during the CM boot sequence. This function was compiled using an ARM compiler and is stored as a const array in CPU1 to CM message RAM. The CPU1 and CM copy functions work together to copy over the CM kernel until all of it has been written. CPU1 then sends the CM kernel entry address to CM which then jumps to this address to start kernel execution. The user can then perform any desired CM commands. CPU1 keeps control of the SCI peripheral and sends over the data CM needs for its kernel functions when requested by CM. The CM kernel can signal the CPU1 kernel that it needs a certain function executed, for example sciaGetWordData. CPU1 will get the result of executing the function and place it into Message RAM for CM to copy over and use for any of its commands. CPU1 has 9 Options 1. DFU 2. Erase 3. Verify 4. Unlock Zone 1 5. Unlock Zone 2 6. Run 7. Reset 8. Run CPU1 Load CM 9. Reset CPU1 Load CM CM has 7 Options 1. DFU 2. Erase 3. Verify 4. Unlock Zone 1 5. Unlock Zone 2 6. Run 7. Reset 5.2.2.1 Kernel Commands CPU1 has two new commands for the F2838x SCI Flash Kernels, they are listed in Table 5-10. Table 5-10. CPU1 Kernel Commands <table> <thead> <tr> <th>Kernel Command</th> <th>Command Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Run CPU1 Load CM</td> <td>0x0030</td> <td>1. Receive the packet with 32 bit address. 2. Release Flash Pump and set boot mode via IPC for CM. 3. Write CM kernel to CM RAM via CPU1 to CM IPC Message RAM. 4. Wait for CM signal and perform SCI function for CM when requested. 5. Branch to address.</td> </tr> <tr> <td>Reset CPU1 Load CM</td> <td>0x0040</td> <td>1. Receive the packet with 32 bit address. 2. Release Flash Pump and set boot mode via IPC for CM. 3. Write CM kernel to CM RAM via CPU1 to CM IPC Message RAM. 4. Wait for CM signal and perform SCI function for CM when requested. 5. Break the while loop and enable WatchDog Timer to time-out and reset.</td> </tr> </tbody> </table> The CM commands are as listed in Table 5-11. Table 5-11. CM Kernel Commands <table> <thead> <tr> <th>Kernel Command</th> <th>Command Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>DFU CM</td> <td>0x0050</td> <td>1. Receive the packet with no data. 2. Receive the flash application byte-by-byte in boot hex format. 3. Selective Erase, Program, and Verify. 4. Send status packet. If successful, the address sent in the status packet is the entry point address of the programmed flash application.</td> </tr> <tr> <td>Erase CM</td> <td>0x0060</td> <td>1. Receive the packet with 32-bit data. 2. Selective erase the sectors specified in the data. 3. Send status packet.</td> </tr> <tr> <td>Verify CM</td> <td>0x0070</td> <td>1. Receive the packet with no data. 2. Receive the flash application byte-by-byte in boot hex format. 3. Receive the flash application byte-by-byte in boot hex format. 4. Send status packet.</td> </tr> <tr> <td>CM Unlock Zone 1</td> <td>0x0080</td> <td>1. Receive the packet with 128-bit data. 2. Write the password to the DCSM Key Registers. 3. Check to see if Zone 1 is unlocked. 4. Send status packet.</td> </tr> </tbody> </table> Table 5-11. CM Kernel Commands (continued) <table> <thead> <tr> <th>Kernel Command</th> <th>Command Code</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>CM Unlock Zone 2</td> <td>0x0090</td> <td>1. Receive the packet with 128-bit data.</td> </tr> <tr> <td></td> <td></td> <td>2. Write the password to the DCSM Key Registers.</td> </tr> <tr> <td></td> <td></td> <td>3. Check to see if Zone 2 is unlocked.</td> </tr> <tr> <td></td> <td></td> <td>4. Send status packet.</td> </tr> <tr> <td>Run CM</td> <td>0x00A0</td> <td>1. Receive the packet with a 32-bit address.</td> </tr> <tr> <td></td> <td></td> <td>2. Branch to the 32-bit address.</td> </tr> <tr> <td>Reset CM</td> <td>0x00B0</td> <td>1. Receive the packet with no data.</td> </tr> <tr> <td></td> <td></td> <td>2. Break the while loop and enable WatchDog Timer to time-out and reset.</td> </tr> </tbody> </table> 5.2.3 Using the Projects With SCI Bootloader This section details the steps needed to run the F2838x kernels on the controlCard. 5.2.3.1 CPU1-CPU2 1. Set controlCard S1:A position 1 to OFF (left). This turns off JTAG communication. 2. Set controlCard S1:A position 2 to ON (right). This turns on UART communication. 3. Set S2 position 1 to OFF (left) and position 2 to ON (right). This sets the controlCard to SCI Boot mode. 4. Open up a command window and navigate to where serial_flash_programmer.exe is. 5. Enter a command with parameters as described below: ``` Example: serial_flash_programmer.exe -d f2838x -k flash_kernel_c28x_dual_ex1_c28x1.txt -a led_ex1_c28x_dual_blinky_cpu1.txt -m flash_kernel_c28x_dual_ex1_c28x2.txt -n led_ex1_c28x_dual_blinky_cpu2.txt -b 9600 -p COM10 -v ``` 6. When the kernel is downloaded and the menu pops up, perform all CPU1 operations before proceeding with CPU2. Restarting the serial_flash_programmer application gives control back to CPU1, so CPU1 and CPU2 actions can be performed within one run of the serial_flash_programmer application. 5.2.3.2 CPU1-CM 1. Set controlCard S1:A position 1 to OFF (left). This turns off JTAG communication. 2. Set controlCard S1:A position 2 to ON (right). This turns on UART communication. 3. Set S2 position 1 to OFF (left) and position 2 to ON (right). This sets the controlCard to SCI Boot mode. 4. Open up a command window and navigate to where serial_flash_programmer.exe is. 5. Enter a command with parameters as described below: ``` Example: serial_flash_programmer.exe -d f2838x -k flash_kernel_c28x_cm_ex1_c28x1.txt -a led_ex1_c28x_cm_blinky_cpu1.txt -o flash_kernel_c28x_cm_ex1_cm.txt -r led_ex1_c28x_cm_blinky_cm.txt -b 9600 -p COM10 -v ``` 6. When the kernel is downloaded and the menu pops up, perform all CPU1 operations before proceeding with CM. Exit the application once CM actions are performed. Restarting the serial_flash_programmer application gives control back to CPU1, so CPU1 and CM actions can be performed within one run of the serial_flash_programmer application. 5.2.4 Using the Projects With CCS 5.2.4.1 CPU1-CPU2 1. Set controlCard S1:A position 1 to ON (right). This turns on JTAG communication. 2. Set controlCard S1:A position 2 to ON (right). This turns on UART communication. 3. In CCS, import and build the CPU1 and CPU2 kernel projects. 4. Launch the target configuration file. 5. Connect to CPU1. 6. Load the gel file provided in the project folder to the project. Right click on CPU1 in the target configuration and select "Open GEL Files View". 7. In the "GEL Files" tab, click on GEL Files. Right click in the "Script" window and select "Load GEL...". Navigate to the project folder and load the gel file. 8. Connect to CPU2. 9. Click "Reset" for CPU1. CPU2 is now in wait boot. 10. Click "Resume" for CPU2. 11. For CPU1, click "Load Program". 12. Load the .out file for the CPU1 kernel. Click "Resume" after the file has loaded. 13. Open up a command window and navigate to where serial_flash_programmer_appln.exe is. 14. Enter a command with parameters as described below: Example: serial_flash_programmer_appln.exe -d f2838x -d f2838x -k flash_kernel_c28x_dual_ex1_c28x1.txt -a led_ex1_c28x_dual_blinky_cpu1.txt -m flash_kernel_c28x_dual_ex1_c28x2.txt -n led_ex1_c28x_dual_blinky_cpu2.txt -b 9600 -p COM10 -v 15. When the menu pops up, perform all CPU1 operations before proceeding with CPU2. 5.2.4.2 CPU1-CM 1. Set controlCard S1:A position 1 to ON (right). This turns on JTAG communication. 2. Set controlCard S1:A position 2 to ON (right). This turns on UART communication. 3. In CCS, import and build the CPU1 and CM kernel projects. 4. Launch the target configuration file. 5. Connect to CPU1. 6. Load the gel file provided in the project folder to the project. Right click on CPU1 in the target configuration and select "Open GEL Files View". 7. In the "GEL Files" tab, click on GEL Files. Right click in the "Script" window and select "Load GEL...". Navigate to the project folder and load the gel file. 8. Connect to CM. 9. Click "Reset" for CPU1. CM is now in wait boot. 10. Click "Resume" for CM. 11. For CPU1, click "Load Program". 12. Load the .out file for the CPU1 kernel. Click "Resume" after the file has loaded. 13. Open up a command window and navigate to where serial_flash_programmer_appln.exe is. 14. Enter a command with parameters as described below. Ex: serial_flash_programmer_appln.exe -d f2838x -k flash_kernel_c28x_cm_ex1_c28x1.txt -a led_ex1_c28x_cm_blinky_cpu1.txt -o flash_kernel_c28x_cm_ex1_cm.txt -r led_ex1_c28x_cm_blinky_cm.txt -b 9600 -p COM10 -v 15. When the menu pops up, perform all CPU1 operations before proceeding with CM. Exit the application once CM actions are performed. Restarting the serial_flash_programmer application gives control back to CPU1, so CPU1 and CM actions should be performed within one run of the serial_flash_programmer application. 6 Example Implementation The kernels described above are available in C2000Ware under examples folder for the specific device within the examples directory. For example, the flash kernel for F2837x is found at C2000Ware_x_x_xx_xx > device_support > f2837xd > examples > dual > F2837xD_sci_flash_kernels > cpu01. The host application is found in C2000Ware (C2000Ware_x_xx_xx_xx > utilities > flash_programmers > serial_flash_programmer). The source and executable are found in the serial_flash_programmer folder. This section details the serial_flash_programmer: how to build, run and use it with Flash Kernel A and B. Note The flash kernel of the appropriate device must be supplied to the host application tool being used to program the flash. The serial_flash_programmer starts the same way independent of the kernel or device. It first loads the kernel to the device through the SCI ROM bootloader. After this, the tool's functionality differs depending on the device and kernel being used. 6.1 Device Setup 6.1.1 Flash Kernels Flash kernel source and project files for Code Composer Studio (CCS) are provided in C2000Ware, in the corresponding device’s examples directory. Load the project into CCS and build the project. These projects have a post-build step in which the compiled and linked .out file is converted into the correct boot hex format needed by the SCI ROM bootloader and is saved as the example name with a .txt extension. 6.1.2 Hardware After building the kernels in CCS, it is important to setup the device correctly to be able to communicate with the host PC running the serial_flash_programmer. The first thing to do is make sure the boot mode select pins are configured properly to boot the device to SCI boot mode. Next, connect the appropriate SCI boot loader GPIO pins to the Rx and Tx pins that are connected to the host PC COM port. A transceiver is often needed in order to convert a Virtual COM port from the PC to GPIO pins that can connect to the device. On some systems, like the controlCARD, an FTDI chip is used to interface the GPIO pins used for SCI communication to a USB Virtual COM port. Refer to the user guide for the controlCARD to get information on the switch configuration needed to enable SCI communication. In this case, the PC must connect to the mini-USB on the controlCARD and use channel B of the FTDI chip to connect to the GPIO pins on the device. After the hardware is setup correctly to communicate with the host, reset the device. This should boot the device to SCI boot mode. 6.2 Host Application: serial_flash_programmer 6.2.1 Overview The command line PC utility is a lightweight (~292KB executable) programming solution that can easily be incorporated into scripting environments for applications like production line programming. It was written using Microsoft Visual Studio® in C++. The project and its source can be found in C2000Ware (C2000Ware_x_xx_xx_xx > utilities > flash_programmers > serial_flash_programmer). To use this tool to program the C2000 device, ensure that the target board has been reset and is currently in the SCI boot mode and connected to the PC COM port. The command line usage of the tool is described below: ``` serial_flash_programmer.exe -d <device> -k <kernel file> -a <app file> -p COM <num> [-m] <kernel2 name> [-n] <app2 name> [-o] <kernel3 name> [-r] <app3 name> [-b] <baudrate> [-q] [-w] [-v] ``` - **-d <device>** - The name of the device to connect and load to: - F2802x, F2803x, F2805x, F2806x, F2807x, F2837xD, F2837xS, F28004x, F2838x, F28002x, F28003x, F280013x or F280015x - **-k <file>** - The file name for the CPU1 flash kernel. This file must be in the ASCII SCI boot format. - **-a <file>** - The application file name to download or verify to CPU1. This file must be in the ASCII SCI boot format. - **-m <file>** - The file name for the CPU2 flash kernel. This file must be in the ASCII SCI boot format. - **-n <file>** - The application file name to download or verify to CPU2. This file must be in the ASCII SCI boot format. - **-o <file>** - The file name for the CM flash kernel. This file must be in the ASCII GPIO boot format. - **-r <file>** - The application file name to download or verify to CM. This file must be in the ASCII GPIO boot format. - **-p COM<num>** - Set the COM port to be used for communications - **-b <num>** - Set the baud rate for the COM port. - **-? or -h** - Show help. - **-q** - Quiet mode. Disable output to stdout - **-w** - Wait for a key press before exiting. - **-v** - Enable verbose output. -d, -k, -a, -p are mandatory parameters. If the baud rate is omitted, it will be set to 9600 by default. Both the flash kernels and flash application MUST be in the SCI8 boot format. For F2838x CM, the flash kernel and flash application file MUST be in the GPIO8 boot format. This was discussed earlier in Section 3 and can be generated from the OUT file using the hex2000 utility. 6.2.2 Building and Running serial_flash_programmer Using Visual Studio Serial_flash_programmer.cpp can be compiled using Visual Studio. 1. Navigate to the serial_flash_programmerdirectory. 2. Double click the serial_flash_programmer.sln to open the Visual Studio project. 3. When Visual Studio opens, select Build → Build Solution. 4. After Visual Studio completes the build, select Debug → serial_flash_programmerproperties. 5. Select Configuration Properties → Debugging. 6. Select the input box next to the CommandArguments. 7. Type the arguments in the following format. The arguments are described in Section 6.2.1. - Format: -d <device> -k <file> -a <file> -p COM<num> -b <baudrate> - Example: -d f2807x -k C:\Documents\flash_kernel.txt -a C:\Documents\Test.txt -p COM7 -b 9600 8. Click Apply and OK. 9. Select Debug → Start Debugging to begin running the project. 6.2.3 Running serial_flash_programmer for F2806x (Flash Kernel A) Note It is recommended to reset the device before running serial_flash_programmer so that Autobaud will complete correctly. 1. Navigate to the folder containing the compiled serial_flash_programmer executable. 2. Run the executable serial_flash_programmer.exe with the following command: > serial_flash_programmer.exe -d f2806x -k <-\f28069_flash_kernel.txt> -a <file> -p COM<num> This first loads the f28069_flash_kernel into RAM of the device using the bootloader. Then, the kernel executes and loads and program flashes with the file specified by the ‘-a’ command line argument. 6.2.4 Running serial_flash_programmer for F2837xD (Flash Kernel B) Note It is recommended to reset the device before running serial_flash_programmer so that auto baud will complete correctly. 1. Navigate to the folder containing the compiled serial_flash_programmer executable. 2. Run the executable serial_flash_programmer.exe with the following command: > serial_flash_programmer.exe -d f2837xD -k <-\F2837xD_sci_flash_kernels_cpu01.txt> -a <file> -m <-\F2837xD_sci_flash_kernels_cpu02.txt> -n <file> -p COM<num> -v This will automatically connect to the device, perform an auto baud lock, and download the CPU1 kernel into RAM and execute it. Now, the CPU1 kernel is running and waiting for a packet from the host. 3. The serial_flash_programmer prints the options to the screen to choose from that will be sent to the device kernel (see Figure 6-1). Select the appropriate number and then provide any necessary information when asked for that command (described in Section 5.1). In the case of DFU or Verify, the original command already specified the Application file, so no additional information will be required at this point. Figure 6-2 shows what the window will look like after the execution of command 1- DFU CPU1. 6.3 Host Application: Firmware Updates on F28004x With SCI Flash Kernel 6.3.1 Overview As explained, the SCI Flash Kernel enables firmware updates. This section will walk through one possible method of doing so using SCI boot and flash boot modes. For this scenario, the device will boot from flash by default, and use SCI boot for firmware updates. One thing worth noting is what exactly booting from flash entails. As noted earlier, a bootloader is used by a device to load and run code from an external source. The SCI flash kernel is loaded to RAM and then the application is loaded to flash. In the case of booting from flash, the device is already equipped with the application, either through Uniflash, CCS or a custom bootloader. In this scenario, once the device boots from flash, through the flash entry point, the application will run. For firmware updates, the device can boot up in SCI boot mode, where the serial flash programmer will download the SCI flash kernel to RAM which allows the download of the new application to flash - this allows the firmware upgrade to happen without putting the SCI flash kernel in flash, thus saving flash space. 6.3.2 Boot Pin Configurations In order to have both of the boot modes for flash Boot and SCI boot, the boot mode needs to be configured. The boot control GPIO Pins determine the boot mode configuration - for F28004x devices, the Boot control Pins are GPIO 24 and GPIO 32. In order to boot from flash, both GPIO 24 and GPIO 32 have to be pulled up to 1, and for SCI Boot, GPIO 24 needs to be pulled down to 0. How a user pulls down the GPIO pin depends on the implementation - one possible example is that the device itself will set the GPIO pin low prior to a firmware upgrade - more details can be found in [10]. 6.3.3 Using Three Boot Modes Suppose that a user wants to switch between 3 boot modes - SCI, flash and I2C. Three boot mode pins will need to be used, since they do not fall into the 4 device default boot modes. In order to have further customization of boot modes as desired here, the user needs to use the BOOTPIN_CONFIG location of the user configurable DCSM OTP. This allows the user to select up to 3 GPIO pins to have up to 8 total boot modes. The BOOTDEF register of the user configurable DCSM OTP will also allow the user to configure boot modes beyond the default boot modes. To switch between SCI, flash, and I2C Boot, the following steps need to be taken: 1. Set BOOTPIN_CONFIG appropriately – bits 7-0, 15-8, 23-16 all to indicate which GPIOs will be used to represent the boot mode. Bits 31-24 will have the key 0x5A to validate the earlier bits. 2. Set BOOTDEF1 to 0x01 to indicate SCI boot with boot mode 1 (when boot mode select GPIOs = 001) and the SCI GPIOs are GPIO29 and GPIO28. 3. Set BOOTDEF3 to 0x03 to indicate Flash boot with boot mode 3 (when boot mode select GPIOs = 011). The Flash entry point is 0x80000 from Flash Bank 0, sector 0. 4. Set BOOTDEF7 to 0x07 to indicate I2C boot with boot mode 7 (when boot mode select GPIOs = 111), and the I2C GPIOs are GPIO32 and GPIO33. For experimentation with boot mode options, users can use the EMU_BOOTPIN_CONFIG register before writing to OTP_BOOTPIN_CONFIG. OTP_BOOTDEF also has an EMU_BOOTDEF for experimentation. The equivalent of the BOOTPIN_CONFIG registers on the F2837x is the BOOTCTRL register. 6.3.4 Performing Live Firmware Updates We have seen how the flash kernel is downloaded to RAM, and facilitates downloading the application to flash. By storing the flash kernel in flash, the user does not need to download the flash kernel to RAM, thus saving time. It is available in flash to directly download the application to flash. On the other hand, it takes up some flash space. This is a tradeoff that certain users may decide to use. It is especially useful to enable certain features, such as Live Firmware Updates (LFU). In LFU, the application only uses flash boot mode, and when the application is running, a user can choose to update firmware. The application will pass control to the flash kernel in flash, which will facilitate updating the application in Flash. On a single-bank flash, this typically requires a device reset. But if the device contains multiple flash banks, a device reset can be avoided with LFU, allowing a seamless transition to new firmware. For further details on how to perform Live Firmware Updates, see [6] and [7]. 7 Troubleshooting Below are solutions to some common issues encountered by users when utilizing the SCI flash kernel. 7.1 General **Question:** I cannot find the SCI flash kernel projects, where are they? **Answer:** <table> <thead> <tr> <th>Device</th> <th>Build Configurations</th> <th>Location</th> </tr> </thead> <tbody> <tr> <td>F2802x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2802x &gt; examples &gt; structs &gt; f28027_flash_kernel</td> </tr> <tr> <td>F2803x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2803x &gt; examples &gt; c28 &gt; f2803x_flash_kernel</td> </tr> <tr> <td>F2805x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2805x &gt; examples &gt; c28 &gt; f28055_flash_kernel</td> </tr> <tr> <td>F2806x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2806x &gt; examples &gt; c28 &gt; f28069_sci_flash_kernel</td> </tr> <tr> <td>F2807x</td> <td>CPU1-CPU2</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2807x &gt; examples &gt; cpu1 &gt; f2807x_sci_flash_kernel</td> </tr> <tr> <td>F2833x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2833x &gt; examples &gt; f28335_flash_kernel</td> </tr> <tr> <td>F2837xS</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2837xs &gt; examples &gt; cpu1 &gt; F2837xS_sci_flash_kernel &gt; cpu01</td> </tr> <tr> <td>F2837xD</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; device_support &gt; f2837xd &gt; examples &gt; dual &gt; F2837xD_sci_flash_kernels</td> </tr> <tr> <td>F28004x</td> <td>RAM, Flash with LDFU, Flash without LDFU</td> <td>C2000Ware_x_xx_xx_xx &gt; driverlib &gt; f28004x &gt; examples &gt; flash, select flashapi_ex2_sci_flash_kernel</td> </tr> <tr> <td>F2838x</td> <td>CPU1-CPU2</td> <td>C2000Ware_x_xx_xx_xx &gt; driverlib &gt; f2838x&gt;examples&gt;c28x_dual&gt;flash_kernel</td> </tr> <tr> <td>F28002x</td> <td>RAM, Flash with LDFU</td> <td>C2000Ware_x_xx_xx_xx &gt; driverlib &gt; f28002x &gt; examples &gt; flash, select flash_kernel_ex3_sci_flash_kernel</td> </tr> <tr> <td>F28003x</td> <td>RAM, Flash with LDFU</td> <td>C2000Ware_x_xx_xx_xx &gt; driverlib &gt; f28003x &gt; examples &gt; flash, select flash_kernel_ex3_sci_flash_kernel</td> </tr> <tr> <td>F280013x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; driverlib &gt; f280013x &gt; examples &gt; flash, select flash_kernel_ex3_sci_flash_kernel</td> </tr> <tr> <td>F280015x</td> <td>RAM</td> <td>C2000Ware_x_xx_xx_xx &gt; driverlib &gt; f280015x &gt; examples &gt; flash, select flash_kernel_ex3_sci_flash_kernel</td> </tr> </tbody> </table> **Question:** What is the difference between Flash Kernel A and Flash Kernel B? **Answer:** Type A flash kernels erase the entirety of flash before streaming any data in, whereas Type B flash kernels erase only the required sectors as data is being streamed in. Type B kernels also provide users the choice to erase all or chosen sectors as they want, as a standalone operation. In addition, Type B kernels support a variety of user commands as opposed to Type A kernels which only support an application load command. **Question:** What are the first things I should check if the SCI flash kernel does not download? **Answer:** - One area of the program to check would be the linker command file - make sure all flash sections are aligned to 128-bit boundaries. In SECTIONS, add a comma and "ALIGN(8)" after each line where a section is allocated to flash. • One other common issue users encounter is that they are not using the correct boot pins for SCI boot mode. For example, on the F28004x devices, SCI boot has 4 options for GPIO pins to use. Make sure that the pins for the default option are not being used for something else. If it is, make sure that another SCI boot option is used, so that it can be connected to another set of pins. Make sure that the SCI kernel project uses this SCI boot GPIO option as the parameter for SCI_GetFunction() as well. • When using long cables, use a lower baud rate to get rid of noise. • For baud rate and connection issues, try running SCI loopback and echoback examples for the device (you should be able to find these in C2000Ware in the device_support or driverlib folders for your device). 7.2 SCI Boot **Question:** I cannot download the SCI kernel to RAM in SCI boot mode, what should I do? **Answer:** Make sure to use the correct GPIO pins to use SCI boot mode. Refer to the previous question for a detailed explanation. 7.3 F2837x **F2837xS** **Question:** The SCI Kernel is downloaded to RAM and Application is downloaded to Flash, but no command window appears, and once that is done, Flash seems to be unwritten to? **Answer:** To address the issue where no command window appears after the Flash kernel is downloaded to RAM - SCI Flash Kernel project contains 2 possible SCIA Boot options: • SCIA Boot option 2 (GPIO 28, 29) • SCIA Boot option 1 (GPIO 84, 85) Use the right pins for your hardware configuration. To address the issue where Flash does not get written properly - Align all Flash sections to 128-bit boundaries in the linker command file. **F2837xD** **Question:** I want to boot from Flash and SCI, how do I switch between the two? Flash Boot is used for normal operation, SCI Boot for firmware update. **Answer:** There are a few options here. A few are mentioned in Section 6.3 - the device can boot up in Flash boot mode for normal operation, and in SCI Boot mode for firmware upgrades. The user will need to design a scheme that allows changing the boot mode select pins settings. Alternately, the user can decide to only use the Flash boot mode, and then in software, branch to the SCI Boot function. This can be through an IO trigger or host command, that serves as a cue to call the SCI_Boot() function. The advantage of this approach is that the user does not need to change the boot mode select pins settings. Note that in this case, the SCI ROM Bootloader is not invoked. **Question:** Using SCI Boot mode to upgrade firmware works, however using Flash boot and branching to SCI Boot in software by calling SCI_Boot() does not work. What should I look at to fix this? **Answer:** • Make sure the correct GPIO pins are being used for SCI boot mode. • Also, it is necessary to disable the watchdog and interrupts prior to the SCI_Boot() call in your program, since Flash is being updated. **Question:** With the ControlCARD, I cannot download the SCI Flash Kernel to RAM in SCI Boot, what steps should I take to do so? **Answer:** 1. The controlCARD requires that option 2 of SCI Boot be used in order for it to work on the device. For more details, see the Warnings/Notes/Errata section of [12]. In order to do this, make sure the SCI Flash Kernel project builds with SCI_BOOT_ALTERNATE as the parameter for SCI_GetFunction. 2. Next, set the SW1:A position 1 to ON on the controlCARD. This allows the emulator to be connected. Set the Boot mode to SCI by setting SW1 Position 1 to 0, and SW1 Position 2 to 1. 3. After that, make sure that SW1:A position 2 is also ON. GPIO28 (and pin 76 of the 180-pin controlCARD connector) will be coupled to the FTDI’s USB-to-Serial adapter. This allows UART communication to a computer via the FTDI chip. 4. After this, connect the emulator via CCS. Launch the target configuration file for the controlCard and connect to CPU1. Open up a Memory Window (View > Memory Window) and look up the location 0xD00 in memory. Change it to 0x815A. In order to use Alternate GPIOs (28, 29) for SCI Boot mode, we need to set the BMODE field (bits 15:8) of the corresponding BOOTCTRL register (either EMUBOOTCTRL (0xD00) or Z1-BOOTCTRL (0x7801E which is in User configurable DCSM OTP) to 0x81). 5. If you wish to run the flash kernel on CPU2 as well, connect to it in CCS. Click "Reset CPU", followed by "Resume". The program will hit ESTOP. Click "Resume" again. 6. In CCS, for CPU1, click "Reset CPU", followed by "Resume" (F8). 7. Now, run the command serial_flash_programmer.exe with the appropriate command. The kernel will be downloaded to RAM. When the menu pops up, select the desired operation to proceed. To see what the command window will look like at this stage, see Figure 6-1. F2837xD LaunchPad Question: I cannot get the SCI Flash Kernel to load into RAM, is there a reason why? Answer: The F2837xD LaunchPad does not support SCI Boot Mode, so this board cannot be used with the SCI Flash Kernel (see the Revision section of [11]). 8 References 4. Texas Instruments: TMS320F28M35x and TMS320F28M36x Flash API Reference Guide 7. Texas Instruments: Live Firmware Update Without Device Reset on C2000 MCUs 8. Texas Instruments: USB Flash Programming of C2000 Microcontrollers 9. Texas Instruments: TMS320F28004x Boot Features and Configurations 10. Texas Instruments: C2000 Software Controlled Firmware Update Process 9 Revision History NOTE: Page numbers for previous revisions may differ from page numbers in the current version. Changes from Revision E (October 2021) to Revision F (July 2023) Page • Updated the numbering format for tables, figures and cross-references throughout the document…………………2 • Updated Section 5…………………………………………………………………………………………………………5 • Updated Section 5.1………………………………………………………………………………………………………5 • Updates were made in Section 6.2.1…………………………………………………………………………………..14 • Updated Section 7.1……………………………………………………………………………………………………..18 IMPORTANT NOTICE AND DISCLAIMER TI PROVIDES TECHNICAL AND RELIABILITY DATA (INCLUDING DATA SHEETS), DESIGN RESOURCES (INCLUDING REFERENCE DESIGNS), APPLICATION OR OTHER DESIGN ADVICE, WEB TOOLS, SAFETY INFORMATION, AND OTHER RESOURCES “AS IS” AND WITH ALL FAULTS, AND DISCLAIMS ALL WARRANTIES, EXPRESS AND IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS. These resources are intended for skilled developers designing with TI products. You are solely responsible for (1) selecting the appropriate TI products for your application, (2) designing, validating and testing your application, and (3) ensuring your application meets applicable standards, and any other safety, security, regulatory or other requirements. These resources are subject to change without notice. TI grants you permission to use these resources only for development of an application that uses the TI products described in the resource. Other reproduction and display of these resources is prohibited. No license is granted to any other TI intellectual property right or to any third party intellectual property right. TI disclaims responsibility for, and you will fully indemnify TI and its representatives against, any claims, damages, costs, losses, and liabilities arising out of your use of these resources. TI's products are provided subject to TI's Terms of Sale or other applicable terms available either on ti.com or provided in conjunction with such TI products. TI's provision of these resources does not expand or otherwise alter TI's applicable warranties or warranty disclaimers for TI products. TI objects to and rejects any additional or different terms you may have proposed. Mailing Address: Texas Instruments, Post Office Box 655303, Dallas, Texas 75265 Copyright © 2023, Texas Instruments Incorporated
{"Source-Url": "https://www.ti.com/lit/an/sprabv4f/sprabv4f.pdf?ts=1690963232812", "len_cl100k_base": 16031, "olmocr-version": "0.1.53", "pdf-total-pages": 21, "total-fallback-pages": 0, "total-input-tokens": 54520, "total-output-tokens": 16909, "length": "2e13", "weborganizer": {"__label__adult": 0.000946044921875, "__label__art_design": 0.0009512901306152344, "__label__crime_law": 0.0006732940673828125, "__label__education_jobs": 0.0012607574462890625, "__label__entertainment": 0.00016200542449951172, "__label__fashion_beauty": 0.000507354736328125, "__label__finance_business": 0.0007300376892089844, "__label__food_dining": 0.0006465911865234375, "__label__games": 0.0025196075439453125, "__label__hardware": 0.234375, "__label__health": 0.0006728172302246094, "__label__history": 0.0005817413330078125, "__label__home_hobbies": 0.000522613525390625, "__label__industrial": 0.005336761474609375, "__label__literature": 0.0002930164337158203, "__label__politics": 0.0003981590270996094, "__label__religion": 0.0012884140014648438, "__label__science_tech": 0.1832275390625, "__label__social_life": 8.404254913330078e-05, "__label__software": 0.0208892822265625, "__label__software_dev": 0.54052734375, "__label__sports_fitness": 0.0007548332214355469, "__label__transportation": 0.0022068023681640625, "__label__travel": 0.0002849102020263672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 65142, 0.06718]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 65142, 0.38354]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 65142, 0.83661]], "google_gemma-3-12b-it_contains_pii": [[0, 793, false], [793, 3642, null], [3642, 7560, null], [7560, 11380, null], [11380, 14983, null], [14983, 17637, null], [17637, 22598, null], [22598, 24824, null], [24824, 28372, null], [28372, 32125, null], [32125, 35038, null], [35038, 39015, null], [39015, 42247, null], [42247, 45928, null], [45928, 48988, null], [48988, 50153, null], [50153, 53412, null], [53412, 56629, null], [56629, 60177, null], [60177, 63214, null], [63214, 65142, null]], "google_gemma-3-12b-it_is_public_document": [[0, 793, true], [793, 3642, null], [3642, 7560, null], [7560, 11380, null], [11380, 14983, null], [14983, 17637, null], [17637, 22598, null], [22598, 24824, null], [24824, 28372, null], [28372, 32125, null], [32125, 35038, null], [35038, 39015, null], [39015, 42247, null], [42247, 45928, null], [45928, 48988, null], [48988, 50153, null], [50153, 53412, null], [53412, 56629, null], [56629, 60177, null], [60177, 63214, null], [63214, 65142, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 65142, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 65142, null]], "pdf_page_numbers": [[0, 793, 1], [793, 3642, 2], [3642, 7560, 3], [7560, 11380, 4], [11380, 14983, 5], [14983, 17637, 6], [17637, 22598, 7], [22598, 24824, 8], [24824, 28372, 9], [28372, 32125, 10], [32125, 35038, 11], [35038, 39015, 12], [39015, 42247, 13], [42247, 45928, 14], [45928, 48988, 15], [48988, 50153, 16], [50153, 53412, 17], [53412, 56629, 18], [56629, 60177, 19], [60177, 63214, 20], [63214, 65142, 21]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 65142, 0.26415]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
93e996266cd436ad443c24d6443284386d77dbff
Software Patent Application Drafting Guideline Development Wonjong Choi (May/1/2014) Department of Writing Studies University of Minnesota Abstract Software patent drafting is a promising field because top IT (Internet Technology) companies rely on software patents to protect their products. However, software patent drafting is a relatively unknown field for technical communication students. This paper answers the questions on "how to become a patent writer" and "how to draft a software patent application". This paper provides specific required skills to become a patent writer. In addition, this paper also provides specific guidelines to drafting the most important sections in a software patent application: claim, embodiment, and diagram sections. Two patent experts working for Samsung Electronics have reviewed this work and their feedback was applied to this paper. Introduction A patent application is a detailed description of an invention. Since patent officers use this patent application as their only evidence to decide whether the invention is patentable subject matter or not, drafting a patent application is a crucial skill when requesting patent rights. For patent application drafting, many guidelines and textbooks detail good general drafting skills. However, there are few materials which explain good software patent application drafting skills even though the software industry is one of the most important and promising industries in the world. Since a software program is not a tangible object and has never been patentable in the past, patent writers require specialized skills and experience to develop a patent application that includes claims, embodiments, and diagrams. In addition, for technical writers, patent drafting is a new and promising field. Many international companies need patent agents to protect their patent rights and this job is potentially stable because drafting patent applications requires specialized knowledge. This paper provides software patent drafting techniques for patent staff-members, inventors, and technical communication students. This guideline will focus on patent application drafting techniques that request stronger patent rights in the claim, embodiment, and drawing sections of patent applications. Moreover, this paper also provides essential steps to becoming a patent agent (writer) for technical writers and technical writing students. # Contents Abstract Introduction Contents Research Method Patent System Patent drafting skill overview Patent and Software Patent How to become a patent agent Patent Agent as a Job How to Become a Professional Patent Writer Patent Drafting Guideline Claim Drafting Beauregard Claim System Claim Method Claim Embodyment Drafting Smart phone & Tablet Television......................................................................................................................... 30 Cameras & Camcorders................................................................................................. 31 Health Equipment......................................................................................................... 33 Diagram Drafting .......................................................................................................... 34 Composition Diagram .................................................................................................. 34 Flowchart ...................................................................................................................... 36 User Interface Diagram ................................................................................................. 37 Terminology Definition ................................................................................................. 39 Reference ...................................................................................................................... 40 Appendix ....................................................................................................................... 42 Interview Question ....................................................................................................... 42 Interview Result – Interviewee #1 ............................................................................... 43 Interview Result – Interviewee #2 ............................................................................... 44 Target Audience ......................................................................................................... 46 Research Method This paper is based on the case study method. Top software companies such as Apple, Google, and Microsoft believe that patent rights are crucial to protecting their market shares. To draft good patent applications, they hire good experienced patent writers, so in general, patent applications created by such companies are top-notch. Thus, analyzing and understanding patent applications from these companies is the best method to absorb good patent drafting skills. First of all, well-known software related patent applications are collected because major software companies such as Apple, Google, and Microsoft hire experienced patent writers. These patent documents are analyzed to extract good language expressions. Then, experienced patent agents read this and provide feedback to improve this guideline. (See Figure 1) Two patent experts will then answer interview questions. They worked for Samsung Electronics in Korea and are currently working toward a technical writing master’s degree in the USA. They have more than 10 years of experience in patent and engineering fields. They have drafted patent applications for Samsung electronics and analyzed patent documents from the biggest electronic companies in the world. Thus, they are able to provide thorough and valuable feedback. They will be presented with ten interview questions about their educational background, becoming a patent writer, and drafting good patent applications. Patent System Patent drafting skill overview A patent application is comprised of several sections which contain detailed technical descriptions and legal expressions. (See Figure 2) Clearly, writing patent applications requires specialized knowledge and skills. First of all, technical knowledge is important in drafting patent applications. Inventions are the result of technical development activities. Since patent writers need to understand this technical subject matter and describe it clearly on a patent application, they should have thorough technical knowledge to draft good patent applications. Two patent experts who have more than 10 years of experience in the patent field provided feedback after reading these guidelines and they point out that technical writers must have a thorough knowledge of technical matters to draft good patent applications. In addition, the patent system is the impetus behind technological advances. New technologies need to present new specialized approaches to meet traditional patent requirements. Software invention is an example. Since software programs are not “tangible” objects, they are not patentable under the definition that a new, useful, and nonobvious process or product is a patentable subject matter under 35 U.S.C. (United States Constitution) §101. To make software programs patentable, inventors must create a tangible product which contains the invented software program. For example, when an inventor puts his GPS program, which navigates cars, into a general purpose computer, this computer is not merely “a general purpose computer” anymore. This is a GPS machine, making it a patentable product even though the GPS software program itself is not patentable. In addition to good writing skills, patent application drafting also requires the use of specialized language expressions in the patent field to make better patent applications and thus get better protection. For example, when an invention contains a particular component, patent writers need to describe it not as one component but “at least” one component. This is because if other copycats contained two or more components, they would get around the infringement if the claim stated only “a component.” This example demonstrates a need for language manipulation in patent writing. Although patent writers own their own writing inventories, they rarely share these collections. This inhibits patent writers from improving the quality of patent applications by sharing their know-how. Patent and Software Patent Article I, Section 8, Clause 8 of the United States Constitution states that “To promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries.” The very first purpose of the given clause - Article I, Section 8, Clause 8 – is to protect the right of intellectual property holders. There are three kinds of intellectual properties – patents, trademarks, and copyrights. The most important intellectual property is the patent, which provides exclusive rights to patent holders for a limited time. Abraham Lincoln said “The patent system added the fuel of interest to the fire of genius, in the discovery and production of new and useful things.” (Feb. 11, 1859). When there was no patent system, there was no method to protect one’s invention. Inventors spent much effort and invested human and monetary resources into developing new products yet could not protect their exclusive rights to their inventions, so they usually hid their technological details from the public. Other inventors weren’t able to build on technology that had already been invented. Thus, there were many redundant developments which stalled technological innovation because innovation is more effectively based on existing technologies. In addition to the exclusive rights of patent holders, the given clause also protects the right of the general public. First of all, exclusive rights with rewards for a limited time motivate technology inventors. The creations improve the quality of life for the general public. People have more conveniences and can enjoy a variety of creative media. In addition, restricting the time helps the general public get full benefits from intellectual property after their rights expire. Figure 3 explains the expiration of a patent. A patent application is published 18 months after its submission, so competitors can obtain the detailed description of new technology and thus can develop better products based on it. This patent expires after 20 years. Then the general public can use the technology and make products following the patent without paying royalties. **Figure 3. Patent Expiration** Since software programs are not “tangible” objects, they are not patentable under the definition that a new, useful, and nonobvious process or product is a patentable subject matter under 35 U.S.C. §101. However, nowadays, software programs have the most potential to achieve success in the market because the quality of hardware from the top electronic companies is almost the same. Customers select an electronic device because of good user interface and user experience implemented by software programs. Thus, patent writers and inventors can convert an intangible software program into a tangible product by combining the invented software program and electronic hardware. “Slide to Unlock” in Figure 4 is one of the best-known issued software patents in the world. (Apple, 2009) Basically, “Slide to Unlock” is a software program to implement an unlocking user interface. To make a patent application for this software program, Apple combines this software program with iPhone (hardware) and writes a patent application for this iPhone which contains the software program. Figure 4. Internal Structure to Implement "Slide to Unlock" (Apple, 2009) How to become a patent agent Patent Agent as a Job Patent agents draft patent applications and govern the patent process. This process includes drafting patent applications, receiving inquiries from patent officers, and resolving these inquiries. Patent agents work with inventors such engineers and product developers and legal professionals such as patent attorneys. Therefore, a patent agent is a technical writer with legal and technical knowledge. This is a good job opportunity for technical writers because many international companies need patent agents to protect their patent rights. In addition, patent agents have more stability in their job positions because of the specialized legal and technical knowledge that is needed. Interviewees also stated that patent drafting job positions are very stable because many companies try to request patent rights to protect their products. As a result, the average salary for patent writers is higher than for other technical writers. (Oppenheimer, 2008) According to the statistics, the median expected salary for a patent agent in the United States is $85,645 (See Figure 5) while the median expected salary for a technical writer is $65,000. (U.S. Bureau of Labor Statistics, 2014) ![Figure 5. Income Range of Patent Agents (Salary.com, 2014)] How to Become a Professional Patent Writer To become a professional patent writer, it is important to understand the process and requirements, and to put them into practice. This section introduces four steps to becoming a patent writer. 1. Acquire Technical Knowledge Basically, a patent application is a description of an invention. To understand the invention itself, technical knowledge is needed. Although patent writers don’t need to have technical knowledge to invent or develop a product or a process, they need to be able to understand the invention and convert its description into legal language. Patent writers should have a certain level of technical knowledge, so they should take courses related to the subject matter when they are undergraduate or graduate students. 2. Understand the patent prosecution process To draft a good patent application, patent writers must understand the patent system well. They should understand patent requirements and the structure and organization of patent applications. To request patent rights for an invention, the invention must be new, useful, and nonobvious. First of all, if there is “a prior art”, inventors are not able to get patent rights. This is a very simple rule. When someone creates a product which already exists, this is not an invention. Second, an invention has to be “a useful art.” For example, when an inventor developed an energy efficient car engine technology, this is a patentable subject matter. However, when an inventor developed an efficient weapon to kill people, this is not a patentable subject matter. This is because an efficient instrument to kill people is not useful for the general public. Third, an invention has to be a nonobvious matter. If an invention doesn’t contain any technological improvements, this would not be a patentable subject matter meaning that if the invention is one of ordinary skills in the field, it is not a patentable subject matter. In addition to understanding patentable subject matters, patent writers have to know all the sub-sections of patent applications. A patent application is made up of title, abstract, drawings, field of invention, prior art, objects of invention, consistory clauses, description of drawings, specific description, and claims. 3. Read patent applications written by well-known companies in your field After understanding the patent system, prospective patent writers should read well written patent documents to observe the techniques of other writers. To select good patent documents, patent applications submitted by the world leading companies in your field are likely the best places to start. These companies hire experienced patent writers and lawyers. They draft patent applications and revise them carefully so their patent documents should contain useful and valuable expressions to request patent rights. 4. Practice patent application drafting The next step is practicing. For any sort of professional writing, practice is a very important activity. Patent application drafting is the same. Two methods are advised. First, prospective patent writers should read patent documents and rewrite them. This allows fledgling patent writers to memorize the structure of patent applications. Second, prospective patent writers can begin to understand the concept of an invention by reading a patent document. Then, they can start to convert the subject matter of the invention into their own expressions. This helps them to improve their patent drafting skills. 5. Review and Request feedback from experts If possible, prospective patent writers should ask other experts to review their writings to get feedback. Experts have their own insight so they are in a position to highlight the good aspects and weaknesses of the patent writings and then could provide recommendations. This allows prospective patent writers to understand their shortcomings and improve them. Patent Drafting Guideline Claim Drafting Patent claims establish the boundaries or scope of an invention. (Stim, 2014) When a copycat made, used, or sold an invention, the patent right owner would be able to sue the copycat. The court compares the invention described in patent claims with every component of the copied product to make a decision. Thus, patent claims are the most important section in a patent application. This section provides representative patent claim drafting methods in the Software invention field and provides the best practices. Beauregard Claim A Beauregard claim is a computer-readable medium claim. Beauregard claims cover computer storage devices which contain a set of computer instructions that make a computer perform a designed function. In the past, a set of computer instructions to perform a certain process was not patentable because these instructions were considered a written document and not an invented object. Figure 6 is an example of a set of computer instructions. Computer programmers and developers write this computer software program using computer programming language. Then, computers interpret and process this computer software program written in computer programming languages. The court viewed this as a set of instructions written down on paper, denying that it is a manufactured product and a patentable subject. However, from the mid-1990s, the court started to view a set of computer instructions stored in a computer-readable storage device such as a floppy disk, a hard disk drive, and a flash memory drive as an article of manufacture, making it patentable. (Malhotra, 2007) Since Beauregard claims allow patent writers to describe the software program invention directly, almost all software patent applications include this kind of claim. **Good Practice:** 17. One or more non-transitory computer-readable media having computer executable code stored thereon, the code comprising: **a routine executable to display a slide bar** with three discrete positions and no intermediate positions there between, wherein the three discrete positions comprise a payment confirmation position disposed at a first end of the slide bar, a decline position disposed at a second end of the slide bar opposite of the first end, and an initial position disposed on the slide bar between the payment confirmation position and the decline position, wherein the slide bar can be swiped from the initial position to a payment confirmation position and from the initial position to the decline position; **a routine executable to confirm a payment** when the graphical element is moved to the confirmation position. (Casey, 2012) This is an example of a Beauregard claim for motion-based payment confirmation. The invention is comprised of two parts. Each part is a set of computer instructions. The first set features a slide bar on the display unit of the target device. Then, the device senses a motion gesture input from a user by monitoring the movement of the said slide bar. When the slide bar is moved to the confirm position, the second set of computer instructions confirms the position of the slide bar and proceeds to the payment process. This claim is good because of the two reasons mentioned below. 1. There are only two components which comprise the invention. When the court makes an infringement decision, it compares each component in the patent claim with a component in a copycat. Few components in the patent claim help the court compare components easily, so it is easier to draw an infringement decision from the court. ② The first component contains only three essential units for the payment. This claim contains three locations for motion – initial position, decline position, and confirm position. These positions are essential for the payment process. Therefore, it is almost impossible to invent a copycat without including three locations. If a copycat also had these three positions in its implementation, it would be a clear infringement. How to write a Beauregard claim: One or more non-transitory computer-readable media having computer executable code stored thereon, the code comprising: [Component A of the SW program] (further details of this SW component); [Component B of the SW program] (further details of this SW component); [Component C of the SW program] (further details of this SW component); And so on. To create a Beauregard claim, patent writers should identify essential components in the invented SW program. These components are elements in the claim. Then, they arrange SW components and write an additional description of each component. Basically, a SW component is a set of computer instructions and a separation unit to dissect a SW program. Patent writers don’t need to write all components in the independent claim. They should write essential components in the independent claim and write non-essential components into dependent claims. **System Claim** In general, all software programs are comprised of steps which perform a process. A system claim is to protect novel components that perform mandatory steps of the invented software program. Therefore, this system claim will protect essential and novel components of the invention. When the court decides whether a competitor has infringed on the invention, the court compares the existence of all components in the patent claim to components in the copycat. When the competitor divides components in the invention into two or more groups and implements two or more systems which work together as a single system to avoid infringement, the court decides it is an infringement. This is because the party must control a system as a whole and obtains benefit from it. Because a system claim allows patent writers to describe novel components or modules in the invention all software patent applications have these types of claims. **Good Practice:** 1. A **system** comprising: - an image receiver configured to receive a digital image, including time of capture of the digital image corresponding to a preset time zone; **a location receiver** configured to receive location information identifying a location, including time of recording of the location information corresponding to a reference time zone; **a comparison unit** configured to compare the preset time zone with the reference time zone; and **a processor** operatively coupled to the image receiver and the location receiver, the processor configured to detect an assignment of the digital image to the location; and generate an indication of a time zone conflict, responsive to the comparison by the comparison unit. (Bhatt, 2013) This example claim is a software program for adjusting time metadata of digital media items. When the time of capture of the digital image is in a preset time zone that is different from the time zone of the location, the user of this capturing device will receive a notification about time zone conflict. This invented system is comprised of four components. The first component acquires an image and a preset zone time. The second component acquires the location. The third component compares the preset zone time with the local time. The fourth component detects any difference and provides a notification where there is a time discrepancy. This claim is good because the purpose of each component in the claim is clear. Patent writers who drafted this claim clearly defined the purpose of each component. This helps judges understand this claim clearly and able to compare all components in this claim with components in a copycat, enabling the inventors to get an infringement decision from the court, preventing competitors from creating copycats. **How to draft a System claim:** A system for [the invented product] comprising: - [Element A] (further details of this element); - [Element B] (further details of this element); - [Element C] (further details of this element); And so on. The structure of a system claim is simple. First of all, identify essential elements of the invention. If there are non-essential elements, patent writers shouldn’t place them in an independent claim as this could narrow the scope of the invention. In addition, patent writers should use general terminology. If they used their own lingo and other competitors used different terminology, the court could decide that they are not using the same terminology and the competitors are not infringing on the invention. Method Claim A software program has a process to achieve certain goals, comprised of steps. Method claims include active steps in a process to define the invention. A process has to be unique or better than the prior arts. Each element in a claim uses verb + “-ing” form. This element represents an active step in a process. So, a method claim is a set of steps in verb + “-ing” forms. When the court decides whether a competitor has infringed on the invention, the court compares the existence of all steps in the method claim to steps in the copycat. When there are too many steps in a claim, it is easy for competitors to stall the existing patent claim by omitting one or two steps in the claim. Therefore, it is very important to identify important (and essential) steps in the process of the invented software program and draft a claim based on only such essential steps. Other unessential steps will be included in other independent claims. Good Practice: 1. A method for providing a user With contextual information for at least one alarm received from a transmitting electronic device, Wherein a receiving electronic device is configured to be in communication with the transmitting electronic device, Wherein an alarm date and an alarm time are associated with the at least one alarm, comprising of: receiving the at least one alarm from the transmitting electronic device; parsing the at least one alarm; automatically matching the at least one alarm to an alarm template; **storing** the at least one alarm on the receiving electronic device with the matched alarm template; and **outputting** the contextual information from the alarm template matched with the at least one alarm at the alarm date and alarm time. (Bull, 2012) **Figure 7. An Example of a Patent Flow Chart (Bull, 2012)** Figure 7 is a flow chart describing the main process of this invented software program. As you can see, this invention is comprised of element steps of the invented process. The claim is including and describing exactly the same process in this flow chart. This example claim is a software program for providing an alarm with contextual information. In other words, when a user receives an alarm, the system also provides related information about it. For example, when a user receives an alarm, the system shows text or images related to this alarm. Therefore, the user is able to identify why the system has presented an alarm. This claim is good because of the two reasons mentioned below. 1. The purpose of each step in the claim is clear and essential. This claim has five steps. They are all essential steps to achieve the goal of this invention. Other competitors are not able to create the same software program without these five steps. 2. This claim doesn’t include unessential steps, like independent claims do. When patent writers want to include non-essential steps into a claim, they would be able to combine the independent claim with a dependent claim to create a more specific claim. Patent writers do this to avoid other prior arts. **How to draft a Method claim:** A **method** for [the invented product] comprising: [Step A of the SW program] (further details of the step A); [Step B of the SW program] (further details of the step B); [Step C of the SW program] (further details of the step C); And so on. To write a method claim, the first step is to identify steps detailing the process of the invention. Software programs consist of steps. A computer follows these steps to complete a process and output the expected result – data or information. Similar to other claim types, patent writers should identify essential steps in the invented process. They don’t need to state non-essential steps in the independent claim. Instead, they should be able to state these non-essential steps on dependent claims. **Embodiment Drafting** *Embodiment by definition is a manner in which an invention can be made, used, practiced or expressed.* (Bellis, 2014) In a patent application, possible examples of the concept of the invention are given to explain different embodiments. The primary purpose of these examples is to explain the feasibility of the invention and to demonstrate significant unexpected improvement from prior arts. (Shao, 2014) Therefore, the embodiment section in a patent application has to contain a detailed description of all possible products and practices of the invention. Moreover, after reading the embodiment section of a patent application, other engineers in the same field should be able to implement the same product and practice the same process. When this embodiment is not specific enough for others such as patent officers, the patent application will be rejected because patent officers base the feasibility of the invention on the embodiment section. In addition, patent officers and judges will decide the scope of the invention by evaluating claims in a patent application. The embodiment describes detailed possible implementations of the invention and supports claims. Therefore, the scope of the embodiment is very important to determine the scope of the invention, making it very important to write all possible embodiments to broaden the scope of the invention and to request stronger patent rights. This section provides representative devices in the Software invention field and provides the best practices for embodiments for these devices. - **Smart phone & Tablet**: These devices are the most popular contemporary mobile devices. - **Television**: Almost all contemporary devices contain a display unit. Therefore, technologies related to television are important because such technologies are applicable to other devices. - **Camera & Camcorder**: A smartphone and a tablet include two cameras – back and front - and the quality of image is one of the most important factors to evaluate a smartphone or a tablet. The most popularly used online services such as Facebook and Instagram are based on camera and camcorder technologies, making these software technologies one of the most important technologies for contemporary mobile devices. - **Health Equipment**: Personal mobile health equipment is an emerging business area and many software companies are focusing on this field. Smart phone & Tablet Convergence Nowadays, smartphones and tablets are very important devices. Smartphones, including tablets, overlap with other electronic devices such as cell phones, personal computers, organizers, televisions, cameras, camcorders, mp3 players, and portable gaming consoles. (See Figure 8) Figure 8. How Over 40 Gadgets Converge Into the Tiny Device in Your Pocket (Russell, 2013) Because these devices are all connected, when patent writers and inventors write smartphone related inventions, they should expand their definitions of the inventions to cover these devices. Therefore, patent writers should use the expression “a mobile communication device” to cover all possible communication devices. Patent writers could use “an image capturing device” to cover a camera and camcorder. This is a good expression that could cover televisions and other video related devices. **Recommendations and Sharing** Smartphones and tablets have both communication ability and a high performance processor. To expand an invention and gain stronger patent rights, patent writers and inventors need to think outside the box. **Recommendation:** Patent writers and inventors are able to add location based features to their initial invention. For example, if the invention were a music player, they could add location based recommendations to their initial concept. In addition, they could add other features – user profile, weather and mood - to recommend music to users. By adding recommendation features to user inventions, a variety of embodiments is possible, making it a stronger case. **Sharing:** Patent writers and inventors are able to expand their inventions by adding sharing features to it. Because of the communication ability of mobile devices and affordability of wireless network cost, sharing contents with peers and other devices is the most popular application. **Television** For a television related invention, it is possible to expand the concept of the invention to all devices containing a display unit such as LCD (Liquid-Crystal Display), OLED (Organic Light-Emitting Diode), and CRT (Cathode Ray Tube). The number of television viewers is decreasing. More people are using smart phones, tablets, and personal computers to watch video contents because these devices are easy to carry and provide interactive services. If the invention only covered “Television”, its impact on the market would not be big enough. Thus, inventors and patent writers have to consider that their inventions could be applied to other devices having display units and expand their inventions to such devices. **Communication** Recently, several television manufacturers have released “Smart TVs” which are able to access the Internet and provide interactive applications to users. However, the market impact is not big enough because users already have convenient communication devices so this feature on the TV is not especially desired. As a result, when inventors and patent writers limit the invention to only televisions, the concept becomes available to manufacturers of tablets and smartphones since the patent doesn’t include these devices. Thus, when an invention is related to televisions, inventors and patent writers have to consider whether a television could possibly have communication capability. This way of thinking will create additional implementations of the invention that should cover not only televisions but also smartphones and tablets. **Cameras & Camcorders** **Image Capturing Device:** Patent writers and inventors don’t describe their inventions as “Camera” or “Camcorder” because this limits the scope of their inventions. Because of convergence and semiconductor technologies, the digital image sensor such as CMOS (Complimentary Metal Oxide Semiconductor) is tiny and other electronic devices such as smartphones, tablets, personal computers (laptops), and televisions include one or more cameras to acquire and share images. When an invention uses “camera” to define itself, the scope of this invention is limited to only camera. This is not a good strategy because other device manufacturers could use this invention without paying royalties if they manufactured not a camera but a smartphone, tablet, and so on. To cover all possible devices mentioned here and request stronger patent rights, patent writers and inventors should use “image capturing device” or “image acquiring device” instead of “camera” or “camcorder.” **Communication** Nowadays, the biggest cameral competitor is the smartphone. Smartphones are easy to carry and have communication capability. This lets people share their photos and has been instrumental in promoting SNS (Social Networking Service). As a result, the size of the market for the camera business is decreasing. However, since a camera is equipped with a high imaging sensor and is able to produce higher quality photos, many people still prefer cameras. Figure 9 compares the image sensor size of the iPhone and a popular DSLR (Digital Single-Lens Reflex) camera. The small, left-most box is an iPhone image sensor and the right-most box is a DSLR sensor. Because of this larger sensor, photos taken by a DSLR are always of better quality. To compete against smartphones and expand the scope of an invention, patent writers and inventors could add communication ability to their camera related inventions. They could write additional implementations related to sharing photos with other people and other devices. This would help them to create stronger patent rights. **Figure 9. Sensor Size: A Relative Size Comparison Tool for Camera Sensors (Zhang, 2012)** Health Equipment **Connectivity:** Improved sensor technology has allowed device manufacturers to create tiny and cheap health devices. This will most certainly create a new huge market, so many electronic giants are trying to get a foot in the door. Mobile device companies such as Apple are also trying to provide health devices by connecting health devices with their mobile devices – iPhone and iPad – to create a variety of inventions. Figure 10 is an example of connectivity – iPhone and sensing device. The sensor monitors user activities including biometric data and send this information to the connected iPhone or iPad. This monitored information can be used to check a user’s health status. Therefore, patent writers who write health device related inventions have to consider convergence scenarios between health devices and mobile devices. This will create various new embodiments for the invention and helps to strengthen patent rights. ![Figure 10. Sports monitoring system for headphones, earbuds and/or headsets (Prest, 2008)](image-url) Diagram Drafting A patent application has to include at least one patent drawing. All patent drafting agencies hire designers who draw diagrams in patent applications. Patent writers draw rough drafts and designers then create very formal and professional diagrams. Therefore, patent writers have to understand why diagrams are important and what diagrams are the best for software related inventions. Helping readers to understand the invention and supporting the invention description are the most important reasons to include diagrams in patent applications. **Drawings help readers understand the invention:** A picture is worth a thousand words. Sometimes, patent readers prefer diagrams to writings because it might be easier to interpret diagrams than read text in order to understand the invention. Readers might also have a more clear understanding of relationships among components comprising the invention. Therefore, understandable diagrams help patent officers understand the invention itself and feasibility of the invention, so this may allow a patent a smoother passage. **When patent writers omit a writing requirement, drawings could substitute for it:** Diagrams in a patent application have to include all components mentioned in the invention claims. This allows patent writers to confirm that they have included all components in the application. If patent writers accidentally omit a component of the invention and it is shown in the diagram, it is okay. **Composition Diagram** A composition diagram is the most common diagram type for a patent application. This diagram includes all components comprising the invention. For example, software related products always have at least one processor unit, one storage unit, one memory unit, input port unit, output port unit, and a display unit. In addition, each product also includes particular hardware components which represent the main functionalities. For example, the two most important differences between a smartphone and a personal computer are sensors and communication ability. Smartphone and tablet related inventions have to contain such sensor and communication components. After including these hardware components, diagrams have to include all software components stated in the claims. Figure 11. Internal Structure to Implement "Slide to Unlock" (Apple, 2009) Figure 11 is a good example of a composition diagram. This diagram is comprised of hardware components and software components. Although the hardware composition is simplified, it includes all essential hardware components. Software composition includes all essential software components, so it is easy to identify important components and interactions among them. This helps patent officers and other engineers understand this invention easily. In addition, the quality of this diagram is high, so readers are able to examine every detail. Sometimes, the quality of a diagram is poor, so readers cannot get all the details. **Flowchart** The easiest method to explain a software program is a flowchart. Technically, a software program is a set of computer instructions and the computer executes one order on this set at a time. This creates an execution flow of instructions. Therefore, the best way to understand a software program is to understand this control flow so almost all software patents include at least one flow chart. Figure 12 is a good example of a flowchart. This flow chart is good for two reasons. First of all, good flowcharts in patent applications should be simple and clear, so they are easy to understand. If patent officers are not able to understand your invention, they won’t be able to evaluate it, and thus they won’t give you patent rights. Therefore, patent writers and inventors need to identify essential steps for their invention and create an understandable flowchart using comprehensive language expressions. Second, this diagram must contain all components mentioned in the first claim of this invention. Each box in this flowchart represents each element in the first claim. This is important because patent officers would be able to confirm claim elements from this flowchart. ![Flowchart Image] **Figure 12. A Flow Chart Example (Casey, 2012)** **User Interface Diagram** Nowadays, UI (User Interface) technology is a very important technology. Since the hardware performance of electronic devices has become universally similar, people are starting to select electronic devices based on the quality of their user interface, creating competition in the software field. “Slide to Unlock” created by Apple is the best example. This UI technology provided a very intuitive interface to secure the iPhone. (Chaudhri, 2009) Other software manufacturers such as Google are not able to use this intuitive technology for Android because this is protected by the patent system. Figure 13 is the main diagram from the patent document of this UI technology. This diagram is good because patent officers are able to intuitively understand the purpose of this invention and figure out the difference between other previous technologies and this technology. Figure 13. User Interface Diagram of "Slide to Unlock" (Apple, 2009) Terminology Definition 1. USPTO: United States Patent and Trademark Office 2. Prior Art: *All information that has been made available to the public in any form before a given date that might be relevant to a patent's claims of originality* (Wikipedia, 2014) 3. Embodiment: *Inventions can take the form of many embodiments. Each embodiment is a manner in which an invention can be made, used, practiced or expressed.* (Patenthome, 2014) Reference Appendix Interview Question General Question 1. What is your job title in your company? 2. What are typical tasks that you do in your job? 3. Describe your education – undergraduate major, graduate major, and so on. How to become a patent writer 4. Do you think patent writing is a promising job for a technical writing student? Why or why not? 5. Describe the steps to become a patent writer. 6. What skills are the most useful to become a patent writer? How to draft a good software patent application 7. Select the three or four most important sections. Why? For example, the claim, diagram, and embodiment sections are important because ... 8. What skills are the most important to draft a good software patent application? Why? 9. What kinds of information should be added to this software patent drafting guideline? Why? Interview Result – Interviewee #1 1. What is your job title in your company? Patent Engineer 2. What are typical tasks that you do in your job? Patent strategy planning, patent application review, Patent map 3. Describe your education – undergraduate major, graduate major, and so on. Graduate 4. Do you think patent writing is a promising job for a technical writing student? Why or why not? In the USA, patent agents and patent layers are only able to draft a patent application because the American government regulates this. In addition, patent drafting requires good writing skills, technical knowledge, and legal knowledge. Therefore, I can’t say a good technical writer is a good patent writer. A patent writer needs to train for all three skills – writing skills, technical knowledge, and legal knowledge. However, I agree with you that patent writing is a promising field. This is true. 5. Describe the steps to become a patent writer. Engineering Background -> Technical writing -> Patent law (agent, lawyer) 6. What skills are the most useful to become a patent writer? Three skills I mentioned above are the most important skills. Among them, technical knowledge is the most important. 7. Select the three or four most important sections. Why? The claim section is the most important. Although Claim is the most important section in a Patent application (claimed invention), Embodiment should support claims. Therefore, embodiment section is also important. 8. What skills are the most important to draft a good software patent application? Why? I think technical knowledge is the most important skill. This is because technical understanding of the invention and related products is crucial to drafting a software patent application and prove infringement. 9. What kinds of information should be added to this software patent drafting guideline? Why? Importance of technical knowledge --- **Interview Result – Interviewee #2** 1. What is your job title in your company? A. Senior engineer 2. What are typical tasks that you do in your job? A. To produce patent applications: I review ideas collected from inventors and convey them to patent attorneys to write patent applications. I review the applications and submit them to patent offices. B. To analyze patents applications from other companies: I review patent applications that are on the public domain to examine and find out what technologies other companies focus on. 3. Describe your education – undergraduate major, graduate major, and so on. A. B.S.E in Electrical Engineering / B.S. in Computer Science (Double major) B. M.S in Electrical Engineering 4. Do you think patent writing is a promising job for a technical writing student? Why or why not? A. I think that it is a promising job because the demand to produce well-written patent applications are increasing continuously. However, the patent writing requires writers to have deep knowledge on technical subject matters. So, if you want to devote yourself to becoming a patent writer, you should know that you have to study technical knowledge. 5. Describe the steps to become a patent writer. A. There are various ways to become a patent writer. In the U.S., becoming a patent agent is the most effective way to be a patent writer. To become a patent agent, you should study a patent agent exam and pass it. Another way to become a patent writer is getting a job in a patent law firm. Many law firms hire patent writers and drafters. 6. What skills are the most useful to become a patent writer? A. Writing skill is the most important for a patent writer because one of the main jobs of a patent writer is to write an invention based on an inventor’s idea. The patent writer should be capable of producing a clear patent application that claims the inventor’s right. To make a patent application clear is not an easy job. It requires ceaseless efforts and long work experience. 7. Select the three or four most important sections. Why? For example, the claim, diagram, and embodiment sections are important because ... The claim section is the most important because it claims the right of the patent application. The embodiment section is important because it can be used to interpret the claim section. The diagram section is important because it helps readers understand the invention very effectively. 8. What skills are the most important to draft a good software patent application? Why? A. Software itself is not patentable. Thus, a description of how a device works with the software is very important 9. What kinds of information should be added to this software patent drafting guideline? Why? A. If a real example is given to the readers, it would be very helpful. For example, how to write a patent application about a software program such as Photoshop. **Target Audience** This guideline is for technical writers, inventors, and students who want to become a patent writer or need to draft a patent application. This guideline provides three representative personas of the target audience to help readers understand the purpose of this guideline. Personaes include a software writer, an inventor, and a technical communication student. Each persona describes why he or she uses this guideline and how to use this guideline. 1. Software Patent Writers Patent application drafting requires the use of specialized language expressions in the patent field to make more explicit patent applications and thus get better protection. Patent writers usually have their own inventories which contain examples of the use of specialized language expressions. However, these personal inventories come from personal knowledge and depend on insufficient patent analysis. Thus, this guideline will replace personal patent drafting inventories. **Persona:** A patent writer who has a technical writing and engineering background Dana is a 30 year old patent writer who works at Samsung Headquarters in Korea. She previously had a job writing electronic hardware patent applications, so she is good at patent application drafting. Recently, she was thinking about her future career and realizes that major Korean companies and the Korean government are focusing on the “Software” business. Therefore, she was considering a career as a software patent writer in the future. The company also offered various software patent writer positions, so she was able to change her role and stay in the company. **Scenario:** She searches for information about software patent application drafting. She searches for guidelines and detailed examples. As a result, she visits my website. At the beginning, she tries to find claim drafting examples because claim is the most important part to define patent rights when she drafts a patent application. She uses the main menu bar on the top of my website to navigate it. She looks for the term “Claim Drafting” or “Claim Example” to find claim types and examples. She is able to find her target page easily and reads the detailed information. She is able to find claim types and examples with detailed explanations. The webpage also provides pros and cons of each example. Therefore, she is able to compare them and find the best one for her concurrent drafting. 2. Inventors in Software Industry (Developers, Researchers, and Students) Inventors must understand the detailed characteristics of Software patent application practices to protect their own inventions. **Persona:** Software Developer Sherry is a 35 year old software developer who works for a small IT company in Minnesota. She is developing a software program for Android software platform. Recently, she invented a better user interface. She wants to protect her invention by demanding patent rights. The company assigned a patent writer who will write a patent application. **Scenario:** Her main interest is to create a more convenient user interface for locking and unlocking smartphones. Recently, she invented a new and better user interface to lock and unlock smartphones. Since the patent writer will draft a patent application for her, she needs to express her invention clearly to the patent writer. However, because of a lack of understanding of the patent system, she is not able to communicate with the patent writer well. The company will provide incentives when she submits the patent application to USPTO (United States Patent and Trademark Office). Therefore, she is looking for a quick reference guide for software patent application drafting and visits my website. She wants to draft a main diagram which describes the internal structure of the invented software system, so she is looking for “diagram drafting” from the website. When she finds a page which contains diagram examples for software inventions, she realizes that this website provides the information she needs. The website contains representative examples of contemporary software and hardware visualizations from the top three IT companies – Apple, Google, and Microsoft. Although she doesn’t have a patent background, she is able to draft a diagram for her invention. She will use this diagram to explain her invention to the patent writer. In addition, the patent writer will improve on this diagram and use it as the main diagram in the patent application. 3. Technical communication students A patent writing job is a good opportunity for students who study technical communication. Students may want to study patent application drafting skills to prepare for their future. **Persona:** Graduate Student in Technical Communication Brian is a 25 year old graduate student working toward a master’s degree in technical communication. He is searching for a job. Although he knows about traditional job positions for technical writers, he is looking for a more specialized technical writing job position because he believes that specialized writing positions may lead to a brighter and more stable future. Recently, he read a new article about patent lawsuits related to Apple and Samsung. He thinks patent writing could be a good career choice because it requires not only good writing skills but also legal knowledge. **Scenario:** Brian is looking for some basic information about the patent application drafting process because he wants to be a patent application writer and is unfamiliar with this field. He visits the law library at the University of Minnesota to find resources. However, he realizes that all patent drafting books are too thick and difficult to read so he looks for brief and easy materials. At the beginning, he searches for patent writers using the Linkedin search function. He visits my Linkedin profile page and reads my profile and then visits my guideline website to acquire further information. When he connects to my website, he glances at the main menu items on the top. Then, he clicks on “how to become a patent writer.” After reading this webpage, he wants to read examples of patent application drafting. He uses a search form on the website to find examples and reaches the “claim types and examples” webpage. He reads each claim type carefully and thinks this website is good to get initial knowledge about patent application drafting. Finally, he adds this website to his bookmarks for future reference. Image Source: http://www.freedigitalphotos.net/images/Learning_g376-College_Student_Holding_Notebook_p104950.html
{"Source-Url": "https://conservancy.umn.edu/bitstream/handle/11299/163075/WRIT8505%20-%20The%20Final%20Project%20-%20Wonjong%20Choi.pdf;jsessionid=8D788F1DD348E88575E01DA196A0B5B2?sequence=1", "len_cl100k_base": 10562, "olmocr-version": "0.1.53", "pdf-total-pages": 50, "total-fallback-pages": 0, "total-input-tokens": 99670, "total-output-tokens": 13451, "length": "2e13", "weborganizer": {"__label__adult": 0.0013942718505859375, "__label__art_design": 0.002716064453125, "__label__crime_law": 0.02886962890625, "__label__education_jobs": 0.406494140625, "__label__entertainment": 0.0007348060607910156, "__label__fashion_beauty": 0.0006923675537109375, "__label__finance_business": 0.020477294921875, "__label__food_dining": 0.0008192062377929688, "__label__games": 0.004955291748046875, "__label__hardware": 0.002349853515625, "__label__health": 0.0014677047729492188, "__label__history": 0.0011510848999023438, "__label__home_hobbies": 0.0005731582641601562, "__label__industrial": 0.001407623291015625, "__label__literature": 0.004230499267578125, "__label__politics": 0.0020389556884765625, "__label__religion": 0.0008864402770996094, "__label__science_tech": 0.0377197265625, "__label__social_life": 0.0006113052368164062, "__label__software": 0.053741455078125, "__label__software_dev": 0.42431640625, "__label__sports_fitness": 0.0008978843688964844, "__label__transportation": 0.0009174346923828124, "__label__travel": 0.0005316734313964844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 59022, 0.01736]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 59022, 0.90107]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 59022, 0.92685]], "google_gemma-3-12b-it_contains_pii": [[0, 140, false], [140, 881, null], [881, 2426, null], [2426, 2792, null], [2792, 4559, null], [4559, 5402, null], [5402, 6022, null], [6022, 6765, null], [6765, 8539, null], [8539, 10560, null], [10560, 11861, null], [11861, 11935, null], [11935, 13237, null], [13237, 14551, null], [14551, 16150, null], [16150, 17168, null], [17168, 18546, null], [18546, 19297, null], [19297, 20760, null], [20760, 21957, null], [21957, 23234, null], [23234, 24512, null], [24512, 25679, null], [25679, 27170, null], [27170, 27689, null], [27689, 29035, null], [29035, 30526, null], [30526, 31975, null], [31975, 32874, null], [32874, 34450, null], [34450, 36106, null], [36106, 37637, null], [37637, 38694, null], [38694, 40295, null], [40295, 41142, null], [41142, 42834, null], [42834, 43527, null], [43527, 43912, null], [43912, 44353, null], [44353, 45809, null], [45809, 46511, null], [46511, 47352, null], [47352, 48847, null], [48847, 50137, null], [50137, 51937, null], [51937, 53289, null], [53289, 55074, null], [55074, 56920, null], [56920, 58450, null], [58450, 59022, null]], "google_gemma-3-12b-it_is_public_document": [[0, 140, true], [140, 881, null], [881, 2426, null], [2426, 2792, null], [2792, 4559, null], [4559, 5402, null], [5402, 6022, null], [6022, 6765, null], [6765, 8539, null], [8539, 10560, null], [10560, 11861, null], [11861, 11935, null], [11935, 13237, null], [13237, 14551, null], [14551, 16150, null], [16150, 17168, null], [17168, 18546, null], [18546, 19297, null], [19297, 20760, null], [20760, 21957, null], [21957, 23234, null], [23234, 24512, null], [24512, 25679, null], [25679, 27170, null], [27170, 27689, null], [27689, 29035, null], [29035, 30526, null], [30526, 31975, null], [31975, 32874, null], [32874, 34450, null], [34450, 36106, null], [36106, 37637, null], [37637, 38694, null], [38694, 40295, null], [40295, 41142, null], [41142, 42834, null], [42834, 43527, null], [43527, 43912, null], [43912, 44353, null], [44353, 45809, null], [45809, 46511, null], [46511, 47352, null], [47352, 48847, null], [48847, 50137, null], [50137, 51937, null], [51937, 53289, null], [53289, 55074, null], [55074, 56920, null], [56920, 58450, null], [58450, 59022, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 59022, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 59022, null]], "pdf_page_numbers": [[0, 140, 1], [140, 881, 2], [881, 2426, 3], [2426, 2792, 4], [2792, 4559, 5], [4559, 5402, 6], [5402, 6022, 7], [6022, 6765, 8], [6765, 8539, 9], [8539, 10560, 10], [10560, 11861, 11], [11861, 11935, 12], [11935, 13237, 13], [13237, 14551, 14], [14551, 16150, 15], [16150, 17168, 16], [17168, 18546, 17], [18546, 19297, 18], [19297, 20760, 19], [20760, 21957, 20], [21957, 23234, 21], [23234, 24512, 22], [24512, 25679, 23], [25679, 27170, 24], [27170, 27689, 25], [27689, 29035, 26], [29035, 30526, 27], [30526, 31975, 28], [31975, 32874, 29], [32874, 34450, 30], [34450, 36106, 31], [36106, 37637, 32], [37637, 38694, 33], [38694, 40295, 34], [40295, 41142, 35], [41142, 42834, 36], [42834, 43527, 37], [43527, 43912, 38], [43912, 44353, 39], [44353, 45809, 40], [45809, 46511, 41], [46511, 47352, 42], [47352, 48847, 43], [48847, 50137, 44], [50137, 51937, 45], [51937, 53289, 46], [53289, 55074, 47], [55074, 56920, 48], [56920, 58450, 49], [58450, 59022, 50]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 59022, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
02ad77469fd0a7cc435b95608c5024a078bfe346
External-Memory Exact and Approximate All-Pairs Shortest-Paths in Undirected Graphs Rezaul Alam Chowdhury Vijaya Ramachandran UTCS Technical Report TR-04-38 August 31, 2004 Abstract We present several new external-memory algorithms for finding all-pairs shortest paths in a $V$-node, $E$-edge undirected graph. Our results include the following, where $B$ is the block-size and $M$ is the size of internal memory. We present cache-oblivious algorithms with $O((V \cdot \frac{B}{T} \log \frac{M}{B} E))$ I/Os for all-pairs shortest paths and diameter in unweighted undirected graphs. For weighted undirected graphs we present a cache-aware APSP algorithm that performs $O(V \cdot (\sqrt{\frac{VE}{B}} + \frac{E}{B} \log \frac{V}{B}))$ I/Os. We also present efficient cache-aware algorithms that find paths between all pairs of vertices in an unweighted graph whose lengths are within a small additive constant of the shortest path length. All of our results improve earlier results known for these problems. For approximate APSP we provide the first nontrivial results. Our diameter result uses $O(V + E)$ extra space, and all of our other algorithms use $O(V^2)$ space. In our work on external-memory algorithm for APSP in weighted undirected graphs we develop the notion of a slim data structure that might have other applications in external-memory computations. 1 Introduction 1.1 The APSP Problem The all-pairs shortest paths (APSP) problem is one of the most fundamental and important combinatorial optimization problems from both a theoretical and a practical point of view. Given a (directed or undirected) graph $G$ with vertex set $V[G]$, edge set $E[G]$, and a non-negative real-valued weight function $w$ over $E[G]$, the APSP problem seeks to find a path of minimum total edge-weight between every pair of vertices in $V[G]$. For any pair of vertices $u, v \in V$, the path from $u$ to $v$ having the minimum total edge-weight is called the shortest path from $u$ to $v$, and the sum of all edge-weights along that path is the shortest distance from $u$ to $v$. The diameter of $G$ is the longest shortest distance between any pair of vertices in $G$. For unweighted graphs the APSP problem is also called the all-pairs breadth-first-search (AP-BFS) problem. By $V$ and $E$ we denote the size of $V[G]$ and $E[G]$, respectively. Considerable research has been devoted to developing efficient internal-memory approximate and exact APSP algorithms [18]. All of these algorithms, however, perform poorly on large data sets when data needs to be swapped between the faster internal memory and the slower external memory. Since most real world applications work with huge data sets, the large number of I/O operations performed by these algorithms becomes a bottleneck which necessitates the design of I/O-efficient APSP algorithms. 1.2 Cache-Aware Algorithms To capture the influence of the memory access pattern of an algorithm on its running time Aggarwal and Vitter [1] introduced the two-level I/O model (or external memory model). This model consists of a memory hierarchy with an internal memory of size $M$, and an arbitrarily large external memory partitioned into blocks of size $B$. The I/O complexity of an algorithm in this model is measured in terms of the number of blocks transferred between these two levels. Two basic I/O bounds are known for this model: the number of I/Os needed to read $N$ contiguous data items from the disk is $\text{scan}(N) = \Theta\left(\frac{N}{B}\right)$ and the number of I/Os required to sort $N$ data items is $\text{sort}(N) = \Theta\left(\frac{N}{B} \log \frac{N}{B}\right)$ [1]. A straightforward method of computing AP-BFS (or APSP) is to simply run a BFS (or single source shortest path (SSSP) algorithm, respectively) from each of the $V$ vertices of the graph. External BFS on an unweighted undirected graph can be solved using either $(V + \text{sort}(E))$ I/Os [15] or $\mathcal{O}\left(\sqrt{VEB}\right)$ I/Os [13]. External SSSP on an undirected graph with general non-negative edge-weights can be computed in $\mathcal{O}(V + \frac{E}{B} \log \frac{V}{B})$ I/Os using the cache-aware Buffer Heap [8]. There are also some results known for external SSSP on undirected graphs with restricted edge-weights [14]. The I/O complexity for external AP-BFS (or APSP) is obtained by multiplying the I/O complexity of external BFS (or SSSP) by $V$. Very recently Arge et al. [6] proposed an $\mathcal{O}(V \cdot \text{sort}(E))$ I/O cache-aware algorithm for AP-BFS on undirected graphs. Their algorithm works by clustering nearby vertices in the graph, and running concurrent BFS from all vertices of the same cluster. This same algorithm can be used to compute unweighted diameter of the graph in the same I/O bound and $\mathcal{O}(\sqrt{VEB})$ additional space. They also present another algorithm for computing the unweighted diameter of sparse graphs ($E = \mathcal{O}(V)$) in $\mathcal{O}(\text{sort}(kV^2B^2))$ I/Os and $\mathcal{O}(kV)$ space for any integer $k$, $3 \leq k \leq \log B$. For undirected graphs with general non-negative edge-weights Arge et al. [6] proposed an APSP algorithm requiring $\mathcal{O}(V \cdot (\sqrt{VEB} + \text{sort}(E)))$ I/Os, whenever $E \leq \frac{BV}{\log V}$. They use a priority queue structure called the Multi-Tournament-Tree which is created by bundling together a number of I/O-efficient Tournament Trees [12]. The use of this structure reduces unstructured accesses to adjacency lists at the expense of increasing the cost of each priority queue operation. 1.3 The Cache-Oblivious Model The main disadvantage of the two-level I/O model is that algorithms often crucially depend on the knowledge of the parameters of two particular levels of the memory hierarchy and thus do not adapt well when the parameters change. In order to remove this inflexibility Frigo et al. introduced the cache-oblivious model [11]. As before, this model consists of a two-level memory hierarchy, but algorithms are designed and analyzed without using the parameters $M$ and $B$ in the algorithm description, and it is assumed that an optimal cache-replacement strategy is used. No non-trivial algorithm is known for the AP-BFS and the APSP problems in the cache-oblivious model except for the method of running single BFS and SSSP, respectively, from each of the $V$ vertices. In this model, BFS on an undirected graph can be performed using $\mathcal{O}\left(\sqrt{VEB} + \frac{E}{B} \log V + \text{MST}(E)\right)$ I/Os [7], and SSSP on an undirected graph with non-negative real-valued edge-weights can be solved in $\mathcal{O}(V + \frac{E}{B} \log \frac{V}{M})$ I/Os using the cache-oblivious Buffer Heap [8] or Bucket Heap [7]. (The result is stated as $\mathcal{O}(V + \frac{E}{B} \log \frac{V}{M})$ I/Os in both [8] and [7], but it was observed by the current authors and the second author in [7] that the amortized I/O cost is actually $\mathcal{O}(V + \frac{E}{B} \log \frac{V}{M})$ [17, 10].) The I/O complexity of the corresponding all-pairs version of the problem is obtained by multiplying the I/O complexity of the single-source version by $V$. 1.4 Our Results In section 2 we present a simple cache-oblivious algorithm for computing AP-BFS on unweighted undirected graphs in $O(V \cdot \log^2 V)$ I/Os, matching the I/O complexity of its cache-aware counterpart [6]. We use this algorithm to compute the diameter of an unweighted undirected graph in the same I/O bound and $O(V + E)$ space. Our cache-oblivious algorithm is arguably simpler than the cache-aware algorithm in [6] and it has a better space bound for computing the diameter. In section 3 we present the first nontrivial external-memory algorithm to compute approximate APSP on unweighted undirected graphs with small additive error. The algorithm is cache-aware, it uses $O((\frac{1}{B^2}) V^2 - \frac{V}{E} E + \log^2 V) \log\log V + \frac{2}{B} V^2 - \frac{V}{E} E + \log\log V) I/Os$, and it produces estimated distances with an additive error of at most $2(k - 1)$, where $2 \leq k \leq \log V$ is an integer, and $E > V \log V$. The number of I/Os performed by our algorithm is close to being a factor of $B$ smaller than the running time of the best internal-memory algorithm known for this problem [9]. For the special case $k = 2$, we present an alternate algorithm that performs better for large values of $B$; this algorithm builds on the internal-memory algorithm in [2]. In section 4 we introduce the notion of a Slim Data Structure for external-memory computation. This notion captures the scenario where only a limited portion of the internal memory is available to store data from the data structure; it is assumed, however, that while executing an individual operation of the data structure, the entire internal memory of size $M$ is available for the computation. We describe and analyze the Slim Buffer Heap which is a slim data structure based on the Buffer Heap [8]. We use Slim Buffer Heaps in a Multi-Buffer Heap to solve the cache-aware exact APSP problem for undirected graphs with general non-negative edge-weights in $O(V \cdot \sqrt{\frac{VE}{B}} + \log V) I/Os$ and $O(V^2)$ space, whenever $E \leq \frac{VB}{\log^2 V}$. This improves on the result in [6] for weighted undirected APSP. We also believe that the notion of a Slim Data Structure is of independent interest and is likely to have other applications in external-memory computation. 2 Cache-Oblivious APSP and Diameter for Unweighted Undirected Graphs In this section we present a cache-oblivious algorithm for computing all-pairs shortest paths and diameter in an unweighted undirected graph. 2.1 The Cache-Oblivious BFS Algorithm of Munagala and Ranade Given a source node $s$, the algorithm of Munagala & Ranade [15] computes the BFS level of each node with respect to $s$. Let $L(i)$ denote the set of nodes in BFS level $i$. For $i < 0$, $L(i)$ is defined to be empty. Let $N(v)$ denote the set of vertices adjacent to vertex $v$, and for a set of vertices $S$, let $N(S)$ denote the multiset formed by concatenating $N(v)$ for all $v \in S$. Algorithm MR-BFS($G$) The algorithm starts by setting $L(0) = \{s\}$. Then starting from $i = 1$, for each $i < V$, the algorithm computes $L(i)$ assuming that $L(i - 1)$ and $L(i - 2)$ have already been computed. Each $L(i)$ is computed in the following three steps: Step 1: Construct $N(L(i - 1))$ by $|L(i - 1)|$ accesses to the adjacency lists, once for each $v \in L(i - 1)$. This step requires $O(|L(i - 1)| + \frac{1}{B} |N(L(i - 1))|)$ I/Os. Step 2: Remove duplicates from $N(L(i - 1))$ by sorting the nodes in $N(L(i - 1))$ by node indices, followed by a scan and a compaction phase. Let $L'(i)$ denote the resulting set by $L'(i)$. This step requires $O(\log |N(L(i - 1))|)$ I/Os. Step 3: Remove from $L'(i)$ the nodes occurring in $L(i - 1) \cup L(i - 2)$ by parallel scanning of $L'(i)$, $L(i - 1)$ and $L(i - 2)$. Since all these three sets are sorted by node indices the I/O complexity of this step is $O(\frac{1}{B} (|N(L(i - 1))| + |L(i - 1)| + |L(i - 2)|)).$ The resulting set is the required set $L(i)$. 3 Given an unweighted undirected graph. Since $\sum_{i} |L(i)| = \mathcal{O}(V)$ and $\sum_{i} |N(L(i))| = \mathcal{O}(E)$, total I/O complexity of this algorithm is $\mathcal{O}(\sum_{i}(|L(i)| + sort(|N(L(i))|)) + \frac{1}{\pi}(|N(L(i))| + L(i))) = \mathcal{O}(V + sort(E))$. 2.2 Cache-Oblivious APSP for Unweighted Undirected Graphs In this section we describe a cache-oblivious APSP algorithm for unweighted undirected graphs using $\mathcal{O}(V \cdot sort(E))$ I/Os. Let $G = (V[G], E[G])$ be an unweighted undirected graph. By $d(u, v)$ we denote the shortest distance between two vertices $u$ and $v$ in $G$. Our algorithm is based on the following observation which follows from triangle inequality and the fact that $d(u, v) = d(v, u)$ in an undirected graph: Observation 1. For any three vertices $u$, $v$ and $w$ in $G$, $d(u, w) - d(v, w) \leq d(v, w) \leq d(u, w) + d(u, v)$. Suppose for some $u \in V[G]$ we have already computed $d(u, w)$ for all $w \in V[G]$. We sort the adjacency lists in non-decreasing order by $d(u, \cdot)$, and by $A(j)$ we denote the portion of this sorted list containing adjacency lists of vertices $v$ with $d(u, v) = j$. Now if $v$ is another vertex in $V[G]$ then observation 1 implies that the adjacency list of any vertex $w$ with $d(v, w) = i$, must reside in some $A(j)$ where $i - d(u, v) \leq j \leq i + d(u, v)$. Therefore, we can use observation 1 to compute $d(v, w)$ for all $w \in V[G]$ as follows: Algorithm Incremental-BFS($G, u, v, d(u, \cdot)$) Function: Given an unweighted undirected graph $G$, two vertices $u, v \in V[G]$, and $d(u, w)$ for all $w \in V[G]$, this algorithm computes $d(v, w)$ for all $w \in V[G]$. It is assumed that $E[G]$ is given as a set of adjacency lists. Steps: Step 1: Sort the adjacency lists of $G$ so that adjacency list of a vertex $x$ is placed before that of another vertex $y$ provided $d(u, x) < d(u, y)$ or $d(u, x) = d(u, y)$ and $x < y$. Let $A(i)$, $0 \leq i < |V|$, denote the portion of this sorted list that contains adjacency lists of vertices lying exactly at distance $i$ from $u$. Step 2: To compute $d(v, w)$ for all $w \in V[G]$, run Munagala and Ranade’s BFS algorithm with source vertex $v$. But step (1) of that algorithm is modified so that instead of finding the adjacency lists of the vertices in $L(i-1)$ by $|L(i-1)|$ independent accesses, they are found by scanning $L(i-1)$ and $A(j)$ in parallel for $j \in \{0, i - 1 - d(u, v)\} \leq j \leq \min(|V| - 1, i - 1 + d(u, v))$. Step 1 of Incremental-BFS requires $\mathcal{O}(sort(E))$ I/Os. In step 2 each $A(j)$ is scanned $\mathcal{O}(d(u, v))$ times. Since $\sum_{j} |A(j)| = \mathcal{O}(E)$, this step requires $\mathcal{O}(\frac{E}{B}d(u, v) + sort(E))$ I/Os. Thus the I/O complexity of Incremental-BFS is $\mathcal{O}(\frac{E}{B}d(u, v) + sort(E))$. Since Incremental-BFS is actually an implementation of Munagala and Ranade’s algorithm, its correctness follows from the correctness of that algorithm, and from observation 1 which guarantees that the set of $A(j)$’s scanned to find the adjacency lists of the vertices in $L(i - 1)$ in step 2 of Incremental-BFS contains all adjacency lists sought. We can use Incremental-BFS to perform BFS I/O-efficiently from all vertices of $G$. The following observation each part of which follows in a straight-forward manner from the properties of spanning trees, Euler Tours and shortest paths, is central to this extension: Observation 2. If $ET$ is an Euler Tour of a spanning tree of an unweighted undirected graph $G$, then 1. the number of edges between any two vertices $x$ and $y$ on $ET$ is an upper bound on $d(x, y)$ in $G$, 2. $ET$ has $\mathcal{O}(V)$ edges, and 3. each vertex of $V[G]$ appears at least once in $ET$. The extended algorithm (AP-BFS) is as follows: **Algorithm AP-BFS(G)** **Steps:** Step 1: (a) Find a spanning tree $T$ of $G$. (b) Construct an Euler Tour $ET$ for $T$. (c) Mark the first occurrence of each vertex on $ET$, and let $v_1, v_2, \ldots, v_{|V|}$ be the marked vertices in the order they appear on $ET$. Step 2: Run Munagala and Ranade’s original BFS algorithm with $v_1$ as the source vertex, and compute $d(v_1, w)$ for all $w \in V[G]$. Step 3: For $i \leftarrow 2$ to $|V|$ do: Call Incremental-BFS $(G, v_{i-1}, v_{i}, d(v_{i-1}, \cdot))$ to compute $d(v_i, w)$ for all $w \in V[G]$. **Correctness.** Correctness of AP-BFS follows from the correctness of Munagala and Ranade’s BFS algorithm and that of Incremental-BFS. Moreover, observation 2(c) ensures that BFS will be performed for each $v \in V[G]$. **I/O Complexity.** Step 1(a) can be performed cache-obliviously in $O(\min\{V + \text{sort}(E), \text{sort}(E) \cdot \log_2 \log_2 V\})$ I/Os [4]. In step 1(b) $ET$ can also be constructed cache-obliviously using $O(\text{sort}(V))$ I/Os [4]. Step 1(c) requires $O(\text{sort}(E))$ I/Os. Step 2 requires $O(V + \text{sort}(E))$ I/Os. Iteration $i$ of step 3 requires $O(\frac{E}{B} \sum_{i=2}^{V} d(v_{i-1}, v_i) + \text{sort}(E))$ I/Os. Total number of I/O operations required by the entire algorithm is thus $O(\frac{E}{B} \sum_{i=2}^{V} d(v_{i-1}, v_i) + V \cdot \text{sort}(E))$. Since by observation 2(a) and 2(b) we have $\sum_{i=2}^{V} d(v_{i-1}, v_i) = O(V)$, the I/O complexity of AP-BFS reduces to $O(V \cdot \text{sort}(E))$. **Space Complexity.** Since the algorithm requires to output all $\Theta(V^2)$ pairwise distances its space requirement is $\Theta(V^2)$. ### 2.3 Cache-Oblivious Unweighted Diameter for Undirected Graphs The AP-BFS algorithm can be used to find the unweighted diameter of an undirected graph cache-obliviously in $O(V \cdot \text{sort}(E))$ I/Os. We no longer need to output all $\Theta(V^2)$ pairwise distances, and each iteration of step 3 of AP-BFS only requires the $\Theta(V)$ distances computed in the previous iteration or in step 2. Thus the space requirement is only $\Theta(V)$ in addition to the $O(E)$ space required to handle the adjacency lists. ### 3 Cache-Aware Approximate APSP for Unweighted Undirected Graphs In this section we present a family of cache-aware external-memory algorithms Approx-AP-BFS$_k$ for approximating all distances in an unweighted undirected graph with an additive error of at most $2(k - 1)$, where $2 \leq k \leq \log V$ is an integer. The error is one sided. If $\delta(u,v)$ denotes the shortest distance between any two vertices $u$ and $v$ in the graph, and $\hat{\delta}(u,v)$ denotes the estimated distance between $u$ and $v$ produced by the algorithm, then $\delta(u,v) \leq \hat{\delta}(u,v) \leq \delta(u,v) + 2(k - 1)$. Provided $E > V \log V$, Approx-AP-BFS$_k$ runs in $O(kV^{2 - \frac{1}{k}} E^{\frac{1}{2k}} \log^{1 - \frac{1}{k}} V)$ time, and triggers $O(\frac{1}{B^{\frac{1}{k}}} V^{2 - \frac{1}{2k}} E^{\frac{1}{2k}} \log^{\frac{2}{k}(1 - \frac{1}{k})} V + \frac{k}{B} V^{2 - \frac{1}{k}} E^{\frac{1}{k}} \log^{1 - \frac{1}{k}} V)$ I/Os. This family of algorithms is the external-memory version of the family of $O(kV^{2 - \frac{1}{k}} E^{\frac{1}{2k}} \log^{1 - \frac{1}{k}} V)$ time internal-memory approximate shortest paths algorithms (apaspk) introduced by Dor et al. [9] which is the most efficient algorithm available for solving the problem in internal memory. The second term in the I/O complexity of **Approx-AP-BFS** is exactly \((1/B)\) times the running time of the Dor et al. algorithm [9]. Though the first term in the I/O complexity of **Approx-AP-BFS** has a smaller denominator \((B^2)\), its numerator is smaller than the numerator of the second term when \(E > V \log V\), thus reducing the impact of the first term in the overall I/O complexity. ### 3.1 The Internal-Memory Approximate AP-BFS Algorithm by Dor et al. The internal-memory approximate APSP algorithm (**apasp** in [9]) receives an unweighted undirected graph \(G = (V[G], E[G])\) as input, and outputs an approximate distance \(\hat{d}(u, v)\) between every pair of vertices \(u, v \in V[G]\) with a positive additive error of at most \(2(k - 1)\). Recall that a set of vertices \(D\) is said to dominate a set \(U\) if every vertex in \(U\) has a neighbor in \(D\). A high level overview of the algorithm is given below: **Algorithm DHZ-Approx-AP-BFS\(_k\)(G)** 1. For \(i \leftarrow 1\) to \(k - 1\) do: (a) Set \(s_i \leftarrow E/\left(\frac{V \log V}{E}\right)^{1/k}\) 2. Decompose \(G\) to produce the following sets: (a) A sequence of vertex sets \(D_1, D_2, \ldots, D_k\) of increasing sizes with \(D_k = V[G]\). For \(1 \leq i \leq k - 1\), \(D_i\) dominates all vertices of degree at least \(s_i\) in \(G\). (b) A decreasing sequence of edge sets \(E_1 \supseteq E_2 \supseteq \ldots \supseteq E_k\), where \(E_1 = E[G]\) and for \(1 < i \leq k\) the set \(E_i\) contains edges that touch vertices of degree at most \(s_{i-1}\). (c) A set \(E^* \subseteq E[G]\) which bears witness that each \(D_i\) dominates the vertices of degree at least \(s_i\) in \(G\). 3. For \(i \leftarrow 1\) to \(k\) do: (a) For each \(u \in D_i\) do: (a1) Run SSSP from \(u\) on \(G_i(u) = (V[G], E_i \cup E^* \cup (\{u\} \times V[G]))\) In each \(G_i(u)\) the edges \(E_i \cup E^*\) are unweighted edges of the input graph, but the edges \(\{u\} \times V[G]\) are weighted, and to each such edge \((u, v)\) an weight is attached which is equal to the current known best upper bound on the shortest distance from \(u\) to \(v\). 4. Return the smallest distance computed between every pair of vertices in step 2. The algorithm maintains the invariant that after the \(i\)th iteration in step 2, the approximate distance computed by the algorithm from each \(u \in D_i\) to each \(v \in V[G]\) has an additive error of at most \(2(i - 1)\). Thus after the \(k\)th iteration a surplus \(2(k - 1)\) distance is computed between every pair of vertices in \(G\). ### 3.2 Our Algorithm Our algorithm adapts the Dor et al. algorithm (**DHZ-Approx-AP-BFS\(_k\)**) to obtain a cache-efficient implementation. In our adaptation we do not modify step 1 of **DHZ-Approx-AP-BFS\(_k\)**, and use the same sequence of values for \((s_1, s_2, \ldots, s_{k-1})\). In section 3.3 we describe an external-memory implementation of step 2 of **DHZ-Approx-AP-BFS\(_k\)**. It turns out that the I/O-complexity of **DHZ-Approx-AP-BFS\(_k\)** depends on the I/O-efficiency of the SSSP algorithm used in step 3(a1). Therefore, we replace each SSSP algorithm with a more I/O-efficient BFS algorithm by transforming each \(G_i(u)\) to an unweighted graph \(G'_i(u)\) of comparable size. But in order to preserve the shortest distances from \(u\) to other vertices in \(G'_i(u)\), the weighted edges of $G_i(u)$ need to be replaced with a set of directed unweighted edges. This makes the graph $G_i'(u)$ partially directed, and we need to modify existing external undirected BFS algorithms to handle the partial directedness in $G_i'(u)$ efficiently. This is described in section 3.4. There are two ways to apply the BFS: either we can run an independent BFS from each $u \in D_i$ as in step 3 of DHZ-Approx-AP-BFS, or we can run BFS incrementally from the vertices of $D_i$ as in section 2.2. It turns out that running independent BFS is more I/O-efficient when $|D_i|$ is smaller (i.e., value of $i$ is smaller), and incremental BFS is more I/O-efficient when $G_i'(u)$ is sparser (i.e., value of $i$ is larger). Therefore, we choose a value of $i$ at which switching from independent BFS to incremental BFS minimizes the I/O-complexity of the entire algorithm. The overall algorithm is described in section 3.5. 3.3 External-Memory Implementation of Step 2 A set of vertices $D$ is said to dominate a set $U$ if every vertex in $U$ has a neighbor in $D$. It has been shown by Aingworth et al. [2] that there is always a set of size $O(V \log V)$ that dominates all the vertices of degree at least $s$ in an undirected graph, and in [9] it has been shown that this set can be found deterministically in $O(V + E)$ time. In this section we present an external-memory implementation of the internal-memory greedy algorithm described in [9] for computing this set. The external-memory version, which we call Dominate, requires $O(V + \frac{V^2}{B} + \text{sort}(E))$ I/Os and $O(V^2 + E \log V)$ time, which is sufficient for our purposes. The internal-memory algorithm uses a priority queue that supports Delete-Max and Decrease-Key (for implementing steps 2(a) and 2(e) in Dominate). But due to the lack of any such I/O-efficient priority queue we use linear scans to simulate those two operations leading to the $\frac{V^2}{B}$ term, and thus the I/O-complexity of Dominate is worse than what one would typically expect from an external-memory implementation of an $O(V + E)$ time internal-memory algorithm. The Dominate function receives an undirected graph $G = (V[G], E[G])$ and a degree threshold $s$ as inputs, and outputs a pair $(D, E^*)$, where $D$ is a set of size $O(V \log V)$ dominating the set of vertices of degree at least $s$ in $G$, and $E^* \subseteq E[G]$ is a set of size $O(V)$ such that for every $u \in V[G]$ with degree at least $s$, there is an edge $(u, v) \in E^*$ with $v \in D$. Algorithm Dominate($G, s$) **Function:** Given an undirected graph $G = (V[G], E[G])$ and a degree threshold $s$, this algorithm outputs a pair $(D, E^*)$, where $D$ is a set of size $O(V \log V)$ that dominates the vertices of degree at least $s$ in $G$, and $E^* \subseteq E[G]$ is a set of size $O(V)$ such that for every $u \in V[G]$ with degree at least $s$, there is an edge $(u, v) \in E^*$ with $v \in D$. **Steps:** 1. **Step 1:** Perform the following initializations: - (a) Sort the adjacency lists of $G$ by their corresponding vertex indices, and the vertices in each adjacency list by their own indices. - (b) Scan the sorted adjacency lists to compute the degree of each vertex, and collect the vertices of degree at least $s$ in sorted order (according to vertex indices) into an initially empty list $L_1$. Each vertex in $L_1$ will be accompanied by its degree. - (c) Set $D \leftarrow \emptyset$, $E^* \leftarrow \emptyset$, and $L_2 \leftarrow \emptyset$. The list $L_2$ will be used to collect the dominated vertices in sorted order (by vertex indices). 2. **Step 2:** While $L_1 \neq \emptyset$ do: - (a) Scan $L_1$ to find and remove a vertex with the largest degree. Let this vertex be $u$ and $A_u$ be its adjacency list. - (b) Add $u$ to $D$ and $L_2$ maintaining the sorted order of $L_2$. - (c) Scan $A_u$ and $L_2$ in parallel and remove from $A_u$ any vertex appearing in $L_2$. - (d) Add the vertices in $A_u$ to $L_2$ by scanning both lists in parallel. - (e) Scan $L_1$ and $A_u$ in parallel and decrease the degree of each vertex in $L_1$ that appears in $A_u$. Remove the vertices with degree zero from $L_1$. - (f) For each $v \in A_u$ do: - Add $(v, u)$ to $E^*$. - Scan $L_1$ and $v$'s adjacency list $A_v$ in parallel, and decrease the degree of each vertex in $L_1$ that appears in $A_v$. - Remove the vertices with degree zero from $L_1$. 7 Correctness of Dominate. Since Dominate is a straightforward external-memory implementation of the internal-memory greedy algorithm for finding dominating sets described in [9], its correctness directly follows from the correctness of that algorithm. I/O Complexity of Dominate. Step 1(a) requires $O(sort(E))$ I/Os and 2(a) requires $O(\frac{E}{B})$ I/Os. Thus step 1 requires at most $O(sort(E))$ I/Os. In step 2, the adjacency list of each vertex in $G$ is loaded at most twice, and scanned $O(1)$ times. In each iteration of step 2, $L_1$ and $L_2$ are also scanned only a constant number of times. Thus step 2 requires $O(V + \frac{V^2}{B})$ I/Os. Therefore, I/O complexity of Dominate($G, s$) is $O(V + \frac{V^2}{B} + sort(E))$. We describe another function, called Decompose, which is an external-memory version of an internal-memory function with the same name described in [9], and uses the Dominate function as a subroutine. The function receives an undirected graph $G = (V[G], E[G])$, and a decreasing sequence $s_1 > s_2 > \ldots > s_{k-1}$ of degree thresholds as inputs. It produces a decreasing sequence of edge sets $E_1 \supseteq E_2 \supseteq \ldots \supseteq E_k$, where $E_1 = E[G]$ and for $1 < i \leq k$ the set $E_i$ contains edges that touch vertices of degree at most $s_{i-1}$. Clearly, $|E_i| \leq V s_{i-1}$ for $1 < i \leq k$. This function also produces a sequence of dominating sets $D_1, D_2, \ldots, D_k$, and an edge set $E^*$. For $1 \leq i < k$ the set $D_i$ dominates all vertices of degree greater than $s_i$, while $D_k$ is simply $V[G]$. The set $E^* \subseteq E$ is a set of edges such that if the degree of a vertex $u$ is greater than $s_i$ then there exists an edge $(u, v) \in E^*$ with $v \in D_i$. Clearly $|E^*| \leq kV$. Algorithm Decompose($G, \langle s_1, s_2, \ldots, s_{k-1} \rangle$) **Function:** Given an undirected graph $G = (V[G], E[G])$ and a decreasing sequence $s_1, s_2, \ldots, s_{k-1}$ of degree thresholds, this algorithm outputs a sequence of edge sets $E_1 \supseteq E_2 \supseteq \ldots \supseteq E_k$, where $E_1 = E[G]$ and for $1 < i \leq k$ the set $E_i$ contains edges that touch vertices of degree at most $s_{i-1}$. It also outputs dominating sets $D_1, D_2, \ldots, D_k$, and an edge set $E^*$. For $1 \leq i < k$ the set $D_i$ dominates all vertices of degree greater than $s_i$, while $D_k$ is simply $V[G]$. The set $E^* \subseteq E$ is such that if $deg(u) > s_i$ then there exists an edge $(u, v) \in E^*$ with $v \in D_i$, where $deg(u)$ denotes the degree of vertex $u$. **Steps:** 1. Perform the following initializations: - **(a)** Sort the adjacency lists of $G$ by their corresponding vertex indices, and the vertices in each adjacency list by their own indices. - **(b)** Scan the sorted adjacency lists to compute the degree of each vertex. 2. For $i = 2$ to $k$ do: - **(a)** Scan the adjacency lists to produce the set $E_i \leftarrow \{ (u, v) \in E[G] \mid deg(u) \leq s_{i-1} \lor deg(v) \leq s_{i-1} \}.$ - **(b)** For $i = 1$ to $k - 1$ do: - $(D_i, E_i^*) \leftarrow$ Dominate($G, s_i$) - **(c)** Set $E_1 \leftarrow E$, $D_k \leftarrow V$, and $E^* \leftarrow \bigcup_{i=1}^{k-1} E_i^*$ I/O Correctness of Decompose. The correctness of this function directly follows from the internal-memory Decompose function in [9]. I/O Complexity of Decompose. The I/O cost of step 1 is $O(sort(E))$. Step 2(a) requires $O(k \frac{E}{B})$ I/Os. Step 2(b) requires $O(k(V + \frac{V^2}{B}))$ I/Os in total since step 1(a) of Dominate can now be eliminated. Step 2(c) can be implemented in $O(\frac{KV}{B} + \frac{E}{B})$ I/Os. Thus the I/O complexity of Decompose is $O(k(V + \frac{V^2}{B}) + sort(E))$. 8
{"Source-Url": "http://www.cs.utexas.edu/ftp/techreports/tr04-38.pdf", "len_cl100k_base": 8923, "olmocr-version": "0.1.50", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 38463, "total-output-tokens": 9487, "length": "2e13", "weborganizer": {"__label__adult": 0.0005559921264648438, "__label__art_design": 0.00028324127197265625, "__label__crime_law": 0.0007076263427734375, "__label__education_jobs": 0.0007305145263671875, "__label__entertainment": 0.00014281272888183594, "__label__fashion_beauty": 0.0002753734588623047, "__label__finance_business": 0.00048732757568359375, "__label__food_dining": 0.0005426406860351562, "__label__games": 0.002223968505859375, "__label__hardware": 0.0031337738037109375, "__label__health": 0.0011110305786132812, "__label__history": 0.0005755424499511719, "__label__home_hobbies": 0.00015985965728759766, "__label__industrial": 0.0008149147033691406, "__label__literature": 0.000370025634765625, "__label__politics": 0.0004134178161621094, "__label__religion": 0.0006113052368164062, "__label__science_tech": 0.1688232421875, "__label__social_life": 9.447336196899414e-05, "__label__software": 0.01322174072265625, "__label__software_dev": 0.80224609375, "__label__sports_fitness": 0.0007367134094238281, "__label__transportation": 0.0015506744384765625, "__label__travel": 0.00042176246643066406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 30014, 0.04457]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 30014, 0.60142]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 30014, 0.83003]], "google_gemma-3-12b-it_contains_pii": [[0, 2856, false], [2856, 7173, null], [7173, 11168, null], [11168, 14933, null], [14933, 18440, null], [18440, 21842, null], [21842, 26292, null], [26292, 30014, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2856, true], [2856, 7173, null], [7173, 11168, null], [11168, 14933, null], [14933, 18440, null], [18440, 21842, null], [21842, 26292, null], [26292, 30014, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 30014, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 30014, null]], "pdf_page_numbers": [[0, 2856, 1], [2856, 7173, 2], [7173, 11168, 3], [11168, 14933, 4], [14933, 18440, 5], [18440, 21842, 6], [21842, 26292, 7], [26292, 30014, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 30014, 0.0]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
d4ae8cd71bd32eee083bfe1c3213b07629cb0e8e
[REMOVED]
{"len_cl100k_base": 11334, "olmocr-version": "0.1.53", "pdf-total-pages": 16, "total-fallback-pages": 0, "total-input-tokens": 64412, "total-output-tokens": 13613, "length": "2e13", "weborganizer": {"__label__adult": 0.0004906654357910156, "__label__art_design": 0.0003333091735839844, "__label__crime_law": 0.000400543212890625, "__label__education_jobs": 0.0005927085876464844, "__label__entertainment": 9.590387344360352e-05, "__label__fashion_beauty": 0.00021696090698242188, "__label__finance_business": 0.00020444393157958984, "__label__food_dining": 0.0005831718444824219, "__label__games": 0.0009694099426269532, "__label__hardware": 0.00127410888671875, "__label__health": 0.0007519721984863281, "__label__history": 0.00034117698669433594, "__label__home_hobbies": 0.00010257959365844728, "__label__industrial": 0.0005640983581542969, "__label__literature": 0.00048232078552246094, "__label__politics": 0.00037479400634765625, "__label__religion": 0.0007882118225097656, "__label__science_tech": 0.03570556640625, "__label__social_life": 9.47713851928711e-05, "__label__software": 0.00386810302734375, "__label__software_dev": 0.9501953125, "__label__sports_fitness": 0.0003943443298339844, "__label__transportation": 0.0008006095886230469, "__label__travel": 0.0002416372299194336}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 42755, 0.02127]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 42755, 0.53294]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 42755, 0.834]], "google_gemma-3-12b-it_contains_pii": [[0, 2248, false], [2248, 5678, null], [5678, 8975, null], [8975, 11200, null], [11200, 13388, null], [13388, 16337, null], [16337, 18834, null], [18834, 21204, null], [21204, 22265, null], [22265, 25342, null], [25342, 28422, null], [28422, 31756, null], [31756, 35030, null], [35030, 38133, null], [38133, 41395, null], [41395, 42755, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2248, true], [2248, 5678, null], [5678, 8975, null], [8975, 11200, null], [11200, 13388, null], [13388, 16337, null], [16337, 18834, null], [18834, 21204, null], [21204, 22265, null], [22265, 25342, null], [25342, 28422, null], [28422, 31756, null], [31756, 35030, null], [35030, 38133, null], [38133, 41395, null], [41395, 42755, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 42755, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 42755, null]], "pdf_page_numbers": [[0, 2248, 1], [2248, 5678, 2], [5678, 8975, 3], [8975, 11200, 4], [11200, 13388, 5], [13388, 16337, 6], [16337, 18834, 7], [18834, 21204, 8], [21204, 22265, 9], [22265, 25342, 10], [25342, 28422, 11], [28422, 31756, 12], [31756, 35030, 13], [35030, 38133, 14], [38133, 41395, 15], [41395, 42755, 16]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 42755, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
340cff17ca7e7ca8d467cffa552fc6e22893a7c1
MASD: Multi-Agent Systems Development Methodology T. Abdelaziz¹, M. Elammari², R. Unland³, C. Branki⁴ ¹,²IT Faculty, University of Garyounis, Benghazi, Libya ³ICB, University of Duisburg-Essen, Essen, Germany ⁴School of ICT, University of the West of Scotland, Scotland, UK 1 tawfig@informatik.uni-essen.d, 2 elammari@garyounis.edu, 3 unlandr@informatik.uni-essen.de 4 cherif.branki@uws.ac.uk Abstract. In recent years, multi-agent systems gained growing acceptance as a required technology to develop complex distributed systems. As result, there is an increased need for practical methodology for developing such systems. This paper presents a new Multi-Agent System Development (MASD) methodology developed over several years through analyzing and studying most of the existing agent oriented methodologies. This new methodology is constructed based on the strengths and weaknesses of existing methodologies. MASD aims to provide designers of agent-based systems with a set of methods and guidelines that allow them to control the construction process of complex systems, enabling software engineers to specify agent-based systems that would be implemented within an execution environment, for example the Jadex platform. MASD differs from existing methodologies in that it is a detailed and complete methodology for developing multi-agent systems. This paper describes the methodology's process and illustrates it using a running example—namely, a car rental system. **Keywords:** agent-oriented methodologies, agent-oriented software engineering, multi-agent systems, software agents. 1. Introduction There has been a wide and an increasing acceptance of multi-agent system to implement complex and distributed systems. In addition, with industry demanding increasingly sophisticated applications, agent-oriented technology is being supplemented. Building multi-agent applications for complex and distributed systems is not an easy task; indeed, the development of industrial-strength applications requires the availability of strong software engineering methodologies. These methodologies typically consist of a set of methods, models, and techniques that facilitate a systematic software development process. Many agent-oriented methodologies and modeling languages have been proposed such as: Gaia [48,52], MaSE [22], MESSAGE [16], Tropos [12], HLIM [25], Prometheus [36], and AUML [5] etc. These methodologies have been established to develop multi-agent systems and to support tools that allow developers to create complex agent applications. Several evaluation frameworks and comparisons of agent-oriented methodologies have been suggested such as [1,6,43,21,40,41,17]. Most of them agree that despite the fact that most of these methodologies are developed on strong foundations, they suffer from number of limitations: none of the existing agent-oriented methodologies has itself established as a standard nor have they been commonly accepted [34]. The lack of standard agent architectures and agent programming languages is actually the main problem in defining agent models and putting them into operation, or providing a useful “standard” code generation. Since there is no standard agent architecture, agent design needs to be customized for each agent architecture. Nevertheless, the analysis models are independent of the agent architectures; they describe what the agent-based system has to do, but not how this is done [30]. Moreover, there is no agreement on how existing methodologies identify and characterize some of the important agent aspects, such as the beliefs, goals, plans, roles that the agents play in the system, or interactions [21,23]. The existence of such an agreement would contribute to agent standardization. Until now, no agent-oriented standards have been established, and most previous research that has examined and compared agent-oriented methodologies suggested that none was completely suitable for industrial development of multi-agent systems [34,44]. Even though existing methodologies are based on a strong agent-oriented basis, they need to support essential software engineering issues such as accessibility and expressiveness, which has an adverse effect on industry acceptability and adoption of agent technology [42]. None of these methodologies is in fact complete (in the sense of covering all of the necessary activities involved in software development life cycle (SDLC)) . Furthermore, most of the existing agent-oriented methodologies suffer from a gap between the design models and the existing implementation languages [43]. One of the steps towards fulfilling this demand is to unify the work of different existing methodologies; work similar to development of the Unified Modeling Language in the area of object-oriented analysis and design. Furthermore, up to this moment, there is no well-established development process with which to construct agent-oriented applications. Therefore, the consequences expected by the agents’ paradigm cannot yet be fully achieved. The main contribution of this paper is to build a new methodology for the development of multi-agent systems, called MASD (Multi-agent Systems Development). This methodology is expected to be a solid and reliable guide in building and developing such systems, as it is based upon other research, including previously existing methodologies. It aims to develop a complete life-cycle methodology for designing and developing MASs. In addition, MASD attempts to solve some of the problems mentioned in the above paragraph. The MASD methodology was established based on three fundamental aspects considered to be the foundation for building a solid methodology: concepts, models, and process. Concepts are the necessary MAS properties considered in building the models of the new methodology in a correct manner. Models include modeling techniques, modeling languages, a diagramming notation, and tools that can be used to analyze and design the agent system. Process is a set of steps or phases describing in detail how the new methodology works. In addition, the MASD methodology bridges the gap between design models and existing implementation languages. It provides refined design models that can be directly implemented in an available programming language, or it can use a dedicated agent-oriented programming platform that provides constructs to implement the high-level design concepts such as Jadex [11], JADE [30], JACK [15], etc. In addition, MASD helps developers to map the developed complex design models into implementation constructs. Furthermore, the MASD methodology proposes an important concept called triggers and relies heavily on agent roles. The role concept is considered one of the most important aspects representing agent behavior; therefore, MASD assumes each agent can play one or more roles in the system. The trigger concept is also considered as an important aspect as it represents the agent reactivity. Furthermore, MASD considers the social agent aspects by utilizing well-known techniques, such as use-case maps, which enable developers to identify social aspects from the problem specification. Therefore, MASD assumes that agent society architecture is to be derived from the problem specification. Moreover, MASD methodology is developed based on essential software engineering issues such as precision, accessibility, expressiveness, domain applicability, modularity, refinement, model derivation, traceability, and clear definitions. Finally, the MASD methodology provides a plain and understandable development process throughout the methodology phases. It captures a holistic view of the system components, and commutative aspects, which should be recognized before designing the methodology models. This is achieved by using well-known techniques such as UCMs and UML-UCDs. 2. MASD Methodology MASD methodology is developed as a reliable systematic approach that proves a milestone for Software Development Life Cycle (SDLC). Fig. 1 illustrates the process of MASD methodology. The proposed methodology covers the most important characteristics of multi-agent systems and deals with the agent concept as a high-level abstraction capable of modeling a complex system. MASD includes well-known techniques for requirement gathering and customer communication and links them to domain analysis and design models such as UCMs [13], UML use-case diagrams [47], activity diagrams [46], FIPA-ACL [27], etc. Furthermore, it supports simplicity and ease of use as well as traceability. The MASD methodology is composed of four main phases: system requirements phase, analysis phase, design phase, and implementation phase. The next sections discuss further each of the four phases. A car rental system [26] is used to demonstrate the process of MASD methodology; the reservation scenario is described as an example. 3. System Requirements Phase The system requirements phase describes the details of system scenarios in a high-level through System Scenario model. The system scenario model utilizes well-known techniques such as use-cases diagrams (UCDs) [47] and use-case maps (UCMs) [13] to describe the whole system scenario. Such techniques assist in discovering the system components such as agents, objects, roles, resources, etc. and their high-level behavior. The system requirements phase produces a model called the system scenario model. 3.1 System Scenario Model This model is a starting point for generating more detailed visual descriptions. It describes the whole system scenario in terms of what a system does, but it does not specify how a system does it. The model captures the system's components and the responsibilities that have to be performed by each component within the system. Then, it illustrates how these components collaborate with each other and with the external environment. In addition, it captures the behavior of the system as it appears from the point of view of the external users. To construct this model, some specific, well-known techniques have been used such as Use-Case Diagrams (UCDs) and Use Case Maps (UCMs). These techniques are assembled together in order to understand and obtain a complete system requirement as far as possible. They are chosen to describe system requirements because these techniques are comparatively more appropriate than others for agent-based systems [2,3,4]. 3.2 Reservation Scenario Example The car rental reservation scenario is used as an example. Most rentals are done by advance reservation. The rental period and the car group are specified at the time of reservation. Reservation can be achieved online, by filling web application, by sending an e-mail, or by a phone call. 3.2.1 UCD of Reservation Scenario UCDs for reservation scenario of the EU-Rent a car Rental Company are constructed. Each use case in the reservation scenario will be described with a diagram as well as describing and clarifying its components. Initially, use case diagrams of the dialogues for the reservation scenario are created. In order to develop UCDs for reservation scenario, actors involved in the reservation scenario are captured and the use cases associated with those actors. For each use case the following attributes are identified: description of use case, actors, goal, preconditions and postconditions, triggering events, and extensions and alternatives to the use case. Actors can be a human or an automated system. A use case is made up of a set of scenarios. Each scenario is a sequence of steps that encompasses an interaction between a user and a system. Fig. 2 describes the UCDs for the reservation scenario. The figure shows two actors: the customer actor and the car rental clerk actor. Each actor represents a role that a user system plays within the system. The customer actor requests the car rental clerk actor to perform an action, such as reserve a car or cancel a reservation. The clerk actor performs actions such as replying to customer requests and so on. ![Use Case Diagrams for reservation scenario.](image) The semi colon symbol “;” in preconditions, postconditions and triggering events represents the “or” operator. The comma symbol “,” is used to represent the “and” operator. **Use case Request reservation** **Use case name:** Request reservation **Description:** The customer requests a reservation from the car rental clerk **Actors:** Customer **Goal:** To make request **Precondition:** Customer wants reservation **Postcondition:** Request rejected; Request accepted **Triggering event:** A customer requests a reservation **Extensions:** **Alternatives:** --- **Use case Request reservation cancellation** **Use case name:** Request reservation cancellation. **Description:** The customer requests canceling reservation from the car rental clerk **Actors:** Customer **Goal:** To make a request to cancel reservation **Precondition:** Customer has reservation and requested cancellation **Postcondition:** Request rejected; Request accepted **Triggering event:** A customer requests to cancel reservation **Extensions:** **Alternatives:** --- ### 3.2.2 UCMs of Reservation Scenario In this model, use case maps for reservation scenarios of the car rental system are described. This section describes how UCMs can be used to represent and describe the reservation scenario of the car rental system. UCMs are applied to capture the behavior of the system as high-level description and explain how UCMs describe the reservation scenario in visual views. The following scenarios represent interactions between some components in the system. By tracing application scenarios, the high-level view of the system is derived. These scenarios describe functional behavior as UCM paths within the system. This discovers system roles, responsibilities, and plug-ins along the way. To capture UCMs, the following steps are performed: - **Identify scenarios and major components involved in the system.** • Identify roles for each component. • Identify preconditions and postconditions for each scenario. • Identify responsibilities and constraints for each component in a scenario. • Identify sub scenarios and replace them with stubs. • Identify components collaborations for the major tasks. Fig. 3 demonstrates the important symbols in the UCM notations. The reservation scenario will be performed between two components of the system called: customer and car rental clerk. Fig. 4 shows the use case map for the reservation scenario. Fig. 4 Use Case Map for the Reservation Scenario The customer component represents the customer in the application environment, and the car rental clerk represents the employee of the car rental company. The preconditions for the reservation scenario are: - A customer wants to rent a car, or - A reservation exists and the customer wants to cancel the reservation. When the first precondition is satisfied the scenario starts with the request reservation stub, which hides the detailed information of the request reservation process. The request reservation can be achieved in several ways. For example, it can be done by a phone call, or by filling a web form, or by an Email. Therefore, the request reservation stub is represented as a dynamic stub. Fig. 5 illustrates the plug-ins for the request reservation dynamic stub. After all responsibilities for the request reservation process are performed, the path leads to the car rental clerk component. In this component there is a responsibility called request information, which requests the customer to provide personal information such as address, phone, personal ID, driving license etc. The path leads to the customer component where there is a responsibility called provide info, which provides a confirmation that the customer has filled in the application form for the rental transaction. After the previous responsibilities are performed, the path leads to the static stub **verify car rentals regulations** which hides the detailed information of the **verify car rentals regulations** process. Fig. 6 illustrates the plug-in for the **verify car rentals regulations**. In this plug-in the car rental clerk checks whether the customer meets the rental rules. The **verify car rentals regulations** stub has two outgoing ports. If the customer passed the car rentals regulations, port “b” will be followed, which means that the customer is allowed to reserve a car. Otherwise, port “c” is followed, which means that the customer reservation request is rejected. The path that comes from port “b” leads to the **check customer demands** stub, which hides the detailed information of the **check customer demands** process. This stub checks whether the customer demands are available or not. At the end of this phase, the general behavior of the system as a whole is described in a high-level view using UCMs scenarios. The interactions that take place between the customer and the car rental system are described and the system requirements are understood using UCDs and UCMs. UCMs and UCDs describe the system without referring to any details regarding the implementation of the system. They provide a clear idea about how the entire system works. 4. Analysis Phase The objective of the analysis phase is to transform the system requirements into a representation of the system that can be forwarded to the design phase. This phase starts with analyzing the system requirements phase; it utilizes the system scenario model that is constructed by UML use-cases and use-case maps. This system scenario model is considered as a base to produce the models of the analysis phase. The analysis phase is concerned with the description of the agent architecture as well as the MAS architecture. It is divided into two stages; the first stage describes agent architecture, while the second stage describes the MAS architecture. 4.1 Agent Architecture Stage The agent architecture stage describes the following models: - Roles model: discovers the roles that agents play or perform in the system, determines responsibilities for each role and specifies activities for each responsibility. - Agent model: identifies agents in the system and assigns roles to them. Refines the roles to fit agent capabilities. - Beliefs model: identifies agent beliefs. - Goals model: identifies agent’s goals. - Plans model: specifies plans for each goal. - Triggers model: identifies the triggers of which each agent should be aware. Triggers could be events or change in beliefs. The MASD methodology requires the development of all models of the agent architecture stage. They are always developed even if the proposed agent system is just as a single agent. 4.1.1 Roles Model The agent role represents an agent behavior that is recognized, providing a means of identifying and placing an agent in a system. Role modeling is appropriate for agent systems [32] because of the following reasons: - Roles and role models present a new abstraction that can unify a range of aspects of a system. Software agents, objects, processes, organizations, and people can play roles, and this is especially important in applications that include all these types of entities, such as information and process management. - Role models are prototypes that should be documented and shared. - Role model collectively integrates roles and may be significant for agent design. - Role model can be used to model adaptive behavior, context switching, mobility and other aspects of agent systems. Furthermore, the roles model presents the agent system as an organization by considering it as a set of roles working together. Each role has its own responsibilities, and these roles improve and systematize the agent functionality and emphasize social or interactive behavior. The agent can perform more than one role in the system, and more than one agent can perform a role. Roles are encapsulated units that can be transferred easily from one agent to another when the need exists. ### 4.1.1.1 Discovering Roles This step is responsible for identifying the main roles that are found in the system. In order to be able to capture those roles, UCMs and UML use cases scenarios are to be exploited. In the system scenario model, the UCM components that are involved in the system are identified. These components could be agents, objects, or actors. Roles are discovered by analyzing path segments that cross UCM components in the system scenario model. This process is performed by passing through all responsibilities and all stubs in all UCM scenarios for each component in the system separately. Roles are also discovered by tracing use cases in UCDs. It is possible then to define the responsibilities and tasks that identify the role or roles which are played by every component of the system (at this moment, only roles are considered and agents are identified later on). Fig. 7 shows some examples to illustrate how the roles are assigned to UCM components. Components are listed in one row and the roles are listed in a second row. Each role can be associated with one or more components. Each component can be associated with one or more roles. 4.1.1.1.1 Determining Responsibilities of the Roles Once roles have been identified then the next step is to determine the duties and responsibilities of each role separately. This process starts by tracing scenarios of use case diagrams that have been developed during the system requirements phase. Identifying each actor individually and determine all its use-cases, then transferring them directly to responsibilities in the role that it plays in the system. The scenario paths of the UCMs are then traversed and all the responsibilities and stubs are individually defined and transferred directly to responsibilities and functions that are carried out by the role. This process is an attempt to fully, clearly and accurately capture most of responsibilities and functions of each role. 4.1.1.1.2 Specifying Activities of Each Responsibility Once the responsibilities and functions of each role are identified, then the following step is to identify all the activities undertaken by each responsibility. This will in fact, represent the functions of the proposed role to be implemented in the system. The important attributes of the roles model are: role name, role description, responsibilities, permissions, perceptions, obligations and constraints. The role name states the name of the role. The role description is a textual explanation of the function of the role. Responsibilities are the activities that the role is responsible to perform. Obligations are requirements that should be available to enable the role to start its functionality and carry out its responsibilities and activities. Permissions are the authorities related to numbers and types of resources that will be exploited by agents in the system. **Constraints** are restrictions and boundaries that the role must not violate through executing its tasks. Table 1 shows the attributes of the role model. Obligations, permissions, and constraints can be derived from UCM scenarios. Developers systematically apply phrase heuristics to classify the statements as permissions, obligations, or constraints. Heuristics include modality (can, may, must), condition key words (if, unless, except) and English conjunctions (and, or, not). Developers must document their interpretation (e.g., “may” indicates a permission) and assign logical meanings to each conjunction. Due to logical disjunctions, each sentence may have multiple obligations, permissions, and constraints. Once all responsibilities and stubs (request reservation, cancel reservation request, etc.) that the component customer performs have been recognized, then it is quite possible to define and specify the role played by the customer component. Here, it is obvious that it plays a renter role. Table 1 illustrates the renter role that the customer component will play in the reservation scenario. In the same situation, the car rental clerk component plays the rentier role. For simplicity, only the renter role in the reservation scenario is described. <table> <thead> <tr> <th>Role name:</th> <th>Renter</th> </tr> </thead> <tbody> <tr> <td>Role description:</td> <td>Renter who pays rent to use a car that is owned by the car rental company.</td> </tr> <tr> <td>Responsibilities &amp; Activities:</td> <td>Res.1 Request reservation</td> </tr> <tr> <td>--------------------------------</td> <td>----------------------------</td> </tr> <tr> <td></td> <td>Act.1 Reserve car by phone</td> </tr> <tr> <td></td> <td>Act.2 Reserve car by E-mail</td> </tr> <tr> <td></td> <td>Act.3 Reserve car online</td> </tr> <tr> <td></td> <td>Res.2 Cancel reservation request</td> </tr> <tr> <td></td> <td>Act.1 Cancel reservation by phone</td> </tr> <tr> <td></td> <td>Act.2 Cancel reservation by Email</td> </tr> <tr> <td></td> <td>Act.3 Cancel reservation online</td> </tr> <tr> <td></td> <td>Res.3 Notify real customer.</td> </tr> <tr> <td></td> <td>Act.1 Notify customer of canceled reservations</td> </tr> <tr> <td></td> <td>Act.2 Notify customer of rejected reservations</td> </tr> <tr> <td></td> <td>Act.3 Notify customer of confirmed reservations</td> </tr> </tbody> </table> <table> <thead> <tr> <th>Obligations:</th> <th>The renter should pass rental regulations</th> </tr> </thead> <tbody> <tr> <td>Permissions:</td> <td>Null</td> </tr> <tr> <td>Constraints:</td> <td>The renter should not have more than one reservation at the same time</td> </tr> </tbody> </table> Table 1 **Renter role for customer component** ### 4.1.1.2 Agent Model The agent model describes the internal structure of agents within the system and how these agents employ its internal structure to perform its tasks. In the MASD methodology, the building process of the agent model is based on the BDI agent architectures [28]. The BDI architecture is based on agent goals, plans, and beliefs. Agents also have triggers which assist agents to determine the appropriate goal or plan to be selected. 4.1.1.2.1 Identifying Agents The agent identification step is performed to extract those agents that are assumed to exist within the system. The agents are identified using use case maps that have been developed during the system requirements phase. Agents are identified by analyzing UCM components. A component can be identified as an agent or several components can be combined to constitute one agent. Hence, several roles are combined into one agent. Fig. 8 shows how roles are assigned to agents. Each agent should be able to fully and logically carry out the roles assigned to it. The developer must select the most appropriate agent for the role. In the car rental system, the customer and car rental clerk components are assigned respectively to a customer agent and a car rental clerk agent. The car rental manager agent represents the branch manager of the car rental company. This agent can play two roles in the system. The first and main role is a director role. The second role is rentier role. It can play the role of rentier when it wants to serve customers as a rentier. ![Fig. 8 Assigning roles to agents](image) 4.1.1.2.2 Refining Roles The refining roles step is merely used to revise the roles that the agent plays within the system. The refinement process consists of two steps. The first step is to match the roles that are captured in the roles model with agents that play these roles according to the agent's capabilities. The role's responsibilities are classified based on who is responsible for performing them. The second step is to separate, or isolate those responsibilities that are to be carried out by real persons from those responsibilities that are to be carried out by agents on their behalf. The refining roles process keeps the responsibilities that are to be carried out by the agent within the roles model. The responsibilities that are to be carried out by real users are stated as preconditions. These preconditions are translated into beliefs. Agents use these beliefs to keep track of whether the real person performs those responsibilities or Agents should be able to sense the environment to check whether these beliefs are changed or not. In other words, an agent may wait for a signal (e.g. a message) that confirms that a task to be performed by the real user has been completed. This refinement process assists developers to build a clear design that is free from confusion and responsibility overlap. **4.1.1.2.3 Agent Beliefs Model** The agent beliefs are identified either by the preconditions or by postconditions of the agent’s plans and goals, or by the obligations, permissions, and constraints that were obtained in the roles model. Furthermore, the beliefs can be obtained by tracing the UCM scenarios. The stubs and responsibilities are considered as bases of beliefs that are used to trace whether these stubs and responsibilities are achieved by the agent or not. In addition, the beliefs store information about the internal state of agents. Agent beliefs are classified into two types: constant belief, these beliefs are set beliefs and not allowed to change, and variable beliefs, the values of these beliefs can change many times. Beliefs can be assigned initial values or their values are computed using some kind of expressions or deduced by inference rules. According to Parsons [37] it is reasonable to assume that the values of the beliefs are obtained in several ways: 1) Initial beliefs (basic facts which represent the agent's initial beliefs). 2) Beliefs deduced from previous beliefs by deductive inference rules. 3) Beliefs obtained as answers to questions put to the environment by the agent. 4) Beliefs perceived by a sensor (facts that the agent perceives in its environment). 5) Beliefs communicated by external agents (messages received from other agents). Also MASD classified the purposes of the beliefs as the following: Storage belief, when the belief is stored and the agent can use it during its lifecycle; maintain belief, when the agent must keep the belief at a certain value e.g. when the agent must keep the temperature constantly at 20 degrees; and achieve belief, the agent stores a required value of the belief and during its lifecycle tries more than one time to check the value of the belief and run plans if the value is not the required value. The agent may not be able to change an achieve belief to a required value but it must keep the value of a maintained belief true at all times. These classifications and its purposes assist the developers to identify the mechanism of how the beliefs are stored and exploited. Accordingly, the agents will be able to reason about the beliefs to select the appropriate actions. Table 2 shows the beliefs model for the customer agent. A notification must be made about the beliefs that are captured from obligations, permissions, and constraints. of the role. These beliefs are considered as initial beliefs. Therefore, they do not belong to any goals or plans. <table> <thead> <tr> <th>Belief</th> <th>Type</th> <th>Purpose</th> </tr> </thead> <tbody> <tr> <td>Agent-Id</td> <td>Constant</td> <td>Storage</td> </tr> <tr> <td>Customer wants to rent a car</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>Customer decides to reserve by phone</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>Customer decides to reserve by E-mail</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>Customer decides to reserve car online</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>Reservation confirmed</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>Reservation rejected</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>Customer wants to cancel a reservation</td> <td>Variable</td> <td>Storage</td> </tr> <tr> <td>The renter should not have more than one reservation at the same time</td> <td>Variable</td> <td>Maintain</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> Table 2 Beliefs Model for Customer Agent 4.1.1.2.4 Agent Goals Model The goal represents a specific target state that the agent is trying to achieve. MASD methodology assumes that the concept of goals in relation to agents has a very strong relation with the BDI architecture. The goals represent the desires and intentions that the agent possesses. The definition of the relationship that links goals with the desires and intentions is formulated as being a similarity or matching relationship. Intentions are considered and defined as being goals that possess previously prepared plans to be executed. Desires are defined as goals with no plans for future execution. In order to identify the goals of the agent, each responsibility of a given role is converted to a specific goal. Therefore, it can be stated that each responsibility within a specific role is considered a goal for the agent who plays the role. Moreover, each activity within a specific responsibility is the foundation for one plan of the goal. The agent goals model consists of several fields as shown in Table 3. The first field is the goal title or the goal name. The second field is the priority, which specifies the goal precedence from the execution point of view in cases where there is a need to execute the agent’s goals based upon a priority. The priorities are classified as follows: High, above normal, normal, below normal and low. The third field is preconditions. The preconditions are the conditions that must be satisfied in order to consider this goal. The fourth field is the postconditions. Postconditions are the conditions that are to be satisfied when the goal is fully achieved. They are considered as an indication showing that the goal has been fully accomplished. Finally, the fifth field is the plans through which goals can be achieved. Table 3 illustrates the goals model of the customer agent. <table> <thead> <tr> <th>Goal</th> <th>Priority</th> <th>Preconditions</th> <th>Postconditions</th> <th>Plans</th> </tr> </thead> <tbody> <tr> <td>Request reservation</td> <td>High</td> <td>• Customer wants to rent a car</td> <td>• Reservation confirmed.</td> <td>• Reserve car by phone</td> </tr> <tr> <td></td> <td></td> <td>• Reservation rejected.</td> <td></td> <td>• Reserve car by E-mail</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>• Reserve car online</td> </tr> <tr> <td>Cancel reservation request</td> <td>Normal</td> <td>• Customer wants to cancel reservation</td> <td>• Cancellation confirmed</td> <td>• Cancel reservation by phone</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>• Cancel reservation by Email</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>• Cancel reservation online</td> </tr> <tr> <td>Notify real customer</td> <td>High</td> <td>• Real customer must be notified</td> <td>• Real customer notified</td> <td>• Notify customer of canceled reservations</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>• Notify customer of rejected reservations</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>• Notify customer of confirmed reservations</td> </tr> </tbody> </table> Table 3 Goals Model for Customer Agent 4.1.1.2.5 Agent Plans Model After the goals of the agents are identified by the previous step, it is time to describe the plans that should be performed by an agent in order to achieve its goal. Since each agent has a goal or set of goals that it wants or wishes to achieve, a plan or a set of plans for each individual goal must exist. Such a plan needs to be adhered to and followed in order for it to be achieved or performed. Each of those plans consists of a set of tasks to be executed. 4.1.1.2.5.1 Specifying Plans for each Goal Plans are a deliberately prepared means through which agents achieve their goals. A plan is not just a sequence of basic actions, but it may also include sub-goals. Other plans are executed to achieve the sub-goals of a plan thereby forming a hierarchy of plans. The agent keeps track of the actions and sub-goals carried out by a plan to determine and handle plan failures. Plans are specified by matching and transforming the activities that belong to the responsibilities within the roles. Each plan consists of a set of tasks. These tasks implement the plan and they complete the required work. Completion and implementation of these tasks is considered a success of the plan. A given goal is considered to be accomplished if at least one plan related to it was implemented. Plans may be executed in a sequential manner, according to the priority of each plan, or in parallel manner. The plans model consists of six parts: a plan name, preconditions, postconditions, successful internal actions, failed internal actions and a plan body. Optional preconditions define the preconditions of the plan, i.e., what conditions must be true in order to execute the plan. Postconditions are conditions that would be true when the plan completes. Successful internal actions are the actions that are performed if the plan succeeds. Failed internal actions are the actions that are performed if the plan fails. Finally, the plan body defines a tree representing a kind of flow-graph of actions to perform. UML activity diagrams [46] are used to represent the plan body. Activity diagrams are used to model the workflow of the process of the internal operation of the agent system. Activity diagrams illustrate the dynamic nature of the agent system by modeling the flow of control from one activity to another. The plans for the request reservation goal are constructed. Activity diagrams are used to represent such plans. Table 4 illustrates reserve car online plan for the customer agent and the tasks that should be performed in this plan. Each activity of the activity diagram represents a task in the plan. <table> <thead> <tr> <th>Plan-name</th> <th>Reserve cars online</th> </tr> </thead> <tbody> <tr> <td>Preconditions</td> <td>Customer decides to reserve a car online</td> </tr> <tr> <td>Postconditions</td> <td>Reservation confirmed</td> </tr> <tr> <td>Successful internal actions</td> <td>Inform the real customer to pick up the car</td> </tr> <tr> <td>Failed internal actions</td> <td>Try with another car rental company</td> </tr> </tbody> </table> **Plan body** <table> <thead> <tr> <th>Activity</th> </tr> </thead> <tbody> <tr> <td>Get car Rental website</td> </tr> <tr> <td>Read car Rental rules</td> </tr> <tr> <td>Verify rules</td> </tr> <tr> <td>Fill in reservation application form</td> </tr> <tr> <td>Approve application</td> </tr> <tr> <td>Close car Rental website</td> </tr> </tbody> </table> Table 4 Reserve Car Online Plan for the Customer Agent ### 4.1.1.2.6 Agent Triggers Model This model identifies and captures triggers that occur during system runtime. The idea of the trigger concept is somewhat similar to the ECA rule (event, condition and action) [24]. Triggers are the events and the changes in the beliefs. All events and the change of beliefs that are expected to occur within the system are identified. This model helps developers to identify these events and select the appropriate reaction for such triggers. Triggers can be caused by information coming from the environment, which has an effect on the behavior of agents. According to that information, the agent performs certain actions as a reaction. Triggers are obtained by capturing and analyzing the beliefs of each agent that can change during runtime. Triggers are also obtained by capturing and identifying expected events that occur in the system during runtime. The selection of triggers that prompts a goal or a specific plan is then followed by transferring them into triggers that motivate the agent to perform some given reactions. The triggers model consists of four attributes: trigger name, trigger type, trigger activator and the actions. Each trigger is identified by a unique trigger name. The trigger type can be either an event or a change of belief. The trigger activator represents the entity that is responsible for causing such trigger. This entity can be an agent, an object, a human or a resource within the system. Actions are either goals to be achieved or plans to be executed. Therefore, actions are labeled accordingly. For each agent, a trigger model is developed which identifies the triggers that are of interest to it. Table 5 describes the triggers model for the customer agent. It shows a list of the triggers that might occur in the reservation scenario during system runtime. By looking at the beliefs model of the customer agent and the reservation scenario in UCMs that was built during the system requirements phase, it is found that the scenario begins with belief (precondition) such as “a customer wants to rent a car”. The belief can be true or false. When this belief changes from false to true, it motivates the agent to perform a certain action (to start to execute a specific plan or to start to achieve a specific goal such as “request reservation” goal) as a reaction. <table> <thead> <tr> <th>Trigger name</th> <th>Trigger type</th> <th>Trigger activator</th> <th>Actions</th> </tr> </thead> <tbody> <tr> <td>Customer wants to rent a car</td> <td>Change of belief</td> <td>Real customer</td> <td>• Request reservation (Goal).</td> </tr> <tr> <td>Customer decides to reserve by phone</td> <td>Change of belief</td> <td>Real customer</td> <td>• Reserve by phone (plan).</td> </tr> <tr> <td>Customer decides to reserve by E-mail</td> <td>Change of belief</td> <td>Real customer</td> <td>• Reserve by E-mail (plan).</td> </tr> <tr> <td>Customer decides to reserve online</td> <td>Change of belief</td> <td>Real customer</td> <td>• Reserve Online (plan).</td> </tr> <tr> <td>Reservation confirmed</td> <td>Event</td> <td>Car rental clerk agent</td> <td>• Notify real customer to pickup the car (plan).</td> </tr> </tbody> </table> ### Table 5 Customer Agent Triggers Model <table> <thead> <tr> <th>Reservation rejected</th> <th>Event</th> <th>Car rental clerk agent</th> <th>Notify real customer of a rejected reservation (plan).</th> </tr> </thead> <tbody> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> 4.2 MAS Architecture Stage The MAS architecture stage is concerned with constructing the multi-agent system. It starts with building the interaction model, which captures all interactions between agents in the system. This is followed by constructing agent relationships model, which captures the relationships between agents in the system. Finally, the agent services model is constructed. This model exhibits the services that each agent makes available to other agents in the system. It facilitates the access to services that are offered by each agent, and organizes the cooperation between agents in the system. 4.2.1 Agent Interaction Model The agent interaction model describes the process in which agents exchange information with each other and with their environment. This model is considered as an initial model to represent interactions between agents in a high-level view. In the design phase, an interaction protocol is used to represent interactions in more detail. The agent interaction model is represented by a notation called interaction diagrams. This notation is suggested by the MASD methodology to describe such interactions. The main function of interaction diagrams is to transform the use case maps scenarios that are developed in the system scenario model into communication messages between the agents. These communications should be comprehensible by the system’s agents. Therefore, a simple agent conversation language is developed based on the speech act theory by Tsohatzidis [45] to help agents understand each other. This speech act theory consists of a communicative act called performative which means purposeful actions performed during conversations between the communicators. For example, the request performative means that the sender requests the receiver to execute some action/actions. On the other hand, the receiver can recognize which type of response is expected from the contents of the conversation. Table 6 illustrates each performative and its description that are used in the agent conversation language. <table> <thead> <tr> <th>Request</th> <th>The sender requests the receiver to execute some actions.</th> </tr> </thead> <tbody> <tr> <td>Query</td> <td>The sender asks the receiver for information.</td> </tr> <tr> <td>Inform</td> <td>The sender gives the receiver.</td> </tr> <tr> <td>Provide</td> <td>The sender provides the receiver with information already requested by the receiver.</td> </tr> <tr> <td>Call for proposal (cfp)</td> <td>The sender calls for proposals.</td> </tr> <tr> <td>Propose</td> <td>The sender proposes to execute specific actions under some conditions.</td> </tr> <tr> <td>accept-proposal</td> <td>The sender accepts the proposal to execute some actions presented in advance.</td> </tr> <tr> <td>reject-proposal</td> <td>The sender rejects the proposal presented in advance.</td> </tr> <tr> <td>Agree</td> <td>The sender agrees to execute some actions.</td> </tr> <tr> <td>Reject</td> <td>The sender rejects to execute some actions.</td> </tr> <tr> <td>Failure</td> <td>The sender notifies that it tried to execute some actions but the execution has failed for some reason.</td> </tr> <tr> <td>not-understood</td> <td>The sender notifies the receiver that it cannot understand the message the sender received.</td> </tr> </tbody> </table> Table 6 **Performatives for Agent Conversation Language** Interaction diagrams are developed from the system scenario model by capturing the lines that connect agents (components) in the use case maps diagram and transfer them into conversations (communication acts) between the agents. Fig. 9 shows the notation of interaction diagrams. The black circle refers to the starting point of the interaction. The path indicates the flow of events in the interaction. The arrow indicates the direction of the flow. The title indicates the performative or the event being exchanged. The symbol “X” indicates the end of the interaction. The agent life bar indicates the life of the agent in the interaction. Fig. 9 **Notation of Interaction Diagrams** Fig. 10 illustrates the mapping from UCMS scenarios to interaction diagrams and shows how interaction diagrams are derived from UCMs scenarios. It describes the request of the customer agent to the car rental clerk agent, which then requests more detailed information about the customer. The customer agent replies to the car rental clerk agent who checks the rules of the car rental company and then replies either by acceptance or by rejection. Agent interaction diagrams give only a partial picture of the system behavior. In order to have a precisely defined system, it is necessary to progress from interaction diagrams to interaction protocols. Interaction protocols define precisely which interaction sequences are valid within the system. 4.2.2 Agent Relationship Model The agent relationships model describes relationships between the agents. It helps the agents to make the necessary decisions when cooperation between agents takes place. It also establishes an official framework of duties and responsibilities. The agent relationships model consists of a set of system components (agents, objects, resources, etc.) that are connected together to satisfy and pursue a common goal. The model assists in organizing the coordination between the system agents. This coordination is achieved through a set of commitments realized by formal agreements and contracts that guarantee rights for both parties. Each commitment is directed from one agent giving this commitment towards its contracting partner, who receives this commitment. In addition, this model helps to identify the proper communication protocols that will be chosen for the conversation between agents in the design phase. The concept of dependency relationships was inspired from Elammari et al. [25], and Yu [50,51]. Agents’ dependency relationships are represented as diagram, where each square represents an agent, and each link between two agents represents the relationship. The link between two agents indicates that one agent (dependant) depends on the other (dependee). The dependency relationship object is called the (dependum). Three types of agent dependency relationships are identified: goal, task, and resource dependency. These relationships can be established either by runtime negotiation or advanced commitment. The model distinguishes among the types of restrictions based on the type of the required relationship between dependant and dependee dependencies. Fig. 11 illustrates the symbols that are used for agent dependency relationships. An arrow represents dependency that is going from a dependee agent to a dependant agent. Fig. 11 Dependency Relationship Symbols **Task dependency** represents a relationship in which an agent requires a specific task to be performed. **Goal dependency** represents the relationship in which an agent is dependent on another agent to achieve a specific goal. **Resource dependency** represents the relationship in which an agent is dependent on a supplying agent to provide it with a specific resource. A resource can be physical or informational. These three types of dependencies can be either a **negotiated** or a **committed** relationship. **Negotiated** relationships represent a relationship where an inter-agent negotiation is required to fulfill the dependency. **Committed** relationships indicate that an agent is obligated to provide a service to fulfill the dependency. Fig. 12 shows dependencies between the customer agent and the car rental clerk agent. The customer agent depends on the car rental clerk agent to handle reservation requests. This dependency is classified as “goal dependency” because the customer agent depends on the reservation agent to achieve this goal, which is called “request reservation”. It also depends on the car rental clerk agent to achieve the canceling reservation goal when the customer wishes to cancel the reservation, or to provide it with reservation information. The car rental clerk agent depends on the customer agent to provide it with personal information. ![Dependency Diagram between Customer Agent and Reservation Agent](image) Fig. 12 **Dependency Diagram between Customer Agent and Reservation Agent** ### 4.2.3 Agent Services Model The agent services model provides a standard mean of interoperation between agents in the system. This model is intended to provide a common description of agent services. The model is also intended to define the location of the agent services within a multi-agent system. This guides the agent community to find those services easily. Agent services are captured by means of the messages exchanged between requester agents and provider agents. The main goal of the agent services model is to facilitate access to services that are offered by each agent. Moreover, it organizes the cooperation between agents through constructing formal agreements. An agreement maintains the agents’ rights by providing them the ability to obtain those services in time. This model is composed of the following five parts: service, agent, expiry date, time of availability, and cost. The service represents the service title. The agent represents the agent offering the service. The expiry date represents the end date of the service. The time of availability is the time that the service should be available to be exploited by other agents. The cost represents the service cost. The agent service model is derived from the use case diagrams that were developed in the system scenario model. Agent services can be derived directly from use case diagrams where each use case can be identified as service. In addition, agent services can be identified as a set of use cases that are compounded into one service. Table 7 illustrates the agents’ services model including the car rental clerk agent services. <table> <thead> <tr> <th>Service</th> <th>Agent</th> <th>Expiry Date</th> <th>Time of Availability</th> <th>Cost</th> </tr> </thead> <tbody> <tr> <td>Reply to customer inquiries</td> <td>Car rental clerk agent</td> <td>Open</td> <td>always</td> <td>Free</td> </tr> <tr> <td>Handle reservation request</td> <td>Car rental clerk agent</td> <td>Open</td> <td>8:00 am to 8:00 pm</td> <td>Free</td> </tr> <tr> <td>Handle rental</td> <td>Car rental clerk agent</td> <td>Open</td> <td>8:00 am to 8:00 pm</td> <td>Free</td> </tr> <tr> <td>Handle car service</td> <td>Car rental clerk agent</td> <td>Open</td> <td>8:00 am to 4:00 pm</td> <td>Free</td> </tr> </tbody> </table> Table 7 Agent Services Model Providing agent services allows agents to search for a certain service that it requires in order to complete its goals or tasks. This model may be updated at runtime by new agents with their services or by new services for agents that already exist. 5. Design Phase The design phase introduces the detailed representation of the models developed in the analysis phases and transforms them into design constructs. These design constructs are useful for actually implementing the new multi-agent system. The models that were developed in the analysis phase are revised according to the specifications of implementation environment. The main objective of the design phase is to capture the agent's structural design and system design specifications. The design phase has two steps: - Creating an agent container. - Defining inter-agent communications. ### 5.1 Agent Container Model The first step of the design phase is to construct the agent container, which can be seen as a type specification for a class of instantiated agents. An agent container represents agent behavior, which can be modularized and decomposed into role specifications that are used by an agent. The core part of the agent specification is to define beliefs, goals, plans and capabilities of the agent and place them in the appropriate agent part. The agent behavior is defined by a container that represents agent roles and its conversations. The agent container simply contains all the important aspects that are needed by the agent to start working. The agent container is composed of several components (beliefs, goals, and plans) where each is represented by a certain model. Each model and its programming aspects will be designed in order to fit with the programming environment. ### 5.1.1 Beliefs The first part of the agent container is the agent beliefs. The beliefs are considered as “agent beliefbase” which represents the agent knowledge about the environment or the world in which the agent works. The agent's beliefbase can be considered as simple data-storage, responsible for creating new beliefs, belief sets, or removing old ones. This beliefbase is shared among all agents’ plans. The beliefs are classified into two types: beliefs that allow the storage of exactly one fact and beliefs that allow the storage of a related set of facts. More details are added to the beliefs during the design stage. A new field called `class` is added to indicate the type and the possible values are: Integer, String or Boolean. The `initial value` for the field depends on the type of belief. The `category` field was also added which has “F” for the beliefs that store exactly one fact and has “S” for the belief that store set of facts. These additional fields assist the designers to specify the way in which these beliefs are implemented correctly. Table 8 provides a detailed description of all the additions of customer agent’s belief model from the analysis stage. <table> <thead> <tr> <th>Belief</th> <th>Type</th> <th>Purpose</th> <th>Class</th> <th>Initial value</th> <th>Category</th> </tr> </thead> <tbody> <tr> <td>Agent _Id</td> <td>Constant</td> <td>Storage</td> <td>String</td> <td>Customer</td> <td>F</td> </tr> <tr> <td>Customer wants to rent a car</td> <td>Variable</td> <td>Storage</td> <td>Boolean</td> <td>True</td> <td>F</td> </tr> <tr> <td>Customer decides to reserve by phone</td> <td>Variable</td> <td>Storage</td> <td>Boolean</td> <td>True</td> <td>F</td> </tr> <tr> <td>Customer decides to reserve by E-mail</td> <td>Variable</td> <td>Storage</td> <td>Boolean</td> <td>True</td> <td>F</td> </tr> <tr> <td>Customer decides to reserve car online</td> <td>Variable</td> <td>Storage</td> <td>Boolean</td> <td>True</td> <td>F</td> </tr> <tr> <td>Reservation confirmed</td> <td>Variable</td> <td>Storage</td> <td>Boolean</td> <td>True</td> <td>F</td> </tr> <tr> <td>Reservation rejected</td> <td>Variable</td> <td>Storage</td> <td>Boolean</td> <td>True</td> <td>F</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>...</td> <td>...</td> </tr> </tbody> </table> Table 8 Revised agent beliefs model 5.1.2 Goals The second component in the agent container is the agent goals. The goals that were developed during the analysis stage are classified into four types of goals: perform, achieve, query, and maintain goal types. **Perform goal** is a type of goal where some action is required to be performed. The results of the goal depend on specific actions. Naturally, when no actions could be performed, the goal has failed. **Achieve goal** is a goal where an agent wants to achieve a certain state (target state) of affairs. This target state is represented by a target condition. When an agent gets a new achieve goal (e.g. no waste at given location) that shall be pursued, the agent starts activities for achieving the target state. When the target state is reached then the goal has been achieved. Otherwise, for a yet unachieved goal, plans are selected for execution. Whenever during the plan execution phase, the target condition is reached, then all running plans of that goal can be aborted. **Query goal** is used to enquire information about a specified issue. Therefore, the goal is used to retrieve a result for a query and does not necessarily cause the agent to engage in actions. When the agent has sufficient knowledge to answer the query the result is obtained instantly and the goal succeeds. Otherwise, applicable plans will try to gather the needed information. **Maintain goal** is the goal that has to keep a specific desired state (its maintain condition) satisfied all the time. When the condition is not satisfied any longer, plans are invoked to re-establish the given state. The maintain goal stays idle until the maintained condition is violated. An example for a maintain goal is to keep the temperature of a nuclear reactor below some specified limit. When this limit is exceeded, the agent has to act and normalize the state. Based on this classification, a type field is added to the goal model as shown in the following goal model. Table 9 provides a detailed description of the added type field of the agent goals model that was obtained in the analysis phase. <table> <thead> <tr> <th>Goal</th> <th>Type</th> <th>Priority</th> <th>Preconditions</th> <th>Postconditions</th> <th>Plans</th> </tr> </thead> <tbody> <tr> <td>Request reservation</td> <td>Achieve goal</td> <td>High</td> <td>• Customer wants to rent a car</td> <td>• Reservation confirmed</td> <td>• Reserve car by phone</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td>• Reservation rejected</td> <td>• Reserve car by E-mail</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td>• Reserve car online</td> </tr> <tr> <td>Cancel reservation request</td> <td>Achieve goal</td> <td>Normal</td> <td>• Customer wants to cancel reservation</td> <td>• cancellation confirmed</td> <td>• Cancel reservation by phone</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td>• Cancel reservation by Email</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td>• Cancel reservation online</td> </tr> <tr> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> <td>...</td> </tr> </tbody> </table> Table 9 Revised agent goals model 5.1.3 Plans In this section, the plans that have been developed in the analysis phase are refined in order to meet the design specifications. The plans are classified into two types. The first type is called the service plan, a plan that has service nature. An instance of the plan is usually running and waits for service requests. It represents a simple way to react on service requests in a sequential manner without the need to synchronize different plan instances for the same plan. The second type is called the *passive plan*. This type can be found in all other procedural reasoning systems. Usually, the passive plan is only run when it has a task to achieve. For this kind of plan, triggering events and goals should be specified to let the agent know what kinds of events the plan can handle (as represented in the agent triggers model). When an agent receives an event, the candidate plan(s) should be selected and instantiated for execution. A field called *type* is added to the plan. It identifies the type of the plan and helps developers to decide the suitable mechanism for plan implementation. Table 10 shows the same table that was shown in the analysis phase plus an additional field called type. <table> <thead> <tr> <th>Plan-name</th> <th>Reserve cars online</th> </tr> </thead> <tbody> <tr> <td>Type</td> <td>Passive plan</td> </tr> <tr> <td>Preconditions</td> <td>Customer decides to reserve car online</td> </tr> <tr> <td>Postconditions</td> <td>Reservation confirmed</td> </tr> <tr> <td>Successful internal actions</td> <td>Inform the real customer to pickup the car</td> </tr> <tr> <td>Failed internal actions</td> <td>Try with another car rental company</td> </tr> <tr> <td>Plan body</td> <td></td> </tr> </tbody> </table> Table 10 Reserve car online plan with Plan Type Field 5.1.4 Capabilities In many situations, goals, beliefs and plans become a common part of a specific task. The agent may need to achieve more than one goal, use more than one belief, and plan. Capabilities are simply a group of goals, beliefs and plans grouped together in a package in order to be used when they are needed to do a certain task in the system. These capabilities are captured from the identified beliefs, goals and plans that are required by the agent capability to implement a specific task. The agent capability is derived from the roles model that has been developed in the analysis phase. The following structure shows how the reservation capability is structured. **Reservation capability:** **Begin** // Reservation capability, **Beliefs:** - Customer wants to rent a car, - Reservation confirmed, - Reservation rejected. - Customer wants to cancel reservation - Cancellation confirmed. **Goals:** **Begin** // goals Request reservation goal **Plans:** - Reserve by phone call. - Reserve by E-mail. - Reserve car online. Cancel reservation request goal. 5.2 Inter-Agent Communication Model This model describes in detail possible interactions between agents. To establish communication between agents, agreed on and accepted protocols have to be deployed. The most established standard is the FIPA Agent communication language [27]. This model is derived by transforming the interaction diagrams that were developed in the agent interaction model in the analysis phase into conversation messages according to FIPA protocol patterns. The flow of interaction diagrams is transferred into messages according to the FIPA ACL protocols. The interaction diagrams are classified according to FIPA ACL protocols that the agents should follow to realize successful conversations. Determining the proper protocol for each interaction diagram is considered as the bases in the process of selecting the proper message between agents. Fig. 13 illustrates how an interaction diagram is transferred into messages according to FIPA ACL protocols. In the following example, the customer agent requests the car rental clerk agent to reserve a car. (request :sender (agent-identifier :Customer_agent) :receiver (agent-identifier :Car_rental_clerk_agent) :content "Reserve group B car for rent" :reply-with reserve-car :language sl :ontology e-Rent :protocol fipa-request interaction) In the following message the car rental clerk agent answers the customer agent that it agrees to the request. ``` (agree :sender (agent-identifier :Car_rental_clerk_agent) :receiver (agent-identifier :Customer_agent) :content "((action (agent-identifier :Car_rental_clerk_agent) (agree))") :protocol fipa-agree :language fipa-sl) ``` 6. Implementation Phase The implementation phase is the point in the development process when the program code actually is written. During the implementation phase, the system is built according to specifications from previous phases, as the previous phases provided models ready to be transferred into an implementation. The produced models have a set of design specifications showing how the agent system and its components should be structured and organized. There are several agent frameworks and platforms proposed to develop multi-agent systems. MASD supports some of them (such as JADE [30], JACK [15], MADKIT [35], Jason [10], and Jadex [11]) as tools in the development process. The Jadex platform is recommended because it is Java based, has a FIPA compliant agent environment, and allows the development of goal-oriented agents following the BDI model. The customer agent is used as an example to show how agents are implemented in Jadex, and this section describes in brief how the customer agent is implemented. Starting up an agent begins with the creation of the agent, and the agent is created according to the agent container developed in the design phase. Each agent container represents an Agent Definition File (ADF) in Jadex. First, a new agent definition file (ADF) called `customer.agent.xml` is created. In this file, all important agent startup properties are defined in a way that complies with the Jadex schema specification. The first attribute of the agent is its type name, which must be the same as the file name (similar to Java class files). In this case, it is set to Customer. Additionally, one can specify a package attribute, which has a similar meaning as in Java programs and serves for grouping purposes only. All plans and other Java classes from the agent's package are automatically known and need not to be imported via an import tag. The following XML code describes in brief the customer ADF: ```xml <!-- CustomerAgent --> <agent xmlns="http://jadex.sourceforge.net/jadex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jadex.sourceforge.net/jadex http://jadex.sourceforge.net/jadex-0.96.xsd" name="Customer" package="jadex.tutorial"> <beliefs> <belief name="agent_Id" class="String"> <fact>"customer1"</fact> </belief> <belief name="customer_wants_to_rent_a_car" class="Boolean"> <fact>"true"</fact> </belief> <belief name="customer_decides_to Reserve_car_by_phone" class="Boolean"> <fact>"true"</fact> </belief> </beliefs> ... <goals> <achievegoal name="request_reservation"> <creationcondition> $beliefbase.Customer_wants_to_rent_a_car. </creationcondition> <unique/> <deliberation> <inhibits ref="cancel_reservation_request"/> </deliberation> <targetcondition> $beliefbase.reservation_confirmed || $beliefbase.reservation_rejected </targetcondition> </achievegoal> <achievegoal name="cancel_reservation_request"> <creationcondition> $beliefbase.customer_wants_to_cancel_reservation. </creationcondition> <unique/> </achievegoal> </goals> <plans> <plan name="reserve_car_by_phone"> <body> new reserve_car_by_phonePlan() </body> </plan> </plans> </agent> ``` In the implementation, a Directory Facilitator (DF) must be built. The DF is an extension of the agent services model, which was developed in the analysis phase. The DF model serves as the “Yellow Pages” for the system agents. The DF allows agents to publish the services they provide so that other agents can find the services and successively use them. Agents may register their services with the DF, or query the DF to find out which services are offered by which agents. An agent is responsible for providing service-related information, e.g. service type, service name, etc. Furthermore, an agent can also deregister or modify its service details. Any agent can interact with a DF to make its services public and to identify agents that provide particular services through the yellow pages. In addition, agents can ask (search) the DF for agents that provide desired services. The DF should provide the agents in the system with the following functions: register, deregister, modify, and search. 7. Future Work This section lists several topics that are not addressed in this paper. Each topic would clearly benefit from further investigation and, hopefully, would strengthen the MASD methodology. Topics for future investigation include: - How to utilize the methodology with special domains such as web-base applications, real time systems, etc. - How to perform testing for the resulting agent system software. • How to deal with issues related to agent project management, such as: metrics, estimation, schedule, risk, and quality. • How to deal with agent mobility. 8. Conclusion Agent-oriented approaches represent an emerging paradigm in software engineering; and there has been a strong demand to apply the agent paradigm in large and complex industrial applications and across different domains. Therefore, the availability of agent-oriented methodologies that support software engineers in developing agent based systems is very important. In recent years, there have been an increasing number of methodologies developed for agent-oriented software engineering. However, none of them are mature and complete enough to fully support the industrial needs for agent-based system development. For these reasons, it is useful to begin gathering together the work of various existing agent-oriented methodologies with the aim of developing a new, more comprehensive, methodology. Thus, this research paper focused on developing a design methodology to assist multi-agent system developers through the entire software development lifecycle, beginning from system requirement phase, and proceeding in a structured manner towards working code. There are few principle strengths of the methodology developed through this research work. It is based on three important aspects—concepts, models, and process—and it is focused toward the specific capabilities of multi-agent systems. At the commencement of research, MASD combined several techniques and concepts into a single, simple, traceable, and structured methodology. These concepts and techniques are represented through a set of models. Most of these models used within the methodology have therefore already been justified and validated within the domain of agents and multi-agent systems. MASD provides extensive guidance in the process of developing the design and for communicating the design within a work group. It is very clear that the existence of this methodology provides great assistance in thinking about and deciding on design issues, as well as conveying design decisions. The methodology has captured all the requirements of the system in a proper way by combining well-known techniques (UCMs and UCDs) into one extensive model called the system scenarios model. MASD methodology has proposed the trigger concept, which has allowed the representation of agent reactivity. MASD has also proven its ability to support organizational aspects by utilizing the role concept, which provides the work at different levels of abstraction. 9. References 20. K. H. Dam, and M. Winikoff, *Comparing Agent-Oriented Methodologies*, the International Bi - 2004. http://www.springer.com/978-3-540-40700-3 24. K. R. Dittrich, S. Gatziu and A. Geppert, *The Active Database Management System Manifesto A Rulebase of ADBMS Features*, Lecture Notes in Computer Science 985 ISBN 3-540-60365-4, 26. EU-Rent, EU-Corporation.: In http://www.businessrulesgroup.org/egsbrg.shtml 27. FIPA ACL.: In http://www.fipa.org/repository/aclspe.cs.html desire-intention model of agency*, In Möller, J. P., Singh M. P., and Rao, A. S., editors, ATAL, 29. IEEE Std 830-1998: In of the 5th International Workshop on Intelligent Agents V: Agent Theories, Architectures, 47. *UML Use case diagrams*: In http://atlas.kennesaw.edu/~dbraun/csis4650/A&D/UML_t- utorial/use_case.htm Authors' Bios Dr. Tawfig M. Abdelaziz (B.Sc, M.Sc and Ph.D) is a lecturer at the Software Engineering Department, Faculty of Information Technology, Garyounis University, in Benghazi, Libya. He is a qualified Software Engineer and has studied computer science in his first degree (B.Sc) (1989) at the University of Garyounis, and received a M.Sc. (1997) from Technical university of Brno, Brno, Czech Republic and Later Ph.D. (2008) in for Computer Science and Business Information Systems (ICB) from the University of Duisburg-Essen, Essen, Germany, specializing in Multi-agent systems. Currently, he leads the Software Engineering department at the Information Technology Faculty in Garyounis University. His general research interests include Software Engineering and Multi-agent systems. Dr. Elammari is currently Dean of the Faculty of Information Technology at the University of Garyounis, where he is also a professor in the Department of Software Engineering. He received a B.Sc. and M.Sc. degrees in computer science from Acadia University in Nova Scotia, Canada and a Ph.D. degree in computer science from the Carleton University in Ottawa, Canada. His research interests include Software Engineering, Agent Systems, and e-government. Rainer Unland is a full professor in computer science at the Institute for Computer Science and Business Information Systems (ICB) at University of Duisburg-Essen where he heads the chair Data Management Systems and Knowledge Representation. He has authored, co-authored and edited more than 120 publications, journals and (text)books in the areas of non-standard/object-oriented database management systems, XML and database systems, object-oriented software development, component-based and aspect-oriented software engineering, advanced transaction management, computer supported cooperative work, (distributed) artificial intelligence, especially Multi-Agent Systems, and industrials informatics. Moreover, he has served as Chair and/or PC member for more than 180 national and international conferences, workshops, and symposia. He is co-founder of the annual International German Conference on Multi-Agent Systems Technology (MATES) and the annual International conference SABRE that serves as an umbrella conference for topics related to software engineering, multi-agent system, Grid computing, and Web-Services and the Internet. Professor Branki has an enviable record of research and development in the provision of innovation and technological support and advice to numerous organisations including global/international concerns and also Scottish SMEs. Professor Branki has developed a track record in research and development as well as recent and current management of several international projects: COSMOS- Construction On Site Mobile Operation Support (a 4.5 Million Euros ESPRIT European Funded project), PATRICIA-Performance and Theory of Remote Intelligent Cooperative Agents on the Internet (DAAD: German-British Council supported project), MAST- Multi-Agents in Structural Design (A Polish-British Council Project). He has worked as senior investigator in several national and international projects such FOCUS (Front-end for Open and Closed User Systems), the first UK multimedia project: MUMS (Multi Media User Modeling Systems).
{"Source-Url": "https://www.researchgate.net/profile/M_Elammari/publication/220535328_MASD_Multi-agent_systems_development_methodology/links/0912f505bafb93862c000000.pdf", "len_cl100k_base": 16091, "olmocr-version": "0.1.49", "pdf-total-pages": 48, "total-fallback-pages": 0, "total-input-tokens": 89997, "total-output-tokens": 19409, "length": "2e13", "weborganizer": {"__label__adult": 0.0003633499145507813, "__label__art_design": 0.0006256103515625, "__label__crime_law": 0.0002834796905517578, "__label__education_jobs": 0.00373077392578125, "__label__entertainment": 8.0108642578125e-05, "__label__fashion_beauty": 0.0001729726791381836, "__label__finance_business": 0.0003275871276855469, "__label__food_dining": 0.0002696514129638672, "__label__games": 0.0007658004760742188, "__label__hardware": 0.0006465911865234375, "__label__health": 0.00028967857360839844, "__label__history": 0.0003597736358642578, "__label__home_hobbies": 9.804964065551758e-05, "__label__industrial": 0.00036525726318359375, "__label__literature": 0.00029397010803222656, "__label__politics": 0.0002722740173339844, "__label__religion": 0.0003879070281982422, "__label__science_tech": 0.011627197265625, "__label__social_life": 9.846687316894533e-05, "__label__software": 0.00630950927734375, "__label__software_dev": 0.9716796875, "__label__sports_fitness": 0.0002417564392089844, "__label__transportation": 0.0005693435668945312, "__label__travel": 0.0002233982086181641}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 85858, 0.02205]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 85858, 0.43924]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 85858, 0.91388]], "google_gemma-3-12b-it_contains_pii": [[0, 1422, false], [1422, 1770, null], [1770, 5218, null], [5218, 8039, null], [8039, 9074, null], [9074, 11420, null], [11420, 12599, null], [12599, 14191, null], [14191, 14730, null], [14730, 16083, null], [16083, 17446, null], [17446, 19355, null], [19355, 21416, null], [21416, 23132, null], [23132, 24612, null], [24612, 26392, null], [26392, 28489, null], [28489, 31293, null], [31293, 33449, null], [33449, 36030, null], [36030, 38569, null], [38569, 40218, null], [40218, 42779, null], [42779, 45225, null], [45225, 47216, null], [47216, 47879, null], [47879, 49929, null], [49929, 52257, null], [52257, 54500, null], [54500, 56769, null], [56769, 59283, null], [59283, 61958, null], [61958, 63208, null], [63208, 64293, null], [64293, 65272, null], [65272, 65623, null], [65623, 67664, null], [67664, 69322, null], [69322, 70744, null], [70744, 73334, null], [73334, 75084, null], [75084, 76795, null], [76795, 78557, null], [78557, 80346, null], [80346, 82143, null], [82143, 82557, null], [82557, 85356, null], [85356, 85858, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1422, true], [1422, 1770, null], [1770, 5218, null], [5218, 8039, null], [8039, 9074, null], [9074, 11420, null], [11420, 12599, null], [12599, 14191, null], [14191, 14730, null], [14730, 16083, null], [16083, 17446, null], [17446, 19355, null], [19355, 21416, null], [21416, 23132, null], [23132, 24612, null], [24612, 26392, null], [26392, 28489, null], [28489, 31293, null], [31293, 33449, null], [33449, 36030, null], [36030, 38569, null], [38569, 40218, null], [40218, 42779, null], [42779, 45225, null], [45225, 47216, null], [47216, 47879, null], [47879, 49929, null], [49929, 52257, null], [52257, 54500, null], [54500, 56769, null], [56769, 59283, null], [59283, 61958, null], [61958, 63208, null], [63208, 64293, null], [64293, 65272, null], [65272, 65623, null], [65623, 67664, null], [67664, 69322, null], [69322, 70744, null], [70744, 73334, null], [73334, 75084, null], [75084, 76795, null], [76795, 78557, null], [78557, 80346, null], [80346, 82143, null], [82143, 82557, null], [82557, 85356, null], [85356, 85858, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 85858, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 85858, null]], "pdf_page_numbers": [[0, 1422, 1], [1422, 1770, 2], [1770, 5218, 3], [5218, 8039, 4], [8039, 9074, 5], [9074, 11420, 6], [11420, 12599, 7], [12599, 14191, 8], [14191, 14730, 9], [14730, 16083, 10], [16083, 17446, 11], [17446, 19355, 12], [19355, 21416, 13], [21416, 23132, 14], [23132, 24612, 15], [24612, 26392, 16], [26392, 28489, 17], [28489, 31293, 18], [31293, 33449, 19], [33449, 36030, 20], [36030, 38569, 21], [38569, 40218, 22], [40218, 42779, 23], [42779, 45225, 24], [45225, 47216, 25], [47216, 47879, 26], [47879, 49929, 27], [49929, 52257, 28], [52257, 54500, 29], [54500, 56769, 30], [56769, 59283, 31], [59283, 61958, 32], [61958, 63208, 33], [63208, 64293, 34], [64293, 65272, 35], [65272, 65623, 36], [65623, 67664, 37], [67664, 69322, 38], [69322, 70744, 39], [70744, 73334, 40], [73334, 75084, 41], [75084, 76795, 42], [76795, 78557, 43], [78557, 80346, 44], [80346, 82143, 45], [82143, 82557, 46], [82557, 85356, 47], [85356, 85858, 48]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 85858, 0.23108]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
a8f707fefc2e0035a7f83b16befbc1387ad38bd4
SAT-Based Leximax Optimisation Algorithms Miguel Cabral INESC-ID, IST, University of Lisbon, Portugal Mikoláš Janota Czech Technical University in Prague, Czech Republic Vasco Manquinho INESC-ID, IST, University of Lisbon, Portugal Abstract In several real-world problems, it is often the case that the goal is to optimise several objective functions. However, usually there is not a single optimal objective vector. Instead, there are many optimal objective vectors known as Pareto-optima. Finding all Pareto-optima is computationally expensive and the number of Pareto-optima can be too large for a user to analyse. A compromise can be made by defining an optimisation criterion that integrates all objective functions. In this paper we propose several SAT-based algorithms to solve multi-objective optimisation problems using the leximax criterion. The leximax criterion is used to obtain a Pareto-optimal solution with a small trade-off between the objective functions, which is suitable in problems where there is an absence of priorities between the objective functions. Experimental results on the Multi-Objective Package Upgradeability Optimisation problem show that the SAT-based algorithms are able to outperform the Integer Linear Programming (ILP) approach when using non-commercial ILP solvers. Additionally, experimental results on selected instances from the MaxSAT evaluation adapted to the multi-objective domain show that our approach outperforms the ILP approach using commercial solvers. 2012 ACM Subject Classification Computing methodologies → Optimization algorithms Keywords and phrases Multi-Objective Optimisation, Leximax, Sorting Networks Digital Object Identifier 10.4230/LIPIcs.SAT.2022.29 Supplementary Material Software (Source Code): https://github.com/miguelcabral/leximaxIST Funding This work was partially supported by Portuguese national funds through FCT, under projects UIDB/50021/2020, PTDC/CCI-COM/31198/2017, PTDC/CCI-COM/32378/2017 and DSAIPA/Al/0044/2018. The results were supported by the Ministry of Education, Youth and Sports within the dedicated program ERC CZ under the project POSTMAN no. LL1902. This article is part of the RICAIP project that has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 857306. 1 Introduction In many real-world problems such as Virtual Machine Consolidation [46], trip planning [50], automated program repair [70] or Package Upgradeability [39], there are several objective functions to minimise. The challenge with having more than one objective function is that the objective functions may be conflicting. Decreasing one objective function may lead to an increase of another objective function. Despite this trade-off, it is possible to discard feasible solutions for which there exists another feasible solution that is able to decrease all objective functions at the same time. For example, suppose we have two objective functions $f_1$ and $f_2$ and two feasible solutions $\alpha$, $\alpha'$ with objective vectors $(f_1(\alpha), f_2(\alpha)) = (10, 10)$ and $(f_1(\alpha'), f_2(\alpha')) = (20, 20)$. In this case there is no trade-off and $\alpha$ is clearly preferred over $\alpha'$. This motivates the well-known notion of Pareto-optimality. A Pareto-optimal solution is such that there does not exist another feasible solution that decreases all objective functions at the same time. When solving a Multi-Objective Boolean Optimisation problem, one can try to enumerate or approximate the set of Pareto-optima (also known as Pareto frontier) and leave it to an expert to choose one of those solutions. The expert does not have to analyse all Pareto-optima, since there are criteria to select a representative subset of Pareto-optimal solutions [33]. A different approach is to transform the multi-objective problem into a single-objective one by using a linear combination of the objective functions. However, defining the weight for each objective function is often unclear for users. One can also compute a Pareto-optimal solution that is minimal according to a certain order. For example, in the lexicographic order [52], users define priorities to the objective functions. In this case, an optimal solution corresponds to minimising the highest priority objective function, then the second highest priority objective function, and so on. For instance, the vector (20, 50) is lexicographically smaller than the vector (40, 30), assuming an order of priorities from left to right. However, defining a lexicographic order corresponds to selecting one feasible solution from the extremes of the Pareto frontier. As a result, the lexicographic-optimum will likely be very unbalanced, i.e. some objective functions will have very small values and other objective functions will have very large values. Unlike the lexicographic order, the leximax relation tends to provide a small trade-off between the several objective functions. Moreover, the leximax relation does not require the user to predefine an order of priority between the objective functions. Hence, computing a leximax-optimal solution is suitable in problems where there is an absence of priorities between the objective functions. In practice, the leximax-optimum corresponds to minimising the maximum value among all objective functions, then the second maximum of the objective functions, and so on. Therefore, besides minimising the worst value among all objective functions, the solution found using the leximax criterion is usually balanced. Thus, leximax is a natural criterion for solving problems where an order among the objective functions is not defined, returning a balanced solution with good performance. Finally, observe that the lexicographic-optimum and the leximax-optimum are both a Pareto-optimum [28]. In this paper, we propose several SAT-based leximax optimisation algorithms. The main contributions of our work are: 1. new incremental SAT-UNSAT and UNSAT-SAT leximax optimisation algorithms, 2. the use of unsatisfiable cores to improve the performance of UNSAT-SAT leximax optimisation algorithms, 3. dynamical construction of the CNF representation of the objective functions, and 4. an extensive empirical evaluation of our algorithms on the Multi-Objective Package Upgradeability Optimisation problem [49] and on randomly generated multi-objective instances based on the MaxSAT Evaluation 2021 benchmarks [55]. This paper is organised as follows. In Section 2 we formally define the Multi-Objective Boolean Optimisation problem using the leximax criterion and highlight related work in Multi-Objective Boolean Optimisation and leximax optimisation. Section 3 describes the new SAT-based leximax optimisation algorithms. In Section 4 we evaluate our leximax optimisation algorithms against other state of the art leximax optimisation algorithms. Finally, Section 5 summarises the main contribution of our work. 2 Background This paper assumes the standard definitions and notation of propositional logic, including the notions of Boolean variable, literal, clause, conjunctive normal form (CNF) and the Boolean satisfiability (SAT) problem [16]. Given a set of \( m \) literals \( l_1, \ldots, l_m \) and respective coefficients \( \omega_1, \ldots, \omega_m \in \mathbb{N} \), a Pseudo-Boolean (PB) expression is a weighted sum of literals \( \sum_{i=1}^{m} \omega_i \cdot l_i \). Given an integer \( k \in \mathbb{N} \), a linear PB constraint has the form \( \sum_{i=1}^{m} \omega_i \cdot l_i \nRightarrow k \), \( \nRightarrow \in \{ \leq, \geq, = \} \). Objective vector where \( \mathbf{a} \) tuples there exists all PB constraints in a Multi-Objective Boolean Optimisation instance. Given an assignment \( \mathbf{a} \) write weights. \( \mathbf{a} \) MOBO is defined by a vector \( \mathbf{f} = (f_1, \ldots, f_n) \) of \( n \) PB expressions and a set of PB constraints defined over a set \( X \) of Boolean variables. We assume, without loss of generality, that each objective function is a weighted sum of Boolean variables, with positive weights. **Definition 2** (Objective vector). Let \( \alpha : X \rightarrow \{0, 1\} \) be a complete assignment that satisfies all PB constraints in a Multi-Objective Boolean Optimisation instance. Given an assignment \( \alpha \) and objective functions \( f = (f_1, \ldots, f_n) \), the vector \( \mathbf{f}(\alpha) = (f_1(\alpha), \ldots, f_n(\alpha)) \) is called the objective vector where \( f_i(\alpha) \) is the value of function \( f_i \) considering the assignment \( \alpha \). **Definition 3** (Pareto-optimal). Let \( \mathbf{a} = (a_1, \ldots, a_n) \in \mathbb{N}^n \) and \( \mathbf{b} = (b_1, \ldots, b_n) \in \mathbb{N}^n \). We write \( \mathbf{a} \prec_{\text{Par}} \mathbf{b} \), if for all \( i \in \{1, \ldots, k\} \), \( a_i \leq b_i \) and there exists \( j \in \{1, \ldots, k\} \) such that \( a_j < b_j \). A feasible solution \( \alpha \) is Pareto-optimal if there does not exist another feasible solution \( \alpha' \) such that \( \mathbf{f}(\alpha') \prec_{\text{Par}} \mathbf{f}(\alpha) \). **Example 4.** Consider two objective vectors \((20, 20, 20)\) and \((40, 40, 40)\). In this case we have that \((20, 20, 20) \prec_{\text{Par}} (40, 40, 40)\). **Example 5.** Consider two objective vectors \((20, 20, 20)\) and \((10, 40, 40)\). In this case, we have that \((20, 20, 20) \not\prec_{\text{Par}} (10, 40, 40)\) and \((10, 40, 40) \not\prec_{\text{Par}} (20, 20, 20)\). That is, the two vectors are not comparable using the relation \( \prec_{\text{Par}} \). **Definition 6** (Lexicographically optimal). Let \( \mathbf{a} = (a_1, \ldots, a_n) \in \mathbb{N}^n \) and \( \mathbf{b} = (b_1, \ldots, b_n) \in \mathbb{N}^n \). We define the lexicographic relation, \( \prec_{\text{lexico}} \), as follows. We write \( \mathbf{a} \prec_{\text{lexico}} \mathbf{b} \) whenever there exists \( i \in \{1, \ldots, n\} \) such that \( a_i < b_i \) and, for all \( j \in \{1, \ldots, i-1\}, a_j = b_j \). A feasible solution \( \alpha \) is lexicographically optimal if there does not exist a feasible solution \( \alpha' \) such that \( \mathbf{f}(\alpha') \prec_{\text{lexico}} \mathbf{f}(\alpha) \). **Example 7.** We have that \((10, 40, 40) \prec_{\text{lexico}} (20, 20, 20)\), since \( 10 < 20 \). Observe that the lexicographic relation is a strict total order. Thus, there exists exactly one lexicographically optimal objective vector. **Proposition 8.** Every lexicographically optimal solution is Pareto-optimal [28]. **Definition 9** (Leximax-optimal). Let \( \mathbf{a} = (a_1, \ldots, a_n) \in \mathbb{N}^n \) and \( \mathbf{b} = (b_1, \ldots, b_n) \in \mathbb{N}^n \). The leximax relation \( \prec_{\text{leximax}} \) is defined as follows. Let \( \mathbf{a}^i \) denote the \( n \)-tuple with the elements of \( \mathbf{a} \) sorted in decreasing order. We call the \( i \)-th component of \( \mathbf{a}^i \) the \( i \)-th maximum of \( \mathbf{a} \). The tuples \( \mathbf{a} \) and \( \mathbf{b} \) are leximax-indistinguishable if \( \mathbf{a}^i = \mathbf{b}^i \). We write \( \mathbf{a} \prec_{\text{leximax}} \mathbf{b} \), if \( \mathbf{a}^i \prec_{\text{lexico}} \mathbf{b}^i \). A feasible solution \( \alpha \) is leximax-optimal if there does not exist a feasible solution \( \alpha' \) such that \( \mathbf{f}(\alpha') \prec_{\text{leximax}} \mathbf{f}(\alpha) \). **Example 10.** We have that \((20, 20, 20) \prec_{\text{leximax}} (10, 40, 40)\), since the following holds for their sorted versions: \((20, 20, 20) \prec_{\text{lexico}} (40, 40, 10)\). The leximax relation is not trichotomous, since any permutation of the components of a vector is indistinguishable (e.g. \((10, 20)^* = (20, 10)^*\)). However, since the lexicographic relation is a strict total order, there is exactly one leximax-optimal sorted objective vector. Any permutation of the values of a leximax-optimal objective vector is also leximax-optimal. So there are at most \( n! \) leximax-optimal objective vectors, where \( n \) is the number of objectives. **Proposition 11.** Every leximax-optimal solution is Pareto-optimal [28]. Algorithm 1 ILP-based leximax optimisation algorithm. \textbf{Input:} Integer Linear Programming constraints $C$ and objective functions $f_1, \ldots, f_n$. \textbf{Output:} A leximax-optimal solution of the problem, $\alpha$. \begin{algorithmic} \For{$i \leftarrow 1$ \textbf{to} $n$} \State $C \leftarrow C \cup \{0 \leq r^i_j \leq 1 : j = 1, \ldots, n\}$ \State $C \leftarrow C \cup \{f_j \leq v_i + r^i_j M : j = 1, \ldots, n\}$ \State $C \leftarrow C \cup \\{\sum_{j=1}^{n} r^i_j \leq i - 1\}$ \State $\alpha \leftarrow \min(v_i, C)$ \State $C \leftarrow C \cup \{v_i = \alpha(v_i)\}$ \EndFor \State \textbf{return} $\alpha$ \end{algorithmic} Related Work in Multi-Objective Boolean Optimisation There are several frameworks based on stochastic search in order to approximate MOBO [24, 71]. These stochastic solvers can sometimes be complemented with the selective integration of constraint solvers [36, 69]. In recent years, several SAT-based algorithms have been proposed that enumerate all Pareto-optimal solutions. For instance, Neves et al. [68] showed that one can find all Pareto-optimal solutions by enumerating all Minimal Correction Subsets of a Boolean formula. Moreover, Soh et al. [67] show that there is a one to one correspondence between $p$-minimal models and Pareto-optimal solutions. More recently, a hitting set based approach has also been proposed [40] for Multi-Objective optimisation with two objective functions where one function is a black box. There are several algorithms and applications using lexicographic optimisation [52]. In Answer Set Programming, the tool \texttt{asprin} [19, 7] uses a general algorithm that computes optimal solutions according to several criteria, including Pareto-optimal, lexicographically optimal and minmax-optimal solutions. In the context of leximax optimisation of discrete problems, we highlight the work of Bouveret and Lemaître [18]. One of the algorithms has been adapted to Integer Linear Programming (ILP) and is implemented in the Package Upgradeability solver \texttt{mccs} [56, 35, 57]. The pseudo-code is shown in Algorithm 1. Given the problem constraints $C$ and the $n$ objective functions, the algorithm iteratively solves single-objective ILP instances. It iterates over the number of objective functions $n$, and in each iteration, $i$, it finds the value of the $i$-th maximum of the objective vector, using the integer variable $v_i$. To find the $i$-th maximum it defines $n$ new Boolean variables $r^i_1, \ldots, r^i_n$ (line 2) in order to relax the constraints on the maximum value of each objective function (line 3). The idea is that for all objective functions $f_j$, $j = 1, \ldots, n$, we have that $f_j \leq v_i$ is enforced if and only if $r^i_j$ is false. Observe that the constant $M$ must be large enough so that $f_j \leq v_i + M$ is trivially satisfied (e.g., $M$ can be an upper bound of $f_1, \ldots, f_n$). Note also that in the first iteration all objective functions must be bounded by the first maximum. In the second iteration, only $n - 1$ objective functions are bounded by the second maximum. In general, in the $i$-th iteration, $n - i + 1$ objective functions are bounded by the $i$-th maximum. This is achieved with the constraint in line 4 that limits the number of relaxation variables that can be assigned to true. The minimisation of $v_i$ subject to $C$ is done through an ILP solver call in line 5. At the end of iteration $i$, a constraint is added that fixes the value of the $i$-th maximum to the optimum found by the ILP call (line 6). 3 Algorithms for Leximax Optimisation In the following sections, we present the new SAT-based leximax optimisation algorithms. The algorithms are constructed by adapting the ILP Algorithm 1 to the Boolean domain, by using several techniques available in the MaxSAT solving literature. In Section 3.1, we show how the ILP-based algorithm can be adapted to the Pseudo-Boolean domain by replacing each ILP solver call by an iterative search on the value of the objective function, using linear search SAT-UNSAT, UNSAT-SAT and binary search [45, 44, 3, 29]. In Section 3.2, we describe the SAT-based algorithms that result from the encoding of the Pseudo-Boolean constraints to CNF [27, 42, 37, 11, 1]. We focus on the translation through sorting networks [27]. Finally, in Sections 3.3 and 3.4, we present the algorithms based on an UNSAT-SAT search using unsatisfiable cores, also a technique already studied in the context of MaxSAT [51, 4, 23]. We refer to the literature on MaxSAT solving for more details on these algorithms [58, 8]. 3.1 Iterative Pseudo-Boolean Algorithm The ILP-based approach for leximax optimisation presented in Algorithm 1 can be adapted to only use Boolean variables. In particular, one can replace each ILP solver call with an iterative PB solving procedure that refines lower bounds and/or upper bounds on the $i$-th maximum, $i = 1, \ldots, n$. In this case, the constraints $f_j \leq v_i + r^j_i M$ (line 3) are changed to $f_j \leq k + r^j_i M$, $j = 1, \ldots, n$, where $k \in \mathbb{N}$. Then, instead of calling an ILP solver and minimising $v_i$, we repeatedly solve a PB satisfiability instance until the minimum value of $k$ is found. For instance, one can use a linear search SAT-UNSAT procedure where, in each iteration $i$, a sequence of satisfiable PB instances are solved. Whenever a new feasible solution is found, a tighter upper bound $UB$ on the value of the $i$-th maximum is determined. In the next PB instance, this value is decreased, by setting $k$ to $UB - 1$, and adding the PB constraints $f_j \leq k + r^j_i M$, $j = 1, \ldots, n$. When the optimal value of the $i$-th maximum is found, we fix it by adding $f_j \leq k + r^j_i M$, $j = 1, \ldots, n$ to the set of hard constraints, where $k$ equals the optimal value of the $i$-th maximum. Note that this linear search SAT-UNSAT can also be replaced with a linear search UNSAT-SAT or a binary search procedure. With linear search UNSAT-SAT, we start with $k = 0$ and increase its value until the PB instance becomes satisfiable. Example 12. Consider a MOBO instance with the following hard constraints $H$ $$H = x_1 + x_2 \geq 1 \land x_4 + x_5 \geq 1 \land x_3 + x_6 \geq 1.$$ Suppose we have the following two objective functions to minimise: $$f_1 = x_1 + x_2 + x_3; \quad f_2 = x_4 + x_5 + x_6.$$ In this example, we show the execution of the PB-based linear search SAT-UNSAT algorithm on this instance using the leximax criterion. We begin by minimising $\max(f_1, f_2)$. First, we call the PB solver on the hard constraints $H$. Any feasible solution $\alpha$ provides us with an upper bound on the value of $\max(f_1, f_2)$. In this case, our upper bound is $UB = \max(f_1(\alpha), f_2(\alpha))$. Next, we check if there exists another feasible solution such that $\max(f_1, f_2) < UB$. Suppose we have a satisfiable assignment $\alpha$ where all variables are assigned value 1 and the objective vector of $\alpha$ is $(3, 3)$. Hence, $UB = 3$. We solve the PB instance with the following constraints: $$H \land x_1 + x_2 + x_3 \leq 2 \land x_4 + x_5 + x_6 \leq 2.$$ The instance is satisfiable and suppose we have a new solution $\alpha'$ where $x_2$ and $x_4$ are assigned to 0, while the other variables are assigned value 1. In this case, the objective vector is $(2,2)$. Then, we update the upper bound of $\max(f_1,f_2)$ to $UB = 2$. Once more, we check if there is a feasible solution such that $\max(f_1,f_2) < UB$, by solving the PB instance with constraints: $$H \land x_1 + x_2 + x_3 \leq 1 \land x_4 + x_5 + x_6 \leq 1.$$ The formula is unsatisfiable. We conclude that the current value of the upper bound, 2, is the minimum value of $\max(f_1,f_2)$. Next, we run the second iteration, where we minimise the second maximum. First, we fix the value of $\max(f_1,f_2)$ to the optimum, 2, by adding to $H$ the PB constraints: $$x_1 + x_2 + x_3 \leq 2 \land x_4 + x_5 + x_6 \leq 2.$$ From the previous objective vector $(2,2)$ we obtain an upper bound on the second maximum of $(f_1,f_2)$ of $UB = 2$. We define two new Boolean variables, $r_1$ and $r_2$, such that, the PB constraint $f_j \leq UB - 1$ is enforced if and only if $r_j$ is false, $j = 1,2$. Hence, a new call is made with additional PB constraints: $$H \land x_1 + x_2 + x_3 \leq 1 + Mr_1 \land x_4 + x_5 + x_6 \leq 1 + Mr_2 \land r_1 + r_2 \leq 1, \quad (1)$$ where $M$ is a large constant. The value of $M$ must be large enough so that when $r_j$ is true the constraints $f_j \leq UB - 1 + Mr_j$ do not restrict more than the remaining constraints, $j = 1,2$. For example, $M$ can be 2, since $f_j \leq 2$, for $j = 1,2$, because we have fixed the value of the first maximum. The formula (1) is satisfiable. Let $\alpha''$ be a satisfiable assignment to (1) with variables $x_1,x_3,x_4,r_1$ assigned value 1 and the remaining variables assigned value 0. In this case we have the objective vector $(2,1)$ and the new upper bound for the second maximum is 1. Finally, a new call is made on the following formula: $$H \land x_1 + x_2 + x_3 \leq 0 + Mr_1 \land x_4 + x_5 + x_6 \leq 0 + Mr_2 \land r_1 + r_2 \leq 1.$$ Since this formula is unsatisfiable, then $\alpha''$ is a lexicmax-optimal solution. Note that having $x_1,x_4,x_6$ assigned value 1 is also a lexicmax-optimal solution with the objective vector $(1,2)$. ### 3.2 Iterative SAT-based Algorithm using Sorting Networks The algorithm described in the previous section uses a PB solver. However, one can replace the PB solver with a SAT solver. For that, all constraints of the MOBO instance must be translated to CNF using one of the many available encodings [9, 66, 6, 62, 37, 12, 10, 27, 2]. Besides the original PB constraints, one also needs to encode into CNF the additional constraints added during the search procedure. First, note that a cardinality constraint is added on the relaxation variables (see line 4 in Algorithm 1). These cardinality constraints are usually small, since the size is bounded by the number of objective functions. Finally, one also needs to deal with the constraints that bound the value of the objective functions. For that, we use an encoding based on sorting networks [43, 27]. In the following, we assume the objective functions to be cardinality expressions for ease of explanation. In case we have a PB expression, a unary encoding from PB to CNF could be used. Instead of encoding to CNF constraints of the form $f_j \leq k + Mr_j$, where $f_j$ is the objective function and $r_j$ is the relaxation variable, we encode to CNF constraints of the form $f_j \leq k$. As a result, the relaxation of these constraints is dealt with in a different way, without requiring a large constant $M$. The encoding starts by adding to the set of hard of constraints, $H$, a sorting network encoding the expression for each objective function. Therefore, for each objective function $f_j$, we get fresh Boolean variables $o_{1,j}, \ldots, o_{m_j,j}$, corresponding to the output of the sorting network of $f_j$, $j = 1, \ldots, n$, where $m_j$ is the value of $f_j$ when all its variables are true. Hence, $f_j = \sum_{i=1}^{m_j} o_{i,j}$, and $o_{1,j}, \ldots, o_{m_j,j}$ is sorted in increasing order. Effectively, we obtain unary representations of the value of the objective functions. If a given variable $o_{v,j}$ is true, this means that the value of objective function $f_j$ is at least $m_j - v + 1$. Otherwise, if $o_{v,j}$ is false, then the value of objective function $f_j$ is smaller than $m_j - v + 1$. Figure 1 illustrates our encoding for finding the first maximum for three objective functions. The encoding starts by adding to the set of hard of constraints, $H$, a sorting network encoding the expression for each objective function. Therefore, for each objective function $f_j$, we get fresh Boolean variables $o_{1,j}, \ldots, o_{m_j,j}$, corresponding to the output of the sorting network of $f_j$, $j = 1, \ldots, n$, where $m_j$ is the value of $f_j$ when all its variables are true. Hence, $f_j = \sum_{i=1}^{m_j} o_{i,j}$, and $o_{1,j}, \ldots, o_{m_j,j}$ is sorted in increasing order. Effectively, we obtain unary representations of the value of the objective functions. If a given variable $o_{v,j}$ is true, this means that the value of objective function $f_j$ is at least $m_j - v + 1$. Otherwise, if $o_{v,j}$ is false, then the value of objective function $f_j$ is smaller than $m_j - v + 1$. An important property of the sorting network encoding is that the componentwise disjunction between the outputs of the sorting networks gives us $\max(f_1, \ldots, f_n)$. For example, the componentwise disjunction between the sorted vectors $(0, 1, 1)$ and $(0, 0, 1)$ is $(0 \lor 0, 1 \lor 0, 1 \lor 1) = (0, 1, 1)$, which corresponds to the vector with the largest number of ones. Then, we add fresh Boolean variables $y_1, \ldots, y_m$ such that $(y_1, \ldots, y_m)$ is the sorted vector of the componentwise disjunction, where $m = \max(m_1, \ldots, m_n)$. The PB constraints enforcing that the $i$-th maximum is upper bounded by $k$ are replaced by the unit clause $\neg y_{m-k}$, if $k < m$. In the case of Figure 1, we have three objective functions $f_1 = x_1 + x_2 + x_3, f_2 = x_4 + x_5 + x_6, f_3 = x_7 + x_8 + x_9$. In the iterations where $i > 1$, it is necessary to consider that some objective functions are relaxed. Hence, for each objective function $f_j$, we add fresh Boolean variables $s_{1,j}^1, \ldots, s_{m_j,j}^i$, $j = 1, \ldots, n$. In addition, we add to $H$ clauses enforcing that if $r_j^i$ is false (i.e. objective function $f_j$ is not relaxed when finding the $i$-th maximum), then $(s_{1,j}^i, \ldots, s_{m_j,j}^i)$ is equal to $(o_{1,j}, \ldots, o_{m_j,j})$, for $j = 1, \ldots, n$. Finally, instead of doing the componentwise disjunction between the outputs of the sorting networks, we do it between the new vectors $(s_{1,j}^1, \ldots, s_{m_j,j}^i)$, $j = 1, \ldots, n$. Note that the relaxation variables allows some of these vectors to assume arbitrary values. However, since we are minimising, those vectors can safely be assigned to false and will not affect the componentwise disjunction. As a result, the vector resulting from the componentwise disjunction, $(y_1^i, \ldots, y_m^i)$, will correspond to the maximum of $n - i + 1$ objective functions. Figure 2 illustrates the encoding used for the second iteration. The next iterations follow the same schema. Observe that the sorting networks do not have to be rebuilt between iterations. The encoding of the objective function expressions using the sorting networks is done only once. Algorithm 2 Core-guided leximax optimisation algorithm. Input: A set of hard constraints $\mathcal{H}$ and objective functions $f_1, \ldots, f_n$. Output: A leximax-optimal solution $\alpha$. 1. $\mathcal{X} \leftarrow \bigcup_{j=1}^{n} \{ \neg x : x \in f_j \}$ 2. for $i \leftarrow 1$ to $n$ do 3. \hspace{1em} $\mathcal{H} \leftarrow \mathcal{H} \cup \{ \sum_{j=1}^{n} r_j^i \leq i - 1 \}$ 4. \hspace{1em} $LB \leftarrow 0$ 5. \hspace{1em} repeat 6. \hspace{2em} $(st, \alpha, C) \leftarrow \text{SAT}(\mathcal{H} \cup \{ \text{EncodeCNF}(f_j \leq LB) \lor r_j^i : j = 1, \ldots, n \} \cup \mathcal{X})$ 7. \hspace{2em} if $st = \text{False}$ then 8. \hspace{3em} if $C \cap \mathcal{X} = \emptyset$ then \hspace{1em} $LB \leftarrow LB + 1$ 9. \hspace{3em} else \hspace{1em} $\mathcal{X} \leftarrow \mathcal{X} \setminus C$ 10. \hspace{2em} until $st$ 11. \hspace{1em} $\mathcal{H} \leftarrow \mathcal{H} \cup \{ \text{EncodeCNF}(f_j \leq LB) \lor r_j^i : j = 1, \ldots, n \}$ 12. return $\alpha$ 3.3 Core-guided Algorithm In this section, we present the structure of our core-guided algorithm for leximax Boolean optimisation. The main goal of the core-guided algorithm is to only consider a subset of the variables in each objective function, thus improving the performance of each call. Given a CNF formula $\varphi$, we assume that a call to a SAT solver to check the satisfiability of $\varphi$ returns a triple $(st, \alpha, C)$, where $st$ is a Boolean that is true if and only if $\varphi$ is satisfiable. If $\varphi$ is satisfiable, then $\alpha$ contains a satisfying assignment. Otherwise, if $\varphi$ is unsatisfiable, then $C$ contains an unsatisfiable subformula (also known as an unsatisfiable core) of $\varphi$. Algorithm 2 shows the pseudocode of the core-guided algorithm. First, we define a set $\mathcal{X}$ with unit clauses that are the negation of the variables in all objective functions $f_1, \ldots, f_n$. As in Algorithm 1, we iterate over the number of objective functions and in each iteration we find the smallest $i$-th maximum considering $n - i + 1$ objective functions. The main difference between Algorithm 1 and Algorithm 2 is that, in each iteration, we perform an UNSAT-SAT search procedure on the value of the $i$-th maximum initially assuming all variables in the objective functions are false, i.e. initially all are set to the optimum value. For finding the minimum $i$-th maximum, we start with a lower bound $LB$ of 0 (line 4). Then, a SAT call ![Figure 2 Schematic depiction of the encoding of the 2nd iteration of the SAT-based algorithm.](image-url) bounds the value of the non-relaxed objective functions to $\text{LB}$. If the formula in line 6 is unsatisfiable and it does not depend on the assumed values in $\mathcal{X}$, then we can safely increase the lower bound (line 8). Otherwise, we remove from $\mathcal{X}$ the unit clauses that appear in the unsatisfiable core $\mathcal{C}$ (line 9). At the end of iteration $i$, the variable $\text{LB}$ contains the smallest possible value for the $i$-maximum of the objective functions. Hence, we can fix this value (line 11). ### 3.4 SAT-based Core-guided Algorithm with Sorting Networks Algorithm 2 can be implemented using different CNF encodings for bounding the objective functions (lines 6 and 11). In this section, we detail Algorithm 2 using the sorting networks representation proposed in Section 3.2. Note that in the core-guided algorithm proposed in Algorithm 2, the CNF encoding of PB constraints that bound the objective functions is simplified due to the unit clauses in the set $\mathcal{X}$ that fix the values of some variables. In developing this algorithm, the same technique using sorting networks from Section 3.2 can be used to encode the objective functions, and use the set $\mathcal{X}$ to unit propagate the fixed values from the input of the sorting networks to the output. However, we propose to improve on this. Instead of representing the entire objective functions in the beginning of the algorithm, we propose to construct sorting networks only for the objective variables that are not negated in $\mathcal{X}$. As a result, the sorting networks are built dynamically and incrementally. At first, the sorting networks are empty and grow as more variables from the objective functions are removed from $\mathcal{X}$ due to the unsatisfiable cores found during the SAT calls. Using dynamic sorting networks raises some challenges. There are two main options for growing the sorting networks: (1) build a new sorting network from scratch or (2) grow the previous sorting network incrementally. However, the first case of rebuilding the sorting network might result in losing incremental SAT solving between iterations. An alternative would be to add a new blocking variable to the entire encoding of a sorting network and control if a given sorting network is active or not using the blocking variable and SAT solver assumptions. Nevertheless, this last alternative still implies rebuilding the sorting networks and the size of the SAT formula might become too large to handle efficiently. Due to these drawbacks, we propose to reuse the sorting network and make it grow in an incremental fashion. The incremental encoding to CNF has been the subject of previous research work [27, 53] but it is new in the context of leximax optimisation. Consider there is a sorting network that encodes some objective function and a new set of variables is to be added. In that case, we can build a sorting network for the new variables and apply a merge encoding between both sorting networks. Figure 3 illustrates the proposed schema for growing a sorting network where the Batcher’s odd-even merge construction [13, 43] can be used. A sorting network with $k$ inputs with Batcher’s odd-even merge sorting network uses $\Theta(k(\log(k))^2)$ comparators. There are no known constructions that produce sorting networks with smaller size complexity that can be used in practice. Thus, a sorting network with $k$ inputs is encoded with $\Omega(k(\log(k))^2)$ clauses. There are situations where the proposed sort-and-merge approach may lead to a larger growth of the number of comparators (and thus the number of clauses) than expected. The issue is that if, each time we obtain a new unsatisfiable core, we remove the variables from $\mathcal{X}$ and add them straight away to the sorting networks, the number of comparators may grow with $k^2$, instead of $k(\log(k))^2$. The odd-even merge construction produces $\Theta(k \log(k))$ comparators when merging two sequences of size $k$, and produces $\Theta(k)$ comparators when merging two sequences with size \( k \) and 1. Therefore, the odd-even merge sorting network, which works by recursively sorting two subsequences and then merging them, only produces \( \Theta(k(\log(k))^2) \) comparators when, in each recursive step, the sequence is cut in half. However, if we have the scenario of merging a sequence of \( k-1 \) elements and a sequence of 1 element, the final sorting network will contain \( \Theta(k^2) \) comparators. In the core-guided algorithm proposed in Algorithm 2, in the worst case, the unsatisfiable cores contain exactly one of the clauses in \( \mathcal{X} \). As a result, it is possible to end up with sorting networks with \( k \) inputs having \( \Theta(k^2) \) comparators. In order to try to limit the worst-case scenario where the encoding of the objective functions becomes quadratic, we propose to delay the merge process between the previous sorting network and the new variables to be added. Hence, when an unsatisfiable core is identified in the SAT call (line 6 of Algorithm 2), we remove from \( \mathcal{X} \) the clauses in the core, but the respective variables are not immediately added to the sorting networks. Instead, the variables from the clauses in the unsatisfiable core are added to a set \( \mathcal{S} \). Next, the SAT solver is repeatedly called with a smaller set \( \mathcal{X} \) of unit clauses. For each new unsatisfiable core \( \mathcal{C} \), clauses from \( \mathcal{C} \cap \mathcal{X} \) are removed from \( \mathcal{X} \) and their respective variables are added to \( \mathcal{S} \). When the SAT call becomes satisfiable, then we add the variables in \( \mathcal{S} \) to the sorting networks and the set \( \mathcal{S} \) is emptied. This procedure consists in finding as many cores as possible of a formula that are disjoint with regard to \( \mathcal{X} \). From now on, we refer to this strategy as the disjoint cores strategy. The use of disjoint cores is another idea borrowed from the MaxSAT solving literature [22, 14]. Note that this option may reduce the number of times the sorting networks are extended during the algorithm’s execution. When extending the sorting networks by sort-and-merge, the disjoint cores strategy can prevent the worst case quadratic growth of the number of comparators. **Example 13.** This example focuses solely on the delay of including literals from unsatisfiable cores into the sorting network representation of the objective functions. Consider a MOBO instance with hard clauses \( \mathcal{H} \) and two objective functions: \[ f_1 = x_1 + x_2 + x_3 + x_4; \quad f_2 = x_5 + x_6 + x_7 + x_8. \] Assume at some point in the execution of the core-guided algorithm with dynamic sorting networks \( \{x_1, x_2\} \) and \( \{x_5, x_6\} \) are in the sorting networks and \( \mathcal{X} = \{\neg x_3, \neg x_4, \neg x_7, \neg x_8\} \). Suppose we are minimising \( \max(f_1, f_2) \) and the lower bound is currently 1. The next call to the SAT solver is testing if there exists a feasible solution for the following formula: \[ \mathcal{H} \land \bigwedge_{l \in \mathcal{X}} l \land x_1 + x_2 \leq 1 \land x_5 + x_6 \leq 1. \] Assume the formula is unsatisfiable and the core $C$ is such that $C \cap X = \{\neg x_3\}$. In this case, $X$ is updated to $\{\neg x_4, \neg x_7, \neg x_8\}$. There are two options. The first option is to add $x_3$ to the sorting network of $f_1$ and continue with the algorithm by calling the SAT solver on the formula $$\mathcal{H} \land \bigwedge_{l \in X} l \land x_1 + x_2 + x_3 \leq 1 \land x_5 + x_6 \leq 1.$$ (3) However, as previously explained, this option may lead to an undesirable growth of the number of clauses in the objective function CNF representation. Hence, using the disjoint cores strategy, $x_3$ is not added to the sorting network right away. Instead we store $x_3$ in a set $S$, but we still remove $\neg x_3$ from $X$. Then, we test once again if (2) is true, but now $x_3$ can be true because it is no longer in $X$. Assume the formula is still unsatisfiable and the new unsatisfiable core $C$ is such that $C \cap X = \{\neg x_7\}$. We remove $\neg x_7$ from $X$ and add $x_7$ to $S$, so now $S = \{x_3, x_7\}$ and $X = \{\neg x_4, \neg x_8\}$. We check again the formula (2) where $x_7$ can now be true. Assume the formula is still unsatisfiable and the new core $C$ is such that $C \cap X = \{\neg x_4\}$. Then, $\neg x_4$ is removed from $X$ and $x_4$ is added to $S$. Assume that (2) becomes satisfiable. Notice that this does not mean the optimal solution has been found, as $\max(f_1, f_2)$ may not be 1 for the feasible solution. We need to add the variables in $S$ to the sorting networks and then check if there exists a feasible solution such that $$\mathcal{H} \land \bigwedge_{l \in X} l \land x_1 + x_2 + x_3 + x_4 \leq 1 \land x_5 + x_6 + x_7 \leq 1,$$ (4) with $X = \{\neg x_8\}$. If the formula (4) is unsatisfiable, we repeat the previous steps of removing literals from $X$ (in this case only $\neg x_8$ is left) until the formula becomes satisfiable. 4 Evaluation This section evaluates the proposed SAT-based algorithms for leximax optimisation. Besides comparing the different strategies of our algorithms, we compare against the state of the art ILP-based approach. The algorithms based on Constraint Programming [18] are not included since we were unable to find a publicly available implementation. 4.1 Use Case: Package Upgradeability The Package Upgradeability problem is an NP-complete problem [26] that arises when a user of a software system (e.g. Linux distributions) wants to install, remove or upgrade software packages. In the final installation, for each package $p_i$ that is installed, all its dependencies must be satisfied and there cannot be any other installed package $p_j$ such that $p_i$ and $p_j$ are conflicting. In addition, the user can define several objective functions to be minimised, such as the number of newly installed packages, the number of removed packages, or the number of not up-to-date packages. Therefore, the Package Upgradeability problem can be modelled as a MOBO formula. Furthermore, it is often the case that the user is unable to define a proper order of preferences among the several objectives. Hence, our evaluation is focused on finding a leximax-optimal solution for the Package Upgradeability problem. There are several Package Upgradeability solvers that rely on encodings to Answer Set Programming [31], Maximum Satisfiability [41, 38], Pseudo-Boolean Optimisation [5] and ILP [57, 35]. However, most tools only compute lexicographically optimal solutions of the problem. Only **mccs** [56, 57] (version 1.1) is able to compute leximax-optimal solutions, using the ILP-based algorithm described in Algorithm 1. \texttt{mccs} can be used with different ILP solvers. Hence, we configured and tested \texttt{mccs} with the following ILP solvers: CPLEX [21] (version 12.10.0), Gurobi [34] (version 9.0.3), SCIP [30, 65] (version 7.0.1), Cbc [20] (version devel, build Jan 14 2021), GLPK [32] (version 4.65) and lpsolve [47] (version 5.5.2.5). 4.2 Implementation and Benchmarks The new SAT-based algorithms and the existing ILP-based algorithm were implemented in a tool for leximax optimisation that is publicly available [17]. In the implementation of the SAT-based algorithms, the Batchers’s odd–even merge procedure [13, 43] was used for constructing and merging sorting networks. The sorting network encoding of MiniSat+ [27] was used without coefficient decomposition and interconnected sorting networks since we focus on solving unweighted instances (e.g. Package Upgradeability). To evaluate the SAT-based algorithms on the Package Upgradeability domain, the \texttt{packup} [41, 38, 64] Package Upgradeability solver was linked with our tool. The algorithms were evaluated using the incremental SAT solving library of CaDiCal [15] (version 1.3.1). The Package Upgradeability solvers, \texttt{packup} and \texttt{mccs}, were executed on a set of 142 Package Upgradeability benchmarks [48] from the Mancoosi International Solver Competition [49]. The objective functions defined in the Mancoosi competition are the following: removed, notuptodate, changed, unsat_recommends and new. For each of the 142 benchmarks we generated instances considering all 26 combinations of two, three, four and five objective functions, resulting in 3692 instances. Of the 3692 instances, 122 instances correspond to unsatisfiable instances or instances that are reduced to the single-objective case. As a result, the final benchmark set contains 3570 instances to find a leximax-optimal solution. In order to broaden the experimental evaluation, we adapted a subset of benchmark instances from the MaxSAT Evaluation 2021 [55] to the multi-objective domain. From the 561 benchmarks of the unweighted track of the MaxSAT Evaluation 2021, we selected 100 instances that encode problems from different domains, such that the MaxSAT solver Open-WBO [54, 63] outperforms Gurobi within a 10 s timeout. For each of those benchmarks, a MOBO instance was generated by keeping the same set of constraints and by randomly partitioning the original set of soft clauses into multiple sets of soft clauses. We considered partitions into two, three and four objective functions, resulting in a set of 300 instances [59]. All algorithms were executed on a single thread, with 180 seconds CPU time limit for the Package Upgradeability instances and 3600 seconds CPU time limit in the case of MaxSAT-based instances. The experiments were run on Intel(R) Xeon(R) E5-2630 v2 CPU 2.60GHz machines with Debian Linux operating system with 4 GB memory limit for each instance. 4.3 Evaluation of the SAT-based Algorithms This section analyses the performance of the different versions of the proposed SAT-based algorithms on the set of Package Upgradeability benchmarks. First we describe the abbreviations used when presenting the results for these versions. There are three versions of Algorithm 1 using the SAT encoding as described in Section 3.2, each corresponding to different types of search for the i-th maximum: the linear search SAT-UNSAT algorithm is linear-su, linear search UNSAT-SAT is linear-us and binary search is binary. There are several versions of the core-guided algorithm proposed in Section 3.4. The version where the sorting networks are rebuilt with non-incremental SAT solving is named core-rebuild. If the sorting networks are rebuilt, but using incremental SAT solving then we use core-rebuild-incr. If the objective functions are statically built at the beginning of the algorithm we use \texttt{core-static}. The version with dynamic sorting networks that extends the objective functions by sorting the new variables and merging with the previous sorting network is \texttt{core-merge}. If the additional disjoint cores strategy is used, then the algorithms' names are appended with ‘-dc’. Figure 4 shows a cactus plot with the run times of solved Package Upgradeability instances by SAT-based algorithms. Among the different versions of the iterative SAT-based algorithm, the best performing was the binary search. Nevertheless, despite being able to solve more instances within the time limit of 180 seconds, it is usually slower than the UNSAT-SAT search when this approach is able to solve the instance. For example, the plot clearly shows that the number of instances solved by the binary search within 20 seconds is much smaller. The results from Figure 4 also show that the core-guided approach using the proposed incremental merge of sorting networks is the best performing algorithm. Moreover, delaying the merge operation by using the disjoint cores strategy results in a significant performance boost. Observe that the disjoint cores strategy also greatly improves the algorithms that rebuild the sorting networks (both the incremental and non-incremental versions). To better understand the difference in the performance of the algorithms, we analyse the number of wires of the sorting networks and the number of clauses of the formula. Figure 5 contains two cactus plots. Both plots correspond to the Package Upgradeability benchmarks. The plot on the left shows the total number of wires of the last sorting networks produced by each algorithm. The plot on the right shows the number of clauses of the last call to the SAT solver. As expected, using dynamic sorting networks allows to significantly reduce the number of wires of the sorting networks when compared with the static representation of the objective functions. This occurs because not all variables are represented in the objective functions. The goal is that the reduction in the number of wires allows a reduction in the number of comparators and ultimately in the number of clauses. Indeed, we observe a significant reduction in the number of clauses with dynamic sorting networks, except for core-rebuild-incr, because it does not delete the previous sorting network encodings, and core-merge, because of the growth of the number of comparators when merging. Since there are many small unsatisfiable cores, the growth in core-merge tends to approximate the worst case scenario explained in Section 3.4. Due to this growth on the size of the formula, core-rebuild-incr and core-merge exceeded the 4 GB memory limit in around 30% and 4% of the instances, respectively. The right plot of Figure 5 clearly shows the impact of using the disjoint cores strategy, resulting in a significant reduction in the size of the final sorting networks. Note that core-merge-dc and core-rebuild-incr-dc both use incremental SAT solving, and produce a similar number of clauses. However, the sort-and-merge approach proved to be more effective than the rebuild approach, as core-merge-dc solved more instances with overall faster run times than core-rebuild-incr-dc. 4.4 Comparison with ILP solvers This section provides a comparison between the best performing core-guided SAT approach core-merge-dc and the iterative ILP algorithm when using different ILP solvers. Figure 6 shows the cactus plots of the run times of solved instances, for each solver. On the left we the results for the Package Upgradeability benchmarks and on the right the results on the instances generated from the MaxSAT Evaluation 2021. In the case of Package Upgradeability, the overall results show that when using commercial solvers Gurobi and CPLEX, the iterative ILP approach solves more instances. However, the plot also shows that our approach can outperform the iterative ILP algorithm when using non-commercial solvers in both the number of instances and run-times. We note that in many real-world cases, such as the Package Upgradeability problem in open-source Linux distributions, the usage of commercial solvers is not feasible. On the MaxSAT Evaluation 2021 instances, we tested the ILP approach using commercial solvers Gurobi and CPLEX. These results suggest that our proposed algorithm can potentially outperform the ILP commercial solvers in other application domains, e.g. the Placement Fixer problem, which is not well-suited for ILP, because of the type of constraints [61]. Figure 7 shows two cactus plots that provide an analysis on the algorithms’ performance depending on the values in the leximax-optimal objective vector in the Package Upgradeability instances. The plot on the left shows the run times for instances where the largest value in the leximax-optimal solution is smaller than 100. On the other hand, the plot on the right shows the run times for instances where the largest value is larger than or equal to 100. Observe that when the largest value is smaller than 100, core-merge-dc has a similar performance to the iterative ILP algorithm when using commercial solvers CPLEX or Gurobi and clearly outperforms non-commercial solvers. On the other hand, the iterative ILP algorithm has a stronger performance for larger values in the leximax-optimal solution. This occurs since our core-guided approach is slower to converge in these situations [25]. Nevertheless, in the context of package upgradeability, it is often the case that real-world users perform incremental adjustments to a current installation. Hence, in these situations, optimal solutions tend to have a small cardinality and our proposed core-merge-dc algorithm excels in those scenarios. 5 Conclusions This paper introduces the first SAT-based leximax optimisation algorithms. Besides iterative SAT-based algorithms, we also propose a new core-guided algorithm for leximax optimisation. The algorithms are built upon the effective encoding of PB constraints to CNF and a CNF encoding to determine the maximum value among several objective functions. Moreover, we explore the translation of PB constraints to CNF using sorting networks. We use a merging technique that allows to dynamically and incrementally extend the representation of objective functions. Additionally, a strategy based on the identification of disjoint cores in the core-guided algorithm allows to delay the merging process, thus resulting in a more effective encoding of the objective functions. An experimental evaluation is carried out on the Multi-Objective Package Upgradeability Optimisation problem and on generated MOBO instances based on the MaxSAT Evaluation benchmarks. The core-guided algorithm outperforms the iterative ILP algorithm when using non-commercial solvers on the Package Upgradeability benchmarks. The results on the MaxSAT Evaluation instances suggest that our SAT-based algorithms may be competitive with the ILP algorithm with commercial solvers on other application domains. As a future direction of research, we highlight the integration of our leximax optimisation algorithms with incomplete algorithms, such as Polosat [60], in the same way they are currently integrated to MaxSAT solvers. Another interesting direction of research is the development of hybrid approaches using SAT and ILP solvers for leximax optimisation, e.g. by adapting the approach of the MaxSAT solver MaxHS [22]. References Cbc solver webpage. [https://github.com/coin-or/Cbc](https://github.com/coin-or/Cbc). GLPK (GNU Linear Programming Kit) webpage. [https://www.gnu.org/software/glpk/](https://www.gnu.org/software/glpk/). Gurobi webpage. [https://www.gurobi.com/](https://www.gurobi.com/).
{"Source-Url": "https://drops.dagstuhl.de/opus/volltexte/2022/16703/pdf/LIPIcs-SAT-2022-29.pdf", "len_cl100k_base": 13457, "olmocr-version": "0.1.53", "pdf-total-pages": 19, "total-fallback-pages": 0, "total-input-tokens": 70663, "total-output-tokens": 18689, "length": "2e13", "weborganizer": {"__label__adult": 0.0003769397735595703, "__label__art_design": 0.00045418739318847656, "__label__crime_law": 0.00047516822814941406, "__label__education_jobs": 0.0021762847900390625, "__label__entertainment": 0.00012171268463134766, "__label__fashion_beauty": 0.0002114772796630859, "__label__finance_business": 0.0007915496826171875, "__label__food_dining": 0.00041031837463378906, "__label__games": 0.0010461807250976562, "__label__hardware": 0.0011167526245117188, "__label__health": 0.0008544921875, "__label__history": 0.000453948974609375, "__label__home_hobbies": 0.0001671314239501953, "__label__industrial": 0.0006356239318847656, "__label__literature": 0.0004215240478515625, "__label__politics": 0.0004127025604248047, "__label__religion": 0.0005440711975097656, "__label__science_tech": 0.167236328125, "__label__social_life": 0.00014019012451171875, "__label__software": 0.0165252685546875, "__label__software_dev": 0.80419921875, "__label__sports_fitness": 0.00029754638671875, "__label__transportation": 0.0007076263427734375, "__label__travel": 0.0002560615539550781}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 63576, 0.0443]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 63576, 0.49417]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 63576, 0.81654]], "google_gemma-3-12b-it_contains_pii": [[0, 3454, false], [3454, 7626, null], [7626, 12198, null], [12198, 15769, null], [15769, 19363, null], [19363, 22981, null], [22981, 26888, null], [26888, 29499, null], [29499, 33552, null], [33552, 36718, null], [36718, 40304, null], [40304, 44188, null], [44188, 46069, null], [46069, 48783, null], [48783, 51688, null], [51688, 55603, null], [55603, 59836, null], [59836, 63576, null], [63576, 63576, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3454, true], [3454, 7626, null], [7626, 12198, null], [12198, 15769, null], [15769, 19363, null], [19363, 22981, null], [22981, 26888, null], [26888, 29499, null], [29499, 33552, null], [33552, 36718, null], [36718, 40304, null], [40304, 44188, null], [44188, 46069, null], [46069, 48783, null], [48783, 51688, null], [51688, 55603, null], [55603, 59836, null], [59836, 63576, null], [63576, 63576, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 63576, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 63576, null]], "pdf_page_numbers": [[0, 3454, 1], [3454, 7626, 2], [7626, 12198, 3], [12198, 15769, 4], [15769, 19363, 5], [19363, 22981, 6], [22981, 26888, 7], [26888, 29499, 8], [29499, 33552, 9], [33552, 36718, 10], [36718, 40304, 11], [40304, 44188, 12], [44188, 46069, 13], [46069, 48783, 14], [48783, 51688, 15], [51688, 55603, 16], [55603, 59836, 17], [59836, 63576, 18], [63576, 63576, 19]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 63576, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
06442aa735504786929130fb6de7af0dfd5d5e1e
Extensions to Systematic Error and Risk Analysis (SERA) Tool - Final Report - Disclaimer: The scientific or technical validity of this Contract Report is entirely the responsibility of the contractor and the contents do not necessarily have the approval or endorsement of Defence R&D Canada. Abstract The Systematic Error and Risk Analysis (SERA) tool is software developed by AIMDC for DRDC Toronto and designed to step accident investigators through a systematic process of identifying factors that led to an accident and associated pre-conditions. The present contract work added new features to the SERA tool, principally the ability for investigators in the field to dictate remarks for later inclusion in a SERA report. The purpose of voice recording is to reduce the need for the more cumbersome use of a stylus to enter textual responses. Support was added to SERA that accepts text recorded on a Sony IC Voice Recorder and transcribed by the Dragon NaturallySpeaking software. The SERA software manages the insertion of the transcribed text into appropriate locations in the SERA interface. Also implemented was a feature that allows users to exclude selected items from an exported SERA report. A final addition to the software allows investigators to review their audio recordings for accuracy in the transcriptions. Résumé L’outil Analyse systématique des erreurs et du risque (SERA) est un logiciel mis au point par AIMDC pour le compte de RDDC Toronto. Il est conçu pour faire suivre aux enquêteurs d’accident les étapes d’un processus systématique de l’identification des facteurs qui ont conduit à un accident et aux préconditions connexes. Les travaux effectués en vertu de ce contrat ont ajouté de nouvelles fonctions à l’outil SERA, principalement l’aptitude des enquêteurs sur le terrain à dicter des remarques à inclure plus tard dans un rapport SERA. L’enregistrement de la parole a pour but de réduire le besoin peu pratique d’utiliser un stylet pour entrer des réponses en texte. L’outil SERA a été enrichi d’une fonction qui accepte un texte enregistré sur un enregistreur de voix Sony IC et transcrit par le logiciel Dragon Naturally Speaking. Le logiciel SERA gère l’insertion du texte transcrit dans les endroits appropriés dans l’interface SERA. Il y a eu également une fonction qui permet les utilisateurs à exclure des éléments sélectionnés d’un rapport SERA. Un ajout final au logiciel permet aux enquêteurs d’examiner les enregistrements sonores pour assurer l’exactitude des transcriptions. Executive Summary The Systematic Error and Risk Analysis (SERA) tool is a software package developed by AIMDC for DRDC Toronto. It is designed to step accident investigators through the systematic process of identifying factors that led to an accident and the associated pre-conditions. The process involves answering a series of questions, some of them requiring yes or no responses and others involving extended textual answers. The present contract involved adding new features to the SERA tool, principally the ability for investigators in the field to dictate remarks for later inclusion in a SERA report. The purpose of voice recording in the field is to reduce the need for the more cumbersome use of a stylus to enter textual responses. To facilitate that process, support was added to accept text recorded on a Sony IC Voice Recorder and transcribed using the Dragon NaturallySpeaking software. Numerical identifiers were added to SERA’s interface to allow the software to correlate each dictated entry with a particular text input area in the software. The new “Voice Recognition” window manages the insertion of the transcribed text into appropriate locations in the SERA interface. A shortcoming in the original software was the inability to specify which components to export to a SERA report, sometimes resulting in the inclusion of extraneous material. To address that issue, an “Export Options” window was added to give users control over the inclusion of the following items: 1) pre-conditions answered, “No”; 2) pre-conditions not answered; and 3) AGA 135 HFACS equivalents. A final addition to the software arose from a study that examined the feasibility of including a mechanism by which investigators could review their audio recordings for accuracy in the transcriptions. As a consequence of that study, it was decided that such a capability could be designed and implemented in the context of the current contract. The new “Audio File Access” window presents users with a list of available audio files and displays their associated numeric identifiers, revealing the correlation between each text input area and each audio file. Users may then select one and click “Play” to open the file with standard audio playback controls. L’outil Analyse systématique des erreurs et du risque (SERA) est un logiciel mis au point par AIMDC pour le compte de RDDC Toronto. Il est conçu pour faire suivre aux enquêteurs d’accident les étapes d’un processus systématique de l’identification des facteurs qui ont conduit à un accident et aux préconditions connexes. Le processus consiste à répondre à une série de questions dont certaines devaient être répondues par oui ou par non et d’autres nécessitant des réponses plus élaborées. Les travaux effectués en vertu de ce contrat ont ajouté de nouvelles fonctions à l’outil SERA, principalement l’aptitude des enquêteurs sur le terrain à dicter des remarques à inclure plus tard dans un rapport SERA. L’enregistrement de voix sur le terrain a pour but de réduire le besoin peu pratique d’utiliser un stylet pour entrer des réponses textuelles. Pour faciliter ce processus, l’outil SERA a été enrichi d’une fonction qui accepte un texte enregistré sur un enregistreur de voix Sony IC et transcrit par le logiciel Dragon Naturally Speaking. Des identificateurs numériques ont été ajoutés à l’interface de l’outil SERA pour permettre au logiciel de corréler chaque entrée dictée avec une zone d’entrée de texte particulière dans le logiciel. La nouvelle fenêtre de reconnaissance de voix gère l’insertion du texte transcrit dans les endroits appropriés de l’interface de SERA. Le défaut de l’ancien logiciel était, entre autres, son incapacité de préciser quels composants il fallait exporter à un rapport SERA. Cela entraînait parfois la présence de matériel étranger dans le rapport. Pour remédier à ce problème, une fenêtre « Export Options » a été ajoutée pour permettre aux utilisateurs de contrôler l’insertion des éléments suivants : 1) réponses « non » aux préconditions; 2) pas de réponses aux préconditions et 3) équivalent au AGA 135 HFACS. Un dernier ajout au logiciel a été suggéré par une étude de la possibilité d’inclure un mécanisme selon lequel les enquêteurs pourraient examiner leurs enregistrements de son pour assurer l’exactitude des transcriptions. En raison de cette étude, il a été décidé qu’une telle capacité pourrait être désignée et appliquée dans le contexte du présent contrat. La nouvelle fenêtre « Audio File Access » présente aux utilisateurs une liste de fichiers sonores disponibles et affiche le numéro de leur identificateur numérique, révélant la corrélation qui existe entre chaque zone d’entrée de texte et chaque fichier sonore. Les utilisateurs peuvent choisir alors un fichier et cliquer sur « Play » pour l’ouvrir à l’aide des contrôles de lecture. # Table of Contents Abstract ........................................................................................................................................ i Résumé ........................................................................................................................................ i Executive Summary .................................................................................................................. iii Sommaire ................................................................................................................................... iv Table of Contents ........................................................................................................................ v List of figures ........................................................................................................................... vii Background ................................................................................................................................. 1 Research Approach ................................................................................................................... 2 Study Objectives and Work Items ............................................................................................. 2 Voice Recording and Speech Recognition .................................................................................... 3 The Sony Voice Recorder Hardware .......................................................................................... 4 The Voice Editor Software ......................................................................................................... 4 Dragon NaturallySpeaking Software ....................................................................................... 4 Recording Dictated Entries ....................................................................................................... 5 “Voice Recognition” Window .................................................................................................. 6 “Audio File Access” Window .................................................................................................. 7 Customised Report Output ........................................................................................................ 8 “Export Options” Window ....................................................................................................... 8 Opportunities for Future Enhancements ...................................................................................... 9 Voice Recognition on the Pocket PC ....................................................................................... 9 Palm Support ........................................................................................................................... 9 References ................................................................................................................................. 10 Annexes ....................................................................................................................................... 12 Annex 1: Instructions for Voice Input with the SERA Accident Investigation Tool ..14 Annex 2: Installing SERA on the Pocket PC ........................................................................ 23 Annex 3: SERA Source Code Files ...................................................................................... 26 List of figures Figure 1: “Voice Recognition” window.................................................................6 Figure 2: “Export Options” window.................................................................8 The Systematic Error and Risk Analysis (SERA) tool is a software package developed by AIMDC for DRDC Toronto. It is designed to step accident investigators through the systematic process of identifying the factors that led to an accident and the associated pre-conditions. The process involves answering a series of questions, some of them requiring yes or no responses and others involving extended textual answers. The software is implemented in Java for Windows, Macintosh and the Pocket PC platforms. Hardware used for the Pocket PC is the Compaq iPaq running under the Microsoft Pocket PC 2002 operating system. The Pocket PC version of SERA is designed to be used by accident investigators in the field. Prior to the current work, Pocket PC users entered textual information using a stylus, an often tedious process. A need was identified to simplify that entry procedure and became a key element of the work in the current contract. Another shortcoming in the software was the inability to select the components exported to a SERA report. Providing users with the ability to customise that output was another task identified for inclusion in this contract. Research Approach Study Objectives and Work Items The following study objectives and work items were identified for this project: Construct an interface to take natural speech as input at locations in SERA where elaboration, explanation and comment are required, convert that audio input into text files with associated tags to appropriate locations in SERA and integrate the results with SERA’s report facility. Offer users the option to eliminate some of results currently included in SERA reports, which tend to add clutter when users do not wish to see them. Specifically, users will be given the option of eliminating the following: 1) pre-conditions answered, "No"; 2) pre-conditions not answered; and, 3) AGA 135 HFACS equivalents. Opting for any of those should delete them from the report only, not from the main SERA file. Conduct an investigation into the feasibility of associating the audio files with the various interface locations to allow users to review the speech recognition results while playing back their recordings. Looking ahead to the establishment of SERA as a recognised tool for accident investigation, a determination needs to be made about what reliability test(s) might be appropriate to help in establishing its credibility. Conduct an investigation into available non-parametric tools to set the stage for a formal test of the software. Optionally, refine SERA based on the results of field evaluations that yield recommendations that affect the look and feel of SERA. The scope of any changes to SERA arising from the results of field evaluations will be limited to editing textual information in SERA and will not involve the decision logic or screen design. Voice Recording and Speech Recognition One of the primary aims of the current contract was to allow investigators to record speech in the field and later incorporate those remarks as text in the appropriate locations in a SERA report. That required several elements: - selection of a suitable hardware device for recording in the field; - selection of software for transferring and transcribing the recorded audio content onto a computer; - specification of guidelines for recording the audio so that it can be linked to specific locations in a SERA report; - construction of an interface within SERA for accepting the transcribed text and inserting it into the appropriate locations; - possible implementation of a method for reviewing the recorded audio files. Those elements are described in detail in the following sections. The Sony Voice Recorder Hardware The Sony IC Voice Recorder was selected as the means for investigators to store dictated remarks. The device allows users to record high quality audio onto a storage card (“Memory Stick”) in much the same way as a tape recorder is used. It is very compact, making it suitable for dictating notes in the field for later retrieval. Because the device has no moving parts, recordings feature less noise than those made with conventional tape recorders, and the electronic storage mechanism allows entries to be indexed and transferred easily to a computer. Audio on the computer then can be converted to editable text using voice recognition software. With the included 8 MB storage card, the recorder can store 64 minutes of audio; with a 128 MB card (the largest available), the device will record over 17 hours of material. In addition to offering the advantages described above, the Sony IC Voice Recorder was selected because it includes software that handles the transfer of audio files to a computer and subsequent transcription of the recorded speech into editable text. The Voice Editor Software The Sony Memory Stick Voice Editor software is bundled with the voice recorder hardware. It allows users to transfer audio files to and from a Windows computer and to listen to them using standard playback controls. It also provides users with a direct link to the Dragon NaturallySpeaking voice recognition software. Instructions for installing the Memory Stick Voice Editor appear in Annex 1. Dragon NaturallySpeaking Software Like the Voice Editor software, the Dragon NaturallySpeaking software is bundled with the Sony voice recorder. It provides the speech recognition capabilities that allow remarks dictated in the field to be transcribed for insertion into a SERA report. The voice recognition software must be trained to recognise a user’s voice before it can be used. That process involves reading one or more passages of text into the Sony Recorder for at least fifteen minutes, although reading for longer does improve the accuracy of recognition. At the end of the training session, the software analyses the sound of the voice, correlating it with the text of the passage read. Because the software learns the characteristics of individual voices, training must be performed separately for each user of the software. Further training can be done later to improve the accuracy of recognition. At least one passage of text must be read for a minimum of 15 minutes. Testing by AIMDC has revealed that significantly higher accuracy can be achieved by training the software with two passages, so it is recommended that users read at least two 15 minute sections. Instructions for installing and training the Dragon software appear in Annex 1. Recording Dictated Entries A key requirement for speech input to SERA was the ability to link spoken entries with specific text input areas in the software. That was accomplished using a numerical identifier scheme whereby each text input area has a unique number displayed next to it in square brackets, which a user records at the beginning of each dictated entry. Most text input areas in SERA are sequentially numbered, but there are apparent gaps in the numbering depending on which branches of the tree a user follows during the investigation of a given accident. Numerical identifiers were chosen over alphabetical or alphanumeric because the voice recognition software has difficulty distinguishing certain letters from words, e.g., the letter “C” and “see.” Also, numeric entry is flexible enough that, for example, the number “259” can be entered by saying either “two hundred and fifty-nine” or “two five nine.” Although the target platform for field investigators is the Pocket PC, numerical identifiers were added to SERA’s interface on all three supported systems, giving users the option to use a Windows or Macintosh laptop in conjunction with the voice recorder. The process of conducting a SERA investigation in the field begins with a user launching SERA on the Pocket PC. The investigator navigates through the SERA process, answering “yes” or “no” to questions, as appropriate, and selecting conclusions and pre-conditions, but without filling in any extended textual information. Several text boxes in the first two SERA screens do not have identifiers because they require short input and often contain proper names. The Dragon software is less effective with such input, so it was decided that those text boxes should be filled in manually using the on-screen keyboard on the PDA. Each recorded entry must begin with a section sign symbol (§), which serves as a separator between entries. This was chosen as a symbol that would not be used in a typical investigation and therefore would not lead to ambiguity when the text is read into SERA. After the section sign, the numerical identifier of the text entry area is recorded, followed by the content of the remark to be added to the report. For example, to record the remark, “the plane was flying too low” for insertion in text box 19, the user would say the following: “Section sign nineteen the plane was flying too low period.” Punctuation and formatting commands can be used to achieve the best possible recognition results. Those are discussed further in Section V of Annex 1, entitled “Special Dictation Commands.” “Voice Recognition” Window The “Voice Recognition” window (see Figure 1) was implemented to provide an interface that allows transcribed text to be input into SERA. It is invoked using the “Import Speech…” command in the “File” menu. The window works by receiving recognised text from the Dragon software into a large text input area. That text constitutes all of the dictated remarks along with their section numbers. When the user clicks the “Insert” button, the text is separated into individual remarks and inserted into the appropriate places in the SERA interface. If SERA encounters a problem interpreting a section number, the user will be notified in the window and can then manually copy and paste the affected text into suitable places in SERA’s interface. The recognition software was so effective, however, that the problem never arose during AIMDC testing. The “Voice Recognition” window includes a “Save Transcript…” command in the “File” menu for storing a copy for future reference. There is an “Open Transcript…” command to call up previously saved material. ![Figure 1: “Voice Recognition” window](image-url) “Audio File Access” Window The current contract included a requirement to examine the feasibility of allowing users to review the audio files associated with each transcribed entry in the SERA interface. Having determined that it was feasible to implement such a capability and given the delay in obtaining material from the inter-rater reliability contractor, it was decided after discussions with the client that implementing the audio file review would constitute a substitute for the inter-rater reliability component of the contract. Furthermore, the current report is to serve as a substitute for the report on the inter-rater reliability study. The “Audio File Access” window was designed to allow users to listen to their original audio recordings to resolve discrepancies with the recognised text. It is invoked using the “Voice Recorder Files” command in the “File” menu. Given the high accuracy of the speech recognition software experienced by AIMDC during testing, it should be assumed that the review procedure will be used only rarely. Reading over the recognised text should be sufficient to catch any errors in the majority of cases. The “Audio File Access” window presents a list of audio files with section numbers in parentheses. Those section numbers are inferred based on SERA’s interpretation of the transcribed text. If there were errors recognising the numerical identifiers during transcription, the parenthesised numbers might not be accurate, but would indicate the approximate location of the desired audio file. After selecting a file, users can click the “Play” button to open the file in the Sony Memory Stick Voice Editor software where it can be reviewed using standard audio playback controls. Customised Report Output A need was identified for investigators to be able to customise some of the results currently included in exported SERA reports, which tend to add clutter if a user does not explicitly wish to see them. Specifically, options were added that allow users to include or exclude the following from a report: 1) pre-conditions answered, “No;” 2) pre-conditions not answered; 3) AGA 135 HFACS equivalents. The options are presented to the user in the “Export Options” window. “Export Options” Window To address the need for customised report output, a new “Export Options” window was created (see Figure 2). That window is displayed when the user selects “Export…” from the “File” menu. The window contains a checkbox for each of the three settings described in the previous section. By default, all checkboxes are selected the first time the window is displayed during a given session, and the state of the window is preserved each time it is displayed during that session. The “Export Options” window was added to all three platforms that currently support SERA: Windows, Macintosh and Pocket PC. ![Export Options Window](image-url) *Figure 2: “Export Options” window* Opportunities for Future Enhancements Future work on the software could encompass some or all of the following items. **Voice Recognition on the Pocket PC** The Pocket PC version of SERA could be extended to allow recognition of spoken commands for navigation through the questionnaire. That could allow selection of yes or no answers and choosing conclusions and pre-conditions, thereby reducing the need for investigators to use a stylus. As PDA technology improves, it likely will be possible for the work using the Sony IC Voice Recorder to be incorporated into the PDA itself. While voice input in the field improves the ease with which an investigation can be conducted, it still requires the use of two handheld devices. Using only one device will be a further improvement for investigators. Before that can happen, however, PDA’s will have to acquire the capacity for storing larger amounts of audio and for interpreting audio files. **Palm Support** A port of the software could be prepared for the PalmOS platform. References Annexes 1. Instructions for Voice Input with the SERA Accident Investigation Tool 2. Installing SERA on the Pocket PC 3. SERA Source Code Files Annex 1 Instructions for Voice Input with SERA Annex 1: Instructions for Voice Input with the SERA Accident Investigation Tool I. Overview The voice recording and recognition capabilities of a Sony IC Recorder and associated software allow users of the SERA accident investigation tool to dictate comments in the field during an accident investigation, thereby avoiding the tedious process of keying information into a mobile device. SERA users still navigate through the SERA questionnaire, answering yes/no questions and selecting appropriate conclusions and pre-conditions. However, extended textual answers and additional remarks can be dictated into the voice recorder for later integration into a SERA report. The next section describes how to use the Sony IC Voice Recorder to dictate text into SERA. The process involves the following steps: - Create a SERA File - Record Dictated Entries - Convert Dictated Entries to Text - Merge Converted Text with the SERA File - Optional Review of Audio Files - Save and Export a Report - Integration of Exported Reports with Other Documents Section III describes the installation and configuration of the software required for voice recognition. Section IV discusses voice recorder hardware issues and Section V presents a summary of special punctuation and formatting commands recognised by the dictation software. II. Detailed Instructions If you have not trained your Sony IC Recorder to recognise your voice, go to Section III and follow the instructions for training up your Recorder. If you have trained your Sony Recorder then continue with the instructions below: - Create a SERA File - While in the field, you, as an investigator, will navigate through the SERA process on a PDA, answering yes or no to questions, as appropriate, selecting conclusions and pre-conditions, but without filling in any extended textual information; - Most text entry areas in the software are labelled with unique numerical identifiers enclosed in square brackets. Those numbers enable the software to associate each spoken entry with a particular text entry area ("text box") in the SERA interface. Several text boxes in the first two SERA screens do not have identifiers because they require short input, often containing proper names. The Dragon software is less effective with such input, so it was decided that those text boxes should be filled in manually using the on-screen keyboard on the PDA. Those should be filled in at this stage of the process; - At the end of the process, the resulting SERA file should be stored on the PDA for later retrieval. To store the file, use the "Save As…” command in SERA’s file menu. - **Record Dictated Entries** - While creating a SERA file, questions requiring more than short responses may be answered most easily by dictating entries into the Sony Voice Recorder (Before using your Sony IC Recorder, make sure you have reviewed the two short notes in Section IV below on the “Care and Feeding of the Sony IC Voice Recorder”); - Each voice entry is associated with a unique numerical code, recorded at the beginning of each dictated section, that correlates with a particular number in square brackets in the interface; - Most text boxes in SERA are sequentially numbered, but you will notice apparent gaps in the numbering depending on which branches of the tree you follow during the investigation of a given accident; - Set the recorder for “SP” (high quality) recording and use the “Low” sensitivity microphone setting. Dictate holding the unit two to four inches from your mouth; - Each recorded entry must begin with a section sign symbol (§), which serves as a separator between entries. After the section sign, the numerical identifier of the text entry area must be recorded, followed by the content of the remark to be added to the report. For example, to record the remark, “the plane was flying too low” for insertion in text box 19, say the following: “Section sign nineteen the plane was flying too low period;” - Carriage returns can be added by saying “new line” and commas are inserted with the “comma” command. Users who are new to voice recognition often omit commands during dictation, resulting in missing punctuation and formatting. To achieve the best possible recognition results, it is recommended that you familiarise yourself with those commands, discussed further in Section V, “Special Dictation Commands;” - Identifier numbers, such as “259,” can be entered either by saying “two hundred and fifty-nine” or “two five nine;” - Each entry should be recorded in a separate file on the voice recorder. Press and release the “Rec/Rec Pause” button to start each recording and the “Stop” button when each one is finished; - If you want to add more to an entry later, you can create a new audio recording having the same numerical identifier with the additional material. When the entries are imported into SERA, the software will merge them into a single text area, as appropriate; - It is recommended that you create a separate folder on the voice recorder for each accident under investigation. Folders can be created using the “New folder” command in the menu. This process is described in more detail on page 37 of the Sony IC Recorder manual. • **Convert Dictated Entries to Text** - Move the SERA file from the PDA to a desktop or laptop computer using the following procedure: - Place the PDA in its cradle connected to your desktop or laptop Windows computer; - Open “My Computer” from the Start menu on the laptop or desktop machine and then open “Mobile Device;” - You will see a list of folders on the PDA and the SERA file should be located in one of those folders. Drag the SERA file to a folder on the laptop or desktop machine. - Launch SERA and open the file that you just moved; - Select “Import Speech…” from the File menu; - Plug the Sony voice recorder into the computer’s USB port using the supplied cable and launch the “Memory Stick Voice Editor” from the Start menu (if you have a USB hub, see the note at the end of this sub-section); - The files on the voice recorder will appear in a list in the window and can be previewed to find those that are to be read into SERA. Select all the relevant files by shift-clicking or control-clicking; - Press the “Voice Recognition” button at the bottom-right corner of the window (it looks like a document with the letters “ABC” superimposed). This will launch the Dragon speech recognition software; - In the next dialogue box, choose to transcribe into “A selected window” and click the “Transcribe” button; - You will then be prompted to click in a window to receive the transcribed text. Select the SERA “Voice Recognition” window, either in the Taskbar or by clicking the window if it is visible. The text will appear in that window as it is transcribed. The transcription usually takes between 5 and 15 minutes for a modest input for a single unsafe act; - When recognition (transcription) has finished, you may use the “Save Transcript…” command in the File menu to store a copy for future reference. You also may use “Open Transcript…” to call up previously saved material; - The USB connection for the voice recorder may not be compatible with all USB hubs and in those cases must be plugged directly into a USB connection of the computer. If there is only one available connection, it will need to be shared between the PDA and the voice recorder. If that is the case, connect the PDA first and transfer the SERA file created in the field (the process is described above). Then disconnect the PDA and connect the voice recorder to carry out the audio file transcription. • **Merge Converted Text with the SERA File** - When the recognition process has finished, click the “Insert” button in the “Voice Recognition” window to instruct SERA to insert the text into the appropriate places in the report; - If SERA no section sign identifier problems are encountered, the “Voice Recognition” window will close and the text will have been inserted into the SERA file; - If errors were found in the transcribed text, the affected entries will appear in the window so that they can manually be cut and pasted into the appropriate text boxes in the SERA file. • **Optional Review of Audio Files** - Some entries may contain errors and on occasion you may need to listen to the original audio recordings to resolve discrepancies. This can be done using the “Voice Recorder Files” command; - Given the high accuracy of the speech recognition software, you may find that you use this procedure only rarely. Simply reading over the recognised text normally is sufficient to catch any errors; - To review the original audio recordings, select the “Voice Recorder Files...” item in SERA’s File menu. That will bring up a window with a list of audio files; - If the voice recorder is connected to the computer, the list will show files on that device; - Otherwise, you can specify a folder containing your audio files using the “Select Folder” button, which will invoke a standard file selection dialogue box. Navigate to the folder with your audio files and double-click any file in that folder to tell SERA where your audio files are located; - If you have inserted the transcribed text into the SERA file, the software will be able to correlate the numbered entries with the audio files containing them. The section identifier will appear in the file list in parentheses after the file name. If there were errors recognising the numerical identifiers during transcription, the parenthesised numbers may not be accurate, but will indicate the approximate location of the desired audio file; - Select a file from the list and click the “Play” button to open it in the Sony software, where it will appear in a window with standard audio playback controls; - It is common for users who are new to voice recognition to omit commands during dictation. Typical errors include not recording periods and commas, capitalisation and carriage returns. Those commands are discussed in greater detail below in the section, “Special Dictation Commands.” • **Save and Export a Report** - The SERA file is now complete and should be saved for future reference; - A report of the complete SERA file now may be exported in text form for integration with other investigation documents. III. Configuration of the SONY and Dragon Software The Sony IC Recorder allows users to record high quality audio onto a storage card (“Memory Stick”) in much the same way as a tape recorder is used. It is very compact, making it suitable for dictating notes in the field for later retrieval. Because the device has no moving parts, recordings feature less noise than those made with conventional tape recorders, and the electronic storage mechanism allows entries to be indexed and transferred to a computer easily. Audio on the computer then can be converted to editable text using voice recognition software. With the included 8 MB storage card, the recorder can store 64 minutes of audio and with a 128 MB card (the largest available), the device will record over 17 hours of material. - Installing the Sony IC Recorder Software on your PC In order to use the Sony IC Recorder with SERA, it is necessary to install the software that came with the unit. That includes the Sony Memory Stick Voice Editor for retrieving and playing back audio files stored on the device and the Dragon NaturallySpeaking software for converting recorded speech into editable text on the computer. Insert the Memory Stick Voice Editor installation CD. It should launch automatically, but if it does not, run “Setup.exe”. Follow the instructions on your screen to complete the installation. - Installing the Dragon Speech Recognition Software Next, insert the Dragon NaturallySpeaking installation CD, which will either launch automatically or you must manually run “Setup.exe”. Follow the on-screen installation instructions. Once it has been installed, the training process begins. - Training the Speech Recognition Software The voice recognition software must be trained to recognise your voice before it can be used. That process involves reading one or more passages of text into the IC Recorder for at least fifteen minutes, although reading for longer can improve the accuracy of recognition. At the end, the software will analyse the sound of your voice, correlating it with the text of the passage read. Because the software learns the characteristics of individual voices, training must be performed separately for each user of the software. Further training can be done later to improve the accuracy of recognition. First, the software will prompt you to specify a user name for your individual settings. The next window will be the “New User Wizard.” Select your language and vocabulary and for “Dictation Source,” select “Sony Memory Stick IC recorder ICD-MS Series.” The next window will present a selection of passages that may be read for training. At least one passage must be read for a minimum of 15 minutes. It is recommended that at least two passages be read as training to achieve higher accuracy. Passages must be read into the voice recorder, and it must be disconnected from the computer to do so. Press the “Rec/Rec Pause” button to begin recording and press the “Stop” button at the end. When reading a passage, do not say “comma,” “period” or any other punctuation commands. Hold the microphone on the recorder 2 to 4 inches from your mouth. When you have finished the first passage, you will be instructed to connect the voice recorder to the computer and find the file using the Memory Stick Voice Editor software. Select the file and click the “Voice Recognition” button to send the recording to the Dragon software for analysis. - **Possible Problem** Note that before the training process is complete, the online help may not be available. Full manuals for the Dragon software can be found in the “Enx” folder inside the “Docs” folder on the CD-ROM. They also are available on the Dragon website at <http://support.scansoft.com/manuals/>. - **Next Steps** Now that you have trained your Sony IC Recorder to recognise your voice, you are ready to conduct an accident investigation using SERA. You will create a SERA file, record any lengthy comments, explanations, notes, etc. into your Sony IC Recorder, merge those with the base SERA file on your PC and produce a report. To continue with that process, return to Section II above and proceed to the first step of creating a SERA file. **IV. Care and Feeding of the Sony IC Voice Recorder** - The Sony voice recorder requires 2 “AAA” alkaline batteries (do not use manganese batteries). For maximum battery performance, use high-capacity alkalines, such as “Duracell Ultra” or “Energizer e2” batteries. Batteries will last for approximately 10 hours of recording. After removing old batteries, insert new ones within three minutes in order to preserve the clock settings. It is recommended that fresh batteries be installed prior to using the recorder for a SERA investigation. More information on batteries can be found on pp. 10-11 of the Sony manual. - The voice recorder can store 999 entries in a single folder. That should be more than enough storage for the typical accident investigation. For maximum flexibility, it is recommended that the unit be cleared of audio recordings prior to initiating an investigation. V. Special Dictation Commands There are a number of commands that can be used during dictation for generating punctuation, special symbols and capitalisation. Below is a partial list and more can be found in the on-line help for the Dragon software under “Dictation.” <table> <thead> <tr> <th>To produce:</th> <th>Speak the command:</th> </tr> </thead> <tbody> <tr> <td>.</td> <td>Period</td> </tr> <tr> <td>,</td> <td>Comma</td> </tr> <tr> <td>-</td> <td>Hyphen</td> </tr> <tr> <td>/</td> <td>Slash</td> </tr> <tr> <td>“ ”</td> <td>Open quote, close quote</td> </tr> <tr> <td>’</td> <td>Apostrophe</td> </tr> <tr> <td>;</td> <td>Semi-colon</td> </tr> <tr> <td>:</td> <td>Colon</td> </tr> <tr> <td>( )</td> <td>Open parenthesis, close parenthesis</td> </tr> <tr> <td>[ ]</td> <td>Open bracket, close bracket</td> </tr> <tr> <td>@</td> <td>At sign</td> </tr> <tr> <td>?</td> <td>Question mark</td> </tr> <tr> <td>!</td> <td>Exclamation mark</td> </tr> <tr> <td>Carriage return</td> <td>New line</td> </tr> </tbody> </table> The Dragon software automatically capitalises the first letter of each sentence, with the exception of the first sentence following the section identifier. SERA automatically capitalises that during import, so it is not necessary to use any special commands for sentence capitalisation as long as you make sure to say “period” at the end of each sentence. The Dragon software will capitalise many proper names automatically, but sometimes it may be necessary to explicitly indicate that a word is capitalised using the “Cap” command (e.g., for “Air Canada,” since “air” would not be identified as a proper name). To enter all capitals, say “All-caps on” and “All-caps off” before and after the capitalised text. Abbreviations, such as “AGL,” can be entered using the “Spell mode on” and “Spell mode off” commands. Words that are not recognised by the software can be added to its vocabulary using the “View/Edit” command in the “Words” menu of the Dragon toolbar. That will allow you to enter words and optionally train them, particularly if they are not pronounced the way their spellings would suggest. Annex 2 Installing SERA on the Pocket PC Annex 2: Installing SERA on the Pocket PC The components of SERA for Pocket PC are contained in a compressed ZIP archive called “SERA_PDA.zip” that includes the following files: - SERA.jar: The SERA application as a JAR (Java archive) file - SERA: A shortcut file that enables SERA to be launched from the PDA’s Start Menu - Installation.pdf: This document containing installation instructions Part 1: Install the “Jeode” Java Runtime Software - Connect the Pocket PC to the Windows machine (i.e., a laptop or desktop computer). This requires installing the Microsoft ActiveSync software and establishing a hardware connection between the units. Follow the directions that came with the Pocket PC device. - If the device has never been synchronised, there will be a prompt to set up a partnership. If a permanent partnership is not required, select “Guest.” Otherwise, follow the directions for establishing a permanent partnership. - The “Jeode” Java runtime software is bundled with some Pocket PC devices. Check the CD-ROM that came with the unit for the Jeode installer. If it was not included with the PDA, it can be acquired from the following web site: http://www.handango.com/PlatformProductDetail.jsp?productId=59096 - From the Windows machine, launch the Jeode installer. Follow the instructions in the installer and, when prompted for the directory, choose to install it into the default directory. If the installer has been run before, it may display a prompt to remove the software. If this happens, continue with the removal and then launch the installer again to complete the installation. - After installation, there will be a standard prompt to check the mobile device for any additional instructions, but no further steps will be required on the Pocket PC. Part 2: Install the SERA Application and Shortcut - Decompress the “SERA_PDA.zip” archive and open the resulting “SERA_PDA” folder. - With the Pocket PC connected to the laptop or desktop computer (see the first and second bullets in Part 1), open “My Computer” on the Windows machine (from the Start menu or by double-clicking the desktop icon). - In the “My Computer” window, open the “Mobile Device” and then open the “My Pocket PC” folder. • Drag the SERA application ("SERA.jar") from the “SERA_PDA” folder into the “My Pocket PC” folder. • If a “File Conversion” alert appears, click “OK.” • To install the shortcut in the PDA Start Menu: In the “My Pocket PC” window (which should still be visible) open the “Windows” folder and then the “Start Menu” folder. • The “SERA_PDA” folder contains a special shortcut file called “SERA”. Drag that file into the “Start Menu” folder. • [Note that this special shortcut file includes information that runs the Jeode software at the same time SERA is launched and, because of that requirement, SERA will not run if a new shortcut is created.] • If a “File Conversion” alert appears, click “OK.” • Installation is complete and the Pocket PC can be disconnected from the computer. SERA can now be launched from the Start Menu on the Pocket PC. Note: Subsequent upgrades to SERA can be applied by performing only the first five steps of Part 2. Annex 3 Source Code Files Annex 3: SERA Source Code Files Windows and Macintosh Versions Collage.jpg • This image file contains the collage that is displayed on the splash screen. Dialogs.java • This file contains the Java code for the dialogue boxes, including the HFACS window, the help prompt, the pop-up help windows and the “save changes” prompt. Flowchart.java • This file contains the Java code necessary for the SERA Flowchart window. Main.java • This file contains the Java code that serves as the main entry point when the application is launched. MainWindow.java • This file contains the Java code necessary for the main SERA window. SERA.mcp • This is the Metrowerks CodeWarrior project file. Tab.jpg • This image file contains the graphic of the tab used for the numbered unsafe acts in the flowchart window. TabSel.jpg • This image file contains the graphic of the tab used for the currently selected unsafe act in the flowchart window. Title.jpg • This image file contains the graphic of the SERA title that is displayed above the collage on the splash screen and at the top of all subsequent screens. Tree.txt • This file contains the text of questions, conclusions and pre-conditions, as well as information on the relationships among the nodes in the SERA decision tree. Pocket PC Version Credits.jpg • This image file contains the graphic of the developer credits screen. Dialogs.java • This file contains the Java code for the dialogue boxes, including the HFACS window, the help prompt, the pop-up help windows and the “save changes” prompt. Flowchart.java • This file contains the Java code necessary for the SERA Flowchart window. Main.java • This file contains the Java code that serves as the main entry point when the application is launched. MainWindow.java • This file contains the Java code necessary for the main SERA window. SERA.bat • This is an MS-DOS batch file which compiles the Java code and builds the application. Splash.jpg • This image file contains the graphic of the splash screen. Tab.jpg • This image file contains the graphic of the tab used for the numbered unsafe acts in the flowchart window. TabSel.jpg • This image file contains the graphic of the tab used for the currently selected unsafe act in the flowchart window. Tree.txt • This file contains the text of questions, conclusions and pre-conditions, as well as information on the relationships among the nodes in the SERA decision tree. 1a. PERFORMING AGENCY Artificial Intelligence Management and Development Corporation, 206 Keewatin Avenue, Toronto, ON M4P 1Z8 CANADA 2. SECURITY CLASSIFICATION UNCLASSIFIED - Unlimited distribution - 1b. PUBLISHING AGENCY DRDC Toronto 3. TITLE (U) Extensions to the Systematic Error and Risk Analysis (SERA) Software Tool. 4. AUTHORS Jack L. Edwards 5. DATE OF PUBLICATION February 5, 2004 6. NO. OF PAGES 33 7. DESCRIPTIVE NOTES 8. SPONSORSHIP/MONITORING/CONTRACTING/ASKING AGENCY Sponsoring Agency: Monitoring Agency: Contracting Agency: DRDC Toronto Tasking Agency: 9. ORIGINATOR’S DOCUMENT NO. Contract Report CR 2004-082 10. CONTRACT, GRANT AND/OR PROJECT NO. PWGSC W7711-03-7861/001/TOR 11. OTHER DOCUMENT NOS. AC264 12. DOCUMENT RELEASABILITY Unlimited announcement 13. DOCUMENT ANNOUNCEMENT Unlimited announcement 14. ABSTRACT The Systematic Error and Risk Analysis (SERA) tool is software developed by AIMDC for DRDC Toronto and designed to step accident investigators through a systematic process of identifying factors that led to an accident and associated pre-conditions. The present contract work added new features to the SERA tool, principally the ability for investigators in the field to dictate remarks for later inclusion in a SERA report. The purpose of voice recording is to reduce the need for the more cumbersome use of a stylus to enter textual responses. Support was added to SERA that accepts text recorded on a Sony IC Voice Recorder and transcribed by the Dragon NaturallySpeaking software. The SERA software manages the insertion of the transcribed text into appropriate locations in the SERA interface. Also implemented was a feature that allows users to exclude selected items from an exported SERA report. A final addition to the software allows investigators to review their audio recordings for accuracy in the transcriptions. RÉSUMÉ [to be done]. 15. KEYWORDS, DESCRIPTORS OR IDENTIFIERS (U) HUMAN ENGINEERING TOOLS; HUMAN FACTORS ENGINEERING; SYSTEMATIC ERROR AND RISK ANALYSIS; SERA; ACCIDENT INVESTIGATION; HUMAN FACTORS ACCIDENT CLASSIFICATION SYSTEM; HFACS; AGA 135; MULTIPLE UNSAFE ACTS;; PERCEPTUAL CONTROL THEORY; IP/PCT; INTELLIGENT AIDING; TRACKING INTERFACE ACTIONS; AGENTS; AGENT TECHNOLOGY.
{"Source-Url": "https://apps.dtic.mil/dtic/tr/fulltext/u2/a609233.pdf", "len_cl100k_base": 10348, "olmocr-version": "0.1.53", "pdf-total-pages": 38, "total-fallback-pages": 0, "total-input-tokens": 62779, "total-output-tokens": 12804, "length": "2e13", "weborganizer": {"__label__adult": 0.0009245872497558594, "__label__art_design": 0.0017080307006835938, "__label__crime_law": 0.0178985595703125, "__label__education_jobs": 0.005458831787109375, "__label__entertainment": 0.0003800392150878906, "__label__fashion_beauty": 0.0002925395965576172, "__label__finance_business": 0.0013971328735351562, "__label__food_dining": 0.0004558563232421875, "__label__games": 0.002712249755859375, "__label__hardware": 0.00872039794921875, "__label__health": 0.0009050369262695312, "__label__history": 0.0009617805480957032, "__label__home_hobbies": 0.0005517005920410156, "__label__industrial": 0.004119873046875, "__label__literature": 0.0006489753723144531, "__label__politics": 0.0008244514465332031, "__label__religion": 0.0008158683776855469, "__label__science_tech": 0.07415771484375, "__label__social_life": 0.0003101825714111328, "__label__software": 0.39697265625, "__label__software_dev": 0.471435546875, "__label__sports_fitness": 0.0008077621459960938, "__label__transportation": 0.006938934326171875, "__label__travel": 0.0005097389221191406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 54590, 0.01762]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 54590, 0.38885]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 54590, 0.81262]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 294, false], [294, 2530, null], [2530, 2530, null], [2530, 4916, null], [4916, 7517, null], [7517, 11011, null], [11011, 11011, null], [11011, 11231, null], [11231, 12397, null], [12397, 14099, null], [14099, 14931, null], [14931, 17730, null], [17730, 20335, null], [20335, 21468, null], [21468, 23276, null], [23276, 24474, null], [24474, 25505, null], [25505, 28112, null], [28112, 28651, null], [28651, 28796, null], [28796, 28844, null], [28844, 30871, null], [30871, 33995, null], [33995, 36520, null], [36520, 39231, null], [39231, 39231, null], [39231, 42400, null], [42400, 44350, null], [44350, 46637, null], [46637, 46679, null], [46679, 48915, null], [48915, 49867, null], [49867, 49894, null], [49894, 51168, null], [51168, 52332, null], [52332, 53168, null], [53168, 54590, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 294, true], [294, 2530, null], [2530, 2530, null], [2530, 4916, null], [4916, 7517, null], [7517, 11011, null], [11011, 11011, null], [11011, 11231, null], [11231, 12397, null], [12397, 14099, null], [14099, 14931, null], [14931, 17730, null], [17730, 20335, null], [20335, 21468, null], [21468, 23276, null], [23276, 24474, null], [24474, 25505, null], [25505, 28112, null], [28112, 28651, null], [28651, 28796, null], [28796, 28844, null], [28844, 30871, null], [30871, 33995, null], [33995, 36520, null], [36520, 39231, null], [39231, 39231, null], [39231, 42400, null], [42400, 44350, null], [44350, 46637, null], [46637, 46679, null], [46679, 48915, null], [48915, 49867, null], [49867, 49894, null], [49894, 51168, null], [51168, 52332, null], [52332, 53168, null], [53168, 54590, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 54590, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 54590, null]], "pdf_page_numbers": [[0, 0, 1], [0, 294, 2], [294, 2530, 3], [2530, 2530, 4], [2530, 4916, 5], [4916, 7517, 6], [7517, 11011, 7], [11011, 11011, 8], [11011, 11231, 9], [11231, 12397, 10], [12397, 14099, 11], [14099, 14931, 12], [14931, 17730, 13], [17730, 20335, 14], [20335, 21468, 15], [21468, 23276, 16], [23276, 24474, 17], [24474, 25505, 18], [25505, 28112, 19], [28112, 28651, 20], [28651, 28796, 21], [28796, 28844, 22], [28844, 30871, 23], [30871, 33995, 24], [33995, 36520, 25], [36520, 39231, 26], [39231, 39231, 27], [39231, 42400, 28], [42400, 44350, 29], [44350, 46637, 30], [46637, 46679, 31], [46679, 48915, 32], [48915, 49867, 33], [49867, 49894, 34], [49894, 51168, 35], [51168, 52332, 36], [52332, 53168, 37], [53168, 54590, 38]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 54590, 0.04558]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
406b06afa274b2ddcc436382579c35320f096343
3D Slicer Documentation Slicer Community Feb 11, 2020 # Contents 1 Getting Started ........................................................................................................ 1 1.1 What is Slicer ? ...................................................................................................... 1 1.2 Hardware Requirements ....................................................................................... 1 1.3 Installing 3D Slicer ............................................................................................... 2 1.4 Further Documentation ....................................................................................... 2 1.5 User Interface Overview ...................................................................................... 2 1.6 Tutorials ............................................................................................................... 2 1.7 Modules ................................................................................................................ 3 1.8 Extensions ........................................................................................................... 3 1.9 Use Cases ............................................................................................................ 3 2 License .................................................................................................................... 5 3 Citing ....................................................................................................................... 7 3.1 3D Slicer as a Platform ......................................................................................... 7 3.2 Individual Module ............................................................................................... 8 4 Acknowledgments ................................................................................................... 9 5 Commercial Use ................................................................................................... 11 5.1 Slicer’s License makes Commercial Use Available ......................................... 11 5.2 Commercial Partners ......................................................................................... 11 5.3 Slicer Based Products ......................................................................................... 12 6 User Interface ......................................................................................................... 13 6.1 Application overview ......................................................................................... 13 6.2 Interacting with views ......................................................................................... 15 6.3 Mouse & Keyboard Shortcuts ............................................................................. 18 7 Data Loading and Saving ....................................................................................... 21 8 Modules ................................................................................................................. 25 8.1 Main modules ....................................................................................................... 25 8.2 Wizards ............................................................................................................... 25 8.3 Informatics .......................................................................................................... 26 8.4 Registration ........................................................................................................ 26 8.5 Segmentation ...................................................................................................... 26 <table> <thead> <tr> <th>Section</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>8.6 Quantification</td> <td>27</td> </tr> <tr> <td>8.7 Diffusion</td> <td>27</td> </tr> <tr> <td>8.8 IGT</td> <td>27</td> </tr> <tr> <td>8.9 Filtering</td> <td>27</td> </tr> <tr> <td>8.10 Surface models</td> <td>28</td> </tr> <tr> <td>8.11 Converters</td> <td>28</td> </tr> <tr> <td>8.12 Endoscopy</td> <td>28</td> </tr> <tr> <td>8.13 Utilities</td> <td>29</td> </tr> <tr> <td>8.14 Developer Tools</td> <td>29</td> </tr> <tr> <td>8.15 Legacy</td> <td>29</td> </tr> <tr> <td>8.16 Testing</td> <td>29</td> </tr> <tr> <td>8.17 MultiVolume Support</td> <td>30</td> </tr> <tr> <td>9 Extensions Manager</td> <td>31</td> </tr> <tr> <td>10 Settings</td> <td>33</td> </tr> <tr> <td>11 Slicer API</td> <td>35</td> </tr> <tr> <td>11.1 Python</td> <td>35</td> </tr> <tr> <td>12 Contributing to Slicer</td> <td>45</td> </tr> <tr> <td>12.1 The PR Process, Circle CI, and Related Gotchas</td> <td>45</td> </tr> <tr> <td>13 Credits</td> <td>49</td> </tr> <tr> <td>14 Indices and tables</td> <td>51</td> </tr> <tr> <td>Python Module Index</td> <td>53</td> </tr> <tr> <td>Index</td> <td>55</td> </tr> </tbody> </table> Welcome to the 3D Slicer community. Here you will learn the basics of using Slicer including installing 3D Slicer, the basics of the main application GUI, how to use Slicer and where to find tutorials and more information. 1.1 What is Slicer? 3D Slicer is: - A software platform for the analysis (including registration and interactive segmentation) and visualization (including volume rendering) of medical images and for research in image guided therapy. - A free, open source software available on multiple operating systems: Linux, MacOSX and Windows. - Extensible, with powerful plug-in capabilities for adding algorithms and applications. Features include: - Multi organ: from head to toe. - Support for multi-modality imaging including, MRI, CT, US, nuclear medicine, and microscopy. - Bidirectional interface for devices. **Important:** There is no restriction on use, but Slicer is NOT approved for clinical use and intended for research. Permissions and compliance with applicable rules are the responsibility of the user. For details on the license see here. 1.2 Hardware Requirements 3D Slicer is an open-source package that can be used on Mac, Linux and Windows. In order to run 3D Slicer your computer must have the graphics capabilities and memory to hold the original image data and process results. A 64-bit system is required. Click here more information. 1.3 Installing 3D Slicer To install Slicer, click here. Fig. 1: The Nightly version of 3D Slicer is updated nightly as groups of developers make changes. The Stable version of 3D Slicer is not updated nightly and is more rigorously tested. Once downloaded, follow the instructions below to complete installation. 1.4 Further Documentation If you’re interested in extending your knowledge, access the User Manual. See also the archives of the users mailing list. The archive is searchable so most answers to questions can be found there. If you’re a developer looking for more information, access the Developer Manual. See also archives of the developer’s mailing list. Similar to the Users Mailing List archive, it is searchable. 1.5 User Interface Overview 3D Slicer is built on a modular architecture. The Main Application GUI is divided into six components: the Application Menu Bar, the Application Toolbar, the Module GUI Panel, the Data Probe Panel, the 2D Slice Viewers, and the 3D Viewer. This section will introduce you to the basic functions on the main application’s GUI. If you require detailed information, visit this page. Open 3D Slicer and load your own data or download sample data to explore. Go ahead and click around the user interface. From the Welcome panel, you can load your own data or download sample data. Sample data is often useful for exploring the features of 3D Slicer if you don’t have data of your own. Click on the push pin in the top left corner of each of the Slice Viewers or the 3D Viewer to see more options. In the Slice Viewers, the horizontal bar can be used to scroll through slices or select a slice. You can explore the various options using your loaded data or downloaded sample data. 1.6 Tutorials The 3D Slicer documentation has an abundance of tutorials to help you familiarize yourself with the basics of 3D Slicer and with specific modules. Try the Welcome Tutorial and the Data Loading and 3D Visualization Tutorial to learn the basics of using 3D Slicer. - To learn about using Slicer for 3D Printing, visit this tutorial. - To learn about Neurosurgical Planning with Slicer, visit this tutorial. - To learn about DTI, visit this tutorial. For more tutorials, visit the Tutorial page to see a comprehensive list. Additionally, visit our YouTube page for video tutorials. If you would like to see a list of example cases with data sets and steps to achieve the same result, visit the Registration Library. 1.7 Modules 1.8 Extensions 1.9 Use Cases The 3D Slicer software is distributed under a BSD-style open source license that is compatible with the Open Source Definition by The Open Source Initiative and contains no restrictions on use of the software. To use Slicer, please read the 3D Slicer Software License Agreement before downloading any binary releases of the Slicer. CHAPTER 3 Citing 3.1 3D Slicer as a Platform To acknowledge 3D Slicer as a platform, please cite the Slicer web site and the following publications when publishing work that uses or incorporates 3D Slicer: 3.1.1 Slicer 4 3.1.2 Slicer 3 3.1.3 Slicer 2 3.2 Individual Module To acknowledge individual modules: Fig. 1: Each module has an acknowledgment tab in the top section. Information about contributors and funding source can be found there. Fig. 2: Additional information (including information about the underlying publications) can be typically found on the manual pages accessible through the help tab in the top section. CHAPTER 4 Acknowledgments We invite commercial entities to use 3D Slicer. ### 5.1 Slicer’s License makes Commercial Use Available - 3D Slicer is a Free Open Source Software distributed under a BSD style license. - The license does not impose restrictions on the use of the software. - 3D Slicer is NOT FDA approved. It is the users responsibility to ensure compliance with applicable rules and regulations. - For details, please see the 3D Slicer Software License Agreement. ### 5.2 Commercial Partners - **Isomics** uses 3D Slicer in a variety of academic and commercial research partnerships in fields such as planning and guidance for neurosurgery, quantitative imaging for clinical trials, clinical image informatics. - **Kitware** Integral to continuing to support the 3D Slicer community, Kitware is also offering consulting services in response to the rapidly growing demand for the development of proprietary applications and commercial products based on 3D Slicer. Kitware has used 3D Slicer to rapidly prototype solutions in nearly every aspect of medical imaging and is also collaborating on the development of commercial pre-clinical and clinical products based on 3D Slicer. - **Pixel Medical** builds on and contributes to 3D Slicer to develop innovative medical software from idea to clinical prototype to finished product, and to support academic research projects. Areas of expertise include radiation therapy, image guided therapy, virtual & augmented reality, hardware & device support, and machine learning & artificial intelligence. Listed in alphabetical order. 5.3 Slicer Based Products - SonoVol is developing a whole-body ultrasound imaging system for small animals. This start-up company arose from research in the Department of Biomedical Engineering at the University of North Carolina at Chapel Hill. - Xstrahl is developing a Small Animal Radiation Research Platform (SARRP) that uses 3D Slicer as its front-end application for radiation therapy beam placement and system control. Listed in alphabetical order. CHAPTER 6 User Interface 6.1 Application overview Slicer stores all loaded data in a data repository, called the “scene” (or Slicer scene or MRML scene). Each data set, such as an image volume, surface model, or point set, is represented in the scene as a “node”. Slicer provides a large number “modules”, each implementing a specific set of functions for creating or manipulating data in the scene. Modules typically do not interact with each other directly: they just all operate on the same data, which is stored in the scene. Slicer package contains over 100 built-in modules and additional modules can be installed by using the Extension Manager. 6.1.1 Module Panel This panel (located by default on the left side of the application main window) displays all the options and features that the current module offers to the user. Current module can be selected using the Module Selection toolbar. Data Probe is located at the bottom of the module panel. It displays information about view content at the position of the mouse pointer. 6.1.2 Views Slicer displays data in various views. The user can choose between a number of predefined layouts, which may contain slice, 3D, chart, and table views. The Layout Toolbar provides a drop-down menu of layouts useful for many types of studies. When Slicer is exited normally, the selected layout is saved and restored next time the application is started. 6.1.3 Application Menu • File: Functions for loading a previously saved scene or individual datasets of various types, and for downloading sample datasets from the internet. An option for saving scenes and data is also provided here. Add Data allows loading data from files. **DICOM** module is recommended to import data from DICOM files and loading of imported DICOM data. **Save** opens the “Save Data” window, which offers a variety of options for saving all data or selected datasets. - **Edit**: Contains an option for showing Application Settings, which allows users to customize appearance and behavior of Slicer, such as modules displayed in the toolbar, application font size, temporary directory location, location of additional Slicer modules to include. - **View**: Functions for showing/hiding additional windows and widgets, such as **Extension Manager** for installing extensions from Slicer app store, **Error Log** for checking if the application encountered any potential errors, **Python Interactor** for getting a Python console to interact with the loaded data or modules, **show/hide toolbars**, or **switch view layout**. ### 6.1.4 Toolbar Toolbar provides quick access to commonly used functions. Individual toolbar panels can be shown/hidden using menu: View / Toolbars section. **Module Selection** toolbar is used for selecting the currently active “module”. The toolbar provides options for searching for module names (Ctrl + f or click on magnify glass icon) or selecting from a menu. **Module history** shows the list of recently used modules. **Arrow buttons** can be used for going back to/returning from previously used module. **Favorite modules** toolbar contains a list of most frequently used modules. The list can be customized using menu: Edit / Application settings / Modules / Favorite Modules. Drag-and-drop modules from the Modules list to the Favorite Modules list to add a module. 6.1.5 Status bar This panel may display application status, such as current operation in progress. Clicking the little X icons displays the Error Log window. 6.2 Interacting with views 6.2.1 View Cross-Reference Holding down the Shift key while moving the mouse in any slice or 3D view will cause the Crosshair to move to the selected position in all views. By default, when the Crosshair is moved in any views, all slice views are scrolled to the same RAS position indexed by the mouse. This feature is useful when inspecting. To show/hide the Crosshair position, click crosshair icon . To customize behavior and appearance of the Crosshair, click the “down arrow” button on the right side of the crosshair icon. 6.2.2 Mouse Modes Slicer has two mouse modes: Transform (which allows interactive rotate, translate and zoom operations), and Place (which permits objects to be interactively placed in slice and 3D views). The toolbar icons that switch between these mouse modes are shown from left to right above, respectively. Place Fiducial is the default place option as shown above; options to place both Ruler and Region of Interest Widgets are also available from the drop-down Place Mode menu. **Note:** Transform mode is the default interaction mode. By default, Place mode persists for one “place” operation after the Place Mode icon is selected, and then the mode switches back to Transform. Place mode can be made persistent (useful for creating multiple fiducial points, rulers, etc.) by checking the Persistent checkbox shown rightmost in the Mouse Mode Toolbar. 6.2.3 3D View Displays a rendered 3D view of the scene along with visual references to specify orientation and scale. Default orientation axes: A = anterior, P = posterior, R = right, L = left, S = superior and I = inferior. 3D View Controls: The blue bar across any 3D View shows a pushpin icon on its left. When the mouse rolls over this icon, a panel for configuring the 3D View is displayed. The panel is hidden when the mouse moves away. For persistent display of this panel, just click the pushpin icon. 6.2.4 Slice View Three default slice views are provided (with Red, Yellow and Green colored bars) in which Axial, Saggital, Coronal or Oblique 2D slices of volume images can be displayed. Additional generic slice views have a grey colored bar and an identifying number in their upper left corner. Slice View Controls: The colored bar across any Slice View shows a pushpin icon on its left. When the mouse rolls over this icon, a panel for configuring the slice view is displayed. The panel is hidden when the mouse moves away. For persistent display of this panel, just click the pushpin icon. For more options, click the double-arrow icon. View Controllers module provides an alternate way of displaying these controllers in the Module Panel. 6.2.5 Chart View 6.2.6 Table View 6.3 Mouse & Keyboard Shortcuts 6.3.1 Generic shortcuts <table> <thead> <tr> <th>Shortcut</th> <th>Operation</th> </tr> </thead> <tbody> <tr> <td>Ctrl+f</td> <td>find module by name (hit Enter to select)</td> </tr> <tr> <td>Ctrl+a</td> <td>add data from file</td> </tr> <tr> <td>Ctrl+s</td> <td>save data to files</td> </tr> <tr> <td>Ctrl+w</td> <td>close scene</td> </tr> <tr> <td>Ctrl+0</td> <td>show Error Log</td> </tr> <tr> <td>Ctrl+1</td> <td>show Application Help</td> </tr> <tr> <td>Ctrl+2</td> <td>show Application Settings</td> </tr> <tr> <td>Ctrl+3</td> <td>show/hide Python Interactor</td> </tr> <tr> <td>Ctrl+4</td> <td>show Extension Manager</td> </tr> <tr> <td>Ctrl+5</td> <td>show/hide Module Panel</td> </tr> <tr> <td>Ctrl+h</td> <td>open default startup module (configurable in Application Settings)</td> </tr> </tbody> </table> 6.3.2 Slice views The following shortcuts are available when a slice view is active. To activate a view, click inside the view: if you do not want to change anything in the view, just activate it then do right-click without moving the mouse. Note that simply hovering over the mouse over a slice view will not activate the view. <table> <thead> <tr> <th>Shortcut</th> <th>Operation</th> </tr> </thead> <tbody> <tr> <td>right-click+drag up/down</td> <td>zoom image in/out</td> </tr> <tr> <td>Ctrl+mouse wheel</td> <td></td> </tr> <tr> <td>middle-click+drag</td> <td>pan (translate) view</td> </tr> <tr> <td>Shift+left-click+drag</td> <td></td> </tr> <tr> <td>left arrow/right arrow</td> <td>move to previous/next slice</td> </tr> <tr> <td>b/f</td> <td></td> </tr> <tr> <td>Shift+mouse move</td> <td>move crosshair in all views</td> </tr> <tr> <td>v</td> <td>toggle slice visibility in 3D view</td> </tr> <tr> <td>r</td> <td>reset zoom and pan to default</td> </tr> <tr> <td>g</td> <td>toggle segmentation or labelmap volume visibility</td> </tr> <tr> <td>t</td> <td>toggle foreground volume visibility</td> </tr> <tr> <td>[/]</td> <td>use previous/next volume as background</td> </tr> <tr> <td>(/)</td> <td>use previous/next volume as foreground</td> </tr> </tbody> </table> 6.3.3 3D views The following shortcuts are available when a 3D view is active. To activate a view, click inside the view: if you do not want to change anything in the view, just activate it then do right-click without moving the mouse. Note that simply hovering over the mouse over a slice view will not activate the view. ### Mouse & Keyboard Shortcuts <table> <thead> <tr> <th>Shortcut</th> <th>Operation</th> </tr> </thead> <tbody> <tr> <td>Shift + mouse move</td> <td>move crosshair in all views</td> </tr> <tr> <td>left-click + drag</td> <td>rotate view</td> </tr> <tr> <td>left arrow/right arrow</td> <td></td> </tr> <tr> <td>up arrow/down arrow</td> <td></td> </tr> <tr> <td>End or Keypad 1</td> <td>rotate to view from anterior</td> </tr> <tr> <td>Shift + End or Shift + Keypad 1</td> <td>rotate to view from posterior</td> </tr> <tr> <td>Page Down or Keypad 3</td> <td>rotate to view from left side</td> </tr> <tr> <td>Shift + Page Down Shift + Keypad 3 or</td> <td>rotate to view from right side</td> </tr> <tr> <td>Home or Keypad 7</td> <td>rotate to view from superior</td> </tr> <tr> <td>Shift + Home Shift + Keypad 7 or</td> <td>rotate to view from inferior</td> </tr> <tr> <td>right-click + drag up/down</td> <td>zoom view in/out</td> </tr> <tr> <td>Ctrl + mouse wheel</td> <td></td> </tr> <tr> <td>+/-</td> <td></td> </tr> <tr> <td>middle-click + drag</td> <td>pan (translate) view</td> </tr> <tr> <td>Shift + left-click + drag</td> <td></td> </tr> <tr> <td>Shift + left arrow/Shift + right arrow</td> <td></td> </tr> <tr> <td>Shift + up arrow/Shift + down arrow</td> <td></td> </tr> <tr> <td>Shift + Keypad 2/Shift + Keypad 4</td> <td></td> </tr> <tr> <td>Shift + Keypad 6/Shift + Keypad 8</td> <td></td> </tr> <tr> <td>Keypad 0 or Insert</td> <td>reset zoom and pan, rotate to nearest standard view</td> </tr> </tbody> </table> **Note:** Simulation of shortcuts not available on your device: - **One-button mouse:** instead of right-click do Ctrl + click - **Trackpad:** instead of right-click do two-finger click Data Loading and Saving There are two major types of data that can be loaded to Slicer: - **DICOM**, which is a widely used and sophisticated set of standards for digital radiology. DICOM data can be only loaded through the DICOM browser, after importing to the DICOM database. The DICOM browser is accessible from the toolbar using the DICOM button. More information about DICOM can be found on the Slicer wiki. - **Non-DICOM**, covering all types of data ranging from images and models to tables and point lists. - Loading can happen in two ways: drag&drop file on the Slicer window, or by using the Load Data button on the toolbar. - Saving happens with the Save Data toolbar button. Data available in Slicer can be reviewed in the Data module, which can be found on the toolbar or the modules list. More details about the module can be found on the Slicer wiki. The Data module’s default Subject hierarchy tab can show the datasets in a tree hierarchy, arranged as patient/study/series as typical in DICOM, or any other folder structure: The Subject hierarchy view contains numerous built-in functions for all types of data. These functions can be accessed by right-clicking the node in the tree. The list of actions differs for each data type, so it is useful to explore the options. Medical imaging data comes in various forms and representations, which may confuse people just starting in the field. The following diagram gives a brief overview about the most typical data types encountered when using Slicer, especially in a workflow that involves segmentation. 8.1 Main modules - module_annotations - module_data - module_datastore - module_dicom - module_editor - module_markups - module_models - module_sceneviews - module_segmentations - module_segmenteditor - module_transforms - module_viewcontrollers - module_vumerendering - module_volumes - module_welcometoslicer 8.2 Wizards - module_comparevolumes 8.3 Informatics - module_annotiations - module_colors - module_data - module_dicom - module_markups - module_sampledata - module_tables - module_terminologies 8.4 Registration - module_brainsfit - module_landmarkregistration - module_performmetrictest - module_brainsresample - module_brainsresize - module_transforms - Specialized: - module_acpctransform - module_brainsdemonwarp - module_fiducialregistration - module_reformat - module_vbrainsdemonwarp 8.5 Segmentation - module_editor - module_emsegment - module_emsegmentquick - module_segmenteditor - module_segmentstatistics - module_simpleregiongrowingsegmentation - Specialized: - module_emsegmentcommandline - module_brainsroiauto 8.6 Quantification - module_dataprobe - module_labelstatistics - module_brainslabelstats - module_petstandarduptakevaluecomputation - module_segmentstatistics 8.7 Diffusion - module_DMRIInstall - Import and export: - module_DWIConvert - Utilities: - module_BRAINSDWICleanup - module_ResampleDTIVolume - module_ResampleScalarVectorDWIVolume 8.8 IGT - module_OpenIGTLinkIF 8.9 Filtering - module_N4ITKBiasFieldCorrection - module_CheckerBoardFilter - module_ExtractSkeleton - module_HistogramMatching - module_ImageLabelCombine - module_SimpleFilters - module_ThresholdScalarVolume - module_VotingBinaryHoleFillingImageFilter - module_IslandRemoval - Arithmetic: - module_AddScalarVolumes – module_CastScalarVolume – module_MaskScalarVolume – module_MultiplyScalarVolumes – module_SubtractScalarVolumes • Denoising: – module_GradientAnisotropicDiffusion – module_CurvatureAnisotropicDiffusion – module_GaussianBlurImageFilter – module_MedianImageFilter • Morphology: – module_GrayscaleFillHoleImageFilter – module_GrayscaleGrindPeakImageFilter ### 8.10 Surface models • module_GrayscaleModelMaker • module_LabelMapSmoothing • module_MergeModels • module_ModelMaker • module_ModelToLabelMap • module_ProbeVolumeWithModel • module_SurfaceToolbox ### 8.11 Converters • module_CreateDICOMSeries • module_CropVolume • module_OrientScalarVolume • module_VectorToScalarVolume ### 8.12 Endoscopy • module_Endoscopy 8.13 Utilities - module_BRAINSStripRotation - module_DataStore - module_dicompatcher - module_ScreenCapture - module_EMSegmentTransformToNewFormat - BRAINS: - module_BRAINSTransformConvert 8.14 Developer Tools - module_Cameras - module_EventBroker - module_ExecutionModelTour - module_ExtensionWizard - DICOM plugins: - module_DICOMDiffusionVolumePlugin - module_DICOMScalarVolumePlugin 8.15 Legacy - Converters: - module_BSplineToDeformationField - Filtering: - module_OtsuThresholdImageFilter - module_ResampleScalarVolume - Registration: - module_ExpertAutomatedRegistration 8.16 Testing - module_PerformanceTests - module_SelfTests 8.17 MultiVolume Support - module_MultiVolumeImporter - module_MultiVolumeExplorer CHAPTER 9 Extensions Manager CHAPTER 11 Slicer API 11.1 Python 11.1.1 freesurfer module 11.1.2 mrml module 11.1.3 saferef module “Safe weakrefs”, originally from pyDispatcher. Provides a way to safely weakref any function, including bound methods (which aren’t handled by the core weakref module). ```python class saferef.BoundMethodWeakref(target, onDelete=None): Bases: object ‘Safe’ and reusable weak references to instance methods BoundMethodWeakref objects provide a mechanism for referencing a bound method without requiring that the method object itself (which is normally a transient object) is kept alive. Instead, the BoundMethodWeakref object keeps weak references to both the object and the function which together define the instance method. Attributes: key – the identity key for the reference, calculated by the class’s calculateKey method applied to the target instance method deletionMethods – sequence of callable objects taking single argument, a reference to this object which will be called when either the target object or target function is garbage collected (i.e. when this object becomes invalid). These are specified as the onDelete parameters of safeRef calls. weakSelf – weak reference to the target object weakFunc – weak reference to the target function Class Attributes: ``` _allInstances – class attribute pointing to all live BoundMethodWeakref objects indexed by the class’s calculateKey(target) method applied to the target objects. This weak value dictionary is used to short- circuit creation so that multiple references to the same (object, function) pair produce the same Bound- MethodWeakref instance. classmethod calculateKey (target) Calculate the reference key for this reference Currently this is a two-tuple of the id()’s of the target object and the target function respectively. class saferef.BoundNonDescriptorMethodWeakref (target, onDelete=None) Bases: saferef.BoundMethodWeakref A specialized BoundMethodWeakref, for platforms where instance methods are not descriptors. It assumes that the function name and the target attribute name are the same, instead of assuming that the function is a descriptor. This approach is equally fast, but not 100% reliable because functions can be stored on an attribute named differently than the function’s name such as in: class A: pass def foo(self): return “foo” A.bar = foo But this shouldn’t be a common use case. So, on platforms where methods aren’t descriptors (such as Jython) this implementation has the advantage of working in the most cases. saferef.get_bound_method_weakref (target, onDelete) Instantiates the appropriate BoundMethodWeakRef, depending on the details of the underlying class method implementation saferef.safeRef (target, onDelete=None) Return a safe weak reference to a callable target target – the object to be weakly referenced, if it’s a bound method reference, will create a BoundMethod- Weakref, otherwise creates a simple weakref. onDelete – if provided, will have a hard reference stored to the callable to be called after the safe reference goes out of scope with the reference object, (either a weakref or a BoundMethodWeakref) as argument. 11.1.4 slicer package Submodules slicer.ScriptedLoadableModule module slicer.clin module This module is a place holder for convenient functions allowing to interact with CLI. slicer.clin.cancel (node) slicer.clin.createNode (cliModule, parameters=None) Creates a new vtkMRMLCommandLineModuleNode for a specific module, with optional parameters slicer.clin.run (module, node=None, parameters=None, wait_for_completion=False, delete_temporary_files=True, update_display=True) Runs a CLI, optionally given a node with optional parameters, returning back the node (or the new one if created) node: existing parameter node (None by default) parameters: dictionary of parameters for cli (None by default) wait_for_completion: block if True (False by default) delete_temporary_files: remove temp files created during exectuion (True by default) update_display: show output nodes after completion slicer.cli.runSync(module, node=None, parameters=None, delete_temporary_files=True, update_display=True) Run a CLI synchronously, optionally given a node with optional parameters, returning the node (or the new one if created) node: existing parameter node (None by default) parameters: dictionary of parameters for cli (None by default) delete_temporary_files: remove temp files created during execution (True by default) update_display: show output nodes after completion slicer.cli.setNodeParameters(node, parameters) Sets parameters for a vtkMRMLCommandLineModuleNode given a dictionary of (parameterName, parameterValue) pairs For vectors: provide a list, tuple or comma-separated string For enumerations, provide the single enumeration value For files and directories, provide a string For images, geometry, points and regions, provide a vtkMRMLNode slicer.logic module slicer.slicerqt-with-tcl module slicer.slicerqt module slicer.testing module slicer.testing.exitFailure(message="") slicer.testing.exitSuccess() slicer.testing.runUnitTest(path, testname) slicer.util module exception slicer.util.MRMLNodeNotFoundException Bases: exceptions.Exception Exception raised when a requested MRML node was not found. class slicer.util.NodeModify(node) Context manager to conveniently compress mrml node modified event. class slicer.util.VTKObservationMixin Bases: object addObserver(object, event, method, group='none') hasObserver(object, event, method) observer(event, method) removeObserver(object, event, method) removeObservers(method=None) slicer.util.array(pattern="", index=0) Return the array you are “most likely to want” from the indexth MRML node that matches the pattern. Meant to be used in the python console for quick debugging/testing. More specific API should be used in scripts to be sure you get exactly what you want, such as arrayFromVolume, arrayFromModelPoints, and arrayFromGrid-Transform. slicer.util.arrayFromGridTransform(gridTransformNode) Return voxel array from transform node as numpy array. Vector values are not copied. Values in the transform node can be modified by changing values in the numpy array. After all modifications has been completed, call gridTransformNode.Modified(). **Warning:** Important: memory area of the returned array is managed by VTK, therefore values in the array may be changed, but the array must not be reallocated. See `arrayFromVolume()` for details. `slicer.util.arrayFromModelPoints(modelNode)` Return point positions of a model node as numpy array. Voxels values in the volume node can be modified by modifying the numpy array. After all modifications has been completed, call modelNode.Modified(). **Warning:** Important: memory area of the returned array is managed by VTK, therefore values in the array may be changed, but the array must not be reallocated. See `arrayFromVolume()` for details. `slicer.util.arrayFromSegment(segmentationNode, segmentId)` Return voxel array of a segment’s binary labelmap representation as numpy array. Voxels values are not copied. If binary labelmap is the master representation then voxel values in the volume node can be modified by changing values in the numpy array. After all modifications has been completed, call: segmentationNode.GetSegmentation().GetSegment(segmentID).Modified() **Warning:** Important: memory area of the returned array is managed by VTK, therefore values in the array may be changed, but the array must not be reallocated. See `arrayFromVolume()` for details. `slicer.util.arrayFromVolume(volumeNode)` Return voxel array from volume node as numpy array. Voxels values are not copied. Voxel values in the volume node can be modified by changing values in the numpy array. After all modifications has been completed, call volumeNode.Modified(). **Warning:** Memory area of the returned array is managed by VTK, therefore values in the array may be changed, but the array must not be reallocated (change array size, shallow-copy content from other array most likely causes application crash). To allow arbitrary numpy operations on a volume array: 1. Make a deep-copy of the returned VTK-managed array using `numpy.copy()`. 2. Perform any computations using the copied array. 3. Write results back to the image data using `updateVolumeFromArray()`. `slicer.util.clickAndDrag(widget, button='Left', start=(10, 10), end=(10, 40), steps=20, modifiers=[])` Send synthetic mouse events to the specified widget (qMRMLSliceWidget or qMRMLThreeDView) button : “Left”, “Middle”, “Right”, or “None” start, end : window coordinates for action steps : number of steps to move in, if <2 then mouse jumps to the end position modifiers : list containing zero or more of “Shift” or “Control” Hint: for generating test data you can use this snippet of code: ```python layoutManager = slicer.app.layoutManager() threeDView = layoutManager.threeDWidget(0).threeDView() style = threeDView.interactorStyle() interactor = style.GetInteractor() def onClick(caller,event): print(interactor.GetEventPosition()) interactor.AddObserver(vtk.vtkCommand.LeftButtonPressEvent, onClick) ``` 38 Chapter 11. Slicer API slicer.util.confirmOkCancelDisplay (text, windowTitle=None, parent=None, **kwargs) Display an confirmation popup. Return if confirmed with OK. slicer.util.confirmRetryCloseDisplay (text, windowTitle=None, parent=None, **kwargs) Display an confirmation popup. Return if confirmed with Retry. slicer.util.confirmYesNoDisplay (text, windowTitle=None, parent=None, **kwargs) Display an confirmation popup. Return if confirmed with Yes. slicer.util.createProgressDialog (parent=None, value=0, maximum=100, labelText='', windowTitle='Processing... ', **kwargs) Display a modal QProgressDialog. Go to QProgressDialog documentation http://pyqt.sourceforge.net/Docs/PyQt4/qProgressDialog.html for more keyword arguments, that could be used. E.g. progressbar = createProgressIndicator(autoClose=False) if you don’t want the progress dialog to automatically close. Updating progress value with progressbar.value = 50 Updating label text with progressbar.labelText = “processing XYZ” slicer.util.delayDisplay (message, autoCloseMsec=1000) Display an information message in a popup window for a short time. If autoCloseMsec>0 then the window is closed after waiting for autoCloseMsec milliseconds If autoCloseMsec=0 then the window is not closed until the user clicks on it. slicer.util.downloadAndExtractArchive (url, archiveFilePath, outputDir, expectedNumberOfExtractedFiles=None, numberOfTrials=3) Downloads an archive from url as archiveFilePath, and extracts it to outputDir. This combined function tests the success of the download by the extraction step, and re-downloads if extraction failed. slicer.util.downloadFile (url, targetFilePath) Download url to local storage as targetFilePath Target file path needs to indicate the file name and extension as well slicer.util.errorDisplay (text, windowTitle=None, parent=None, standardButtons=None, **kwargs) Display an error popup. slicer.util.exit (status=0) slicer.util.extractArchive (archiveFilePath, outputDir, expectedNumberOfExtractedFiles=None) Extract file archiveFilePath into folder outputDir. Number of expected files unzipped may be specified in expectedNumberOfExtractedFiles. If folder contains the same number of files as expected (if specified), then it will be assumed that unzipping has been successfully done earlier. slicer.util.findChild (widget, name) Convenience method to access a widget by its name. A RuntimeError exception is raised if the widget with the given name does not exist. slicer.util.findChildren (widget=None, name='', text='', title='', className='') Return a list of child widgets that meet all the given criteria. If no criteria are provided, the function will return all widgets descendants. If no widget is provided, slicer.util.mainWindow() is used. :param widget: parent widget where the widgets will be searched :param name: name attribute of the widget :param text: text attribute of the widget :param title: title attribute of the widget :param className: className() attribute of the widget :return: list with all the widgets that meet all the given criteria. slicer.util.getFilesInDirectory (directory, absolutePath=True) Collect all files in a directory and its subdirectories in a list slicer.util.getFirstNodeByClassByName (className, name, scene=None) Return the first node in the scene that matches the specified node name and node class. 11.1. Python slicer.util.getFirstNodeByName(name, className=None) Get the first MRML node that name starts with the specified name. Optionally specify a classname that must also match. slicer.util.getModule(moduleName) slicer.util.getModuleGui(module) slicer.util.getNewModuleGui(module) slicer.util.getNode(pattern='*', index=0, scene=None) Return the indexth node where name or id matches pattern. By default, pattern is a wildcard and it returns the first node associated with slicer.mrmlScene. Throws MRMLNodeNotFoundException exception if no node is found that matches the specified pattern. slicer.util.getNodes(pattern='*', scene=None, useLists=False) Return a dictionary of nodes where the name or id matches the pattern. By default, pattern is a wildcard and it returns all nodes associated with slicer.mrmlScene. If multiple node share the same name, using useLists=False (default behavior) returns only the last node with that name. If useLists=True, it returns a dictionary of lists of nodes. slicer.util.getNodesByClass(className, scene=None) Return all nodes in the scene of the specified class. slicer.util.importClassesFromDirectory(directory, dest_module_name, type_info, filematch='*') slicer.util.importModuleObjects(from_module_name, dest_module_name, type_info) Import object of type ‘type_info’ (str or type) from module identified by ‘from_module_name’ into the module identified by ‘dest_module_name’. slicer.util.importQtClassesFromDirectory(directory, dest_module_name, filematch='*') slicer.util.importVTKClassesFromDirectory(directory, dest_module_name, filematch='*') slicer.util.infoDisplay(text, windowTitle=None, parent=None, standardButtons=None, **kwargs) Display popup with a info message. slicer.util.loadAnnotationFiducial(filename, returnNode=False) slicer.util.loadAnnotationROI(filename, returnNode=False) slicer.util.loadAnnotationRuler(filename, returnNode=False) slicer.util.loadColorTable(filename, returnNode=False) slicer.util.loadFiberBundle(filename, returnNode=False) slicer.util.loadFiducialList(filename, returnNode=False) slicer.util.loadLabelVolume(filename, properties={}, returnNode=False) slicer.util.loadMarkupsFiducialList(filename, returnNode=False) slicer.util.loadModel(filename, returnNode=False) slicer.util.loadNodeFromFile(filename, filetype, properties={}, returnNode=False) slicer.util.loadScalarOverlay(filename, returnNode=False) slicer.util.loadScene(filename, properties={}) slicer.util.loadSegmentation(filename, returnNode=False) slicer.util.loadTransform(filename, returnNode=False) slicer.util.loadUI(path) Load UI file path and return the corresponding widget. Raises a RuntimeError exception if the UI file is not found or if no widget was instantiated. slicer.util.loadVolume(filename, properties={}, returnNode=False) Properties: - name: this name will be used as node name for the loaded volume - labelmap: interpret volume as labelmap - singleFile: ignore all other files in the directory - center: ignore image position - discardOrientation: ignore image axis directions - autoWindowLevel: compute window/level automatically - show: display volume in slice viewers after loading is completed - fileNames: list of filenames to load the volume from slicer.util.lookupTopLevelWidget(objectName, verbose=True) Loop over all top level widget associated with ‘slicer.app’ and return the one matching ‘objectName’ slicer.util.mainWindow(verbos=True) slicer.util.messageBox(text, parent=None, **kwargs) Displays a messagebox. ctkMessageBox is used instead of a default qMessageBox to provide “Don’t show again” checkbox. For example: slicer.util.messageBox(“Some message”, dontShowAgainSettingsKey = “MainWindow/DontShowSomeMessage”) slicer.util.moduleNames() slicer.util.modulePath(moduleName) slicer.util.moduleSelector() slicer.util.openAddColorTableDialog() slicer.util.openAddDataDialog() slicer.util.openAddFiberBundleDialog() slicer.util.openAddFiducialDialog() slicer.util.openAddModelDialog() slicer.util.openAddScalarOverlayDialog() slicer.util.openAddSegmentationDialog() slicer.util.openAddTransformDialog() slicer.util.openAddVolumeDialog() slicer.util.openSaveDataDialog() slicer.util.pythonShell(verbos=True) slicer.util.quit() slicer.util.reloadScriptedModule(moduleName) Generic reload method for any scripted module. slicer.util.resetSliceViews() Reset focal view around volumes slicer.util.resetThreeDViews() Reset focal view around volumes slicer.util.restart() slicer.util.saveNode(node, filename, properties={}) Save ‘node’ data into ‘filename’. It is the user responsability to provide the appropriate file extension. User has also the possibility to overwrite the fileType internally retrieved using method 'qSlicerCoreIOMan- ger::fileWriterFileType(vtkObject*)'. This can be done by specifying a 'fileType' attribute to the optional 'properties' dictionary. slicer.util.saveScene(filename, properties={}) Save the current scene. Based on the value of 'filename', the current scene is saved either as a MRML file, MRB file or directory. If filename ends with '.mrml', the scene is saved as a single file without associated data. If filename ends with '.mrb', the scene is saved as a MRML bundle (Zip archive with scene and data files). In every other case, the scene is saved in the directory specified by 'filename'. Both MRML scene file and data will be written to disk. If needed, directories and sub-directories will be created. slicer.util.selectModule(module) slicer.util.selectedModule() slicer.util.setSliceViewerLayers(background='keep-current', foreground='keep-current', label='keep-current', foregroundOpacity=None, labelOpacity=None) Set the slice views with the given nodes. If node ID is not specified (or value is 'keep-current') then the layer will not be modified. : param background: node or node ID to be used for the background layer : param foreground: node or node ID to be used for the foreground layer : param label: node or node ID to be used for the label layer : param foregroundOpacity: opacity of the foreground layer : param labelOpacity: opacity of the label layer slicer.util.settingsValue(key, default, converter=<function <lambda>>, settings=None) Return settings value associated with key if it exists or the provided default otherwise. settings parameter is expected to be a valid qt.Settings object. slicer.util.showStatusMessage(message, duration=0) slicer.util.sourceDir() Location of the Slicer source directory. Type str or None This provides the location of the Slicer source directory, if Slicer is being run from a CMake build directory. If the Slicer home directory does not contain a CMakeCache.txt (e.g. for an installed Slicer), the property will have the value None. slicer.util.startupEnvironment() Returns the environment without the Slicer specific values. Path environment variables like PATH, LD_LIBRARY_PATH or PYTHONPATH will not contain values found in the launcher settings. Similarly key=value environment variables also found in the launcher settings are excluded. Note that if a value was associated with a key prior starting Slicer, it will not be set in the environment returned by this function. The function excludes both the Slicer launcher settings and the revision specific launcher settings. slicer.util.tempDirectory(key='__SlicerTemp__', tempDir=None, includeDateTime=True) Come up with a unique directory name in the temp dir and make it and return it # TODO: switch to QTemporaryDir in Qt5. Note: this directory is not automatically cleaned up slicer.util.toBool(value) Convert any type of value to a boolean. The function uses the following heuristic: 1) If the value can be converted to an integer, the integer is then converted to a boolean. 2) If the value is a string, return True if it is equal to 'true'. False otherwise. Note that the comparison is case insensitive. 3) If the value is neither an integer or a string, the bool() function is applied. ```python >>> [toBool(x) for x in range(-2, 2)] [True, True, False, True] >>> [toBool(x) for x in ['-2', '-1', '0', '1', '2', 'Hello']] [True, True, False, True, True, False] >>> toBool(object()) True >>> toBool(None) False ``` `slicer.util.toVTKString(str)` Convert unicode string into 8-bit encoded ascii string. Unicode characters without ascii equivalent will be stripped out. `slicer.util.unicodeify(s)` `slicer.util.updateTableFromArray(tableNode, narrays)` Sets values in a table node from a numpy array. Values are copied, therefore if the numpy array is modified after calling this method, values in the table node will not change. Example: ```python import numpy as np histogram = np.histogram(arrayFromVolume(getNode('MRHead'))) tableNode = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLTableNode") updateTableFromArray(tableNode, histogram) ``` `slicer.util.updateVolumeFromArray(volumeNode, narray)` Sets voxels of a volume node from a numpy array. Voxels values are deep-copied, therefore if the numpy array is modified after calling this method, voxel values in the volume node will not change. Dimensions and data size of the source numpy array does not have to match the current content of the volume node. `slicer.util.warningDisplay(text, windowTitle=None, parent=None, standardButtons=None, **kwargs)` Display popup with a warning message. **Module contents** This module sets up root logging and loads the Slicer library modules into its namespace. 11.1.5 teem module 11.1.6 vtkAddon module 11.1.7 vtkITK module There are many ways to contribute to Slicer, with varying levels of effort. Do try to look through the documentation first if something is unclear, and let us know how we can do better. - Ask a question on the slicer-devel email list - Submit a feature request or bug, or add to the discussion on the Slicer issue tracker - Submit a Pull Request to improve Slicer or its documentation We encourage a range of Pull Requests, from patches that include passing tests and documentation, all the way down to half-baked ideas that launch discussions. 12.1 The PR Process, Circle CI, and Related Gotchas 12.1.1 How to submit a PR? If you are new to Slicer development and you don’t have push access to the Slicer repository, here are the steps: 1. Fork and clone the repository. 2. Create a branch. 3. Push the branch to your GitHub fork. 4. Create a Pull Request. This corresponds to the Fork & Pull Model mentioned in the GitHub flow guides. When submitting a PR, the developers following the project will be notified. That said, to engage specific developers, you can add Cc: @<username> comment to notify them of your awesome contributions. Based on the comments posted by the reviewers, you may have to revisit your patches. 12.1.2 How to efficiently contribute? We encourage all developers to: - Review and follow the style guidelines described on the wiki. - Add or update tests. There are plenty of existing tests to inspire from. The testing how-tos are also resourceful. • consider potential backward compatibility breakage and discuss these on the mailing list. For example, update of ITK, Python, Qt or VTK version, change to core functionality, should be carefully reviewed and integrated. Ideally, several developers would test that the changes don’t break extensions. 12.1.3 How to integrate a PR? Getting your contributions integrated is relatively straightforward, here is the checklist: • All tests pass • Consensus is reached. This usually means that at least two reviewers approved the changes (or added a LGTM comment) and at least one business day passed without anyone objecting. LGTM is an acronym for Looks Good to Me. • To accommodate developers explicitly asking for more time to test the proposed changes, integration time can be delayed by few more days. Next, there are two scenarios: • You do NOT have push access: A Slicer core developer will integrate your PR. If you would like to speed up the integration, do not hesitate to send a note on the mailing list. • You have push access: Follow Integrating topic from external contributor instructions on the wiki. 12.1.4 Automatic testing of pull requests Every pull request is tested automatically using CircleCI each time you push a commit to it. The Github UI will restrict users from merging pull requests until the CI build has returned with a successful result indicating that all tests have passed. The testing infrastructure is described in details in the 3D Slicer Improves Testing for Pull Requests Using Docker and CircleCI blog post. 12.1.5 Nightly tests After changes are integrated, every evening at 10pm EST (3am UTC), Slicer build bots (aka factories) will build, test and package Slicer application and all its extensions on Linux, MacOSX and Windows. Results are published daily on CDash and developers introducing changes introducing build or test failures are notified by email. 12.1.6 Decision-making process 1. Given the topic of interest, initiate discussion on the mailing list. 2. Identify a small circle of community members that are interested to study the topic in more depth. 3. Take the discussion off the general list, work on the analysis of options and alternatives, summarize findings on the wiki or similar. Labs page are usually a good ground for such summary. 4. Announce on the mailing list the in-depth discussion of the topic for the Slicer Community hangout, encourage anyone that is interested in weighing in on the topic to join the discussion. If there is someone who is interested to participate in the discussion, but cannot join the meeting due to conflict, they should notify the leaders of the given project and identify the time suitable for everyone. 5. Hopefully, reach consensus at the hangout and proceed with the agreed plan. The initial version of these guidelines was established during the [winter project week 2017](http://www.namic.org/Wiki/index.php/2017_Winter_Project_Week/UpdatingCommunityForums). 12.1.7 Benevolent dictators for life The benevolent dictators can integrate changes to keep the platform healthy and help interpret or address conflict related to the contribution guidelines. These currently include: - Jean-Christophe Fillion-Robin - Andras Lasso - Steve Pieper Alphabetically ordered by last name. The Slicer community is inclusive and welcome anyone to work to become a core developer and then a BDFL. This happens with hard work and approval of the existing BDFL. CHAPTER 13 Credits Please see the GitHub project page at https://github.com/Slicer/Slicer/graphs/contributors CHAPTER 14 Indices and tables - genindex - modindex - search S saferef, 35 slicer, 43 slicer.cli, 36 slicer.testing, 37 slicer.util, 37 <table> <thead> <tr> <th>A</th> <th>addObserver() (slicer.util.VTKObservationMixin method), 37</th> </tr> </thead> <tbody> <tr> <td></td> <td>array() (in module slicer.util), 37</td> </tr> <tr> <td></td> <td>arrayFromGridTransform() (in module slicer.util), 37</td> </tr> <tr> <td></td> <td>arrayFromModelPoints() (in module slicer.util), 38</td> </tr> <tr> <td></td> <td>arrayFromSegment() (in module slicer.util), 38</td> </tr> <tr> <td></td> <td>arrayFromVolume() (in module slicer.util), 38</td> </tr> <tr> <td>B</td> <td>BoundMethodWeakref (class in saferef), 35</td> </tr> <tr> <td></td> <td>BoundNonDescriptorMethodWeakref (class in saferef), 36</td> </tr> <tr> <td>C</td> <td>calculateKey() (saferef.BoundMethodWeakref class method), 36</td> </tr> <tr> <td></td> <td>cancel() (in module slicer.cli), 36</td> </tr> <tr> <td></td> <td>clickAndDrag() (in module slicer.util), 38</td> </tr> <tr> <td></td> <td>confirmOKCancelDisplay() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>confirmRetryCloseDisplay() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>confirmYesNoDisplay() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>createNode() (in module slicer.cli), 36</td> </tr> <tr> <td></td> <td>createProgressDialog() (in module slicer.util), 39</td> </tr> <tr> <td>D</td> <td>delayDisplay() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>downloadAndExtractArchive() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>downloadFile() (in module slicer.util), 39</td> </tr> <tr> <td>E</td> <td>errorDisplay() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>exit() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>exitFailure() (in module slicer.testing), 37</td> </tr> <tr> <td></td> <td>exitSuccess() (in module slicer.testing), 37</td> </tr> <tr> <td></td> <td>extractArchive() (in module slicer.util), 39</td> </tr> <tr> <td>F</td> <td>findChild() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>findChildren() (in module slicer.util), 39</td> </tr> <tr> <td>G</td> <td>get_bound_method_weakref() (in module saferef), 36</td> </tr> <tr> <td></td> <td>getFilesInDirectory() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>getFirstNodeByClassByName() (in module slicer.util), 39</td> </tr> <tr> <td></td> <td>getModule() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>getModuleGui() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>getNewModuleGui() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>getNode() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>getNodes() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>getNodesByClass() (in module slicer.util), 40</td> </tr> <tr> <td>H</td> <td>hasObserver() (slicer.util.VTKObservationMixin method), 37</td> </tr> <tr> <td>I</td> <td>importClassesFromDirectory() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>importModuleObjects() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>importQtClassesFromDirectory() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>importVTKClassesFromDirectory() (in module slicer.util), 40</td> </tr> <tr> <td></td> <td>infoDisplay() (in module slicer.util), 40</td> </tr> <tr> <td>L</td> <td>loadAnnotationFiducial() (in module slicer.util), 40</td> </tr> </tbody> </table> loadAnnotationROI() (in module slicer.util), 40 loadAnnotationRuler() (in module slicer.util), 40 loadColorTable() (in module slicer.util), 40 loadFiberBundle() (in module slicer.util), 40 loadFiducialList() (in module slicer.util), 40 loadLabelVolume() (in module slicer.util), 40 loadMarkupsFiducialList() (in module slicer.util), 40 loadModel() (in module slicer.util), 40 loadNodeFromFile() (in module slicer.util), 40 loadScalarOverlay() (in module slicer.util), 40 loadScene() (in module slicer.util), 40 loadSegmentation() (in module slicer.util), 40 loadTransform() (in module slicer.util), 40 loadUI() (in module slicer.util), 40 loadVolume() (in module slicer.util), 40 lookupTopLevelWidget() (in module slicer.util), 41 MainWindow() (in module slicer.util), 41 messageBox() (in module slicer.util), 41 moduleNames() (in module slicer.util), 41 modulePath() (in module slicer.util), 41 moduleSelector() (in module slicer.util), 41 MRMLNodeNotFoundException, 37 Observer (class in slicer.util), 37 openAddColorTableDialog() (in module slicer.util), 41 openAddDataDialog() (in module slicer.util), 41 openAddFiberBundleDialog() (in module slicer.util), 41 openAddFiducialDialog() (in module slicer.util), 41 openAddModelDialog() (in module slicer.util), 41 openAddScalarOverlayDialog() (in module slicer.util), 41 openAddSegmentationDialog() (in module slicer.util), 41 openAddTransformDialog() (in module slicer.util), 41 openAddVolumeDialog() (in module slicer.util), 41 openSaveDataDialog() (in module slicer.util), 41 pythonShell() (in module slicer.util), 41 quit() (in module slicer.util), 41 reloadScriptedModule() (in module slicer.util), 41 removeObserver() (slicer.util.VTKObservationMixin method), 37 removeObservers() (slicer.util.VTKObservationMixin method), 37 resetSliceViews() (in module slicer.util), 41 resetThreeDViews() (in module slicer.util), 41 restart() (in module slicer.util), 41 run() (in module slicer.cli), 36 runSync() (in module slicer.cli), 36 runUnitTest() (in module slicer.testing), 37 saferef (module), 35 safeRef() (in module saferef), 36 saveNode() (in module slicer.util), 41 saveScene() (in module slicer.util), 42 selectedModule() (in module slicer.util), 42 selectModule() (in module slicer.util), 42 setNodeParameters() (in module slicer.cli), 37 setSliceViewerLayers() (in module slicer.util), 42 settingsValue() (in module slicer.util), 42 showStatusMessage() (in module slicer.util), 42 slicer (module), 43 slicer.cli (module), 36 slicer.testing (module), 37 slicer.util (module), 37 sourceDir() (in module slicer.util), 42 startupEnvironment() (in module slicer.util), 42 tempDirectory() (in module slicer.util), 42 toBool() (in module slicer.util), 42 toVTKString() (in module slicer.util), 43 unicodeify() (in module slicer.util), 43 updateTableFromArray() (in module slicer.util), 43 updateVolumeFromArray() (in module slicer.util), 43 VTKObservationMixin (class in slicer.util), 37 warningDisplay() (in module slicer.util), 43
{"Source-Url": "https://buildmedia.readthedocs.org/media/pdf/slicer/latest/slicer.pdf", "len_cl100k_base": 14400, "olmocr-version": "0.1.53", "pdf-total-pages": 60, "total-fallback-pages": 0, "total-input-tokens": 105240, "total-output-tokens": 16678, "length": "2e13", "weborganizer": {"__label__adult": 0.00030875205993652344, "__label__art_design": 0.0008249282836914062, "__label__crime_law": 0.00016546249389648438, "__label__education_jobs": 0.0004303455352783203, "__label__entertainment": 8.255243301391602e-05, "__label__fashion_beauty": 0.00013720989227294922, "__label__finance_business": 0.00012576580047607422, "__label__food_dining": 0.00029778480529785156, "__label__games": 0.0009183883666992188, "__label__hardware": 0.0014553070068359375, "__label__health": 0.00044655799865722656, "__label__history": 0.00018417835235595703, "__label__home_hobbies": 0.0001277923583984375, "__label__industrial": 0.0002529621124267578, "__label__literature": 0.00011920928955078124, "__label__politics": 9.763240814208984e-05, "__label__religion": 0.00033164024353027344, "__label__science_tech": 0.0134429931640625, "__label__social_life": 8.177757263183594e-05, "__label__software": 0.03326416015625, "__label__software_dev": 0.9462890625, "__label__sports_fitness": 0.0003077983856201172, "__label__transportation": 0.00021159648895263672, "__label__travel": 0.00015878677368164062}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 61450, 0.02812]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 61450, 0.22951]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 61450, 0.63271]], "google_gemma-3-12b-it_contains_pii": [[0, 56, false], [56, 56, null], [56, 3779, null], [3779, 4830, null], [4830, 6212, null], [6212, 8689, null], [8689, 8732, null], [8732, 8732, null], [8732, 9065, null], [9065, 9065, null], [9065, 10672, null], [10672, 11052, null], [11052, 11079, null], [11079, 11079, null], [11079, 12644, null], [12644, 13103, null], [13103, 14769, null], [14769, 16452, null], [16452, 18264, null], [18264, 18848, null], [18848, 19296, null], [19296, 21151, null], [21151, 23255, null], [23255, 23255, null], [23255, 24306, null], [24306, 24834, null], [24834, 24834, null], [24834, 24834, null], [24834, 25184, null], [25184, 25893, null], [25893, 26597, null], [26597, 27335, null], [27335, 27992, null], [27992, 28076, null], [28076, 28106, null], [28106, 28106, null], [28106, 28106, null], [28106, 28106, null], [28106, 29435, null], [29435, 32207, null], [32207, 34313, null], [34313, 37367, null], [37367, 40732, null], [40732, 43301, null], [43301, 45383, null], [45383, 48714, null], [48714, 50560, null], [50560, 50560, null], [50560, 52045, null], [52045, 55026, null], [55026, 55515, null], [55515, 55515, null], [55515, 55627, null], [55627, 55627, null], [55627, 55690, null], [55690, 55690, null], [55690, 55765, null], [55765, 55765, null], [55765, 58465, null], [58465, 61450, null]], "google_gemma-3-12b-it_is_public_document": [[0, 56, true], [56, 56, null], [56, 3779, null], [3779, 4830, null], [4830, 6212, null], [6212, 8689, null], [8689, 8732, null], [8732, 8732, null], [8732, 9065, null], [9065, 9065, null], [9065, 10672, null], [10672, 11052, null], [11052, 11079, null], [11079, 11079, null], [11079, 12644, null], [12644, 13103, null], [13103, 14769, null], [14769, 16452, null], [16452, 18264, null], [18264, 18848, null], [18848, 19296, null], [19296, 21151, null], [21151, 23255, null], [23255, 23255, null], [23255, 24306, null], [24306, 24834, null], [24834, 24834, null], [24834, 24834, null], [24834, 25184, null], [25184, 25893, null], [25893, 26597, null], [26597, 27335, null], [27335, 27992, null], [27992, 28076, null], [28076, 28106, null], [28106, 28106, null], [28106, 28106, null], [28106, 28106, null], [28106, 29435, null], [29435, 32207, null], [32207, 34313, null], [34313, 37367, null], [37367, 40732, null], [40732, 43301, null], [43301, 45383, null], [45383, 48714, null], [48714, 50560, null], [50560, 50560, null], [50560, 52045, null], [52045, 55026, null], [55026, 55515, null], [55515, 55515, null], [55515, 55627, null], [55627, 55627, null], [55627, 55690, null], [55690, 55690, null], [55690, 55765, null], [55765, 55765, null], [55765, 58465, null], [58465, 61450, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 61450, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 61450, null]], "pdf_page_numbers": [[0, 56, 1], [56, 56, 2], [56, 3779, 3], [3779, 4830, 4], [4830, 6212, 5], [6212, 8689, 6], [8689, 8732, 7], [8732, 8732, 8], [8732, 9065, 9], [9065, 9065, 10], [9065, 10672, 11], [10672, 11052, 12], [11052, 11079, 13], [11079, 11079, 14], [11079, 12644, 15], [12644, 13103, 16], [13103, 14769, 17], [14769, 16452, 18], [16452, 18264, 19], [18264, 18848, 20], [18848, 19296, 21], [19296, 21151, 22], [21151, 23255, 23], [23255, 23255, 24], [23255, 24306, 25], [24306, 24834, 26], [24834, 24834, 27], [24834, 24834, 28], [24834, 25184, 29], [25184, 25893, 30], [25893, 26597, 31], [26597, 27335, 32], [27335, 27992, 33], [27992, 28076, 34], [28076, 28106, 35], [28106, 28106, 36], [28106, 28106, 37], [28106, 28106, 38], [28106, 29435, 39], [29435, 32207, 40], [32207, 34313, 41], [34313, 37367, 42], [37367, 40732, 43], [40732, 43301, 44], [43301, 45383, 45], [45383, 48714, 46], [48714, 50560, 47], [50560, 50560, 48], [50560, 52045, 49], [52045, 55026, 50], [55026, 55515, 51], [55515, 55515, 52], [55515, 55627, 53], [55627, 55627, 54], [55627, 55690, 55], [55690, 55690, 56], [55690, 55765, 57], [55765, 55765, 58], [55765, 58465, 59], [58465, 61450, 60]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 61450, 0.14199]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
26d75fb98c8afecd1aa09ca9c82d9ee2f46b023a
On semi-automated matching and integration of database schemas Ünal-Karakas, Ö. Citation for published version (APA): General rights It is not permitted to download or to forward/distribute the text or part of it without the consent of the author(s) and/or copyright holder(s), other than for strictly personal, individual use, unless the work is under an open content license (like Creative Commons). Disclaimer/Complaints regulations If you believe that digital publication of certain material infringes any of your rights or (privacy) interests, please let the Library know, stating your reasons. In case of a legitimate complaint, the Library will make the material inaccessible and/or remove it from the website. Please Ask the Library: http://uba.uva.nl/en/contact, or a letter to: Library of the University of Amsterdam, Secretariat, Singel 425, 1012 WP Amsterdam, The Netherlands. You will be contacted as soon as possible. Chapter 6 Empirical validation of SASMINT In order to measure the quality and performance of our approach to schema matching and integration, we have performed a number of experiments. These experiments consider and make use of schemas that include different types of schema heterogeneities, as addressed in Chapter 3. This chapter describes these experiments and their results. In this respect, in Section 6.1 we first address a number of related experiments performed by other main research efforts. A number of specific quality measures used for assessing the results of our schema matching and schema integration components of SASMINT are described next in Section 6.2. The main characteristics of test schemas are addressed in Section 6.3. The setup and details related to the performed experimental evaluations are given in Section 6.4. Our evaluation results are addressed in Sections 6.5 to 6.7. Finally, Section 6.8 concludes the chapter with a summary of evaluation results. This chapter contains some research results, which were previously published in the Journal of Knowledge and Information Systems (Unal & Afsarmanesh, 2010). 6.1 Schema Matching Evaluations in Related Research The evaluation performed in most existing schema matching research does not use any benchmark; rather they each use their own test schemas in evaluating specific aspects of their proposed system. A comparison of different evaluations introduced by different research for schema matching systems is provided in (Do et al., 2002). It specifies four different types of criteria to compare existing evaluations, including the evaluation of COMA (Do & Rahm, 2002), Cupid (Madhavan et al., 2001), Similarity Flooding (Melnik et al., 2002), SEMINT (Li & Clifton, 2000), and GLUE (Doan et al., 2002). These criteria include: 1) **Input**: Types of input data used, such as dictionaries used and schema specification. 2) **Output**: Information included in the match result, such as the mappings between different schema elements. 3) **Quality measures**: Measures used to assess the accuracy of the match result. 4) **Effort**: Types of needed manual effort measured in evaluations, such as pre-match and post-match efforts. As (Do et al., 2002) concludes, it is difficult to compare results of different schema matching evaluations with each other, as these evaluations have been carried out in different ways and aimed at specific features. Authors further point at the requirement for a schema matching... benchmark to make the comparison of results of different research evaluations possible. Such a generic benchmark has however not yet been defined and/or considered in any research work. So far, only a benchmark for evaluating the systems, which match XML Schemas is proposed in (Duchateau et al., 2007). This benchmark, called XBenchMatch, consists of quality measures for both schema matching and schema integration. It also provides some evaluation of the matching performance. In XBenchMatch it is assumed that for evaluating the quality of schema matching, mappings must be given as XML path correspondences (e.g. person.person_name - person.lastName). Furthermore, for evaluating the quality of “integrated schema”, a number of measures are introduced as a part of XBenchMatch. However, these measures assume that also the correct (ideal) integrated schema is provided to the XBenchMatch. As such, the integrated schema which is generated as the output of the schema integration tool is compared against the ideal integrated schema. Both of these schemas need to be in the XML Schema format. For the purpose of evaluating the quality of “schema matching”, XBenchMatch applies the four measures of Precision, Recall, F-measure, and Overall, as most other evaluation approaches also apply some of these methods. Detailed description of these measures is provided in the next section. In summary, most evaluation approaches consider only the quality of schema matching. Although the XBenchMatch prototype measures the quality of both the schema matching and schema integration, it can only support the XML Schema formats. Furthermore, there are some assumptions of XBenchMatch (e.g. the availability of the ideal integrated schema) as explained in the previous paragraph, which makes the general use of this benchmark difficult. Since SASMINT works with relational schemas and due to other reasons addressed above, we could not apply XBenchMatch for the evaluation of SASMINT. Nevertheless, as addressed in Section 6.2 below in details, nearly all measures introduced in other competitive research are considered and applied for validation of SASMINT. ### 6.2 Quality Measures Used for Evaluating SASMINT The main goal of SASMINT is to automate the schema matching and integration processes to the extent possible. In other words, our main concern for SASMINT is its effectiveness, in how accurately the system can identify the matching pairs and generate the integrated schema automatically. For this reason, we consider only the quality and accuracy measures in our evaluations of the SASMINT system, and do not take into account the time performance related measures and assessment. Performance measures depend on the underlying environment and the technologies used, and thus it is challenging to obtain neutral objective evaluations. Furthermore, for schema matching and integration, when performance is considered, it is not only related to how fast the system works but also how much time the user spends correcting the results manually. Therefore, when the system produces more accurate results, the user needs to spend less manual time and the overall performance increases. Therefore, the accuracy aim of SASMINT also improves the performance of its schema matching and schema integration. We apply two types of quality measures in our experiments: 1) quality measures for schema matching, and 2) quality measures for schema integration. Details of these measures are provided in the next sub-section. 6.2 Quality Measures Used for Evaluating SASMINT 6.2.1 Quality Measures for Schema Matching Similar to most other schema matching evaluations, we used the concepts of precision and recall from the information retrieval field (Cleverdon & Keen, 1966) for measuring the quality of schema matching. Precision (P) and Recall (R) are computed as follows: \[ P = \frac{x}{x + z} \quad \text{and} \quad R = \frac{x}{x + y} \] where \( x \) is the number of correctly identified similar strings (i.e. true positives), \( z \) is the number of strings found as similar, while actually they were not (i.e. false positives), and \( y \) is the number of those similar strings, which the system missed to identify (i.e. false negatives). As such the higher the precision value is and the higher the recall value is, the better is the system. Although precision and recall measures are widely used for a variety of evaluation purposes, neither of them alone can accurately assess the match quality. For instance, recall can be increased by returning all pairs as similar, but increasing the number of false positives and thus decreasing the precision. Therefore, a measure combining precision and recall is better suited for accuracy evaluation. F-measure (Rijsbergen, 1979) is one such measure, combining recall and precision using the following formula. As such the higher the f-measure value is, the better is the system. \[ F = \frac{2}{\frac{1}{P} + \frac{1}{R}} \] Another such measure, called Overall, is proposed by (Melnik et al., 2002). It is different from f-measure in that overall takes into account the amount of work needed to correct the results, namely to add the relevant needed matches that have not been discovered (false negatives) and to remove those matchers, which are incorrect but have been extracted by the matcher (false positives). Overall is always lower than f-measure, and if the precision is lower than 0.5, the result for overall becomes negative (Melnik et al., 2002) (Do et al., 2002). Overall, represented by O, and also called as accuracy, is defined by the following formula. As such the higher the overall value is, the better is the system. \[ O = R \cdot (2 - \frac{1}{P}) \] As an example, assume that an automatic schema matching system correctly identifies 10 matches out of 25 real matches that can be identified manually by the user, and incorrectly identifies 4 other matches. In this case, the number of true positives (x) is 10, false negatives (y) is 25-10 = 15, and false positives (z) is 4. As a result, the system has the following precision, recall, f-measure, and overall values: \[ P = \frac{10}{10 + 4} = 0.71 \quad R = \frac{10}{10 + 15} = 0.40 \] \[ F = \frac{2}{\frac{1}{0.71} + \frac{1}{0.40}} = 0.51 \quad O = 0.40 \cdot (2 - (1 / 0.71)) = 0.24 \] 6.2.2 Quality Measures for Schema Integration Quality measures used for the assessment of schema integration in SASMINT benefit from the ideas presented in (Batini et al., 1986). Schema merging and restructuring processes described in (Batini et al., 1986) aim at improving the resulting schema with respect to the following three qualities: 1) **Completeness**: Merged or integrated schema must cover concepts of all participating schemas. 2) **Minimality**: If the same concept is represented in more than one participating schemas, then the integrated schema must contain only a single representation of this concept. In other words, redundancies must be eliminated. 3) **Understandability**: Resulting integrated schema must be easily understandable by the user. In evaluation of SASMINT, we are interested in quantitative objective measures. For this reason, we only consider measuring the **completeness** and **minimality** which will produce objective results. The **understandability** of SASMINT, while not measured rigorously, was satisfactory for the empirical tests we performed in the lab. The two measures of completeness and minimality applied to SASMINT are inspired by (Batini et al., 1986). However, within each of these measures, we have introduced two other measures for **key completeness** and **key minimality** to validate the generated primary and foreign keys when measuring the quality of SASMINT’s schema integration approach. We believe that these added measures, which are missing from Batini’s approach, are required for proper validation of schema integration. These measures are explained below: - **Completeness Measure**: In the resulting integrated schema, all concepts (i.e. tables and columns in the relational schema) of both the donor and recipient schemas must be covered. Completeness measure determines how much this goal has been achieved. Therefore, \( \forall c_i \in \{c_1, c_2, ..., c_k\} \), where \( c_i \) is a concept in the donor or recipient schema and \( k \) is the total number of concepts in that donor or recipient schemas, \( \exists c_j \in \{c_1, c_2, ..., c_l\} \) where \( c_j \) is a concept of the integrated schema and \( c_j \supseteq c_i \) and \( l \) is the number of concepts in the integrated schema. Taking this definition as the base, completeness of an integrated schema in SASMINT is measured using the following formula: \[ \text{m_{completeness}} = \frac{n_{complete}}{n_{total}}, \] where \( n_{complete} \) is the number of concepts of recipient and donor schemas that are covered in the integrated schema and \( n_{total} \) (also \( l \) above) is the total number of concepts involved in donor and recipient schemas. Schema integration in SASMINT also handles primary and foreign keys, which will be referred to as “keys” from this point onward. Therefore, another completeness measure, called **key completeness**, is also defined for SASMINT to measure how many of the keys of the recipient and donor schemas are covered in the integrated schema. 6.2 Quality Measures Used for Evaluating SASMINT Given that $n_{\text{completeKey}}$ is the number of keys of recipient and donor schemas that are covered in the integrated schema and $n_{\text{totalKey}}$ is the total number of keys involved in donor and recipient schemas, the following formula measures the key completeness, $m_{\text{completenessKey}}$, of an integrated schema in SASMINT: $$m_{\text{completenessKey}} = \frac{n_{\text{completeKey}}}{n_{\text{totalKey}}}$$ **Minimality Measure:** The amount of redundancy in the resulting integrated schema must be minimal to the extent possible. Each joint and/or related concept of the donor and recipient schemas shall appear only once in the integrated schema. Namely, if the donor and recipient schemas have common concepts, only one of them must be represented in the integrated schema. Minimality measure identifies how many redundant concepts exist in the integrated schema. Suppose that $\exists c_i \in \{c_1, c_2, \ldots, c_k\}$, where $c_i$ is a concept of the donor schema and $k$ its total number of concepts, and $\exists c_j \in \{c_1, c_2, \ldots, c_l\}$, where $c_j$ is a concept of the recipient schema and $l$ its total number of concepts. If $\exists c_x, c_y \in \{c_1, c_2, \ldots, c_m\}$, where $c_x$ and $c_y$ are concepts of the integrated schema and $m$ its total number of concepts, such that $c_i \equiv c_j = c_x = c_y$, then either $c_x$ or $c_y$ is redundant. Following formula is used to calculate the amount of redundancy in an integrated schema: $$m_{\text{redundancy}} = \frac{n_{\text{redundant}}}{n_{\text{total}}}$$ where $n_{\text{redundant}}$ is the number of redundant concepts in the integrated schema and $n_{\text{total}}$ is the total number of concepts introduced in the donor and recipient schemas. Based on this formula, we derive the following formula to measure the minimality of the SASMINT integrated schema. $$m_{\text{minimality}} = 1 - \frac{n_{\text{redundant}}}{n_{\text{total}}}$$ Similar to the case of completeness measure, another minimality measure, called *key minimality*, is also defined for SASMINT to determine if the resulting integrated schema is minimal considering its primary and foreign keys. Key minimality, $m_{\text{minimalityKey}}$, is measured using the following formula: $$m_{\text{minimalityKey}} = 1 - \frac{n_{\text{redundantKey}}}{n_{\text{totalKey}}}$$ where the $n_{\text{redundantKey}}$ is the number of redundant primary and foreign keys in the integrated schema and the $n_{\text{totalKey}}$ is the total number of such keys introduced in the donor and recipient schemas. 6.3 Test Schemas We have carried out the experimental evaluation of SASMINT using six pairs (donor and recipient) of “test schemas”, characteristics of each of which are shown in Table 6.1 and the six pairs of schemas are represented in Appendix D. As for the evaluation of schema matching, each pair was matched by the SASMINT, and then the results were compared against the correct matches shown in Table 6.2. We carried out the same tests for schema matching in COMA++ (a leading competitor) and compared its results with the results of SASMINT. On the other hand, for evaluation of schema integration, three pairs of schemas all from the university domain (in Table 6.1) were integrated. Moreover, in order to evaluate the Sampler component, first five schema pairs were used in the Sampler tests. Details of these tests are provided in the next sections. Table 6.1. Characteristics of Test Schemas <table> <thead> <tr> <th>Test Schema Pair #</th> <th>Short Name</th> <th>Domain</th> <th>Donor/Recipient</th> <th>Number of Tables</th> <th>Number of columns</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>PO</td> <td>Purchase</td> <td>Recipient</td> <td>5</td> <td>27</td> </tr> <tr> <td></td> <td></td> <td>Order</td> <td>Donor</td> <td>5</td> <td>25</td> </tr> <tr> <td>2</td> <td>Hotel</td> <td>Hotel</td> <td>Recipient</td> <td>6</td> <td>21</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Donor</td> <td>5</td> <td>14</td> </tr> <tr> <td>3</td> <td>SDB</td> <td>Biology</td> <td>Recipient</td> <td>9</td> <td>21</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Donor</td> <td>9</td> <td>22</td> </tr> <tr> <td>4</td> <td>Univ1</td> <td>University</td> <td>Recipient</td> <td>9</td> <td>30</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Donor</td> <td>5</td> <td>22</td> </tr> <tr> <td>5</td> <td>Univ2</td> <td>University</td> <td>Recipient</td> <td>9</td> <td>38</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Donor</td> <td>7</td> <td>27</td> </tr> <tr> <td>6</td> <td>Univ3</td> <td>University</td> <td>Recipient</td> <td>5</td> <td>17</td> </tr> <tr> <td></td> <td></td> <td></td> <td>Donor</td> <td>3</td> <td>10</td> </tr> </tbody> </table> We used schemas from four different domains: Schema Pair#1 contains two purchase order schemas that we generated ourselves. Schema Pair#2 consists of two hotel schemas. We modified the hotel schemas used for MAPONTO (An et al., 2006) evaluation tests. Similarly, in Schema Pair#3, we used a modified version of MAPONTO SDB schemas from the biology domain. In Schema Pair#4, we used MAPONTO schemas from the university domain, again after modifying them. Schema Pair#5 consists of university schemas that we generated. As Schema Pair#6, we modified the test schemas of Similarity Flooding (Melnik et al., 2002) from the university domain. We intentionally selected three pairs from the university domain in order to also use them for the schema integration evaluation. Therefore, the schema integration tests integrated six schemas from the university domain. The correct matches represented in Table 6.2 are matches that are generated manually by ourselves. These constitute the source for verification of correctness of automatic matchings. ### Table 6.2. Correct Matches between Schema Pairs <table> <thead> <tr> <th>Schema Pair#</th> <th>Type</th> <th>Correct Matches</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>column-column</td> <td>one_room=room, suite=room, town_house=room, num_beds=num_beds_attribute, on_floor=on_floor_attribute, smoking_preference=smoking_attribute, one_room:roomNum=room:roomNum, one_room:hasNumBedsAttribID=room:numBedsAttribID, one_room:hasOnFloorAttribID=room:onFloorAttribID, one_room:hasSmokingPreferenceAttribID=room:smokingOrNoAttribID, one_room:oneRoomID=room:roomID, suite:roomNum=room:roomNum, suite:hasNumBedsAttribID=room:numBedsAttribID, suite:hasOnFloorAttribID=room:onFloorAttribID, suite:hasSmokingPreferenceAttribID=room:smokingOrNoAttribID, town_house:townHouseID=room:roomID, townhouse:roomNum=room:roomNum, town_house:hasNumBedsAttribID=room:numBedsAttribID, town_house:hasOnFloorAttribID=room:onFloorAttribID, town_house:hasSmokingPreferenceAttribID=room:smokingOrNoAttribID, num_beds:numBedsID=num_beds_attribute:numBedsAttributeID, num_beds:numBedsAttrib=num_beds_attribute:numBedsAttrib, on_floor:onFloorID=on_floor_attribute:onFloorAttributeID, on_floor:onFloorAttrib=on_floor_attribute:onFloorAttrib, smoking_preference:smokingPreferenceID=smoking_attribute:smokingAttributeID, smoking_preference:smokingPreferenceAttrib=smoking_attribute:smokingAttribute</td> </tr> <tr> <td>3</td> <td>table-table</td> <td>diagnoses=donor, sample=sample, family_history=family_history, life_style_factors=life_style_factors, lab_test=lab_test, medications=medications, animal_donor=donor, human_donor=donor</td> </tr> <tr> <td>5</td> <td>table-table</td> <td>course=course, student=student, faculty_member=academic_staff</td> </tr> <tr> <td>Schema Pair#</td> <td>Type</td> <td>Correct Matches</td> </tr> <tr> <td>-------------</td> <td>------------</td> <td>---------------------------------------------------------------------------------------------------------------------------------------------</td> </tr> <tr> <td>column-table</td> <td>faculty_member:researchInterest=areasOfInterest</td> <td></td> </tr> <tr> <td>Column-column</td> <td>faculty_member:email=academic_staff:email, faculty_member:faculty_member_id=academic_staff:academic_staff_id, faculty_member:personName=academic_staff:name, course:number=course:courseNumber, course:courseTitle=course:courseTitle, course:instructor=course:instructor, course:prerequisites=course:prerequisite, course:description=course:description, student:studentName=student:student_name, student:email=student:email, student:advisor=student:supervisor, student:student_id=student:student_id,</td> <td></td> </tr> <tr> <td>table-table</td> <td>university=academic_institution, program=program, academic_programme=academic_programme, department=department, course=academic_course, academic_staff_member=university_academic_instructor</td> <td>5 academic_programme:ACADEMIC_YEAR=academic_programme:YEAR, academic_programme:ACADEMIC_SEMESTER=academic_programme:SEMESTER, academic_programme:PROGRAM_REF=academic_programme:PROGRAM_REF, department:department_ID=department:department_ID, department:DEPT_NAME=department:DEPT_NAME, course:course_ID=academic_course:academic_course_ID, course:INSTRUCTOR=academic_course:ACADEMIC_COURSE_INSTRUCTOR, academic_staff_member:academic_staff_member_ID=university_academic_instructor:university_academic_instructor_ID, academic_staff_member:STAFF_NAME=university_academic_instructor:STAFF_NAME, academic_staff_member:STAFF_EMAIL=university_academic_instructor:STAFF_EMAIL, academic_staff_member:STAFF_PHONE=university_academic_instructor:STAFF_PHONE,</td> </tr> <tr> <td>column-column</td> <td>professor=professor, student=student, workson=workson</td> <td>6 professor:Id=professor:Id, professor:Name=professor:Name, professor:Sal=professor:Salary, student:Name=student:Name, student:GPA=student:GradePointAverage, student:Yr=student:Year, workson:Name=workson:StudentName, workson:Proj=workson:Project</td> </tr> </tbody> </table> 6.4 Setup for the Experimental Evaluation We compared the “schema matching” component of SASMINT against one of the state of the art system, COMA++ (Aumueller et al., 2005). We selected COMA++ research prototype, because it is the most complete schema matching tool so far developed, consisting of a library of variety of matching algorithms and a sophisticated GUI. SASMINT and COMA++ are comparable, since they both support matching of relational schemas and aim at providing similar functionalities. Of course not all algorithms or metrics that these two systems apply are the same. Furthermore, how they combine the results of different algorithms is not the same either. Output of the schema matching is given in the range [0-1] in both systems. However, it is not clear in COMA++, in what format the results of schema matching are stored internally. In other words, COMA+++ has an internal repository where the results are stored, but how the results are represented there is not clear. Before starting the evaluation tasks, we inserted a number of abbreviations and their long forms into the abbreviation lists of both systems. One important difference between SASMINT and COMA++ is that SASMINT uses WordNet for semantic matching, whereas COMA++ requires the user to add all needed synonyms in the schema domains manually. Since WordNet might not contain all semantic relationships among the concepts of schemas, in order to make a fair comparison, we did not make any addition to COMA++'s default synonyms list, to make a fair comparison. Furthermore, COMA++ uses only the synonymy relationship; on the other hand, SASMINT also makes use of the IS-A relationships as well as gloss overlaps, which are available in the WordNet dictionary. Representation of schemas through the GUI is also different for the two systems. COMA++ does not explicitly show foreign keys. Instead of showing the foreign key column, it displays the table that is pointed by the foreign key. However, in some cases this functionality of COMA++ does not work as expected. Several different metrics or algorithms are considered and combined in both systems, in the manner that is explained below: - **For SASMINT**: We selected the default strategy of SASMINT for combining the algorithms, which is the weighted sum of them with equal weights applied to each algorithm in each group of syntactic, semantic, and structure matching. Although not the default approach, rather assigning appropriate weights for each match task would give better results, we decided to use SASMINT’s default strategy in order to make a fair comparison with COMA++. In other words, in real practice, the results of SASMINT would be better than what they are in these tests. Sampler could help the user to identify appropriate weights for the linguistic matching algorithms. The reported evaluation results in Section 6.5 and Appendix E are without applying the Sampler component of SASMINT. Results of experiments showing how Sampler can accomplish this improvement of results accuracy, i.e. how these weights affect the match results, are addressed in Section 6.7. - **For COMA++**: We used the default matching strategy of COMA++, which is called COMA. The COMA matcher combines the name, path, leaves, parents, and siblings matchers, by averaging them. In their tests, this combination was the winner and that is why we selected it. We used the default threshold, which is 0.5, in the experiments. As for the selection of match results, we used two different approaches that we call as “select all above threshold” and “select max above threshold”, as detailed below. Please note that while the results of “select all above threshold” are presented in Section 6.5, the results of “select max above threshold” are presented in Appendix E. 1) **Select All above Threshold:** Selecting all matched pairs that have the similarity above a certain threshold value. 2) **Select Max above Threshold:** Selecting the pairs with the maximum similarity. In other words, whenever there is more than one concept matching a single concept in a schema, the one with the highest similarity is selected as the matching candidate. SASMINT and COMA++ use different strategies for selecting the maximal similar pairs. SASMINT’s approach is explained in Chapter 4. COMA++’s default strategy works as follows: When there is more than one match to the same concept, the one with the highest similarity is selected if the difference between the similarity values is more than 0.0080. We also carried out tests in order to validate the Sampler component that helps to identify appropriate weights for each linguistic matching algorithm in the schema matching process. The results of these tests are presented in Section 6.6. The first five schema pairs (Schema Pairs #1, 2, 3, 4, and 5) were selected as the test schemas when evaluating Sampler. Although we compared SASMINT with COMA++ for the purpose of schema matching, we could not carry out functionality comparison for schema integration between them. COMA++ provides a simple schema merging functionality, but it is limited and not comparable to SASMINT’s schema integration. To the best of our knowledge, there is no other system supporting both schema matching and schema integration. Therefore, we evaluated the integration component of SASMINT alone. For this purpose, we used the six schemas from the university domain, introduced as Schema Pair#4, 5, and 6. Since the aim of schema integration is integrating two schemas at a time, based on the correspondences between them, we corrected the wrong or missing matches after the schema matching step and then continued with the integration process. ### 6.5 Evaluation of Schema Matching – For “select all above threshold” strategy In the first experiment that we performed to evaluate SASMINT and compare it with COMA++, we used the “select all above threshold” strategy. We present the results of this experiment in Figures 6.1 through 6.8. Correspondingly, we provide detailed explanations about the four comparison results of precision, recall, f-measure, and overall in the following paragraphs 6.5.1 to 6.5.4. Although the results gained from applying this strategy are worse than the “select max above threshold” strategy, this strategy is important when there is a need for suggesting multiple candidates for each schema element and leaving it to the user to identify the correct match among the alternatives. Namely, instead of proposing only one matched candidate for each schema element, which could be incorrect, the system suggests all possible match candidates, which makes it easier for the user to determine the final match result. 6.5 Evaluation of Schema Matching – For “select all above threshold” strategy 6.5.1 Evaluation of Schema Matching Using Precision Precision shows how correct the system works. Precision values for COMA++ and SASMINT are shown in Figure 6.1 and Figure 6.2 respectively. Since in the “select all above threshold” strategy, all match pairs with similarity above the threshold are selected, the number of false positives was high for some schema pairs. Especially for schemas that consisted element names with more than one token, precision was low. In our test cases, these schemas are the purchase order schemas (Schema Pair#1), university schemas of Maponto (Schema Pair#4), and the university schema that we generated ourselves (Schema Pair#5). In these cases, the low precision was due to the fact that for element names containing similar tokens, although the whole names were different, the final similarity result was usually above the threshold. Furthermore, the systems interpreted and treated all tokens equally, while some tokens had none or little effect in the meaning. For example, “deliverDate” and “deliver_zip” were identified as similar because both names contained the token “deliver”. However, the first one is the name of the column that contains the date of delivery, whereas, the second one is the name of the column that contains the zip code information. In such situations, SASMINT and COMA++ both found similarity values around 0.5. These cases could have been prevented by raising the threshold value, but then some correct matches could have been also missed. When precision was considered, SASMINT achieved almost 9 times better than COMA++ for the Hotel schemas test case. For other schemas, except for Schema Pair#6 from the university domain, for which COMA++ achieved just a little bit better (around 1.05 times), SASMINT achieved on average 2 times better than COMA++. Precision of SASMINT was on the average 0.58, whereas that of COMA++ was 0.26. This result was because of the high number of false positives identified by COMA++. In other words, COMA++ identified high number of irrelevant matches, which can be a bigger problem when schemas being compared are large. 6.5.2 Evaluation of Schema Matching Using Recall Recall shows how well the system finds all true matches and thus it indicates the completeness of the applied system. The average recall for COMA++ was 0.92, whereas for SASMINT it was 0.85. Figures 6.3 and 6.4 show the recall values for COMA++ and SASMINT. respectively. For UNIV-3 schemas, they both had the recall value of 1.0 and for SDB schemas, SASMINT was 1.14 times better than COMA++. For the remaining schemas, which were purchase order, hotel, UNIV-1, and UNIV-2, COMA++ achieved a bit (on the average 1.17 times) higher than SASMINT. However, it should be noted that this happened at the expense of very low precision values for COMA++. That means, in order to achieve just a bit higher recall values, COMA++ sacrificed the precision, resulting in very low precision values for these test cases, as indicated in Figures 6.1 and 6.2. This is due to the fact that there is an inverse relationship between precision and recall. Since COMA++ tries to find all possible matches, it also identifies a large number of false positive matches, which decrease the precision. SASMINT missed some of the correct matches, mostly due to low semantic similarity values that it could compute for some name pairs, such as (product, item) and (suite, room). Especially the gloss-based measure was not as successful as expected. Since the last version of WordNet (3.0) is not available yet for the Windows operating system, we had to use the previous version (2.0) of WordNet. We think that when the new version is ready, WordNet will provide more types of semantic relationships, and therefore the semantic similarity values for both path-based and gloss-based measures of SASMINT will be much more enhanced. ![Fig. 6.3. Recall values for COMA++ - select all above threshold strategy](image) ![Fig. 6.4. Recall values for SASMINT - select all above threshold strategy](image) ### 6.5.3 Evaluation of Schema Matching Using F-Measure As stated before, f-measure is used to combine the results of precision and recall. In other words, the higher the f-measure value, the better is the quality of the system. Most evaluation experiments in fact use f-measure as the measure to compare the systems, and not the individual precision and recall values. When f-measure is considered, the difference between SASMINT and COMA++ becomes clearer. This is due to the fact that f-measure considers both the precision and recall, and although recall values for COMA++ were a bit higher than those for SASMINT, precision of SASMINT was much better than that of COMA++, which results in higher f-measure values for SASMINT. As it is clear from the Figures 6.5 and 6.6, f-measure values for SASMINT were on average 2.2 times higher than those for COMA++ for all schema pairs, except the last schema pair (UNIV-3), for which they almost achieved the same. What can be inferred from these results is that the quality of results achieved by the SASMINT system is much higher than COMA++, considering the f-measure evaluation. 6.6 Evaluation of Schema Matching with Sampler 6.5.4 Evaluation of Schema Matching Using Overall Similar to f-measure, overall also represents a combination of precision and recall. Its value is smaller than both Precision and Recall and it can even have negative values, if the number of the false positives is more than the number of true positives. The overall indicator measures the overall accuracy of the system. It aims to identify how much manual effort is required in order to identify all correct matches. Overall values for SASMINT were consistently much higher than those for COMA++. In some cases, for example the hotel schemas, SASMINT achieved overall value around 0.7. In the case of UNIV-2 and purchase order schemas, on the other hand, it did not do very well because of the high number of false positive matches that SASMINT identified for these schemas. Since the number of false positive matches for COMA++ was very high, it had very low overall values, which means a lot of manual intervention by user is required in order to remove these wrongly identified matches. This result is very clear especially for the first five schema pairs (purchase order, hotel, SDB, and the UNIV-1, and UNIV-2 schemas). Evaluation results for COMA++ and SASMINT, based on the overall values are shown in Figures 6.7 and 6.8 respectively. Since the aim of such systems is to achieve the schema matching as automatically as possible, the amount of required human intervention is an important measure for comparing these systems. The lesser manual effort is required, the better the system is. 6.6 Evaluation of Schema Matching with Sampler In order to evaluate the Sampler component, we carried out tests using the first five schema pairs introduced in Table 6.1. As explained before, Sampler is used to compute the weights only for linguistic matching algorithms. In test cases where the element names from two schemas were highly similar, we set the threshold to a value higher than 0.5. In other cases, we used the default threshold value, which was 0.5. After setting the threshold value, we performed the tests using both equal weights for the linguistic matching algorithms and the weights suggested by Sampler for these algorithms. We used the “select max above threshold” strategy for the Sampler tests. Furthermore, we did not use the last schema pair (schema pair#6) in the tests, because for this pair, precision, recall, f-measure, and overall values were already identified as 1 in the tests using the “select max above threshold” strategy, when equal weights were used. Details of tests with the Sampler component are explained below. ### 6.6.1 Test with Purchase Order Schemas-PO (Schema Pair#1) In this test, we used the default threshold value, which was 0.5. We provided the similar pairs shown in Table 6.3 to Sampler, which computed the weights for semantic similarity algorithms shown in the same table. Results for precision, recall, f-measure, and overall were already high before the Sampler component was used. With the use of Sampler, (product, item) pair was correctly identified as similar, which was false negative before. As the result, Sampler helped to increase the values of recall, f-measure, and overall, as shown in Figure 6.9. Precision was 1 both before and after the use of the Sampler component. <table> <thead> <tr> <th>Similar Pairs</th> <th>Computed Weights</th> </tr> </thead> <tbody> <tr> <td>Semantically Similar Pairs:</td> <td>Wu and Palmer: 1.0</td> </tr> <tr> <td>customer - buyer</td> <td>Gloss: 0.0</td> </tr> <tr> <td>product – item</td> <td></td> </tr> </tbody> </table> Table 6.3. Similar Pairs and Computed weights for Schema Pair#1 6.6 Evaluation of Schema Matching with Sampler ### 6.6.2 Test with Hotel Schemas-Hotel (Schema Pair#2) In this test, we set the threshold value as 0.7. We provided the similar pairs shown in Table 6.4 to Sampler, which computed the weights for syntactic similarity algorithms shown again in Table 6.4. When SASMINT used these weights for matching the hotel schemas, results for recall, f-measure, and overall were on the average 1.75 times (57%) better than the case without the use of Sampler. This result can be seen in Figure 6.10. #### 6.6.2.1 Results of the Test with Schema Pair#1 **Fig. 6.9.** Results of the Test with Schema Pair#1 <table> <thead> <tr> <th>Similar Pairs and Computed weights for Schema Pair#2</th> </tr> </thead> <tbody> <tr> <td><strong>Similar Pairs</strong></td> </tr> <tr> <td>Syntactically Similar Pairs:</td> </tr> <tr> <td>smoking_Preference_Attrib - smoking_Attrib</td> </tr> <tr> <td>smoking_Preference_ID - smoking_Attribute_ID</td> </tr> <tr> <td>hasSmokingPreferenceAttribID - smokingOrNoAttribID</td> </tr> <tr> <td>on_floor - on_Floor_attribute</td> </tr> <tr> <td>numBedsID – numBedsAttributeID</td> </tr> <tr> <td><strong>Computed Weights</strong></td> </tr> <tr> <td>Levenshtein: 0.0</td> </tr> <tr> <td>Jaccard: 0.11</td> </tr> <tr> <td>LCS: 0.20</td> </tr> <tr> <td>Monge-Elkan: 0.22</td> </tr> <tr> <td>Jaro: 0.22</td> </tr> <tr> <td>TF*IDF: 0.25</td> </tr> </tbody> </table> 6.6.3 Test with Biology Schemas-SDB (Schema Pair#3) Two schemas (donor and recipient) in Schema Pair#3 use the same names for most of their schema elements. We set the threshold value to 0.9 and provided the two similar pairs of (animal_donor-donor) and (human_donor-donor). Sampler computed 1.0 for the weight of Monge-Elkan distance metric and 0.0 for other syntactic similarity metrics, as shown in Table 6.5. When we ran SASMINT with these weights, the results were as shown in Figure 6.11. There was a slight decrease in Precision when Sampler was used. This was due to the two false positives (donor, donor_visit) and (donorID, donorVisitID). However, recall, f-measure, and overall were all improved. <table> <thead> <tr> <th>Similar Pairs</th> <th>Computed Weights</th> </tr> </thead> <tbody> <tr> <td>Syntactically Similar Pairs:</td> <td>Levenshtein: 0.0</td> </tr> <tr> <td>animal_donor - donor</td> <td>Jaccard: 0.0</td> </tr> <tr> <td>human_donor – donor</td> <td>LCS: 0.0</td> </tr> <tr> <td></td> <td>Jaro: 0.0</td> </tr> <tr> <td></td> <td>TF*IDF: 0.0</td> </tr> <tr> <td></td> <td>Monge-Elkan: 1.0</td> </tr> </tbody> </table> 6.6 Evaluation of Schema Matching with Sampler 6.6.4 Test with University Schemas-UNIV1 (Schema Pair#4) For the test with these schema pairs, we set the threshold value as 0.7. We provided syntactically similar pairs, shown in Table 6.6. As shown in Figure 6.12, precision was slightly better before, whereas recall, f-measure, and overall values were higher with the use of Sampler. Since we provided Sampler (personName, name) as the syntactically similar pair, the personName column of the faculty_member table was successfully matched to the name column of the academic_staff table. However, at the same time, it incorrectly matched the personName column of the faculty_member and the name column of the admin_staff table. This in turn, increased the number of false positives, and thus slightly decreased the precision. However, since Sampler helped to identify more number of similar pairs, recall was much better than the case without the Sampler. As the result, f-measure and overall were better with the use of Sampler, as shown in Figure 6.12. ### Table 6.6. Similar Pairs and Computed weights for Schema Pair#4 <table> <thead> <tr> <th>Similar Pairs</th> <th>Computed Weights</th> </tr> </thead> <tbody> <tr> <td>Syntactically Similar Pairs:</td> <td></td> </tr> <tr> <td>number - courseNumber</td> <td>Levenshtein: 0.0</td> </tr> <tr> <td>personName - name</td> <td>Jaccard: 0.0</td> </tr> <tr> <td>researchInterest – areasOfInterest</td> <td>Jaro: 0.15</td> </tr> <tr> <td></td> <td>LCS: 0.15</td> </tr> <tr> <td></td> <td>TF*IDF: 0.3</td> </tr> <tr> <td></td> <td>Monge-Elkan: 0.4</td> </tr> </tbody> </table> 6.6.5 Test with University Schemas-UNIV2 (Schema Pair#5) In this test, we set the threshold value to 0.7 and provided the pairs shown in Table 6.7 to Sampler. Weights computed by Sampler for syntactic similarity algorithms are presented in Table 6.7. Similar to the case addressed in Section 6.7.4, with the use of Sampler the precision decreased because some new false positive pairs were introduced. For example, the university_name column of the university table and the name column of the university_student table were identified as similar, which was incorrect. However, since the value of recall was much higher when Sampler was used, f-measure and overall increased, as presented in Figure 6.13 also. <table> <thead> <tr> <th>Similar Pairs</th> <th>Computed Weights</th> </tr> </thead> <tbody> <tr> <td>academic_semester - semester</td> <td>Levenshtein: 0.0</td> </tr> <tr> <td>course_id - academic_course_id</td> <td>Jaccard: 0.0</td> </tr> <tr> <td>course_instructor - academic_course_instructor</td> <td>Jaro: 0.0</td> </tr> <tr> <td>staff_name - name</td> <td>LCS: 0.18</td> </tr> <tr> <td>course - academic course</td> <td>Monge-Elkan: 0.35</td> </tr> <tr> <td></td> <td>TF*IDF: 0.47</td> </tr> </tbody> </table> 6.7 Evaluation of Schema Integration Performance In order to evaluate the schema integration component of SASMINT, we used schema pairs from the university domain. The three university schema pairs introduced in Table 6.1 which are Schema Pairs#4, 5, and 6 are used for this purpose. As addressed further below, please note that the Appendix F provides details of the steps of evaluation. Figures 6.14 through 6.16 show the elements of these pairs. SASMINT integrates two schemas at a time, therefore, incrementally generating the final integrated schema. The steps we followed for integrating these six schemas are explained below. We have selected to start with larger schemas first, namely Schema Pair#5. First Schema - academic_programme - academic_programme_ID - ACADEMIC_YEAR, ACADEMIC_SEMESTER,PROGRAM_REF - academic_staff_member [academic_staff_member_ID, STAFF_NAME, STAFF_EMAIL, STAFF_PHONE, STAFF_FAX, STAFF_IDENTIFICATION_NUM, STAFF_BIRTHDATE] - campus [campus_ID, CAMPUS_NAME, CAMPUS_LOCATION, UNVCAMPUS] - course [course_ID, COURSE_NAME, COURSE_CREDITS, COURSE_PROVIDER, COURSE_INSTRUCTOR] - department [department_ID, DEPT_NAME, FACULTY_REF] - faculty [faculty_ID, FACULTY_NAME, DEAN_REF, UNIVERSITY_REF] - program [program_ID, PROGRAM_NAME, PROGRAM_DESC] - registration [registration_ID, REGISTRATION_ACADEMICSTAFFMEMBER_REF, REGISTRATION_COURSE_REF, REGISTRATION_ACADEMICPROGRAMME_REF] - university [university_ID, UNIVERSITY_NAME, UNIVERSITY_WEBSITE, UNIVERSITY_ESTABLISHMENT_DATE] Second Schema - academic_course - academic_course_ID, ACADEMIC_COURSE_NAME, ACADEMIC_COURSE_CREDITS, ACADEMIC_COURSE_PROVIDER, ACADEMIC_COURSE_INSTRUCTOR - academic_institution [academic_institution_ID, ACADEMIC_INSTITUTION_NAME, ACADEMIC_INSTITUTION_WEBSITE] - academic_programme [academic_programme_ID, YEAR, SEMESTER, PROGRAM_REF] - department [department_ID, DEPT_NAME, UNIVERSITY_REF] - program [program_ID, PROGRAM_NAME, PROGRAM_DESC] - university_academic_instructor [university_academic_instructor_ID, NAME, ELECTRONIC_MAIL, OFFICE_ADDRESS, TELEPHONE] - university_student [university_student_ID, NAME, ELECTRONIC_MAIL, TELEPHONE] **Fig. 6.14. Schema Pair#5 (UNIV-2)** Step-1: First Schema of Schema Pair#5 + Second Schema of Schema Pair#5 At the first step of schema integration test, SASMINT system has integrated two schemas of the Schema Pair#5, shown in Figure 6.14, resulting in the integrated schema, elements of which are shown in Figure 6.17. During the integration process, one redundancy was automatically generated, which was the “UNIVERSITY_REF” column of the “department” table. Therefore, the result of minimality measure was 0.99, which is a substantial automated achievement. When key minimality is considered, one redundant foreign key relationship was defined on the same “UNIVERSITY_REF” column, which resulted in a key minimality of 97%. Although the resulting integrated schema had one redundant element and foreign key, it covered all the elements and keys of two source schemas. Therefore, the result is considered as 100% complete and 100% key complete, which is again a substantial automated achievement. Further details of this step are provided in Appendix F. Step-2: Integrated Schema#1 + First Schema of Schema Pair#6 At this step, SASMINT integrated the Integrated Schema#1 and the first schema of the Schema Pair#6, generating the Integrated Schema#2. Figure 6.18 shows only newly added tables and those tables that had changes in their columns. Due to the redundant “UNIVERSITY_REF” column and the foreign key defined on it, the result of minimality measure was 0.99 and the key minimality measure was 0.97. However, since all the concepts and keys of the first three schemas integrated (first schema of the Schema Pair#5, second schema of the Schema Pair#5, and first schema of the Schema Pair#6) were covered in the integrated schema, completeness and key completeness were again 100%. 6.7 Evaluation of Schema Integration Performance **Fig. 6.17. Elements of Integrated Schema#1** ``` INTEGRATED_1:university (university_ID (PK), UNIVERSITY_NAME, UNIVERSITY_ESTABLISHMENT_DATE, UNIVERSITY_WEBSITE) INTEGRATED_1:program (program_ID (PK), PROGRAM_NAME, PROGRAM_DESC) INTEGRATED_1:academic_programme (academic_programme_ID (PK), ACADEMIC_YEAR, ACADEMIC_SEMESTER, PROGRAM_REF) INTEGRATED_1:department (department_ID (PK), DEPT_NAME, UNIVERSITY_REF(FK), FACULTY_REF(FK)) INTEGRATED_1:course (course_ID (PK), COURSE_NAME, COURSE_CREDITS, COURSE_PROVIDER (FK), COURSE_INSTRUCTOR(FK)) INTEGRATED_1:academic_staff_member (academic_staff_member_ID (PK), STAFF_NAME, STAFF_IDENTIFICATION_NUM, STAFF_FAX, STAFF_BIRTHDATE, OFFICE_ADDRESS, STAFF_EMAIL, STAFF_PHONE) INTEGRATED_1:campus (campus_ID (PK), CAMPUS_NAME, CAMPUS_LOCATION, UNVCAMPUS (FK)) INTEGRATED_1:faculty (faculty_ID (PK), FACULTY_NAME, DEAN_REF(FK), UNIVERSITY_REF (FK)) INTEGRATED_1:registration (registration_ID (PK), REGISTRATION_ACADEMICSTAFFMEMBER_REF(FK), REGISTRATION_COURSE_REF(FK), REGISTRATION_ACADEMICPROGRAMME_REF(FK)) INTEGRATED_1:university_student (university_student_ID (PK), NAME, ELECTRONIC_MAIL, TELEPHONE) ``` **Fig. 6.18. New Elements of Integrated Schema#2** ``` INTEGRATED_2:payrate (Rank (PK), HrRate) INTEGRATED_2:workson (Name, Proj, Hrs, ProjRank (FK)) INTEGRATED_2:address (Id (PK), Street, City, PostalCode) INTEGRATED_2:academic_staff_member (academic_staff_member_ID (PK), STAFF_NAME, STAFF_IDENTIFICATION_NUM, STAFF_FAX, STAFF_BIRTHDATE, STAFF_EMAIL, STAFF_PHONE, Sal, addr(FK)) INTEGRATED_2:university_student (university_student_ID (PK), NAME, ELECTRONIC_MAIL, TELEPHONE, GPA, Yr) ``` **Step-3: Integrated Schema#2 + Second Schema of Schema Pair#6** At Step-3, SASMINT generated Integrated Schema#3, by integrating the Integrated Schema#2 and the second schema of the Schema Pair#6. The only change in the new integrated schema was the addition of one new column, called “Expenses” to the “workson” table. Due to the redundant “UNIVERSITY_REF” column and the foreign key defined on it, the resulting schema was again 99% minimal and 97% key minimal. However, it was again 100% complete considering both the concepts and keys. **Step-4: Integrated Schema#3 + First Schema of Schema Pair#4** In Step-4, SASMINT integrated the Integrated Schema#3 and the first schema of the Schema Pair#4, resulting in the Integrated Schema#4. Figure 6.19 shows only the newly added tables and those tables that had changes in their columns at this step. Minimality and key minimality were 0.99 and 0.98 respectively, because of the redundant “UNIVERSITY_REF” column and the foreign key. Considering the concepts, schema was 100% complete, but since three foreign keys were missed, as explained in Appendix F, the key completeness was 0.95 after this step. Step-5: Integrated Schema#4 + Second Schema of Schema Pair#4 In the final step of schema integration, SASMINT integrated the Integrated Schema#4 and the second schema of the Schema Pair#4. Final integrated schema is called Integrated Schema#5. Figure 6.20 shows the elements of the final integrated schema. This schema was 99% minimal and 99% key minimal. Redundancy was again due to the “UNIVERSITY_REF” column and the foreign key defined on it. Although all the concepts of six schemas integrated were covered in the final schema, resulting in 100% completeness, two more foreign keys were missed in this step, in addition to the ones in the previous step. Therefore, the key completeness was 0.93, as explained in detail in Appendix F. 6.8 Conclusions This chapter presents the results of our evaluation of the SASMINT system. In this chapter, first the state of the art in the schema matching evaluations is addressed, and then the quality measures that were applied during our experiments are explained. After that, the set of six test schemas that were used for evaluating the SASMINT system are introduced. Since there was not any benchmark for relational schema matching systems, we generated our own test schemas, a number of which were the same or modified versions of schemas from the evaluations of similar matching systems in related research. After the introductory part, the results of our experiments are presented in this chapter. Schema matching in SASMINT was compared against one leading state of the art schema matching system, the COMA++. A brief summary of this comparison based on the input, the combination of matchers, the output, the persistence store, and the quality criteria is given below: - **Input:** SASMINT accepts relational schemas, bearing in mind that most data are still stored in relational databases and corresponding schemas are represented as relational DDLs. As stated in Chapter 7 about the Future Steps, it may be possible to extend SASMINT to also support matching of XML Schema. The COMA++ accepts relational schema, XML Schema, and OWL as input to its matching procedure. In addition to the schemas to be matched, SASMINT uses a number of auxiliary inputs. A file consisting of a number of well-known abbreviations is exploited. Users can update (extend) this file with other abbreviations from the domain of schemas. As the second auxiliary input, SASMINT uses the WordNet for identifying semantic relationships between schema elements. Similar to SASMINT, COMA++ also utilizes a user-modifiable list of abbreviations. On the other hand, in order to detect synonymy relationships, COMA++ requires a user-provided list of synonyms. The disadvantage of this approach is that users are required to continuously update this list with pairs of synonyms from the domain of schemas. - **Combination of Matchers:** SASMINT and COMA++ both provide a library of matchers. SASMINT provides the possibility of user assigned weights to different algorithms and a Sampler component, which helps the user to identify the appropriate weight for each linguistic matching metric. On the other hand, COMA++ supports different alternatives for combining, aggregating, and selecting match results from different metrics. But the user should decide and select the approaches to be applied. This feature makes it difficult for an inexperienced user to identify the best combination. - **Output:** The output of a match system is a mapping, indicating which elements of the recipient and donor schemas correspond to each other. Both SASMINT and COMA++ represent these correspondences using a value between 0 and 1. Furthermore, they both can support 1-to-1, 1-to-n, n-to-1, and m-to-n types of matches. • **Persistence store for the results:** For matching and integration of schemas, SASMINT stores the results based on SDML. This allows the results to be used for federated query processing and for decomposition of queries to be sent to different local schemas, as well as for formal representation of the semi-automatically generated integrated schema from the recipient and donor schemas. COMA++ has an internal repository for the results, but users cannot see in which format results are stored and it is not clear how to use these results outside of the system. • **Quality of Schema Matching:** The quality of schema matching supported by SASMINT and COMA++ was compared using their default settings for the combination of different matchers. SASMINT's default approach for combining linguistic and structure matching metrics calculates their weighted sum. However, then the Linguistic metrics have a higher impact (0.7) than the structure ones (0.3), on the final result. But in the evaluation between the two systems, each metric in groups of the linguistic matching and structure matching was considered with equal weight. Namely, in order to make a fair comparison with COMA++, we did not give higher weights to the metrics that could be more appropriate for some schema types. COMA matcher combines name, path, leaves, parents, and siblings matchers by averaging them. We updated the abbreviation lists of both systems with new abbreviations related to schemas. However, we did not update the synonyms list of COMA++, because manually adding into this list some complex semantic correspondences would also lead to unfair comparisons. We carried out experiments based on two types of result selection strategies that we call as: 1) Select all above threshold and 2) select max above threshold. Both systems performed better in the second approach. When the first approach was used, results for COMA++ were worse than those of SASMINT. For the second approach, the systems performed the same for some schema pairs, for the remaining pairs, SASMINT performed better than COMA++. In order to evaluate the Sampler component of SASMINT, we performed some tests using the same set of test schemas. For this purpose, after setting the threshold value, we provided the Sampler component with a number of similar pairs from the two schemas being compared. We performed schema matching using both the Sampler’s computed weights as well as the equal weights for linguistic matching algorithms. In some cases, using Sampler’s computed weights resulted in an increase in the number of false positives, and thus a decrease in the precision. However, in every such case since Sampler identifies higher number of correct matches, by assigning appropriate weights, the corresponding recall was much better than the case where Sampler was not used. Therefore, even in these cases, this resulted in an increase in f-measure and overall performance of SASMINT. Therefore, using Sampler was shown to improve the quality of match results. After evaluating the schema matching approach of SASMINT against the leading system COMA++, we evaluated the schema integration approach of SASMINT. Since COMA++’s schema merging feature is very primitive and there were no other systems at the level of SASMINT, which can use their schema matching results for semi-automatic schema integration, we could unfortunately not compare the results of schema integration approach of SASMINT with any other system. Nevertheless, we performed the incremental integration of six schemas to be able to evaluate SASMINT against the state of the art criteria defined for automated schema integration. During the empirical evaluation, SASMINT achieved a high percentage of minimality and completeness for its integrated schemas procedure, which applies its user-validated matches. To sum up, schema matching and schema integration are two challenging tasks in SASMINT. Different types of schema heterogeneities, such as semantic and structural, make these tasks more difficult to achieve automatically. A semi-automatic system might perform badly on such schemas. Evaluation data sets need to be carefully selected to cover different types of schema heterogeneities. Furthermore, in order to fairly evaluate the schema matching and schema integration systems, measures need to be carefully selected and defined to consider all aspects of a system in evaluation, such as quality of the match and integration results, how the results are represented, how easily these results can be modified/corrected by the user, and whether it is possible to use these results in other processes like query decomposition in federated query processing.
{"Source-Url": "https://pure.uva.nl/ws/files/1033641/82553_10.pdf", "len_cl100k_base": 14034, "olmocr-version": "0.1.49", "pdf-total-pages": 26, "total-fallback-pages": 0, "total-input-tokens": 60972, "total-output-tokens": 14820, "length": "2e13", "weborganizer": {"__label__adult": 0.0005822181701660156, "__label__art_design": 0.0015954971313476562, "__label__crime_law": 0.0009174346923828124, "__label__education_jobs": 0.033599853515625, "__label__entertainment": 0.00030803680419921875, "__label__fashion_beauty": 0.000457763671875, "__label__finance_business": 0.0035495758056640625, "__label__food_dining": 0.0006771087646484375, "__label__games": 0.0010776519775390625, "__label__hardware": 0.0008912086486816406, "__label__health": 0.000965595245361328, "__label__history": 0.001407623291015625, "__label__home_hobbies": 0.0003600120544433594, "__label__industrial": 0.0009822845458984375, "__label__literature": 0.0023860931396484375, "__label__politics": 0.0005993843078613281, "__label__religion": 0.0008797645568847656, "__label__science_tech": 0.311279296875, "__label__social_life": 0.0007519721984863281, "__label__software": 0.158447265625, "__label__software_dev": 0.4765625, "__label__sports_fitness": 0.00027179718017578125, "__label__transportation": 0.0007534027099609375, "__label__travel": 0.0005207061767578125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60420, 0.02452]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60420, 0.32632]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60420, 0.88689]], "google_gemma-3-12b-it_contains_pii": [[0, 1024, false], [1024, 3527, null], [3527, 7045, null], [7045, 9854, null], [9854, 12898, null], [12898, 15302, null], [15302, 18960, null], [18960, 22037, null], [22037, 24330, null], [24330, 28004, null], [28004, 31037, null], [31037, 33550, null], [33550, 36295, null], [36295, 38544, null], [38544, 40046, null], [40046, 41585, null], [41585, 42553, null], [42553, 44111, null], [44111, 45163, null], [45163, 47381, null], [47381, 49136, null], [49136, 51983, null], [51983, 52576, null], [52576, 55720, null], [55720, 59566, null], [59566, 60420, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1024, true], [1024, 3527, null], [3527, 7045, null], [7045, 9854, null], [9854, 12898, null], [12898, 15302, null], [15302, 18960, null], [18960, 22037, null], [22037, 24330, null], [24330, 28004, null], [28004, 31037, null], [31037, 33550, null], [33550, 36295, null], [36295, 38544, null], [38544, 40046, null], [40046, 41585, null], [41585, 42553, null], [42553, 44111, null], [44111, 45163, null], [45163, 47381, null], [47381, 49136, null], [49136, 51983, null], [51983, 52576, null], [52576, 55720, null], [55720, 59566, null], [59566, 60420, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60420, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60420, null]], "pdf_page_numbers": [[0, 1024, 1], [1024, 3527, 2], [3527, 7045, 3], [7045, 9854, 4], [9854, 12898, 5], [12898, 15302, 6], [15302, 18960, 7], [18960, 22037, 8], [22037, 24330, 9], [24330, 28004, 10], [28004, 31037, 11], [31037, 33550, 12], [33550, 36295, 13], [36295, 38544, 14], [38544, 40046, 15], [40046, 41585, 16], [41585, 42553, 17], [42553, 44111, 18], [44111, 45163, 19], [45163, 47381, 20], [47381, 49136, 21], [49136, 51983, 22], [51983, 52576, 23], [52576, 55720, 24], [55720, 59566, 25], [59566, 60420, 26]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60420, 0.28295]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
abe2474eba9f8409de7868b4e6b8311d8a739724
Farkas Lemma made easy Christophe Alias To cite this version: Christophe Alias. Farkas Lemma made easy. 10th International Workshop on Polyhedral Compilation Techniques (IMPACT 2020), Jan 2020, Bologna, Italy. pp.1-6. hal-02422033 HAL Id: hal-02422033 https://inria.hal.science/hal-02422033 Submitted on 8 Jan 2020 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Farkas Lemma made easy Tool Demonstration Christophe Alias Laboratoire de l’Informatique du Parallélisme CNRS, ENS de Lyon, Inria, UCBL, Université de Lyon Lyon, France Christophe.Alias@inria.fr Abstract In this paper, we present fkcc, a scripting tool to prototype program analyses and transformations exploiting the affine form of Farkas lemma. Our language is general enough to prototype in a few lines sophisticated termination and scheduling algorithms. The tool is freely available and may be tried online via a web interface. We believe that fkcc is the missing chain to accelerate the development of program analyses and transformations exploiting the affine form of Farkas lemma. ACM Reference Format: 1 Introduction Many program analyses require to handle universally quantified constraints such as $\forall x \in D : \Phi(x)$, where $D$ is a convex polyhedron and $\Phi$ is a conjunction of affine constraints. For instance, this occurs in loop scheduling [5, 6], loop tiling [3], program termination [2] or generation of loop invariants [4]. Farkas lemma – affine form – provides a way to get rid of that universal quantification, at the price of introducing quadratic terms. It is even possible to use Farkas lemma to turn universally quantified quadratic constraints into existentially quantified affine constraints [5, 6]. However, this requires tricky algebraic manipulations, notoriously difficult to experiment by hand and to implement. In this tool demonstration, we present a scripting tool, fkcc [1] which makes it possible to manipulate easily Farkas lemma to benefit from those nice properties. Specifically, we will discuss the following points: - A general formulation for the resolution of equations $\forall x : S(x) = 0$ where $S$ is summation of affine forms including Farkas terms. So far, this resolution was applied for specific instances of Farkas summation. This result is the basic engine of the fkcc scripting language. - A scripting language to apply and exploit Farkas lemma; among polyhedra, affine functions and affine forms. - Our tool, fkcc, implementing these principles, is available at http://foobar.ens-lyon.fr/fkcc. fkcc may be downloaded and tried online via a web interface. fkcc comes with many examples, making it possible to adopt the tool easily. This tool demonstration is structured as follows. Section 2 presents the affine form of Farkas lemma, our resolution theorem, and explains how it applies to compute scheduling functions. Then, Section 3 defines the syntax and outlines informally the semantics of the fkcc language. Finally, Section 4 concludes this paper and draws future research perspectives, then Annex A gives a real-life example of fkcc script to compute a Pluto-style tiling [3] for the Jacobi 1D kernel. 2 Farkas lemma in polyhedral compilation This section presents the theoretical background of this tool demonstration. We first introduce the affine form of Farkas lemma. Then, we present our theorem to solve equations $\forall x : S(x) = 0$ where $S$ is a summation of affine forms including Farkas terms. This formalization will then be exploited to design the fkcc language. Lemma 2.1 (Farkas Lemma, affine form). Consider a non-empty convex polyhedron $P = \{x, A x + b \geq 0\} \subseteq \mathbb{R}^n$ and an affine form $\phi : \mathbb{R}^n \rightarrow \mathbb{R}$ such that $\phi(x) \geq 0 \ \forall x \in P$. Then: $\exists \lambda_0 \geq 0, \lambda_0 \geq 0$ such that: $$\phi(x) = \lambda(Ax + b) + \lambda_0 \ \forall x$$ Hence, Farkas lemma makes it possible to remove the quantification $\forall x \in P$ by encoding directly the positivity over $P$ into the definition of $\phi$, thanks to the Farkas multipliers $\lambda$ and $\lambda_0$. In the remainder, Farkas terms will be denoted by: $\lambda(\lambda_0, \lambda, A, b)(\bar{x}) = \lambda(A\bar{x} + b) + \lambda_0$. We now recall our theorem [1] to solve equations $\forall x : S(x) = 0$ where $S$ involves Farkas terms. The result is expressed as a conjunction of affine constraints, which is suited for integer linear programming: Theorem 2.2 (solve). Consider a summation $S(\bar{x}) = \bar{u} \cdot \bar{x} + \sum_i b(\lambda_{10}, \lambda_i, A_i, b_i)(\bar{x})$ of affine forms, including Farkas terms. Then: $$\forall \bar{x} : S(\bar{x}) = 0 \iff \begin{cases} \bar{u} + \sum_i A_i (\lambda_i) = \bar{0} \wedge \\ \bar{v} + \sum_i (\lambda_i \cdot b_i + \lambda_{10}) = 0 \end{cases}$$ Application to scheduling Figure 1 depicts an example of a program (a) computing the product of two polynomials specified by their arrays of coefficients a and b, and the iteration domain with the data dependence across iterations (b) and an example schedule \( \theta(i,j) = i \) prescribing a parallel execution by vertical waves. This paragraph reformulates the technique presented in [5] with our theorem 2.2. This formulation will directly inspire the \texttt{fkcc} syntax presented in the next section. A schedule must be positive everywhere on its iteration domain: \[ \theta(i,j,N) \geq 0 \quad \forall (i,j) \in D_N \tag{1} \] Applying Farkas lemma, this translates to: \[ \exists \lambda_0 \geq 0, \bar{A}, \bar{b} \quad \text{s.t.} \quad \theta(i,j,N) = \bar{\varnothing}(\lambda_0, \bar{A}, \bar{b})(i,j,N) \tag{2} \] Moreover, a schedule must satisfy the data dependencies \((i,j) \rightarrow (i',j')\), abstracted by a dependence polyhedron \(\Delta_N\): \[ \theta(i',j',N) > \theta(i,j,N) \quad \forall (i,j,i',j') \in \Delta_N \tag{3} \] This is equivalently written as the positivity of the affine form \((i,j,i',j',N) \rightarrow \theta(i',j',N) - \theta(i,j,N) - 1 \) over the convex polyhedron \(\Delta_N\). Applying Farkas lemma: \[ \exists \mu_0 \geq 0, \bar{\mu} \geq 0 \quad \text{s.t.} \quad \theta(i',j',N) - \theta(i,j,N) - 1 = \bar{\varnothing}(\mu_0, \bar{\mu}, C, \bar{d})(i,j,i',j',N) \] Substituting \(\theta\) using Equation (2), this translates to solving \[\forall (i,j,i',j',N) : S(i,j,i',j',N) = 0, \text{ where } S(i,j,i',j',N) \text{ is the summation:} \] \[ \bar{\varnothing}(\lambda_0, \bar{A}, \bar{b})(i',j',N) - \bar{\varnothing}(\lambda_0, \bar{A}, \bar{b})(i,j,N) - 1 = \bar{\varnothing}(\mu_0, \bar{\mu}, C, \bar{d})(i,j,i',j',N) \] Since \(-\bar{\varnothing}(\lambda_0, \bar{A}, \bar{b}) = \bar{\varnothing}(-\lambda_0, -\bar{A}, \bar{b})\), we may apply theorem 2.2 to obtain a system of affine constraints with \(\lambda_0, \bar{A}, \bar{b}\). Linear programming may then be applied to find out the desired schedule [3, 6]. 3 \texttt{FKCC} at a glance This section outlines briefly the input syntax of \texttt{FKCC} on our motivating example. For a detailed description, the reader is referred to [1]. **Program, instructions, polyhedra** An \texttt{FKCC} program consists of a sequence of instructions. There is no other control structure than the sequence. An instruction may assign an \texttt{FKCC} object (polyhedron, affine form or affine function) to an \texttt{FKCC} identifier, or may be an \texttt{FKCC} object alone. In the latter case, the \texttt{FKCC} object is streamed out to the standard output. \texttt{FKCC} objects are expressed with the same syntax as \texttt{iscf7}: - \texttt{parameters := \{M,eps\};} - \texttt{parametrized_iterations := [M] -> \{[i]: 0 <= i and i < M\};} Parameters \texttt{must} be declared with the parameters construct. The parameters of a polyhedron \texttt{may} optionally be declared on preceding brackets \([M] \rightarrow \ldots\). The set intersection of two polyhedra \(P\) and \(Q\) is obtained with \(P \cap Q\). **Affine forms** An affine form may be defined as a Farkas term: - \texttt{iterations := [] -> \{[i,j,N]: 0 <= i and i < N and 0 <= j and j < N\};} - \texttt{theta := positive_on_iterations;} If \texttt{iterations} is \{\{x | x = 0 \geq b \geq 0\}, \texttt{then theta is defined as } \bar{\varnothing}(\lambda_0, \bar{A}, \bar{b})\} where \(\lambda_0\) and \(\bar{\lambda}\) are fresh positive variables. In this case, the polyhedron is never parametrized: the parameters must be handled as variables. Affine forms may be summed, scaled and composed with affine functions, typically to adjust the input dimension: - \texttt{dependence := [] -> \{[i,j,i',j',N]: 0 <= i and i < N and 0 <= j and j < N and 0 <= i' and i' < N and 0 <= j' and j' < N and i+j = i'+j' and i<i';} - \texttt{to_target := \{[i,i',j',j''],N] -> [i',j'',N];} - \texttt{to_source := \{[i,i',j',j''],N] -> [i,j,N];} - \texttt{sum := (theta . to_target) - (theta . to_source) - 1 - positive_on_dependence;} In a summation of affine forms, affine forms must have the same input dimension. Also, a constant \(-1\) is automatically interpreted as an affine form \{[i,j,i',j',N] \rightarrow -1\}. The terms of the summation are simply separated with + and -, no parenthesis are allowed. Affine forms may also be stated explicitly: - \texttt{sum_eps := (theta . to_target) - (theta . to_source) + \{[i,j,i',j'',N] \rightarrow -1 eps\} - positive_on_dependence;} **Resolution** The main feature of \texttt{FKCC} is the resolution of equations \(\forall x : S(x) = 0\) where \(S\) is a summation of affine forms including Farkas terms. This is obtained with the instruction \texttt{solve}: - \texttt{solve sum = 0;} The result is a polyhedron with Farkas multipliers (obtained after applying Theorem 2.2 (solve)): When the summation contains affine forms with parameters (as \(\text{sum}_\text{eps}\)), the resolution interprets parameters as constants. In particular, this makes it possible to tune dependence satisfaction: \(\theta(i', j') \geq \theta(i, j) + \epsilon_d\) with \(0 \leq \epsilon_d \leq 1\). At this point, we need to recover the coefficients of our affine form \(\theta\) in terms of \(\lambda\) (\(\lambda_0, \ldots, \lambda_3\)) and \(\lambda_0\) (\(\lambda_4\)). Observe that \(\theta(S) = \lambda_0 + \lambda_A \cdot x + \lambda_1 \cdot y + \lambda_3\). If the coefficients of \(\theta\) are written: \(\theta(S) = \lambda \cdot x + \lambda_0\), we simply have: \(\lambda = \lambda_A + \lambda_1 \cdot y + \lambda_3 + \lambda_0\). This is obtained with define: \[ \begin{align*} \text{define theta with tau;} \end{align*} \] The result is a conjunction of definition equalities, gathered in a polyhedron: \[ \begin{align*} \lambda_0, \lambda_1, \lambda_2, \lambda_3, \lambda_4, \lambda_A \in & \mathbb{R} & \lambda_0 + \lambda_1 \cdot y + \lambda_2 \cdot z + \lambda_3 + \lambda_4 \cdot w & = \theta(S). \end{align*} \] The first coefficients \(\tau_k\) define \(\lambda\); the last one defines the constant \(\lambda_0\). On our example, \(\theta(i, j, N) = \tau_0 \cdot 1 + \tau_1 \cdot i + \tau_2 \cdot N + \tau_3\). Now we may gather the results and eliminate the \(\lambda\) to keep only \(\tau\) and \(\lambda_0\): \[ \begin{align*} \text{keep } \tau_0, \tau_1, \tau_2, \tau_3 & \text{ in} \end{align*} \] \[ \begin{align*} \text{(solve sum = 0) \ast (define theta with tau)}; \end{align*} \] The result is a polyhedron with all the valid schedules: \[ \begin{align*} \lambda_0, \lambda_1, \lambda_2, \lambda_3, \lambda_4, \lambda_A \in & \mathbb{R} & \lambda_0 + \lambda_1 \cdot y + \lambda_2 \cdot z + \lambda_3 + \lambda_4 \cdot w & = \theta(S). \end{align*} \] All these steps may be applied at once with the \textsf{find} command: \[ \begin{align*} \text{find theta s.t. sum = 0}; \end{align*} \] The coefficients are automatically named \(\theta_0, \theta_1, \ldots\) etc with the same convention as define. We point out that define \textit{choose fresh names} for coefficients (e.g., \(\tau_4, \tau_5\) on the second time with ‘\(\tau_0\)’) whereas \textit{find always chooses the same names}. Hence \textit{find} would be preferred when deriving separately constraints on the coefficients of \(\theta\). find may filter the coefficients for several affine forms expressed as Farkas terms in a summation: \[ \begin{align*} \text{find theta_s, theta_s.t.} \end{align*} \] \[ \begin{align*} \text{theta_s.to_target} - \text{theta_s.to_source} = 1 \end{align*} \] \[ \begin{align*} \text{positive on dependences from S_to_T} = 0; \end{align*} \] This is typically used to compute schedules for programs with multiple assignments (here \(S\) and \(T\) with dependences from iterations of \(S\) to iterations of \(T\)). Finally, note that keep \(\tau_0, \tau_1, \tau_2, \tau_3, \tau_4\) in \(P\); projects \(P\) on variables \(\tau_0, \tau_1, \tau_2, \tau_3\); the result is a polyhedron with integral points of coordinates \((\tau_0, \tau_1, \tau_2, \tau_3)\). This way, the order in which \(\tau_0, \tau_1, \tau_2, \tau_3\) are specified to keep impacts directly a further lexicographic optimization. As in \(\text{iscc}\), the lexicographic minimum of a polyhedron is obtained with the \textsf{lexmin} command. This example, however, does not admit a lexico-minimum solution. We can find a solution by forcing positive coefficients: \[ \begin{align*} \text{positive_theta := [] -> \{[theta_0, theta_1, theta_2, theta_3]:} \end{align*} \] \[ \begin{align*} \text{theta_0 >> 0 and theta_1 >> 0 and theta_2 >> 0 and theta_3 >> 0}; \end{align*} \] \[ \begin{align*} \text{lexmin (find theta s.t. sum = 0) \ast positive_theta; \end{align*} \] Using the \textsf{-pretty} option, we obtain: \[ \begin{align*} \text{theta_0 = 1} \end{align*} \] \[ \begin{align*} \text{theta_1 = 0} \end{align*} \] \[ \begin{align*} \text{theta_2 = 0} \end{align*} \] \[ \begin{align*} \text{theta_3 = 0} \end{align*} \] Which corresponds to the schedule \(\theta(i, j, N) = i\). We point out that it is also possible to write in a few lines of \textsf{fkcc} the latency minimization as in [5]. A complete description may be found in [1]. 4 Conclusion \textsf{FKCC} is a scripting tool to prototype program analyses using the affine form of Farkas lemma. The script language of \textsf{FKCC} is powerful enough to write in a few lines sophisticated scheduling algorithms. The object representation (polyhedral, affine functions) is compatible with \textsf{iscc}, a widespread polyhedral tool featuring manipulation of affine relations. \textsf{FKCC} provides features to generate \textsf{iscc} code, and conversely, the output of \textsf{iscc} might be injected in \textsf{Fkcc}. This will allow to take profit of both worlds. We believe that scripting tools are mandatory to evaluate quickly research ideas. So far, Farkas lemma-based approaches were locked by two facts: applying by hand Farkas Lemma is a pain; and implementing an analysis with Farkas lemma is notoriously time consuming and bug prone. With \textsf{FKCC}, computer scientists are now freed from these constraints. Let the power of \textsf{fkcc} be with you! References A Pluto-style tiling with fkcc We give here the fkcc script discussed in the demo session to compute a Pluto-style tiling [3] for the Jacobi-1D kernel. Note the sections expressing successively the data dependences (→), the correctness condition \((S, i) \rightarrow (T, j) \Rightarrow \phi_T(j) - \phi_S(i) \geq 0\), the laziness (minimal dependence distance \(\delta_{ST} = \phi_T(j) - \phi_S(i)\)), and finally the computation of non-null and linearly independent affine tiling hyperplanes in \(\phi_S\) and \(\phi_T\). Applying fkcc with the -pretty option, we obtain: ``` $ fkcc -pretty < pluto.fk phi_S_0 = 1 phi_S_0 = 2 phi_S_1 = 0 phi_S_1 = 1 phi_S_2 = 0 phi_S_2 = 0 phi_S_3 = 0 phi_S_3 = 0 phi_S_4 = 0 phi_S_4 = 0 phi_T_0 = 1 phi_T_0 = 2 phi_T_1 = 0 phi_T_1 = 1 phi_T_2 = 0 phi_T_2 = 0 phi_T_3 = 0 phi_T_3 = 0 phi_T_4 = 0 latency_0 = 0 latency_1 = 0 latency_2 = 1 Which corresponds to the affine tiling \(\phi_S(t, i) = (t, 2t + i)\) and \(\phi_T(t, i) = (t, 2t + i + 1)\) with a maximum dependence distance 1 for the first tiling hyperplane and 2 for the second tiling hyperplane. ``` # # jacobi-1D non-perfect # # # for (t = 1; t <= T; t++) # # { # # for (i = 1; i < N - 1; i++) # # for (i = 1; i < N - 1; i++) # # A[i] = B[i]; //T # # } D_S := [] \rightarrow \{ [t,i,T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \}; D_T := [] \rightarrow \{ [t,i,T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \}; phi_S := \text{positive on } D_S; phi_T := \text{positive on } D_T; #S --- T Delta_ST := [] \rightarrow \{ [t,i,t',i',T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \text{ and } 1 \leq t' \text{ and } t' \leq T \text{ and } 1 \leq i' \text{ and } i' \leq N-1 \text{ and } t=t' \text{ and } i=i' \}; #T --- S, read a[i-1] Delta_Ts_1 := [] \rightarrow \{ [t,i,t',i',T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \text{ and } 1 \leq t' \text{ and } t' \leq T \text{ and } 1 \leq i' \text{ and } i' \leq N-1 \text{ and } t+t'=t' \text{ and } i=i'-1 \}; #T --- S, read a[i+1] Delta_Ts_2 := [] \rightarrow \{ [t,i,t',i',T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \text{ and } 1 \leq t' \text{ and } t' \leq T \text{ and } 1 \leq i' \text{ and } i' \leq N-1 \text{ and } t+t'=t' \text{ and } i=i'+1 \}; #S --- T, read a[i] Delta_STS_1 := [] \rightarrow \{ [t,i,t',i',T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \text{ and } 1 \leq t' \text{ and } t' \leq T \text{ and } 1 \leq i' \text{ and } i' \leq N-1 \text{ and } t+t'=t' \text{ and } i=i' \}; #S --- T, read a[i+1] Delta_STS_2 := [] \rightarrow \{ [t,i,t',i',T,N]: 1 \leq t \text{ and } t \leq T \text{ and } 1 \leq i \text{ and } i \leq N-1 \text{ and } 1 \leq t' \text{ and } t' \leq T \text{ and } 1 \leq i' \text{ and } i' \leq N-1 \text{ and } t+t'=t' \text{ and } i=i'+1 \}; # Correctness: \( s \rightarrow t \implies \phi(s) \leq \phi(t) \) eq \[ to\_target := \{[t,i,t',i',T,N] \rightarrow [t',i',T,N]\}; \] \[ to\_source := \{[t,i,t',i',T,N] \rightarrow [t,i,T,N]\}; \] \[ \phi\_correct := \] \[ # S \rightarrow T \] \[ (\text{find} \ \phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_T \ . \ to\_target) - (\phi\_S \ . \ to\_source) - \text{positive}\_on\ \Delta_{ST} = 0) \times \] \[ # S \rightarrow T, \ (\text{anti read}(a[i-1]) \rightarrow \text{write}(a[i])) \] \[ (\text{find} \ \phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_T \ . \ to\_target) - (\phi\_S \ . \ to\_source) - \text{positive}\_on\ \Delta_{ST\_anti\_1} = 0) \times \] \[ # S \rightarrow T, \ (\text{anti read}(a[i+1]) \rightarrow \text{write}(a[i])) \] \[ (\text{find} \ \phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_T \ . \ to\_target) - (\phi\_S \ . \ to\_source) - \text{positive}\_on\ \Delta_{ST\_anti\_2} = 0) \times \] \[ # T \rightarrow S, \ \text{read} a[i-1] \] \[ (\text{find} \ \phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ to\_target) - (\phi\_T \ . \ to\_source) - \text{positive}\_on\ \Delta_{TS\_1} = 0) \times \] \[ # T \rightarrow S, \ \text{read} a[i] \] \[ (\text{find} \ \phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ to\_target) - (\phi\_T \ . \ to\_source) - \text{positive}\_on\ \Delta_{TS\_2} = 0) \times \] \[ # T \rightarrow S, \ \text{read} a[i+1] \] \[ (\text{find} \ \phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ to\_target) - (\phi\_T \ . \ to\_source) - \text{positive}\_on\ \Delta_{TS\_3} = 0) \] \[ # Efficiency: \( s \rightarrow t \implies \phi(t) - \phi(s) \leq \text{latency}(N) \), then \text{min latency}(N) \] \[ # L(N) \geq 0 \text{ on the parameter domain} \] \[ \text{latency} := \text{positive}\_on\ ([] \rightarrow ([T,N]: T \geq 0 \text{ and } N \geq 0)); \] \[ \text{latency\_def} := \text{define latency with latency}; \] \[ \text{to\_param} := \{[t,i,t',i',T,N] \rightarrow [T,N]\}; \] \[ \phi\_bounded := \] \[ # S \rightarrow T \] \[ (\text{find} \ \text{latency,}\phi\_S,\phi\_T \ \text{s.t.} \ \text{latency} \ . \ \text{to\_param} - (\phi\_T \ . \ \text{to\_target}) + (\phi\_S \ . \ \text{to\_source}) - \text{positive}\_on\ \Delta_{ST} = 0) \times \] \[ # S \rightarrow T, \ \text{(anti read}(a[i-1]) \rightarrow \text{write}(a[i])) \] \[ (\text{find} \ \text{latency,}\phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_T \ . \ \text{to\_target}) - (\phi\_S \ . \ \text{to\_source}) - \text{positive}\_on\ \Delta_{ST\_anti\_1} = 0) \times \] \[ # S \rightarrow T, \ (\text{anti read}(a[i+1]) \rightarrow \text{write}(a[i])) \] \[ (\text{find} \ \text{latency,}\phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ \text{to\_target}) - (\phi\_T \ . \ \text{to\_source}) - \text{positive}\_on\ \Delta_{ST\_anti\_2} = 0) \times \] \[ # T \rightarrow S, \ \text{read} a[i-1] \] \[ (\text{find} \ \text{latency,}\phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ \text{to\_target}) - (\phi\_T \ . \ \text{to\_source}) - \text{positive}\_on\ \Delta_{TS\_1} = 0) \times \] \[ # T \rightarrow S, \ \text{read} a[i] \] \[ (\text{find} \ \text{latency,}\phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ \text{to\_target}) - (\phi\_T \ . \ \text{to\_source}) - \text{positive}\_on\ \Delta_{TS\_2} = 0) \times \] \[ # T \rightarrow S, \ \text{read} a[i+1] \] \[ (\text{find} \ \text{latency,}\phi\_S,\phi\_T \ \text{s.t.} \ (\phi\_S \ . \ \text{to\_target}) - (\phi\_T \ . \ \text{to\_source}) - \text{positive}\_on\ \Delta_{TS\_3} = 0) \] \[ # First hyperplane: avoid the null solution \] \[ \phi\_filter\_level\_1 := [] \rightarrow \{[\phi\_S\_0,\phi\_S\_1,\phi\_S\_2,\phi\_S\_3,\phi\_S\_4,\phi\_T\_0,\phi\_T\_1,\phi\_T\_2,\phi\_T\_3,\phi\_T\_4]\): \] \[ \# \phi\_S: \text{positive coefficients} + \text{no parameters} \] \[ \phi\_S\_0 \geq 0 \text{ and} \] \[ \phi\_S\_1 \geq 0 \text{ and} \] \[ \phi\_S\_2 = 0 \text{ and} \] \[ \phi\_S\_3 = 0 \text{ and} \] \[ \phi\_S\_4 \geq 0 \text{ and} \] \[ \# \phi\_T: \text{positive coefficients} + \text{no parameters} \] \[ \phi\_T\_0 \geq 0 \text{ and} \] \[ \phi\_T\_1 \geq 0 \text{ and} \] \[ \phi\_T\_2 = 0 \text{ and} \] \[ \phi\_T\_3 = 0 \text{ and} \] \[ \phi\_T\_4 \geq 0 \text{ and} \] #phi_S != 0 and phi_T != 0 phi_S_0 + phi_S_1 + phi_S_2 + phi_S_3 >= 1 and phi_S_0 + phi_T_1 + phi_T_2 + phi_T_3 >= 1 }; all_level_1 := keep latency_0, latency_1, latency_2, phi_S_0, phi_S_1, phi_S_2, phi_S_3, phi_S_4, phi_T_0, phi_T_1, phi_T_2, phi_T_3, phi_T_4 in phi_correct * phi_bounded * phi_filter_level_1; lexmin all_level_1; # # Second hyperplane: avoid the null solution + linear independence with the first hyperplane # phi_filter_level_2 := [] -> { [phi_S_0, phi_S_1, phi_S_2, phi_S_3, phi_S_4, phi_T_0, phi_T_1, phi_T_2, phi_T_3, phi_T_4]: #phi_S: positive coefficients + no parameters + lin. ind (coef(i) > 0) phi_S_0 >= 0 and phi_S_1 > 0 and phi_S_2 = 0 and phi_S_3 = 0 and phi_S_4 >= 0 and #phi_T: positive coefficients + no parameters + lin. ind (coef(i) > 0) phi_T_0 >= 0 and phi_T_1 > 0 and phi_T_2 = 0 and phi_T_3 = 0 and phi_T_4 >= 0 and #phi_S != 0 and phi_T != 0 phi_S_0 + phi_S_1 + phi_S_2 + phi_S_3 >= 1 and phi_S_0 + phi_T_1 + phi_T_2 + phi_T_3 >= 1 }; all_level_2 := keep latency_0, latency_1, latency_2, phi_S_0, phi_S_1, phi_S_2, phi_S_3, phi_S_4, phi_T_0, phi_T_1, phi_T_2, phi_T_3, phi_T_4 in phi_correct * phi_bounded * phi_filter_level_2; lexmin all_level_2;
{"Source-Url": "https://inria.hal.science/hal-02422033/document", "len_cl100k_base": 8362, "olmocr-version": "0.1.50", "pdf-total-pages": 7, "total-fallback-pages": 0, "total-input-tokens": 22956, "total-output-tokens": 9915, "length": "2e13", "weborganizer": {"__label__adult": 0.00026345252990722656, "__label__art_design": 0.0003387928009033203, "__label__crime_law": 0.000286102294921875, "__label__education_jobs": 0.0004968643188476562, "__label__entertainment": 6.246566772460938e-05, "__label__fashion_beauty": 0.0001220107078552246, "__label__finance_business": 0.0002378225326538086, "__label__food_dining": 0.00031948089599609375, "__label__games": 0.0004701614379882813, "__label__hardware": 0.000904083251953125, "__label__health": 0.0003690719604492187, "__label__history": 0.0002161264419555664, "__label__home_hobbies": 0.00010275840759277344, "__label__industrial": 0.0005459785461425781, "__label__literature": 0.00016260147094726562, "__label__politics": 0.00023829936981201172, "__label__religion": 0.0004279613494873047, "__label__science_tech": 0.039093017578125, "__label__social_life": 8.273124694824219e-05, "__label__software": 0.010772705078125, "__label__software_dev": 0.94384765625, "__label__sports_fitness": 0.0002390146255493164, "__label__transportation": 0.0004470348358154297, "__label__travel": 0.00019049644470214844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 25744, 0.02823]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 25744, 0.44713]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 25744, 0.68757]], "google_gemma-3-12b-it_contains_pii": [[0, 861, false], [861, 5553, null], [5553, 10471, null], [10471, 17360, null], [17360, 20412, null], [20412, 24550, null], [24550, 25744, null]], "google_gemma-3-12b-it_is_public_document": [[0, 861, true], [861, 5553, null], [5553, 10471, null], [10471, 17360, null], [17360, 20412, null], [20412, 24550, null], [24550, 25744, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 25744, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 25744, null]], "pdf_page_numbers": [[0, 861, 1], [861, 5553, 2], [5553, 10471, 3], [10471, 17360, 4], [17360, 20412, 5], [20412, 24550, 6], [24550, 25744, 7]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 25744, 0.0]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
370e7dbc780b35455011d776db37baa66f3aa48f
The role of semantics in e-government service model verification and evolution L. Stojanovic(1), A. Abecker(1), D. Apostolou(3), G. Mentzas(2), R. Studer(1) (1) FZI, Research Center for Information Technologies at the University of Karlsruhe, Germany (2) National Technical University of Athens, Greece (3) University of Piraeus, Greece Abstract e-government systems are subject to a continual change. The importance of better change management is nowadays more important due to the evolution of Europe towards a multicultural, more open and international society with changing common values, increasing levels of education, demographic involvement and adoption of new technologies. In this paper we show how semantic technologies may improve change management. The novelty of the approach lies in the formal verification of the service description as well as in the using of formal methods for achieving consistency when a problem is discovered. Introduction An important characteristic of today’s business systems is their ability to adapt themselves efficiently to the changes in their environment, as well as to the changes in their internal structures and processes. The continual reengineering of a business system, i.e. the need to be better and better, is becoming a prerequisite for surviving reengineering of a business system, i.e. the need to be internal structures and processes. The continual change, which means making of changes in a planned and management in general refers to the task of managing is still a challenge. Change management problem in e-government seems to be quite complex. It is necessary to provide support for propagating changes to all dependent artefacts by ensuring the consistency of the whole system. Otherwise, the reliability, accuracy and effectiveness of the e-government system decrease significantly. The changes to be managed lie within and are controlled by the public administrations. The most frequent changes are the changes of existing business processes based on the adaptation of the business goals, organisational structure or due to possibility to organise processes in a better way. For example, public administrations at the government level or at the federal level work on supporting unification of e-government services, on standards for data exchange as well as on providing examples of the process models of public services that are implemented by municipalities. Moreover, the internal changes might have been triggered by events originating outside the public administration, i.e. by “the environment.” Hence, the change management must take into account the response to changes over which the public administration exercises little or no control (e.g., legislation, social and political upheaval, the actions of competitors, shifting economic tides and currents, and so on). On the other hand, in a dynamically changing political and economical environment, the regulations themselves have to be continually improved, in order to enable the efficient functioning of a modern society. Taking into account an enormous number of public services and dependencies between them, as well as the complexity of interpreting and implementing changes in government regulations, the process of reconfiguring the existing public services seems to be quite complex. It is necessary to provide support for propagating changes to all dependent artefacts by ensuring the consistency of the whole system. However, building and maintaining long-living applications that will be “open for changes” is still a challenge. Change management in general refers to the task of managing change, which means making of changes in a planned and systematic fashion (Nickols, 2003). The aim is to more effectively resolve changes in an ongoing organization. Change management is especially important for the applications that are distributed over different systems. Due to our tasks in an ongoing project, in this paper we treat change management problem in e-government systems. Indeed, e-government systems (e.g. portals) are typical examples of distributed applications. They enable integration of various, physically distributed services differing in the level of formality and the structure. The changes to be managed lie within and are controlled by the public administrations. The most frequent changes are the changes of existing business processes based on the adaptation of the business goals, organisational structure or due to possibility to organise processes in a better way. For example, public administrations at the government level or at the federal level work on supporting unification of e-government services, on standards for data exchange as well as on providing examples of the process models of public services that are implemented by municipalities. Moreover, the internal changes might have been triggered by events originating outside the public administration, i.e. by “the environment.” Hence, the change management must take into account the response to changes over which the public administration exercises little or no control (e.g., legislation, social and political upheaval, the actions of competitors, shifting economic tides and currents, and so on). On the other hand, in a dynamically changing political and economical environment, the regulations themselves have to be continually improved, in order to enable the efficient functioning of a modern society. Taking into account an enormous number of public services and dependencies between them, as well as the complexity of interpreting and implementing changes in government regulations, the process of reconfiguring the existing public services seems to be quite complex. It is necessary to provide support for propagating changes to all dependent artefacts by ensuring the consistency of the whole system. Otherwise, the reliability, accuracy and effectiveness of the e-government system decrease significantly. Although the importance of change management is demonstrated in the practice (Hardless, et al. 2000), as known to the authors the corresponding methods and tools are still missing. However, since the demands for change-aware e-government are much higher (Stojanovic, et al. 2006), in this paper we propose an approach that enables agile response to frequent and huge changes in the environment or in the system itself. The novelty of the approach lies in the formal verification of the service description as well as in the using formal methods. In this paper we show how semantic technologies may improve change management. The novelty of the approach lies in the formal verification of the service description as well as in the using of formal methods for achieving consistency when a problem is discovered. 2 For example, the e-government service for birthday certificate can be treated as a separate service or as a composite service in the context on other services such as passport issuance. The addition of a new input in the birthday certificate service requires the changes in the data-flow of many of services that include it (e.g. the passport issuance service) in order to achieve one-step e-government. methods for achieving consistency when a problem is discovered. The verification is driven by a set of desirable properties including such as standard set of properties as well as domain-specific constraints (e.g. all activities are bound on some law or regulation). While performing the checks, the system generates specific suggestions on how to fix errors based on the type of errors and the situation at hand. Even though it is very desirable to identify errors and to resolve them in an early stage of the service modelling, there are no tools that provide such means. This paper is organized as follows: The set of ontologies used for describing e-government services is discussed in section 2. Change management process is introduced in section 3. The change preservation phase of this process that enables verification of a service description and generation of recommendations to fix problems found in the description is elaborated in section 4. The implementation details are given in section 5. In section 6, an overview of related work is presented, while in section 7 we present the main conclusions of this work. **OntoGov Model** Before starting with the description of our approach for the change management, here we briefly describe the set of ontologies used for modelling e-government services. This set represents the Ontogov model. Dependencies between OntoGov ontologies are shown in Figure 1. They are called *Meta ontologies*, since they define the schema i.e. the language for modelling the e-government services. ![Figure 1. The OntoGov model](image) The OntoGov model consists of two major parts – the *OntoGov Profile ontology* and the *OntoGov Process ontology*, which are developed based on the OWL-S\(^3\) ontologies. However, both of them are extended / adapted in order to take into account unique characteristics of the e-government services as well as some aspects needed for the better management of changes. For example, since a profile in generally is used for advertising and discovering of e-government services, a typical profile of an e-government service contains the information such as name, short description, version, status, date of creation, creator, etc. Additionally, the OntoGov Profile ontology includes the Life-Event ontology that is used for the classification of the e-government services. A part of this ontology is shown in Figure 2. ![Figure 2. A part of the Life-Event ontology](image) The Life-Event ontology includes concepts such as residential affairs, residential permissions, identification certifications, naturalization citizenship, moving, education etc. It has been developed based on the existing standards for modelling life events such as the Swiss Standard eCH-001\(^4\) that aims to give an overview over all relevant e-government services in Switzerland and therefore to provide a consistent and standardized classification of the services. The inventory comprises 1.200 e-government services that are all services initialized by a citizen or internal administration processes. It is important to note that the Life-Event ontology is common for all the users even though they are often geographically distributed and experience significant problems in common communication language (e.g. English) and in the style of the communication. The lexical layer\(^5\) of the Life-Event ontology enables to deal with different languages. The OntoGov Process ontology models (i) process flow using activities (which can be either atomic or composite) and control constructs (e.g. sequence, split, join, switch, etc.) and (ii) data flow through inputs, outputs and equivalence relationship between them. Input and output of an activity are represented using entities defined in the Domain ontology. The Domain ontology shown in Figure 3 encodes concepts of the public administration domain such as the “terminology” used in the e-government domain. Every public administration should keep its autonomy in describing its own domain. For example, the Domain ontology defines the type and structure of documents such as certificate. Moreover, for each activity a set of metadata may be defined that includes name, description, preconditions, and \(^3\) http://www.daml.org/services/owl-s/1.0/ \(^4\) Best Practice Structure Process Inventory - http://www.ech.ch \(^5\) The lexical layer of an ontology models various lexical properties of ontology entities, such as labels, synonyms, stems etc. postconditions. This standard set of metadata is extended with the legal, organizational and lifecycle aspects defined in the corresponding ontologies. All these ontologies are used for the annotation of the e-government services in order to enable better and easier management of them. Figure 3. A part of the Domain ontology For example, while in private organizations the decisions for process definitions are mainly based on time, cost and quality criteria, government processes must be in accordance with the existing law and regulations from different levels (state, region, and municipality). Therefore, we have developed the Legal ontology that models the structure of the legal documents, which includes paragraphs, sections, amendments, etc. It is very important to document the laws and regulations the process is based upon – not only for the whole process but also for specific activities, since the legislation regulates the accomplishments of the administrative services. By associating legislation to these services, it is possible to trace and propagate the effects that a change in the legislation (or administrative regulations) produces on the models of the administrative services. To develop the Legal ontology that is shown in Figure 4 we have analyzed the structure of legal documents in Switzerland, Greece and Spain, since the goal of the OntoGov project is to pilot the system at three partners coming from these countries. We concluded that the legal documents have very similar structure independently of the country they are defined for. Even though different countries use different terminology to organize their legal documents, all of them use three levels of abstractions. Therefore, it was possible to extract the general structure of a law and to represent it in a form of the Legal ontology. The Organisational ontology shown in Figure 5 describes the roles and areas of responsibility and capabilities within an organisation with respect to the activities of a process model. Moreover, it models the structure of an organisation, its resources, know-how, etc. For example, we distinguish two types of resources: (1) human resources who perform an activity and (2) equipment (i.e. hardware, software etc.) that is occupied by the activity. Note that equipment is needed to perform an activity. However, it is released after finishing this activity. Figure 4. A part of the Legal ontology Finally, the OntoGov Process ontology includes the Lifecycle ontology that describes the decision-making process in the public administration. A part of this ontology is shown in Figure 6. It bridges the gap between decision making and realisation by providing means for describing these decisions and formally stating reasons that motivate the design decisions. Indeed, it is intended to support the transition from knowledge acquisition to implementation. It provides answers on the following questions: (i) “How have the process design (e.g. regarding atomic activities) and flow (e.g. regarding control constructs) been realized?” and (ii) “Why has a design decision been taken?”. Since it includes entities for documenting design decisions and the underlying rationale, it gives concrete clues on how the corresponding e-government service has to be modified. During ongoing development, it helps the public administrators to avoid pursuing unpromising design alternatives repeatedly, but it also facilitates maintenance by improving the understandability of the service design. A description of the design process also supports traceability, since it links parts of the service design to the portions of the specification they were derived from and to the requirements that influenced design decisions. In this way we build model that supports not only the specification and design of e-government processes, but more important it provides an automated, transparent, and user centered... support to the entire process lifecycle, from analysis to execution, by suggesting solutions that can be adopted, refused, or refined by public administrators. Figure 6. A part of the LifeCycle ontology All the previously mentioned ontologies represent the OntoGov model. In order to model concrete e-government services and all data relevant for these services we have developed the Domain-oriented ontologies. Therefore, this cluster includes a set of ontologies that are structured in accordance with the specific domain, e.g., pilot. These ontologies are “specialization” of ontologies belonging to the cluster of Meta Ontologies or other domain-oriented ontologies. For example, at the government level we may define the Legal-Federal ontology based on the Legal ontology that belongs to the OntoGov model. It contains the entities representing the laws that hold at federal level. Each federal state has its own laws. Therefore, the Legal-State ontology may be a specialization of the Legal-Federal ontology (since a state must satisfy all federal laws) by extending it with the knowledge related to the federal state laws. Further, each municipality may create its Legal-Municipality ontology that extends the Legal-State ontology with some regulations. This example is shown in Figure 7. We note that there is no constraints regarding the depth of the specialization. However, our approach is currently limited to including entire models rather than including subsets. Also, when a model is reused, information can only be added, and not retracted. The main ontology in the cluster of domain-oriented ontologies is the so-called Service ontology. Each e-government service is represented by one Service ontology. A Service ontology is an instantiation of the OntoGov Profile Ontology and it contains specializations of all ontologies included in the OntoGov Profile Ontology. We note that the “specializations” of the Legal, Organizational and Domain ontologies may be shared between several Service ontologies. It means that for each particular governmental institution the domain experts have to define their own specialization of the Legal, Organizational and Domain ontologies by taking into account the specificities of this public administration. Moreover, they have to reuse as much as possible of already existing knowledge. For example, to define their own ontology for legal aspects they should reuse the ontology representing the law at the state level (or at least at the federal level) and not to start directly from the Legal ontology. This will speed up the ontology development process and will increase the interoperability. Figure 7. Specialisation of the legal ontologies On the other hand, the specializations of the Lifecycle, Process and Profile ontologies are specific for each concrete service. This specialization is done by creating instances and property instances of corresponding concepts defined in some of the included ontologies. It means that for each e-government service we have exactly one specialization of these three ontologies, since each e-government service has its own profile, process model as well as life-cycle. We note that a Service ontology may include other Service ontologies. An example of modelling e-government services An example of the process part of the e-government service “Announcement of moving”, modelled by using the OntoGov model, is shown in Figure 8. This service is classified as of high potential for European e-government improvement, as it is typically involving various public and private institutions. Today, the service is split into few separated tasks. In the case that a citizen invokes this service from a web portal, she is asked to provide all information needed to perform the complete service (cf. “EnterApplicationForm” in Figure 8). After submitting the requested information, the eligibility is checked (cf. “CheckEligibility”). Based on the result, the service can be either broken (cf. “RejectApplication”) or continued. The next step depends on whether she is already registered (cf. “Deregistration”) or not (cf. “Registration”). Deregistration has to be performed in one municipality. In addition, the person has to register himself/herself in the new municipality. In the meantime several private or semi-private entities, like telecommunication companies or the electricity company, have to be notified about the change. --- 6 An ontology OS is defined as a specialization of an ontology O if it includes the ontology O and extends its entities either at the conceptual level (e.g. by defining the specialization of a concept) or at the instance level (e.g. by instantiating a particular concept). We treat the term ontology specialization as a synonym for term ontology reuse or ontology modularization. of the address (cf. “GetThirdPatiesAddress” and “NotifyThirdParties”). Finally, the citizen has to be informed about the result of the service. By describing the e-government service “Announcement of moving” in this way the quality of the service is improved, since it is performed by the citizen as one task regardless what and how much (technical) processes run behind. Moreover, not only knowledge on how to execute the service is stored but also why it was designed as it is. Therefore for every entity in the process model of a service (i.e. either an activity or a control construct), information on the underlying design decisions is stored. An example of the design decision that is defined for the activity “CheckEligibility” is shown in Figure 8. This decision is legally grounded: the information that public administrators need to know regarding this activity is defined by law (cf. SR 101 and SR 201 Art. 22A-26A). Additionally, a decision may stem from technical reasons or organizational reasons. In the case that a reason changed, this information is used to propagate the change to the affected service(s). **Design Decision 1:** **Eligibility handling** **Reason I:** Citizen must have Swiss domicile in order to perform automatic registration/deregistration **Related Instance(s):** SR 101 SR 210 Art. 22A – 26A --- **Change Management Process** Change management is the timely adaptation of a system to the changes in business requirements, users’ needs, etc. as well as the consistent propagation of these changes to dependent artefacts (Nickols, 2003). A modification in one part of the system may generate many inconsistencies in other parts of the same system (Stojanovic, 2004). This variety of causes and consequences of the changes makes the change management a very complex operation that should be considered as both an organizational and a technical process (Stojanovic, Stojanovic, 2004). Existing approaches for change management in e-government focus mainly on manual managing of a particular, isolated service and on supporting only message-based communication between public administrators. It means that public administrators can exchange raw information, but not semantically more complex structures, like decisions, since e.g. they are missing a commonly agreed description of problems. --- **Figure 8.** “Announcement of moving” e-government service modelled using the OntoGov model Moreover, the existing approaches require a growing number of highly skilled personnel, making the maintenance costly. Finally, the changes that affect the system are resolved and propagated in an ad-hoc manner. However, the ad hoc management of changes might work only for particular cases. It can scale neither in space nor in time. Therefore, in order to avoid unnecessary complexity and failures in the long run, change management must be treated in a more systematic way. Our approach for Change Management enables consistent propagation of changes within a service and between the services in order to ensure the quality of the decision making process. Since the services are represented as a set of metadata (instances) related to an ontology, each step in resolving changes can be formalized and automatically performed. We define a four-phase change management process as shown in Figure 9. The process starts with representing a request for a change formally and explicitly. Then, the change preservation prevents inconsistencies by computing additional changes that guarantee the transition of the model into another consistent state. During the change implementation phase, required and derived changes are applied to the system in a transactional manner. In the change propagation phase all dependent knowledge items are found and updated. In the rest of this section we describe this four phases briefly. The detailed description of the change preservation phase is given in next section. Change representation The OWL ontology language represents the standard for representing ontologies on the Web and it is used as the representation language of OntoGov ontologies. Each entity of the OWL ontology model represents one logical axiom. Therefore, a complete set of changes determined by the OWL ontology language includes only two changes: “AddAxiom” and “RemoveAxiom”. However, this granularity of the ontology changes is not always appropriate. For example, to make the service s1 a predecessor of the service s2, the public administrator needs to apply a list of ontology changes that includes creating a sequence between s1 and s2 and connecting outputs of s1 to the corresponding inputs of s2. Therefore, public administrators require a method for expressing their needs for changes in an exacter, easier and more declarative manner. For them, it would be more useful to know that they can connect two services, rather than to know how it is realized. The full set of changes for the OntoGov model is defined in (Stojanovic, at al., 2006). These changes correspond to the “conceptual” operation that someone wants to apply without understanding the details (i.e. a set of ontology changes) that the change management system has to perform. Change preservation Changes are forces that drive the evolution. They can be applied to a consistent description of an e-government service, and after all the changes are performed, the description must pass into another consistent state. Therefore, when updating a service description, it is not enough just to consider the entities figuring in the request for a change, because the other entities in the same description may also be affected by the updates. Since it is not sufficient to change only a part of the description that is related to the request for a change while keeping all the other entities intact, we introduce the change preservation phase. Its task is to enable the resolution of changes in a systematic manner by ensuring the consistency (Haase, Stojanovic, 2005) of the whole description of an e-government service. This is elaborated in next section. Change implementation The role of the change implementation phase is (i) to inform a public administrator about all consequences of a change request, (ii) to apply all the (required and derived) changes and (iii) to keep track of performed changes. Notification In order to avoid performing undesired changes, before applying a change to a service description, a list of all implications to the service description should be generated and presented to a public administrator who modifies the service description. Only if the public administrator is informed about all the changes that are going to be performed on a request, she can make strategy decisions posed by the system. The public administrator should however have possibilities to make such choices or even to abort the entire modification when she realizes that it would have undesired consequences for other parts of the service description. Consequently, she should be able to comprehend a list of all the changes and approve or cancel them. When the changes are approved, they are performed by successively resolving changes from the list. If changes are cancelled, the service description remains intact. Change application In order to give a public administrator a chance to cancel a change after it has been completely analyzed, it is necessary to separate the analysis of the user’s request for the change from the final execution of this request within the change management system. Therefore, the main task of the change implementation phase is the application of changes. During this phase all changes (i.e. required and derived changes) are applied to a consistent service. --- 7 The analysis of a change covers the change preservation and the change propagation phases, where the change is extended with the additional changes that ensure the consistency. description and result into a new consistent service description. Indeed, one of the main advantages of our change management process is the separation of the phases where requests are analyzed from the final execution of the changes. This separation was naturally driven by the need for the transaction\(^8\). Only after a successful commitment of the hypothetical “reasoning” performed by the change preservation, the changes in effect took place on the service description itself. Once acknowledged by the public administrator for the implementation, all the changes are considered as an atomic “transaction” (i.e. they act like a transaction), although they are executed step by step. **Change Logging** The next task of the change implementation is to keep track about the performed changes. Information about changes can be represented in many different ways. To communicate about changes, we need a common understanding of a change model and of a log model. Therefore, we introduce the service evolution ontology and the service evolution log (Stojanovic, 2004). The service evolution ontology is a model of ontology changes enabling better management of these changes. The service evolution log tracks the history of applied changes as an ordered sequence of information (defined through the service evolution ontology) about a particular change. Moreover, the **change reversibility** is also supported. It enables undoing and redoing changes made in an ontology-based description of the e-government service. Consequently, changes can be executed in reverse order thus forcing the service description to return to the conditions prior to the change execution. It is important to note that reversibility means undoing all effects of some change, which may not be the same as simply requesting an inverse change manually. For example, if an atomic service is deleted from a process model, its metadata and links will need to be deleted as well. Reversing such a change is not equal to recreating the deleted atomic service – one needs, also, to revert the metadata and the links into the original state. **Change propagation** The basic requirement for a management system is that it has to be simple, correct and usable for public administrators. Note that they are responsible for keeping semantic description of services up-to-date and don’t need to be experienced ontology engineers. Thus, a management system must provide capabilities for the automatic identification of problems in the semantic description of e-government services and ranking them according to their importance. When such problems arise, a management system must assist the public administrators in identifying the sources of the problem, in analysing and defining solutions for resolving them. Finally, the system should help in determining the ways for applying the proposed solutions. The role of a change management system is much more than finding inconsistencies in a description and alerting a domain expert about them. This is pretty much the kind of support provided by conventional compilers. However, helping public administrators notice the inconsistencies only partially addresses this issue. Ideally, a change management system should be able to support domain experts in resolving the problems at least by making suggestions how to do that. The following procedure has been realized: - **Checking actuality of the associated Ontologies** – Since each ontology has a version number associated with it that is incremented each time the ontology is changed, checking the equivalence of the original of the included ontology and the replica can be done by a simple comparison of the version numbers. - **Extracting Deltas** – After determining that the included ontology needs to be updated, the evolution log for this ontology is accessed. The extracted deltas contain all changes that have been applied to the original after the last synchronization with the replica, as determined by the version numbers. - **Analysis of changes** – Each performed change is analysed, in order to find e-government services that have to be updated. We distinguish between the addition and the deletion of an entity from the included ontology. Removals can be resolved directly by applying the consistency preservation mechanism (see next section), since it ensures the consistency by generating additional changes. For example, the removal of a role from the Organisation ontology causes the removal of all annotations of activities made using this role or all instantiations of this role. On the other hand, the addition requires an additional effort that depends on the structure of the included ontologies. Here we describe how this problem is resolved in the e-government domain by considering the Legal ontology. We analyse the addition of a new amendment. The goal is to find services that realize the law related to this amendment, and to order them in an appropriate way. Since each activity is referred to a law/chapter/paragraph/article, the corresponding activities can be easily found. In case there are several services referring to the given law (e.g. through a paragraph or an amendment), they are ranked according to the semantic similarity that is based on calculating the distance between two entities in the hierarchy. - **Making recommendation:** In order to make recommendations how to adapt the service description we use the Lifecycle ontology. Since it is a description of the service design process, which clarifies which design decisions were taken for which reasons, it proves to be valuable for further development and maintenance. Let’s consider an example. A change in the Organizational ontology could be the split of the organizational unit into two sub-units. This “organizational reason” might cause the design decision “Executing an activity in two steps”, i.e. --- \(^8\) A transaction represents a sequence of actions that is treated as a unit for the purposes of satisfying a request. For a transaction to be completed, it has to be accomplished in its entirety. two (atomic) activities. For example, the decision to split the activity “CheckEligibility” shown in Figure 8 into two activities can be caused by the fact that two different public authorities are responsible for this action: the residents’ registration verifies personal information and the “immigration office” verifies the validity of the visa, in case the citizen is foreigner. **Change preservation** In this section, we present a novel approach to the consistency preservation that supports the public administrators in managing and optimizing the service descriptions according to their needs. The underlying system is able to find the “weak places” in the description of the e-government services (e.g. unreachable entities, non-expected data, etc.) by considering the semantics of the underlying OntoGov model. The proposed approach incorporates mechanisms for verifying the service description with respect to different consistency criteria as well as mechanisms enabling us to take actions to optimize it. It has been realized through two sub-tasks: - **Verification**: It is responsible for checking the consistency of a service description. Its goal is to find “parts” in the description that do not meet consistency conditions; - **Evolution**: It is responsible for ensuring the consistency of the service description by generating additional changes that resolve detected inconsistencies. In the rest of this section we describe our approach for inconsistency detection. Thereafter, we present our approach for “moving” the inconsistent ontology back into a consistent state, i.e. change generation. **Verification** In this section we explore the verification of the OntoGov model, which means checking of the correctness of the service description with the respect to the service consistency definition. Moreover, it provides enough information to analyze the sources of conflicts. Its role will be to inform a public administrator about the necessity for updating the description of an e-government service, and to allow the application of the service changes, enabling an easy spotting of potential problems. The description of the e-government services (or more generally the description of the semantic web services) can be arbitrary complex, containing multiple concurrent threads that may interact in unexpected way (Ankolekar, et al., 2005). We propose an approach that is able to verify numerous properties. The set of properties is not predefined, which means that it does not include only the standard properties such as safety, liveness, etc. (Naumovich, G., Clarke, L., 2000), but more important it can be easily extended by the application specific properties. Verification of description of e-government services is realized using formal methods. These methods seek to establish a logical proof that a system works correctly. A formal approach provides: - a modeling language to describe the system; - a specification language to describe the correctness requirements; and - an analysis technique to verify that the system meets its specification. The model describes the possible behaviors of the system, and the specification describes the desired behaviors of the system. The statement the model P satisfies the specification α is now a logical statement, to be proved or disproved using the analysis technique. Since the goal of the inconsistency detection is to check whether a service description satisfies the required specification, it can be treated as a formal verification problem in which: (1) a modelling language used to describe a system is defined through the OntoGov model, (2) a specification language corresponds to the consistency constraints that must be preserved and an analysis technique can be treated as inference process. Whereas the model of the e-government services is described in section OntoGov Model, the consistency is defined in (Stojanovic, et al., 2006). In the rest of this section we focus on (3). Formal verification methods can be roughly classified as: - Proof-theoretic: a suitable deductive system is used, and correctness proofs are built using a theorem prover, and - Model-theoretic: a model of the run-time behaviour of the system is built, and this model is checked for the required properties. In this section we explore the verification of the OntoGov model using proof-theoretic method. Once we have a service description plus the formally defined consistency constraints that correspond to the users’ requirements, we can automatically check whether these constraints are satisfied in the service description with the help of the reasoning. The KAON2 inference engine is used, since it implements the proof-theory for DL and DL-safe rules. By performing an efficient exploration of the possible inconsistencies that can be built in the service description, the system is able to verify all the consistency constraints\(^\text{10}\) defined for the OntoGov model. One example of these constraints is given in Figure 10. The set of the consistency constraints as well as a description of the concrete service are inputs to the KAON2 inference engine that is used to automatically verify whether the service description satisfies the consistency. Practically, a query is sent, since possible problems are hierarchically organized. A trace of the answer to a query is considered as a model that reflects how different pieces of a service description are put together to generate the answer. If the KAON2 verifies that the consistency constrains are fulfilled (i.e. there is no inconsistency). \(^9\) http://kaon2.semanticweb.org \(^{10}\) Since in this work we use the KAON2 inference engine, the consistency constraints must be specified as DL-safe rules. answer), then the service description is consistent. Otherwise, the KAON2 provides explanation about causes of problems, since it can identify the conditions under which the problem occurs. \[ \text{ErrorReachable}(X) \leftarrow \\ \neg \text{isReachable}(X) \\ \text{isReachable}(Y) \leftarrow \\ \text{isReachable}(X) \land \\ \text{hasNext}(X,Y) \\ \text{isReachable}(Y) \leftarrow \\ \text{hasFirstService}(X,Y) \] Figure 10. Verification based on the constraints. A part of consistency rules is depicted in the left part. The right part shows the process model that does not satisfy the rules. The realised verification procedure is depicted in Figure 11. The set of the consistency constraints selected/defined\(^{11}\) by the public administrator are transformed into a set of DL-safe rules and these rules are included in the temporary version of the OntoGov Profile and OntoGov Process ontology, respectively. Since the description of a concrete service includes both of these ontologies, it will include the rules to be checked. The service description is given to the KAON2 reasoner and the query “about all possible errors” is initiated. The result produced by KAON2 reasoner is then presented to the public administrator in the form that he/she can understand. Even though logic provides an unambiguous formal specification, it is hard to imagine that a public administrator will comprehend it. Therefore, “wrapping” into a more friendly formalisms, i.e. natural language explanation\(^{12}\) has been proposed. It means that in the case of any violations of consistency constraints, the reasoner will output a counterexample, which demonstrates the courses of wrong behaviour. An analysis of this counterexample provides information that helps to correct and refine the service description. For example, a precondition of an activity is not achieved because there are some previous activities that undo the precondition. Let’s consider the driving licence service for foreigners in Germany. The preconditions of the Application activity includes that foreigners come from non-EU countries. Since the special verification is required for the countries emerged from the break-up of Yugoslavia, there is an activity in the process model that has a precondition that the foreigners must be from Slovenia. However, the Application activity undoes this precondition, since Slovenia is a member of EU. It is very difficult for a user to notice that some of the paths in the model are not be possible due to at least two reasons: (i) this service description is very complicated with many disjunctive branches, and (ii) the background knowledge (i.e. the fact that Slovenia is in EU) is needed. Our system is able to detect this problem by applying reasoning methods (i.e. there is a corresponding consistency constraint\(^{13}\)) and to help the user fix problem. It can find activities in the process model that should be executed before the failed activity that have effects that undid the unachieved preconditions. Moreover, it suggests modifying the activity whose precondition can never be achieved. For the above mentioned type of failure, our system suggests (i) changing or adding constraints for the Application activity and (ii) deleting or modifying the Verification activity. Moreover, the system is also able to propose changing ordering constraints among the activities. For example, the user may either forget to specify connections between the activities or may specify wrong connections. These problems may be detected by checking a particular consistency constraint\(^{14}\) that defines the certain ordering constraints already specified for the type of these activities. During the verification, the system checks (among others) the dependencies between activities using the ordering consistency constraint. In the case that some activity does not satisfy the ordering constraint, the system produces the error message containing the fixes such as adding or modifying dependency between activities. We note that the same problem can be a consequence of different inconsistencies in the model, since one abnormality can lead to another. For example, missing the first activity in a model causes unreachable activities. To help avoid confusion, our system can selectively present suggestions for improvement by focusing the user on the actual cause of a problem. For the previous example, the system suggests starting with the resolution of the first activity problem. However, the user can check other problems as well, in the case that he/she what to do that. For the description of e-government services the proposed solution seems to be an ideal technique, since only consistency constraints defined by the public administrators need to be considered. The probability of running into the undecidable solution is quite low, since the restriction to the DL-subset of SWRL rules has been chosen to make reasoning decidable. Moreover, reasoning in KAON2 is implemented by novel algorithms that allow applying well-known deductive database techniques, such as magic sets, to DL reasoning. According to the performance evaluation (Motik, Sattler, 2005), such algorithms make answering queries in KAON2 one or more orders of magnitude faster than in existing systems. \[^{11}\] A user can select consistency criteria from the list of available consistency constraints and/or can define a new consistency criterion. \[^{12}\] We do not use logical notations since public administrators do not have logic background knowledge. For each possible problem, an explanation in natural language is generated. \[^{13}\] If an activity precedes another activity, then its preconditions have to subsume the preconditions of the next one. \[^{14}\] Any specialisation of the activity A1 must always be a predecessor of any specialisation of the activity A2, where A1 and A2 are two activities defined in the OntoGov model and their order is given in advance. Formal verification: Based on the possible behaviours (i.e., a ontology-based service description) and on the desirable behaviours (i.e., formally defined consistency constraints) the system constructs a proof that either proves or disproves the correctness claim. In this work we applied the formal techniques based on the sound and complete set of consistency rules (provided with an inference mechanism) to verify the models. The informal approaches, such as the procedural approach, whose semantics is given by a procedural mechanism that is capable of providing answer to wide class of consistency problems, can be applied as well. However, the extensibility of the procedural approach is time-consuming and error-prone, since knowledge about consistency is represented by means of an ad hoc structure. Alternative approaches cover testing, which executes the actual model on selected inputs or simulation, which simulates a model on selected inputs (not exhaustive), cannot be applied, since they perform the so-called dynamic checks. On the contrary, our approach performs static checks by posting questions about various features of the service description. Evolution Changes are applied to a consistent service description, and after all the changes are performed, the description must remain consistent. This is done by finding inconsistencies in the description and completing required changes with additional changes, which guarantee the transfer of the initial consistent description into another consistent state. Indeed, the updated service description is not defined directly by applying a requested change. Instead, it is indirectly characterized as a service description that satisfies the user’s requirement for a change and it is at the same time a consistent e-government service description. Therefore, there are two major issues involved in the change generation. The first issue is the understanding how an ontology-based service description can be changed since the change management is realized by means of applying changes. To resolve the first issue a possible set of changes is defined in (Stojanovic, at al., 2006). The second issue involves deciding when and how to modify a service description to keep its consistency, which is elaborated in (Stojanovic, 2006). It is based on the formal approach for suggesting fixes that directly point to the source of the errors. Indeed, each possible change is formally modelled. The most critical part of a definition change is rules that specify the side effects of a change on the other related entities. To define the rules for each change, we started by finding out the cause-effect relationship between the changes. This kind of dependency between the changes forms the so-called change dependency graph. A sample screenshot of the OntoGov change management system illustrating triggered actions (i.e., generated changes) for the removal of the atomic activity is given in Figure 12. In this scenario, the user requested to remove the atomic activity B. According to the change dependency graph, this change may cause: - Remove all input links of AtomicActivity B; - Remove all output links of AtomicActivity B; - Remove all metadata defined for AtomicActivity B that includes: - the attributes such as name, description, first and last service; - the relations to the associated ontologies (i.e., Legal, Organizational and Lifecycle ontology); - the relations to the inputs and outputs defined through the Domain ontology; - the pre- and post-conditions. Before changes are performed, their impact is reported to the user (the right part of Figure 12). Presentation of changes follows the progressive disclosure principle: related changes are grouped together and organized in a tree-like form. The user initially sees only the general description of changes (cf. “Delete atomic service B” in Figure 12). By opening a node in the tree, the user can see what changes will actually be performed (cf. “Delete input parameter CertificateInstanceName” in Figure 12). Hence, the change information can be viewed at different levels of granularity. If the user is interested in details, she can view the detailed dependencies and their impact on the service description. --- 15 A link can be a sequence or a relation to the split, join or switch control construct. expand the tree and view complete information. She may cancel the operation before it is actually performed. **Implementation** OMS is the ontology management system that has been developed within the OntoGov project. It is a management system for the ontology-based description of the e-government services. It is much more than a standard framework for creating, modifying, querying, and storing ontology-based description of e-government services. It provides support for the service lifecycle management, which includes service modelling; service reconfiguration, service reuse, service discovery and service analysis. ![Conceptual architecture of the OMS](image) **Figure 13.** Conceptual architecture of the OMS The simplified conceptual architecture of the OMS system is presented in Figure 13. Roughly, the OMS components can be divided into three layers: - **Applications and Services Layer** realizes UI applications and provides interfaces to non-human agents. It includes: - (i) **Service Modeller** – it is an editor for the semantic description of the e-government services and (ii) **Service Registry** – it is a registry of the e-government services. - The Service API as part of the Middleware Layer is the focal point of the OMS architecture. The bulk of requirements related to the management of e-government service description is realized in this layer; - **Data and Remote Services Layer** provides data storage facilities. It is based on KAON2 API, which is an API for OWL ontologies. The middleware layer of the OMS shown in Figure 13 emphasizes points of interest related to the change management. The main modules are (i) **basics module**; (ii) **consistency preservation module**; (iii) **change implementation module**; (iv) **change propagation module**; (v) **lifecycle module** and (vi) **registry module**. The functionality as well as the implementation of these modules is described in (Stojanovic, Apostolou, 2005). Our initial evaluation shows that the OMS is able to find all inconsistencies in the service description and to suggest useful fixes including the fixes that directly point to the source of the inconsistencies. **Related work** OWL-S process models are typically verified using human inspection, simulation and testing. In this paper we proposed the formal verification, which as opposed to traditional techniques such as testing and simulation has two main advantages (i) formality - the intuitive correctness is made formally; and (ii) verification - the goal of the analysis is to prove or disprove the correctness claim. It is not adequate to check a representative sample of possible behaviours as in simulation; rather a guarantee that all behaviours satisfy the specification is required. The verification of the OWL-S process model is described in (Narayanan, McIlraith, 2002) and (Ankolekar, et al., 2005). Whereas the first paper proposes a Petri Net-based operational semantics, which models the control-flow of a process model, the second paper additionally models the data flow and applies the SPIN model-checker as the automatic verification tool. We extend these works in several dimensions. First, we model not only the control-flow and data flow consistency constraints. We allow to the public administrators to specify arbitrary domain-dependent consistency constraints. In this way we are able to cover all perspectives of the business models, i.e. control flow, data flow, operational issues (e.g. interactions between systems) and resources (e.g. humans, machines etc.). Second, we do not consider only the process model but also the profile of a service. Finally, we have realized --- 16 OiMModeller is used as an editor for the “standard” ontologies. It is a graphical tool for ontology creation and maintenance. Since it is based on the different ontology model, we have realized a translator of the KAON ontologies (http://kaon.semanticweb.org/) into the KAON2 ontologies (http://kaon2.semanticweb.org/). We note that each KAON ontology can be transformed into a KAON2 ontology without loss of information. the verification of the e-government service descriptions using rule-based inference process. Many AI researchers have investigated useful ways of verifying and validating knowledge bases for ontologies and rules. However, it is not easy to directly apply them to checking process models. In (Kim, Gil, 2001) the authors discussed the KANAL system that relates pieces of information in process models among themselves and to the existing knowledge base, analyzing how different pieces of input are put together to achieve some effect. It builds interdependency models from this analysis and uses them to find errors and propose fixes. However, it does not allow the user to specify their specific conditions, even though the predefined set of constraints doesn’t cover all the users’ needs. Our approach allows the user to define the user-defined conditions. Moreover, it separates the specification of consistency from the realization of the change preservation procedure. Finally, the inconsistency detection and the change generation procedures are governed by well-defined formal models that are fully automated. Therefore, the approach is accessible by public administrators who are not experts in formal methods. There are many graphical tools (ARIS, Adonis, to name just a few) that lay out a process model and draw connections among steps. These tools lack formal methods for verifying properties of processes. Indeed, they tools are limited to simple checks on process models, since there is no semantics associated to the individual steps. In contrast, we propose an approach that allows to the users to formally specify consistency constraints. Ontologies and rules are used to represent this kind of background knowledge or user’s needs. With this context, our system is much more helpful in checking the process model. Moreover, our system can check the service profile as well and it proposes suggestions for resolving the problems. Conclusion e-government systems are subject to a continual change. The importance of better change management is nowadays more important due to the evolution of Europe towards a multicultural, more open and international society with changing common values, increasing levels of education, demographic involvement and adoption of new technologies. It is especially true for the new EU countries, since the European integration has paved the way for new legislation, regulations and corresponding changes that affect the way public administrations in the enlarge Europe are organized and operate. It is clear that ad hoc management of changes in eGovernment might work only for particular cases. In order to avoid drawbacks in the long run, the change management must be treated in a more systematic way. In this paper we presented an approach for ontology-based change management. Our approach goes beyond a standard change management process; rather it is a continual improvement process. The novelty of the approach lies in the formal verification of the service description as well as in the using of formal methods for achieving consistency when a problem is discovered. Acknowledgement The research presented in this paper was partially funded by the EC in the project “IST PROJECT 507237 - OntoGov”. References Motik, B., Sattler, U., 2005, Practical DL Reasoning over Large ABoxes with KAON2
{"Source-Url": "http://www.aaai.org/Papers/Symposia/Spring/2006/SS-06-06/SS06-06-020.pdf", "len_cl100k_base": 11078, "olmocr-version": "0.1.50", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 38053, "total-output-tokens": 12324, "length": "2e13", "weborganizer": {"__label__adult": 0.0003311634063720703, "__label__art_design": 0.0007925033569335938, "__label__crime_law": 0.0015554428100585938, "__label__education_jobs": 0.003787994384765625, "__label__entertainment": 0.0001685619354248047, "__label__fashion_beauty": 0.0002624988555908203, "__label__finance_business": 0.002460479736328125, "__label__food_dining": 0.00041031837463378906, "__label__games": 0.0008845329284667969, "__label__hardware": 0.0010166168212890625, "__label__health": 0.0008840560913085938, "__label__history": 0.0009403228759765624, "__label__home_hobbies": 0.00013518333435058594, "__label__industrial": 0.0006489753723144531, "__label__literature": 0.0006709098815917969, "__label__politics": 0.0029773712158203125, "__label__religion": 0.0004982948303222656, "__label__science_tech": 0.290771484375, "__label__social_life": 0.0002233982086181641, "__label__software": 0.1082763671875, "__label__software_dev": 0.58056640625, "__label__sports_fitness": 0.00022101402282714844, "__label__transportation": 0.0009679794311523438, "__label__travel": 0.0003104209899902344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 59691, 0.01378]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 59691, 0.53973]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 59691, 0.93114]], "google_gemma-3-12b-it_contains_pii": [[0, 7168, false], [7168, 11639, null], [11639, 15565, null], [15565, 20380, null], [20380, 22815, null], [22815, 28293, null], [28293, 34383, null], [34383, 40141, null], [40141, 46121, null], [46121, 50472, null], [50472, 54570, null], [54570, 59691, null]], "google_gemma-3-12b-it_is_public_document": [[0, 7168, true], [7168, 11639, null], [11639, 15565, null], [15565, 20380, null], [20380, 22815, null], [22815, 28293, null], [28293, 34383, null], [34383, 40141, null], [40141, 46121, null], [46121, 50472, null], [50472, 54570, null], [54570, 59691, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 59691, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 59691, null]], "pdf_page_numbers": [[0, 7168, 1], [7168, 11639, 2], [11639, 15565, 3], [15565, 20380, 4], [20380, 22815, 5], [22815, 28293, 6], [28293, 34383, 7], [34383, 40141, 8], [40141, 46121, 9], [46121, 50472, 10], [50472, 54570, 11], [54570, 59691, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 59691, 0.0]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
8aa52923caf2c1c1099dad7df48fb9f15a1df6a5
# Table of Contents Chapter 1 - Purpose ............................................................................................................. 1 Chapter 2 - Prerequisites .................................................................................................. 3 2.1. Hardware Requirements .......................................................................................... 3 2.2. Java SE Runtime (JRE) 1.7 or 1.8 ......................................................................... 3 2.3. Application Server ............................................................................................... 3 Apache Tomcat 7 or 8 ............................................................................................. 4 Enable Unicode support in Tomcat ........................................................................ 4 Tomcat Memory Settings ......................................................................................... 4 2.4. Database .............................................................................................................. 5 Chapter 3 - Installing IKAN ALM .................................................................................. 6 3.1. Running the installer ............................................................................................ 6 For Windows users .................................................................................................. 6 For Linux/Unix users .............................................................................................. 6 3.2. Language Selection, Welcome, Readme and License Panels ................................ 7 3.3. Selecting the Packages to Install .......................................................................... 9 3.4. Installing the Server ............................................................................................ 9 ALM Server parameters (1 of 2) ........................................................................... 10 ALM Server parameters (2 of 2) ........................................................................... 11 Tomcat parameters ............................................................................................... 12 Database connection parameters ........................................................................... 13 3.5. Installing the Agent ............................................................................................. 14 3.6. Installing the Commandline .................................................................................. 16 3.7. Summary and installation ..................................................................................... 17 3.8. Initializing the IKAN ALM Database ..................................................................... 19 Chapter 4 - Starting IKAN ALM ..................................................................................... 21 4.1. Starting the IKAN ALM Web application ............................................................... 21 4.2. Starting the IKAN ALM Server ............................................................................. 22 4.3. Starting the IKAN ALM Agent .............................................................................. 22 4.4. Using the IKAN ALM Commandline ................................................................. 22 | Chapter 5 - | Uninstalling IKAN ALM | ................................................................. | 24 | | Chapter 6 - | Upgrading IKAN ALM | ................................................................... | 25 | | 6.1 | IKAN ALM Upgrade Procedure | ................................................................................. | 25 | | 6.2 | Database Migration Tool | ......................................................................................... | 26 | | Appendix A - | Manually Installing and Removing the IKAN ALM Server and Agent as a Windows Service | ........................................................................................................ | 28 | | Appendix B - | Manually Installing and Removing the IKAN ALM Server and Agent as a Daemon Process on Linux/Unix Systems | ........................................................................................................ | 29 | | Appendix C - | JAAS configuration | ............................................................................. | 31 | | C.1 | IKAN ALM Server JAAS configuration | .............................................................................. | 31 | | C.2 | JVM option or user.home JAAS configuration | ........................................................................ | 32 | | C.3 | JAAS implementation: flat file security | ............................................................................. | 32 | | C.4 | Flat file security: contents | ...................................................................................... | 32 | | Appendix D - | DB2 configuration | ............................................................................... | 33 | | Appendix E - | Troubleshooting | .................................................................................. | 34 | | E.1 | The installer doesn’t start and displays the error : "Java Runtime not found" | ........................................................................................ | 34 | This document explains how to install IKAN ALM using a graphical installer. If you want to install IKAN ALM using the console installer, please refer to the document *HowToALM 5.8_Tomcat.Install*. IKAN ALM consists of 3 major components: - IKAN ALM Server - IKAN ALM Agent - IKAN ALM Commandline An IKAN ALM installation needs exactly 1 Server and at least 1 Agent to function correctly. The IKAN ALM Server consists of 3 different components: - the IKAN ALM Web Application - the IKAN ALM Server daemon - the IKAN ALM Server environment The IKAN ALM Web Application is an interface to the IKAN ALM administration, and must be deployed on a Java EE Web container. The IKAN ALM Server daemon itself consists of 2 sub-components, a Scheduler and a Monitor. The IKAN ALM Scheduler is responsible for observing the VCR (Version Control Repository) and creating a Build request when changes (modified sources) in the VCR are detected. The IKAN ALM Monitor will manage the different build and deploy actions that are executed by the IKAN ALM Agent(s). Both the IKAN ALM Server and the IKAN ALM Agent run as OSGi bundles in Apache Karaf containers, benefiting from the advantages of a modular architecture. The IKAN ALM Server daemon will be installed in the IKAN ALM Server Environment, and may be launched by scripts, or started as a Windows service or Unix/Linux daemon. The IKAN ALM Server Environment contains the following important files and folders: - **Build Archive Location**: the location where the Build results will be stored, - **Work Copy Location**: the location where the sources that are checked out from the repository are stored before they are transported to the Agents, - **Phase Catalog Location**: the location where the Phases that have been imported will be stored, ready to be retrieved by remote Agents when needed, - **Scripts Location**: the location to be used for storing centralized build and deploy scripts, - **Configuration with the (external) security system. For more information, refer to the Appendix [JAAS configuration](#) (page 31), - **Documentation in PDF format.** A machine that needs to execute IKAN ALM Builds and Deploys must have the IKAN ALM Agent installed. The IKAN ALM Commandline can be installed separately and can be used as an alternative for the web interface to create Level Requests and Reports via a command prompt. Example configuration 1: Single machine, everything locally installed: - Machine 1: Server, Agent, Commandline Example configuration 2: Multiple machines, remote Agent and Commandline: - Machine 1: Server, Agent - Machine 2: Agent, Commandline The following section provides an overview of the prerequisites for installing IKAN ALM. The complete requirements are available online at [http://www.ikanalm.com](http://www.ikanalm.com). ### 2.1. Hardware Requirements <table> <thead> <tr> <th>Component</th> <th>Memory</th> <th>Disk</th> </tr> </thead> <tbody> <tr> <td>IKAN ALM Server</td> <td>Min 1GB, recommended 2GB</td> <td>Min 10GB, recommended 40GB</td> </tr> <tr> <td>IKAN ALM Agent</td> <td>Min 256MB, recommended 512MB</td> <td>Min 1GB</td> </tr> <tr> <td>IKAN ALM Commandline</td> <td>Min 128MB, recommended 256MB</td> <td>Min 40MB</td> </tr> </tbody> </table> Note that these are just indicative values. If the IKAN ALM Server will also act as a Build Server, it might have more demanding memory requirements depending on the number of builds that run concurrently. For a more mathematical approach, we refer to the article “Capacity Planning for Software Build Management Servers” on the “CM Crossroads” site: [http://www.cmcrossroads.com/article/capacity-planning-software-build-management-servers](http://www.cmcrossroads.com/article/capacity-planning-software-build-management-servers). There is no hard and fast rule for disk storage space. The actual amount you will require depends on the number and size of the projects managed with IKAN ALM, and on the size of the build results stored in the build archive. More projects and larger build results mean more required disk space. ### 2.2. Java SE Runtime (JRE) 1.7 or 1.8 All IKAN ALM components need at least a Java Development Kit (JDK) or a Server Java Runtime (Server JRE). IKAN ALM has been tested to run with both Oracle Java and OpenJDK. The Java SE Server Runtime Environment (Server JRE) or Software Development Kit (SDK) can be freely obtained from Oracle’s website. Both 32-bit and 64-bit versions are supported. The latest version of Java SE can be downloaded from [http://www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.oracle.com/technetwork/java/javase/downloads/index.html). ### 2.3. Application Server The IKAN ALM Web application requires a Java EE 5 to 7 compliant web container, supporting the Servlet 2.5 to 3.1 and JSP 2.1 to 2.3 specifications. Apache Tomcat 7 or 8 IKAN ALM has been tested with Apache Tomcat 7.0.55 and later versions. When choosing a version, please check Tomcat's own prerequisites (e.g. Tomcat 8 requires at least Java SE v 7). IKAN ALM has been proven to run on Tomcat on different Operating Systems, including recent versions of Windows and Linux, Sun Solaris, HP Unix, MacOS X, zLinux, … If a suitable Java Runtime is available (Java SE Runtime (JRE) 1.7 or 1.8 (page 3)), IKAN ALM may run on other Operating Systems. Consult the detailed Technical Requirements on _http://www.ikanalm.com_. Enable Unicode support in Tomcat When using Unicode symbols in IKAN ALM (for instance, projects containing files with special characters in the name), an extra setting should be applied to the Tomcat’s server.xml configuration file. Modify the TOMCAT_HOME/conf/server.xml file: in the http connector, add the attribute URIEncoding="UTF-8": ```xml <Connector port="8080" protocol="HTTP/1.1" URIEncoding="UTF-8" connectionTimeout="200000" redirectPort="8443" /> ``` This fix is based on the article: _http://wiki.apache.org/tomcat/FAQ/CharacterEncoding_. Tomcat Memory Settings It is recommended to set the following memory settings for running IKAN ALM with Java 8 in Tomcat: • initial Java heap size (-Xms) : 128m • max Java heap size (-Xmx) : 384m • max Metaspace size (-XX:MaxMetaspace) : 128m If you launch Tomcat from the startup scripts, you need to create or edit TOMCAT_HOME/bin/setenv.bat (Windows) or TOMCAT_HOME/bin/setenv.sh (Linux/Unix), and to add, near the top of the file, a line like: • for Windows: SET JAVA_OPTS=-Xms128m -Xmx384m -XX:MaxMetaspaceSize=128m • for Linux/Unix: JAVA_OPTS=-Xms128m -Xmx384m -XX:MaxMetaspaceSize=128m If you run Tomcat as a Windows service, you need to set the memory settings in the file TOMCAT_HOME/bin/service.bat. Add the following lines near the top of the file: ```bash set JvmMs=128 set JvmMx=384 set JvmArgs=-XX:MaxMetaspaceSize=128m ``` After these modifications, you need to re-install the service by running "service.bat remove", followed by "service.bat install". You need Administrative privileges to run these commands. If you use Java 7, replace the setting -XX:MaxMetaspaceSize=128m with -XX:MaxPermSize=128m. For an explanation, refer to _http://javaeessupportpatterns.blogspot.co.uk/2013/02/java-8-from-permgen-to-metaspaces.html_. IKAN Development 2.4. Database IKAN ALM supports MySQL, MsSQL, Oracle and DB2 database as the back-end. During the installation, it is possible to verify a connection to an existing database, as well as to initialize the existing database with the default data. Beware that when the DB initializing option is selected, the existing data will be overwritten. Before initializing the database, make sure the database/scheme exists. For MySQL, it is recommended that the database has a character set of UTF8. Here is an example of the MySQL script creating a database from scratch: ``` CREATE DATABASE alm CHARACTER SET utf8 COLLATE utf8_unicode_ci; ``` Consult your database documentation for more information on the appropriate UTF8-collation for your system. This section describes the different steps for installing IKAN ALM. ### 3.1. Running the installer **For Windows users** Execute either the 32-bit or the 64-bit installer: - alm_install_5-8_x86.exe To run this installer image, you will need to have a 32-bit Public Java Runtime Environment (Public JRE) installed. - alm_install_5-8_x64.exe To run this installer image, you will need to have a 64-bit Public Java Runtime Environment (Public JRE) installed. Refer to [Troubleshooting](#) (page 34) when the IKAN ALM installer won’t start. The graphical IKAN ALM installer will start. Depending on the flavor of Windows OS used, there can be differences in the installer’s behavior. If UAC is enabled (Windows Vista and later), Windows will ask for a confirmation for the program to make changes to the computer (if your user account is an administrator). If you are trying to install the application from an account other than Administrator, you might get the message "requested operation requires elevation". **For Linux/Unix users** Before installing ALM, make sure that the \$JAVA_HOME/jre/lib/security/java.security’ file has write access for the current user, otherwise the installation can fail. An example of granting the maximum access to the file: ```bash sudo chmod 777 /usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security ``` Open a shell, go to the folder containing the IKAN ALM installation files and execute `java -jar alm_install_5.8.jar`. Assuming Java is installed and present in the PATH, the graphical IKAN ALM installer will start. 3.2. Language Selection, Welcome, Readme and License Panels 1. Choose the installation language and click OK. The following welcome screen will be displayed: 2. Click Next to continue. The following screen is displayed: ![Image of IKAN ALM installation screen 1] 3. Carefully read the readme information and click Next to continue. The following screen is displayed: ![Image of IKAN ALM installation screen 2] 4. Read the license agreement carefully. Select the option “I accept the terms of this license agreement” and click the Next button. 3.3. Selecting the Packages to Install The packages panel is displayed: Here you can select which IKAN ALM components you wish to install. By default, all components are selected. Select the component(s) you wish to install, and then click Next. Refer to the following sections for more information on the installation options: - Installing the Server (page 9) - Installing the Agent (page 14) - Installing the Commandline (page 16) 3.4. Installing the Server This section explains the installation options of the IKAN ALM Server component. Note: The panels in this section are only displayed if you selected the “ALM Server” package. The following fields are available: <table> <thead> <tr> <th>Field</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Install Path</td> <td>Select the location where IKAN ALM should be installed. The default is <code>C:\ALM</code> on Windows, and <code>$HOME/ALM</code> on Linux/Unix. You can change this location using the Browse button. Further on in this document, this location will be referred to as <code>ALM_HOME</code>.</td> </tr> <tr> <td>Java Path</td> <td>The installation directory of the Java Runtime that will be used to launch the Server. This can point to a Server JRE or JDK. By default, the Java Runtime that started the installer is selected. IKAN ALM needs a Server JRE or JDK 1.7 or 1.8. You can change this location using the Browse button. Files will be copied to the Install Path, and a file will be modified in a subfolder of the Java Path, so make sure that the user who will run the installation has write access to these locations. Make sure that the selected Java Runtime is the same as the one that is used to start Tomcat!</td> </tr> <tr> <td>Database type</td> <td>The type of database that will host the IKAN ALM database. The possible choices are: MySQL (default), MsSQL, Oracle, DB2. Specific parameters for the selected database can be provided later in the installation procedure.</td> </tr> </tbody> </table> Click *Next* to go to the second page of ALM Server parameters. ### ALM Server parameters (2 of 2) The following fields are available: <table> <thead> <tr> <th>Field</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Server port</td> <td>The port number used for communication between the Server and its Agents. Note that you must use this same port number in subsequent IKAN ALM Agent installations, otherwise the Agent-Server communication may fail. Default: 20021</td> </tr> <tr> <td>Agent port</td> <td>The port number the local IKAN ALM Agent is going to listen on. Default: 20020</td> </tr> <tr> <td>Karaf RMI Registry port</td> <td>The RMI registry port used by the Karaf container the IKAN ALM Server is running in. Default: 1100</td> </tr> <tr> <td>Karaf RMI Server port</td> <td>The RMI server port used by the Karaf container the IKAN ALM Server is running in. Default: 44445</td> </tr> <tr> <td>Karaf SSH port</td> <td>The SSH port used by the Karaf container the IKAN ALM Server is running in. Default: 8102</td> </tr> </tbody> </table> Click Next to go to the application server parameters panel. **Tomcat parameters** Provide the parameters of your Tomcat installation. <table> <thead> <tr> <th>Field</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Secure Server-Agent communication</td> <td>When enabled, this causes all Server-Agent communication to be encrypted.</td> </tr> <tr> <td>Tomcat parameters</td> <td></td> </tr> <tr> <td>Port</td> <td>The Tomcat HTTP Connector port. Default: 8080</td> </tr> <tr> <td>Tomcat home dir</td> <td>Set this to the home directory of the Tomcat installation that will host the IKAN ALM Web application.</td> </tr> </tbody> </table> Click Next to go to the Database parameters panel. Database connection parameters Depending on the database that was chosen to host the IKAN ALM database, a panel similar to this one will be displayed: The following fields are available: <table> <thead> <tr> <th>Field</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Host</td> <td>The host name of the database server. Default: the host name of the local system</td> </tr> <tr> <td>Port</td> <td>The port on which the database server is listening on. Default: the default port of the selected database type</td> </tr> <tr> <td>Database name</td> <td>The name of the IKAN ALM database.</td> </tr> <tr> <td>Schema</td> <td>The schema name, only available when the database type is DB2. Default: ALM</td> </tr> <tr> <td>Username</td> <td>A valid user that can connect to the database and has write access to it.</td> </tr> <tr> <td>Password</td> <td>A valid password.</td> </tr> <tr> <td>Initialize the database</td> <td>Specifies whether to initialize the IKAN ALM database. WARNING: when enabled, all IKAN ALM related tables in the target database will be dropped and populated with initial data!</td> </tr> <tr> <td>Validate connection</td> <td>Specifies whether to test the database connection parameters after pressing the Next button.</td> </tr> </tbody> </table> Click Next to continue the installation. 3.5. Installing the Agent When you selected the “ALM Agent” package, the following panel is displayed: The following fields are available: <table> <thead> <tr> <th>Field</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Install Path</td> <td>Select the target location where the IKAN ALM Agent should be installed. The default is <code>C:\ALM</code> on Windows, and <code>$HOME/ALM</code> on Linux/Unix. You can change this location using the Browse button. This field is initialized to the Server Install Path and greyed out when you also selected the IKAN ALM Server component.</td> </tr> <tr> <td>Java Path</td> <td>The installation directory of the Java Runtime that will be used to launch the Agent. This can point to a Server JRE or JDK. By default, the Java Runtime that started the installer is selected. The IKAN ALM Agent needs a Server JRE or JDK 1.7 or 1.8. You can change this location using the Browse button.</td> </tr> <tr> <td>Agent port</td> <td>The port the Agent will be listening on. The default value is “20020”. If you change this value, you will also have to change the “Agent Port” property of the Machine representing this Agent in the IKAN ALM Global Administration. This field is initialized and greyed out when you also selected the IKAN ALM Server component.</td> </tr> <tr> <td>Field</td> <td>Description</td> </tr> <tr> <td>-------------------------------</td> <td>---------------------------------------------------------------------------------------------------------------------------------------------</td> </tr> <tr> <td>Server host</td> <td>The hostname (or IP address) of the IKAN ALM Server machine. The Agent will try to connect to the Server by using this name or IP address and using the HTTP or HTTPS protocol. By default it is set to the host name of the local system. This field is initialized and greyed out when you also selected the IKAN ALM Server component.</td> </tr> <tr> <td>Server port</td> <td>The port the IKAN ALM Server is listening on. The Agent will try to connect to the Server on this port. The default value is “20021”. This field is initialized and greyed out when you also selected the IKAN ALM Server component.</td> </tr> <tr> <td>Karaf RMI Registry port</td> <td>The RMI registry port used by the Karaf container the IKAN ALM Agent is running in. Default: 1099.</td> </tr> <tr> <td>Karaf RMI Server port</td> <td>The RMI server port used by the Karaf container the IKAN ALM Agent is running in. Default: 44444.</td> </tr> <tr> <td>Karaf SSH port</td> <td>The SSH port used by the Karaf container the IKAN ALM Agent is running in. Default: 8101.</td> </tr> <tr> <td>Secure Server-Agent communication</td> <td>When enabled, this causes all Server-Agent communication to be encrypted. Default: disabled. This field is initialized and greyed out when you also selected the IKAN ALM Server component.</td> </tr> </tbody> </table> Click Next to continue the installation. 3.6. **Installing the Commandline** When you selected the “ALM CommandLine” package, the following panel is displayed: The following fields are available: <table> <thead> <tr> <th>Field</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Install Path</td> <td>Select the target location where IKAN ALM should be installed. The default is C: \ ALM on Windows, and $HOME / ALM on Linux/Unix. You can change this location using the Browse button. This field is initialized and greyed out when you also selected the IKAN ALM Server component or the IKAN ALM Agent component.</td> </tr> <tr> <td>Java Path</td> <td>The installation directory of the Java Runtime that will be used to launch the Commandline. This can point to a Server JRE or JDK. By default, the Java Runtime that started the installer is selected. The IKAN ALM Commandline needs at least a JRE or JDK 1.7. You can change this location using the Browse button.</td> </tr> </tbody> </table> Click Next to continue the installation. 3.7. Summary and installation A Summary panel will be displayed: Verify all defined parameters, and click Next to start the installation. When this step has finished successfully, click Next to perform post-installation actions. When all actions are completed successfully, the following will be displayed: If the message “BUILD SUCCESSFUL” is displayed, the post-installation actions were all successful. Click Next to check the last panel of the installation, which displays information about the uninstaller. Click Done to end the installation. During the installation, a log file was created in the folder ALM_HOME/FileBased named “Install_V5.8_*.log” (e.g., Install_V5.8_20130526100925_900283204835522781.log). The installation summary can also be reviewed in the file ALM_HOME/Uninstaller/InstallSummary.htm. If this was a new IKAN ALM Server installation (no re-installation or upgrade of an older version), and the ‘Initialize the database’ option was NOT selected during the installation, the next step is to initialize the IKAN ALM database. ### 3.8. Initializing the IKAN ALM Database This step must only be executed when you perform a new (first) IKAN ALM Server installation and if the ‘Initialize the database' option was NOT selected during the installation. When using DB2 as the IKAN ALM database, some additional configuration is required. For more information, please refer to the section DB2 configuration (page 33). To initialize the database, launch the script ALM_HOME/FileBased/initializeALMDatabase.cmd (Windows) or ALM_HOME/FileBased/initializeALMDatabase.sh (Linux/Unix): This section describes the steps to perform the startup of the different IKAN ALM components. - If you want to configure IKAN ALM through its GUI, you must first start the IKAN ALM Web application (Starting the IKAN ALM Web application (page 21)). - If you want to run Builds and Deploys, you must start the IKAN ALM Server and Agent (Starting the IKAN ALM Server (page 22) and Starting the IKAN ALM Agent (page 22)). - If you want to use the IKAN ALM Commandline interface, see Using the IKAN ALM Commandline (page 22) ### 4.1. Starting the IKAN ALM Web application To start the IKAN ALM Web application, you need to start the Apache Tomcat web server that is hosting it. The IKAN ALM GUI can be reached by browsing to the url `http://<host>:<port>/alm`. For example: `http://alm_server:8080/alm`. If this is the first installation of IKAN ALM, the License window will be displayed: Provide a valid license, and then click *Submit*. Next, the Log in page will be displayed: Log in with user id “global”, password “global”. For more information on the IKAN ALM GUI, refer to the IKAN ALM 5.8 User Guide, which is located at ALM_HOME/doc/ALMUserGuide.pdf. 4.2. Starting the IKAN ALM Server The IKAN ALM Server runs as an OSGi bundle inside a Karaf container. Therefore, to start the IKAN ALM Server, the Karaf container must be started first. - On Linux/Unix, from a shell: Launch the shell script “ALM_HOME/daemons/server/startServer.sh”. Use “ALM_HOME/daemons/server/stopServer.sh” to stop the IKAN ALM Server. - On Windows, as a Windows Service: By default, the IKAN ALM Server is registered as a Windows service which will be started automatically at system start-up. Alternatively, you can control the service via Start > Settings > Control Panel > Administrative Tools > Services. The name of the IKAN ALM Server service is “IKAN ALM 5.8 Server”. - On Windows, from a Command Prompt: Launch the command file “ALM_HOME/daemons/server/startServer.cmd”. Use “ALM_HOME/daemons/server/stopServer.cmd” to stop the IKAN ALM Server. 4.3. Starting the IKAN ALM Agent - On Linux/Unix, from a shell: Launch the shell script “ALM_HOME/daemons/agent/startAgent.sh”. Use “ALM_HOME/daemons/agent/stopAgent.sh” to stop the IKAN ALM Agent daemon. - On Windows, as a Windows Service: By default, the IKAN ALM Agent is registered as a Windows service which will be started automatically at system start-up. Alternatively, you can control the service via Start > Settings > Control Panel > Administrative Tools > Services. The name of the Agent service is “IKAN ALM 5.8 Agent”. - On Windows, from a Command Prompt: Launch the command file “ALM_HOME/daemons/agent/startAgent.cmd”. Use “ALM_HOME/daemons/agent/stopAgent.cmd” to stop the IKAN ALM Agent. 4.4. Using the IKAN ALM Commandline If you selected the IKAN ALM CommandLine package, it will be installed in ALM_HOME/commandline. - To launch the IKAN ALM Commandline on Linux/Unix: Open a shell and launch “ALM_HOME/commandline/alm.sh”. - To launch the IKAN ALM Commandline on Windows: Open a Command Prompt and launch “ALM_HOME/commandline/alm.cmd”. For more detailed information on the IKAN ALM Commandline, refer to the section *Command Line Interface* in the *IKAN ALM User Guide – Release 5.8*. To completely uninstall IKAN ALM from your system, do the following: - **On Linux/Unix:** Open a shell and execute the command “java -jar ALM_HOME/Uninstaller/uninstaller.jar” - **On Windows XP/2003:** Open Control Panel > Add/Remove Programs, select the entry “IKAN ALM 5.8” and click “Change/Remove” - **On Windows Vista/Server2008 and above:** Open “Programs and Features”, select the entry “IKAN ALM 5.8” and click “Uninstall/Change” The uninstaller windows will be displayed: ![Uninstall Window](image) **WARNING:** if you enable the option “Force the deletion of ...” the uninstaller will DELETE the ENTIRE installation directory! This means that if your Build Archive, Deploy scripts or target environments are located in this installation directory, they will be REMOVED. If you leave this option disabled, the uninstaller will keep some files in the installation directory, like the original location of the Build Archive (ALM_HOME/system/buildArchive). Click **Uninstall** to start the removal. When finished, the following will be displayed: ![Uninstall Confirmation](image) Click **Quit** to end the uninstaller. CHAPTER 6 Upgrading IKAN ALM The general approach to upgrading IKAN ALM is straightforward: first back up the current installation and the database, then reinstall the application and upgrade the database to a higher version. If the upgrade process fails, you can restore the back-up, and continue running the previous version of IKAN ALM (and contact support). You should at least back up the following: 1. IKAN ALM database 2. Build Archive Location: configured in System Settings (default = ALM_HOME/system/buildArchive) 3. Deploy Scripts Location: configured in System Settings (default = ALM_HOME/system/deployScripts) 4. Phase Catalog: configured in System Settings (default = ALM_HOME/system/phaseCatalog) Note: For safety reasons, it is highly recommended to back up the entire ALM_HOME directory. Experience has shown that, sometimes, one needs to restore a configuration like a security setting or the configuration of the log files. 6.1. IKAN ALM Upgrade Procedure 1. Stop the IKAN ALM Server/Agent and the IKAN ALM application server (Tomcat) and make the back-up. This is necessary to make sure you have the latest version of everything. 2. Uninstall the IKAN ALM Server and (if it has been installed) the local ALM Agent. To do so, run the uninstaller on the IKAN ALM Server machine. Information on how to do this can be found in the section Uninstalling IKAN ALM (page 24) or in the guide HowToALM 5.8_Tomcat_Install.pdf (in case the previous version of IKAN ALM was installed with the console installer). 3. Highly recommended: also back up the ALM_HOME folder to keep the configuration. 4. Uninstall the remote agents. Configure and run the uninstaller on each remote IKAN ALM Agent machine. Information on how to do this can be found in the section Uninstalling IKAN ALM (page 24) or in the guide HowToALM 5.8_AgentInstall.pdf. 5. Configure and run the installer of the ALM Server and local ALM Agent. Refer to the section Installing IKAN ALM (page 6) or to the document HowToALM 5.8_Tomcat_Install.pdf. 6. Migrate the IKAN ALM database to the latest version. To do this, run the Database Migration Tool (described in the next section) from the new ALM Server installation. 7. Finally, run the installer of the remote ALM Agents. Refer to the guide HowToALM 5.8_AgentInstall.pdf. 6.2. Database Migration Tool The Database Migration Tool is a command line tool launched by the migrateALMDatabase script. The tool automatically detects the current database version and, if needed, attempts to migrate it to the latest one. As pointed out in the previous section, you should back up the IKAN ALM database before starting the DB migration. To start the migration, you need to run the DB migration tool located in: ALM_HOME/FileBased/migrateALMDatabase.cmd (on Windows) or ALM_HOME/FileBased/migrateALMDatabase.sh (on Linux installations). By default, the DB Migration Tool uses the database connection parameters defined in the ALM_HOME/FileBased/install.properties file. You can also define a custom path to the install.properties by using the -installProperties switch (see the migrateALMDatabase script file contents). The default Java executable is used to run the migration tool. In case it cannot be found, you may have to set the JAVA_HOME variable in the migrateALMDatabase script file. The Database Migration will be done in different steps: when migrating from the older 5.2 version, first the 5.2 to 5.5 migration will be executed, before migrating version 5.5 to the (latest) 5.8 version. Note: Migrating the older IKAN ALM database 5.2 to version 5.5 includes significant changes. Therefore, depending on the size of your database, it may take a while (up to a few hours). A migration log is created in the ALM_HOME/FileBased/almDbMigration.log file and will also be displayed in the console window. By default, the IKAN ALM installer registers the IKAN ALM Server and Agent components as Windows services. However, for convenience purposes, the IKAN ALM installation includes scripts to unregister or re-register the IKAN ALM Server and Agent as services. The procedures are identical for the ALM Agent and Server, so we will only describe them for the ALM Server: - To unregister the service, execute "ALM_HOME/daemons/server/karaf/bin/karaf-service.bat remove". - To register the service, execute "ALM_HOME/daemons/server/karaf/bin/karaf-service.bat install". If you want to reconfigure the service, edit the file ALM_HOME/daemons/server/karaf/etc/karaf-wrapper.conf. You can, for example, change the amount of memory the ALM Server can use (in Mb) by changing: wrapper.java.maxmemory = 512. It is generally not recommended to change any of the other properties in the karaf-wrapper.conf file, as it may cause the ALM Server to stop working. APPENDIX B Manually Installing and Removing the IKAN ALM Server and Agent as a Daemon Process on Linux/Unix Systems The IKAN ALM installer does not automatically install the ALM Server or Agent as a Linux/Unix daemon. These steps must be performed after installation. Since the ALM Server and Agent use Apache Karaf as their OSGi runtime environment, this basically comes down to using the Apache Karaf Wrapper feature (see the Karaf 4.0 manual: http://karaf.apache.org/manual/latest/#_service_wrapper). As an example, we will describe this procedure for installing and removing the ALM Server as a service on a CentOS Linux. For the ALM Agent, repeat the procedure, but substitute "server" with "agent". 1. If you are currently running the ALM Server, stop it by executing ALM_HOME/daemons/server/stopServer.sh 2. Launch the ALM Server Karaf by executing ALM_HOME/daemons/server/karaf/bin/karaf_server.sh. This will launch the ALM Server with the Karaf console enabled, which we will need to use the Karaf Wrapper feature. 3. After the startup messages have finished, press <enter> and you will see the Karaf console prompt: "karaf@root>" 4. In the Karaf console, execute "feature:install wrapper". This will install the Karaf Wrapper feature. You can verify that this worked by executing "feature:list | grep wrapper". This should give the output: wrapper | 4.0.7 | x | Started | standard-4.0.7 | Provide OS integration 5. Now we must call "wrapper:install" which will generate the necessary files to install the ALM Server as a Linux service. In the Karaf console, execute 'wrapper:install -s DEMAND_START -n almserver58 -d "IKAN ALM 5.8 Server" -D "IKAN ALM 5.8 Server Daemon"'. When this command succeeds, it conveniently reports the commands that we need to execute as subsequent steps. 6. Shut down the ALM Server Karaf: in the Karaf console, execute "shutdown -f" 7. Adapt the ALM_HOME/daemons/server/karaf/etc/almserver58-wrapper.conf file that was created, by adding the following options: - Just before the KARAF_HOME, in the section of the general wrapper properties, set the path to the Java runtime you selected during the IKAN ALM Server installation (See Installing the Server on page 9.): set.default.JAVA_HOME=/opt/java/jdk1.8.0 • change the path to the java executable: wrapper.java.command=/opt/java/jdk1.8.0/bin/java • In the section of the JVM Parameters, add following parameters: wrapper.java.additional.10=-XX:+UnlockDiagnosticVMOptions wrapper.java.additional.11=-XX:+UnsyncloadClass 8. At this point everything is configured so we can install, remove, stop and start the IKAN ALM Server Linux daemon. All of these commands need administrative privileges, so you will need to execute them with "sudo": To install the service: • ln -s /home/ikan/ALM/daemons/server/karaf/bin/almservr58-service /etc/init.d/ • chkconfig almservr58-service --add To start the service when the machine is rebooted: • chkconfig almservr58-service on To disable starting the service when the machine is rebooted: • chkconfig almservr87-service off To start the service: • service almservr58-service start To stop the service: • service almservr58-service stop To uninstall the service: • chkconfig almservr58-service --del • rm /etc/init.d/almservr58-service JAAS configuration For the authentication and authorization of users, IKAN ALM uses the Java Authentication and Authorization Service (JAAS) (see http://download.oracle.com/javase/6/docs/technotes/guides/security/jaas/JAASRefGuide.html). The IKAN ALM Server installation automatically preconfigures JAAS, so this appendix is only for troubleshooting, or if you want to adapt authentication, e.g., for using Windows domain authentication. JAAS authentication is performed in a pluggable fashion. This permits applications to remain independent from underlying authentication technologies. New or updated authentication technologies can be plugged into IKAN ALM without requiring modifications to the application itself. C.1. IKAN ALM Server JAAS configuration The IKAN ALM Server installation modifies the java.security file of the Java Runtime that was selected in ALM Server parameters (1 of 2) (page 10). This file is located in the subfolder jre/lib/security if the Java Runtime is a JDK, or in the subfolder lib/security when a Server JRE was selected. Note that if you use Tomcat to host the IKAN ALM Web application, it must be started with this selected Java Runtime, or else you will have authentication errors. The location of the login configuration file is set statically by specifying the URL in the login.config.url.n property (in the “Default login configuration file” paragraph). For example: ``` # # Default login configuration file # #login.config.url.1=file:${user.home}/.java.login.config login.config.url.1=file:/opt/alm/system/security/jaas.config ``` with “/opt/alm/” the chosen ALM_HOME. If multiple configuration files are specified (if n >= 2), they will be read and combined into one single configuration: ``` # # Default login configuration file # #login.config.url.1=file:${user.home}/.java.login.config login.config.url.1=file:/opt/alm/system/security/jaas.config login.config.url.1=file:c:/Documents and Settings/Administrator/.java.login.config login.config.url.2=file:c:/alm/system/security/jaas.config ``` C.2. JVM option or user.home JAAS configuration If you are using Tomcat, there are two other ways to set up the JAAS configuration: 1. The first uses a system property which is set from the command line: `-Djava.security.auth.login.config` option. When running Tomcat from a Linux/Unix shell or from a Windows Command Prompt, set the `JAVA_OPTS` variable in the file `TOMCAT_HOME/bin/Catalina.sh` or `TOMCAT_HOME/bin/Catalina.bat`: `JAVA_OPTS=-Djava.security.auth.login.config=/opt/alm/system/security/jaas.config` 2. The second option is to use the default configuration file which is loaded from the user’s home directory: `file:${user.home}/.java.login.config` C.3. JAAS implementation: flat file security The IKAN ALM Server uses a simple JAAS implementation, where user groups and users are configured in a flat file. In the JAAS configuration file, this is specified as follows (when `ALM_HOME="/opt/alm"`): ```java /** * ALM flat file security configuration */ ALM { com.tagish.auth.FileLogin required pwdFile="/opt/alm/system/security/passwd.config"; } ``` C.4. Flat file security: contents The contents of the `passwd.config` file when using flat file security is fairly easy and self-explanatory: ```plaintext userid:encrypted password:groupname:groupname:groupname user:ee11cbb19052e40b07aac0ca060c23ee:ALM User project:46f86faa6bbf9ac94a7e459509a20ed0:ALM User:ALM Project global:9c70933aff6b2a6d08c687a6cbb6b765:ALM User:ALM Administrator ``` The encrypted password is in MD5 encryption format. There are numerous free downloadable tools that can generate a MD5 checksum for a given string. There is even a JavaScript implementation that you can use online to calculate checksums at: [http://pajhome.org.uk/crypt/md5/index.html](http://pajhome.org.uk/crypt/md5/index.html) For example, to add a user with User ID “testuser” and password “testuser” who belongs to the “ALM User” and “ALM Project” User Groups, do the following: 1. Add following entry to the `passwd.config` file: ```plaintext testuser:5d9c68c6c50ed3d02a2fcf54f63993b6:ALM User:ALM Project ``` 2. Stop and restart Apache Tomcat 3. Login to IKAN ALM using User ID “testuser” and Password “testuser”. When using DB2 as the IKAN ALM database, please make sure that the page size of the table space and its associated buffer pool is not less than 8K. Otherwise, when creating a new database in DB2, the default page size is 4K and this can cause SQL errors while running the database initialization script. The page size of a table space in DB2 is determined by the associated buffer pool, but you cannot change the page size of a buffer pool. So, if you want to use an existing DB2 database with the page size already set to 4K, a possible workaround would be to create a new buffer pool with a page size of 8K, and next to create a new table space (e.g., USERSPACE2) with a page size of 8K and associate it with the new buffer pool. Furthermore, you will also need to create a new system temporary tablespace (e.g., TEMPSPACE2) and associate it with a buffer pool that has a page size set to at least 8K. APPENDIX E Troubleshooting E.1. The installer doesn't start and displays the error: "Java Runtime not found" When launching the 32-bit or 64-bit IKAN ALM installer on Windows, you may receive the following error, after which the IKAN ALM installer quits: ![Java Runtime Environment not found error message] The most likely cause is that there is no suitable Java Runtime Environment (JRE) installed. The 32-bit installer needs a 32-bit JRE installed, while the 64-bit installer needs a 64-bit JRE installed. Furthermore, the JRE should be version 1.7 or 1.8. The solution is to install a suitable JRE. If for some reason you do not want to install a JRE, there is a workaround to launch the IKAN ALM installer with only a Java Development Kit (JDK) or a Server JRE installed: set the JAVA_HOME environment variable to point to the JDK or Server JRE folder, either globally on the system, or from a commandline prompt, and then launch the IKAN ALM installer. When you set JAVA_HOME from a commandline prompt, there are two possible pitfalls: - do not wrap the JAVA_HOME path in quotes, even when it contains spaces - when UAC is enabled (Windows Vista and later), the commandline prompt must have Administrative privileges (the title of the prompt must start with "Administrator:"
{"Source-Url": "https://www.ikanalm.com/documents/IKAN%20ALM%205.8%20Installation%20guide.pdf", "len_cl100k_base": 10616, "olmocr-version": "0.1.53", "pdf-total-pages": 37, "total-fallback-pages": 0, "total-input-tokens": 61282, "total-output-tokens": 12038, "length": "2e13", "weborganizer": {"__label__adult": 0.0002682209014892578, "__label__art_design": 0.000286102294921875, "__label__crime_law": 0.00022482872009277344, "__label__education_jobs": 0.0012674331665039062, "__label__entertainment": 7.539987564086914e-05, "__label__fashion_beauty": 0.00011146068572998048, "__label__finance_business": 0.00037550926208496094, "__label__food_dining": 0.00015676021575927734, "__label__games": 0.0010318756103515625, "__label__hardware": 0.0011301040649414062, "__label__health": 0.00013875961303710938, "__label__history": 0.00028061866760253906, "__label__home_hobbies": 0.00014853477478027344, "__label__industrial": 0.0003070831298828125, "__label__literature": 0.0002319812774658203, "__label__politics": 0.00020754337310791016, "__label__religion": 0.0003643035888671875, "__label__science_tech": 0.0120697021484375, "__label__social_life": 0.00011610984802246094, "__label__software": 0.06768798828125, "__label__software_dev": 0.9130859375, "__label__sports_fitness": 0.0001474618911743164, "__label__transportation": 0.00022280216217041016, "__label__travel": 0.00018417835235595703}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 47864, 0.02083]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 47864, 0.22268]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 47864, 0.73209]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 3485, false], [3485, 5506, null], [5506, 6175, null], [6175, 8137, null], [8137, 10368, null], [10368, 12761, null], [12761, 13507, null], [13507, 15094, null], [15094, 15254, null], [15254, 15515, null], [15515, 16290, null], [16290, 17912, null], [17912, 19695, null], [19695, 20849, null], [20849, 22290, null], [22290, 23768, null], [23768, 25737, null], [25737, 26907, null], [26907, 27047, null], [27047, 27317, null], [27317, 28354, null], [28354, 28516, null], [28516, 29497, null], [29497, 31648, null], [31648, 31798, null], [31798, 32940, null], [32940, 34670, null], [34670, 36681, null], [36681, 36808, null], [36808, 38114, null], [38114, 40390, null], [40390, 41418, null], [41418, 43469, null], [43469, 45671, null], [45671, 46576, null], [46576, 47864, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 3485, true], [3485, 5506, null], [5506, 6175, null], [6175, 8137, null], [8137, 10368, null], [10368, 12761, null], [12761, 13507, null], [13507, 15094, null], [15094, 15254, null], [15254, 15515, null], [15515, 16290, null], [16290, 17912, null], [17912, 19695, null], [19695, 20849, null], [20849, 22290, null], [22290, 23768, null], [23768, 25737, null], [25737, 26907, null], [26907, 27047, null], [27047, 27317, null], [27317, 28354, null], [28354, 28516, null], [28516, 29497, null], [29497, 31648, null], [31648, 31798, null], [31798, 32940, null], [32940, 34670, null], [34670, 36681, null], [36681, 36808, null], [36808, 38114, null], [38114, 40390, null], [40390, 41418, null], [41418, 43469, null], [43469, 45671, null], [45671, 46576, null], [46576, 47864, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 47864, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 47864, null]], "pdf_page_numbers": [[0, 0, 1], [0, 3485, 2], [3485, 5506, 3], [5506, 6175, 4], [6175, 8137, 5], [8137, 10368, 6], [10368, 12761, 7], [12761, 13507, 8], [13507, 15094, 9], [15094, 15254, 10], [15254, 15515, 11], [15515, 16290, 12], [16290, 17912, 13], [17912, 19695, 14], [19695, 20849, 15], [20849, 22290, 16], [22290, 23768, 17], [23768, 25737, 18], [25737, 26907, 19], [26907, 27047, 20], [27047, 27317, 21], [27317, 28354, 22], [28354, 28516, 23], [28516, 29497, 24], [29497, 31648, 25], [31648, 31798, 26], [31798, 32940, 27], [32940, 34670, 28], [34670, 36681, 29], [36681, 36808, 30], [36808, 38114, 31], [38114, 40390, 32], [40390, 41418, 33], [41418, 43469, 34], [43469, 45671, 35], [45671, 46576, 36], [46576, 47864, 37]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 47864, 0.14579]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
8b3a4eb7698cb63ae7737a92acbd4840c0688674
Computing the prefix of an automaton Marie-Pierre Béal, Olivier Carton To cite this version: Marie-Pierre Béal, Olivier Carton. Computing the prefix of an automaton. Informatique Théorique et Applications, 2000, 34 (6), pp.503-514. hal-00619217 HAL Id: hal-00619217 https://hal-upec-upem.archives-ouvertes.fr/hal-00619217 Submitted on 5 Sep 2011 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Computing the prefix of an automaton MARIE-PIERRE BÉAL OLIVIER CARTON Institut Gaspard Monge* Institut Gaspard Monge* Université de Marne-la-Vallée Université de Marne-la-Vallée March 7, 2001 Abstract We present an algorithm for computing the prefix of an automaton. Automata considered are non-deterministic, labelled on words, and can have \(\varepsilon\)-transitions. The prefix automaton of an automaton \(A\) has the following characteristic properties. It has the same graph as \(A\). Each accepting path has the same label as in \(A\). For each state \(q\), the longest common prefix of the labels of all paths going from \(q\) to an initial or final state is empty. The interest of the computation of the prefix of an automaton is that it is the first step of the minimization of sequential transducers. The algorithm that we describe has the same worst case time complexity as another algorithm due to Mohri but our algorithm allows automata that have empty labelled cycles. If we denote by \(P(q)\) the longest common prefix of labels of paths going from \(q\) to an initial or final state, it operates in time \(O((P + 1) \times |E|)\) where \(P\) is the maximal length of all \(P(q)\). 1 Introduction Transducers are finite state machines whose transitions or edges are labelled by a pair made of an input word and an output word. They are widely used in practice to model various things like lexical analyzers in language processing [14], operations in numeration systems [11] or also encoding or decoding schemes for channels [2]. As a transducer has input and output labels, and even if these labels are letters, there is in general no minimal equivalent object like for simple finite state automata. It is very often required that the transducer has letters as input labels and has moreover a deterministic input automaton. It is then called sequential. Used as an encoder, this means that the output codeword is obtained sequentially from the input data. Transducers which are not sequential, but which realize sequential functions, can be first determinized (see for instance [4]) *Institut Gaspard Monge, Université de Marne-la-Vallée, 5 boulevard Descartes, 77454 Marne-la-Vallée Cedex 2, France. http://www-lgm.univ-mlv.fr/~beal/carton* or [3]). In the case of sequential transducers, there exists a minimal equivalent sequential transducer, even if the output labels are variable length words. A characterization of minimal sequential transducers was first given in [7]. A procedure to produce a minimal sequential transducer is there indicated. It is in particular shown in [7] that the minimal sequential transducer is obtained in two steps. The first one is the computation of the prefix automaton of the output automaton of the transducer. The second step is a classical minimization of the transducer obtained at the end of the first step, seen as an ordinary finite state automaton. The prefix of an automaton can be interpreted as an automaton with the same underlying graph, same behaviour but produces its output as soon as possible. Its name comes from the fact that for any state \( q \), the longest common prefix \( P(q) \) of labels of paths going from \( q \) to an initial or final state is empty. The first algorithm of computation of the prefix of an automaton appears in [12] and [13]. The construction is there called a quasi-determinization. It has been noticed by Mohri that the first step of the minimization of sequential transducers is independent from the notion of transducers. The quasi-determinization is an algorithm that works on finite state automata. It keeps the graph of an automaton and changes only the labels of the edges. Roughly speaking, it pushes the labels of the edges from the final states towards the initial states as much as possible. The algorithm of Mohri has a time complexity \( O((P + 1) \times |E|) \), where \( E \) is the set of edges and \( P \) the maximum of the lengths of \( P(q) \) for all states \( q \). We assume here that the number of states \( |Q| \) is less than the number of edges. Another algorithm for computing the prefix of automaton has been presented in [5] and [6]. The approach of this algorithm is really different from ours. It is based on the construction of the suffix tree of a tree and its time complexity is \( O(|Q| + |E| + S \log |A|) \), where \( A \) is the alphabet and \( S \) is the sum of the lengths of the labels of all edges of the automaton. Breslauer's algorithm can thus be better when there is a small number of edges and Mohri's algorithm is better in the other case. In practice, \( S \) can be very large and \( P \) can be very small. This makes the algorithms of Mohri and ours almost linear. A comparison of the two complexities is given in [13]. Our algorithm uses the same principle of pushing letters through states as Mohri's algorithm does. Main restriction to Mohri's algorithm is that it does not work when the automaton contains a cycle of empty label (the system of equations given in [13, Lemma 2 p. 182] does not admit a unique solution in this case). Some step in Mohri's algorithm requires that the automaton has no empty labelled cycle. However, if the starting automaton does not have any such cycle, this property is kept along the process. The algorithm is therefore correct in this case. This restriction is not really important for applications since the transducers used in practice, like in language processing, have no empty labelled cycles in output. In this paper, we present another algorithm of computation of the prefix of an automaton which has the same worst case time complexity as Mohri's algorithm, \( O((P + 1) \times |E|) \), and that works for all automata. The existence of empty labelled cycles accounts for most of the difficulty in the coming algo- rithm. The time complexity is independent of the size of the alphabet. The algorithm consists in decreasing by 1 the value \( P \) at each step. We present our algorithm for sequential transducers but it can be directly extended to the case of subsequential transducers (see [7] or [4] for the definition of a subsequential transducer). In Section 2, we recall some basic definitions from automata theory and we define the prefix automaton of an automaton. The computation algorithm of the prefix of an automaton is presented in Section 3. The complexity is analyzed in Section 4. In that section some data structures are described which can be used to get the right time complexity of the algorithm. 2 Prefix of an automaton and applications In the sequel, \( A \) denotes a finite alphabet and \( \varepsilon \) is the empty word. A word \( u \) is a prefix of a word \( v \) if there is a word \( w \) such that \( v = uw \). The word \( w \) is denoted by \( u^{-1}v \). The longest common prefix of a set of words is the longest word which is prefix of all words of the set. An automaton over \( A^* \) is composed of a set \( Q \) of states, a set \( E \subset Q \times A^* \times Q \) of edges and two sets \( I, F \subset Q \) of initial and final states. An edge \( e = (p, u, q) \) from \( p \) to \( q \) is denoted by \( p \xrightarrow{u} q \), the word \( u \) being the label of the edge. The automaton is finite if \( Q \) and \( E \) are finite. A path is a possibly empty sequence of consecutive edges. Its label is the concatenation of the labels of the consecutive edges. An automaton is often denoted by \( \mathcal{A} = (Q, E, I, F) \). An accepting path is a path from an initial state to a final state. The language or set of words recognized (or accepted) by an automaton is the set of labels of accepting paths. An automaton is deterministic if it is labelled by letters of a finite alphabet \( A \), if it has one initial state and if for each state \( p \) and each letter \( a \) in \( A \), there is at most one edge \( p \xrightarrow{a} q \) for some \( q \). We now define the prefix automaton of a given automaton \( \mathcal{A} \). This prefix automaton has the same graph as \( \mathcal{A} \), but the labels of the edges are changed. However the labels of the accepting paths remain unchanged and the prefix automaton recognizes the same words. Furthermore, for any state \( q \) of the prefix automaton the longest common prefix of the labels of all paths going from \( q \) to an initial or final state is empty. Let \( \mathcal{A} = (Q, E, I, F) \) be a finite non-deterministic automaton labelled by words. We assume that the automaton is trim, that is, any state belongs to an accepting path. For each state \( q \), we denote by \( P_\mathcal{A}(q) \), or just \( P(q) \), the longest common prefix of the labels of all paths going from \( q \) to an initial or final state. Remark that \( P(q) = \varepsilon \) if \( q \) is initial or final. The prefix automaton of \( \mathcal{A} \) is the automaton \( \mathcal{A}' = (Q, E', I, F) \) defined as follows. \[ E' = \{ q \xrightarrow{P(q)^{-1}uP(r)} r \mid q \xrightarrow{u} r \text{ is an edge of } \mathcal{A} \}. \] One may easily check that if \( q \xrightarrow{u} r \) is an edge of \( \mathcal{A} \), then the word \( P(q) \) is by definition a prefix of the word \( uP(r) \) and the previous definition is thus consistent. Note that a path labelled by \( w \) from \( q \) to \( r \) in \( A \) becomes a path labelled by \( P(q)^{-1}wP(r) \) from \( q \) to \( r \) in the prefix automaton. If this path is accepting, \( q \) is initial and \( r \) is final and thus \( P(q) \) and \( P(r) \) are both empty. Then the label of the path in the prefix automaton is the same as in \( A \). The label of a cycle of \( A \) is conjugated to its label in the prefix automaton. In particular the empty labelled cycles of the prefix automaton are the same as the ones of \( A \). By construction the longest common prefix of the labels of all paths going from \( q \) to an initial or final state is empty in the prefix automaton. Our definition of the prefix automaton allows edges coming in an initial state. In most cases, there is none and for each non-initial state \( q \), \( P(q) \) is the longest common prefix of the labels of all paths going from \( q \) to a final state. The words \( P(q) \) are the longest words such that \( P(q) = \varepsilon \) if \( q \) is initial or final and such that \( P(q) \) is a prefix of \( uP(r) \) for any edge \( q \xrightarrow{a} r \). Indeed, if a function \( P' \) maps any state \( q \) to a word such that these two conditions are met, then \( P'(q) \) is a prefix of \( P(q) \) for any state \( q \). \[ \begin{array}{c} 1 \xrightarrow{b} 2 \xrightarrow{a} 4 \\ \varepsilon \xrightarrow{\varepsilon} 3 \\ \varepsilon \xrightarrow{a} 3 \end{array} \] **Figure 1:** An automaton \( A \). \[ \begin{array}{c} 1 \xrightarrow{b} 2 \xrightarrow{c} 4 \\ \varepsilon \xrightarrow{\varepsilon} 3 \\ \varepsilon \xrightarrow{\varepsilon} 3 \end{array} \] **Figure 2:** The prefix automaton of \( A \). **Example 1.** Consider the automaton \( A \) pictured in Figure 1 where the initial state is 1 and the final state is 4. The prefix automaton of \( A \) is pictured in Figure 2. The main application of the prefix of an automaton is minimization of sequential and subsequential transducers. A transducer is defined as an automaton, except that the labels of the edges are pairs made of an input word and an output word. A transducer labelled in $A \times B^*$ is *sequential* if its input automaton is deterministic. It has been proved [7], [8, p. 95], see also [12] and [13], that among the sequential transducers computing a given function, there is a minimal one which can be obtained from any sequential transducer computing the function. This minimization is performed in two steps. The first step is the computation of the prefix automaton of the output automaton of the transducer. The second step is a minimization of the resulting transducer, considered as a finite automaton. We refer to [12] for examples of minimization of sequential transducers. 3 Computation of the prefix of an automaton In this section, we describe an algorithm which computes the prefix of an automaton. The automaton $A = (Q, E, I, T)$ is a non-deterministic automaton whose edges are labelled by words over a finite alphabet $A$. The labels can be the empty word and cycles with empty labels are allowed. We first describe the principle of the algorithm. If $q$ is a state of $A$, we recall that $P(q)$ denotes the longest common prefix of the labels of all paths going from $q$ to an initial or final state. We denote by $p(q)$ the first letter of $P(q)$ if $P(q) \neq \varepsilon$, and $\varepsilon$ if $P(q) = \varepsilon$. We denote by $P_A$ the maximum of the lengths of all $P(q)$ for all states $q$. If $P_A > 0$, we construct from the automaton $A = (Q, E, I, T)$ an automaton $A' = (Q, E', I, T)$ whose edges are defined as follows: $$E' = \{ q \xrightarrow{p(q)^{-1}u_p(r)} r \mid q \xrightarrow{u} r \text{ is an edge of } A \}.$$ It recognizes the same language as $A$ and satisfies $P_{A'} = P_A - 1$. By iterating this process, we get the prefix automaton. We now explain the computation of the automaton $A'$. We call $\varepsilon$-edge any edge whose label is $\varepsilon$. Let $A_e$ be the sub-automaton of $A$ obtained by keeping only the $\varepsilon$-edges. We first compute the strongly connected components of $A_e$. This can be performed by depth-first explorations of $A_e$ [9]. The strongly connected components are stored in an array $c$ indexed by $Q$. For each state $q$ we denote by $c[q]$ a state that represents the strongly connected component of $q$. The call to `Strongly-Connected-Components(A_e)` in the pseudo code below will refer to this procedure that computes the array $c$. Note that all states $q$ in a same strongly connected component of $A_e$ have same $P(q)$ and thus same $p(q)$. The construction of $A'$ is then done with two depth-first explorations, first an exploration of $A_e$, second, an exploration of $A$. The first exploration computes $p(q)$ for each state $q$ of $A_e$. This symbol, either a letter or $\varepsilon$, is stored in the cell `letter[q]` of an array `letter`. As $p(q)$ is common to all states \( q \) in a same strongly connected component of \( \mathcal{A}_e \), we compute it only for the states \( c[q] \). At the beginning of the computation, all cells \( \text{letter} \[q \] \) are set to the default value \( \top \) which stands for undefined. During the computation, these values are changed into symbols of \( A \cup \{ \varepsilon \} \). Let \( X \) be the set \( A \cup \{ \varepsilon, \top \} \). We define a partial order on the set \( X \) as follows. For each \( a \in A \), \[ \varepsilon < a < \top. \] Note that each subset of \( X \) has an inf in \( X \) such that, for all \( x \in X \), all \( a, b \in A \) with \( a \neq b \), \[ \inf(\varepsilon, x) = \varepsilon, \inf(\top, x) = x, \inf(a, b) = \varepsilon. \] We also assume that an array \( \text{local} \) indexed by \( Q \) gives, for each state \( q \), either \( \varepsilon \) if \( q \) is final or initial, or \( \inf(S) \) where \( S \) is the set of letters that appear as the first letter of a non-empty label of an edge going out of \( q \). Note that if there is no edge with a non-empty label going out of \( q \), \( \text{local}[q] \) is equal to \( \top \). The array \( \text{local} \) is initialized by the procedure \( \text{Init-Table} \) and updated with the procedures \( \text{Update-Table-Head} \) and \( \text{Update-Table-Tail} \) that we shall describe later. For each state \( q \) in \( Q \), the value of \( \text{letter}[c[q]] \) is first set to the inf of \( \text{local}[r] \), for all states \( r \) in the same strongly connected component of \( \mathcal{A}_e \) as \( q \). This is done by the procedure \( \text{Init-Letter} \). During the exploration of the automaton \( \mathcal{A}_e \), if \( q \) has a successor \( r \) such that \( \text{letter}[c[r]] < \text{letter}[c[q]] \), then \( \text{letter}[c[q]] \) is changed in \( \inf(\text{local}[q], \text{letter}[c[q]]) \). We claim that the cell of index \( q \) of the array \( \text{letter} \) contains \( p(q) \) at the end of this exploration. This exploration is done by the function \( \text{Find-Letter} \). It returns a boolean which is true if there is at least one state \( q \) with \( p(q) \) non-empty. We give below a pseudocode for the procedures \( \text{Init-Letter}, \text{Find-Letter} \) and \( \text{Find-Letter-Visit} \). We follow the depth-first search presentation of [9]. **Init-Letter** (set of states \( Q \)) for each state \( q \in Q \) do let \( \text{letter}[c[q]] \) \( \leftarrow \top \) for each state \( q \in Q \) do let \( \text{letter}[c[q]] \) \( \leftarrow \inf(\text{local}[q], \text{letter}[c[q]]) \) **Find-Letter** (automaton \( \mathcal{A}_e = (Q, E_e, I, F) \)) \( \text{bool} \leftarrow \text{false} \) for each state \( q \in Q \) do let \( \text{color}[q] \) \( \leftarrow \text{white} \) for each state \( q \in Q \) do if \( \text{color}[q] = \text{white} \) then \( \text{Find-Letter-Visit}(\mathcal{A}_e, q) \) return \( \text{bool} \) **Find-Letter-Visit** (automaton $A_e = (Q, E_e, I, F)$, state $q$) $color[q] \leftarrow \text{BLACK}$ for each edge $(q, \varepsilon, r)$ do if $color[r] = \text{WHITE}$ then $\text{Find-Letter-Visit}(A_e, r)$ $\text{letter}[c[q]] \leftarrow \inf(\text{letter}[c[q]], \text{letter}[c[r]])$ if $\text{letter}[c[q]] \neq \varepsilon$ then $\text{bool} \leftarrow \text{TRUE}$ We now prove the correctness of our algorithm. **Proposition 2** Function $\text{Find-Letter}$ computes $p(q)$ for each state $q$. **Proof.** For each state $q$, “$\text{letter}[c[q]] \geq p(q)$” is an invariant of the function $\text{Find-Letter}$. Indeed, one has $\text{local}[r] \geq p(q)$, for each state $r$ in the same strongly connected component as $q$. This implies that “$\text{letter}[c[q]] \geq p(q)$” is an invariant of the function $\text{Init-Letter}(Q)$. Moreover, if there is an edge $(q, \varepsilon, r)$ and if $\text{letter}[c[r]] \geq p(r)$, we get $\text{letter}[c[q]] \geq p(r) \geq p(q)$. Then “$\text{letter}[c[q]] \geq p(q)$” is invariant during $\text{Find-Letter-Visit}(A_e, q)$. We now show that if there is an edge $(q, \varepsilon, r)$ between two states $q$ and $r$, we have $\text{letter}[c[q]] \leq \text{letter}[c[r]]$ at the end of $\text{Find-Letter}(A_e)$. This fact is trivial if $q$ and $r$ belong to the same strongly connected component of $A_e$. If not, the end of the exploration of state $r$ is before the end of the exploration of $q$. Then the line 5 of $\text{Find-Letter-Visit}(A_e, q)$ implies that $\text{letter}[c[q]] \leq \text{letter}[c[r]]$. Let us assume there is a (possibly empty) path from $q$ to a state $r$ which has an empty label and an edge going out of $r$ labelled with $au$, where $u$ is a word. Then $\text{letter}[c[q]] \leq a$ at the end of $\text{Find-Letter-Visit}(A_e, q)$. Indeed, at the end of $\text{Find-Letter-Visit}(A_e, q)$, we have $\text{letter}[c[r]] \leq a$, and then also $\text{letter}[c[q]] \leq \text{letter}[c[r]] \leq a$. Let us assume that $p(q)$ is a letter $a$ in $A$. Then there is a (possibly empty) path from $q$ to a state $r$ which has an empty label and an edge going out of $r$ labelled with $au$, where $u$ is a word. As a consequence $\text{letter}[c[q]] \leq a$ and then $\text{letter}[c[q]] = p(q)$. Let us now assume that $p(q)$ is the empty word. Then there is either a (possibly empty) path from $q$ to a state $r$ which has an empty label and an edge going out of $r$ labelled with $au$, where $u$ is a word, and there is a (possibly empty) path from $q$ to a state $r'$ which has an empty label and an edge going out of $r'$ labelled with $bu$, where $u$ is a word, with $b \neq a$. In this case $\text{letter}[c[q]] \leq \inf(a, b) = \varepsilon$, and then $\text{letter}[c[q]] = p(q)$. Or there is a (possibly empty) path from $q$ to a state $r$ which has an empty label and with $r$ final or initial. Again $\text{letter}[c[q]] \leq \text{letter}[c[r]] = \varepsilon$. Finally, $\text{letter}[c[q]] = p(q)$ for each $q$. $\square$ The second depth-first exploration is an exploration of the automaton $A$. It updates the labels of $A$ in order to decrease the length of $P(q)$ for each state $q$ such that $p(q)$ is non-empty. For each edge $(q, u, r)$, where $u$ is a finite word, the following two operations are performed. The letter (or empty word) $p(c[r])$ is added at the end of $u$. Then the first letter (or empty word) $p(c[q])$ is removed. from the beginning of \( u \). Note that these two operations are possible. If \( u \) is nonempty, then \( p(c[q]) \) is the first letter of \( u \) and if \( u = \varepsilon \) then \( p(c[q]) = p(c[p]) \) or \( p(c[q]) = \varepsilon \). These operations change the labels of the edges of the automaton \( \mathcal{A} \) and thus also the values of the array \( \text{local} \). Lines 3 and 5 of \( \text{Move-Letter-Visit} \) change the labels of the edge \( e \) in \( \mathcal{A} \). Since an edge with empty label can become an edge with a non-empty label and conversely, the edge of \( \mathcal{A}_e \) are also updated there. The values of the array \( \text{local} \) are updated with two procedures \( \text{Update-Table-Head} \) and \( \text{Update-Table-Tail} \) described later. The exploration is done during the run of procedure \( \text{Move-Letter} \) whose pseudo code is given below. \[ \text{Move-Letter}(\text{automaton } \mathcal{A} = (Q, E, I, F)) \] \[ \text{for each state } q \in Q \text{ do} \] \[ \text{color}[q] \leftarrow \text{white} \] \[ \text{for each state } q \in Q \text{ do} \] \[ \text{if color}[q] = \text{white} \text{ then} \] \[ \text{Move-Letter-Visit}(\mathcal{A}, q) \] \[ \text{Move-Letter-Visit}(\text{automaton } \mathcal{A} = (Q, E, I, F), \text{ state } q) \] \[ \text{color}[q] \leftarrow \text{black} \] \[ \text{for each edge } e = (q, u, r) \text{ where } u \text{ is a (possibly empty) word do} \] \[ \text{append letter}[c[p]] \text{ at the end of the label of } e \text{ in } \mathcal{A} \text{ and update } \mathcal{A}_e \] \[ \text{Update-Table-Tail}(e, \text{letter}[c[p]]) \] \[ \text{remove letter}[c[p]] \text{ from the head of the label of } e \text{ in } \mathcal{A} \text{ and update } \mathcal{A}_e \] \[ \text{Update-Table-Head}(e, \text{letter}[c[p]]) \] \[ \text{if color}[r] = \text{white} \text{ then} \] \[ \text{Move-Letter-Visit}(\mathcal{A}, r) \] **Proposition 3** Function transforms the automaton \( \mathcal{A} \) in an automaton \( \mathcal{A}' \) whose edges are: \[ E' = \{ q \xrightarrow{p(i)^{-1}wp(r)} r \mid q \xrightarrow{u} r \text{ is an edge of } \mathcal{A} \). \] Therefore, the function \( \text{Move-Letter} \) changes the label \( w \) of any path from \( q \) to \( r \) into \( p(q)^{-1}wp(r) \). **Proof.** This follows directly from the construction. \( \square \) **Proposition 4** Function \( \text{Move-Letter} \) transforms the automaton \( \mathcal{A} \) in an automaton \( \mathcal{A}' \) which has the same graph as \( \mathcal{A} \), keeps the labels of accepting paths and satisfies \( P_{\mathcal{A}'} = P_{\mathcal{A}} - 1 \). **Proof.** Let \( w \) be the label of a path from an initial state \( i \) to a final state \( t \) in \( \mathcal{A} \). The label of the same path obtained at the end of \( \text{Move-Letter} \) in \( \mathcal{A}' \) is \( p(i)^{-1}wp(t) = w \). Thus the labels of accepting paths are unchanged. Moreover, for each state \( q \) one has \( P_{\mathcal{A}'}(q) = p_{\mathcal{A}}(q)^{-1}P_{\mathcal{A}}(q) \). It follows that \( P_{\mathcal{A}'} = P_{\mathcal{A}} - 1 \) if \( P_{\mathcal{A}} \geq 1 \). \( \square \) We now give a pseudo code of the procedure Make-Prefix which is the main procedure of the algorithm. \begin{verbatim} MAKE-PREFIX(automaton \( \mathcal{A} = (Q, E, I, F) \)) INIT-TABLE(\( \mathcal{A} \)) STRONGLY-CONNECTED-COMPONENTS(\( \mathcal{A}_e \)) repeat INIT-LETTER(Q) bool \( \leftarrow \) FIND-LETTER(\( \mathcal{A}_e \)) if bool then MOVE-LETTER(\( \mathcal{A} \)) until bool = \text{false} \end{verbatim} The result of the computation of the automaton \( \mathcal{A} \) pictured in Figure 1 is the automaton pictured in Figure 2. The automaton \( \mathcal{A} \) is such that \( P_\mathcal{A} = \varepsilon \). Note that this automaton has an empty labelled cycle. \textbf{Remark 5} The two procedures FIND-LETTER and FIND-LETTER-VIST can be performed on the directed acyclic graph obtained as the quotient of \( \mathcal{A}_e \) by the relation of being in a same strongly connected component. This graph can be much smaller than \( \mathcal{A}_e \) itself. It can be computed by the procedure STRONGLY-CONNECTED-COMPONENTS. \textbf{Remark 6} By proposition 3, the label of a cycle is changed into one of its conjugate by the function MOVE-LETTER. Therefore, the strongly connected components of \( \mathcal{A}_e \) are unchanged during the iteration of function MAKE-PREFIX. \section{Data structures and complexity} In order to analyze the complexity of our algorithm, we briefly discuss a possible implementation of structures required in the construction. A classical way for implementing the automaton \( \mathcal{A} \) is to use \( |Q| \) adjacency lists that represent the edges. We may assume that we have two adjacency lists for each state \( q \). The first one represents the edges of empty label going out of \( q \), that is the edges that also belong to \( \mathcal{A}_e \). The second one represents the edges of non-empty label going out of \( q \). In order to compute, for each state \( q \), local(\( q \)) in a constant time, we maintain an array \( L \) indexed by \( Q \) defined as follows: - \( L[q] \) is the list of pairs \((a, n)\) with \( a \in A, n \geq 0 \in \mathbb{N} \), such that \( q \) has at least one outgoing edge labelled by a word whose first letter is \( a \) and such that \( n \) is the positive number of edges going out of \( q \) and whose first letter is \( a \). We point out that the first component of an element of $L[q]$ is a letter and never contains $\varepsilon$. Thus $\text{local}(q)$ is $\varepsilon$ if $L[q]$ has more than one element or if $q$ is initial or final. It is the letter $a$ if $L[q]$ contains exactly one pair $(a, n)$ and $q$ is neither initial nor final. It is $\top$ otherwise. The operation performed in the lists are the insertion of a new letter, that is a pair $(a, 1)$, the incrementation and decrementation of the second component of an element, and the deletion of a letter, that is of a pair $(a, 1)$. We need all these operations to be performed in a constant time. We use a known technique which allows us to get this time complexity (see for example [1] exercise 2.12 p. 71 and [10] exercise “Implantation de fonctions partielles” 1.14 Chapter 1). This technique is based on the use of array of size $|Q| \times |A|$ which is not initialized. We assume that the lists $L[q]$ are doubly linked and implemented with cursors. We denote by $T$ an array of variable size. The cells of $T$ are used to store the elements of the lists $L[q]$. Each cell has several fields: a field $\text{label}$ which contains the letter, a field $\text{number}$ that contains the number of edges going out of $q$ whose first letter is $\text{label}$, a field $\text{state}$ which contains the state $q$ such that the cell belongs to $L[q]$, and finally fields $\text{next}$ and $\text{prev}$ that give the index of the next (respectively previous) element in the same list. The cell of index $q$ of the array $L$ is the index in $T$ of the first element of $L[q]$, if this list is non-empty. Another array $U$, indexed by $Q \times A$, gives for each pair $(q, a)$ the index in $T$ of the cell of $L[q]$ whose letter is $a$, if this letter is in $L[q]$. This array allows us to access an element of a list in a constant time. The operations of insertion, deletion of an element in a list are then done in a constant time. The operations of incrementation and decrementation of the field $\text{number}$ of the cell of a given label in a given list are also done in a constant time. Indeed, to increment the field $\text{number}$ of the letter $a$ in $L[q]$, one increments the field $\text{number}$ of the cell of $T$ indexed by $U[q, a]$. The array $T$ is initially empty and its size is 0. The size of $T$ is incremented when a new cell is needed in $T$. A cell that corresponds to an element of a list that has just been removed is marked to be free. Thus the existence of a letter $a$ in $L[q]$ is obtained by checking whether $U[q, a]$ is an index $i$ in $[1, \text{size}(T)]$, whether the cell $T[i]$ is not marked free, and whether the fields label and state are respectively equal to $a$ and $q$. This is performed in a constant time. All the lists of successors that represent the edges of the automaton $A$ and $A_{\varepsilon}$, and the arrays $\text{local}$, $L$, $T$, $U$ are updated when the label of an edge is changed during the process. The arrays $L$ and $\text{local}$ are initialized by the procedure $\text{Init-Table}$. The arrays $L$, $T$, $U$ and $\text{local}$ are updated by the procedures $\text{Update-Table-Head}$ and $\text{Update-Table-Tail}$. We give below a pseudo code for the procedure $\text{Init-Table}$. \text{Init-Table}((\text{automaton } A = (Q, E, I, F)) \begin{align*} \text{for each } q \in Q \text{ do} & \\ & L[q] \leftarrow \text{the empty list} \\ & \text{local}[q] \leftarrow \top \\ \text{for each } q \in Q \text{ do} & \\ \end{align*} for each edge \((q, au, r)\) where \(a\) is letter and \(u\) a word do if \(a\) is not in \(L[q]\) then insert the pair \((a, 1)\) in \(L[q]\) else increment the field number of the letter \(a\) in \(L[q]\) if \(L[q]\) has more than one element or if \(q\) is initial or final then local\(q\) \(\leftarrow\) \(\varepsilon\) else if \(L[q]\) is not empty then local\(q\) \(\leftarrow\) the unique letter of \(L[q]\) We now describe the updating of the tables and lists. An update is needed as soon as the label of an edge of \(A\) is changed. Note that the labels of the edges of the automata \(A\) and \(A_e\) are changed in a constant time. Indeed, a label of an edge going out of a state \(q\) that becomes empty is removed from the list of edges of non-empty labels going out of \(q\), and added into the list of edges of empty labels going out of \(q\) (and conversely). This is performed in a constant time in line 3 and line 5 of [Move-Letter-Visit]. To update the arrays \(L, T, U\) and \(local\), we distinguish the two kinds of modification of the labels of the edges. A letter or the empty word can be added at the end of a label. The procedure called to update is in this case the procedure Update-table-Tail. A letter or the empty word can be removed from the head of the label. The procedure called to update is in this case the procedure Update-table-Head. Pseudo codes for Update-table-Tail and Update-table-Head are given below. Update-table-Tail\((edge \ q = (q, u, r), \ \text{letter (or empty word)} \ x)\) if \(u = \varepsilon\) and \(x \neq \varepsilon\) then if \(x\) is not in \(L[q]\) then insert the pair \((x, 1)\) in \(L[q]\) else increment the field number of the letter \(x\) in \(L[q]\) if \(L[q]\) has more than one element or if \(q\) is initial or final then local\(q\) \(\leftarrow\) \(\varepsilon\) else local\(q\) \(\leftarrow\) the unique letter of \(L[q]\) Update-table-Head\((edge \ q = (q, u, r), \ \text{letter (or empty word)} \ x)\) We have \(u = xu'\), where \(u'\) is a finite word, whenever \(x \neq \varepsilon\) if \(x \neq \varepsilon\) then decrement the field number of the letter \(x\) in \(L[q]\) if this field is equal to 0 then remove the pair \((x, 0)\) from \(L[q]\) if \(u' = bu''\) where \(b\) is a letter of \(A\) then if \(b\) is not in \(L[q]\) then insert the pair \((b, 1)\) in \(L[q]\) else increment the field number of the letter \(b\) in \(L[q]\) if \(L[q]\) has more than one element or if \(q\) is initial or final then local\(q\) \(\leftarrow\) \(\varepsilon\) else if \(L[q]\) has exactly one element then local\(q\) \(\leftarrow\) the unique letter of \(L[q]\) else locally] $\leftarrow T$ We analyze now the complexity of our algorithm. We denote by $|S|$ the cardinality of a set $S$. As the automaton is trim, $|Q| \leq |E| + 1$. We also denote by $|E_e|$ the cardinality of the current automaton $\mathcal{A}_e$. We always have $|E_e| \leq |E| but the automaton $\mathcal{A}_e$ may be much smaller than $\mathcal{A}$. We denote here by $P$ the maximal length of the words $P(q)$ for all states $q$. Proposition 7 Function Make-Prefix works in time $O((P + 1) \times |E|)$. Proof. Function Init-Table can be implemented to work in time $O(|Q| + |E|)$. Functions Strongly-Connected-Components and Find-Letter can be implemented to work in time $O(|Q| + |E_e|)$. Function Init-Letter works in time $O(|Q|)$. As discussed above, function Update-Table works in time $O(1)$. Function Move-Letter works in time $O(|Q| + |E|)$ Finally the loop in Make-Prefix is executed at most $P + 1$ times. The complexity of our algorithm is then $O((|Q| + |E|) \times (P + 1) + (|Q| + |E_e|) \times (P + 1))$. Since the automata considered are trim, $|Q| \leq |E| + 1$ and the complexity is thus $O((P + 1) \times |E|)$. Let $S$ be the sum of the lengths of the labels of all edges of the automaton. The space complexity of the algorithm is $O((|Q| \times |A|) + |E| + S)$. 5 Acknowledgements We thank Christian Choffrut and Maxime Crochemore for useful discussions and comments. Christian Choffrut pointed out to us the inaccuracy of the algorithm of [13] in the particular case where the automaton has an empty labelled cycle. We also thank the anonymous referees for their relevant remarks. References [1] Aho, A. V., Hopcroft, J. E., and Ullman, J. D. The Design and and infinite words. Tech. Rep. 99-12, I.G.M., Université de Marne-la-Vallée, 1999. 1979. [5] Brislauer, D. The suffix tree of a tree and minimizing sequential trans- ducers. In CPM'96 (1996), vol. 1075 of Lecture Notes in Computer Science, Springer-Verlag, pp. 116-129.
{"Source-Url": "https://hal-upec-upem.archives-ouvertes.fr/hal-00619217/file/hal.pdf", "len_cl100k_base": 10322, "olmocr-version": "0.1.53", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 69468, "total-output-tokens": 12078, "length": "2e13", "weborganizer": {"__label__adult": 0.0004987716674804688, "__label__art_design": 0.0006494522094726562, "__label__crime_law": 0.0005397796630859375, "__label__education_jobs": 0.0021572113037109375, "__label__entertainment": 0.0001920461654663086, "__label__fashion_beauty": 0.00027370452880859375, "__label__finance_business": 0.0003819465637207031, "__label__food_dining": 0.0006251335144042969, "__label__games": 0.0012140274047851562, "__label__hardware": 0.0018720626831054688, "__label__health": 0.00136566162109375, "__label__history": 0.0005841255187988281, "__label__home_hobbies": 0.00022149085998535156, "__label__industrial": 0.0008225440979003906, "__label__literature": 0.0012836456298828125, "__label__politics": 0.00047469139099121094, "__label__religion": 0.0010528564453125, "__label__science_tech": 0.364990234375, "__label__social_life": 0.00017213821411132812, "__label__software": 0.007904052734375, "__label__software_dev": 0.611328125, "__label__sports_fitness": 0.00040602684020996094, "__label__transportation": 0.000949859619140625, "__label__travel": 0.0002532005310058594}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 36913, 0.01919]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 36913, 0.62996]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 36913, 0.79936]], "google_gemma-3-12b-it_contains_pii": [[0, 892, false], [892, 3161, null], [3161, 6725, null], [6725, 10060, null], [10060, 12071, null], [12071, 15135, null], [15135, 18148, null], [18148, 21601, null], [21601, 24780, null], [24780, 27168, null], [27168, 30737, null], [30737, 33485, null], [33485, 35713, null], [35713, 36913, null]], "google_gemma-3-12b-it_is_public_document": [[0, 892, true], [892, 3161, null], [3161, 6725, null], [6725, 10060, null], [10060, 12071, null], [12071, 15135, null], [15135, 18148, null], [18148, 21601, null], [21601, 24780, null], [24780, 27168, null], [27168, 30737, null], [30737, 33485, null], [33485, 35713, null], [35713, 36913, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 36913, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 36913, null]], "pdf_page_numbers": [[0, 892, 1], [892, 3161, 2], [3161, 6725, 3], [6725, 10060, 4], [10060, 12071, 5], [12071, 15135, 6], [15135, 18148, 7], [18148, 21601, 8], [21601, 24780, 9], [24780, 27168, 10], [27168, 30737, 11], [30737, 33485, 12], [33485, 35713, 13], [35713, 36913, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 36913, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
5252a5119d012bdd34b4c62c1372bdfeaefef5f4
This is an electronic reprint of the original article. This reprint may differ from the original in pagination and typographic detail. Author(s): Käkölä, Timo Title: Standards Initiatives for Software Product Line Engineering and Management within the International Organization for Standardization Year: 2010 Version: Please cite the original version: All material supplied via JYX is protected by copyright and other intellectual property rights, and duplication or sale of all or part of any of the repository collections is not permitted, except that material may be duplicated by you for your research use or educational purposes in electronic or print form. You must obtain permission for any other use. Electronic or print copies may not be offered, whether for sale or otherwise to anyone who is not an authorised user. Standards Initiatives for Software Product Line Engineering and Management within the International Organization for Standardization Timo Käkölä University of Jyväskylä 40014 University of Jyväskylä, Finland timokk@jyu.fi Abstract: Software product line engineering is an established methodology for fast and effective development of software-intensive systems and services. To reap maximum benefits from the methodology, businesses typically need to implement coordinated changes in development methodologies, tools, product architectures, organizational designs, and business models. Product lines are developed in complex international software ecosystems, but there is no coordinated set of international standards for defining and leveraging the methodology. As a result, ecosystems cannot adopt standardized methods and tools for developing product lines, tool vendors face difficulties in developing tools to enable product line engineering, and universities cannot effectively set up product line engineering courses because an internationally accepted curriculum is missing. The International Organization for Standardization has initiated several projects to create a set of international standards for software product line engineering. Practitioners, researchers, and other stakeholders can contribute to these projects through their national standards bodies. This paper discusses the projects and future directions for product line standardization. Keywords: International Organization for Standardization, Software product line engineering and management, Software product line body of knowledge 1. INTRODUCTION To succeed in the global markets of software-intensive products, high-tech companies need to shorten the cycle time of new product development while improving product quality and service delivery and maintaining or reducing the total resources required [2;18]. This concern can be dealt through internal or external strategies. Internal strategies include global software development, where development resources are distributed globally to reap cost benefits, leverage specialized competencies, and address specific needs of geographically defined markets [3;8;21]. and software product line engineering and management, that is, the strategic acquisition, creation, and reuse of software assets [15;17;20]. External strategies include acquiring commercial off-the-shelf components and outsourcing software development, maintenance, and related services to best-in-class service providers [4;14]. This paper focuses on the software product line engineering strategy in the contexts of global software development and ecosystems. Software product line engineering is a methodology for developing software products and software-intensive systems and services faster, at lower costs, and with better quality and higher end-user satisfaction than is possible through the engineering of single systems. It has been applied and found useful in organizations worldwide. It differs from the engineering of single systems in two primary ways [20]: 1. It needs two distinct development processes: domain engineering and application engineering. Domain engineering defines and realizes the commonality and variability of the software product line, thus establishing the common software platform for developing high-quality applications rapidly within the line. Application engineering derives specific applications by strategically reusing the platform and by exploiting the variability built into the platform. 2. It needs to explicitly define and manage variability. During domain engineering, variability is introduced in all software product line assets such as domain requirements, architectural models, components, and test cases. It is exploited during application engineering to derive applications mass-customized to the needs of different customers and markets. Organizations typically have to overcome numerous challenges to fully reap the benefits from software product line engineering. They need to implement coordinated changes in development methodologies, tools, product architectures, organizational designs, and business models [6;19]. They also need to be able to develop product lines in complex international software ecosystems. However, the software product line engineering body of knowledge is still fragmented and there is no coordinated set of international standards for defining and leveraging the software product line methodology. As a result, ecosystems cannot adopt standardized methods and tools for developing product lines, tool vendors face difficulties in developing tools to enable product line engineering, and universities cannot effectively set up product line engineering courses because an internationally accepted curriculum is missing. The seventh subcommittee (SC 7) titled “Software and Systems Engineering” of the Joint ISO/IEC Technical Committee (JTC 1) of the International Organization for Standardization (ISO) has initiated several projects and will initiate new ones between 2010 and 2012 to create a coordinated set of international standards for... software product line engineering. The author of this paper serves as a co-editor in these projects, providing technical expertise and leadership, facilitating, and coordinating the international efforts in these projects together with the other editors. Numerous decisions need to be taken in these and future projects to define and organize the software product line body of knowledge, so it becomes more actionable, convergent, and easier to improve by practitioners and researchers in the future. A small group of experts within SC 7 has already conducted ample planning, research, and writing for these projects and taken some decisions to scope them appropriately. However, the projects are still in early phases. The purpose of this paper is to discuss some of the plans and issues that the projects will work on during the next few years and to solicit relevant input from practitioners and researchers to facilitate the identification and analysis of relevant content for the standards, consensus building, and decision-making. Stakeholders worldwide can contribute to the projects through their national standards bodies. The paper is organized as follows. In Section 2, challenges involved in software product line engineering and the implications of those challenges for practitioners, researchers, educators, and other stakeholders are discussed. Section 3 discusses the background and status of software product line standards initiatives within the International Organization for Standardization. Section 4 concludes the paper and presents potential future directions for product line standardization. 2. CHALLENGES INVOLVED IN SOFTWARE PRODUCT LINE ENGINEERING AND MANAGEMENT This section covers important challenges that organizations, practitioners, educators, researchers and other stakeholders face in trying to benefit from software product line engineering. 2.1 The need for high levels of abstraction Software product line engineering involves higher levels of abstraction than the engineering of single-systems partly because the platforms require substantial investments, have long life cycles, and have to provide product line architectures and features generally applicable to a wide range of products, services, and markets. Without appropriate abstractions the platforms with predefined variability cannot be built and managed effectively. Highly competent individuals are required to create and manage these abstractions. On the other hand, high levels of abstraction improve productivity, for example, by enabling the automation of routine development tasks [23]. Industrially validated modeling methods and commercially available modeling tools are critically important to deal with the abstractions [13]. In addition to traditional system modeling, variability modeling is required in product line engineering to document explicitly how the applications within the product line can vary. 2.2 The need to cope with high levels of complexity Software product line engineering involves higher technical, social, and managerial complexity than the engineering of single systems. Software product lines are typically larger than single systems and developed in large software ecosystems in which sets of interlinked businesses draw upon the software and hardware platforms to function as units and interact with shared international markets for software and services through the exchange of information, resources, and artifacts. Dealing with this complexity requires well-coordinated changes in development methodologies, processes, tools, product architectures, organizational designs, business models, and capability levels of the stakeholders involved. Domain engineering typically requires development methodologies that can deal with large scale and long term platform development and meet stringent stability, reliability, scalability, security, and other quality requirements. Application engineering requires strong market orientation, short development cycles, and fast time-to-market. As a result, organizations wishing to deploy software product lines may not be able to choose any particular development methodology for organization-wide use, which may increase development complexity and costs [17]. Domain engineering and application engineering often need to be carried out in separate organizational units because their concerns are so different. If adequate separation is not conducted, domain engineers may end up working in short term application engineering projects, which are typically perceived to earn most or all of the financing for the business as a whole, and the long-term investments in shared platforms may be hampered. Yet, the work products of these organizations need to be successfully integrated to deliver products to markets. Without careful organizational designs, organizational complexity and costs may increase, but the organizational effectiveness may not rise accordingly. The two engineering life cycles and enabling knowledge management systems also need to be carefully and holistically designed because the cycles are very knowledge intensive and require the management of a large number of complex dependencies between many types of artifacts. The relationships between artifacts need to be explicit and traceable to enable adequate coupling between domain and application engineering. Specifically, the relationships between domain artifacts need to be traceable within the domain engineering life cycle, the relationships between application artifacts need to be traceable within the application engineering lifecycle, and the relationships between domain and application artifacts have to be traceable across the domain and application engineering lifecycles [20]. For example, application test cases typically depend on application requirements, but also reuse domain test cases, which depend on domain requirements [22]. Finally, the business models need to be appropriate and clear from the external and internal viewpoints. Most importantly, the organization has to identify and prioritize the market and technology domains it will be targeting and the planning horizon needs to be long enough, so it is possible to determine whether the required platform and product development and marketing investments are likely enough to produce the desired financial and other returns on investments from the targeted domains. Deep stocks of domain knowledge need to be developed about the targeted market and technology domains, so the business model must ensure direct access to the markets and technology providers. Otherwise, intermediaries may hamper or block the knowledge flows required to establish and maintain the required stocks of domain knowledge. From an internal viewpoint, the business model must facilitate the adequate (but not excessive) financing and resourcing of domain engineering. This is especially important in the early phases of building the platform(s) when substantial investments are required but their returns are not yet materializing [17]. 2.3 The fragmented body of knowledge While many businesses have been able to increase their organizational efficiency and effectiveness through software product line engineering, the extant software product line body of knowledge remains fragmented, making it challenging for educators to teach and for students and practitioners to understand and apply software product line concepts. An internationally accepted academic educational curriculum and readily available teaching materials for software product line engineering are missing, hampering the effective set up and execution of product line engineering courses in universities and other institutes of higher education. The only well known curriculum has been established by the Software Engineering Institute, but it is proprietary and targeted to practitioners. It thus cannot be applied directly in universities. Most advances in the field have been presented in individual scientific papers but, in practice, few, if any, of the methods and tools presented in the papers are so widely used in the industry globally that they could be considered as de-facto standards for software product line engineering. International standards do not cover software product line engineering either. Individual papers cannot have both the holistic scope and the details required to help businesses take coordinated product line adoption actions to redesign their business models, processes, and structures, knowledge management systems, and product line architectures appropriately. Books can better meet the scope requirements than individual research papers but there are only a few books that take a scientific and holistic enough view to enable software product line engineering education in universities. Pohl, Böckle, and Van der Linden [20] completed in 2005 the first and, so far, the only book about software product line engineering explicitly targeted to students in undergraduate and graduate level university courses. It covers all the practices and concepts that need to be mastered to implement product lines. However, it has been written on a relatively high level of abstraction and the industrial validation of the proposed methods and tools is in early phases, making the practical application of the methods and tools challenging. The book of Clements and Northrop [5] is another important component of the product line engineering body of knowledge. It primarily supports the practitioner-oriented curriculum of the Software Engineering Institute. Due to their different focuses, the two books might complement each other well, when properly integrated under a common curriculum. However, such an integrated curriculum is nontrivial to develop, partly because Pohl et al. [20] and Clements and Northrop [5] reflect, respectively, European and North American product line research traditions relying on partly different concepts, terminologies, and methods to describe, develop, and deploy product lines. As a result, most students in software engineering, management information systems, information technology, marketing, and other relevant disciplines cannot develop holistic, inter-disciplinary views about software product line engineering and its organizational, technological, business, social, psychological, and other implications during their studies. 2.4 The lack of tools The fragmented body of knowledge and the lack of international software product line standards also hurt commercial software tool vendors. Interoperable and even integrated information systems are critical to support knowledge management throughout the domain and application engineering life-cycles [16] and during variability modeling and resolution [1]. Yet, commercially available and industrially validated software tools to implement such systems for product line engineering are scarcely available partly because the markets do not know what to expect from such tools and thus remain small and fragmented. Tool vendors have typically circumvented the problem (1) by focusing on features that support the engineering of single systems well through standardized general purpose languages and methods and (2) by enabling extension mechanisms that let organizations tailor their own methods and tools for purposes such as variability modeling. For example, to model the variability of product lines, two approaches have been proposed in the literature: integrated and orthogonal variability modeling. The first, traditional approach has been to integrate variability modeling in the systems modeling notation, typically Unified Modeling Language™ (UML) [7;10], by appropriately extending the metamodel of the notation through profiles. Extended UML metamodels enabling both system and variability modeling are available in the literature [1] and most general purpose UML modeling tools support the design and use of the extended metamodels through profiles [24;25]. In this approach, variability models can only be edited by people who use UML tools with the same extended UML metamodel. An organization can thus implement variability modeling practices by adopting a variability metamodel available in the literature; adapting the metamodel to its needs as necessary; establishing organization-wide policies, incentive schemes, and training mechanisms to enforce variability modeling using the metamodel; and codifying the metamodel into the modeling tool(s) used organization-wide. However, a thorough literature review conducted for this research paper has revealed no literature about such variability modeling implementations in organizations. Indeed, agreeing upon and institutionalizing a new extended UML meta-model in any large organization is likely to be very challenging considering that UML is complex in itself to learn and use and extensions will increase the complexity. Moreover, spreading the variability information across different system models would make it very difficult to keep the information consistent and unambiguous and to provide stakeholders with holistic views of software variability [20, p. 74-75]. Even if the meta-model was agreed upon and instituted organizationally, it would not be enough because software product line engineering typically involves numerous partners and other external organizations in complex global ecosystems. To establish variability modeling practices using UML tools in such ecosystems, all the organizations involved would have to agree upon a common extended UML meta-model. Based on the available literature and the author’s own experiences in such global ecosystems, it will be unlikely that variability modeling practices based on such metamodel extensions would become common. A more feasible option may be to officially extend the ISO/IEC 19501 (UML) standard [10] to cover variability modeling. Such an extension is beyond the scope of this paper and the ISO is not currently pursuing it. The second variability modeling approach, orthogonal variability modeling, distinguishes between a variability model and a system model [20]. An orthogonal variability model represents a cross-sectional, holistic view of variability across all associated software development artifacts such as requirements, designs, software implementations, and test cases. Models with the highest levels of abstraction are used to represent external variability from the viewpoint of market segments and customers, whereas the lower abstraction levels manifest internal (mostly technical) variability from the viewpoint of the product line provider. Pohl et al. [20, Ch. 4] present a comprehensive metamodel for orthogonal variability modeling that enables product line engineers to capture variation points, that is, the items that vary; variants defining how the variable items can vary; and constraints between variants, between variants and variation points, and between variation points. Orthogonal variability models are easier to apply in practice than integrated models partly because organizations can continue to use the systems modeling notations such as UML they are familiar with. No changes in the metamodels of systems modeling notations are needed because orthogonal variability models are created separately and associated with the system models through traceability links. Orthogonal variability models also scale better than integrated ones. They usually describe the variability using graphical notations. However, orthogonal variability modeling is not yet used in the industry partly because there are no commercially available modeling tools to support it. The best way to improve tool support may be the international standardization of the metamodel for orthogonal variability modeling. Vendors would then have a baseline for developing their tools and markets would know better what benefits and services to expect from variability modeling and the supporting tools. The metamodel presented by Pohl et al [20, Ch. 4] can be used as one basis of standard development because it captures variation points, variants, and the other meta-classes and their relationships deemed most important in the variability modeling literature. 2.5 Summary Software product line engineering research and practice has produced a very comprehensive body of knowledge that has already been used successfully in numerous organizations. However, over time the body of knowledge has become divergent, consisting of a myriad of concepts, models, methods, and tools that are partially overlapping, inconsistent, competing, and possibly even conflicting. During the next decade, the field must focus more on consolidating its body of knowledge. Indeed, the field has now matured to a stage where the next level of development requires coordinated actions beyond the research community. Markets naturally have a key role in determining which research deliverables and other stocks of knowledge produce most value in practice, thus facilitating the consolidation of the software product line body of knowledge. International standardization efforts are also needed to determine those parts of the body of knowledge that are stable and coherent enough for standardization purposes. 3. STANDARDIZATION INITIATIVES To address many of the diverse challenges software product line researchers and practitioners face (Section 2), a set of interrelated software product line engineering standards will be created by ISO/JTC1/SC7. This section describes the background for the software product line standardization initiative and presents and analyzes the preliminary reference model that is being developed to guide more specific standardization projects in the future. 3.1 Background ISO/JTC1/SC7 decided to initiate activities related to software product line engineering standardization in its plenary meeting in Helsinki in May 2005. It appointed the author of this paper and professor Dan Lee (from Korea Advanced Institute of Technology) to lead an international group of experts in a project studying the need for new and/or revised standards in the field of requirements engineering. At that time, the author was involved with the largest software engineering research project series (ESAPS, CAFÉ, and FAMILIES) conducted in Europe by that time. The series of projects focused on product line engineering and FAMILIES, the concluding project, was being completed. Substantial advances in the tools and methods related to software product line requirements engineering had been created in the project series [15,17,20]. No international standards existed for such methods and tools because the existing standards focused on requirements engineering of single systems. In response to the appointment, the author and Dan Lee reviewed requirements engineering standards and proposed that ISO/JTC1/SC7, among other issues, should create a new standard for software product line requirements engineering. The proposal was accepted in May 2006 and a new project ISO/IEC 29118 was started. During the next two years, a small team including Dan Lee and the author created several ISO/IEC 29118 standard drafts. During the process, it became evident that the scope of the 29118 project was too wide. Software product line requirements engineering involves parts of both domain and application engineering life-cycles. Because there is no standard describing the life-cycles and the central concepts of software product line engineering, a reference model for the two lifecycle processes and a thorough glossary were incorporated in the 29118 drafts. Some drafts were more than 100 pages long with several appendixes. ISO/JTC1 policies have recently started to emphasize the creation of sets of small, interrelated, and coordinated standards. For each set, one standard typically outlines the overall architecture, that is, the concepts to be probed in individual standards within the set and the relationships between them. In broad, complex, and rapidly developing fields such as software product line engineering, the standard creation process is typically ongoing, that is, once an international standard is accepted and released, its revision starts immediately so a new release replacing the previous one (and possibly some other standards) will be ready about five years later. It is easier to create, agree upon, and maintain small and well-scaled standards than a few large ones. The drawbacks with the approach relate mainly to keeping numerous interrelated standards within each set consistent and to the readability and understandability of each set when there is no one document covering the entire scope of the standard set holistically and in depth. SC 7 has decided to create a set of interrelated software product line engineering standards. The 29118 project has been terminated in 2009 and its contents have been divided into two new projects. ISO/IEC 26520 [11] will establish a reference model for software product line engineering, covering phases of the domain and application engineering life-cycles on a high level of abstraction. ISO/IEC 26521 [12] details the domain and application requirements engineering processes. During the next decade, new projects will create three standards for the other commonly accepted life-cycle phases: product line architecting, realization, and testing. There will also be standards for technical management (ISO 26525) and organizational management (the standard number has not yet been assigned) practices. The set of standards is intended to benefit businesses in various industries, tool vendors, researchers, and research institutes investigating, facilitating, and/or leveraging software product line engineering practices. 3.2 Review of ISO/IEC 26520 Draft from May 2009 The draft of the ISO/IEC 26520 is intended to: - Enable its users to holistically understand, adopt, and enact the domain and application engineering life-cycles. - Enable its users to evaluate and select relevant methods and tools based on business and user-related criteria. - Help development teams specify, verify, and validate engineering and management practices for existing or envisioned product lines based on the product line practices described in the standard. - Provide a reference model for software product line engineering and management, that is, an abstract representation of the domain and application engineering life-cycles and enabling core asset management, organizational management, and technical management processes that will be detailed in the other software product line standards. - Help tool vendors develop interoperable tool suites and features supporting the domain and application engineering life-cycles and their phases and communicate about their tools to the markets. In the preliminary reference model (Figure 1), software product line engineering consists of domain engineering and application engineering life-cycles. The phases of the two life-cycles have been aligned with the framework of Pohl et al. [20, p. 22], so the users of the envisioned standard can find details about the life-cycles and their phases from one well-respected source. The life-cycles should be loosely coupled, synchronized by platform releases, and enacted based on different life-cycle models as they are typically performed with different quality criteria and objectives in mind. In addition, the reference model emphasizes core asset management, organizational management, and technical management processes. Domain engineering Domain engineering consists of the following phases: product line scoping, domain requirements engineering, domain design, domain realization, and domain testing (c.f., [20, p. 22]). Product management is responsible for product line scoping (or, synonymously, product line roadmapping or product portfolio management) that - defines the products that will constitute the product line and the common and variable features that are visible to markets, - analyzes the products from an economic viewpoint, and - schedules and monitors the development and marketing of the product line and its products. Product line scoping is divided into three sub-processes (c.f., [17, p. 31]): - **Product portfolio scoping** determines the product roadmap for the products the product line organization should be developing, producing, marketing, and selling; the common and variable features that should be provided to reach the long and short term business objectives of the product line organization; and the schedule for introducing products to markets. - **Domain scoping** draws upon the product types to identify the functional areas most important to the envisioned product line. The areas must provide sufficient reuse potential to justify the product line. - **Asset scoping** is used to identify the core assets (i.e., domain artifacts the common and variable features of the product line can reuse) and estimate their costs and benefits in order to determine whether an organization should launch a product line. **Figure 1. The preliminary reference model of the ISO/IEC 26520 draft for software product line engineering and management [11].** Domain requirements engineering refines the common and variable high-level features for the products identified during product line scoping; constructs a detailed enough requirements specification, including the orthogonal variability model, to guide domain design, realization, and testing; and provides feedback to product management with respect to the changes required in the feature sets and the product roadmap as a whole. It consists of domain requirements elicitation, analysis, specification, and validation phases. Domain requirements elicitation identifies product line stakeholders as broadly as possible and captures the common and variable domain requirements the stakeholders can foresee over the lifetime of the product line. Domain requirements analysis identifies and refines the elicited domain requirements. Thorough negotiations with the stakeholders are typically necessary to ensure there are enough common and variable features to justify product lines from the economic viewpoint. Domain requirements specification documents the common and variable requirements. Specifications may include symbolic placeholders, where application requirements engineering can incorporate product-specific requirements. During domain requirements validation the stakeholders verify and validate that the right domain requirements have been specified correctly. Domain requirements are then baselined. During domain requirements management they can only be changed through systematic change management and impact analysis policies governing how changes in the domain requirements are proposed, reviewed, and accepted. Domain requirements are domain artifacts managed by domain requirements engineering. **Domain design** develops a product line reference architecture enabling the realization of the common and variable requirements, evaluates the architecture from the viewpoints of functional and quality requirements, and manages changes related to the architecture. The reference architecture defines a generic structure and a set of rules all applications within the product line must follow to successfully reuse the common features and some of the variable features. It also incorporates new internal variable features to facilitate the technical implementation of various product variants during application engineering. It must have a long life cycle and accommodate the needs of all applications reasonably well, so it should be periodically evaluated and improved as necessary. To facilitate evaluation, change management, and impact analysis, the architecture has to be fully traceable to the respective domain requirements. **Domain reference architectures are domain artifacts managed by domain design.** **Domain realization** buys, designs, and implements the common and variable realization artifacts, including the reusable components, interfaces, and the supporting infrastructure, and partially validates them with respect to the common and variable requirements and the structures and rules of the reference architecture. The outcomes of domain realization are responsible for managing changes related to these interfaces and components. It does not build executable applications. As a result, validation and change management depend on full traceability (1) Legend: Phase Information flow Application engineering develops individual systems on top of the platform established in domain engineering. It deals with less complexity and shorter development times than domain engineering because large parts of engineering have been moved to domain engineering. It is directly involved with customers and thus needs to deal with rapidly changing market needs effectively while using the platform offerings to maximum possible extent. In the preliminary ISO/IEC 26520 reference model, application engineering follows the life-cycle described by Pohl et al. [20, p. 22]: application requirements engineering, application design, application realization, and application testing. Therefore, these life-cycle phases are only described briefly in the following subsections. Application requirements engineering identifies the specific requirements for individual products. It starts from existing common and variable requirements to maximally leverage the product line platform. It also has an important role in providing insights to domain requirements engineering in order to guide platform development especially in the early phases of the product line creation. Application design derives an instance of the product line reference architecture and adapts it, so the resulting application architecture conforms to the application requirements. The application architecture should be consistent with the reference architecture to enable the reuse of domain artifacts. Application realization implements products by drawing upon the application requirements and architecture; reusing, configuring, and adapting existing domain components and interfaces; and building new components and interfaces to enable application-specific functionality. Application testing validates the final applications against the application requirements by drawing upon domain test artifacts to test common and variable features derived from the platform; creating new application test artifacts for application-specific features; performing application-specific tests; and analyzing the results and taking corrective actions. Organizational management Organizational management refers to organizational-level ongoing practices that are necessary for the successful introduction and institutionalization of the domain and application engineering life-cycles in organizations (c.f., [5;19]). Organizations cannot reap maximum benefits from software product line engineering without solid business cases, long-term commitments of top executives, appropriate organizational designs, effective transitioning of people from the engineering of single systems to engineering product lines, and consistent orchestrations of daily product line routines. The ISO/IEC 26520 draft outlines three organizational management practice areas: business case management, transition management, and operations management. Business cases in the context of software product lines serve two purposes [19]: (1) justifying the effort to adopt the product line approach for building products and (2) deciding whether or not to include a particular product as a member of a product line. This practice area is challenging from the viewpoint of the structure of the ISO/IEC 26520 draft because the same practices are also incorporated in the domain scoping phase of the preliminary reference model, creating redundancy within the model. However, it may be justified to keep this practice area in organizational management because the building of business cases is a complex, multi-disciplinary, and strategic ongoing activity at least in large organizations that run multiple product lines. Competencies for building business cases in such organizations must be shared across all product lines and products and thus be located in the organizational level. Moreover, organization-wide data collection and measurement systems need to be instituted to track on an ongoing basis how well product line organizations are meeting the goals specified in the business cases. Such issues are not addressed by the domain and application engineering life-cycle models specified in the draft. Transition management practice area incorporates all practice areas that according to Northrop and Clements [19] are needed to transition an organization from single systems engineering to product line engineering: funding, launching and institutionalizing, structuring the organization, training, and organizational planning and risk management. Launching a software product line requires the creation of an adoption plan to describe how the two life-cycles and the supporting organizational and technical management practices will be appropriately rolled out across the organization. The product line strategy can be considered institutionalized within organizations when the organizations have extensive core asset bases and supporting organizational structures, processes, information systems, and business models in place and when their developer communities routinely use the domain artifacts to develop products. *Operations management* practice area [19] describes (1) the organizational units and stakeholders involved, (2) the interconnections among organizational units carrying out domain engineering, application engineering, and management, and (3) how the organizational units • produce and evolve domain artifacts • define and evolve the production plan • use the domain artifacts and production plan to field products and • monitor and improve the health and profitability of the product line. It should be noted that the planning of the specific standard for organizational management practice areas is in early phases. There is little published research and data available globally from software product line organizations related to the relative importance of the practice areas. It is thus challenging to determine which particular areas are important enough be incorporated in the standard. When this work progresses and more evidence is obtained, other organizational management practice areas are likely to be incorporated in the ISO/IEC 26520 reference model. For example, acquisition management is a key practice area because both application and domain engineering units may outsource or offshore large chunks of engineering. It should also be noted that the organizational management practice areas in the draft are descriptive because they follow mainly the lessons from the software product line practice initiative of the Software Engineering Institute [19]. The draft thus does not provide a staged representation similar to the staged representation of the CMMI. A staged representation would provide organizations with a roadmap through which they could raise the maturity of software product line practices by following a proven sequence of improvements, beginning with basic practices and tools and progressing through a predefined path of successive levels, each serving as a foundation for the next. Van der Linden et al. [17] present the Family Evaluation Framework, providing organizations with such a roadmap. The framework can be used to measure organizations’ product line abilities from the viewpoints of business, domain and application engineering life-cycles, product line reference architecture, and organization design. Improvements can then be focused on areas where most value can be created. The framework can thus be much more useful than simple descriptions. However, it has not yet been extensively validated in practice. The future development of the organizational management standard thus calls for thorough empirical validation of the framework. If the framework is found valid and useful, it can be seriously considered for inclusion in the reference model and the specific organizational management standard. **Technical management** Technical management practices are management practices necessary for the development and evolution of both domain artifacts and applications [19]. In the draft, the *process management* practice area includes all practice areas (except for the *scoping* practice area that is already incorporated in *product line scoping* and *business case management*) defined by Northrop and Clements [19] without significant changes: configuration management, make/buy/mine/commission analysis, measurement and tracking, process discipline, technical planning, technical risk management, and tool support. They are not elaborated in this paper. *Variability management* practice area helps domain and application engineers maintain the orthogonal variability model of a product line through five practices: (1) variability modeling, (2) traceability management, (3) variability annotation, (4) variability validation, and (5) variability control. *Variability modeling* supports domain and application engineers in developing the variability models in appropriate levels of detail and through consistent notations. *Traceability management* helps domain and application engineers establish and maintain links between the variability model and associated domain and application artifacts. The costs and benefits of traceability links should be analyzed to determine appropriate level of traceability. Having too much or too little traceability is costly [16]. *Variability annotation* helps domain and application engineers add descriptions to variability models and their elements, documenting, for example, whether a variation point deals with external or internal variability. *Variability validation* helps domain and application engineers and other stakeholders review or inspect the orthogonal variability model and its documentation and associations with domain and application artifacts. *Variability control* helps domain and application engineers manage changes related to variation points, variants, variability constraints, and traceability links in the orthogonal variability model. In the draft, *variability management* practice area belongs to *technical management*. However, the orthogonal variability model is usually the most important single domain artifact within a product line. Therefore, it may be more logical to incorporate *variability management* in the *core asset management* practice area in future drafts of ISO/IES 26520. Core asset management Core asset management practice area involves a set of information systems and associated services for storing, mining, and managing changes in the domain artifacts resulting from domain engineering and the relationships (e.g., traceability links) between them. Core asset management represents the most important difference between the preliminary reference model and the framework of Pohl et al. [20]. Pohl et al. [20, p.22] emphasize the roles of domain and application artifacts, including variability models, by visually representing domain artifacts as outputs of respective domain engineering phases that can be stored in domain artifact repositories and used as inputs to the respective application engineering phases. For example, domain requirements engineering produces domain requirements, which are reused or adapted by application requirements engineering. Pohl et al. [20] also visually represent application artifacts as application-specific outputs of the respective application engineering phases that can be stored in application-specific repositories. For example, when adapted domain requirements and new application-specific requirements together with the variability model are stored in the application-specific requirements repositories, it is easier for domain requirements engineers to analyze the application-specific requirements later. Based on the analysis, domain requirements engineers can then determine whether some of the requirements should be generalized as domain requirements and stored in domain requirements repositories for reuse in other applications. In the preliminary reference model of ISO/IES 26520, domain and application artifact repositories and their roles in sharing knowledge between domain and application engineering are not visible. Instead, core asset management implicitly incorporates the repositories. However, in the draft standard core asset management includes comprehensive change and configuration management processes, which are already incorporated in the domain engineering life-cycle. On the other hand, core asset management in the draft standard does not include application artifact repositories at all. The coverage of core asset management needs to be revised extensively in the future 26520 drafts to remove redundancy and fix the omissions. It is probably best to keep the change management of various domain artifacts in the respective domain engineering phases and only provide the domain and application artifact repositories and associated information management services through core asset management. 4. CONCLUSIONS This paper has identified and justified the need for international standards in the area of software product line engineering and management. It has outlined the strategy ISO/JTC1/SC7 is taking to bring about a set of software product line engineering and management to which all subsequent software product line standards will be linked. The set of standards is meant to advance (1) software product line practices in organizations in various industries and (2) the convergence and further accumulation of the software product line body of knowledge. The set is envisioned to be fairly well aligned with the books of Pohl et al. [20] and Van der Linden et al. [17]. It thus relies on orthogonal variability modeling that, so far, has not been extensively validated in various industries. This implies that design science research [9] is needed to develop industrially feasible tools for orthogonal variability modeling and that behavioral science research (e.g., case studies and action research) is needed to validate the orthogonal variability modeling approach in practice. Most of the tools and methods available in the extant software product line body of knowledge have not yet been fully validated in various industries. Therefore, this paper and the entire software product line standardization initiative of the ISO call for more extensive collaborative efforts between researchers and practitioners to further improve the relevance and validity of the available tools and methods. For example, the Family Evaluation Framework [17] can provide organizations with roadmaps through which they can choose the components of the product line body of knowledge most appropriate to their needs, accelerating the adoption of product line practices. When the framework has been validated through empirical research and appropriately revised, it may be incorporated in an international standard during the next decade. To facilitate industrial applications of software product line engineering, other new standardization projects, that have not yet been planned officially, will also be needed. For example, the variability metamodel for orthogonal variability modeling is not yet a part of any standardization project in ISO. Establishing a new standard solely for the variability metamodel may be the best option because it enables the evolution of the metamodel independently from other standards. The metamodel can also be expected to remain quite stable because the extant literature has already converged quite well concerning the metaclasses (e.g., variation point and variant) of the metamodel. 5. REFERENCES
{"Source-Url": "https://jyx.jyu.fi/bitstream/handle/123456789/26772/Standards_Initiatives_for_Software_Product.pdf;jsessionid=70CF5FBD3B4E7F5D2EC3DDF95C8B08E5?sequence=1", "len_cl100k_base": 8534, "olmocr-version": "0.1.53", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 32132, "total-output-tokens": 10698, "length": "2e13", "weborganizer": {"__label__adult": 0.00027441978454589844, "__label__art_design": 0.0002791881561279297, "__label__crime_law": 0.00027060508728027344, "__label__education_jobs": 0.0016317367553710938, "__label__entertainment": 4.571676254272461e-05, "__label__fashion_beauty": 0.00012922286987304688, "__label__finance_business": 0.0004341602325439453, "__label__food_dining": 0.00022220611572265625, "__label__games": 0.0004520416259765625, "__label__hardware": 0.0004451274871826172, "__label__health": 0.0002419948577880859, "__label__history": 0.00018918514251708984, "__label__home_hobbies": 5.418062210083008e-05, "__label__industrial": 0.00024330615997314453, "__label__literature": 0.0002301931381225586, "__label__politics": 0.00017440319061279297, "__label__religion": 0.00026726722717285156, "__label__science_tech": 0.006320953369140625, "__label__social_life": 6.777048110961914e-05, "__label__software": 0.00782012939453125, "__label__software_dev": 0.9794921875, "__label__sports_fitness": 0.0001938343048095703, "__label__transportation": 0.00033211708068847656, "__label__travel": 0.00014543533325195312}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 55000, 0.02754]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 55000, 0.16809]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 55000, 0.92312]], "google_gemma-3-12b-it_contains_pii": [[0, 1116, false], [1116, 6250, null], [6250, 12063, null], [12063, 18138, null], [18138, 23987, null], [23987, 29794, null], [29794, 34784, null], [34784, 39092, null], [39092, 45078, null], [45078, 50943, null], [50943, 55000, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1116, true], [1116, 6250, null], [6250, 12063, null], [12063, 18138, null], [18138, 23987, null], [23987, 29794, null], [29794, 34784, null], [34784, 39092, null], [39092, 45078, null], [45078, 50943, null], [50943, 55000, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 55000, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 55000, null]], "pdf_page_numbers": [[0, 1116, 1], [1116, 6250, 2], [6250, 12063, 3], [12063, 18138, 4], [18138, 23987, 5], [23987, 29794, 6], [29794, 34784, 7], [34784, 39092, 8], [39092, 45078, 9], [45078, 50943, 10], [50943, 55000, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 55000, 0.0]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
f816aabf14334e240f51df1b0dfdc6a5ed7076d2
Table of Contents Abstract and introduction .............................................................................................................. i Introduction ................................................................................................................................. 1 Are you Well-Architected? ......................................................................................................... 1 Continuous integration .................................................................................................................. 3 AWS CodeCommit ...................................................................................................................... 3 AWS CodeBuild ......................................................................................................................... 3 AWS CodeArtifact ..................................................................................................................... 4 Continuous delivery .................................................................................................................... 5 AWS CodeDeploy ...................................................................................................................... 5 AWS CodePipeline .................................................................................................................... 6 Deployment strategies .................................................................................................................. 7 In-place deployments ................................................................................................................. 7 Blue/green deployment .............................................................................................................. 7 Canary deployment ................................................................................................................... 7 Linear deployment .................................................................................................................... 8 All-at-once deployment ............................................................................................................ 8 Deployment strategies matrix .................................................................................................... 9 AWS Elastic Beanstalk deployment strategies ......................................................................... 9 Infrastructure as code .................................................................................................................. 10 AWS CloudFormation .............................................................................................................. 10 AWS Serverless Application Model ......................................................................................... 11 AWS Cloud Development Kit ................................................................................................. 12 AWS Cloud Development Kit for Kubernetes ....................................................................... 12 AWS Cloud Development Kit for Terraform ......................................................................... 12 AWS Cloud Control API ......................................................................................................... 12 Automation and tooling .............................................................................................................. 14 AWS OpsWorks ....................................................................................................................... 14 AWS Elastic Beanstalk ............................................................................................................ 15 EC2 Image Builder ................................................................................................................... 16 AWS Proton ............................................................................................................................. 16 AWS Service Catalog ............................................................................................................... 16 AWS Cloud9 .............................................................................................................................. 16 AWS CloudShell ..................................................................................................................... 16 Amazon CodeGuru .................................................................................................................. 17 Monitoring and observability ...................................................................................................... 18 Amazon CloudWatch metrics ................................................................................................. 18 Amazon CloudWatch Alarms ................................................................................................. 18 Amazon CloudWatch Logs ...................................................................................................... 18 Amazon CloudWatch Logs Insights ....................................................................................... 19 Amazon CloudWatch Events ................................................................................................. 19 Amazon EventBridge ............................................................................................................... 19 AWS CloudTrail ...................................................................................................................... 19 Amazon DevOps Guru ............................................................................................................. 20 AWS X-Ray ............................................................................................................................. 20 Amazon Managed Service for Prometheus ......................................................................... 20 Amazon Managed Grafana ....................................................................................................... 20 Communication and Collaboration ............................................................................................. 21 Two-Pizza Teams ..................................................................................................................... 21 AWS CodeStar ......................................................................................................................... 21 Security ...................................................................................................................................... 22 AWS Shared Responsibility Model ......................................................................................... 22 Identity and Access Management ......................................................................................... 23 Conclusion .................................................................................................................................. 24 Document Revisions .................................................................................................................. 25 Introduction to DevOps on AWS Publication date: April 7, 2023 (Document Revisions (p. 25)) Today more than ever, enterprises are embarking on their digital transformation journey to build deeper connections with their customers, to achieve sustainable and enduring business value. Organizations of all shapes and sizes are disrupting their competitors and entering new markets by innovating more quickly than ever before. For these organizations, it is important to focus on innovation and software disruption, making it critical to streamline their software delivery. Organizations that shorten their time from idea to production making speed and agility a priority could be tomorrow’s disruptors. While there are several factors to consider in becoming the next digital disruptor, this whitepaper focuses on DevOps, and the services and features in the Amazon Web Services (AWS) platform that will help increase an organization's ability to deliver applications and services at a high velocity. Introduction DevOps is the combination of cultural philosophies, engineering practices, and tools which increase an organization's ability to deliver applications and services at high velocity and better quality. Over time, several essential practices have emerged when adopting DevOps: continuous integration (CI), continuous delivery (CD), Infrastructure as Code (IaC), and monitoring and logging. This paper highlights AWS capabilities that help you accelerate your DevOps journey, and how AWS services can help remove the undifferentiated heavy lifting associated with DevOps adaptation. It also describes how to build a continuous integration and delivery capability without managing servers or build nodes, and how to use IaC to provision and manage your cloud resources in a consistent and repeatable manner. - **Continuous integration**: A software development practice where developers regularly merge their code changes into a central repository, after which automated builds and tests are run. - **Continuous delivery**: A software development practice where code changes are automatically built, tested, and prepared for a release to production. - **Infrastructure as Code**: A practice in which infrastructure is provisioned and managed using code and software development techniques, such as version control, and continuous integration. - **Monitoring and logging**: Enables organizations to see how application and infrastructure performance impacts the experience of their product’s end user. - **Communication and collaboration**: Practices are established to bring the teams closer and by building workflows and distributing the responsibilities for DevOps. - **Security**: Should be a cross cutting concern. Your continuous integration and continuous delivery (CI/CD) pipelines and related services should be safeguarded and proper access control permissions should be set up. An examination of each of these principles reveals a close connection to the offerings available from AWS. Are you Well-Architected? The AWS Well-Architected Framework helps you understand the pros and cons of the decisions you make when building systems in the cloud. The six pillars of the Framework allow you to learn architectural best practices for designing and operating reliable, secure, efficient, cost-effective, and sustainable systems. Using the AWS Well-Architected Tool, available at no charge in the AWS Management Console, you can review your workloads against these best practices by answering a set of questions for each pillar. Continuous integration Continuous integration (CI) is a software development practice where developers regularly merge their code changes into a central code repository, after which automated builds and tests are run. CI helps find and address bugs quicker, improve software quality, and reduce the time it takes to validate and release new software updates. AWS offers the following services for continuous integration: Topics - AWS CodeCommit (p. 3) - AWS CodeBuild (p. 3) - AWS CodeArtifact (p. 4) AWS CodeCommit AWS CodeCommit is a secure, highly scalable, managed source control service that hosts private git repositories. CodeCommit reduces the need for you to operate your own source control system and there is no hardware to provision and scale or software to install, configure, and operate. You can use CodeCommit to store anything from code to binaries, and it supports the standard functionality of GitHub, allowing it to work seamlessly with your existing Git-based tools. Your team can also use CodeCommit’s online code tools to browse, edit, and collaborate on projects. AWS CodeCommit has several benefits: - **Collaboration** — AWS CodeCommit is designed for collaborative software development. You can easily commit, branch, and merge your code, which helps you easily maintain control of your team’s projects. CodeCommit also supports pull requests, which provide a mechanism to request code reviews and discuss code with collaborators. - **Encryption** — You can transfer your files to and from AWS CodeCommit using HTTPS or SSH, as you prefer. Your repositories are also automatically encrypted at rest through AWS Key Management Service (AWS KMS) using customer-specific keys. - **Access control** — AWS CodeCommit uses AWS Identity and Access Management (IAM) to control and monitor who can access your data in addition to how, when, and where they can access it. CodeCommit also helps you monitor your repositories through AWS CloudTrail and Amazon CloudWatch. - **High availability and durability** — AWS CodeCommit stores your repositories in Amazon Simple Storage Service (Amazon S3) and Amazon DynamoDB. Your encrypted data is redundantly stored across multiple facilities. This architecture increases the availability and durability of your repository data. - **Notifications and custom scripts** — You can now receive notifications for events impacting your repositories. Notifications will come as Amazon Simple Notification Service (Amazon SNS) notifications. Each notification will include a status message as well as a link to the resources whose event generated that notification. Additionally, using AWS CodeCommit repository cues, you can send notifications and create HTTP webhooks with Amazon SNS or invoke AWS Lambda functions in response to the repository events you choose. AWS CodeBuild AWS CodeBuild is a fully managed continuous integration service that compiles source code, runs tests, and produces software packages that are ready to deploy. You don’t need to provision, manage, and scale your own build servers. CodeBuild can use either of GitHub, GitHub Enterprise, BitBucket, AWS CodeCommit, or Amazon S3 as a source provider. CodeBuild scales continuously and can process multiple builds concurrently. CodeBuild offers various pre-configured environments for various versions of Microsoft Windows and Linux. Customers can also bring their customized build environments as Docker containers. CodeBuild also integrates with open source tools such as Jenkins and Spinnaker. CodeBuild can also create reports for unit, functional, or integration tests. These reports provide a visual view of how many tests cases were run and how many passed or failed. The build process can also be run inside an Amazon Virtual Private Cloud (Amazon VPC) which can be helpful if your integration services or databases are deployed inside a VPC. **AWS CodeArtifact** AWS CodeArtifact is a fully managed artifact repository service that can be used by organizations to securely store, publish, and share software packages used in their software development process. CodeArtifact can be configured to automatically fetch software packages and dependencies from public artifact repositories so developers have access to the latest versions. Software development teams increasingly rely on open-source packages to perform common tasks in their application package. It has become critical for software development teams to maintain control on a particular version of the open-source software to ensure the software is free of vulnerabilities. With CodeArtifact, you can set up controls to enforce this. CodeArtifact works with commonly used package managers and build tools such as Maven, Gradle, npm, yarn, twine, and pip, making it easy to integrate into existing development workflows. Continuous delivery Continuous delivery (CD) is a software development practice where code changes are automatically prepared for a release to production. A pillar of modern application development, continuous delivery expands upon continuous integration by deploying all code changes to a testing environment and/or a production environment after the build stage. When properly implemented, developers will always have a deployment-ready build artifact that has passed through a standardized test process. Continuous delivery lets developers automate testing beyond just unit tests so they can verify application updates across multiple dimensions before deploying to customers. These tests might include UI testing, load testing, integration testing, API reliability testing, and more. This helps developers more thoroughly validate updates and preemptively discover issues. Using the cloud, it is easy and cost-effective to automate the creation and replication of multiple environments for testing, which was previously difficult to do on-premises. AWS offers the following services for continuous delivery: - **AWS CodeBuild** (p. 3) - **AWS CodeDeploy** (p. 5) - **AWS CodePipeline** (p. 6) Topics - **AWS CodeDeploy** (p. 5) - **AWS CodePipeline** (p. 6) AWS CodeDeploy AWS CodeDeploy is a fully managed deployment service that automates software deployments to a variety of compute services such as Amazon Elastic Compute Cloud (Amazon EC2), AWS Fargate, AWS Lambda, and your on-premises servers. AWS CodeDeploy makes it easier for you to rapidly release new features, helps you avoid downtime during application deployment, and handles the complexity of updating your applications. You can use CodeDeploy to automate software deployments, reducing the need for error-prone manual operations. The service scales to match your deployment needs. CodeDeploy has several benefits that align with the DevOps principle of continuous deployment: - **Automated deployments** — CodeDeploy fully automates software deployments, allowing you to deploy reliably and rapidly. - **Centralized control** — CodeDeploy enables you to easily launch and track the status of your application deployments through the AWS Management Console or the AWS CLI. CodeDeploy gives you a detailed report enabling you to view when and to where each application revision was deployed. You can also create push notifications to receive live updates about your deployments. - **Minimize downtime** — CodeDeploy helps maximize your application availability during the software deployment process. It introduces changes incrementally and tracks application health according to configurable rules. Software deployments can easily be stopped and rolled back if there are errors. - **Easy to adopt** — CodeDeploy works with any application, and provides the same experience across different platforms and languages. You can easily reuse your existing setup code. CodeDeploy can also integrate with your existing software release process or continuous delivery toolchain (for example, AWS CodePipeline, GitHub, Jenkins). AWS CodeDeploy supports multiple deployment options. For more information, refer to the Deployment strategies (p. 7) section of this document. AWS CodePipeline *AWS CodePipeline* is a continuous delivery service that you can use to model, visualize, and automate the steps required to release your software. With AWS CodePipeline, you model the full release process for building your code, deploying to pre-production environments, testing your application, and releasing it to production. AWS CodePipeline then builds, tests, and deploys your application according to the defined workflow every time there is a code change. You can integrate partner tools and your own custom tools into any stage of the release process to form an end-to-end continuous delivery solution. AWS CodePipeline has several benefits that align with the DevOps principle of continuous deployment: - **Rapid delivery** — AWS CodePipeline automates your software release process, allowing you to rapidly release new features to your users. With CodePipeline, you can quickly iterate on feedback and get new features to your users faster. - **Improved quality** — By automating your build, test, and release processes, AWS CodePipeline enables you to increase the speed and quality of your software updates by running all new changes through a consistent set of quality checks. - **Easy to integrate** — AWS CodePipeline can easily be extended to adapt to your specific needs. You can use the pre-built plugins or your own custom plugins in any step of your release process. For example, you can pull your source code from GitHub, use your on-premises Jenkins build server, run load tests using a third-party service, or pass on deployment information to your custom operations dashboard. - **Configurable workflow** — AWS CodePipeline enables you to model the different stages of your software release process using the console interface, the AWS CLI, *AWS CloudFormation*, or the AWS SDKs. You can easily specify the tests to run and customize the steps to deploy your application and its dependencies. Deployment strategies Deployment strategies define how you want to deliver your software. Organizations follow different deployment strategies based on their business model. Some choose to deliver software that is fully tested, and others might want their users to provide feedback and let their users evaluate under development features (such as Beta releases). The following section discusses various deployment strategies. Topics - In-place deployments (p. 7) - Blue/green deployment (p. 7) - Canary deployment (p. 7) - Linear deployment (p. 8) - All-at-once deployment (p. 8) In-place deployments In this strategy, the previous version of the application on each compute resource is stopped, the latest application is installed, and the new version of the application is started and validated. This allows application deployments to proceed with minimal disturbance to underlying infrastructure. With an in-place deployment, you can deploy your application without creating new infrastructure; however, the availability of your application can be affected during these deployments. This approach also minimizes infrastructure costs and management overhead associated with creating new resources. You can use a load balancer so that each instance is deregistered during its deployment and then restored to service after the deployment is complete. In-place deployments can be all-at-once, assuming a service outage, or done as a rolling update. AWS CodeDeploy and AWS Elastic Beanstalk offer deployment configurations for one-at-a-time, half-at-a-time, and all-at-once. Blue/green deployment Blue/green deployment, sometimes referred to as red/black deployment, is a technique for releasing applications by shifting traffic between two identical environments running differing versions of the application. Blue/green deployment helps you minimize downtime during application updates, mitigating risks surrounding downtime and rollback functionality. Blue/green deployments enable you to launch a new version (green) of your application alongside the old version (blue), and monitor and test the new version before you reroute traffic to it, rolling back on issue detection. Canary deployment The purpose of a canary deployment is to reduce the risk of deploying a new version that impacts the workload. The method will incrementally deploy the new version, making it visible to new users in a slow fashion. As you gain confidence in the deployment, you will deploy it to replace the current version in its entirety. Linear deployment Linear deployment means traffic is shifted in equal increments with an equal number of minutes between each increment. You can choose from predefined linear options that specify the percentage of traffic shifted in each increment and the number of minutes between each increment. All-at-once deployment All-at-once deployment means all traffic is shifted from the original environment to the replacement environment all at once. Deployment strategies matrix The following matrix lists the supported deployment strategies for Amazon Elastic Container Service (Amazon ECS), AWS Lambda, and Amazon EC2/on-premises. - Amazon ECS is a fully managed orchestration service. - AWS Lambda lets you run code without provisioning or managing servers. - Amazon EC2 enables you to run secure, resizable compute capacity in the cloud. <table> <thead> <tr> <th>Deployment strategy</th> <th>Amazon ECS</th> <th>AWS Lambda</th> <th>Amazon EC2/on-premises</th> </tr> </thead> <tbody> <tr> <td>In-place</td> <td>✓</td> <td>✓</td> <td>✓</td> </tr> <tr> <td>Blue/green</td> <td>✓</td> <td>✓</td> <td>✓*</td> </tr> <tr> <td>Canary</td> <td>✓</td> <td>✓</td> <td>X</td> </tr> <tr> <td>Linear</td> <td>✓</td> <td>✓</td> <td>X</td> </tr> <tr> <td>All-at-once</td> <td>✓</td> <td>✓</td> <td>X</td> </tr> </tbody> </table> **Note** Blue/green deployment with EC2/on-premises works only with EC2 instances. AWS Elastic Beanstalk deployment strategies AWS Elastic Beanstalk supports the following type of deployment strategies: - **All-at-once** Performs in place deployment on all instances. - **Rolling** Splits the instances into batches and deploys to one batch at a time. - **Rolling with additional batch** Splits the deployments into batches but for the first batch creates new EC2 instances instead of deploying on the existing EC2 instances. - **Immutable** If you need to deploy with a new instance instead of using an existing instance. - **Traffic splitting** Performs immutable deployment and then forwards percentage of traffic to the new instances for a pre-determined duration of time. If the instances stay healthy, then forward all traffic to new instances and shut down old instances. **Infrastructure as code** A fundamental principle of DevOps is to treat infrastructure the same way developers treat code. Application code has a defined format and syntax. If the code is not written according to the rules of the programming language, applications cannot be created. Code is stored in a version management or source control system that logs a history of code development, changes, and bug fixes. When code is compiled or built into applications, we expect a consistent application to be created, and the build is repeatable and reliable. Practicing *infrastructure as code* means applying the same rigor of application code development to infrastructure provisioning. All configurations should be defined in a declarative way and stored in a source control system such as AWS CodeCommit, the same as application code. Infrastructure provisioning, orchestration, and deployment should also support the use of the infrastructure as code. Infrastructure was traditionally provisioned using a combination of scripts and manual processes. Sometimes these scripts were stored in version control systems or documented step by step in text files or run-books. Often the person writing the run books is not the same person executing these scripts or following through the run-books. If these scripts or runbooks are not updated frequently, they can potentially become a show-stopper in deployments. This results in the creation of new environments not always being repeatable, reliable, or consistent. In contrast, AWS provides a DevOps-focused way of creating and maintaining infrastructure. Similar to the way software developers write application code, AWS provides services that enable the creation, deployment and maintenance of infrastructure in a programmatic, descriptive, and declarative way. These services provide rigor, clarity, and reliability. The AWS services discussed in this paper are core to a DevOps methodology and form the underpinnings of numerous higher-level AWS DevOps principles and practices. AWS offers following services to define Infrastructure as a code. - **AWS CloudFormation** (p. 10) - **AWS Cloud Development Kit (AWS CDK)** (p. 12) - **AWS Cloud Development Kit for Kubernetes** (p. 12) - the section called “AWS Cloud Development Kit for Terraform” (p. 12) - the section called “AWS Cloud Control API” (p. 12) **AWS CloudFormation** AWS CloudFormation is a service that enables developers to create AWS resources in an orderly and predictable fashion. Resources are written in text files using JSON or YAML format. The templates require a specific syntax and structure that depends on the types of resources being created and managed. You author your resources in JSON or YAML with any code editor such as AWS Cloud9, check it into a version control system, and then CloudFormation builds the specified services in safe, repeatable manner. A CloudFormation template is deployed into the AWS environment as a stack. You can manage stacks through the AWS Management Console, AWS Command Line Interface, or AWS CloudFormation APIs. If you need to make changes to the running resources in a stack you update the stack. Before making changes to your resources, you can generate a change set, which is a summary of your proposed changes. Change sets enable you to see how your changes might impact your running resources, especially for critical resources, before implementing them. AWS CloudFormation creating an entire environment (stack) from one template You can use a single template to create and update an entire environment, or separate templates to manage multiple layers within an environment. This enables templates to be modularized, and also provides a layer of governance that is important to many organizations. When you create or update a stack in the CloudFormation console, events are displayed, showing the status of the configuration. If an error occurs, by default the stack is rolled back to its previous state. Amazon SNS provides notifications on events. For example, you can use Amazon SNS to track stack creation and deletion progress using email and integrate with other processes programmatically. AWS CloudFormation makes it easy to organize and deploy a collection of AWS resources, and lets you describe any dependencies or pass in special parameters when the stack is configured. With CloudFormation templates, you can work with a broad set of AWS services, such as Amazon S3, Auto Scaling, Amazon CloudFront, Amazon DynamoDB, Amazon EC2, Amazon ElastiCache, AWS Elastic Beanstalk, Elastic Load Balancing, IAM, AWS OpsWorks, and Amazon VPC. For the most recent list of supported resources, refer to [AWS resource and property types reference](#). AWS Serverless Application Model The [AWS Serverless Application Model](#) (AWS SAM) is an open-source framework that you can use to build serverless applications on AWS. AWS SAM integrates with other AWS services, so creating serverless applications with AWS SAM provides the following benefits: - **Single-deployment configuration** — AWS SAM makes it easy to organize related components and resources, and operate on a single stack. You can use AWS SAM to share configuration (such as memory and timeouts) between resources, and deploy all related resources together as a single, versioned entity. - **Extension of AWS CloudFormation** — Because AWS SAM is an extension of AWS CloudFormation, you get the reliable deployment capabilities of AWS CloudFormation. You can define resources by using AWS CloudFormation in your AWS SAM template. • **Built-in best practices** — You can use AWS SAM to define and deploy your IaC. This makes it possible for you to use and enforce best practices such as code reviews. ### AWS Cloud Development Kit (AWS CDK) The [AWS Cloud Development Kit (AWS CDK)](https://aws.amazon.com/cdk/) is an open source software development framework to model and provision your cloud application resources using familiar programming languages. AWS CDK enables you to model application infrastructure using TypeScript, Python, Java, and .NET. Developers can leverage their existing Integrated Development Environment (IDE), using tools such as autocomplete and in-line documentation to accelerate development of infrastructure. AWS CDK utilizes AWS CloudFormation in the background to provision resources in a safe, repeatable manner. Constructs are the basic building blocks of CDK code. A construct represents a cloud component and encapsulates everything AWS CloudFormation needs to create the component. The AWS CDK includes the [AWS Construct Library](https://docs.aws.amazon.com/cdk/v2/guide/constructs-libraries.html), containing constructs representing many AWS services. By combining constructs together, you can quickly and easily create complex architectures for deployment in AWS. ### AWS Cloud Development Kit for Kubernetes [AWS Cloud Development Kit for Kubernetes](https://docs.aws.amazon.com/cdk/latest/dev/k8s.html) is an open-source software development framework for defining Kubernetes applications using general-purpose programming languages. Once you have defined your application in a programming language (as of the date of this publication, only Python and TypeScript are supported), cdk8s will convert your application description in to pre-Kubernetes YAML. This YAML file can then be consumed by any Kubernetes cluster running anywhere. Because the structure is defined in a programming language, you can use the rich features provided by the programming language. You can use the abstraction feature of the programming language to create your own boilerplate code, and reuse it across all of the deployments. ### AWS Cloud Development Kit for Terraform Built on top of the open source [JSII library](https://jsii.org), [CDK for Terraform](https://aws.amazon.com/cdk wl/terraform) (CDKTF) allows you to write Terraform configurations in your choice of C#, Python, TypeScript, Java, or Go and still benefit from the full ecosystem of Terraform providers and modules. You can import any existing provider or module from the Terraform Registry into your application, and CDKTF will generate resource classes for you to interact with in your target programming language. With CDKTF, developers can set up their IaC without context switching from their familiar programming language, using the same tooling and syntax to provision infrastructure resources similar to the application business logic. Teams can collaborate in familiar syntax, while still using the power of the Terraform ecosystem and deploying their infrastructure configurations via established Terraform deployment pipelines. ### AWS Cloud Control API [AWS Cloud Control API](https://aws.amazon.com/cloud-control-api/) is a new AWS capability that introduces a common set of Create, Read, Update, Delete, and List (CRUDL) APIs to help developers manage their cloud infrastructure in an easy and consistent way. The Cloud Control API common APIs allow developers to uniformly manage the lifecycle of AWS and third-party services. As a developer, you might prefer to simplify the way you manage the lifecycle of all your resources. You can use Cloud Control API's uniform resource configuration model with a pre-defined format to standardize your cloud resource configuration. In addition, you will benefit from uniform API behavior (response elements and errors) while managing your resources. For example, you will find it simple to debug errors during CRUDL operations through uniform error codes surfaced by Cloud Control API that are independent of the resources you operate on. Using Cloud Control API, you will also find it simple to configure cross-resource dependencies. You will also no longer require to author and maintain custom code across multiple vendor tools and APIs to use AWS and third-party resources together. Another core philosophy and practice of DevOps is automation. Automation focuses on the setup, configuration, deployment, and support of infrastructure and the applications that run on it. By using automation, you can set up environments more rapidly in a standardized and repeatable manner. The removal of manual processes is key to a successful DevOps strategy. Historically, server configuration and application deployment have been predominantly a manual process. Environments become non-standard, and reproducing an environment when issues arise is difficult. The use of automation is critical to realizing the full benefits of the cloud. Internally, AWS relies heavily on automation to provide the core features of elasticity and scalability. Manual processes are error prone, unreliable, and inadequate to support an agile business. Frequently, an organization may tie up highly skilled resources to provide manual configuration, when time could be better spent supporting other, more critical, and higher value activities within the business. Modern operating environments commonly rely on full automation to eliminate manual intervention or access to production environments. This includes all software releasing, machine configuration, operating system patching, troubleshooting, or bug fixing. Many levels of automation practices can be used together to provide a higher level end-to-end automated process. Automation has the following key benefits: - Rapid changes - Improved productivity - Repeatable configurations - Reproducible environments - Elasticity - Automatic scaling - Automated testing Automation is a cornerstone with AWS services and is internally supported in all services, features, and offerings. **Topics** - AWS OpsWorks (p. 14) - AWS Elastic Beanstalk (p. 15) - EC2 Image Builder (p. 16) - AWS Proton (p. 16) - AWS Service Catalog (p. 16) - AWS Cloud9 (p. 16) - AWS CloudShell (p. 16) - Amazon CodeGuru (p. 17) **AWS OpsWorks** AWS OpsWorks takes the principles of DevOps even further than AWS Elastic Beanstalk. It can be considered an application management service rather than simply an application container. AWS OpsWorks provides even more levels of automation, with additional features such as integration with configuration management software (Chef) and application lifecycle management. You can use application lifecycle management to define when resources are set up, configured, deployed, undeployed, or ended. For added flexibility AWS OpsWorks has you define your application in configurable stacks. You can also select predefined application stacks. Application stacks contain all the provisioning for AWS resources that your application requires, including application servers, web servers, databases, and load balancers. Application stacks are organized into architectural layers so that stacks can be maintained independently. Example layers could include web tier, application tier, and database tier. Out of the box, AWS OpsWorks also simplifies setting up AWS Auto Scaling groups and Elastic Load Balancing (ELB) load balancers, further illustrating the DevOps principle of automation. Just like AWS Elastic Beanstalk, AWS OpsWorks supports application versioning, continuous deployment, and infrastructure configuration management. **AWS OpsWorks showing DevOps features and architecture** AWS OpsWorks also supports the DevOps practices of monitoring and logging (covered in the next section). Monitoring support is provided by Amazon CloudWatch. All lifecycle events are logged, and a separate Chef log documents any Chef recipes that are run, along with any exceptions. **AWS Elastic Beanstalk** AWS Elastic Beanstalk is a service to rapidly deploy and scale web applications developed with Java, .NET, PHP, Node.js, Python, Ruby, Go, and Docker on familiar servers such as Apache, NGINX, Passenger, and IIS. Elastic Beanstalk is an abstraction on top of Amazon EC2, Auto Scaling, and simplifies the deployment by giving additional features such as cloning, blue/green deployments, Elastic Beanstalk Command Line Interface (EB CLI) and integration with AWS Toolkit for Visual Studio, Visual Studio Code, Eclipse, and IntelliJ for increase developer productivity. EC2 Image Builder EC2 Image Builder is a fully managed AWS service that helps you to automate the creation, maintenance, validation, sharing, and deployment of customized, secure, and up-to-date Linux or Windows custom AMI. EC2 Image Builder can also be used to create container images. You can use the AWS Management Console, the AWS CLI, or APIs to create custom images in your AWS account. EC2 Image Builder significantly reduces the effort of keeping images up-to-date and secure by providing a simple graphical interface, built-in automation, and AWS-provided security settings. With EC2 Image Builder, there are no manual steps for updating an image nor do you have to build your own automation pipeline. AWS Proton AWS Proton enables platform teams to connect and coordinate all the different tools your development teams need for infrastructure provisioning, code deployments, monitoring, and updates. AWS Proton enables automated infrastructure as code provisioning and deployment of serverless and container-based applications. AWS Proton enables platform teams to define their infrastructure and deployment tools, while providing developers with a self-service experience to get infrastructure and deploy code. Through AWS Proton, platform teams provision shared resources and define application stacks, including CI/CD pipelines and observability tools. You can then manage which infrastructure and deployment features are available for developers. AWS Service Catalog AWS Service Catalog enables organizations to create and manage catalogs of IT services that are approved for AWS. These IT services can include everything from virtual machine images, servers, software, databases, and more to complete multi-tier application architectures. AWS Service Catalog lets you centrally manage deployed IT services, applications, resources, and metadata to achieve consistent governance of your IaC templates. With AWS Service Catalog, you can meet your compliance requirements while making sure your customers can quickly deploy the approved IT services they need. End users can quickly deploy only the approved IT services they need, following the constraints set by your organization. AWS Cloud9 AWS Cloud9 is a cloud-based IDE that lets you write, run, and debug your code with just a browser. It includes a code editor, debugger, and terminal. AWS Cloud9 comes prepackaged with essential tools for popular programming languages, including JavaScript, Python, PHP, and more, so you don’t need to install files or configure your development machine to start new projects. Because your AWS Cloud9 IDE is cloud-based, you can work on your projects from your office, home, or anywhere using an internet-connected machine. AWS CloudShell AWS CloudShell is a browser-based shell that makes it easier to securely manage, explore, and interact with your AWS resources. AWS CloudShell is pre-authenticated with your console credentials. Common development and operations tools are pre-installed, so there’s no need to install or configure software on your local machine. **Amazon CodeGuru** Amazon CodeGuru is a developer tool that provides intelligent recommendations to improve code quality and identify an application’s most expensive lines of code. Integrate CodeGuru into your existing software development workflow to automate code reviews during application development and continuously monitor application’s performance in production and provide recommendations and visual clues on how to improve code quality, application performance, and reduce overall cost. CodeGuru has two components: - **Amazon CodeGuru Reviewer** — Amazon CodeGuru Reviewer is an automated code review service that identifies critical defects and deviation from coding best practices for Java and Python code. It scans the lines of code within a pull request and provides intelligent recommendations based on standards learned from major open-source projects as well as Amazon codebase. - **Amazon CodeGuru Profiler** — Amazon CodeGuru Profiler analyzes the application runtime profile and provides intelligent recommendations and visualizations that guide developers on how to improve the performance of the most relevant parts of their code. Monitoring and observability Communication and collaboration are fundamental in a DevOps philosophy. To facilitate this, feedback is critical. This feedback is provided by our suite of monitoring and observability services. AWS provides the following services for monitoring and logging: Topics - Amazon CloudWatch metrics - Amazon CloudWatch Alarms - Amazon CloudWatch Logs - Amazon CloudWatch Logs Insights - Amazon CloudWatch Events - Amazon EventBridge - AWS CloudTrail - Amazon DevOps Guru - AWS X-Ray - Amazon Managed Service for Prometheus - Amazon Managed Grafana Amazon CloudWatch metrics Amazon CloudWatch metrics automatically collect data from AWS services such as Amazon EC2 instances, Amazon EBS volumes, and Amazon RDS database (DB) instances. These metrics can then be organized as dashboards and alarms or events can be created to trigger events or perform Auto Scaling actions. Amazon CloudWatch Alarms You can set up alarms using Amazon CloudWatch alarms based on the metrics collected by Amazon CloudWatch metrics. The alarm can then send a notification to Amazon SNS topic, or initiate Auto Scaling actions. An alarm requires period (length of the time to evaluate a metric), evaluation period (number of the most recent data points), and datapoints to alarm (number of data points within the evaluation period). Amazon CloudWatch Logs Amazon CloudWatch Logs is a log aggregation and monitoring service. AWS CodeBuild, CodeCommit, CodeDeploy and CodePipeline provide integrations with CloudWatch logs so that all of the logs can be centrally monitored. In addition, the previously mentioned services various other AWS services provide direct integration with CloudWatch. With CloudWatch Logs you can: - Query your log data - Monitor logs from Amazon EC2 instances • Monitor AWS CloudTrail logged events • Define log retention policy Amazon CloudWatch Logs Insights Amazon CloudWatch Logs Insights scans your logs and enables you to perform interactive queries and visualizations. It understands various log formats and auto-discovers fields from JSON logs. Amazon CloudWatch Events Amazon CloudWatch Events delivers a near real-time stream of system events that describe changes in AWS resources. Using simple rules that you can quickly set up, you can match events and route them to one or more target functions or streams. CloudWatch Events becomes aware of operational changes as they occur. CloudWatch Events responds to these operational changes and takes corrective action as necessary, by sending messages to respond to the environment, activating functions, making changes, and capturing state information. You can configure rules in Amazon CloudWatch Events to alert you to changes in AWS services and integrate these events with other third-party systems using Amazon EventBridge. The following are the AWS DevOps related services that have integration with CloudWatch Events. • Application Auto Scaling Events • CodeBuild Events • CodeCommit Events • CodeDeploy Events • CodePipeline Events Amazon EventBridge Note Amazon CloudWatch Events and EventBridge are the same underlying service and API, however, EventBridge provides more features. Amazon EventBridge is a serverless event bus that enables integrations between AWS services, Software as a services (SaaS), and your applications. In addition to build event driven applications, EventBridge can be used to notify about the events from the services such as CodeBuild, CodeDeploy, CodePipeline, and CodeCommit. AWS CloudTrail To embrace the DevOps principles of collaboration, communication, and transparency, it's important to understand who is making modifications to your infrastructure. In AWS, this transparency is provided by AWS CloudTrail. All AWS interactions are handled through AWS API calls that are monitored and logged by AWS CloudTrail. All generated log files are stored in an Amazon S3 bucket that you define. Log files are encrypted using Amazon S3 server-side encryption (SSE). All API calls are logged whether they come directly from a user or on behalf of a user by an AWS service. Numerous groups can benefit from CloudTrail logs, including operations teams for support, security teams for governance, and finance teams for billing. Amazon DevOps Guru Amazon DevOps Guru is a service powered by machine learning (ML) that is designed to make it easy to improve an application’s operational performance and availability. DevOps Guru helps detect behaviors that deviate from normal operating patterns, so you can identify operational issues long before they impact your customers. DevOps Guru uses ML models informed by years of Amazon.com and AWS operational excellence to help identify anomalous application behavior (for example, increased latency, error rates, resource constraints, and others) and surface critical issues that could cause potential outages or service disruptions. When DevOps Guru identifies a critical issue, it saves debugging time by fetching relevant and specific information from a large number of data sources and automatically sends an alert and provides a summary of related anomalies, and context for when and where the issue occurred. AWS X-Ray AWS X-Ray helps developers analyze and debug production, distributed applications, such as those built using a microservices architecture. With X-Ray, you can understand how your application and its underlying services are performing to identify and troubleshoot the root cause of performance issues and errors. X-Ray provides an end-to-end view of requests as they travel through your application, and shows a map of your application’s underlying components. X-Ray makes it easy for you to: - **Create a service map** – By tracking requests made to your applications, X-Ray can create a map of services used by your application. This provides you with a view of connections among services in your application, and enables you to create a dependency tree, detect latency or errors when working across AWS Availability Zones or Regions, zero in on services not operating as expected, and so on. - **Identify errors and bugs** – X-Ray can automatically highlight bugs or errors in your application code by analyzing the response code for each request made to your application. This enables easy debugging of application code without requiring you to reproduce the bug or error. - **Build your own analysis and visualization apps** – X-Ray provides a set of query APIs you can use to build your own analysis and visualizations apps that use the data that X-Ray records. Amazon Managed Service for Prometheus Amazon Managed Service for Prometheus is a serverless monitoring service for metrics compatible with open-source Prometheus, making it easier for you to securely monitor and alert on container environments. Amazon Managed Service for Prometheus reduces the heavy lifting required to get started with monitoring applications across Amazon Elastic Kubernetes Service, Amazon Elastic Container Service, and AWS Fargate, as well as self-managed Kubernetes clusters. Amazon Managed Grafana Amazon Managed Grafana is a fully managed service with rich, interactive data visualizations to help customers analyze, monitor, and alarm on metrics, logs, and traces across multiple data sources. You can create interactive dashboards and share them with anyone in your organization with an automatically scaled, highly available, and enterprise-secure service. Communication and Collaboration Whether you are adopting DevOps Culture in your organization or going through a DevOps cultural transformation, communication and collaboration are an important part of your approach. At Amazon, we have realized that there was a need to bring a change to the mindset of our teams and thus adopted the concept of *Two-Pizza Teams*. **Topics** - Two-Pizza Teams (p. 21) - AWS CodeStar (p. 21) Two-Pizza Teams "We try to create teams that are no larger than can be fed by two pizzas," said Bezos. "We call that the two-pizza team rule." The smaller the team, the better the collaboration. Collaboration is very important, as software releases are moving faster than ever. And a team's ability to deliver the software can be a differentiating factor for your organization against your competition. Imagine a situation in which a new product feature needs to be released or a bug needs to be fixed. You want this to happen as quickly as possible, so you can have a smaller go-to-market timed. You don't want the transformation to be a slow-moving process; you want an agile approach where waves of changes start to make an impact. Communication between teams is also important as you move toward the shared responsibility model and start moving out of the siloed development approach. This brings the concept of ownership to the team, and shifts their perspective to look at the process as an end-to-end venture. Your team should not think about your production environments as black boxes where they have no visibility. Cultural transformation is also important, because you might be building a common DevOps team or have a DevOps focused member in your team. Both of these approaches introduce Shared Responsibility in to the team. AWS CodeStar /aws/code_star/ provides the tools you need to quickly develop, build, and deploy applications on AWS. With AWS CodeStar, you can use a variety of project templates to start developing applications on Amazon EC2, AWS Lambda, and AWS Elastic Beanstalk. AWS CodeStar allows you to accelerate application delivery by providing a pre-configured continuous delivery toolchain for developing, building, testing, and deploying your projects on AWS. The project dashboard in AWS CodeStar makes it easy to centrally monitor application activity and manage day-to-day development tasks such as recent code commits, builds, and deployments. Because AWS CodeStar integrates with Atlassian JIRA, a third-party issue tracking and project management tool, you can create and manage JIRA issues in the AWS CodeStar dashboard. Security Whether you are going through a DevOps transformation or implementing DevOps principles for the first time, you should think about Security as integrated in your DevOps processes. This should be cross cutting concern across your build, test deployment stages. Before exploring security in DevOps on AWS, this paper looks at the AWS Shared Responsibility Model. Topics - AWS Shared Responsibility Model (p. 22) - Identity and Access Management (p. 23) AWS Shared Responsibility Model Security is a shared responsibility between AWS and the customer. The different parts of the Shared Responsibility Model are: - **AWS responsibility “Security of the Cloud”** - AWS is responsible for protecting the infrastructure that runs all of the services offered in the AWS Cloud. This infrastructure is composed of the hardware, software, networking, and facilities that run AWS Cloud services. - **Customer responsibility “Security in the Cloud”** – Customer responsibility is determined by the AWS Cloud services that a customer selects. This determines the amount of configuration work the customer must perform as part of their security responsibilities. This shared model can help relieve the customer’s operational burden as AWS operates, manages, and controls the components from the host operating system and virtualization layer down to the physical security of the facilities in which the service operates. This is critical in the cases where customer want to understand the security of their build environments. Permissions are maintained in IAM. You can use IAM to control who is authenticated (signed in) and authorized (has permissions) to use resources. Identity and Access Management AWS Identity and Access Management (IAM) defines the controls and policies that are used to manage access to AWS resources. Using IAM you can create users and groups and define permissions to various DevOps services. In addition to the users, various services may also need access to AWS resources. For example, your CodeBuild project might need access to store Docker images in Amazon Elastic Container Registry (Amazon ECR) and need permissions to write to Amazon ECR. These types of permissions are defined by a special type role know as service role. IAM is one component of the AWS security infrastructure. With IAM, you can centrally manage groups, users, service roles and security credentials such as passwords, access keys, and permissions policies that control which AWS services and resources users can access. IAM Policy lets you define the set of permissions. This policy can then be attached to either a role, user, or a service to define their permission. You can also use IAM to create roles that are used widely within your desired DevOps strategy. In some cases, it can make perfect sense to programmatically AssumeRole instead of directly getting the permissions. When a service or user assumes roles, they are given temporary credentials to access a service that they normally don’t have access to. Conclusion To make the journey to the cloud smooth, efficient, and effective, technology companies should embrace DevOps principles and practices. These principles are embedded in AWS, and form the cornerstone of numerous AWS services, especially those in the deployment and monitoring offerings. Begin by defining your infrastructure as code using the service AWS CloudFormation or AWS CDK. Next, define the way in which your applications are going to use continuous deployment with the help of services like AWS CodeBuild, AWS CodeDeploy, AWS CodePipeline, and AWS CodeCommit. At the application level, use containers such as AWS Elastic Beanstalk, Amazon ECS, or Amazon Elastic Kubernetes Service (Amazon EKS). Use AWS OpsWorks to simplify the configuration of common architectures. Using these services also makes it easy to include other important services such as Auto Scaling and Elastic Load Balancing. Finally, use the DevOps strategy of monitoring such as Amazon CloudWatch, and solid security practices such as IAM. With AWS as your partner, your DevOps principles bring agility to your business and IT organization and accelerate your journey to the cloud. # Document Revisions To be notified about updates to this whitepaper, subscribe to the RSS feed. <table> <thead> <tr> <th>Change</th> <th>Description</th> <th>Date</th> </tr> </thead> <tbody> <tr> <td>Updated (p. 25)</td> <td>Updated</td> <td>April 7, 2023</td> </tr> <tr> <td>Updated sections to include new services (p. 25)</td> <td>Updated sections to include new services</td> <td>October 16, 2020</td> </tr> <tr> <td>Initial publication (p. 25)</td> <td>Whitepaper first published</td> <td>December 1, 2014</td> </tr> </tbody> </table> Contributors Contributors to this document include: - Abhra Sinha, Solutions Architect - Anil Nadiminti, Solutions Architect - Muhammad Mansoor, Solutions Architect - Ajit Zadgaonkar, World Wide Tech Leader, Modernization - Juan Lamadrid, Solutions Architect - Darren Ball, Solutions Architect - Rajeswari Malladi, Solutions Architect - Pallavi Nargund, Solutions Architect - Bert Zahniser, Solutions Architect - Abdullahi Olaoye, Cloud Solutions Architect - Mohamed Kiswani, Software Development Manager - Tara McCann, Manager, Solutions Architect Notices Customers are responsible for making their own independent assessment of the information in this document. This document: (a) is for informational purposes only, (b) represents current AWS product offerings and practices, which are subject to change without notice, and (c) does not create any commitments or assurances from AWS and its affiliates, suppliers or licensors. AWS products or services are provided “as is” without warranties, representations, or conditions of any kind, whether express or implied. The responsibilities and liabilities of AWS to its customers are controlled by AWS agreements, and this document is not part of, nor does it modify, any agreement between AWS and its customers. © 2023 Amazon Web Services, Inc. or its affiliates. All rights reserved.
{"Source-Url": "https://docs.aws.amazon.com/pdfs/whitepapers/latest/introduction-devops-aws/introduction-devops-aws.pdf", "len_cl100k_base": 10818, "olmocr-version": "0.1.53", "pdf-total-pages": 31, "total-fallback-pages": 0, "total-input-tokens": 64303, "total-output-tokens": 11996, "length": "2e13", "weborganizer": {"__label__adult": 0.00030875205993652344, "__label__art_design": 0.00027871131896972656, "__label__crime_law": 0.0001854896545410156, "__label__education_jobs": 0.0005159378051757812, "__label__entertainment": 5.429983139038086e-05, "__label__fashion_beauty": 0.00011223554611206056, "__label__finance_business": 0.0006937980651855469, "__label__food_dining": 0.00022590160369873047, "__label__games": 0.0003376007080078125, "__label__hardware": 0.0006804466247558594, "__label__health": 0.00023257732391357425, "__label__history": 0.00014674663543701172, "__label__home_hobbies": 7.331371307373047e-05, "__label__industrial": 0.00021076202392578125, "__label__literature": 0.00019752979278564453, "__label__politics": 0.00018167495727539065, "__label__religion": 0.0002491474151611328, "__label__science_tech": 0.002849578857421875, "__label__social_life": 7.772445678710938e-05, "__label__software": 0.00824737548828125, "__label__software_dev": 0.9833984375, "__label__sports_fitness": 0.0001990795135498047, "__label__transportation": 0.0002841949462890625, "__label__travel": 0.00017559528350830078}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60355, 0.00842]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60355, 0.03333]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60355, 0.87244]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 0, null], [0, 7309, false], [7309, 7309, null], [7309, 10552, null], [10552, 10859, null], [10859, 13904, null], [13904, 15694, null], [15694, 18793, null], [18793, 20879, null], [20879, 23407, null], [23407, 23857, null], [23857, 25660, null], [25660, 29094, null], [29094, 31242, null], [31242, 34752, null], [34752, 35554, null], [35554, 37713, null], [37713, 39790, null], [39790, 42747, null], [42747, 44033, null], [44033, 45830, null], [45830, 48300, null], [48300, 51505, null], [51505, 54099, null], [54099, 55628, null], [55628, 57129, null], [57129, 58302, null], [58302, 59017, null], [59017, 59568, null], [59568, 60355, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 0, null], [0, 7309, true], [7309, 7309, null], [7309, 10552, null], [10552, 10859, null], [10859, 13904, null], [13904, 15694, null], [15694, 18793, null], [18793, 20879, null], [20879, 23407, null], [23407, 23857, null], [23857, 25660, null], [25660, 29094, null], [29094, 31242, null], [31242, 34752, null], [34752, 35554, null], [35554, 37713, null], [37713, 39790, null], [39790, 42747, null], [42747, 44033, null], [44033, 45830, null], [45830, 48300, null], [48300, 51505, null], [51505, 54099, null], [54099, 55628, null], [55628, 57129, null], [57129, 58302, null], [58302, 59017, null], [59017, 59568, null], [59568, 60355, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60355, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60355, null]], "pdf_page_numbers": [[0, 0, 1], [0, 0, 2], [0, 7309, 3], [7309, 7309, 4], [7309, 10552, 5], [10552, 10859, 6], [10859, 13904, 7], [13904, 15694, 8], [15694, 18793, 9], [18793, 20879, 10], [20879, 23407, 11], [23407, 23857, 12], [23857, 25660, 13], [25660, 29094, 14], [29094, 31242, 15], [31242, 34752, 16], [34752, 35554, 17], [35554, 37713, 18], [37713, 39790, 19], [39790, 42747, 20], [42747, 44033, 21], [44033, 45830, 22], [45830, 48300, 23], [48300, 51505, 24], [51505, 54099, 25], [54099, 55628, 26], [55628, 57129, 27], [57129, 58302, 28], [58302, 59017, 29], [59017, 59568, 30], [59568, 60355, 31]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60355, 0.03297]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
ba1508359fd761b347a9be4e9af280e0e3b9fb62
Survey of Distributed Decision Laurent Feuilloley, Pierre Fraigniaud To cite this version: | Laurent Feuilloley, Pierre Fraigniaud. Survey of Distributed Decision. 2016. hal-01331880 HAL Id: hal-01331880 https://hal.archives-ouvertes.fr/hal-01331880 Submitted on 14 Jun 2016 HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers. L’archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d’enseignement et de recherche français ou étrangers, des laboratoires publics ou privés. Survey of Distributed Decision* Laurent Feuilloley and Pierre Fraigniaud Institut de Recherche en Informatique Fondamentale CNRS and University Paris Diderot Abstract We survey the recent distributed computing literature on checking whether a given distributed system configuration satisfies a given boolean predicate, i.e., whether the configuration is legal or illegal w.r.t. that predicate. We consider classical distributed computing environments, including mostly synchronous fault-free network computing (LOCAL and CONGEST models), but also asynchronous crash-prone shared-memory computing (WAIT-FREE model), and mobile computing (FSYNC model). *Both authors received additional support from Inria project-team GANG. # Contents 1 Introduction 3 2 Model and Definitions 4 2.1 Distributed Languages 5 2.2 Distributed Decision 5 2.3 Probabilistic Distributed Decision 6 2.4 Distributed Verification 7 2.5 Distributed Decision Hierarchy 8 3 Distributed Decision in Networks 9 3.1 LOCAL model 9 3.1.1 Local Distributed Decision (LD and BPLD) 9 3.1.2 Identity-Oblivious Algorithms (LDO) 10 3.1.3 Anonymous Networks 11 3.2 CONGEST model 11 3.2.1 Non-Local Algorithms 11 3.2.2 Local Algorithms 11 3.3 General Interpretation of Individual Outputs 12 4 Distributed Verification in Networks 12 4.1 LOCAL model 12 4.1.1 Local Distributed Verification (Σ₁^{LD}, PLS, and LCP) 13 4.1.2 Identity-Oblivious Algorithms (Σ₁^{LDO} and NLD) 14 4.1.3 Anonymous Networks 14 4.2 CONGEST model (log-Σ₁^{LD} and log-LCP) 14 4.3 General Interpretation of Individual Outputs 14 5 Local Hierarchies in Networks 15 5.1 LOCAL model (DH^{LD} and DH^{LDO}) 15 5.2 CONGEST model (log-DH^{LD}) 15 5.3 Distributed Graph Automata (DH^{DGA}) 16 6 Other Computational Models 16 6.1 Wait-Free Computing 16 6.2 Mobile Computing 16 6.3 Quantum Computing 16 7 Conclusion 17 1 Introduction The objective of this note is to survey the recent achievements in the framework of distributed decision: the computing entities of a distributed system aim at checking whether the system is in a legal state with respect to some boolean predicate. For instance, in a network, the computing entities may be aiming at checking whether the network satisfies some given graph properties. Recall that, in a construction task, processes have to collectively compute a valid global state of a distributed system, as a collection of individual states, like, e.g., providing each node of a network with a color so that to form a proper coloring of that network. Instead, in a decision task, processes have to collectively check whether a given global state of a distributed system is valid or not, like, e.g., checking whether a given coloring of the nodes of a network is proper [25]. In general, a typical application of distributed decision is checking the validity of outputs produced by the processes w.r.t. a construction task that they were supposed to solved. This applies to various settings, including randomized algorithms as well as algorithms subject to any kind of faults susceptible to corrupt the memory of the processes. The global verdict on the legality of the system state is obtained as an aggregate of individual opinions produced by all processes. Typically, each process opinion is a single bit (i.e., accept or reject) expressing whether the system state looks legal or illegal from the perspective of the process, and the global verdict is the logical conjunction of these bits. Note that this mechanisms reflects both decision procedures in which the individual opinions of the processes are collected by some centralized entity, and decision procedures where any process detecting some inconsistency in the system raises an alarm and/or launches a recovery procedure, in absence of any central entity. We will also briefly consider less common procedures where each process can send some limited information about its environment in the system, and a central authority gathers the information provided by the processes to forge its verdict about the legality of the whole system state. The difficulty of distributed decision arises when the processes cannot obtain a global perspective of the system, which is typically the case if one insists on some form of locality in networks, or if the processes are asynchronous and subject to failures. In such frameworks, not all boolean predicates on distributed systems can be checked in a distributed manner, and one of the main issue of distributed decision is to characterize the predicates that can be distributively checked, and at which cost. For predicates that cannot be checked, or for which checking is too costly, the system can be enhanced by providing processes with certificates, with the objective to help these processes for expressing their individual opinions. Such certificates could be produced by an external entity, but they might also well be produced by the processes themselves during a pre-computation phase. One typical framework in which the latter scenario finds application is self-stabilization. Indeed, a self-stabilizing algorithm may produce, together with its distributed output, a distributed certificate that this output is correct. Of course, the certificates are also corruptible, and thus not trustable. Hence, the checking procedure must involve a distributed verification algorithm in charge of verifying the collection of pairs (output, certificate) produced by all the processes. Some even more elaborated mechanisms for checking the legality of distributed system states are considered in the literature, and we survey such mechanisms as well. We consider the most classical distributed computing models, including synchronous distributed network computing [49]. In this setting, processes are nodes of a graph representing a network. They all execute the same algorithm, they are fault-free, and they are provided with distinct identities in some ID-space (which can be bounded or not). All processes start simultaneously, and computation proceeds in synchronous rounds. At each round, every process exchanges messages with its neighboring processes in the network, and performs individual com- The volume of communication each node can transmit and receive on each of its links at each round might be bounded or not. The **CONGEST** model typically assumes that at most $O(\log n)$ bits can be transferred along each link at each round in $n$-node networks. (In this case, the ID-space is supposed to be polynomially bounded as a function of the network size). Instead the **LOCAL** model does not limit the amount of information that can be transmitted along each link at each round. So, a $t$-round algorithm $\mathcal{A}$ in the **LOCAL** model can be transformed into another algorithm $\mathcal{B}$ in which every node first collects all data available in the ball of radius $t$ around it, and, second, simulate $\mathcal{A}$ locally without communication. We also consider other models like asynchronous distributed shared-memory computing [5]. In this setting, every process has access to a global memory shared by all processes. Every process accesses this memory via atomic read and write instructions. The memory is composed of registers, and each process is allocated a set of private registers. Every process can read all the registers, but can only write in its own registers. Processes are given distinct identities in $[n] = \{1, \ldots, n\}$ for $n$-process systems. They runs asynchronously, and are subject to crashes. A process that crashes stops taking steps. An arbitrary large number of processes can crash. Hence, an algorithm must never include instructions leading a process to wait for actions by another process, as the latter process can crash. This model is thus often referred to as the **WAIT-FREE** model. Finally, we briefly consider other models, including mobile computing [22], mostly in the fully-synchronous **FSYNC** model in graphs (where all mobile agents perform in lock-step, moving from nodes to adjacent nodes in a network), and distributed quantum computing (where processes have access to intricate variables). ### 2 Model and Definitions Given a boolean predicate, a distributed decision algorithm is a distributed algorithm in which every process $p$ must eventually output a value $$\text{opinion}(p) \in \{\text{accept, reject}\}$$ such that the global system state satisfies the given predicate if and only if all processes accept. In other word, the global interpretation of the individual opinions produced by the processes is the logical conjunction of all these opinions: $$\text{global verdict} = \bigwedge_{p} \text{opinion}(p).$$ Among the earliest references explicitly related to distributed decision, it is worth mentioning [1, 6, 42]. In this section, we describe the general framework of distributed decision, without explicit references to some specific underlying computational model. The structure of the section is inspired from the structure of complexity classes in sequential complexity theory. Given the “base” class $\mathcal{P}$ of languages that are sequentially decidable by a Turing machine in time polynomial in the size of the input, the classes $\mathcal{NP}$ (for non-deterministic polynomial time) and $\mathcal{BPP}$ (for bounded probability polynomial time) are defined, as well as the classes $\Sigma_k^\mathcal{P}$ and $\Pi_k^\mathcal{P}$, $k \geq 0$, of the polynomial hierarchy. In this section we assume given an abstract class $\mathcal{BC}$ (for bounded distributed computing), based on which larger classes can be defined. Such a base class $\mathcal{BC}$ could be a complexity class like, e.g., the class of graph properties that can be checked in constant time in the **LOCAL** model, or a computability class like, e.g., the class of system properties that can be checked in a shared-memory distributed system subject to crash failures. Given the “base” class $\mathcal{BC}$, we shall define the classes $\mathcal{NBC}$, $\mathcal{BPBC}$, $\Sigma_k^{\mathcal{BC}}$ and $\Pi_k^{\mathcal{BC}}$, that are to $\mathcal{BC}$ what $\mathcal{NP}$, $\mathcal{BPP}$, $\Sigma_k^\mathcal{P}$ and $\Pi_k^\mathcal{P}$ are to $\mathcal{P}$, respectively. 2.1 Distributed Languages A system configuration $C$ is a (partial) description of a distributed system state. For instance, in distributed network computing, a configuration $C$ is of the form $(G, \ell)$ where $G$ is a graph, and $\ell : V(G) \rightarrow \{0, 1\}^*$. Similarly, in shared memory computing, a configuration $C$ is of the form $\ell : [n] \rightarrow \{0, 1\}^*$ where $n$ is the number of processes. The function $\ell$ is called labeling function, and $\ell(v)$ the label of $v$, which can be any arbitrary bit string. In the context of distributed decision, the label of a process is the input of that process. For instance, the label of a node in a processor network can be a color, and the label of a process in a shared memory system can be a status like “elected” or “defeated”. Note that, in both examples, a configuration is oblivious to the content of the shared memory and/or to the message in transit. The labeling function $\ell$ may not describe the full state of each process, but only the content of some specific variables. **Definition 1** Given a distributed computing model, a distributed language is a Turing-computable set of configurations compatible with this model. For instance, in the framework of network computing, $$\text{PROPER-COLORING} = \{(G, \ell) : \forall\{u, v\} \in E(G), \ell(u) \neq \ell(v)\}$$ is the distributed language composed of all networks with a proper coloring of their nodes (the label $\ell(v)$ of node $v$ is its color). Similarly, in the framework of crash-prone shared-memory computing, $$\text{AGREEMENT} = \{\ell : \exists y \in \{0, 1\}^*, \forall i \in [n], \ell(i) = y \text{ or } \ell(i) = \bot\}$$ is the distributed language composed of all systems where agreement between the non-crashed processes is achieved (the label of process $p_i$ is $\ell(i)$, and the symbol $\bot$ refers to the scenario in which process $p_i$ crashed). For a fixed distributed language $L$, a configuration in $L$ is said to be legal, and a configuration not in $L$ is said to be illegal. Any distributed language $L$ defines a construction task, in which every process must compute a label such that the collection of labels outputted by the processes form a legal configuration for $L$. In the following, we are mostly interested in decision tasks, where the labels of the nodes are given, and the processes must collectively check whether these labels form a legal configuration. **Notation.** Given a system configuration $C$ with respect to some distributed computing model, we denote by $V(C)$ the set of all computing entities (a.k.a. processes) in $C$. This notation reflects the fact that, in the following, the set of processes will most often be identified as the vertex-set $V(G)$ of a graph $G$. 2.2 Distributed Decision Given a distributed computing model, let us define some bounded computing class $BC$ as a class of distributed languages that can be decided with a distributed algorithm $A$ using a bounded amount of resources. Such an algorithm $A$ is said to be bounded. What is meant by “resource” depends on the computing model. In most of the models investigated in this paper, the resource of interest is the number of rounds (as in the LOCAL and CONGEST models), or the number of read/write operations (as in the WAIT-FREE model). A distributed language $L$ is in $BC$ if and only if there exists a bounded algorithm $A$ such that, for any input configuration $C$, the algorithm $A$ outputs $A(C, v)$ at each process $v$, and this output satisfies: $$C \in L \iff \text{ for every } v \in V(C), A(C, v) = \text{accept.}$$ (1) That is, for every $C \in L$, running $A$ on $C$ results in all processes accepting $C$. Instead, for every $C \notin L$, running $A$ on $C$ results in at least one process rejecting $C$. **Example.** In the context of network computing, PROPER-COLORING can be decided in one round, by having each node merely comparing its color with the ones of its neighbors, and accepting if and only if its color is different from all these colors. Similarly, in the context of shared-memory computing, AGREEMENT can be decided by having each node performing just one read/write operation, accepting if and only if all labels different from ⊥ observed in memory are identical. In other words, assuming that $BC$ is a network computing class bounding algorithms to perform in a constant number of rounds, we have $$\text{PROPER-COLORING} \in BC$$ for any model allowing each process to send its color to all its neighbors in a constant number of rounds, like, e.g., the LOCAL model. Similarly, assuming that $BC$ is a shared-memory computing class bounding algorithms to perform in a constant number of read/write operations, we have $$\text{AGREEMENT} \in BC.$$ **Notation.** In the following, Eq. (1) will often be abbreviated to $$C \in L \iff A(C) = \text{accept}$$ in the sense that $A$ accepts if and only if each of the processes accepts. Note that the rule of distributed decision, i.e., the logical conjunction of the individual boolean outputs of the processes is not symmetric. For instance, deciding whether a graph is properly colored can be done locally, while deciding whether a graph is not properly colored may require long-distance communications. On the other hand, asking for other rules, like unanimous decision (where all processes must reject an illegal configuration) or even just majority decision, would require long-distance communications for most classical decision problems. ### 2.3 Probabilistic Distributed Decision The bounded computing class $BC$ is a base class upon which other classes can be defined. Given $p, q \in [0, 1]$, we define the class $BPBC(p, q)$, for **bounded probability bounded computing**, as the class of all distributed languages $L$ for which there exists a randomized bounded algorithm $A$ such that, for every configuration $C$, $$\begin{cases} C \in L & \Rightarrow \Pr[A(C) = \text{accept}] \geq p; \\ C \notin L & \Rightarrow \Pr[A(C) = \text{reject}] \geq q. \end{cases}$$ (2) Such an algorithm $A$ is called a $(p, q)$-decider for $L$. Note that, as opposed to the class $BPP$ of complexity theory, the parameters $p$ and $q$ are not arbitrary, in the sense that boosting the probability of success of a $(p, q)$-decider in order to get a $(p', q')$-decider with $p' > p$ and $q' > q$ is not always possible. Indeed, if $A$ is repeated many times on an illegal instance, say $k$ times, it may well be the case that each node will reject at most once during the $k$ repetitions, because, at each iteration of $A$, rejection could come from a different node. As a consequence, classical boosting techniques based on repetition and taking majority do not necessarily apply. Example. Let us consider the following distributed language, where each process can be labeled either white or black, i.e., \( \ell : V(C) \to \{\circ, \bullet\} \): \[ \text{AMOS} = \{ \ell : |\{v \in V(C) : \ell(v) = \bullet\}| \leq 1 \}. \] Here, AMOS stands for “at most one selected”, where a node \( v \) is selected if \( \ell(v) = \bullet \). There is a trivial \((p, q)\)-decider for AMOS as long as \( p^2 + q \leq 1 \), which works as follows. Every node \( v \) with \( \ell(v) = \circ \) accepts (with probability 1). A node \( v \) with \( \ell(v) = \bullet \) accepts with probability \( p \), and rejects with probability \( 1 - p \). If \( C \in \text{AMOS} \), then \( \Pr[\text{all nodes accept} C] \geq p \). If \( C \notin \text{AMOS} \), then \( \Pr[\text{at least one node rejects} C] \geq 1 - p^2 \geq q \). ### 2.4 Distributed Verification Given a bounded computing class \( BC \), we describe the class \( NBC \), which is to \( BC \) what \( NP \) is to \( P \) in complexity theory. We define the class \( NBC \), for *non-deterministic bounded computing*, as the class of all distributed languages \( \mathcal{L} \) such that there exists a bounded algorithm \( A \) satisfying that, for every configuration \( C \), \[ C \in \mathcal{L} \iff \exists c : A(C, c) = \text{accept} \tag{3} \] where \[ c : V(C) \to \{0, 1\}^*. \] The function \( c \) is called the *certifying* function. It assigns a certificate to every process, and the certificates do not need to be identical. Note that the certificate \( c(v) \) of process \( v \) must not be mistaken with the label \( \ell(v) \) of that process. The bounded algorithm \( A \) is also known as a *verification* algorithm for \( \mathcal{L} \), as it verifies a given proof \( c \), which is supposed to certify that \( C \in \mathcal{L} \). At each process \( v \in V(C) \), the verification algorithm takes as input the pair \((\ell(v), c(v))\). Note that the appropriate certificate \( c \) leading to accept a configuration \( C \in \mathcal{L} \) may depend on the given configuration \( C \). However, for \( C \notin \mathcal{L} \), the verification algorithm \( A \) must systematically guaranty that at least one process rejects, whatever the given certificate function is. Alternatively, one can interpret Eq. (3) as a game between a *prover* which, for every configuration \( C \), assigns a certificate \( c(v) \) to each process \( v \in V(C) \), and a *verifier* which checks that the certificates assigned by the prover collectively form a *proof* that \( C \in \mathcal{L} \). For a legal configuration (i.e., a configuration in \( \mathcal{L} \)) the prover must be able to produce a distributed proof leading the distributed verifier to accept, while, for an illegal configuration, the verifier must reject in at least one node whatever the proof provided by the prover is. Example. Let us consider the distributed language \[ \text{ACYCLIC} = \{(G, \ell) : G \text{ has no cycles}\} \] in the context of network computing. Note that \( \text{ACYCLIC} \) cannot be decided locally, even in the \( \text{LOCAL} \) model. However, \( \text{ACYCLIC} \) can be verified in just one round. If \( G \) is acyclic, i.e., \( G \) is a forest, then let us select an arbitrary node in each tree of \( G \), and call it a root. Next, let us assign to each node \( u \in V(G) \) the certificate \( c(u) \) equal to its distance to the root of its tree. The verification algorithm \( A \) then proceeds at every node \( u \) as follows. Node \( u \) exchanges its certificate with the ones of its neighbors, and checks that it has a unique neighbor \( v \) satisfying \( c(v) = c(u) - 1 \), and all the other neighbors \( w \neq v \) satisfying \( c(w) = c(u) + 1 \). (If \( u \) has \( c(u) = 0 \), then it checks that all its neighbors \( w \) have \( c(w) = 1 \).) If all tests are passed, then \( u \) accepts, else it rejects. If $G$ is a acyclic, then, by construction, the verification accepts at all nodes. Instead, if $G$ has a cycle, then, for every setting of the certifying function, some inconsistency will be detected by at least one node of the cycle, which leads this node to reject. Hence $\text{acyclic} \in \text{NBC}$ where BC bounds the number of rounds, for every distributed computing model allowing every node to exchange $O(\log n)$ bits along each of its incident edges at every round, like, e.g., the CONGEST model. **Notation.** For any function $f : \mathbb{N} \rightarrow \mathbb{N}$, we define $\text{NBC}(f)$ as the class $\text{NBC}$ where the certificates are bounded to be on at most $f(n)$ bits in $n$-node networks. For $f \in \Theta(\log n)$, $\text{NBC}(f)$ is rather denoted by $\log$-$\text{NBC}$. ### 2.5 Distributed Decision Hierarchy In the same way the polynomial hierarchy $\text{PH}$ is built upon $\text{P}$ using alternating universal and existential quantifiers, one can define a hierarchy built upon base class BC. Given a class $\text{BC}$ for some distributed computing model, we define the distributed decision hierarchy $\text{DH}^\text{BC}$ as follows. We set $\Sigma^\text{BC}_0 = \Pi^\text{BC}_0 = \text{BC}$, and, for $k \geq 1$, we set $\Sigma^\text{BC}_k$ as the class of all distributed languages $L$ such that there exists a bounded algorithm $A$ satisfying that, for every configuration $C$, $C \in L \iff \exists c_1 \forall c_2 \exists c_3 \ldots Q c_k : A(C, c_1, \ldots, c_k) = \text{accept}$ where, for every $i \in \{1, \ldots, k\}$, $c_i : V(C) \rightarrow \{0, 1\}^*$, and $Q$ is the universal quantifier if $k$ is even, and the existential one otherwise. The class $\Pi^\text{BC}_k$ is defined similarly, by having a universal quantifier as first quantifier, as opposed to an existential one as in $\Sigma^\text{BC}_k$. The $c_i$'s are called certifying functions. In particular, we have $\text{NBC} = \Sigma^\text{BC}_1$. Finally, we define $\text{DH}^\text{BC} = (\cup_{k \geq 0} \Sigma^\text{BC}_k) \cup (\cup_{k \geq 0} \Pi^\text{BC}_k)$. As for $\text{NBC}$, a class $\Sigma^\text{BC}_k$ or $\Pi^\text{BC}_k$ can be viewed as a game between a prover (playing the existential quantifiers), a disprover (playing the universal quantifiers), and a verifier (running a verification algorithm $A$). **Example.** Let us consider the distributed language $\text{VERTEX-COVER} = \{(G, \ell) : \{|v \in V(G) : \ell(v) = 1\} \text{ is a minimum vertex cover}\}$ in the context of network computing. We show that $\text{VERTEX-COVER} \in \Pi^\text{BC}_2$, that is, there exists a bounded distributed algorithm $A$ such that $(G, \ell) \in \text{VERTEX-COVER} \iff \forall c_1 \exists c_2 : A(G, \ell, c_1, c_2) = \text{accept}$ where BC is any network computing class bounding algorithms to perform in a constant number of rounds. For any configuration $(G, \ell)$, the disprover tries to provide a vertex cover $c_1 : V(G) \rightarrow \{0, 1\}$ of size smaller than the solution $\ell$, i.e., $|\{v \in V(G) : c_1(v) = 1\}| < |\{v \in V(G) : \ell(v) = 1\}|$. On a legal configuration $(G, \ell)$, the prover then reacts by providing each node $v$ with a certificates $c_2(v)$ such that the $c_2$-certificates collectively encode a spanning tree (and its proof) aiming at demonstrating that there is an error in $c_1$ (like $c_1$ is actually not smaller than $\ell$, or $c_1$ is not covering some edge, etc.). It follows that $$\text{VERTEX-COVER} \in \Pi_2^{bc}$$ for any model allowing each process to exchange $O(\log n)$-bits messages with its neighbors in a constant number of rounds, like, e.g., the CONGEST model. **Notation.** Similarly to the class $\text{NBC}$, for any function $f : \mathbb{N} \to \mathbb{N}$, we define $\Sigma_k^{bc}(f)$ (resp., $\Pi_k^{bc}(f)$) as the class $\Sigma_k^{bc}$ (resp., $\Pi_k^{bc}$) where all certificates are bounded to be on at most $f(n)$ bits in $n$-node networks. For $f \in \Theta(\log n)$, these classes are denoted by log-$\Sigma_k^{bc}$ and log-$\Pi_k^{bc}$, respectively. The classes $\text{DH}^{bc}(f)$ and log-$\text{DH}^{bc}$ are defined similarly. # 3 Distributed Decision in Networks In this section, we focus on languages defined as collections of configurations of the form $(G, \ell)$ where $G$ is a simple connected $n$-node graph, and $\ell : V(G) \to \{0, 1\}^*$ is a labeling function assigning to every node $v$ a label $\ell(v)$. Recall that an algorithm $A$ is *deciding* a distributed language $L$ if and only if, for every configuration $(G, \ell)$, $$(G, \ell) \in L \iff A(G, \ell) \text{ accepts at all nodes.}$$ ## 3.1 LOCAL model ### 3.1.1 Local Distributed Decision (LD and BPLD) In their seminal paper [48], Naor and Stockmeyer define the class $\text{LCL}$, for *locally checkable labelings*. Let $\Delta \geq 0$, $k \geq 0$, and $\ell \geq 0$, and let $B$ be a set of balls of radius at most $t$ with nodes of degree at most $\Delta$, labeled by labels in $[k]$. Note that $B$ is finite. Such a set $B$ defines the language $L$ consisting of all configurations $(G, \ell)$ where $G$ is a graph with maximum degree $\Delta$, and $\ell : V(G) \to [k]$, such that all balls of radius $t$ in $(G, \ell)$ belong to $B$. The set $B$ is called the set of *good* balls for $L$. $\text{LCL}$ is the class of languages that can be defined by a set of good balls, for some parameters $\Delta$, $k$, and $t$. For instance the set of $k$-colored graphs with maximum degree $\Delta$ is a language in $\text{LCL}$. The good balls of this $\text{LCL}$ language are simply the balls of radius 1 where the center node is labeled with a color different from all the colors of its neighbors. A series of results were achieved in [48] about $\text{LCL}$ languages. In particular, it is Turing-undecidable whether any given $L \in \text{LCL}$ has a construction algorithm running in $O(1)$ rounds in the LOCAL model. Also, [48] showed that the node IDs play a limited role in the context of $\text{LCL}$ languages. Specifically, [48] proves that, for every $r \geq 0$, if a language $L \in \text{LCL}$ has a $r$-round construction algorithm, then it has also a $r$-round *order invariant* construction algorithm, where an algorithm is order invariant if the *relative order* of the node IDs may play a role, but not the actual *values* of these IDs. The assumption $L \in \text{LCL}$ can actually be discarded, as long as $L$ remains defined on constant degree graphs with constant labels. That is, [3] proved that, in constant degree graphs, if a language with constant size labels has a $r$-round construction algorithm, then it has also a $r$-round order invariant construction algorithm. Last but not least, [48] established that randomization is of little help in the context of $\text{LCL}$ languages. Specifically, [48] proves that if a language $L \in \text{LCL}$ has a randomized Monte-Carlo construction algorithm running in $O(1)$ rounds, then $L$ also has a deterministic construction algorithm running in $O(1)$ rounds. The class $\text{LD}$, for *local decision* was defined in [33] as the class of all distributed languages that can be decided in $O(1)$ rounds in the LOCAL model. The class $\text{LD}$ is the basic class playing the role of BC in the context of local decision. Hence LCL ⊆ LD since the set of good balls of a language in LCL is, by definition, finite. On the other hand, LCL ⊊ LD, where the inclusion is strict since LD does not restrict the graphs to be of bounded degree, nor the labels to be of bounded size. Given $p, q \in [0, 1]$, the class BPLD$(p, q)$, for bounded probability local decision, was defined in [33] as the class of languages for which there is a $(p, q)$-decider running in $O(1)$ rounds in the LOCAL model. For $p^2 + q \leq 1$, BPLD$(p, q)$ is shown to include languages that cannot be even decided deterministically in $o(n)$ rounds. On the other hand, [33] also establishes a derandomization result, stating that, for $p^2 + q > 1$, if $L \in$ BPLD$(p, q)$, then $L \in$ LD. This results however holds only for languages closed under node deletion, and it is proved in [27] that, for any every $c \geq 2$, there exists a language $L$ with a $(p, q)$-decider satisfying $p^c + q > 1$ and running in a single round, which cannot be decided deterministically in $o(\sqrt{n})$ rounds. On the other hand, [27] proves that, for $p^2 + q > 1$, we have BPLD$(p, q)$ = LD for all languages restricted on paths. On the negative side, it was proved in [27] that boosting the probability of success for decision tasks is not always achievable in the distributed setting, by considering the classes $$BPLD_k = \bigcup_{p^{1+k/q} + q > 1} BPLD(p, q) \text{ and } BPLD_\infty = \bigcup_{p+q > 1} BPLD(p, q)$$ for any $k \geq 1$, and proving that, for every $k \geq 1$, $BPLD_k \subset BPLD_\infty$, and $BPLD_k \subset BPLD_{k+1}$, where all inclusions are strict. On the positive side, it was proved in [20] that the result in [48] regarding the derandomization of construction algorithms can be generalized from LCL to BPLD. Namely, [20] proves that, for languages on bounded degree graphs and bounded size labels, for every $p > \frac{1}{2}$ and $q > \frac{1}{2}$, if $L \in$ BPLD$(p, q)$ has a randomized Monte-Carlo construction algorithm running in $O(1)$ rounds, then $L$ has also a deterministic construction algorithm running in $O(1)$ rounds. ### 3.1.2 Identity-Oblivious Algorithms (LDO) In the LOCAL model, a distributed algorithm is identity-oblivious, or simply ID-oblivious, if the outputs of the nodes are not impacted by the identities assigned to the nodes. That is, for any two ID-assignments given to the nodes, the output of every node must be identical in both cases. Note that an identity-oblivious algorithm may use the IDs of the nodes (e.g., to distinguish them), but the output must be oblivious to these IDs. The class LDO, for local decision oblivious was defined in [28, 29], as the class of all distributed languages that can be decided in $O(1)$ rounds by an ID-oblivious algorithm in the LOCAL model. The class LDO is the basic class playing the role of BC in the context of ID-oblivious local decision. It is shown in [29] that LDO = LD when restricted to languages that are closed under node deletion. However, it is proved in [28] that LDO ⊊ LD, where the inclusion is strict. In the language $L \in$ LD \ LDO used in [28] to prove the strict inclusion LDO ⊊ LD, each node label includes a Turing machine $M$. Establishing $L \in$ LD makes use of an algorithm simulating $M$ at each node, for a number of rounds equal to the identity of the node. Establishing $L \notin$ LDO makes use of the fact that an ID-oblivious algorithm can be sequentially simulated, and therefore, if an ID-oblivious algorithm would allow to decide $L$, then by simulation of this algorithm, there would exist a sequential algorithm for separating the set of Turing machines that halts and output 0 from the set of Turing machines that halts and output 1, which is impossible. In [29, 30], the power of IDs in local decision is characterized using oracles. An oracle is a trustable party with full knowledge of the input, who can provide nodes with information about this input. It is shown in [29] that LDO ⊊ LD ⊊ LDO$^\#node$ where $\#node$ is the oracle providing each node with an arbitrary large upper bound on the number of nodes. A scalar oracle $f$ returns a list \( f(n) = (f_1, \ldots, f_n) \) of \( n \) values that are assigned arbitrarily to the \( n \) nodes in a one-to-one manner. A scalar oracle \( f \) is large if, for any set of \( k \) nodes, the largest value provided by \( f \) to the nodes in this set grows with \( k \). [30] proved that, for any computable scalar oracle \( f \), we have \( \text{LDO}^f = \text{LD}^f \) if and only if \( f \) is large, where \( \text{LD}^f \) (resp., \( \text{LDO}^f \)) is the class of languages that can be locally decided in \( O(1) \) rounds in the LOCAL model by an algorithm (resp., by an ID-oblivious algorithm) which uses the information provided by \( f \) available at the nodes. ### 3.1.3 Anonymous Networks Derandomization results were achieved in [19] in the framework of anonymous network (that is, nodes have no IDs). Namely, for every language \( \mathcal{L} \) that can be decided locally in any anonymous network, if there exists a randomized anonymous construction algorithm for \( \mathcal{L} \), then there exists a deterministic anonymous construction algorithm for \( \mathcal{L} \), provided that the latter is equipped with a 2-hop coloring of the input network. ### 3.2 CONGEST model #### 3.2.1 Non-Local Algorithms In [44] and [17] the authors consider decision problems such as checking whether a given set of edges forms a spanning tree, checking whether a given set of edges forms a minimum-weight spanning tree (MST), checking various forms of connectivity, etc. All these decision tasks require essentially \( \Theta(\sqrt{n} + D) \) rounds (the lower bound is typically obtained using reduction to communication complexity). In particular, [17] proved that checking whether a given set of edges is a spanning tree requires \( \Omega(\sqrt{n} + D) \) rounds, which is much more that what is required to construct a spanning tree \( (O(D) \) rounds, using a simple breadth-first search). However, [17] proved that, for some other problems (e.g., MST), lower bounds on the round-complexity of the decision task consisting in checking whether a solution is valid yield lower bounds on the round-complexity of the corresponding construction task, and this holds also for the construction of approximate solutions. The congested clique model is the CONGEST model restricted to complete graphs. Deciding whether a graph given as input contains some specific patterns as subgraphs has been considered in [16] and [18] for the congested clique. In particular, [16] provides an algorithm for deciding the presence of a \( k \)-node cycle \( C_k \) running in \( O(2^{O(k)}n^{0.158}) \)-rounds. #### 3.2.2 Local Algorithms Very few distributed languages on graphs can be checked locally in the CONGEST model. For instance, even just deciding whether \( G \) contains a triangle cannot be done in \( O(1) \) rounds in the CONGEST model. Distributed property testing is a framework recently introduced in [15]. Let \( 0 < \epsilon < 1 \) be a fixed parameter. Recall that, according to the usual definition borrowed from property testing (in the so-called sparse model), a graph property \( P \) is \( \epsilon \)-far from being satisfied by an \( m \)-edge graph \( G \) if applying a sequence of at most \( \epsilon m \) edge-deletions or edge-additions to \( G \) cannot result in a graph satisfying \( P \). We say that a distributed algorithm \( A \) is a distributed testing algorithm for \( P \) if and only if, for any graph \( G \) modeling the actual network, \[ \begin{align*} &\{ G \text{ satisfies } P \implies \Pr[ A \text{ accepts } G \text{ in all nodes}] \geq \frac{2}{3}, \\ &G \text{ is } \epsilon \text{-far from satisfying } P \implies \Pr[ A \text{ rejects } G \text{ in at least one node}] \geq \frac{2}{3}. \end{align*} \] Among other results, [15] proved that, in bounded degree graphs, bipartiteness can be distributively tested in \( O(\text{polylog } n) \) rounds in the CONGEST model. Moreover, it is also proved that triangle-freeness can be distributedly tested in $O(1)$ rounds. (The dependence in $\epsilon$ is hidden in the big-$O$ notation). This latter result has been recently extended in [40] to testing $H$-freeness, for every 4-node graph $H$, in $O(1)$ rounds. On the other hand, it is not known whether distributed testing $K_5$-freeness or $C_5$-freeness can be achieved in $O(1)$ rounds, and [40] proves that “natural” approaches based on DFS or BFS traversals do not work. 3.3 General Interpretation of Individual Outputs In [3, 4], a generalization of distributed decision is considered, where every node output not just a single bit (accept or reject), but can output an arbitrary bit-string. The global verdict is then taken based on the multi-set of all the binary strings outputted by the nodes. The concern is restricted to decision algorithms performing in $O(1)$ rounds in the LOCAL model, and the objective is to minimize the size of the outputs. The corresponding basic class BC for outputs on $O(1)$ bits is denoted by ULD, for universal LD. (It is universal in the sense that the global interpretation of the individual outputs is not restricted to the logical conjunction). It is proved in [3] that, for any positive even integer $\Delta$, every distributed decision algorithm for cycle-freeness in connected graphs with degree at most $\Delta$ must produce outputs of size at least $\lceil \log \Delta \rceil - 1$ bits. Hence, cycle-freeness does not belong to ULD in general, but it does belong to ULD for constant degree graphs. In [11] the authors consider a model in which each node initially knows the IDs of its neighbors, while the nodes do not communicate through the edges of the network but via a public whiteboard. The concern of [11] is mostly restricted to the case in which every node can write only once on the whiteboard, and the objective is to minimize the size of the message written by each node on the whiteboard. The global verdict is then taken based on the collection of messages written on the whiteboard. It is shown that, with just $O(\log n)$-bit messages, it is possible to rebuild the whole graph from the information on the whiteboard as long as the graph is planar or, more generally, excluding a fixed minor. Variants of the model are also considered, in which problems such as deciding triangle-freeness or connectivity are considered. See also [43] for deciding the presence of induced subgraphs. 4 Distributed Verification in Networks In this section, we still focus on languages defined as collections of configurations of the form $(G, \ell)$ where $G$ is a simple connected $n$-node graph, and $\ell : V(G) \to \{0,1\}^*$ is a labeling function. Recall that an algorithm $\mathcal{A}$ is verifying a distributed language $\mathcal{L}$ if and only if, for every configuration $(G, \ell)$, $$(G, \ell) \in \mathcal{L} \iff \exists c : \mathcal{A}(G, \ell, c) \text{ accepts at all nodes}$$ where $c : V(G) \to \{0,1\}^*$, and $c(v)$ is called the certificate of node $v \in V(G)$. Again, the certificate $c(v)$ of node $v$ must not be mistaken with the label $\ell(v)$ of node $v$. Also, the notion of certificate must not be confused with the notion of advice. While the latter are trustable information provided by an oracle [26, 31, 32], the former are proofs that must be verified. We survey the results about the class NBC = $\Sigma_1^{BC}$ where the basic class BC is LD, LDO, ULD, etc. 4.1 LOCAL model It is crucial to distinguish two cases in Eq. (4), depending on whether the certificates can depend on the identities assigned to the nodes, or not, as reflected in Eq. (5) and (6) below. 4.1.1 Local Distributed Verification ($\Sigma_1^{LP}$, PLS, and LCP) A distributed language $\mathcal{L}$ satisfies $\mathcal{L} \in \Sigma_1^{LP}$ if and only if there exists a verification algorithm $A$ running in $O(1)$ rounds in the LOCAL model such that, for every configuration $(G, \ell)$, we have \[ \begin{cases} (G, \ell) \in \mathcal{L} & \Rightarrow \forall \text{ID}, \exists c, A(G, \ell, c) \text{ accepts at all nodes} \\ (G, \ell) \notin \mathcal{L} & \Rightarrow \forall \text{ID}, \forall c, A(G, \ell, c) \text{ rejects in at least one node} \end{cases} \] (5) where $c : V(G) \to \{0, 1\}^*$, and where, for $(G, \ell) \in \mathcal{L}$, the assignment of the certificates to the nodes may depend on the identities given to these nodes. This notion has actually been introduced under the terminology proof-labeling scheme in [47], where the concern is restricted to verification algorithms running in just a single round, with the objective of minimizing the size of the certificates. In particular, it is proved that minimum-weight spanning tree can be verified with certificates on $O(\log^2 n)$ bits in $n$-node networks, and this bound in tight [45] (see also [44]). Interestingly, the $\Omega(\log^2 n)$ bits lower bound on the certificate size can be broken, and reduced to $O(\log n)$ bits, to the price of allowing verification to proceed in $O(\log n)$ rounds [46]. There are tight connections between proof-labeling schemes and compact silent self-stabilizing algorithms [13], and proof-labeling schemes can even be used as a basis to semi-automatically derive compact time-efficient self-stabilizing algorithms [12]. Let PLS be the class of distributed languages for which there exists a proof-labeling scheme. We have $$\text{PLS} = \text{ALL}$$ where ALL is the class of all distributed languages on networks (i.e., with configurations of the form $(G, \ell)$). This equality is however achieved using certificates on $O(n^2 + nk)$ bits in $n$-node networks, where $k$ is the maximum size of the labels in the given configuration $(G, \ell)$. The $O(n^2)$ bits are used to encode the adjacency matrix of the network, and the $O(nk)$ bits are used to encode the inputs to the nodes. The notion of proof-labeling scheme has been extended in [41] to the notion of locally checkable proofs, which is the same as proof-labeling scheme but where the verification algorithm is not bounded to run in a single round, but may perform an arbitrarily large constant number of rounds. Let LCP be the associate class of distributed languages. By definition, we have $$\text{LCP} = \Sigma_1^{LP},$$ and, more specifically, $$\text{LCP}(f) = \Sigma_1^{LP}(f)$$ for every function $f$ bounding the size of the certificates. Moreover, since $\text{PLS} = \text{ALL}$, it follows that $$\text{PLS} = \text{LCP} = \Sigma_1^{LP} = \text{ALL}.$$ 4.1.2 Identity-Oblivious Algorithms ($\Sigma_1^{LDO}$ and NLD) A distributed language $L$ satisfies $L \in \Sigma_1^{LDO}$ if and only if there exists a verification algorithm $A$ running in $O(1)$ rounds in the $LOCAL$ model such that, for every configuration $(G, \ell)$, we have \[ \begin{align*} (G, \ell) \in L &\Rightarrow \exists c, \forall ID, A(G, \ell, c) \text{ accepts at all nodes} \\ (G, \ell) \notin L &\Rightarrow \forall c, \forall ID, A(G, \ell, c) \text{ rejects in at least one node} \end{align*} \] where $c : V(G) \to \{0, 1\}^*$, and, for $(G, \ell) \in L$, the assignment of the certificates to the nodes must not depend on the identities given to these nodes. In [33], the class NLD, for non-deterministic local decision is introduced. In NLD, even if the certificates must not depend on the identities of the nodes, the verification algorithm is not necessarily identity-oblivious. Yet, it was proved in [29] that restricting the verification algorithm to be identity-oblivious does not restrict the power of the verifier. Hence, $$\text{NLD} = \Sigma_1^{LDO}$$ $\Sigma_1^{LDO}$ is characterized in [29] as the class of languages that are closed under lift, where $H$ is a $k$-lift of $G$ if there exists an homomorphism from $H$ to $G$ preserving radius-$k$ balls. Hence, $$\Sigma_1^{LDO} \subset \text{ALL}$$ where the inclusion is strict. However, it was proved in [33] that, for every distributed language $L$, and for every $p, q$ such that $p^2 + q \leq 1$, there is a non-deterministic $(p, q)$-decider for $L$. In other words, for every $p, q$ such that $p^2 + q \leq 1$, we have $$\text{BPNLD}(p, q) = \text{ALL}.$$ In [33], a complete problem for NLD was identified. However, it was recently noticed in [7] that the notion of local reduction used in [33] is way too strong, enabling to bring languages outside NLD into NLD. A weaker notion of local reduction was thus defined in [7], preserving the class NLD. A language is proved to be NLD-complete under this weaker type of local reduction. 4.1.3 Anonymous Networks Distributed verification in the context of fully anonymous networks (no node-identities, and no port-numbers) has been considered in [23]. 4.2 CONGEST model ($\log\Sigma_1^{LD}$ and log-LCP) The class log-LCP, that is, $\log\Sigma_1^{LD}$, i.e., $\Sigma_1^{LD}$ with certificates of size $O(\log n)$ bits, was investigated in [41]. This class fits well with the CONGEST model, which allows to exchange messages of at most $O(\log n)$ bits at each round. For instance, non-bipartiteness is in log-LCP. Also, restricted to bounded-degree graphs, there are problems in log-LCP that are not contained in NP, but log-LCP $\subseteq$ NP/poly, i.e., NP with a polynomial-size non-uniform advice. Last but not least, [41] shows that existential MSO on connected graphs is included in log-LCP. 4.3 General Interpretation of Individual Outputs As already mentioned in Section 3.3, a generalization of distributed decision was considered in [3, 4], where every node outputs not just a single bit (accept or reject), but can output an arbitrary bit-string. The global verdict is then taken based on the multi-set of all the binary strings outputted by the nodes. The concern is restricted to decision algorithm performing in $O(1)$ rounds in the $LOCAL$ model, and the objective is to minimize the size of the output. The certificates must not depend on the node IDs, that is, verification proceed as specified in Eq. (6). For constant size outputs, it is shown in [4] that the class \( \text{UNLD} = \Sigma_1^{\text{ULD}} \) satisfies \[ \text{UNLD} = \text{ALL} \] with just 2-bit-per-node outputs, which has to be consider in contrast to the fact that \( \text{NLD} \) is restricted to languages that are closed under lift (cf. Section 4.1.2). This result requires using certificates on \( O(n^2 + nk) \) bits in \( n \)-node networks, where \( k \) is the maximum size of the labels in the given configuration \( (G, \ell) \), but [4] shows that this is unavoidable. Also, while verifying cycle-freeness using the logical conjunction of the 1-bit-per-node outputs requires certificates on \( \Omega(\log n) \) bits [41], it is proved in [4] that, by simply using the conjunction and the disjunction operators together, on only 2-bit-per-node outputs, one can verify cycle-freeness using certificates of size \( O(1) \) bits. 5 Local Hierarchies in Networks In this section, we survey the results about the hierarchies \( \Sigma_k^{\text{BC}} \) and \( \Pi_k^{\text{BC}} \) for different basic classes \( \text{BC} \), including \( \text{LD} \), \( \text{LDO} \), etc. 5.1 LOCAL model (\( \text{DH}^{\text{LD}} \) and \( \text{DH}^{\text{LDO}} \)) We have seen in Section 4.1.1 that \( \Sigma_1^{\text{LD}} = \text{ALL} \), which implies that the local distributed hierarchy \( \text{DH}^{\text{LD}} \) collapses at the first level. On the other hand, we have also seen in Section 4.1.2 that \( \Sigma_1^{\text{LDO}} \subset \text{ALL} \), where the inclusion is strict as \( \Sigma_1^{\text{LDO}} \) is restricted to languages that are closed under lift. It was recently proved in [7] that \[ \text{LDO} \subset \Pi_1^{\text{LDO}} \subset \Sigma_1^{\text{LDO}} = \Sigma_2^{\text{LDO}} \subset \Pi_2^{\text{LDO}} = \text{ALL} \] where all inclusions are strict. Hence, the local ID-oblivious distributed hierarchy collapses at the second level. Moreover, it is shown that \( \Pi_2^{\text{LDO}} \) has a complete problem for local label-preserving reductions. (A complete problem for \( \text{ALL} \) was also identified in [33], but using an inappropriate notion of local reduction). In the context of a general interpretation of individual outputs (see Section 4.3), [4] proved that \( \Sigma_1^{\text{ULD}} = \text{ALL} \). 5.2 CONGEST model (\( \text{log-DH}^{\text{LD}} \)) We have previously seen that \( \Sigma_1^{\text{LD}} = \text{ALL} \). However, this requires certificates of polynomial size. In order to fit with the constraints of the CONGEST model, the local distributed hierarchy with certificate of logarithmic size was recently investigated in [21]. While it follows from [45] that \( \text{mst} \notin \log-\Sigma_1^{\text{LD}} \), it is shown in [21] that \[ \text{mst} \in \log-\Pi_2^{\text{LD}}. \] In fact, [21] proved that, for any \( k \geq 1 \), \[ \log-\Sigma_{2k}^{\text{LD}} = \log-\Sigma_{2k-1}^{\text{LD}} \quad \text{and} \quad \log-\Pi_{2k+1}^{\text{LD}} = \log-\Pi_{2k}^{\text{LD}}, \] and thus focused only on the hierarchy \( (\Lambda_k)_{k\geq0} \) defined by \( \Lambda_0 = \text{LD} \), and, for \( k \geq 1 \), \[ \Lambda_k = \begin{cases} \log-\Sigma_k^{\text{LD}} & \text{if } k \text{ is odd} \\ \log-\Pi_k^{\text{LD}} & \text{if } k \text{ is even}. \end{cases} \] It is proved that if there exists \( k \geq 0 \) such that \( \Lambda_{k+1} = \Lambda_k \), then \( \Lambda_{k'} = \Lambda_k \) for all \( k' \geq k \). That is, the hierarchy collapses at the \( k \)-th level. Moreover, there exists a distributed language on 0/1-labelled oriented paths that is outside the \( \Lambda_k \)-hierarchy, and thus outside \( \log\text{-DH}^{k\text{D}} \). However, deciding whether a given solution to several optimisation problems such as maximum independent set, minimum dominating set, maximum matching, max-cut, min-cut, traveling salesman, etc., is optimal are all in \( \text{co-} \Lambda_1 \), and thus in \( \log\text{-}\Pi^{k\text{D}}_2 \). The absence of a non-trivial automorphism is proved to be in \( \Lambda_3 \), that is \( \log\text{-}\Sigma^{k\text{D}}_3 \) — recall that this language requires certificated of \( \tilde{\Omega}(n^2) \) bits to be placed in \( \Sigma^{k\text{D}}_1 \) (see [41]). It is however not known whether \( \Lambda_3 \neq \Lambda_2 \), that is whether \( \log\text{-}\Pi^{k\text{D}}_2 \subset \log\text{-}\Sigma^{k\text{D}}_3 \) with a strict inclusion. 5.3 Distributed Graph Automata (\( \text{DH}^{\text{DGA}} \)) An analogue of the polynomial hierarchy, where sequential polynomial-time computation is replaced by distributed local computation was recently investigated in [50]. The model in [50] is called distributed graph automata. This model assumes a finite-state automaton at each node (instead of a Turing machine), and assumes anonymous computation (instead of the presence of unique node identities). Also, the model assumes an arbitrary interpretation of the outputs produced by each automaton, based on an arbitrary mapping from the collection of all automata states to \{true, false\}. The main result in [50] is that the hierarchy \( \text{DH}^{\text{DGA}} \) coincides with \( \text{MSO} \) on graphs. 6 Other Computational Models 6.1 Wait-Free Computing The class \( \text{WFD} \) defined as the class of all distributed languages that are wait-free decidable was characterized in [36] as the class of languages satisfying the so-called projection-closeness property. For non projection-closed languages, [37] investigated more general interpretation of the individual opinions produced by the processes, beyond the logical conjunction of boolean opinions. In [35], it is proved that \( k \)-set agreement requires that the processes must be allowed to produce essentially \( k \) different opinions to be wait-free decided. The class \( \Sigma^{\text{WFD}}_1 \) has been investigated in [38, 39], with applications to the space complexity of failure detectors. Interestingly, it is proved in [14] that wait-free decision finds applications to run-time verification. 6.2 Mobile Computing The class \( \text{MAD} \), for mobile agent decision has been considered in [34], as well as the class \( \text{MAV} = \Sigma^{\text{MAD}}_1 \), for mobile agent verification. It is proved that \( \text{MAV} \) has a complete language for a basic notion of reduction. The complement classes of \( \text{MAD} \) and \( \text{MAV} \) have been recently investigated in [8] together with sister classes defined by other ways of interpreting the opinions of the mobile agents. 6.3 Quantum Computing Distributed decision in a framework in which nodes can have access to extra resources, such as shared randomness, or intricate variables (in the context of quantum computing) is discussed in [2]. 7 Conclusion Distributed decision and distributed verification are known to have applications to very different contexts of distributed computing, including self-stabilization, randomized algorithms, fault-tolerance, runtime verification, etc. In this paper, our aim was to survey the results targeting distributed decision and verification per se. Beside the many interesting problems left open in each of the references listed in this paper, we want to mention two important issues. Lower bounds in decision problems are often based on spatial or temporal arguments. Typically, the lack of information about far away processes, or the lack of information about desynchronized (or potentially crashed) processes, prevents processes to forge a consistent opinion about the global status of the distributed system. In the context of shared resources, such type of arguments appears however to be too weak (cf. [2]). Similarly, lower bounds in verification problems are often based on reduction to communication complexity theory. However, such reductions appear to be difficult to apply to higher classes in the local hierarchy, like separating the class at the third level from the class at the second level of the local hierarchy with $O(\log n)$-bit certificates (cf. [21]). This paper has adopted a systematic approach for presenting the results related to distributed decision and verification from the literature. This approach was inspired from sequential complexity and sequential computability theories. Such an approach provides a framework that enables to clearly separate decision from verification, as well as clearly separate the results obtained under different assumption (ID-oblivious, size of certificates, etc.). As already mentioned in [24], we believe that distributed decision provides a framework in which bridges between very different models might be identified, as decision tasks enables easy reductions between languages, while construction tasks are harder to manipulate because of the very different natures of their outputs. References
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01331880/file/arxiv.pdf", "len_cl100k_base": 14556, "olmocr-version": "0.1.53", "pdf-total-pages": 21, "total-fallback-pages": 0, "total-input-tokens": 71562, "total-output-tokens": 19043, "length": "2e13", "weborganizer": {"__label__adult": 0.00041604042053222656, "__label__art_design": 0.0005731582641601562, "__label__crime_law": 0.0004651546478271485, "__label__education_jobs": 0.0018911361694335935, "__label__entertainment": 0.0002104043960571289, "__label__fashion_beauty": 0.0002486705780029297, "__label__finance_business": 0.0004930496215820312, "__label__food_dining": 0.0005197525024414062, "__label__games": 0.0012645721435546875, "__label__hardware": 0.0015869140625, "__label__health": 0.0012989044189453125, "__label__history": 0.0007166862487792969, "__label__home_hobbies": 0.00018227100372314453, "__label__industrial": 0.0006551742553710938, "__label__literature": 0.0008244514465332031, "__label__politics": 0.0004665851593017578, "__label__religion": 0.0007295608520507812, "__label__science_tech": 0.484619140625, "__label__social_life": 0.00016891956329345703, "__label__software": 0.01271820068359375, "__label__software_dev": 0.488525390625, "__label__sports_fitness": 0.00032210350036621094, "__label__transportation": 0.0008015632629394531, "__label__travel": 0.0002651214599609375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 65557, 0.04048]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 65557, 0.38453]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 65557, 0.86521]], "google_gemma-3-12b-it_contains_pii": [[0, 821, false], [821, 1549, null], [1549, 2770, null], [2770, 7094, null], [7094, 11145, null], [11145, 14768, null], [14768, 17908, null], [17908, 21828, null], [21828, 25162, null], [25162, 29104, null], [29104, 33280, null], [33280, 37262, null], [37262, 40918, null], [40918, 43796, null], [43796, 47176, null], [47176, 50582, null], [50582, 54061, null], [54061, 57362, null], [57362, 60519, null], [60519, 63276, null], [63276, 65557, null]], "google_gemma-3-12b-it_is_public_document": [[0, 821, true], [821, 1549, null], [1549, 2770, null], [2770, 7094, null], [7094, 11145, null], [11145, 14768, null], [14768, 17908, null], [17908, 21828, null], [21828, 25162, null], [25162, 29104, null], [29104, 33280, null], [33280, 37262, null], [37262, 40918, null], [40918, 43796, null], [43796, 47176, null], [47176, 50582, null], [50582, 54061, null], [54061, 57362, null], [57362, 60519, null], [60519, 63276, null], [63276, 65557, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 65557, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 65557, null]], "pdf_page_numbers": [[0, 821, 1], [821, 1549, 2], [1549, 2770, 3], [2770, 7094, 4], [7094, 11145, 5], [11145, 14768, 6], [14768, 17908, 7], [17908, 21828, 8], [21828, 25162, 9], [25162, 29104, 10], [29104, 33280, 11], [33280, 37262, 12], [37262, 40918, 13], [40918, 43796, 14], [43796, 47176, 15], [47176, 50582, 16], [50582, 54061, 17], [54061, 57362, 18], [57362, 60519, 19], [60519, 63276, 20], [63276, 65557, 21]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 65557, 0.0]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
3807cb36923f44698d27ddc8cfdf72d95811cd11
Abstract: The purpose of this document is to provide a standard for quality factors of web services in their development, usage and management. Web services usually have distinguished characteristics. They are service-oriented, network-based, variously bind-able, loosely-coupled, platform independent, and standard-protocol based. As a result, a web service system requires its own quality factors unlike installation-based software. For instance, as the quality of web services can be altered in real-time according to changes by the service provider, considering real-time properties of web services is very meaningful in describing the web services quality. This document presents the quality factors of web services with definition, classification, and sub-factors case by case. For each quality factor, related specifications are cited with a brief explanation. This specification can be generally extended to the definition of quality of SOA and to provide the foundation for quality in the SOA system. Status: This document was last revised or approved by the OASIS Web Services Quality Model TC on the above date. The level of approval is also listed above. Check the “Latest version” location noted above for possible later revisions of this document. Technical Committee members should send comments on this specification to the Technical Committee’s email list. Others should send comments to the Technical Committee by using the “Send A Comment” button on the Technical Committee’s web page at http://www.oasis-open.org/committees/wsqm/. For information on whether any patents have been disclosed that may be essential to implementing this specification, and any offers of patent licensing terms, please refer to the Intellectual Property Rights section of the Technical Committee web page (http://www.oasis-open.org/committees/wsqm/ipr.php). Citation format: When referencing this specification the following citation format should be used: [WS-Quality-Factors-v1.0] Notices Copyright © OASIS Open 2011. All Rights Reserved. All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this specification. OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this specification by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this specification. OASIS may include such claims on its website, but disclaims any obligation to do so. OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS’ procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims. The name "OASIS" is a trademark of OASIS, the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance. ## Table of Contents 1 Introduction ................................................................................................................. 6 1.1 Characteristics of WS Quality .............................................................................. 6 1.2 WS Quality Factors ............................................................................................. 7 1.3 Audience ............................................................................................................. 8 1.4 Terminology ......................................................................................................... 8 1.5 Normative References ......................................................................................... 8 1.6 Non-Normative References ............................................................................... 8 2 Business Value Quality ............................................................................................... 9 2.1 Definition ............................................................................................................. 9 2.2 Sub Quality Factors ............................................................................................. 9 2.2.1 Price .............................................................................................................. 9 2.2.2 Penalty and Incentive ................................................................................... 9 2.2.3 Business Performance ............................................................................... 10 2.2.4 Service Recognition .................................................................................... 10 2.2.5 Service Reputation ..................................................................................... 10 2.2.6 Service Provider Reputation ....................................................................... 10 3 Service Level Measurement Quality .......................................................................... 11 3.1 Definition ............................................................................................................. 11 3.2 Sub Quality Factors ............................................................................................. 11 3.2.1 Response Time ............................................................................................. 11 3.2.2 Maximum Throughput ............................................................................... 12 3.2.3 Availability .................................................................................................. 12 3.2.4 Accessibility ................................................................................................ 12 3.2.5 Successability .............................................................................................. 13 4 Interoperability Quality ............................................................................................... 14 4.1 Definition ............................................................................................................. 14 4.2 Sub Quality Factors ............................................................................................. 15 4.2.1 Standard Adoptability ............................................................................... 15 4.2.2 Standard Conformability ........................................................................... 15 4.2.3 Relative Proofness ...................................................................................... 15 4.3 Relationships to other Standards ....................................................................... 16 5 Business Processing Quality ......................................................................................... 17 5.1 Definition ............................................................................................................. 17 5.2 Sub Quality Factors ............................................................................................. 17 5.2.1 Messaging Reliability .................................................................................. 17 5.2.2 Transaction Integrity ................................................................................... 18 5.3 Relationship to other Standards ....................................................................... 19 6 Manageability Quality ................................................................................................. 21 6.1 Definition ............................................................................................................. 21 6.2 Sub Quality Factors ............................................................................................. 21 6.2.1 Informability ................................................................................................ 21 6.2.2 Observability ............................................................................................... 21 ## 6.2.3 Controllability ### 6.3 Relationship to other Standards ### 7 Security Quality #### 7.1 Definition #### 7.2 Sub Quality Factor <table> <thead> <tr> <th>Sub Quality Factor</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>Encryption</td> <td>24</td> </tr> <tr> <td>Authentication</td> <td>25</td> </tr> <tr> <td>Authorization</td> <td>25</td> </tr> <tr> <td>Integrity</td> <td>25</td> </tr> <tr> <td>Non-Repudiation</td> <td>26</td> </tr> <tr> <td>Availability</td> <td>26</td> </tr> <tr> <td>Audit</td> <td>26</td> </tr> <tr> <td>Privacy</td> <td>27</td> </tr> </tbody> </table> #### 7.3 Relationship to other Standards ### 8 Conformance ### Appendix A. Acknowledgments 1 Introduction The importance of web services has been raised as an enabler of Service Oriented Architecture (SOA). As a result, most software communities who are related in the planning, development and management of SOA have significantly interested in Web Services quality. This document specifies web services quality factors conceptually along with definition and explanation of sub-factors. This chapter presents the basic characteristics of web services and quality factors induced from them. 1.1 Characteristics of WS Quality Web services have distinguished characteristics different from installation-based software because of their service-oriented nature. The provider and consumer of services could belong to different ownership domains so that there are many cases that a service cannot meet the consumer’s service requirements in respect of service quality and content. Web services are usually invoked through networks, so the network performance critically affects the overall web service quality. As a web service client binds to a web service server with loosely-coupled manner and various binding mechanisms, both client and server could be bound easily and flexibly. On the contrary, the client and the server cannot guarantee for proper operating performance. They may be operated platform-independently, so it requires more efforts for guaranteeing interoperability between them. Even though web services are based on standard protocols of communication, misconception of the protocols can produce critical results in non-interoperable services. Due to the characteristics described above, web services show distinct quality characteristics from those of general software. Firstly, the usage of web services is highly sensitive to their quality, especially in --- <Figure 1-1> Extracting Quality Factors of WS Due to the characteristics described above, web services show distinct quality characteristics from those of general software. Firstly, the usage of web services is highly sensitive to their quality, especially in regard to performance and business. A web service consumer is willing to change a service while using it if it cannot satisfy his requirements on performance or business. Most of web service consumers have an interest in the quality of web services and thus would correspond to the quality problem immediately. Secondly, as web services are operated in the close relation with the other systems, the web service quality depends on the peripheral technical environment: network, security system, and software resource system, and business effectiveness. For example, the quality of transport media influences deeply on the web service quality. Consequently, even though a web service shows very rapid response time on the server side, we cannot expect rapid response time if the bandwidth of transport network is narrow. In the same way, although a web service has been implemented efficiently, it is difficult to expect good performance of the web service when a service provider has low processing capability. Thirdly, a web service client and a server are bound loosely and variously. The web service client can change the web service server dynamically, so the client can experience considerable variation of web service quality. The client can change web services in real-time when the quality is not satisfied. Fourthly, a web service consumer is usually not able or restricted to manage and control a web service, because in many cases a consumer’s domain is different from a service provider’s. Accordingly, the web service consumer requires guaranteeing the higher level of web service quality. Finally, more effort to assure interoperability of web services is required, because a web service client and a server system could be deployed on heterogeneous platforms and web service developers could misunderstand related standards. To summarize above, the characteristics of web services lead to the distinguished characteristics of web service qualities unlike those of installation-based software. Therefore, it is required to induce quality items in alignment with consideration of these characteristics of web service quality during overall web service lifecycle. 1.2 WS Quality Factors A web service quality factor refers to a group of items which represent web service’s functional and non-functional properties (or values) to share the concept of web services quality among web service stakeholders. Based on the characteristics of web service quality described previously, the web service quality factors are composed of business value quality, service level measurement quality, interoperability quality, business processing quality, manageability quality and security quality. Based on whether quality factors are related with business perspective or system perspective, they can be categorized into two groups: the business quality group and the system quality group (Refer to <Figure 1-2>). Business quality group includes only the business value quality factor. System quality group is comprised of the variant quality part and the invariant quality part. The variant quality part includes quality factors whose values can be dynamically varied in run-time while a service is being used. On the while, the invariant quality part refers to quality factors whose values are determined as soon as the service development is completed. The invariant quality part includes interoperability quality, business processing quality, manageability quality and security quality. Business value quality refers to a business perspective to help to make the right selection of a service by evaluating the business value of web services. For evaluating business value, it includes the sub-factors: price, penalty and incentive, business performance, service recognition, service reputation and service provider reputation. Service level measurement quality measures the performance of web services in numeric value: response time, maximum throughput, availability, accessibility and successability. Interoperability quality is a quality factor to evaluate whether a web service system conforms to standard adoptability, standard conformability and relative proofness. Web services may be used in mission-critical work between business partners, and in that case reliability and stability of web services are very important quality items. The business processing quality factor evaluates these items, including messaging reliability, transaction integrity and collaborability. Manageability quality is about to whether web services are manageable or managed items, including informability, observability and controllability, web services are also vulnerable to security attack and fraud of their frequent exposure to open networks. Security quality guarantees the safety of web services for use. That is, it is a collection of quality items to evaluate the functionality and the metric performance of a security system. It includes the sub-factors: encryption, authentication, authorization, integrity, non-repudiation, availability, audit and privacy. 1.3 Audience The intended audiences of this document include non-exhaustively: - Quality associates of web services and SOA: quality managers, quality assurers, quality authenticators, quality information providers, etc. - Architects and developers designing, identifying or developing a system based on web services or SOA concept. - Standard architects and analysts developing specifications of web services or SOA. - Decision makers seeking a "consistent and common" understanding of web services or SOA. 1.4 Terminology The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC2119]. 1.5 Normative References 1.6 Non-Normative References None 2 Business Value Quality 2.1 Definition When a service party decides to use a web service for business, it should consider surely the value of the service on the business. In some cases, the web service may give positive value such as profit, convenience, collaboration to the service party. But in the other cases, it may impose more burdens on the party than the value it delivers. For example, it may require an extra cost for keeping the service in stable condition or cause economic loss due to service provider's failure to meet promised quality. As a result, web service consumers tend to be very sensitive generally to the value of web services on a business. The business value of web services means the economic worth delivered by applying web services on a business. The business value depends on the price of a service, a penalty/compensation policy, service recognition, service reputation and service provider reputation. In addition to those sub-factors, business benefit, profit, and ROI (return on investment) caused by web services could be added in the business value quality. But, it's very difficult to evaluate these values by the effect caused by web services alone because the values depend heavily on each individual business context. Thus, we exclude the business benefit, profit, and ROI from the business value quality. The price and the penalty/compensation sub-factors represent the monetary value, which could be determined by a service provider or the contract between a service provider and a consumer. The service recognition, the service reputation and the service provider reputation are related with the trust of web services, so they could be evaluated as a part of business value. Business value quality provides a business perspective to help to make a right selection of service by evaluating the business value of web services. Consumers refer to the value of this factor to reach a decision to select the most appropriate web service for a given business. 2.2 Sub Quality Factors 2.2.1 Price The price sub-factor is a monetary value of service that a consumer pays for services to a provider while or after using web services. The price of a web service can be determined by a service provider. A service consumer considers the price of a web service in respect of the functions, contents, and the quality of the web service in order to make the decision whether he uses the web service. For general software, users pay overall price for a software package. On the contrary, a consumer has to pay the fee of a web service continuously based on the amount of time usage or use data, so he has continuously interest in the service price. Therefore, the price of a web service affects in the usage of the web service. A service provider should decide the appropriate price by considering the service quality and value. In relation to the price factor, a billing method is also important quality factor for measuring business value of a web service. For example, a reasonable and systematic billing system can improve the trust of a web service. A convenient billing system, a discount policy, and mileage points enhance consumer's loyalty. 2.2.2 Penalty and Incentive Penalty or compensation is the financial compensation for business losses due to nonfulfillment of a contract or failure to meet promised quality. Penalty can be charged to a service provider or a service consumer based on a contract. When a service provider fails to keep service quality levels specified in the contract, the service provider needs to compensate for the loss of a service consumer. The compensation rules need to be specified in the contract. Penalty can be calculated based on service downtime, maximum or average response times, or security requirements of a service, and so on. The performance monitoring of the web service is necessary to determine whether compensation is required or not, and how much compensation is required. Penalty can be charged to a service consumer when the consumer breaches the contract unilaterally, which brings financial loss to a service provider. On the contrary, incentives as positive rewards can be specified in a contract. For example, an incentive can be paid when a service provider has provided higher quality than the quality level specified in the contract. In addition, an incentive can be paid to a service consumer when the servicer consumer uses a service more than a certain usage level during a given time period. 2.2.3 Business Performance In the case that a service provider provides commodities and services in the real world as well as information by web services, the performance of business activity provided for them affects the business value of the web services directly. For example, consider a delivery service with which web services are provided for an order and a payment process. In this case, all the processes including the order, confirmation, delivery, notification and payment which are all connected within the information flow and business activity flow. Overall service quality is related with the capability of the business body as well as the quality of web services. Business performance is defined as the capability of a business party performing business activities for services. The business performance can be measured by the time it takes to complete a business service or the throughput. The time to complete is composed of the duration for performing business activities and a latency for ready or a condition. The throughput is the amount of outcomes for a service per a unit time. 2.2.4 Service Recognition Service recognition quality is defined by how many potential consumers perceive the existence of a service. That is, it is related to the popularity of the service. A highly recognized service means that it has more potential for many people to use the web service. Service recognition can be measured by various methods. For example, it can be estimated by the number of clicks on a service description in a service registry or the number of page views on a service web page. Service recognition is not derived from the service consumer’s experience of service usage. Also, the service recognition level can be improved through promotion or advertising of a web service. However, it does not guarantee the superiority of the other quality factors of the web service such as response time, availability, and reliability. 2.2.5 Service Reputation Service reputation is a social evaluation of service consumers toward a web service. It refers to consumers' opinions on the quality of web services. Service reputation can be evaluated by performing a survey or vote on service quality and consumer satisfaction. In addition, service reputation can be estimated from the replies, comments or reviews of service consumers. Service reputation is very influential for potential service consumers to select web services. While service recognition reflects expectation of the service value before use, service reputation mainly refers to the experienced service quality after use. 2.2.6 Service Provider Reputation Service provider reputation is the opinion of the group of service parties toward a service provider on certain criteria. Service provider reputation is an asset that gives the service provider a competitive advantage because a service provider with a good reputation will be regarded as a reliable, credible, trustworthy and responsible one for service consumers. It can be sustained through consistent quality management activities on services as a whole. Service provider reputation can be influenced by customer’s previous experience on other services of the provider as well as advertisement or public relations. Service consumers pay attention to service provider reputation as well as a service itself. Service provider reputation can be estimated by brand value, financial soundness, the quality of customer service, technical support and sustainability of a service provider. 3 Service Level Measurement Quality 3.1 Definition As a service could be provided by third parties and invoked dynamically via network, service performance might be varied by the network speed or the number of connected users at a given time. Service Level Measurement quality is a set of quantitative attributes which describe the runtime service responsiveness in a view of consumers. This quality factor represents how quickly and soundly web services can respond which can be measured numerically on system. Service Level Measurement Quality consists of five sub-quality factors; response time, maximum throughput, availability, accessibility, and successability. 3.2 Sub Quality Factors 3.2.1 Response Time Response time refers to duration from the time of sending a request to the time of receiving a response. The response time can be varied by the point of measurement and affected by three types of latency: client latency, network latency and server latency as depicted in <Figure 3-1>. Client latency refers to the delay time caused by a client system in the whole processing time for a service request. It is a sum of the time taken between 'a client application requests a service' event and 'the request is sent by a client' event (t1~t2), and the time taken between 'response arrives to the client' event and 'the application system receives the response' event (t7~t8). Network latency refers to the time taken on a network for transmitting request message and response message. It is a sum of the time taken between 'a client sends a request' event and 'the web services server receives the request' event (t2~t3), and the time taken between 'the server sends a response' event and 'the client receives the response' event (t6~t7). Server latency is a delay time caused by a server system in the whole processing time for a service request. It is a sum of the time taken between ‘the server sends the request’ event and ‘web services receives the request’ event (t3~t4), ‘the time taken for processing the service’ event (t4~t5), and the time taken between ‘the response is sent by the web services’ event and ‘the server receives the response’ event (t5~t6). Three types of latency and response time can be calculated by the following formulas. \[ ClientLatency = CL1 + CL2 \] \[ NetworkLatency = NL1 + NL2 \] \[ ServerLatency = SL1 + SL2 + SL3 \] \[ ResponseTime = ClientLatency + NetworkLatency + ServerLatency \] 3.2.2 Maximum Throughput Maximum throughput refers to the maximum amount of services that the service provider can process in a given time period. It is the maximum number of responses which can be processed in a unit time. The following formula expresses the maximum throughput. \[ MaximumThroughput = \max\left( \frac{\text{NumberOfRequestsProcessedbyServiceProviderInMeasuredTime}}{\text{MeasuredTime}} \right) \] 3.2.3 Availability Availability is a measurement which represents the degree to which web services are available in operational status. This refers to a ratio of time in which the web services server is up and running. As the DownTime represents the time when a web services server is not available to use and UpTime represents the time when the server is available, Availability refers to ratio of UpTime to measured time. In order to calculate Availability, it is conveniently rather using DownTime than UpTime and it can be expressed as the following formula. \[ Availability = 1 - \frac{\text{DownTime}}{\text{MeasuredTime}} \] 3.2.4 Accessibility Accessibility represents the probability of which web services platform is accessible while the system is available. This is a ratio of receiving Ack message from the platform when requesting services. That is, it is expressed as the ratio of the number of returned Ack message to the number of request messages in a given time. To increase accessibility, a system needs to be built in expansible architecture. \[ \text{Accessibility} = \frac{\text{NumberOfAckMessage}}{\text{NumberOfRequestedMessage}} \] 3.2.5 Successability Successability is a probability of returning responses after web services are successfully processed. In other words, it refers to a ratio of the number of response messages to the number of request messages after successfully processing services in a given time. 'Being successful' means the case that a response message defined in WSDL is returned. In this time, it is assumed that a request message is an error free message. \[ \text{Successability} = \frac{\text{Number of Response Message}}{\text{Number of Requested Message}} \] 4 Interoperability Quality 4.1 Definition For executing web services, there should be no semantic and technical problems in processing a message transmitted between a service provider and a service consumer. No semantic problem refers to the process when a receiver understands a message in the exact meaning as the sender intended. A prerequisite condition for the mutual understanding of semantics in a message, the name of service, the name and type of parameters, the type of return values are consistent between a service provider and a service consumer. This prerequisite condition may be satisfied if the service consumer implemented its system exactly according to the information of a service description (i.e. WSDL). But, this requires an agreement between all service parties for using service contents such as the name of items in e-documents and codes without any semantic problems. No technical problem refers to the conditions when all components for messaging including transport, security, reliability, encoding, and message structure coincide during implementation. Two systems of communication parties are said to be interoperable when they exchange and use information as if both could operate appropriately on the same platform. Implementing the messaging technology adopts related standards for assuring interoperability. If there is no standard available, one of service associates could adjust its technical implementation to the other’s or both can agree to match their implementation specifications bilaterally. However, if a standard exists, the service associates can achieve interoperability by adjusting their implementation to the standard specification. Even though a service associate follows a standard, interoperability problems could arise in the case that an implementer misunderstands the standard or implements a module with a different intention. In some cases, the implementer may add new functions not described in the standard arbitrary. However this difference of a platform or network device could damage the interoperability between the two parties. Considering the above cases, we can categorize the problems of interoperability into 3 groups: ① a system which has been implemented by not adopting a standard, ② a system which has been implemented according to a standard, with some functions implemented without regard to the standard, ③ a system which has been implemented according to standards properly, but which has a problem of interoperability due to difference of platform of network. All of these issues must be considered in evaluating interoperability of a service system. Interoperability quality includes standard adoptability, standard conformability and relative proofness as shown in <Figure 4-1>. Standard Adoptability of web services evaluates how many functions of a web service are implemented by adopting related standards. The function of a web service means necessary requirements such as user authentication, data encryption, service delivery, transaction processing, etc. They could also include the original features of the business such as codes, document formats, business terms etc. Standard conformability of a web service evaluates whether the standards adopted to implement the functions of the web service conforms completely and correctly to the specification of the standards. Relative proofness evaluates whether a client and a service can communicate successfully on specific platforms. --- ![Interoperability of web services](image-url) 4.2 Sub Quality Factors 4.2.1 Standard Adoptability In order to guarantee interoperability of web services, functions of a web service should be implemented by adopting related standards. Standard Adoptability is measured by the ratio of functions which are implemented by adopting related standards. Standard adoption function $f$ is defined on the set of functions $X = \{x_1, \ldots, x_n\}$ of a web service $S$ and returns one of binary values, 0 and 1. $f$ is formulated as follows: $$f(x_i) = \begin{cases} 1 & \text{if function } x_i \text{ is implemented by adopting related standards} \\ 0 & \text{otherwise} \end{cases}$$ Based on the standard adoption function $f$, standard adoptability of web service $S$ is defined as follows: $$\text{StandardAdoptability}(S) = \frac{\sum_{i=1}^{n} f(x_i)}{n}$$ 4.2.2 Standard Conformability Assuming that a web service $S$ has $n$ functions, and only $m$ functions of them are implemented by adopting related standards. Standard conformability function $g$ is defined by the set of standard adopted functions $X_a = \{x_1, \ldots, x_m\}$ of web service $S$ and returns one of binary values, 0 and 1. $g$ is defined as follows: $$g(x_i) = \begin{cases} 1 & \text{if function } x_i \text{ conforms all adopted standards} \\ 0 & \text{otherwise} \end{cases}$$ Based on the standard conformability function, standard conformability of web service $S$ is defined as follows: $$\text{StandardConformability}(S) = \frac{\sum_{i=1}^{m} g(x_i)}{m}$$ 4.2.3 Relative Proofness Relative proofness indicates that web services are successful in exchanging and using the information between two special system platforms. In real environments, services based on a technology platform cannot be fully interoperable with other services on a different technology platform even if a standard conformability test is passed. Whether the functions of web services are implemented by standards, vendor specification or non-standards, relative proofness of service interoperability is tested and verified in a real service platform that satisfies specific environments. VPI (Verified Platform Information) represents the basic information of an opponent's platform and additional descriptions of the verification when web services are tested and verified in real service environments of the opponent's platform. $$\text{Relative Proofness} = \{\text{VPI}_1, \text{VPI}_2, \ldots, \text{VPI}_n\}, \text{where } n \text{ is the number of platforms verified}$$ 4.3 Relationships to other Standards - WS-I Basic Profile 1.1 This is a profile for interoperability of SOAP, WSDL, UDDI and is administered by WS-I. URL: http://www.ws-i.org/Profiles/BasicProfile-1.1.html - WS-I Basic Profile 1.2 This is a profile for interoperability of SOAP, WSDL, UDDI and is administered by WS-I. URL: http://ws-i.org/profiles/BasicProfile-2.0-WGD.html - WS-I Basic Security Profile Version 1.0 This is a profile for interoperability of web services security and is administered by WS-I. URL: http://www.ws-i.org/Profiles/BasicSecurityProfile-1.0-2007-03-30.html - WS-I Basic Security Profile Version 1.1 This is a profile for interoperability of web services security and is administered by WS-I. URL: http://www.ws-i.org/Profiles/BasicSecurityProfile-1.1.html - WS-I Reliable Secure Profile 1.2 This is a profile for interoperability of reliable message and secured transmission and is administered by WS-I. (WS-ReliableMessaging 1.1, WS-SecureConversation 1.3) URL: http://www.ws-i.org/Profiles/ReliableSecureProfile-1.0.html - WS-I Simple SOAP Binding Profile Version 1.2 This is a profile for interoperability of SOAP Binding and is administered by WS-I. URL: http://www.ws-i.org/Profiles/SimpleSoapBindingProfile-1.0.html 5 Business Processing Quality 5.1 Definition As the applying areas of web services are growing on a wide scale, the cases that use them in communication between service units (i.e., enterprise, department, agency, program, division) are increasing rapidly. Applying web services in business means that the service unit executing them has to take responsibility of the execution result. For applying web services in business, the intention of service providers and consumers has to be reflected correctly in business results. A service unit can assure correctness and reliability in the business context for business processing. In order to achieve this, a web service platform for business should possess functions of reliable messaging, transaction processing, and collaborability. These functions could be optionally used according to the requirement of a service unit. Accordingly, business processing quality is defined as the capability of a web service platform for assuring correctness and reliability in business processing. 5.2 Sub Quality Factors 5.2.1 Messaging Reliability Most networks and their communication channels are not fairly reliable in real world. They are exposed to unexpected circumstance variances, internal system errors and inexperienced users. As a result, the messages for service requests and response could be lost and duplicated and their sequence confused. These cases would cause serious results in business, which could give a fatal blow to a service unit. Messaging reliability refers to the capability for messaging functionality which ensures the intention of messaging for service units. The level of messaging reliability depends on the requirement of service units. For example, a service unit could require a very restrict level of reliability in which a message is transferred once and only once at any case (i.e. money transfer). In some cases, a service unit requires at least one message transferred (i.e. request message for search). The sequence of messages could be disregarded (i.e. request for an invoice). On the other hand, the sequence of messages could have major effects to a business (i.e. request for stock trading). The level of messaging reliability could be determined by the agreement of parties participating in a business relationship. The business parties MUST provide the reliability functions which guarantee the level of reliability more than the level agreed. The messaging reliability includes 4 basic factors, which can be combined. Certain combinations are of particular interest due to their widespread application: exactly once and ordered (also referred to as exactly once ordered). - Transmitting at least once (guaranteed delivery) Every message MUST be transmitted at least once or an error MUST be raised on at least one endpoint. Some messages SHOULD be delivered more than once until an Acknowledgement is received from the receiver. Each message MUST be transmitted at least once, otherwise both receiver and sender MUST issue an error message. In addition, the sender MUST keep retransmitting the message until Ack is received from the receiver. - Transmitting at most once (guaranteed duplicate elimination) Each Message MUST be transmitted at most once without duplication. Otherwise an error will be raised on at least one endpoint. The receiver MUST block the duplicated message. Each message MUST be transmitted at most once. The receiver MUST block the duplicated message. Each message MUST be transmitted precisely once, otherwise both receiver and sender MUST issue an error message. In addition, the sender MUST keep retransmitting the message until Ack is received from the receiver. The receiver MUST block the duplicated message. - Transmitting precisely once (guaranteed delivery and duplicate elimination) Each message MUST be transmitted precisely once, otherwise both receiver and sender MUST issue an error message. In addition, the sender MUST keep retransmitting the message until an Acknowledgement is received from the receiver. The receiver MUST block the duplicated message. This delivery assurance is the logical "and" for the two prior delivery assurances. - Transmitting sequentially (guaranteed delivery order) Messages in sequence MUST be transmitted from where they are created to the receivers who the messages are intended to be orderly delivered to. To do this, the sender MUST sequentially send the message with message sequence information embedded in the messages. And the receiver would have to be able to rearrange the messages according to sequence information embedded in the messages. ### 5.2.2 Transaction Integrity Transactions running across multiple services over multiple domains need to maintain business integrity. Traditionally, a transaction is a business processing unit (a unit of work) that involves one or more services and is either completed in this entirety or is not done at all. Transaction integrity refers to whether a service has functionality for processing transactions or a transaction integrity platform environment can be applied. The transaction model of web services can be divided into either a short-term transaction (atomic transaction) or a long-term transaction (business activity). #### Short-term transaction (atomic transaction, all-or-nothing property) Short-term transaction is a transaction which requires a service locked for a short period of time such as purchasing a book online. The major function of the transaction is to reset to default when a request of the transaction is not processed or a request of a transaction is processed so that all the changes resulting from the transaction are applied. This transaction is also called an Atomic transaction and MUST satisfy the following 4 ACID (Atomicity, Consistency, Isolation, and Durability) requisites. - Atomicity The transaction completes successfully (commits) or if it fails (aborts), all of its effects are undone (roll-back) - Consistency Transactions produce consistent results and preserve application specific invariants - Isolation The results of a task are not shared with other transactions unless it is successfully completed. - Durability Once a transaction is successfully completed, its results SHOULD be permanently applied to a system. #### Long-term transaction (long-running transaction) Long-term transaction refers to a transaction which requires a longer processing time or its resources cannot be locked exclusively during processing. It is also referred to business activity. Because a long-term transaction consists of some short-term transactions or independent web services, Commit or Roll-back mechanisms of short-term transactions cannot be used. Therefore, long-term transaction quality is evaluated by the following criteria, not by ACID attributes. - Consistency Long-term transaction SHOULD be able to change consistently the status of participating systems. - Compensatory Long-term transaction MUST support an independent and alternative flow to compensate for failed transactions. Because long-term transactions consist of some short-term transactions or independent web services, an alternative flow of processing is needed without individual processes being reset to default. 5.2.3 Collaborability The application of web service collaboration is prevalent to implement business processes. A business process can be defined as the execution of activities according to a defined set of rules in order to achieve a common goal between participants. Collaborability is the capability of a service platform to define, control and manage service flow between participants. There are two types of collaborability: orchestration which is executed or coordinated by single conductor and choreography which is executed or coordinated by multiple participants. - Orchestration Orchestration is a technique used to compose hierarchical and self-contained service-oriented business processes that are executed and coordinated by a single agent acting in a "conductor" role [OASIS, Reference Architecture for Service Oriented Architecture]. In other words, orchestration is the technique to define and execute a flow or procedure of services to achieve business processing. An orchestration is typically implemented using a scripting approach to compose service-oriented business processes. This typically involves use of a standards-based orchestration scripting language. An example of such a language is the Web Services Business Process Execution Language (WS-BPEL) [WS-BPEL]. - Choreography Choreography is a technique used to characterize and to compose service-oriented business collaborations based on ordered message exchanges between participants in order to achieve a common business goal. [OASIS, Reference Architecture for Service Oriented Architecture] In other words, choreography defines the sequence and dependencies of interactions between multiple participants to implement a business process composing multiple web services. Choreography differs from orchestration primarily in that each party in a business collaboration describes its part in the service interaction in terms of public message exchanges that occur between the multiple parties as standard atomic or composite services, rather than as specific service-oriented business processes that a single conductor/coordinator (e.g., orchestration engine) executes [OASIS, Reference Architecture for Service Oriented Architecture]. To be specific, choreography describes the sequence of interactions for web service messages. WSDL describes the static interface and choreography defines the dynamic behavior external interface. It is the Peer-to-Peer collaboration model of exchanging messages among related partners as a part of a bigger business transaction with many participants. 5.3 Relationship to other Standards - WS-Reliability 1.1 WS-Reliability is a SOAP-based protocol for exchanging SOAP messages with guaranteed delivery, no duplicates, and guaranteed message ordering. URL: http://docs.oasis-open.org/wsrmas-wsreliability/v1.1/wsrmas-wsreliability-1.1-spec-os.pdf - WS-ReliableMessaging 1.2 WS-Reliable Messaging is a protocol that allows messages to be transferred reliably between nodes implementing this protocol in the presence of software component, system, or network failures. URL: http://docs.oasis-open.org/wsrma-wsrma/200702/wsrma-1.2-spec-os.html - WS-Context 1.0 WS-Context provides a definition, structuring mechanism, and service definitions for organizing and sharing context across multiple execution endpoints. URL: http://docs.oasis-open.org/wsfwsc-ws-context/v1.0/wstx.html - WS-Coordination 1.2 WS-Coordination specifies an extensible framework for providing protocols that coordinate the actions of distributed applications. URL: http://docs.oasis-open.org/wsfwsc-wscoor/v1.2-spec.html • WS-AtomicTransaction 1.2 WS-AtomicTransaction specifies the definition of the Atomic Transaction coordination type that is to be used with the extensible coordination framework described in WS-Coordination. URL: http://docs.oasis-open.org/ws-tx/wstx-wsat-1.2-spec-os/wstx-wsat-1.2-spec-os.html • WS-BusinessActivity 1.2 WS-BusinessActivity specifies the definition of two Business Activity coordination types: AtomicOutcome or MixedOutcome, that are to be used with the extensible coordination framework described in the WS-Coordination specification. URL: http://docs.oasis-open.org/ws-tx/wstx-wsba-1.2-spec-os/wstx-wsba-1.2-spec-os.html • WSBPEL 2.0 WSBPEL describes a business process activity using web services and defines the way they are linked with each other. Using Orchestration, business process collaboration is composed. WS-BPEL 2.0 is approved as OASIS standard. URL: http://docs.oasis-open.org/wsbpel/2.0/OS/wsbpel-v2.0-OS.html • WS-CDL 1.0 Web Services Choreography Description Language is a language to describe XML based web services collaboration as choreography. It is a standard for the decentralized business process. URL: http://www.w3.org/TR/2005/CR-ws-cdl-10-20051109/ 6 Manageability Quality 6.1 Definition The more web services gain weight in business, the more the web service management scheme is needed for maintaining web service quality. Web service can be managed not only locally by a web service manager or provider, but also remotely by a consumer and a third party system. Web service management may be a prerequisite for the foundation of trust between a service consumer and a provider. Manageability is defined as an ability which keeps a web service and its resources being manageable. At this point, the web service resource includes the software and hardware components used by the web service and a platform on which the web service operates. Manageability can be achieved by implementing manageability capabilities, which are exposed as an access point, for each web service. A manageability implementation means an implementation of a manageability endpoint and all of its manageability capabilities. The manageability capability helps targeting a web service, provides a function to monitor operational status, and controls operations along with web service protocol. As the manageability capability enables a service consumer to use web services with reliability and stability, it may be an important criterion for one to select a web service. The manageability is classified into 3 sub-factors: informability, observability and controllability. 6.2 Sub Quality Factors 6.2.1 Informability The management of a web service requires the primitive information to be settled in the implementation phase in order to cope with troubles and to support a web service operation. Informability is a sub-quality factor to measure whether the primitive information can provide enough to manage a web service. The primitive information for managing a web service is divided into the manageability access information, assessment of web service management capability and the web service primitive information. - Manageability access information The manageability capabilities are exposed as a web service access endpoint thus a manageability consumer SHOULD get the access point for managing a web service and manageability access information. There are two ways to achieve this. One is to implement an additional web service whose functionality is to return a manageability endpoint for managing a web service. The other is to implement each web service equipped with an operation which returns its own manageability endpoint. The former has a disadvantage that a consumer has to know previously the reference of a web service which informs the access point of manageability capabilities. In the latter, a web service developer is burdened to implement an additional operation to inform the manageability endpoint. By utilizing both, a manageability consumer SHOULD get the manageability endpoint precisely through simple web service interface. - Web service primitive information The manageability capability can provide primitive information of a web service to be managed. The primitive information includes web service properties (e.g. protocol version number, encryption algorithm, messaging pattern, etc), description of web services and their resources, characteristics of a manageability implementation, relation information between web services and resource. The manageability endpoint SHOULD also have an identity capability to discriminate whether two web services are the same by referring to their identity information. 6.2.2 Observability Observability measures how effectively a manageability implementation can provide status information of a web service. The status of a web service system can be revealed by gathering the values of... performance metrics. Therefore, observability can be evaluated by how effectively the metrics are taken when gathering information. The effectiveness of gathering metrics is represented in three aspects: - How much are metrics provided? - How exactly metrics are provided? - Are the metrics provided in real-time? A manageability consumer can get the status information by two methods: monitoring and notification. In the former, he can request the information anytime to a manageability endpoint actively, then a corresponding manageability capability returns a metric value based on monitoring results. In the latter, a manageability consumer subscribes previously significant events or issues to be notified. Then, when a subscribed event or trouble occurs, he will be notified. The target information to be observed includes all the operational status information such as performance metrics, a utilization ratio of memory, and a history of messages. ### 6.2.3 Controllability There may be a case that a web service and its resources have to be regulated for keeping a stable status or coping with performance degradation. For example, a manageability consumer may increase the size of a web service message queue when there are too many messages received at the same time. If there is an error found in the messaging process, a web service platform SHOULD be stopped to cope with the problem. Thus, Controllability measures whether a manageability implementation can provide enough control functions to keep a web service in controllable status. The control functions are classified into operation control functions and configuration control functions. - **Operation control functions** These are to change an operational status of a web service by executing commands such as start, stop, fork, and exit to the web service or related resources. - **Configuration control functions** These are to modify the value of configuration parameters. For example, according to the change of a circumstance, a manageability consumer wants to adjust the value of a web service configuration such as a queue size, an encoding method and an encryption algorithm. For measuring controllability, the scope, stability, voluntary, and easiness of control functions in a manageability implementation MUST be evaluated. ### 6.3 Relationship to other Standards - **W3C Web Services Architecture** It defines the structure of web services including the state model of web services and the structure for management. The standardization was completed in January, 2004. It consists of Web Services Architecture for defining web services structure, Web Services Usage Scenarios, and Web Services Management: Services Life Cycle for defining the state model of web services. URL: [http://www.w3.org/TR/ws-arch/](http://www.w3.org/TR/ws-arch/) - **OASIS Web Services Notification (WSN) v1.3** WSN is the OASIS standard to define the mechanism of asynchronous message exchange using an event. It was completed in October, 2006. It consists of WS-BaseNotification to define the message exchange mechanism of basic event method, WS-BrokeredNotification to define the asynchronous message exchange mechanism using the broker like MOM and WS-Topics for exchanging the event information. URL: [http://www.oasis-open.org/specs/#wsnv1.3](http://www.oasis-open.org/specs/#wsnv1.3) - **OASIS Web Services Resource Framework (WSRF) v1.2** WSRF proposes the common framework for managing various resources that exist on networks. It was completed on April, 2006. It consists of WS-Resource to define resources, WS-ResourceProperties to define exchange method of the resources, WS-ResourceLifetime to define lifecycle of the resources, WS-ServiceGroup for define the way for managing the numerous resources as a group and WS-BaseFaults to define basic malfunctions that can occur during the attributes management process. Although WS-Resource Metadata Descriptor is not approved as a standard, it is very important for managing web services and is being used in TC such as WSDM. URL: http://www.oasis-open.org/specs/#wsrfv1.2 OASIS Web Services Distributes Management (WSDM) v1.1 WSDM proposes the framework for managing various resources on networks. It consists of MUWS (Management Using Web Services) and MOWS (Management of Web Services). URL: http://www.oasis-open.org/specs/#wsdmv1.1 7 Security Quality 7.1 Definition Security quality is the degree of ability that can protect web services from various threats on confidentiality, integrity and availability. Typical threats on web services environment are unauthorized access, exposure, forgery and destruction of web services. These security threats can destroy web services environment by identity theft, forgery of financial data and blockage of services. Therefore, security quality is becoming significantly critical and essential for web service. This security quality should be considered on two technical perspectives. - Transport Level Security Transport level security is to provide a secure data transfer on the transport layer. This is regardless of the characteristics and complexities of web services because its implementation is based on transport layer protocols and web services are applied on the application layer. Because security on the parts of a message is not supported, it has a limitation that the security cannot be guaranteed during intermediary processing. - Message Level Security Message level security is a method which provides security service using XML based message to provide confidentiality and integrity of SOAP messages. Message level security uses End-To-End model, thus it provides persistent security. The sub quality factors of the security quality include encryption, authentication, authorization, integrity, availability, audit, non-repudiation and privacy. Each quality factor is related to confidentiality, Integrity and availability. 7.2 Sub Quality Factor 7.2.1 Encryption Encryption is data protection and disposure control on web services with cryptographic functionality to prevent unauthorized user access of confidential or sensitive information. Frequently ‘encryption’ is regarded as ‘confidentiality’ in a narrow sense. - Transport Level Encryption Transport level encryption supports only the encryption of the entire message, using the cryptographic features provided by SSL, TLS or IPSec protocol. It ensures confidentiality of data when sending and receiving the data on the transport layer. However, if it has any intermediary processing, the data should be decrypted and revealed to the intermediary. - Message Level Encryption To ensure confidentiality of web services’ message, message level encryption is provided by either the XML-Encryption or the cryptographic functionality (e.g. PGP for the attachment) in the WS-Security. Especially, the XML-Encryption can encrypt the part of the message with the WS-SecurityPolicy along with message protection policy, thus confidentiality of the service on transport level can be improved. Firstly, the encryption quality can be measured by whether the encryption feature is applied or not. If the encryption feature is applied, the strength of the encryption function (e.g. AES-128-CBC is a stronger encryption algorithm than 3DES-CBC.), the size of encryption key, or the life cycle of key will affect the encryption quality. 7.2.2 Authentication Authentication is the identification of services’ consumer/provider and the verification of the credential that can be assured by the identification and trusted for the transmission. - Transport Level Authentication Transport level authentication is the same method as traditional web environment. Normally the authentication method is ID/Password, X.509 based certificate, Kerberos and so on. And transport level authentication is an authentication under point-to-point model. Thus, if it has no intermediary processing, it can be trusted and provide many vendors with good interoperability. But, if intermediary processing exists, the consumer’s credential cannot be trusted and the provider cannot know who the first origin is, because the identification is propagated and changed. - Message Level Authentication Message level authentication is an XML message based authentication using standard of W3C such as WS-Security. Message level authentication method is sometimes similar to transport level authentication. It can use ID/Password, X.509 based certificate token, or Kerberos token just inserted in XML. And for more secure requirements and standard based interoperability, a more special authentication method is used with XML token such as SAML, WS-Federation, Liberty, and so on. But, because the interconversion is not supported among XML tokens, the provider must consider STS (Security Token Service) in WS-Trust specification under the mixed XML token environment. The authentication quality can be measured by whether the authentication feature is applied or not. And it can be the strength of the implementation of authentication method such as password policy, multi-factor authentication or the possibility of bypass in an authentication mechanism. 7.2.3 Authorization Authorization is the control over access on service/message for each actor’s right. It is used to support Confidentiality and Integrity. It uses various policies, access control models and security levels as means of support of Authorization. - Transport Level Authorization Transport level authorization refers to the access control on the resources of users of the transport channel. It is implemented on application, middleware – web application server, directory, or security device using various security models such as RBAC (Rule based access control) and so on. In this case, the Transport level authorization has the same limitation as the point-to-point model. In essence the transport level authorization is decentralized control. Thus, Origin authorization policy cannot persist under transport level authorization with intermediary processing. - Message Level Authorization Message level authorization is the XML messaged based authorization using standard of W3C such as WS-Security. It is represented with XACML as service authorization policy and WS-SecurityPolicy as message protected policy. Moreover, it can be encapsulated with the access right defined as XACML or SAML to carry XACML. Using this function, the access right over the actual resources is controlled. The authorization quality can be measured by whether the authorization feature is applied or not. It can be the possible bypass in an authorization mechanism. 7.2.4 Integrity Integrity is to protect from unauthorized service/message modify, delete and create. It uses access control and briefing message. - Transport Level Data Integrity Transport level data integrity refers to a feature such as the packet comparison and message digest provided by IPSEC or TLS to provide the data integrity when sending and receiving data between transport channels. - Message Level Data Integrity Message level data integrity refers to the data integrity of SOAP message level. It can be guaranteed by XML-Signature in WS-Security. Also, XKMS to manage the digital signature for the data integrity can be used. The Integrity quality can be measured by whether the integrity feature is applied or not. ### 7.2.5 Non-Repudiation Non-repudiation is to prevent receivers and senders from denying that they send and receive messages. It uses digital-signature for non-repudiation. - Transport Level Non-Repudiation Under the transport layer, non-repudiation cannot be built using digital-signature. Usually it is included in application or business logic. Hence, we do not mention non-repudiation of transport level here. - Message Level Non-Repudiation Message level non-repudiation- can be built using XML-Signature in WS-Security. XKMS is used to manage the digital signature for non-repudiation on the transport level. The non-repudiation quality of the message level can be measured by whether the non-repudiation feature is applied or not. ### 7.2.6 Availability Availability is to allow only authorized consumers to access service whenever they need. The techniques such as IDS, IPS or Anti-DoS(Denial of Services) can be implemented to ensure availability. - Transport Level Availability Transport level availability refers to service continuity on the transport layer to prevent exhausting web resources by excessive or malicious requests which can make services unavailable. It is established by surveilling the packets with IDS, IPS or Anti-DoS equipment on the transport layer. - Message Level Availability Message level availability refers to service continuity on the message level to protect malicious XML messages which can make services unavailable. It is accomplished by filtering and verifying messages on the application level or XML firewall. The availability quality can be measured by whether the availability feature is applied or not. ### 7.2.7 Audit Audit is the capability to trace and verify activities and events on web services providing and consuming. During the security audit process, security vulnerability or security attack can be identified from the traced information. - Transport Level Audit Transport level audit is to trace and verify send/receive information on transport layer. - Message Level Audit Message level audit is to trace and verify request/response message on the application layer. The audit quality can be measured by whether the audit feature is applied or not. ### 7.2.8 Privacy Privacy is the protection of sensitive information of web services consumers and providers. To support privacy, it is necessary to guarantee above, the sub quality factors of security quality. Additionally privacy policy is required in compliance with law and regulations related with privacy. The privacy quality can be measured by whether the protection of privacy information is implemented and the privacy policy is defined appropriately. ### 7.3 Relationship to other Standards - **W3C XML Signature** - XML digital signature standard - URL: [http://www.w3.org/TR/xmlsig-core/](http://www.w3.org/TR/xmlsig-core/) - **W3C XML Encryption** - XML encryption standard - URL: [http://www.w3.org/TR/xmlenc-core/](http://www.w3.org/TR/xmlenc-core/) - **W3C XKMS (XML Key Management Specification)** - Key management service standard which makes the integration between PKI and XML application easy - URL: [http://www.w3.org/2001/XKMS/](http://www.w3.org/2001/XKMS/) - The standard to provide the authentication, integrity, non-repudiation, and confidentiality of SOAP - **OASIS WS-SecurityPolicy (Web Services Policy)** - The standard to provide the security policy applied on WS-Security. - URL: [http://docs.oasis-open.org/wss-xsws-securitypolicy/200702/wss-securitypolicy-1.2-spec-os.html](http://docs.oasis-open.org/wss-xsws-securitypolicy/200702/wss-securitypolicy-1.2-spec-os.html) - **OASIS SAML (Security Assertion Markup Language)** - The standard to reliably exchange the authentication and approval information based on XML - **OASIS XACML (eXtensible Access Control Markup Language)** - The access control standard that consists of XML based policy language and access control decision, request/response language - **MS, VeriSign, BEA, IBM WS-Trust (Web Services Trust Language)** - The standard about issuing and exchange the security token and configuring trust relationship in various trust domains - URL: [http://docs.oasis-open.org/ws-sx/ws-trust/v1.4/os/ws-trust-1.4-spec-os.html](http://docs.oasis-open.org/ws-sx/ws-trust/v1.4/os/ws-trust-1.4-spec-os.html) - **MS, VeriSign, BEA, IBM WS-Federation (Web Services Federation Language)** - The mechanism definition to intervene user identification, attributes, and authentication among web services applications what belong to different security domains. - URL: [http://docs.oasis-open.org/wsfed/federation/v1.2/os/ws-federation-1.2-spec-os.html](http://docs.oasis-open.org/wsfed/federation/v1.2/os/ws-federation-1.2-spec-os.html) 8 Conformance A product, document or service conforms to this specification if it adopts or provides all the quality factors and sub quality factors in this specification. If there are some quality factors or sub quality factors with no value or not adopted in a product, then they should be supplied with no value or the value indicating “not applicable” such as N/A. The name and meaning of each quality factor or sub quality factor should not be changed. It is possible to include additional quality factors or sub quality factors which are not given in this specification. For the adopted or provided quality factors, a product, document or service should satisfy all of the MUST or REQUIRED level requirements defined in the part of the quality factors in this specification. Appendix A. Acknowledgments The following individuals have participated in the creation of this specification and are gratefully acknowledged: Participants: - Eunju Kim, National Information Society Agency - Yongkon Lee, Individual - Yeongho Kim, Daewoo Information Systems - Hyungkeun Park, IBM - Jongwoo Kim, Individual - Byoungsun Moon, Individual - Junghee Yun, National Information Society Agency - Guil Kang, National Information Society Agency External Contributors: - Dugki Min, Konkuk University - Mujeong An, LG CNS - Sojung Kim, National University of Singapore
{"Source-Url": "http://docs.oasis-open.org/wsqm/WS-Quality-Factors/v1.0/cs01/WS-Quality-Factors-v1.0-cs01.pdf", "len_cl100k_base": 14104, "olmocr-version": "0.1.53", "pdf-total-pages": 29, "total-fallback-pages": 0, "total-input-tokens": 100355, "total-output-tokens": 15835, "length": "2e13", "weborganizer": {"__label__adult": 0.0003476142883300781, "__label__art_design": 0.0005640983581542969, "__label__crime_law": 0.0005540847778320312, "__label__education_jobs": 0.0013179779052734375, "__label__entertainment": 0.00013005733489990234, "__label__fashion_beauty": 0.00015044212341308594, "__label__finance_business": 0.001987457275390625, "__label__food_dining": 0.0002589225769042969, "__label__games": 0.0006246566772460938, "__label__hardware": 0.0009465217590332032, "__label__health": 0.00031447410583496094, "__label__history": 0.0003113746643066406, "__label__home_hobbies": 8.0108642578125e-05, "__label__industrial": 0.0003066062927246094, "__label__literature": 0.00047659873962402344, "__label__politics": 0.0003497600555419922, "__label__religion": 0.00040531158447265625, "__label__science_tech": 0.042999267578125, "__label__social_life": 0.00012993812561035156, "__label__software": 0.03509521484375, "__label__software_dev": 0.912109375, "__label__sports_fitness": 0.00017893314361572266, "__label__transportation": 0.00039505958557128906, "__label__travel": 0.00021541118621826172}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 73869, 0.03096]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 73869, 0.28658]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 73869, 0.88935]], "google_gemma-3-12b-it_contains_pii": [[0, 855, false], [855, 2173, null], [2173, 6088, null], [6088, 11347, null], [11347, 11882, null], [11882, 13935, null], [13935, 19000, null], [19000, 19930, null], [19930, 24047, null], [24047, 27960, null], [27960, 30408, null], [30408, 31991, null], [31991, 32549, null], [32549, 36078, null], [36078, 38573, null], [38573, 39855, null], [39855, 43675, null], [43675, 47137, null], [47137, 50759, null], [50759, 51966, null], [51966, 55671, null], [55671, 59390, null], [59390, 60076, null], [60076, 63101, null], [63101, 66550, null], [66550, 69336, null], [69336, 72509, null], [72509, 73292, null], [73292, 73869, null]], "google_gemma-3-12b-it_is_public_document": [[0, 855, true], [855, 2173, null], [2173, 6088, null], [6088, 11347, null], [11347, 11882, null], [11882, 13935, null], [13935, 19000, null], [19000, 19930, null], [19930, 24047, null], [24047, 27960, null], [27960, 30408, null], [30408, 31991, null], [31991, 32549, null], [32549, 36078, null], [36078, 38573, null], [38573, 39855, null], [39855, 43675, null], [43675, 47137, null], [47137, 50759, null], [50759, 51966, null], [51966, 55671, null], [55671, 59390, null], [59390, 60076, null], [60076, 63101, null], [63101, 66550, null], [66550, 69336, null], [69336, 72509, null], [72509, 73292, null], [73292, 73869, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 73869, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 73869, null]], "pdf_page_numbers": [[0, 855, 1], [855, 2173, 2], [2173, 6088, 3], [6088, 11347, 4], [11347, 11882, 5], [11882, 13935, 6], [13935, 19000, 7], [19000, 19930, 8], [19930, 24047, 9], [24047, 27960, 10], [27960, 30408, 11], [30408, 31991, 12], [31991, 32549, 13], [32549, 36078, 14], [36078, 38573, 15], [38573, 39855, 16], [39855, 43675, 17], [43675, 47137, 18], [47137, 50759, 19], [50759, 51966, 20], [51966, 55671, 21], [55671, 59390, 22], [59390, 60076, 23], [60076, 63101, 24], [63101, 66550, 25], [66550, 69336, 26], [69336, 72509, 27], [72509, 73292, 28], [73292, 73869, 29]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 73869, 0.02347]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
97520ab545a9e3ba216140fa61e8d0de62c548de
ABSTRACT In the process of platform attestation, a Trusted Platform Module is a performance bottleneck, which causes enormous delays if multiple simultaneously attestation requests arrive in a short period of time. In this paper we show how the scalability of platform attestation can be improved. In this context, we propose three protocols that enable fast and secure integrity reporting for servers that have to handle many attestation requests. We implemented all of our protocols and compared them in terms of security and performance. Our proposed protocols enable a highly frequented entity to timely answer incoming attestation requests. Categories and Subject Descriptors General Terms Security Keywords Remote Attestation, Trusted Computing, Performance, Scalability, Attestation Protocols, Integrity Reporting 1. INTRODUCTION The Trusted Computing Group (TCG) is a non-profit organization that defines open standards for hardware-enabled trusted computing and security technologies. A core component of the specifications issued by the TCG is the Trusted Platform Module (TPM) [?], which can be viewed as functionally equivalent to a high-end smart card. The TPM can be used to significantly enhance system security, since it offers means of storing cryptographic keys in a protected manner and is able to establish trust relationships between remote entities [?]. To enable the establishment of trust relationships between two different entities, the TPM provides a mechanism to obtain software integrity measurements and to store these measurements in shielded locations called Platform Configuration Registers (PCR). These measurements can be reported to a remote entity through the process of platform attestation, which provides a proof of authenticity of the measurements. This process is crucial for ensuring endpoint integrity and thus the trustworthiness of an entity to which confidential data is transferred. Example scenarios that can utilize these concepts include Electronic Commerce, E-Government and Information Rights Management. The process of remote attestation and the requirements of protocols that support secure integrity reporting have been investigated in the literature [?]. In this context, all proposed solutions require the TPM to perform one expensive asymmetric cryptographic operation for each entity that is requesting integrity information. One reason for the high complexity is that a verifying entity has to ensure freshness of the integrity information, which is achieved by a challenge-response authentication involving the TPM. However, since the TPM is very limited in its computation power, the computation of one asymmetric operation takes between one and three seconds [?]. This causes the process of remote attestation to scale very poorly, which is particularly problematic if an entity is highly frequented and distributes integrity measurements to many clients (such as a server from which all clients request integrity information before they start using a particular service). In this paper we present protocols that allow to overcome the performance bottleneck of a TPM, so that an entity is able to frequently report its integrity to many clients. To this end, we propose three different protocols that utilize different mechanisms of the TPM: the first protocol extends the most widely used platform attestation by bundling a number of attestation requests and answering them with one TPM operation; the second protocol requires a Trusted Third Party and utilizes hash-chains; and the third protocol realizes integrity reporting using time synchronized timestamps. Our developed protocols do not require new trusted computing technology or modifications to the TPM specifi- cation. We have implemented all of our proposed protocols and have run simulations on currently available hardware TPMs. The simulations clearly indicate that the developed protocols are able to overcome the performance bottleneck of a TPM and can thus be used in environments where an entity is heavily exposed to integrity reporting queries. The remainder of this paper is organized as follows. In Section ?? we review related work, showing that all existing protocols scale poorly and thus cannot be used in highly frequented environments. Section ?? presents the assumptions and notations for our work. In Section ?? we present our protocols which enable a highly frequented entity to report its integrity. In Section ?? we analyze the security of our proposed solutions and in Section ?? we evaluate the protocols by looking at performance issues. Finally, we conclude in Section ??. 2. RELATED WORK Löhr et al. [?] present key components for scalable offline attestation. In this context, they introduce an attestation token that consists of all necessary information to make a statement whether a specific platform is trusted. This attestation token is public and can thus be shared amongst other entities. However, to verify that a specific platform configuration is trusted and to obtain a proof that a specific attestation token belongs to a specific platform, expensive TPM operations are required. This concept is therefore not applicable in scenarios where frequent integrity verification is needed. Gasmi et al. [?] propose to include integrity information into secure channel establishment. For this purpose, they enhance the TLS-protocol with SKAE certificates [?] that additionally carry integrity information. However, their approach requires the computation of multiple expensive asymmetric cryptographic operations on the TPM on both endpoints. This again limits the usefulness in highly frequented environments due to massive performance degradations. Shi et al. [?] address the time-of-use and time-of-attestation discrepancy of the TPM-based binary attestation. This discrepancy emerges because a software component is measured before execution and not directly before attestation. To overcome this problem, the authors propose to only attest to a small piece of sensitive code and thus measure a particular piece of code immediately before execution. However, the work requires that for every established communication channel, two TPM_Seal, one TPM_Unseal and one TPM_Sign operation are computed on the TPM, thus rendering the approach inapplicable in a client–server scenario. Another approach to overcoming the bottleneck of a TPM is to use virtual TPMs [?]. A virtual TPM is a software TPM that only uses the underlying hardware TPM for certain operations. This approach significantly increases the performance of the attestation process, since the CPU is used to calculate the attestation related operations. On the downside, because the TPM is implemented in software, this approach does not offer the same security as a hardware TPM. In particular, a software TPM does not provide functions such as active shields or active security sensors for preventing unauthorized access. Another proposal [?] considers extending a TPM with hardware-based virtualization techniques and attaching the TPM to a faster BUS or integrating it directly into the CPU. Since the TPM possesses much more computation power in this approach, performance degradation in the attestation process does not occur. However, the approach requires modifications of the TPM architecture. Our work uses the TPM-based binary attestation which requires a trusted OS that performs measurements of all executed code, i.e., binary attestation. In contrast, [?] and [?] focus on semantic attestation based on attesting the behavior of software components. However, semantic attestation also requires a TCG-enhanced boot process to ensure that a small operating system kernel applies mechanisms that enforce the semantic attestation. To this end, a partially TPM-based binary attestation is required so that time degradations of the attestation process also apply to approaches based on semantic attestation. Other related work, such as [?, ?, ?] additionally require that the communication perform expensive TPM operation during the execution of the attestation protocol. 3. ASSUMPTIONS AND NOTATIONS In the following, we call the entity who wants to attest to the contents of its platform configuration the server and we call the entities that require an attestation the clients. The server is also referred to as prover, since he wants to prove to the verifier (a client) that he is in a trusted system configuration. We assume that a trusted operating system, that is either based on a virtual machine monitor [?, ?, ?] or on a microkernel [?, ?, ?], performs integrity measurements on running software. However, specifying and presenting the operating system environment is beyond the scope of this paper. We use the following notation: \( C_x \) denotes a client with \( x \in \{1, \ldots, n\} \) and \( S \) denotes a server; \( N_a \) and \( N_b \) are random nonces that are used to verify freshness and to detect impersonation. We denote a set of platform configuration registers as \( PCR \) and the Stored Measurement Log as SML. 4. SCALABLE SOLUTIONS In this section we will first highlight the shortcomings of the integrity reporting mechanisms as defined by the TCG [?]. We will then show how attestation can be used in highly-frequented scenarios. In this context, we will present three different solutions that overcome the performance bottleneck of a TPM. Figure ?? shows the delays that occur when multiple attestation requests arrive simultaneously at one server. Each attestation request includes one nonce that is generated by the challenger, to ensure freshness of the attestation reply. Every request can not be answered until the TPM has performed the TPM_Quote command, which signs a number of platform configuration registers and the nonce of the requester with an Attestation Identity Key (AIK). While the TPM performs internal computation, it is locked and does not accept any other request from the software stack. Thus, attestation requests are non-parallelizable. Incoming attestation requests are delayed until the TPM is able to process a new TPM_Quote command. We have implemented the integrity reporting protocol specified by the TCG and performed measurements on currently available TPMs (see Section ??). Our simulations on different hardware TPMs showed that single TPM_Quote operation takes about one second, which verify the results presented in [?] stating that the time required for computing one TPM_Sign operation is between one and three seconds. Figure 1 ? points out that even if a small number of clients require an attestation, massive delays will occur due to the sequential operation of the TPM. That is not only the case when the TPM_Quote command is used, but also when integrity reporting is realized implicitly through other TPM-operations, e.g., through sealing [?], or binding [?, ?]. We also ran simulations of an attestation protocol that utilizes TPM_CertifyKey combined with TPM_Unbind as proposed by L¨ohr et al. [?] and Sadeghi et al. [?]. These protocols enable platform attestation by sealing a non-migratable TPM key to a set of platform configuration registers. However, the time for computing one TPM_Unbind operation (around one second1) is comparable to computing one TPM_Quote operation. These results clearly indicate that computing asymmetric cryptography on a TPM is very expensive, making currently proposed attestation protocols hardly applicable in highly-frequented scenarios. 4.1 Multiple-Hash Attestation The Multiple-Hash Attestation protocol extends the integrity reporting defined by the TCG by bundling a number of attestation requests and answering them with one TPM_Quote operation. For this purpose, we utilize the properties of a collision resistant hash function. In particular, we map a number of incoming attestation requests to a single request whose nonce is computed as a hash of all nonces of the arriving attestation requests. Before the nonces are passed to the TPM, they are also added to a NonceList that describes which nonces were hashed to produce the target nonce. The prover then transmits the output of the TPM_Quote command together with the NonceList and the SML to all entities that issued an attestation request. Before accepting the proof, the verifier checks whether his nonce is part of the NonceList transmitted alongside the TPM_Quote output. To prevent masquerading attacks on the authenticity of the platform configuration [?], it is necessary to integrate an authentication process in the attestation protocol. These at- tacks forward the integrity measurements of a conform host to masquerade a conform system state. Therefore, our proposed protocols add a key-establishment in order to ensure that the channel of attestation is authentic. The negotiated key can then used as an encryption key for all subsequent messages sent between server and client. This mechanism also guarantees an end-to-end communication and keeps the attestation channel from becoming compromised by another application that could take over the attestation channel after the attestation has succeeded. Protocol ?? shows the resulting protocol flow. Protocol 4.1.1: Multiple-Hash Attestation 1. Precomputation by S. S selects an appropriate prime \( p \) and generator \( g \) of \( Z_p^* \) (\( 2 \leq g \leq p - 2 \)). S chooses a random secret \( s \), \( 2 \leq s \leq p - 2 \), and computes \( g^s \mod p \). S transmits \( p \) and \( g \) to all \( C_e \). 2. Precomputation by \( C_e \). \( C_e \) chooses a random secret \( c_e \), \( 2 \leq c_e \leq p - 2 \), and computes \( g^{c_e} \mod p \). 3. Attestation challenge. \( C_e, x = 1, \ldots, n \), choose a non-predictable nonce \( N_a \) and transmit message (??) to \( S \). \[ C_e \rightarrow S: \quad N_a, g^{c_e} \mod p \] 4. \( S \) adds \( N_{a1}, \ldots, N_{an} \) to the NonceList and computes: \[ \text{NonceList} = N_{a1} \parallel N_{a2} \parallel \ldots \parallel N_{an} \] 5. \( S \) then computes the attestation response message by signing the HashedNonceList and a set of PCRs using an AIK. \( S \) then transmits message (??) to \( C_e \). \[ S \rightarrow C_e: \quad \text{Cert}(AIK), \text{NonceList}, g^p \mod p, \] \[ \{\text{HashedNonceList, PCR}\}^K_{AIK} \] 6. Key confirmation. \( C_e \) computes the shared session key by computing \( K_{SC_e} = (g^{s})^{c_e} \mod p \). \( C_e \) then generates a second non-predictable nonce \( (N_{b_e}) \) and transmits message (??) to \( S \): \[ C_e \rightarrow S: \quad \{N_{b_e}, g^{c_e} \mod p\}^{K_{SC_e}} \] 7. \( S \) computes the shared session key by computing \( K_{SC_e} = (g^{s'})^{c_e} \mod p \) and decodes the received message with \( K_{SC_e} \). \( S \) then transfers message (??) to \( C_e \). \[ S \rightarrow C_e: \quad \{N_{a_e}, N_{b_e}, \text{SML}, g^{c_e} \mod p\}^{K_{SC_e}} \] 8. \( C_e \) verifies the signature of \( \{\text{HashedNonceList, PCR}\}^{K_{AIK}} \) and checks the freshness of \( N_{a_e} \), by recalculating HashedNonceList using the transmitted NonceList. Based on the received SML and the PCR values \( C_e \) processes the SML and re-computes the received PCR values. If the computed values match the signed PCR values, the SML is valid and unaltered. Finally, \( C_e \) has to verify that the delivered integrity reporting values match the given reference values; thus \( C_e \) can decide if \( S \) is in a trusted system state. --- 1. All measurements were performed on a TPM ST Microelectronics ST19WP18-TPM-C and an Atmel TPM 1.2. --- Figure 1: Delay of simultaneous arriving attestation requests The above solution works well if several attestation requests arrive at once; if they are slightly delayed, the Multiple-Hash Attestation Protocol can be optimized further. For this purpose, we introduce a ring buffer with three different areas, each consisting of one area for the NonceList and another area for the output of a TPM operation. Figure ?? depicts this tri-state ring buffer and shows how it is embedded in the attestation protocol. This tri-state ring buffer holds all relevant data for three different threads that are responsible for passing data from the verifier to the TPM and vice versa: - **Input thread**: This thread collects challenge-requests and writes them to a NonceList area of the ring buffer. - **Working thread**: This thread computes the Hashed-NonceList from the NonceList stored in one of the three areas of the buffer and executes the TPM Quote on the HashedNonceList and the PCR. The result is then written back to the same area of the buffer and the ring buffer is rotated. - **Output thread**: This thread is responsible for reading the results of the TPM operation from the buffer and for delivering the results to the corresponding clients who requested attestation. ![Tri-state ring buffer of the Multiple-Hash Attestation](image) Each time a new attestation request arrives at the server, the input thread forks a new process. This process adds the incoming nonce to the NonceList and remembers the area of the ring buffer that is responsible for the process. The working thread runs continuously; this thread is responsible for passing data to and receiving data from the TPM. As soon as the working thread receives an answer from the TPM, the working thread writes the results in the ring buffer and rotates the tri-state ring buffer. This working thread then retrieves the new NonceList of the adjacent area, which he hashes to create the HashedNonceList and passes to the TPM. While the working thread is operating on the TPM, the processes that are responsible for answering the client’s attestation-requests are waiting until the tri-state buffer has been rotated one round and their data is ready. As soon as the requested data is present in the buffer, the processes that are responsible for the attestation-request can deliver the attestation-response, consisting of the signed HashedNonceList and PCR, to the requester. This approach enables a very efficient realization of the Multiple-Hash Attestation. Since the working thread that is responsible for the TPM is also responsible for the ring buffer, a maximum utilization of the TPM can be achieved. Incoming attestation requests must wait a maximum of two rotation steps of the ring buffer before the result is available. ### 4.2 Timestamped Hash-Chain Attestation Another alternative to reduce the number of costly TPM operations is to relinquish the server from integrating every nonce of each client into the costly TPM operations. This can be achieved by involving a Trusted Third Party (TTP) that is responsible for issuing nonces for the attestation process. For this purpose, the TTP provides nonces, signatures of these nonces and timestamps that state when the TTP generated the nonces. We divide the time into intervals; each nonce together with the timestamp is associated to a particular time interval. To ensure an attestation request arrives at the server in a particular interval, the server uses the nonce which is valid in the current interval and not a nonce provided by the client. The TTP and all clients need to be loosely time-synchronized to enable the clients to verify the validity of the TTP generated nonce for a certain interval. A straightforward implementation of this idea results in a high load at the TTP. During $i$ intervals, the TTP has to generate $n \times i$ nonces and timestamps to serve $n$ servers. Since the intervals should be in the range of seconds, a TTP has to generate new nonces very frequently. To relieve the TTP from generating a nonce for each interval, we propose using hash-chains [??]. The TTP issues a nonce $Na_0$ with time-stamp only for the first time interval and the server uses the initial TTP-generated nonce $Na_0$ only for the first attestation query. After each interval the server performs a hash-operation on the nonce by applying the hash function $h$ successively to the nonce of the previous interval in order to produce the nonce of the next interval, i.e., $Na_{v+1} = h(Na_v)$, with $v = 0, 1, \ldots, k$. ![Protocol flow of the Timestamped Hash-Chain Attestation](image) Since the TTP issues a timestamp only for the first nonce, the verifying clients cannot directly validate whether the received nonce is valid in the current interval. To enable the clients to verify the validity of the nonce, the server has to provide a proof that he applied the hash function the correct number of times. Since the attestation service of the server is part of the server’s platform configuration and thus its state is included in the SML, the clients can verify that the attestation service is in a trusted state. The proof is thus being made through validating the platform configuration of the service. Figure ?? depicts the Timestamped Hash-Chain Attestation. After each interval, the server calculates a new hash-value with which the new attestation is performed. To enable the clients to validate the freshness of the platform configuration, the server delivers an attestation token (τ) to the requester. This attestation token consists of the TTP-signed seed nonce together with a timestamp, an AIK signed message with the current interval count, the nonce of the current interval, the PCRs and the public Diffie-Helman key of the server and the certificate of the AIK. The attestation token therefore consists of all information that is necessary to validate the freshness of the attestation response: \[ τ = \{N_{00}, \text{time}_0\}_K_{TP}^{−1}, \text{Cert(AIK)} \\ \{h^v(N_{00}), v, \text{PCR}, g^* \text{mod } p\}_{K_{AIK}^{−1}} \] (7) The attestation token introduced here has similarities to the one introduced in [?]. However, the main difference is that a verifier can validate the platform configuration without requiring the prover to perform expensive TPM operations. To verify that the platform configuration of the server is trusted, the clients have to verify the validity of all certificates, all signatures and the validity of the timestamp. Furthermore, the clients have to verify whether the received nonce is valid in the current active interval. For this purpose, the following equation must hold: \(\text{time}_0 + v \cdot t \leq \text{time} \leq \text{time}_0 + (v + 1) \cdot t + \epsilon\), where \(v\) represents the interval number, \(t\) the time length of the interval, and \(\text{time}\) the point of time when the TTP generated the nonce. Moreover, \(\text{time}\) denotes the current time of the verifier and \(\epsilon\) a certain error range. The time length of the interval is part of the SML and thus represented by the platform configuration of the server. The resulting protocol is shown in Protocol ??. **Protocol 4.2.1:** Timestamped Hash-Chain Attestation 1. \(S\) chooses a TTP for providing the seed nonce and the TTP transfers message (??) to \(S\). \[\text{TPP} \rightarrow S : \{N_{00}, \text{time}_0\}_K_{TP}^{−1}\] (1) 2. Precomputation by \(S\). \(S\) selects an appropriate prime \(p\) and generator \(g\) of \(Z_p^\ast\) (\(2 \leq g \leq p - 2\)). \(S\) chooses a random secret \(s\), \(2 \leq s \leq p - 2\), and computes \(g^s \text{mod } p.\) \(S\) transmits \(p\) and \(g\) to all \(C_x\). 3. Precomputation by \(C_x\). \(C_x\) chooses a random secret \(c_x, 2 \leq c_x \leq p - 2\), and computes \(g^{c_x} \text{mod } p\). 4. Attestation challenge. \(C_x, x = 1, \ldots, n\), deliver message (??) to \(S\). \[C_x \rightarrow S : \text{g}^{c_x} \text{mod } p\] (2) 5. Depending on the current interval \(v, S\) computes the current valid nonce \(N_v\) by calculating: \[N_v = h(N_{v-1}), \text{ with } v = 1, \ldots, k\] (3) 6. \(S\) computes the attestation response message by signing \(N_v\), the current interval \(\epsilon\) and the set of requested PCRs using an AIK thereby obtaining \(\{h^v(N_v), v, g^\epsilon \text{mod } p, \text{PCR}\}_{K_{AIK}^{−1}}\). 7. \(S\) transmits the attestation token \(τ\) in message (??) to \(C_x\). \[S \rightarrow C_x : \{N_v, \text{time}_0\}_K_{TP}^{−1}, \text{Cert(AIK)}, \{h^v(N_v), v, g^\epsilon \text{mod } p, \text{PCR}\}_{K_{AIK}^{−1}}\] (4) 8. Key confirmation. \(C_x\) computes the shared session key by computing \(K_{SC_x} = (g^s)^{c_x} \text{mod } p\). \(C_x\) then generates a second non-predictable nonce \((Nb_x)\) and transmits message (??) to \(S\). \[C_x \rightarrow S : \{Nb_x, g^{c_x} \text{mod } p\}_{K_{SC_x}}\] (5) 9. \(S\) computes the shared session key by computing \(K_{SC_x} = (g^{c_x})^s \text{mod } p\) and decrypts the received message with \(K_{SC_x}\). \(S\) then transfers message (??) to \(C_x\). \[S \rightarrow C_x : \{N_v, Nb_x, \text{SML}, g^* \text{mod } p\}_{K_{SC_x}}\] (6) 10. \(C_x\) verifies all signatures and checks the freshness of the \(N_v\) by checking whether Equations (??) and (??) hold: \[\text{time}_0 + v \cdot t \leq \text{time} \leq \text{time}_0 + (v + 1) \cdot t + \epsilon\] (7) \[h^v(N_v) = N_v\] (8) 11. Finally, \(C_x\) verifies that the platform configuration of \(S\) is trusted based on the SML and the PCRs. ### 4.3 Tickstamp Attestation The tickstamp attestation uses the tick-counter of a TPM (a tick is in the time range of milliseconds up to seconds). A TPM provides a mechanism to create a signature of the current tick-counter value. The resulting data structure includes a signature of the current tick-counter value and the time interval after which the counter is periodically incremented. To use tick-counters during platform attestation, we utilize the concept that a TPM enables the creation of non-migratable keys that are bound to the platform configuration. Before a TPM performs platform attestation, a non-migratable key is generated on the TPM and bound to a specific set of platform configuration registers. This key is certified using an AIK, which gives a proof that the key is bound to a specific set of platform configuration registers. The bound key is then used in periodic time intervals to generate TickStampBlobs, which is only possible while the platform configuration has not changed. A TickStampBlob consists of a complete TPM_CURRENT_TICKS structure [?]. and the resulting signature. It includes the current value of the tick-counter, a tick-session identifier, and a signature of the data. To demonstrate to a remote party that the platform configuration is to be trusted, an attestation token \( \tau \) is computed. This token comprises the latest TickStampBlob, which is the first part of the token shown in Equation (??), as well as the certificate of the key used to generate the TickStampBlob: \[ \tau = \{\text{currentTicks}, g^\tau \mod p\}K_T^{-1}, \] \( \text{Cert}(K_T), \text{Cert}(AIK) \) The trustworthiness of the platform configuration can be evaluated based on the certificate and the tick-count value inside the TickStampBlob. However, the token gives only an assertion about the platform configuration in relation to the tick-counter on the platform that wants to demonstrate its configuration. A synchronization of the tick-counter of the challenger and the prover is thus needed. In the following, we will discuss two means of achieving this synchronization. Most implementations of the TPM specification initialize a tick-session after a reboot of the system with the value zero. To uniquely identify a specific tick-session, the TPM also adds a nonce to the tick-session. Since the nonce is also part of every TickStampBlob, two different TickStampBlob structures can be uniquely related to their session. **Challenge-Response Synchronization.** The easiest way to perform synchronization with the tick-session of the server is to deliver a nonce to the server which is then signed with TPM_TickStampBlob. The resulting signature includes the complete TPM_CURRENT_TICKS structure (??), which gives an assertion about the actual tick-counter value, the tick-rate and the identifying nonce of the current tick-session. Based on this information, the verifier can check the freshness of the actual attestation token. However, this concept requires one expensive sign operation on the TPM, which does not scale. It is thus not applicable in highly-frequented environments. **Time Synchronization using a TTP.** Another alternative is to involve a Trusted Third Party in the synchronization protocol. This sync-TTP is responsible for associating a specific tick-session to a specific global time. For this purpose, the TTP generates and transfers a nonce to the server, directly after the tick-session on the server is initialized. This nonce is then signed with TPM_TickStampBlob by the server TPM and the result is delivered to the sync-TTP. The sync-TTP verifies the signatures and generates a synchronization token that includes the global time, the round-trip time and the received result. This sync token is then returned to the server which adds the token to all generated attestation tokens. Based on the synchronization token, an association between the global time and the beginning of a specific tick-session is made. A client only needs to synchronize his time with the sync-TTP in order to make a statement about the freshness of the received attestation token \( \tau \) in Equation (??). The sync-TTP thus provides services similar to a generic NTP server. It is also reasonable that a NTP server can be extended with the ability to create synchronization tokens, since these protocol steps only require minimal additional computations. Tickstamp Attestation with TTP-based time synchronization is shown in Protocol 4.3.1. **Protocol 4.3.1: Tickstamp Attestation with synchronization token** 1. \( S \) selects a TTP for providing a sync-token. The TTP transfers a nonce \( N_t \) using message (I) to \( S \) \[ \text{TTP} \rightarrow S: \quad N_t \quad (I) \] 2. \( S \) creates a non-migratable TPM key \( K_T \) that is bound to a specific set of platform configuration registers. \( S \) certifies \( K_T \) with \( K_{AIK} \). The resulting structure is denoted as \( \text{Cert}(K_T) \) and gives an assertion to which PCR values \( K_T \) is bound. \( S \) then signs the actual tick-counter value with \( K_T^{-1} \) and delivers message (II) to the TTP. \[ S \rightarrow \text{TTP}: \quad \{N_t, \text{currentTicks}\}K_T^{-1}, \quad \text{Cert}(K_T), \text{Cert}(AIK) \quad (II) \] 3. The TTP verifies the signature and creates a timestamp on the received message and transfers the sync-token \( \tau_{sync} \) in message (III) to \( S \). \[ \text{TTP} \rightarrow S: \quad \{\{N_t, \text{currentTicks}\}K_T^{-1}, \text{Time}\}K_T^{-1} \quad (III) \] The server has now received a sync-token that can subsequently be used by the clients to verify freshness of the attestation token. After completing this initialization phase, the server is ready to answer attestation requests. 1. **Precomputation and Pre-deployment by \( S \).** \( S \) selects an appropriate prime \( p \) and generator \( g \) of \( Z_p^* \) \( (2 \leq g \leq p - 2) \). \( S \) chooses a random secret \( s \), \( 2 \leq s \leq p - 2 \), and computes \( g^s \mod p \). \( S \) transmits \( g^s \) and \( p \) to all \( C_x \). 2. **Precomputation by \( C_x \).** \( C_x \) chooses a random secret \( c_x \), \( 2 \leq c_x \leq p - 2 \), and computes \( g^{c_x} \mod p \). 3. **Attestation challenge.** \( C_x \), \( x = 1, \ldots, n \), deliver message (??) to \( S \). \[ C_x \rightarrow S: \quad g^{c_x} \mod p \quad (1) \] 4. The server periodically signs the actual tick-counter value with \( K_T^{-1} \). The resulting data structure is denoted as TickStampBlob. 5. \( S \) transmits the synchronization token \( \tau_{sync} = \{\{N_t, \text{currentTicks}\}K_T^{-1}, \text{Time}\}K_T^{-1} \) and the attestation token \( \tau \) in message (??) to \( C_x \). \[ S \rightarrow C_x: \quad \{\text{currentTicks}, g^\tau \mod p\}K_T^{-1}, \quad \text{Cert}(K_T), \text{Cert}(AIK), \tau_{sync} \quad (2) \] 6. **Key confirmation.** \( C_x \) computes the shared session key by computing \( K_{S_Cx} = (g^s)^{c_x} \mod p \). \( C_x \) then generates a second non-predictable nonce \( (N_{b_x}) \) and transfers message (??) to \( S \). \[ C_x \rightarrow S: \quad \{N_{b_x}, g^{c_x} \mod p\}K_{S_Cx} \quad (3) \] 7. $S$ computes the shared session key by computing \( K_{SC_x} = (g^x)^y \mod p \) and decrypts the received message with $K_{SC_x}$. $S$ then transfers message (??) to $C_x$. \[ S \rightarrow C_x : \{ Nb_y, SML, g^x \mod p \}_{K_{SC_x}} \] (4) 8. Finally, $C_x$ verifies all signatures and checks whether the attestation token $\tau$ is fresh using the synchronization token $\tau_{sync}$. In addition, $C_x$ verifies that the platform configuration of $S$ is trusted based on the SML and the PCRs. 5. SECURITY ANALYSIS In this section we will discuss the security of our proposed protocols. Since all protocols include an authentication step, we will first analyze whether this step is secure and enables secure integrity reporting. We finally perform a formal verification using the AVISPA protocol prover [2]. 5.1 Security of the Authentication In this section we will discuss the security of the authentication step by looking at potential attacks, including man-in-the-middle and version rollback attacks. 5.1.1 Man-in-the-Middle attack All presented protocols prevent an attacker from hiding his malicious software configuration by performing a relay attack [?, ?], since all subsequent messages are encrypted with the computed session key $K_{SC_x}$. It is not possible for an attacker to perform some sort of man-in-the-middle attack and to establish two different cryptographic sessions between the verifier and the challenger, as he is not able to modify the attestation response of the prover. Since the session key $K_{SC_x}$ is protected by the trusted operating system (e.g., by storing it in a special purpose region of a security kernel or in a special virtual machine) it is not possible to extract this key under normal run-time conditions. Changing the trusted operating system environment to enable extraction of this key would lead to a non-conformant system state which would have been detected in the attestation phase. 5.1.2 Version-rollback attack The presented protocol is not compatible with a verifier that expects the insecure existing remote attestation defined by the TCG. This is especially true for the Multiple-Hash Attestation. This attack was misleadingly classified in [?] as a man-in-the-middle attack. However, this classification is insufficient, since the attack requires that one entity executes the insecure integrity reporting protocol specified by the TCG in [?]. In this attack scenario, three different parties, a verifier, a prover and an adversary, are involved. The adversary tries to relay the attestation challenge of the verifier to the prover, thus trying to masquerade a trustworthy system configuration. The verifier and the adversary run an authentication enhanced attestation protocol (e.g., Protocol ??), while the prover runs the TCG-defined attestation protocol. This attack can be classified as a version rollback attack, in which the adversary masks his public key together with the nonce provided by the verifier as new nonce for the prover. The prover does not verify the syntax of the attestation challenge. He directly signs the masqueraded nonce including public key and delivers the computed signature to the adversary. The adversary simply forwards the obtained message and both adversary and verifier compute the shared key based on the exchanged public keys. However, since the protocol’s software integrity of the prover is also reflected in the platform configuration, the verifier will determine the platform configuration as not being trusted. The version rollback attack is therefore only a theoretical attack and fails, since it is not possible to successfully masquerade a trusted system configuration. 5.2 Formal Security Analysis To formally analyze the proposed protocol, we use the AVISPA protocol prover [?]. AVISPA provides a special language [?, ?] for describing security protocols and specifying their intended security properties (we refer to the AVISPA website for more details) AVISPA is a powerful tool to formally analyze cryptographic protocols. Since our proposed protocols include an authentication phase, it is necessary to analyze whether the protocols are secure against Dolev-Yao attackers [?]. In the following we restrict us to analysis of Protocol ??, all other protocols can be handled analogously. Each involved entity (i.e., prover and verifier), is modelled as a finite state machine and each transition from one state to another requires the receipt of a message and the sending of a reply message. Thus, the verifier is modelled as a state machine with three states and the prover is modelled as a state machine with two states. In each state, the respective message as specified in the protocols are transferred, e.g., the prover receives in its first state message (4) of Protocol ?? and creates and delivers message (5) to the verifier. We use the Dolev-Yao intruder model [?] to model the attacker and the environment. In this intruder model the attacker has full control over all messages that are sent over the network. The attacker can therefore intercept, analyze or modify messages, as well as compose new messages and send the messages to any party. To abstract from the negotiation of a common generator $g$ and a common group $Z_p$, we assume that these are global parameters known to all parties in the environment. However, this is not a security restriction since these messages can transferred in plaintext without loss of security (see [?]). We use AVISPA to verify the following security goals: - $C_x$ authenticates a genuine and authentic TPM on the value $Na_x$. This holds since only an authentic TPM is able to sign $Na_x$ with a corresponding non-migratable key (AIK or special purpose key). - $C_x$ authenticates the TPM of $S$ on the value $K_{SC_x}$. This holds since given the first statement, only the owner of the TPM possesses the corresponding private Diffie-Helman key. As a consequence, only $C_x$ is able to compute the secret key based on the provided public key. - $C_x$ authenticates the TPM of $S$ on the value $Nb_x$. This holds since given the second statement, only $S$ can decrypt $Nb_x$ and send it back to $C_x$. \[2\] http://www.avispa-project.org • $C_x$ and $S$ share the key $K_{SC_x}$, which is confidential and should be kept secret. • $C_x$ and $S$ share the Stored Measurement Log (SML), which is privacy related and should also be kept secret. It should be noted that we do not directly authenticate $S$ to $C_x$. $C_x$ only determine whether they are currently communicating with the platform that has provided authentic measurements and that this channel is authenticated. After modelling the protocol, we analyzed the model with the model checker provided by AVISPA. We found no attack trace; thus the protocol analyzer reports that all security properties are satisfied and Protocol ?? is secure. 5.3 Security Considerations of the Multiple-Hash Attestation The main difference between the existing TCG-defined integrity reporting and the Multiple-Hash Attestation is that multiple nonces are hashed to one single nonce. The security of this process relies on the property that the hash function, in our case SHA-1, is collision resistant. If a collision-resistant hash function is used, it is infeasible for an adversary to find a collision that can be used to masquerade a trustworthy system configuration. 5.4 Security Considerations of the Timestamped Hash-Chain Attestation A general problem in the process of platform attestation is that an untrusted platform configuration can be replayed, leading to a non-trustworthy platform configuration being masqueraded as trustworthy. This attack is prevented by using randomly generated nonces combined with the challenge-response authentication method. However, in the context of the Timestamped Hash-Chain Attestation, these nonces are derived from a seed nonce by applying a hash function on this value. It is therefore possible to generate nonces that are valid in the future. This property can be exploited by an adversary by generating nonces that are valid in future intervals, computing the attestation token in a trustworthy configuration, and replaying the computed attestation token in the future after compromising the platform. The risk that an adversary may perform such an attack can be minimized by preventing an adversary’s ability to inject nonces corresponding to future time intervals. That can be done, for example, by modifying the operating system so that it only allows certain trusted processes to communicate with a TPM. These trusted processes should only accept seed nonces with a valid signature that have been created by a TTP. Since the configuration of the operating system is also part of the platform configuration, a verifier can check whether the prover’s OS is in a trusted state and thus possesses a mechanism to prevent attacks of this type. 5.5 Security Considerations of the Tickstamp Attestation The security of the Tickstamp Attestation relies on the assurance that a specific non-migratable TPM key, satisfying certain criteria, is used. This assurance is made using a certificate generated through $TPM\_Certify\_Key$. Lühr et al. [?] verified that the concept of binding a key to a specific set of platform configuration registers is secure against man-in-the-middle attacks. We will thus only look at the differences between the protocol proposed in [?] and our proposal. In contrast to Lühr et al., we also integrate a public Diffie-Helman key into the $K_{TS}$ signed message. Using $K_{TS}$ as a signing key at a specific time is only possible if the platform configuration is in a known and trusted state. The extraction of the Diffie-Helman key requires a modified system configuration that causes the state of the platform to change. The TPM will then deny decryption of the sealed key $K_{TS}$. To further enhance security, the Diffie-Helman key should also be held in a special purpose region of a microkernel or virtual machine, as, for example, proposed in [?]. It should also be noted that each time $K_{TS}$ is used, it is verified that the actual platform configuration is consistent with the platform configuration $K_{TS}$ was bound to. 6. EVALUATION In this section we will first present the performance measurements of our implementation. We will then perform a comparison of our proposed protocols. 6.1 Performance Evaluation The main goal of our proposal is to enhance the scalability of platform attestation. We implemented all of our proposed protocols in Java using the tpm4java framework and ran performance simulations. The advantage of this framework is that it is a very efficient implementation and we can talk directly to the /dev/tpm device driver without requiring that another TPM software stack be present in the system. A software stack in the background would additionally need computation power and thus decrease performance. Our approach causes the time degradation to depend only on the TPM. We measured the runtime of all protocols, excluding those for generating the Diffie-Helman keys and those for generating a new TPM non-migratable key ($K_{TS}$) required in Protocol ??. The results shown in Figure ?? were obtained by averaging over 100 independent runs for each protocol. For each protocol, we measured the latencies when one attestation challenge arrives, as well as when multiple (100) attestation challenges arrive simultaneously. The latencies of the TCG-defined protocol [?] as well as the Robust-IRP [?] scale linearly. Therefore, the time for answering $n$ simultaneously arriving attestation request is approximately equal to $n \times x$, where $x$ is the time for answering one attestation. The average column also depicts the time that is necessary to execute the key confirmation phase once the TPM has delivered the integrity information; this time is shown as the second summand in the column. Note that the TCG-defined IRP in Figure ?? does not have a second summand as the TCG-defined protocol does not require a key-establishment. The time to finish a Multiple-Hash Attestation varies roughly between 1 and 2 seconds, this variation is caused by the ring buffer. If the ring buffer has just been rotated one step and new requests arrive, these requests have to wait until the TPM has finished calculation and the buffer is rotated again. The Tickstamp-Attestation and the Time-stamp-Attestation also consider the time that is needed to generate the attestation token. As soon as the token has been generated, it can be used to attest to the contents of --- 3http://tpm4java.datenzone.de the platform configuration registers. This token generation time therefore indicates the length of the attestation interval in which this attestation token is used. An attestation interval can, therefore, not be smaller than about 1.5 seconds. The measurements show that all proposed protocols are independent of the number of simultaneously arriving requests. They can therefore significantly reduce the time required to answer simultaneously arriving attestation requests. 6.2 Comparison of the protocols All proposed protocols enable a highly-frequented server to timely answer all incoming attestation requests. While the Multiple-Hash Attestation is the slowest and requires roughly between one and two seconds to complete the attestation process, it has the advantage that it is very similar to the existing TCG-proposed integrity reporting protocol. Prover and verifier must, therefore, only minimally modify their attestation interface. This protocol can be classified as an active attestation, since it requires the verifier to provide a nonce for the server. To use the protocol a direct connection to the verifier must be established; it is thus not possible to relay the attestation message to other parties. The biggest advantage of Timestamped Hash-Chain Attestation and the Tickstamp Attestation is that these protocols are passive attestations, which require no direct communication between server and client to deliver integrity information. A client can thus collect attestation tokens which he received from other entities and see how the configuration of a particular server changed over time. If this is a desirable feature, the SML must be integrated inside the attestation tokens $\tau$, which would remove the need of a direct connection to the prover and the verifier can collect attestation tokens without noticing the server. However, to ensure freshness of the attestation token and to complete the authentication process, a direct communication between server and client is needed. Both protocols require a TTP either for providing a synchronization token or for the initial nonce. Since the Timestamped Hash-Chain Attestation requires additional security mechanisms, we suggest to use, depending on the scenario, either the Tickstamp Attestation or the Multiple-Hash Attestation. To prevent an attacker from performing masquerading attacks on the authenticity of the platform configuration, our protocols establish a secure channel between the involved entities. This secure channel is then used for transmitting the privacy-related Stored Measurement Log. Although the computation of these cryptographic operations degrade the server performance, we believe that ensuring the authenticity of integrity information is necessary in order to enable secure integrity reporting. However, it should also be noted that these cryptographic operations can be computed very efficiently and only increase the time for answering one attestation request by 0.70% and are in the range of milliseconds. 7. CONCLUSION In scenarios where an entity is frequently requested to deliver integrity information, existing protocols for performing the TCG-specified platform attestation scale badly. Such scenarios mainly include a client-server architecture, where a large number of clients frequently request integrity information of a particular server. This restriction is caused by the fact that a Trusted Platform Module (TPM) possesses very restricted computation power and is highly involved in the process of platform attestation. In this paper we proposed three solutions to overcome the bottleneck of a TPM and thus to perform platform attestation in scenarios where a frequent integrity verification is needed. Our proposed protocols do not require any modifications to the TPM hardware or any modifications to the measurement process. Although our protocols are based on the TPM-based binary attestation and treat PCR values as measurement data, they could be easily modified to send other forms of measurement data, such as measurement data collected in run-time measurement systems. We presented a performance evaluation as well as a security analysis of our proposed protocol; the results clearly indicate that the protocols can considerably reduce the performance overhead of the attestation process. 8. REFERENCES <table> <thead> <tr> <th>Protocol</th> <th>No. concurrent Req.</th> <th>Average (ms)</th> <th>Min (ms)</th> <th>Max (ms)</th> </tr> </thead> <tbody> <tr> <td>TCG-IRP [?]</td> <td>1</td> <td>852.47</td> <td>842</td> <td>879</td> </tr> <tr> <td></td> <td>n</td> <td>852.47 - n</td> <td></td> <td></td> </tr> <tr> <td>Robust-IRP [?]</td> <td>1</td> <td>863.75 + 3.4</td> <td>860</td> <td>881</td> </tr> <tr> <td></td> <td>n</td> <td>869.75 - n + 3.4</td> <td></td> <td></td> </tr> <tr> <td>Multiple-Hash Attestation</td> <td>n (Best)</td> <td>939.91 + 6.16</td> <td>921</td> <td>973</td> </tr> <tr> <td></td> <td>n (Worst)</td> <td>936.61 + 6.68</td> <td>892 + 1</td> <td>1826.84 + 20</td> </tr> <tr> <td>Timestamped Attestation</td> <td>Token generation</td> <td>1448.95</td> <td>1422</td> <td>1727</td> </tr> <tr> <td></td> <td>time n</td> <td>&lt;1 + 6.36</td> <td></td> <td></td> </tr> <tr> <td>Tickstamp Attestation</td> <td>Token generation</td> <td>1456.58</td> <td>1424</td> <td>1686</td> </tr> <tr> <td></td> <td>time n</td> <td>&lt;1 + 6.42</td> <td></td> <td></td> </tr> </tbody> </table> Figure 4: Measured latencies of selected Integrity Reporting Protocols
{"Source-Url": "http://sit.sit.fraunhofer.de/smv/publications/download/STC2008_RE.pdf", "len_cl100k_base": 11490, "olmocr-version": "0.1.49", "pdf-total-pages": 10, "total-fallback-pages": 0, "total-input-tokens": 38026, "total-output-tokens": 14019, "length": "2e13", "weborganizer": {"__label__adult": 0.0003814697265625, "__label__art_design": 0.000362396240234375, "__label__crime_law": 0.001346588134765625, "__label__education_jobs": 0.0007915496826171875, "__label__entertainment": 9.14931297302246e-05, "__label__fashion_beauty": 0.0001760721206665039, "__label__finance_business": 0.0008859634399414062, "__label__food_dining": 0.00031685829162597656, "__label__games": 0.0009908676147460938, "__label__hardware": 0.003786087036132813, "__label__health": 0.0006976127624511719, "__label__history": 0.0003681182861328125, "__label__home_hobbies": 0.00014507770538330078, "__label__industrial": 0.0009307861328125, "__label__literature": 0.0002923011779785156, "__label__politics": 0.0003709793090820313, "__label__religion": 0.0004906654357910156, "__label__science_tech": 0.3544921875, "__label__social_life": 9.495019912719728e-05, "__label__software": 0.0384521484375, "__label__software_dev": 0.59375, "__label__sports_fitness": 0.0002460479736328125, "__label__transportation": 0.0006399154663085938, "__label__travel": 0.00019299983978271484}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 56572, 0.02355]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 56572, 0.199]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 56572, 0.87733]], "google_gemma-3-12b-it_contains_pii": [[0, 3911, false], [3911, 10622, null], [10622, 15824, null], [15824, 21000, null], [21000, 26393, null], [26393, 32494, null], [32494, 38719, null], [38719, 45148, null], [45148, 51008, null], [51008, 56572, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3911, true], [3911, 10622, null], [10622, 15824, null], [15824, 21000, null], [21000, 26393, null], [26393, 32494, null], [32494, 38719, null], [38719, 45148, null], [45148, 51008, null], [51008, 56572, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 56572, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 56572, null]], "pdf_page_numbers": [[0, 3911, 1], [3911, 10622, 2], [10622, 15824, 3], [15824, 21000, 4], [21000, 26393, 5], [26393, 32494, 6], [32494, 38719, 7], [38719, 45148, 8], [45148, 51008, 9], [51008, 56572, 10]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 56572, 0.0515]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
6e94e5020e3154decf93586fb544631586d93d88
National Computing Centre Limited National Computing Centre Limited Ada Joint Program Office United States Department of Defense Washington, DC 20301-3081 National Computing Centre Limited Approved for public release; distribution unlimited. See Attached. Ada® Compiler Validation Summary Report: Compiler Name: SD Ada-Plus VAX/VMS x MC68020 Host: VAX 8600 under VMS Target: Motorola MC68020 under no operating system Testing Completed 1 December 1986 Using ACVC 1.8 This report has been reviewed and is approved. [Signature] The National Computing Centre Ltd Vony Gwillim Oxford Road Manchester M1 7ED [Signature] Ada Validation Office Dr. J. S. Kramer Institute for Defense Analyses Alexandria VA [Signature] Ada Joint Program Office Virginia L. Castor Director Department of Defense Washington DC *Ada is a registered trademark of the United States Government (Ada Joint Program Office). AVF Control Number: AVF-VSR-90502/07 Ada* COMPILER VALIDATION SUMMARY REPORT: Systems Designers\plc SD Ada-Plus VAX/VMS x MC68020 Version 2B.00 Host : VAX 8600 Target: Motorola MC68020 Completion of On-Site Testing: 1 December 1986 Prepared By: National Computing Centre Limited Oxford Road Manchester M1 7ED UK Prepared For: Ada Joint Program Office United States Department of Defense Washington, D.C. USA *Ada is a registered trademark of the United States Government (Ada Joint Program Office). This Validation Summary Report (VSR) summarizes the results and conclusions of validation testing performed on the SD Ada-Plus VAX/VMS x MC68020, 2B.00, using Version 1.8 of the Ada* Compiler Validation Capability (ACVC). The SD Ada-Plus VAX/VMS x MC68020 is hosted on a VAX 8600 operating under VMS, 4.2. Programs processed by this compiler may be executed on a Motorola MC68020. On-site testing was performed 28 November 1986 through 1 December 1986 at Systems Designers plc, Camberley, under the direction of The National Computing Centre Ltd (AVF), according to Ada Validation Organization (AVO) policies and procedures. The AVF identified 2102 of the 2399 tests in ACVC Version 1.8 to be processed during on-site testing of the compiler. The 19 tests withdrawn at the time of validation testing, as well as the 278 executable tests that make use of floating-point precision exceeding that supported by the implementation were not processed. After the 2102 tests were processed, results for Class A, C, D, or E tests were examined for correct execution. Compilation listings for Class B tests were analyzed for correct diagnosis of syntax and semantic errors. Compilation and link results of Class L tests were analyzed for correct detection of errors. There were 184 of the processed tests determined to be inapplicable; the remaining 1918 tests were passed. The results of validation are summarized in the following table: <table> <thead> <tr> <th>RESULT</th> <th>CHAPTER</th> <th>TOTAL</th> </tr> </thead> <tbody> <tr> <td>Passed</td> <td>2 3 4 5 6 7 8 9 10 11 12 14</td> <td></td> </tr> <tr> <td>Failed</td> <td>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</td> <td></td> </tr> <tr> <td>Inapplicable</td> <td>23 120 140 3 0 0 1 1 7 1 0 166 462</td> <td></td> </tr> <tr> <td>Withdrawn</td> <td>0 5 5 0 0 1 1 2 4 0 1 0</td> <td></td> </tr> <tr> <td>TOTAL</td> <td>116 330 425 247 161 98 140 264 134 32 219 233 2399</td> <td></td> </tr> </tbody> </table> The AVF concludes that these results demonstrate acceptable conformity to ANSI/MIL-STD-1815A Ada. *Ada is a registered trademark of the United States Government (Ada Joint Program Office). TABLE OF CONTENTS CHAPTER 1 INTRODUCTION 1.1 PURPOSE OF THIS VALIDATION SUMMARY REPORT ..........1-2 1.2 USE OF THIS VALIDATION SUMMARY REPORT ..............1-2 1.3 REFERENCES ...........................................1-3 1.4 DEFINITION OF TERMS ...................................1-3 1.5 ACVC TEST CLASSES .....................................1-4 CHAPTER 2 CONFIGURATION INFORMATION 2.1 CONFIGURATION TESTED ....................................2-1 2.2 IMPLEMENTATION CHARACTERISTICS .......................2-2 CHAPTER 3 TEST INFORMATION 3.1 TEST RESULTS ...........................................3-1 3.2 SUMMARY OF TEST RESULTS BY CLASS .....................3-1 3.3 SUMMARY OF TEST RESULTS BY CHAPTER ....................3-2 3.4 WITHDRAWN TESTS .......................................3-2 3.5 INAPPLICABLE TESTS ......................................3-2 3.6 SPLIT TESTS ............................................3-4 3.7 ADDITIONAL TESTING INFORMATION .........................3-4 3.7.1 Prevalidation .......................................3-4 3.7.2 Test Method ..........................................3-5 3.7.3 Test Site ...........................................3-5 APPENDIX A COMPLIANCE STATEMENT APPENDIX B APPENDIX F OF THE Ada STANDARD APPENDIX C TEST PARAMETERS APPENDIX D WITHDRAWN TESTS CHAPTER 1 INTRODUCTION This Validation Summary Report (VSR) describes the extent to which a specific Ada compiler conforms to the Ada Standard. This report explains all technical terms used within it and thoroughly reports the results of testing this compiler using the Ada Compiler Validation Capability (ACVC). An Ada compiler must be implemented according to the Ada Standard and any implementation-dependent features must conform to the requirements of the Ada Standard. The Ada Standard must be implemented in its entirety, and nothing can be implemented that is not in the Standard. Even though all validated Ada compilers conform to the Ada Standard, it must be understood that some differences do exist between implementations. The Ada Standard permits some implementation dependencies—for example, the maximum length of identifiers or the maximum values of integer types. Other differences between compilers result from characteristics of particular operating systems, hardware, or implementation strategies. All of the dependencies demonstrated during the process of testing this compiler are given in this report. The information in this report is derived from the test results produced during validation testing. The validation process includes submitting a suite of standardized tests, the ACVC, as inputs to an Ada compiler and evaluating the results. The purpose of validating is to ensure conformity of the compiler to the Ada Standard by testing that the compiler properly implements legal language constructs and that it identifies and rejects illegal language constructs. The testing also identifies behaviour that is implementation dependent but permitted by the Ada Standard. Six classes of tests are used. These tests are designed to perform checks at compile time, at link time, and during execution. 1.1 PURPOSE OF THIS VALIDATION SUMMARY REPORT This VSR documents the results of the validation testing performed on an Ada compiler. Testing was carried out for the following purposes: - To attempt to identify any language constructs supported by the compiler that do not conform to the Ada Standard. - To attempt to identify any unsupported language constructs required by the Ada Standard. - To determine that the implementation-dependent behaviour is allowed by the Ada Standard. Testing of this compiler was conducted by NCC under the direction of the AVF according to policies and procedures established by the Ada Validation Organisation (AVO). On-site testing was conducted from 28 November 1986 through 1 December 1986 at Systems Designers plc., Camberley. 1.2 USE OF THIS VALIDATION SUMMARY REPORT Consistent with the national laws of the originating country, the AVO may make full and free public disclosure of this report. In the United States, this is provided in accordance with the "Freedom of Information Act" (5 U.S.C. 552). The results of this validation apply only to the computers, operating systems, and compiler versions identified in this report. The organisations represented on the signature page of this report do not represent or warrant that all statements set forth in this report are accurate and complete, or that the subject compiler has no nonconformities to the Ada Standard other than those presented. Copies of this report are available to the public from: Ada Information Clearinghouse Ada Joint Program Office CUSDRE The Pentagon, Rm 3D-139 (Fern Street) Washington DC 20301-3081 or from: Ada Validation Facility The National Computing Centre Ltd Oxford Road Manchester M1 7ED United Kingdom 1-2 Questions regarding this report or the validation test results should be directed to the AVF listed above or to: Ada Validation Organization Institute for Defense Analyses 1801 North Beauregard Alexandria VA 22311 1.3 REFERENCES 1.4 DEFINITION OF TERMS ACVC The Ada Compiler Validation Capability. A set of programs that evaluates the conformity of a compiler to the Ada language specification, ANSI/MIL-STD-1815A. Applicant The agency requesting validation. AVF The National Computing Centre Ltd. In the context of this report, the AVF is responsible for conducting compiler validations according to established policies and procedures. AVO The Ada Validation Organization. In the context of this report, the AVO is responsible for setting procedures for compiler validations. Compiler A processor for the Ada language. In the context of this report, a compiler is any language processor, including cross-compilers, translators, and interpreters. Failed test A test for which the compiler generates a result that demonstrates nonconformity to the Ada Standard. INTRODUCTION Host The computer on which the compiler resides. Inapplicable A test that uses features of the language that a compiler test is not required to support or may legitimately support in a way other than the one expected by the test. Passed test A test for which a compiler generates the expected result. Target The computer for which a compiler generates code. Test A program that checks a compiler's conformity regarding a particular feature or features to the Ada Standard. In the context of this report, the term is used to designate a single test, which may comprise one or more files. Withdrawn A test found to be incorrect and not used to check conformity to test the Ada language specification. A test may be incorrect because it has an invalid test objective, fails to meet its test objective, or contains illegal or erroneous use of the language. 1.5 ACVC TEST CLASSES Conformity to the Ada Standard is measured using the ACVC. The ACVC contains both legal and illegal Ada programs structured into six test classes: A, B, C, D, E, and L. The first letter of a test name identifies the class to which it belongs. Class A, C, D, and E tests are executable, and special program units are used to report their results during execution. Class B tests are expected to produce compilation errors. Class L tests are expected to produce link errors. Class A tests check that legal Ada programs can be successfully compiled and executed. However, no checks are performed during execution to see if the test objective has been met. For example, a Class A test checks that reserved words of another language (other than those already reserved in the Ada language) are not treated as reserved words by an Ada compiler. A Class A test is passed if no errors are detected at compile time and the program executes to produce a PASSED message. Class B tests check that a compiler detects illegal language usage. Class B tests are not executable. Each test in this class is compiled and the resulting compilation listing is examined to verify that every syntax or semantic error in the test is detected. A Class B test is passed if every illegal construct that it contains is detected by the compiler. Class C tests check that legal Ada programs can be correctly compiled and executed. Each Class C test is self-checking and produces a PASSED, FAILED, or NOT APPLICABLE message indicating the result when it is executed. Class D tests check the compilation and execution capabilities of a compiler. Since there are no requirements placed on a compiler by the Ada Standard for some parameters—for example, the number of identifiers permitted in a compilation or the number of units in a library—a compiler may refuse to compile a Class D test and still be a conforming compiler. Therefore, if a Class D test fails to compile because the capacity of the compiler is exceeded, the test is classified as inapplicable. If a Class D test compiles successfully, it is self-checking and produces a PASSED or FAILED message during execution. Each Class E test is self-checking and produces a NOT APPLICABLE, PASSED, or FAILED message when it is compiled and executed. However, the Ada Standard permits an implementation to reject programs containing some features addressed by Class E tests during compilation. Therefore, a Class E test is passed by a compiler if it is compiled successfully and executes to produce a PASSED message, or if it is rejected by the compiler for an allowable reason. Class L tests check that incomplete or illegal Ada programs involving multiple, separately compiled units are detected and not allowed to execute. Class L tests are compiled separately and execution is attempted. A Class L test passes if it is rejected at link time—that is, an attempt to execute the main program must generate an error message before any declarations in the main program or any units referenced by the main program are elaborated. Two library units, the package REPORT and the procedure CHECK_FILE, support the self-checking features of the executable tests. The package REPORT provides the mechanism by which executable tests report PASSED, FAILED, or NOT APPLICABLE results. It also provides a set of identity functions used to defeat some compiler optimization allowed by the Ada Standard that would circumvent a test objective. The procedure CHECK_FILE is used to check the contents of text files written by some of the Class C tests for chapter 14 of the Ada Standard. The operation of these units is checked by a set of executable tests. These tests produce messages that are examined to verify that the units are operating correctly. If these units are not operating correctly, then the validation is not attempted. The text of the tests in the ACVC follow conventions that are intended to ensure that the tests are reasonably portable without modification. For example, the tests make use of only the basic set of 55 characters, contain lines with a maximum length of 72 characters, use small numeric values, and place features that may not be supported by all implementations in separate tests. However, some tests contain values that require the test to be customized according to implementation-specific values—for example, an illegal file name. A list of the values used for this validation are listed in Appendix C. A compiler must correctly process each of the tests in the suite and demonstrate conformity to the Ada Standard either meeting the pass criteria given for the test or by showing that the test is inapplicable to the implementation. Any test that was determined to contain an illegal language construct or an erroneous language construct is withdrawn from the ACVC and, therefore, is not used in testing a compiler. The tests withdrawn at the time of validation are given in Appendix D. CHAPTER 2 CONFIGURATION INFORMATION 2.1 CONFIGURATION TESTED The candidate compilation system for this validation was tested under the following configuration: Compiler: SD Ada-Plus VAX/VMS x MC68020 ACVC Version: 1.8 Certification Expiration Date: 17 December 1987 Host Computer: Machine : VAX 8600 Operating System: VMS 4.2 Memory Size: 20 M byte Target Computer: Machine : Motorola MC68020 implemented on Motorola MVME 133 board, incorporating MC68881 floating point co-processor. Operating System: no operating system Memory Size: 1 M byte Communications Network: RS232C connector via a null modem using a protocol conforming to RS232C. 2.2 IMPLEMENTATION CHARACTERISTICS One of the purposes of validating compilers is to determine the behaviour of a compiler in those areas of the Ada Standard that permit implementations to differ. Class D and E tests specifically check for such implementation differences. However, tests in other classes also characterize an implementation. This compiler is characterized by the following interpretations of the Ada Standard: - Capacities. The compiler correctly processes compilations containing loop statements nested to 65 levels, block statements nested to 65 levels, and recursive procedures separately compiled as subunits nested to 17 levels. It correctly processes a compilation containing 723 variables in the same declarative part. (See tests D55A03A..H (8 tests), D56001B, D64005E..G (3 tests), and D29002K.) - Universal integer calculations. An implementation is allowed to reject universal integer calculations having values that exceed $\text{SYSTEM.MAX\_INT}$. This implementation does not reject such calculations and processes them correctly. (See tests D4A002A, D4A002B, D4A004A, and D4A004B.) - Predefined types. This implementation supports the additional predefined type $\text{SHORT\_INTEGER}$ in the package STANDARD. (See tests B86001C and B86001D.) - Based literals. An implementation is allowed to reject a based literal with a value exceeding $\text{SYSTEM.MAX\_INT}$ during compilation, or it may raise $\text{NUMERIC\_ERROR}$ or $\text{CONSTRAINT\_ERROR}$ during execution. This implementation raises $\text{NUMERIC\_ERROR}$ during execution. (See test E24101A.) - Array Types. An implementation is allowed to raise $\text{NUMERIC\_ERROR}$ or $\text{CONSTRAINT\_ERROR}$ for an array having a 'LENGTH' that exceeds $\text{STANDARD\_INTEGER'}$LAST and/or $\text{SYSTEM.MAX\_INT}$. A packed BOOLEAN array having a 'LENGTH exceeding INTEGER'LAST raises $\text{NUMERIC\_ERROR}$ when the array type is declared. (See test C52103X.) A packed two-dimensional BOOLEAN array with more than INTEGER'LAST components raises NUMERIC_ERROR when the array type is declared. (See test C52104Y.) A null array with one dimension of length greater than INTEGER'LAST may raise NUMERIC_ERROR or CONSTRAINT_ERROR either when declared or assigned. Alternatively, an implementation may accept the declaration. However, lengths must match in array slice assignments. This implementation raises NUMERIC_ERROR when the array type is declared. (See test E52103Y.) In assigning one-dimensional array types, the expression appears to be evaluated in its entirety before CONSTRAINT_ERROR is raised when checking whether the expression's subtype is compatible with the target's subtype. In assigning two-dimensional array types, the expression does not appear to be evaluated in its entirety before CONSTRAINT_ERROR is raised when checking whether the expression's subtype is compatible with the target's subtype. (See test C52013A.) Discriminated types. During compilation, an implementation is allowed to either accept or reject an incomplete type with discriminants that is used in an access type definition with a compatible discriminant constraint. This implementation accepts such subtype indications. (See test E38104A.) In assigning record types with discriminants, the expression appears to be evaluated in its entirety before CONSTRAINT_ERROR is raised when checking whether the expression's subtype is compatible with the target's subtype. (See test C52013A.) Aggregates. In the evaluation of a multi-dimensional aggregate, all choices appear to be evaluated before checking against the index type. (See tests C43207A and C43207B.) In the evaluation of an aggregate containing subaggregates, all choices are evaluated before being checked for identical bounds. (See test E43212B.) All choices are evaluated before CONSTRAINT_ERROR is raised if a bound in a nonnull range of a nonnull aggregate does not belong to an index subtype. (See test E43211B.) Functions An implementation may allow the declaration of a parameterless function and an enumeration literal having the same profile in the same immediate scope, or it may reject the function declaration. If it accepts the function declarations, the use of the enumeration literal's identifier denotes the function. This implementation rejects the declarations. (See test E66001D.) Representation clauses. The Ada Standard does not require an implementation to support representation clauses. If a representation clause is not supported, then the implementation must reject it. While the operation of representation clauses is not checked by Version 1.8 of the ACVC, they are used in testing other language features. This implementation accepts 'SIZE and 'STORAGE_SIZE for tasks, 'STORAGE_SIZE for collections, and 'SMALL clauses. Enumeration representation clauses, including those that specify noncontiguous values, appear to be supported. (See tests CS5B16A, C87B62A, C87B62B, C87B62C, and BC1002A.) Pragmas. The pragma INLINE is not supported for procedures. The pragma INLINE is not supported for functions. (See tests CA3004E and CA3004F.) Input/Output. The package SEQUENTIAL_IO can be instantiated with unconstrained array types and record types with discriminants. The package DIRECT_IO can be instantiated with unconstrained array types and record types with discriminants without defaults. (See tests AE2101C, AE2101H, CE2201D, CE2201E, and CE2401D.) This implementation implements input/output packages SEQUENTIAL_IO, DIRECT_IO and TEXT_IO as "null" packages. The package raises two possible exceptions, details of which are given in paragraph F.8 of Appendix B. Generics. Generic subprogram declarations and bodies can be compiled in separate compilations. (See test CA2009F.) Generic package declarations and bodies can be compiled in separate compilations. (See tests CA2009C and BC3205D.) 3.1 TEST RESULTS Version 1.8 of the ACVC contains 2399 tests. When validation testing of SD Ada-Plus VAX/VMS x MC68020 was performed, 19 tests had been withdrawn. The remaining 2380 tests were potentially applicable to this validation. The AVF determined that 462 tests were inapplicable to this implementation, and that the 1918 applicable tests were passed by the implementation. The AVF concludes that the testing results demonstrate acceptable conformity to the Ada Standard. 3.2 SUMMARY OF TEST RESULTS BY CLASS <table> <thead> <tr> <th>RESULT</th> <th>TEST CLASS</th> <th>TOTAL</th> </tr> </thead> <tbody> <tr> <td></td> <td>A B C D E L</td> <td></td> </tr> <tr> <td>Passed</td> <td>69 865 912</td> <td>17 11</td> </tr> <tr> <td>Failed</td> <td>0 0 0</td> <td>0 0</td> </tr> <tr> <td>Inapplicable</td> <td>0 2 456</td> <td>0 2</td> </tr> <tr> <td>Withdrawn</td> <td>0 7 12</td> <td>0 0</td> </tr> <tr> <td>TOTAL</td> <td>69 874 1380</td> <td>17 13</td> </tr> </tbody> </table> 3.3 SUMMARY OF TEST RESULTS BY CHAPTER <table> <thead> <tr> <th>RESULT</th> <th>CHAPTER</th> </tr> </thead> <tbody> <tr> <td>Passed</td> <td>5 1 6 7 8 9 10 11 12 13 14 TOTAL</td> </tr> <tr> <td>93 205 280 244 161 97 138 261 123 31 218 67 1918</td> <td></td> </tr> <tr> <td>Failed</td> <td>0 0 0 0 0 0 0 0 0 0 0 0</td> </tr> <tr> <td>Inapplicable</td> <td>23 120 140 3 0 0 1 1 7 1 0 166 462</td> </tr> <tr> <td>Withdrawn</td> <td>0 5 5 0 0 1 1 2 4 0 1 0 19</td> </tr> <tr> <td>TOTAL</td> <td>116 330 425 247 161 98 140 264 134 32 219 233 2399</td> </tr> </tbody> </table> 3.4 WITHDRAWN TESTS The following 19 tests were withdrawn from ACVC Version 1.8 at the time of this validation: - C32114A - B33203C - C34018A - C35904A - B37401A - C41404A - B45116A - C48008A - B49006A - B4A010C - B74101B - B87B50A - C92005A - C940ACA - CA3005A - BC3204C - (4 tests) See Appendix D for the reason that each of these tests was withdrawn. 3.5 INAPPLICABLE TESTS Some tests do not apply to all compilers because they make use of features that a compiler is not required by the Ada Standard to support. Others may depend on the result of another test that is either inapplicable or withdrawn. For this validation attempt, 462 tests were inapplicable for the reasons indicated: - C34001E, B52004D, B55B09C, and C55B07A use LONG_INTEGER which is not supported by this compiler. - C34001F and C35702A use SHORT_FLOAT which is not supported by this compiler. - C34001G and C35702B use LONG_FLOAT which is not supported by this compiler. TEST INFORMATION - C64104M, CB1010B, CZ1201D requires storage space for a fixed size collection which is exceeded during execution. On the MC68020 target computer the default collection size allocation is 1K bytes. STORAGE_ERROR is raised during execution because the total size of the objects within the collection is greater than this default storage size. Although these three tests were ruled inapplicable, modified versions using representation clauses to increase the collection sizes for C64104M, CB1010B and CZ1201D to 4K, 10K and 2K respectively. These modified tests all executed successfully. - B86001DT requires a predefined numeric type other than those defined by the Ada language in package STANDARD. There is no such type for this implementation. - CB6001F. A separate package is used to collect the executable test results from the MC68020 target. The package TEST_IO uses the package SYSTEM, thus when this test recompiles package SYSTEM it invalidates the package TEST_IO. This means that the test cannot be built and executed. - C96005B checks implementations for which the smallest and largest values in type DURATION are different from the smallest and largest values in DURATION's base type. This is not the case for this implementation. - CA3004E, EA3004C, and LA3004A use INLINE pragma for procedures which is not supported by this compiler. - CA3004F, EA3004D, and LA3004B use INLINE pragma for functions which is not supported by this compiler. - This implementation raises USE_ERROR when an attempt is made to create/open a file. As a result, the following 166 tests are inapplicable, as is CZ1103A (one of the support units), although this test does not appear in the counts. CE2102D..F (3 tests) CE2204A..B (2 tests) CE3104A CE2102I..J (2 tests) CE2210A CE3107A CE2104A..D (4 tests) CE2401A..F (6 tests) CE3108A..B (2 tests) CE2105A CE2404A CE3109A CE2106A CE2405B CE3110A CE2107A..F (6 tests) CE2406A CE3111A..E (5 tests) CE2108A..D (4 tests) CE2407A CE3112A..B (2 tests) CE2109A CE2408A CE3114A..B (2 tests) CE2110A..C (3 tests) CE2409A CE3115A CE2111A..E (5 tests) CE2410A CE3203A CE2111G..H (2 tests) CE3102B CE3208A CE2201A..F (6 tests) CE3103A CE3310A..C (3 tests) TEST INFORMATION CE3302A CE3303A CE3402A..D (4 tests) CE3412A CE3403A. C (3 tests) CE3413A CE3403E.F (2 tests) CE3413C CE3404A..C (3 tests) CE3602A..D (4 tests) CE3805A..B (2 tests) CE3405A..D (4 tests) CE3603A CE3406A..D (4 tests) CE3604A CE3407A..C (3 tests) CE3605A..E (5 tests) CE3905A..C (3 tests) CE3408A..C (3 tests) CE3606A..B (2 tests) CE3905L CE3409A CE3704A..B (2 tests) CE3906A..C (3 tests) CE3409C..F (4 tests) CE3704D..F (3 tests) CE3906E..F (2 tests) CE3410A The following 278 tests make use of floating-point precision that exceeds the maximum of 6 supported by the implementation: C24113C..Y (23 tests) C35705C..Y (23 tests) C35706C..Y (23 tests) C35707C..Y (23 tests) C35708C..Y (23 tests) C35802C..Y (23 tests) C45241C..Y (23 tests) C45321C..Y (23 tests) C45421C..Y (23 tests) C45424C..Y (23 tests) C45521C..Z (24 tests) C45621C..Z (24 tests) Also one of the support tests, CZ1103A does not produce output equivalent to the expected output. This is because the exception USE_ERROR is raised on all attempts to create a file within this test. 3.6 SPLIT TESTS If one or more errors do not appear to have been detected in a Class B test because of compiler error recovery, then the test is split into a set of smaller tests that contain the undetected errors. These splits are then compiled and examined. The splitting process continues until all errors are detected by the compiler or until there is exactly one error per split. Any Class A, Class C, or Class E test that cannot be compiled and executed because of its size is split into a set of smaller subsets that can be processed. Splits were required for 6 Class B tests. B22003A B29001A B74401C BC1202E BC10AEB BC3204B 3-4 3.7 ADDITIONAL TESTING INFORMATION 3.7.1 Prevalidation Prior to validation, a set of test results for ACVC Version 1.8 produced by SD Ada-Plus VAX/VMS x MC68020 was submitted to the AVF by the applicant for review. Analysis of these results demonstrated that the compiler successfully passed all applicable tests, and the compiler exhibited the expected behaviour on all inapplicable tests. 3.7.2 Test Method Testing of SD Ada-Plus VAX/VMS x MC68020 using ACVC Version 1.8 was conducted on-site by a validation team from the AVF. The configuration consisted of a VAX 8600 host operating under VMS, 4.2, and a Motorola MC68020 target under no operating system. The host and target computers were linked via RS232C connector. A magnetic tape containing all tests was taken on-site by the validation team for processing. The magnetic tape contained tests that make use of implementation-specific values which were customized before being written to the magnetic tape. Tests requiring splits during the prevalidation testing were not included in their split form on the magnetic tape. The contents of the magnetic tape were loaded directly onto the host computer. After the test files were loaded to disk, the full set of tests was compiled and linked on the VAX 8600, and all executable tests were run on the Motorola MC68020. Object files were linked on the host computer, and executable images were transferred to the target computer via RS232C connector. Results were printed from the host computer, with results being transferred to the host computer via RS232C connector. The compiler was tested using command scripts provided by Systems Designers plc. and reviewed by the validation team. The following options were in effect for testing: <table> <thead> <tr> <th>Option</th> <th>Effect</th> </tr> </thead> <tbody> <tr> <td>&quot;list=&gt;on&quot;</td> <td>this ensures that the compilation listings produced by the compiler contain a full listing of the test source.</td> </tr> </tbody> </table> Tests were compiled, linked and executed (as appropriate) using a single host computer and a single target computer. Test output, compilation listings, and job logs were captured on magnetic tape and archived at AVF. The listings examined on-site by the validation team were also archived. 3.7.3 TEST SITE The validation team arrived at Systems Designers plc., Camberley on 28 November 1986 and departed after testing was completed on 1 December 1986. Systems Designers plc., has submitted the following compliance statement concerning the SD Ada-Plus VAX/VMS x MC68020. COMPLIANCE STATEMENT Compliance Statement Base Configuration: Compiler: SD Ada-Plus VAX/VMS x MC68020, 2B.00 Test Suite: Ada* Compiler Validation Capability, Version 1.8 Host Computer: Machine: VAX 8600 Operating System: VMS 4.2 Target Computer: Machine: Motorola MC68020 implemented on Motorola MVME 133 board, incorporating MC68881 floating point co-processor Operating System: no operating system Communications Network: RS232C connector via a null modem using a protocol conforming to RS232C. Systems Designers plc. has made no deliberate extensions to the Ada language standard. Systems Designers plc. agrees to the public disclosure of this report. Systems Designers plc. agrees to comply with the Ada trademark policy, as defined by the Ada Joint Program Office. Date: 1 December 1986 Systems Designers plc Bill Davison Customer Service Manager *Ada is registered trademark of the United States Government (Ada Joint Program Office). APPENDIX B APPENDIX F OF THE Ada STANDARD The only allowed implementation dependencies correspond to implementation-dependent pragmas, to certain machine-dependent conventions as mentioned in chapter 13 of MIL-STD-1815A, and to certain allowed restrictions on representation classes. The implementation-dependent characteristics of the SD Ada-Plus VAX/VMS x MC68020, 2B.00 are described in the following sections which discuss topics one through eight as stated in Appendix F of the Ada Language Reference Manual (ANSI/MIL-STD-1815A). The specification of the package STANDARD is also included in this appendix. APPENDIX F TO THE REFERENCE MANUAL ## AMENDMENT RECORD <table> <thead> <tr> <th>Amendment Notification</th> <th>Date of Issue</th> <th>Incorporated By</th> <th>Date Incorporated</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> Systems Designers Ada-Plus Appendix F Contents Page 1 CONTENTS PREFACE APPENDIX F IMPLEMENTATION-DEPENDENT CHARACTERISTICS F.1 IMPLEMENTATION-DEPENDENT PRAGMAS F.1.1 Pragma EXPORT F.1.2 Pragma DEBUG F.1.3 Pragma SUPPRESS ALL F.2 IMPLEMENTATION-DEPENDENT ATTRIBUTES F.3 PACKAGE SYSTEM F.4 RESTRICTIONS ON REPRESENTATION CLAUSES F.4.1 Length Clauses F.4.1.1 Attribute SIZE F.4.1.2 Attribute STORAGE_SIZE F.4.1.3 Attribute SMALL F.4.2 Record Representation Clauses F.4.2.1 Alignment Clause F.4.2.2 Component Clause F.4.3 Address Clauses F.4.3.1 Object Addresses F.4.3.2 Entry Addresses F.5 IMPLEMENTATION-GENERATED NAMES F.6 INTERPRETATION OF EXPRESSIONS IN ADDRESS CLAUSES F.7 UNCHECKED CONVERSIONS F.8 CHARACTERISTICS OF THE INPUT/OUTPUT PACKAGES F.8.1 The Package TEXT_IO F.8.2 The Package IO_EXCEPTIONS F.9 PACKAGE STANDARD F.10 PACKAGE MACHINE_CODE F.11 LANGUAGE-DEFINED PRAGMAS F.11.1 Pragma INLINE F.11.2 Pragma INTERFACE F.11.2.1 Assembler Names F.11.2.2 Parameter Passing Conventions F.11.2.3 Procedure-Calling Mechanism F.11.3 Pragma OPTIMISE F.11.4 Pragma SUPPRESS D.A.REF.AF[BC-MH] 1.0 Ada-Plus Appendix F Contents Page 2 FIGURES Fig. F.1 Package SYSTEM Fig. F.2 Package STANDARD Fig. F.3 Routine Activation Record on Entry to Called Subprogram Fig. F.4 Routine Entry And Exit Code D.A.REF.AF[BC-MH] 1.0 This document describes the implementation-dependent characteristics of the VAX/VMS x MC68020 SD-Ada Compiler. The document should be considered as Appendix F of the Reference Manual for the Ada Programming Language. APPENDIX F IMPLEMENTATION-DEPENDENT CHARACTERISTICS F.1 IMPLEMENTATION-DEPENDENT PRAGMAS F.1.1 Pragma EXPORT Form pragma EXPORT ([ADA_NAME=>] simple_name, [EXT_NAME=>] "name_string"); The pragma EXPORT takes the name of an Ada variable in the first parameter position and a string in the second parameter position. The name must be the simple name of a variable in the package level static data area in scope, and name-string must be a string literal which is unique in any program produced for the target, otherwise the program is erroneous. The parameter name_string must be a string literal which conforms to the naming conventions imposed by the MC68020 builder. The name must be no more than eight characters in length and start with a dot or upper case letter. The rest of the characters are restricted to being a digit, dot, dollar, underline or upper case letter. Position The pragma EXPORT may be placed at the position of a basic declarative item of a library package specification or in the declarative part of a library package body. Effect Use of this pragma causes the compiler to generate additional linkage information. This associates the string literal of the second parameter with the variable nominated by the first parameter. This external naming facility is restricted to data objects held in static areas. F.1.2 Pragma DEBUG Form pragma DEBUG ([NAME=>]name); The pragma DEBUG takes a name as the single argument. The value yielded by the parameter must be scalar or access type. Position The pragma DEBUG may be placed at the position of a basic_declarative_item or a statement where the name is in scope. Effect Use of this pragma causes the compiler to generate tracing code, and auxiliary information in debug symbol tables. This tracing code is loaded into the target computer in such a way that the main thread of normal execution perceives no reference to the trace code, and the values embedded in the main thread code, such as offsets, remain unaffected. The tracing code may be activated by use of the Debug System. F.1.3 Pragma SUPPRESS_ALL Form pragma SUPPRESS_ALL; This pragma has no parameters. Position The pragma SUPPRESS_ALL is only allowed at the start of a compilation before the first compilation unit. Effect Use of this pragma prevents the compiler from generating any run-time checks for CONSTRAINT_ERROR or NUMERIC_ERROR. F.2 IMPLEMENTATION-DEPENDENT ATTRIBUTES There are no such attributes. F.3 PACKAGE SYSTEM The specification of the package SYSTEM is given in Figure F.1. In order to obtain addresses the routine CONVERT ADDRESS is supplied. The function takes a parameter of type EXTERNAL ADDRESS which must be 8 or less Hexadecimal characters representing an address. If the address is outside the range 0..MEMORY SIZE-1 the predefined exception CONSTRAINT_ERROR is raised. CONSTRAINT_ERROR is also raised if the EXTERNAL ADDRESS contains any non-hexadecimal characters. The function is overloaded to take a parameter of type ADDRESS and return EXTERNAL ADDRESS. This value will have all leading zeros suppressed unless the address is zero in which case a single zero will be returned. package SYSTEM is type ADDRESS is private; type NAME is (MC68020); SYSTEM_NAME : constant NAME := MC68020; STORAGE_UNIT : constant := 8; MEMORY_SIZE : constant := 2**32; MIN_INT : constant := -(2**31); MAX_INT : constant := (2**31)-1; MAX_DIGITS : constant := 6; MAX_MANTISSA : constant := 31; FINE_DELTA : constant := 2#1.0#E-30; TICK : constant := 2#1.0#E-7; subtype PRIORITY is INTEGER range 0 .. 15; type UNIVERSAL_INTEGER is range MIN_INT .. MAX_INT; subtype EXTERNAL_ADDRESS is STRING; function CONVERT_ADDRESS (ADDR : EXTERNAL_ADDRESS) return ADDRESS; function CONVERT_ADDRESS (ADDR : ADDRESS) return EXTERNAL_ADDRESS; function "+" (ADDR : ADDRESS; OFFSET : UNIVERSAL_INTEGER) return ADDRESS; private -- type ADDRESS is system-dependent end SYSTEM; Figure F.1 Package SYSTEM F.4 RESTRICTIONS ON REPRESENTATION CLAUSES F.4.1 Length Clauses F.4.1.1 Attribute SIZE The value specified for SIZE must not be less than that chosen by default by the compiler (e.g. 8 for enumeration types, 32 for integer types, real types and access types, etc.). The value given is ignored. F.4.1.2 Attribute STORAGE_SIZE For access types the limit is governed by the indexing range of the target machine and the maximum is equivalent to SYSTEM.ADDRESS'LAST. For task types the limit is also SYSTEM.ADDRESS'LAST. F.4.1.3 Attribute SMALL Only values which are powers of two are supported for this attribute. F.4.2 Record Representation Clauses F.4.2.1 Alignment Clause The static_simple_expression used to align records onto storage unit boundaries must deliver the values 1 or 2. F.4.2.2 Component Clause The static range is restricted to ranges which force component alignment onto storage unit boundaries only, (i.e. multiples of 8 bits). The component size defined by the static range must not be less than the minimum number of bits required to hold every allowable value of the component. For a component of non-scalar type, the size must not be larger than that chosen by the compiler for the type. F.4.3 Address Clause F.4.3.1 Object Addresses For objects with an address clause, a pointer is declared which points to the object at the given address. There is a restriction however that the object cannot be initialised either explicitly or implicitly (i.e. the object cannot be an access type). F.4.3.2 Entry Addresses Address clauses for entries are supported; the address given is the address of an interrupt vector. F.5 IMPLEMENTATION-GENERATED NAMES There are no implementation-generated names denoting implementation-dependent components. F.6 INTERPRETATION OF EXPRESSIONS IN ADDRESS CLAUSES The expressions in an address clause are interpreted as absolute addresses on the target. F.7 UNCHECKED CONVERSIONS The implementation imposes the restriction on the use of the generic function UNCHECKED CONVERSION that the size of the target type must not be greater than the size of the source type. F.8 CHARACTERISTICS OF THE INPUT/OUTPUT PACKAGES Packages SEQUENTIAL IO, DIRECT IO and the predefined input/output package TEXT IO are implemented as "null" packages which conform to the specification given in the Ada Language Reference Manual. This package raises the exceptions specified in Chapter 14 of the Language Reference Manual. There are two possible exceptions which are raised by this package. These are given here in the order in which they will be raised. a) The exception STATUS_ERROR is raised by an attempt to operate upon a file that is not open (no files can be opened). b) The exception USE_ERROR is raised if exception STATUS_ERROR is not raised. Note that MODE_ERROR cannot be raised as no file can be opened (therefore it cannot have a current mode) and NAME_ERROR cannot be raised since there are no restrictions on file names. The predefined package IO_EXCEPTIONS is defined in the Ada Language Reference Manual. The predefined package LOW_LEVEL_IO is not provided. The implementation-dependent characteristics are described in Sections F.8.1 to F.8.2. F.8.1 The Package TEXT_IO When any procedure is called the exception STATUS_ERROR or USE_ERROR is raised (there are no restrictions on the format of the NAME or FORM parameters). The type COUNT is defined: ```plaintext type COUNT is range 0 .. INTEGER'LAST; ``` and the subtype FIELD is defined: ```plaintext subtype FIELD is INTEGER range 0 .. 132; ``` F.8.2 The Package IO_EXCEPTIONS The specification of the package is the same as that given in the Ada Language Reference Manual. F.9 PACKAGE STANDARD The specification of package STANDARD is given in Figure F.2. package STANDARD is type BOOLEAN is (FALSE, TRUE); type SHORT_INTEGER is range -32768 .. 32767; type INTEGER is range -2147483648 .. 2147483647; type FLOAT is digits 6 range -16#0.FFFFFF#E32 .. 16#0.FFFFFF#E32; type CHARACTER is (nul, soh, stx, etx, eot, enq, ack, bel, bs, ht, lf, vt, ff, cr, so, si, dle, dc1, dc2, dc3, dc4, nak, syn, etb, can, em, sub, esc, fs, gs, rs, us, Figure F.2 (1 of 4) Package STANDARD for CHARACTER use -- ASCII characters without holes (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127); package ASCII is -- Control characters: NUL : constant CHARACTER := nul; SOH : constant CHARACTER := soh; STX : constant CHARACTER := stx; ETX : constant CHARACTER := etx; EOT : constant CHARACTER := eot; ENQ : constant CHARACTER := enq; ACK : constant CHARACTER := ack; BEL : constant CHARACTER := bel; BS : constant CHARACTER := bs; HT : constant CHARACTER := ht; LF : constant CHARACTER := lf; VT : constant CHARACTER := vt; FF : constant CHARACTER := ff; CR : constant CHARACTER := cr; SO : constant CHARACTER := so; SI : constant CHARACTER := si; DLE : constant CHARACTER := dle; DC1 : constant CHARACTER := dcl; DC2 : constant CHARACTER := dc2; DC3 : constant CHARACTER := dc3; DC4 : constant CHARACTER := dc4; NAK : constant CHARACTER := nak; SYN : constant CHARACTER := syn; Figure F.2 (2 of 4) Package STANDARD ETB : constant CHARACTER := etb; CAN : constant CHARACTER := can; EM : constant CHARACTER := em; SUB : constant CHARACTER := sub; ESC : constant CHARACTER := esc; FS : constant CHARACTER := fs; GS : constant CHARACTER := gs; RS : constant CHARACTER := rs; US : constant CHARACTER := us; DEL : constant CHARACTER := del; -- Other characters: EXCLAM : constant CHARACTER := '!' ; QUOTATION : constant CHARACTER := '"'; SHARP : constant CHARACTER := '#' ; DOLLAR : constant CHARACTER := '$'; PERCENT : constant CHARACTER := '%' ; AMPER : constant CHARACTER := '&'; COLON : constant CHARACTER := ':' ; SEMICOLON : constant CHARACTER := ';'; QUERY : constant CHARACTER := '?' ; ATSIGN : constant CHARACTER := '@'; LBRAK : constant CHARACTER := '['; BAR : constant CHARACTER := '|'; RBRAK : constant CHARACTER := ']'; UNDER : constant CHARACTER := '_'; GRAVE : constant CHARACTER := '?'; L_CIRC : constant CHARACTER := 'c'; BRCR : constant CHARACTER := 'r'; L_BRAKE : constant CHARACTER := '{'; TILDE : constant CHARACTER := '~'; -- Lower case letters: LC_A : constant CHARACTER := 'a'; LC_B : constant CHARACTER := 'b'; LC_C : constant CHARACTER := 'c'; LC_D : constant CHARACTER := 'd'; LC_E : constant CHARACTER := 'e'; LC_F : constant CHARACTER := 'f'; LC_G : constant CHARACTER := 'g'; LC_H : constant CHARACTER := 'h'; LC_I : constant CHARACTER := 'i'; LC_J : constant CHARACTER := 'j'; LC_K : constant CHARACTER := 'k'; LC_L : constant CHARACTER := 'l'; LC_M : constant CHARACTER := 'm'; LC_N : constant CHARACTER := 'n'; LC_O : constant CHARACTER := 'o'; LC_P : constant CHARACTER := 'p'; LC_Q : constant CHARACTER := 'q'; LC_R : constant CHARACTER := 'r'; LC_S : constant CHARACTER := 's'; LC_T : constant CHARACTER := 't'; LC_U : constant CHARACTER := 'u'; LC_V : constant CHARACTER := 'v'; LC_W : constant CHARACTER := 'w'; LC_X : constant CHARACTER := 'x'; LC_Y : constant CHARACTER := 'y'; LC_Z : constant CHARACTER := 'z'; end ASCII; -- Predefined subtypes: subtype NATURAL is INTEGER range 0 .. INTEGER'LAST; subtype POSITIVE is INTEGER range 1 .. INTEGER'LAST; -- Predefined string type: type STRING is array (POSITIVE range <>) of CHARACTER; type DURATION is delta 2#1.0#E-7 range -16777216.0 .. 16777215.0; -- The predefined exceptions: CONSTRAINT_ERROR : exception; NUMERIC_ERROR : exception; PROGRAM_ERROR : exception; STORAGE_ERROR : exception; TASKING_ERROR : exception; end STANDARD; Figure F.2 (4 of 4) Package STANDARD F.10 PACKAGE MACHINE_CODE Package MACHINE_CODE is not supported by the SD-Ada Compiler. F.11 LANGUAGE-DEFINED PRAGMAS The definition of certain language-defined pragmas is incomplete in the Ada Language Reference Manual. The implementation restrictions imposed on the use of such pragmas are specified in Sections F.11.1 to F.11.4. F.11.1 Pragma INLINE This pragma supplies a recommendation for inline expansion of a subprogram to the compiler. This pragma is ignored by the SD-Ada Compiler. F.11.2 Pragma INTERFACE This pragma allows subprograms written in another language to be called from Ada. The SD-Ada Compiler only supports pragma INTERFACE for the language ASSEMBLER. Normal Ada calling conventions are used by the SD-Ada Compiler when generating a call to an ASSEMBLER subprogram. F.11.2.1 Assembler Names The name of an interface routine must conform to the naming conventions both of Ada and of the MC68020 builder. F.11.2.2 Parameter Passing Conventions Parameters are passed to the called procedure in the order given in the specification of the subprogram, with default expressions evaluated, if present. Scalars are passed by copy for all parameter modes (the value is copied out for parameters with mode out). Composite types are passed by reference for all parameter modes. F.11.2.3 Procedure-Calling Mechanism The procedure-calling mechanism uses the run-time stack organisation shown in Figure F.3 and the routine entry and exit code shown in Figure F.4. LINK STACK <table> <thead> <tr> <th>Address</th> <th>Description</th> </tr> </thead> </table> | "Return" Address | "Return" Address | Return Address | Return Address <-- SP | N+19 | SP Saved Parameter pointer | N+15 | EXCEP Address of Exception Handler Table <-- PP | N+11 | DISPLAY Saved Display Entry for Current nesting level | N+7 | FP Dynamic Predecessor | N+3 | SP Saved Top of Link stack | N+22+P | L <Locals> Local Data | N+22 | P <parameters> Routine parameters (in order declared) <-- FP | N+20 | NEST*4 Current nesting level*4 | N+16 | FF Dynamic Predecessor | N+12 | FP Dynamic Predecessor | N+8 | SP Saved Top of Link stack | N | PP Saved Parameter pointer MAIN STACK Figure F.3 Routine Activation Record on Entry to Called Subprogram The implementation uses the following dedicated and temporary registers: - **SP** - Link Stack Pointer - **FP** - Frame Pointer - **PP** - Parameter Frame Pointer - **DP** - Display Pointer - **TS** - Main Stack Pointer Macros RM_P_BEGIN and RM_P_END are provided for the routine entry and exit code respectively. This code is shown in Figure F.4. **Routine Entry Code** ``` MOVE.L SP,(PP)+ MOVE.L FP,(PP)+ MOVE.L n(DP),(PP)+ MOVEA.L PP,FP MOVE.L FP,(FP)+ MOVE.W #<nest*4>,(FP)+ MOVE.L FP,n(DP) ``` **Routine Exit Code** ``` MOVE.L -(PP),n(DP) MOVEA.L -(PP),FP MOVEA.L -(PP),SP RTS ``` **Figure F.4** Routine Entry And Exit Code **F.11.3 Pragma OPTIMISE** This pragma supplies a recommendation to the compiler for the criterion upon which optimisation is to be performed. This pragma is ignored by the SD-Ada Compiler. **F.11.4 Pragma SUPPRESS** This pragma gives permission for specified run-time checks to be omitted by the compiler. This pragma is ignored by the SD-Ada Compiler. Readers Comments Do you find this document suitable to your needs? Is it understandable, usable, and well structured? Does it fit appropriately into the Documentation Set which accompanies your Product? We would like your comments: ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ ________________________________________________________________________ Did you find specific errors in the document? If so, can you please submit a User Documentation Problem (UDOP) Report, an example of which is included as part of the Release Details supplied with your product. Name _________________________________________________________________ Position _______________________________________________________________ Company ______________________________________________________________ Address ________________________________________________________________ Date ________________________________________________________________ Software Version No. ________________________________________________ Please return your comments to: Customer Services Group, Systems Designers plc, Pembroke House, Pembroke Broadway, Camberley, Surrey. GU15 3XD UNITED KINGDOM D.A.REF.AF{BC-MH} 1.0 APPENDIX C TEST PARAMETERS Certain tests in the ACVC make use of implementation-dependent values, such as the maximum length of an input line and invalid file names. A test that makes use of such values is identified by the extension .TST in its file name. Actual values to be substituted are identified by names that begin with a dollar sign. A value must be substituted for each of these names before the test is run. The values used for this validation are given below. <table> <thead> <tr> <th>NAME AND MEANING</th> <th>VALUE</th> </tr> </thead> <tbody> <tr> <td>$BIG_ID1</td> <td>A....A1 with varying last character.</td> </tr> <tr> <td>$BIG_ID2</td> <td>A....A2 with varying last character.</td> </tr> <tr> <td>$BIG_ID3</td> <td>A....A3A....A with varying middle character.</td> </tr> <tr> <td>$BIG_ID4</td> <td>A....A4A....A with varying middle character.</td> </tr> <tr> <td>$BIG_INT_LIT</td> <td>0....0298 with enough leading zeroes so that is is the size of the maximum line length.</td> </tr> <tr> <td>$BIG_REAL_LIT</td> <td>0....069.0E1 either of floating- or fixed-point type, has value of 690.0, and has enough leading zeroes to be the size of the maximum line length.</td> </tr> <tr> <td>NAME AND MEANING</td> <td>VALUE</td> </tr> <tr> <td>----------------------------------</td> <td>--------------------------------------------</td> </tr> <tr> <td>$BLANKS</td> <td>235 blanks</td> </tr> <tr> <td>A sequence of blanks twenty</td> <td></td> </tr> <tr> <td>characters fewer than the size</td> <td></td> </tr> <tr> <td>of the maximum line length.</td> <td></td> </tr> <tr> <td>$COUNT_LAST</td> <td>2147483647</td> </tr> <tr> <td>A universal integer literal</td> <td></td> </tr> <tr> <td>whose value is TEXT_IO.COUNT'LAST.</td> <td></td> </tr> <tr> <td>$EXTENDED_ASCII_CHARS</td> <td>&quot;abcdefghijklmnpqrstuvwxyz</td> </tr> <tr> <td>A string literal containing all</td> <td>!@$%^[]&quot;{}&quot;</td> </tr> <tr> <td>the ASCII characters with</td> <td></td> </tr> <tr> <td>printable graphics that are not</td> <td></td> </tr> <tr> <td>in the basic 55 Ada character</td> <td></td> </tr> <tr> <td>set.</td> <td></td> </tr> <tr> <td>$FIELD_LAST</td> <td>255</td> </tr> <tr> <td>A universal integer literal</td> <td></td> </tr> <tr> <td>whose value is TEXT_IO.FIELD'LAST</td> <td></td> </tr> <tr> <td>$FILENAME_WITH_BAD_CHARS</td> <td>X))!.dat</td> </tr> <tr> <td>An illegal external file name</td> <td></td> </tr> <tr> <td>that either contains invalid</td> <td></td> </tr> <tr> <td>characters or is too long if no</td> <td></td> </tr> <tr> <td>invalid characters exist.</td> <td></td> </tr> <tr> <td>$FILENAME_WITH_WILD_CARD_CHAR</td> <td>file*.dat</td> </tr> <tr> <td>An external file name that</td> <td></td> </tr> <tr> <td>either contains a wild card</td> <td></td> </tr> <tr> <td>character or is too long if no</td> <td></td> </tr> <tr> <td>wild card characters exists.</td> <td></td> </tr> <tr> <td>$GREATER_THAN_DURATION</td> <td>2.0</td> </tr> <tr> <td>A universal real value that lies</td> <td></td> </tr> <tr> <td>between DURATION'BASE'LAST and</td> <td></td> </tr> <tr> <td>DURATION'LAST if any, otherwise</td> <td></td> </tr> <tr> <td>any value in in the range of</td> <td></td> </tr> <tr> <td>DURATION.</td> <td></td> </tr> <tr> <td>$GREATER_THAN_DURATION_BASE_LAST</td> <td>16777216.0</td> </tr> <tr> <td>The universal real value that is</td> <td></td> </tr> <tr> <td>greater than DURATION'BASE'LAST,</td> <td></td> </tr> <tr> <td>if such a value exists.</td> <td></td> </tr> <tr> <td>$ILLEGAL_EXTERNAL_FILE_NAME</td> <td>bad_char</td> </tr> <tr> <td>An illegal external file name.</td> <td></td> </tr> <tr> <td>NAME AND MEANING</td> <td>VALUE</td> </tr> <tr> <td>------------------</td> <td>-------</td> </tr> <tr> <td>$\text{ILLEGAL_EXTERNAL_FILE_NAME2}$</td> <td>bad_char*</td> </tr> <tr> <td>An illegal external file name that is different from $\text{ILLEGAL_EXTERNAL_FILE_NAME1}$.</td> <td></td> </tr> <tr> <td>$\text{INTEGER_FIRST}$</td> <td>-2147483648</td> </tr> <tr> <td>The universal integer literal expression whose value is $\text{INTEGER_FIRST}$.</td> <td></td> </tr> <tr> <td>$\text{INTEGER_LAST}$</td> <td>2147483647</td> </tr> <tr> <td>The universal integer literal expression whose value is $\text{INTEGER_LAST}$.</td> <td></td> </tr> <tr> <td>$\text{LESS_THAN_DURATION}$</td> <td>-2.0</td> </tr> <tr> <td>A universal real value that lies between $\text{DURATION_BASE_FIRST}$ and $\text{DURATION_FIRST}$ if any, otherwise any value in the range of $\text{DURATION}$.</td> <td></td> </tr> <tr> <td>$\text{LESS_THAN_DURATION_BASE_FIRST}$</td> <td>-16777216.0</td> </tr> <tr> <td>The universal real value that is less than $\text{DURATION_BASE_FIRST}$, if such a value exists.</td> <td></td> </tr> <tr> <td>$\text{MAX_DIGITS}$</td> <td>6</td> </tr> <tr> <td>The universal integer literal whose value is the maximum digits supported for floating-point types.</td> <td></td> </tr> <tr> <td>$\text{MAX_IN_LEN}$</td> <td>20</td> </tr> <tr> <td>The universal integer literal whose value is the maximum input line length permitted by the implementation.</td> <td></td> </tr> <tr> <td>$\text{MAX_INT}$</td> <td>2147483647</td> </tr> <tr> <td>The universal integer literal whose value is $\text{SYSTEM_MAX_INT}$.</td> <td></td> </tr> <tr> <td>$\text{NAME}$</td> <td>$\text{NAME}$</td> </tr> <tr> <td>A name of a predefined numeric type other than $\text{FLOAT}$, $\text{INTEGER}$, $\text{SHORT_FLOAT}$, $\text{SHORT_INTEGER}$, $\text{LONG_FLOAT}$, or $\text{LONG_INTEGER}$ if one exists, otherwise any undefined name.</td> <td></td> </tr> <tr> <td>NAME AND MEANING</td> <td>VALUE</td> </tr> <tr> <td>------------------------------------------</td> <td>-----------</td> </tr> <tr> <td>$NEG_BASED_INT</td> <td>16</td> </tr> <tr> <td>A based integer literal whose highest order nonzero bit falls in the sign bit position of the representation for SYSTEM.MAX_INT.</td> <td>FFFFFFFFE</td> </tr> <tr> <td>$NON_ASCII_CHAR_TYPE</td> <td>(NON_NULL)</td> </tr> <tr> <td>An enumerated type definition for a character type whose literals are the identifier NON_NULL and all non_ASCII characters with printable graphics.</td> <td></td> </tr> </tbody> </table> APPENDIX D WITHDRAWN TESTS Some tests are withdrawn from the ACVC because they do not conform to the Ada Standard. The following 19 tests had been withdrawn at the time of validation testing for the reasons indicated. A reference of the form "AI-xxxxxx" is to an Ada Commentary. - C32114A: An unterminated string literal occurs at line 62. - B33203C: The reserved word "IS" is misspelled at line 45. - C34018A: The call of function G at line 114 is ambiguous in the presence of implicit conversions. - C35904A: The elaboration of subtype declarations SFX3 and SFX4 may raise NUMERIC_ERROR instead of CONSTRAINT_ERROR as expected in the test. - B37401A: The object declarations at lines 126 through 135 follow subprogram bodies declared in the same declarative part. - C41404A: The values of 'LAST and 'LENGTH are incorrect in the if statements from line 74 to the end of the test. - B45116A: ARRPRIBL 1 and ARRPRIBL 2 are initialized with a value of the wrong type--PRIBOOL_TYPE instead of ARRPRIBOOL_TYPE--at line 41. - C48008A: The assumption that evaluation of default initial values occurs when an exception is raised by an allocator is incorrect according to AI-00397. - B49006A: Object declarations at lines 41 and 50 are terminated incorrectly with colons, and end case; is missing from line 42. - B4A010C: The object declaration in line 18 follows a subprogram body of the same declarative part. WITHDRAWN TESTS . B74101B: The **begin** at line 9 causes a declarative part to be treated as a sequence of statements. . C87B50A: The call of "/=" at line 31 requires a use clause for package A. . C92005A: The "/=" for type PACK.BIG_INT at line 40 is not visible without a use clause for the package PACK. . C940ACA: The assumption that allocated task TT1 will run prior to the main program, and thus assign SPYNUMB the value checked for by the main program, is erroneous. . CA3005A,D: No valid elaboration order exists for these tests. (4 tests) . BC3204C: The body of BC3204C0 is missing. ATELMED 8
{"Source-Url": "http://www.dtic.mil/dtic/tr/fulltext/u2/a180064.pdf", "len_cl100k_base": 15147, "olmocr-version": "0.1.49", "pdf-total-pages": 54, "total-fallback-pages": 0, "total-input-tokens": 109497, "total-output-tokens": 18212, "length": "2e13", "weborganizer": {"__label__adult": 0.0003066062927246094, "__label__art_design": 0.00032830238342285156, "__label__crime_law": 0.0003345012664794922, "__label__education_jobs": 0.000652313232421875, "__label__entertainment": 5.233287811279297e-05, "__label__fashion_beauty": 0.0001647472381591797, "__label__finance_business": 0.0004756450653076172, "__label__food_dining": 0.0002124309539794922, "__label__games": 0.0007872581481933594, "__label__hardware": 0.00469970703125, "__label__health": 0.0002313852310180664, "__label__history": 0.0002343654632568359, "__label__home_hobbies": 9.85860824584961e-05, "__label__industrial": 0.0009140968322753906, "__label__literature": 0.000186920166015625, "__label__politics": 0.0001862049102783203, "__label__religion": 0.0004737377166748047, "__label__science_tech": 0.029296875, "__label__social_life": 4.1544437408447266e-05, "__label__software": 0.01338958740234375, "__label__software_dev": 0.94580078125, "__label__sports_fitness": 0.00021016597747802737, "__label__transportation": 0.0005588531494140625, "__label__travel": 0.00013935565948486328}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60707, 0.07348]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60707, 0.38087]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60707, 0.80992]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 0, null], [0, 650, false], [650, 1294, null], [1294, 1800, null], [1800, 1800, null], [1800, 3777, null], [3777, 5127, null], [5127, 6955, null], [6955, 8698, null], [8698, 10095, null], [10095, 12308, null], [12308, 14838, null], [14838, 15930, null], [15930, 16586, null], [16586, 18553, null], [18553, 20565, null], [20565, 22481, null], [22481, 23348, null], [23348, 24685, null], [24685, 26894, null], [26894, 28600, null], [28600, 30661, null], [30661, 31115, null], [31115, 31234, null], [31234, 32228, null], [32228, 32842, null], [32842, 32877, null], [32877, 33379, null], [33379, 34482, null], [34482, 34705, null], [34705, 34923, null], [34923, 35978, null], [35978, 36990, null], [36990, 38092, null], [38092, 38960, null], [38960, 40182, null], [40182, 41766, null], [41766, 42670, null], [42670, 43729, null], [43729, 45211, null], [45211, 46532, null], [46532, 47667, null], [47667, 49157, null], [49157, 49878, null], [49878, 50873, null], [50873, 52297, null], [52297, 53368, null], [53368, 56671, null], [56671, 58154, null], [58154, 58692, null], [58692, 60099, null], [60099, 60697, null], [60697, 60707, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 0, null], [0, 650, true], [650, 1294, null], [1294, 1800, null], [1800, 1800, null], [1800, 3777, null], [3777, 5127, null], [5127, 6955, null], [6955, 8698, null], [8698, 10095, null], [10095, 12308, null], [12308, 14838, null], [14838, 15930, null], [15930, 16586, null], [16586, 18553, null], [18553, 20565, null], [20565, 22481, null], [22481, 23348, null], [23348, 24685, null], [24685, 26894, null], [26894, 28600, null], [28600, 30661, null], [30661, 31115, null], [31115, 31234, null], [31234, 32228, null], [32228, 32842, null], [32842, 32877, null], [32877, 33379, null], [33379, 34482, null], [34482, 34705, null], [34705, 34923, null], [34923, 35978, null], [35978, 36990, null], [36990, 38092, null], [38092, 38960, null], [38960, 40182, null], [40182, 41766, null], [41766, 42670, null], [42670, 43729, null], [43729, 45211, null], [45211, 46532, null], [46532, 47667, null], [47667, 49157, null], [49157, 49878, null], [49878, 50873, null], [50873, 52297, null], [52297, 53368, null], [53368, 56671, null], [56671, 58154, null], [58154, 58692, null], [58692, 60099, null], [60099, 60697, null], [60697, 60707, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60707, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60707, null]], "pdf_page_numbers": [[0, 0, 1], [0, 0, 2], [0, 650, 3], [650, 1294, 4], [1294, 1800, 5], [1800, 1800, 6], [1800, 3777, 7], [3777, 5127, 8], [5127, 6955, 9], [6955, 8698, 10], [8698, 10095, 11], [10095, 12308, 12], [12308, 14838, 13], [14838, 15930, 14], [15930, 16586, 15], [16586, 18553, 16], [18553, 20565, 17], [20565, 22481, 18], [22481, 23348, 19], [23348, 24685, 20], [24685, 26894, 21], [26894, 28600, 22], [28600, 30661, 23], [30661, 31115, 24], [31115, 31234, 25], [31234, 32228, 26], [32228, 32842, 27], [32842, 32877, 28], [32877, 33379, 29], [33379, 34482, 30], [34482, 34705, 31], [34705, 34923, 32], [34923, 35978, 33], [35978, 36990, 34], [36990, 38092, 35], [38092, 38960, 36], [38960, 40182, 37], [40182, 41766, 38], [41766, 42670, 39], [42670, 43729, 40], [43729, 45211, 41], [45211, 46532, 42], [46532, 47667, 43], [47667, 49157, 44], [49157, 49878, 45], [49878, 50873, 46], [50873, 52297, 47], [52297, 53368, 48], [53368, 56671, 49], [56671, 58154, 50], [58154, 58692, 51], [58692, 60099, 52], [60099, 60697, 53], [60697, 60707, 54]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60707, 0.13043]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
564a2e5e534dc2c81f86c6a5fa303e3b78cc619d
Data-Driven Concurrency for High Performance Computing George Matheou Paraskevas Evripidou TR-17-1 May 2017 Data-Driven Concurrency for High Performance Computing George Matheou UCY-CS-TR-17-1 May 2017 Abstract In this work we utilize data-flow/data-driven techniques in order to improve the performance of High Performance Computing (HPC) systems. The proposed techniques are implemented and evaluated through an efficient, portable and robust programming framework, based on the Data-Driven Multithreading (DDM) model, that enables data-driven concurrency on HPC systems. DDM is a hybrid control-flow/data-flow model of execution that schedules threads based on data availability on sequential processors. The proposed framework is provided as an extension to FREDDO, a C++ implementation of the DDM model, that supports data-driven execution on single-node multi-core architectures. The proposed framework has been evaluated using a suite of eight benchmarks, with different characteristics, on two different systems: a 4-node AMD system with a total of 128 cores and a 64-node Intel HPC system with a total of 768 cores. The performance evaluation shows that the distributed FREDDO implementation scales well and tolerates scheduling overheads and memory latencies effectively. We also compare our framework with MPI/ScaLAPACK, SWARM and DDM-VM. The comparison results show that the proposed framework obtains comparable or better performance. Particularly, on the 768-core system, our framework is up to 1.61× faster than the MPI/ScaLAPACK implementation which is based solely on the sequential model of execution. Additionally, on the 128-core system, the proposed framework is up to 1.26× faster than SWARM and up to 1.42× faster than DDM-VM. Index terms—Data-Driven Multithreading; Distributed Execution; Runtime System; High Performance Computing 1 Introduction The end of the exponential growth of the sequential processors has facilitated the development of multi-core and many-core architectures. Such architectures have dominated the High Performance Computing (HPC) field, from shared memory systems to large-scale distributed memory clusters. Programming of such systems is mainly done through parallel extensions of the sequential model like MPI [1] and OpenMP [2]. These extensions do facilitate high productivity parallel programming, but also suffer from the inability to tolerate long memory and synchronization latencies [3, 4, 5, 6]. As a result, the high number of computational resources of the current HPC systems is not utilized efficiently [7]. Indeed, realistic applications running on current supercomputers typically use only 5%-10% of the machine’s peak processing power at any given time [4]. Even worse, as the number of cores will inevitably be increased in the coming years, the fraction that can be kept busy at any given time can be expected to plummet [4]. As such, new programming/execution models need to be developed in order to utilize efficiently the resources of the current and future HPC systems. Such a model is the data-flow model of execution [8, 9, 10]. Data-flow is a formal model that is inherently parallel, functional and asynchronous [8, 11]. It enforces only a partial ordering, as dictated by the true data-dependencies, which is the minimum synchronization possible. This is very beneficial for parallel processing since it allows to exploit the maximum potential parallelism [12]. Moreover, programming models and architectures, based on the data-flow principles, can handle concurrency and tolerate memory and synchronization latencies efficiently [3]. In this work we present and evaluate a programming framework that supports data-flow/data-driven concurrency on HPC systems. The proposed framework is based on the Data-Driven Multithreading (DDM) model of execution [13]. DDM is a hybrid control-flow/data-flow model of execution that schedules threads (called DThreads) based on data availability on conventional processors. A DThread is scheduled for execution after all of its required data have been produced, thus, no synchronization or communication latencies are experienced after a DThread begins its execution. The proposed programming framework extends the FREDDO framework [14], a C++ implementation of DDM, that targets single-node multi-core systems. The distributed FREDDO implementation provides (i) a software Distributed Shared Memory (DSM) system \[15\] with a shared Global Address Space, (ii) an implicit memory management based on data-driven semantics using data forwarding techniques \[16\] and (iii) an implicit distributed termination detection algorithm \[17\]. This allows the distributed DDM/FREDDO applications to be fundamentally the same as the single-node ones. This is because complicated tasks, such as, partitioning of data and computations, movement of data during execution and preserving coherency/consistency, are provided automatically. Furthermore, the proposed implementation provides an efficient distributed data-driven scheduling optimized for multithreaded architectures. This is achieved by implementing a lightweight two-layer scheduling mechanism based on the DDM's tagging system where scheduling operations, computations and network functionalities are operated asynchronously. The contributions presented in this paper are the following: 1. Provide an efficient, portable and robust distributed implementation of the DDM model. All the required data structures and mechanisms have been designed and implemented in order to support efficient distributed data-driven concurrency under the FREDDO framework. 2. Provide distributed recursion support for the DDM model. 3. The evaluation of the DDM model on two different systems: a 4-node local AMD system with a total of 128 cores and an open-access 64-node Intel HPC system with a total of 768 cores. The DDM model was previously evaluated only on very small distributed multi-core systems with up to 24 cores using the DDM-VM implementation \[18\]. For the evaluation of the distributed FREDDO implementation we have used a benchmark suite consisting of eight benchmarks with different characteristics: embarrassingly parallel and recursive algorithms as well as benchmarks with high complexity Dependency Graphs. The performance evaluation shows that FREDDO scales well on both systems. Particularly, on the AMD system for the 4-node configuration and the largest problem size, FREDDO achieves up to 93% of the ideal speedup with an average of 82%. On the CyTera system, for the 64-node configuration and the largest problem size, FREDDO achieves up to 84% of the ideal speedup with an average of 67%. 4. The comparison of the results obtained from the FREDDO framework and two state-of-the-art frameworks, the ScALAPACK \[19\] and SWARM \[20\], for the Cholesky benchmark. FREDDO is also compared with DDM-VM \[18\], the first distributed implementation of the DDM model, for the Cholesky and LU benchmarks. ScALAPACK is an MPI-based library that provides high-performance linear algebra routines for parallel distributed memory machines while DDM-VM and SWARM are software runtime systems that allow data-driven concurrency on distributed multi-core systems. The comparison results show that FREDDO achieves similar or better performance. 5. Provide simple mechanisms/optimizations to reduce the network traffic of a distributed DDM execution. Our experiments on the AMD system show that FREDDO can reduce the total amount of TCP packets by up to \(6.55\times\) and the total amount of data by up to \(16.7\%\) when is compared with the DDM-VM system. 6. The implementation of a connectivity layer with two different network interfaces: a Custom Network Interface (CNI) and MPI \[1\]. The CNI support allows to have a direct and fair comparison with frameworks that also utilize a custom network interface (e.g., DDM-VM and SWARM) where the MPI support provides portability and flexibility to the FREDDO framework. Finally, we provide comparison results for CNI and MPI for several benchmarks. The remainder of this paper is organized as follows. Section 2 describes the DDM model and the current single-node FREDDO implementation. Section 3 presents the distributed FREDDO implementation. An example of a FREDDO programming example is presented in Section 4. The experimental results and related work are presented in Sections 5 and 6 respectively. Finally, Section 7 concludes this paper. 2 Data-Driven Multithreading DDM [13] is a non-blocking multithreading model that decouples the execution from the synchronization part of a program and allows them to execute asynchronously, thus, tolerating synchronization and communication latencies efficiently. In DDM, a program consists of several threads of instructions (called DThreads) that have producer-consumer relationships. A DThread is scheduled for execution in a data-driven manner, that is, after all of its required data have been produced. DDM allows multiple instances of the same DThread to co-exist in the system. Each DThread instance is identified uniquely by the tuple: Thread ID (TID) and Context. Re-entrant constructs, such as loops and function calls, can be parallelized by mapping them into DThreads. For example, each iteration of a parallel loop can be executed by an instance of a DThread. The core of the DDM model is the Thread Scheduling Unit (TSU) [21] which is responsible for scheduling DThreads at run-time based on data-availability. For each DThread, the TSU collects meta-data (also called Thread Templates) that enable the management of the dependencies among the DThreads and determine when a DThread instance can be scheduled for execution. The TSU schedules a DThread instance for execution when all its producer-instances have completed their execution. Finally, the DDM model was evaluated by several software [22, 23, 18, 14] and hardware [24, 25] implementations. Although hardware data-flow/data-driven implementations can achieve higher performance than software runtime systems [25, 26], in this work, we provide a software implementation in order to utilize the resources of the current/commercial HPC systems. 2.1 Single-node FREDDO implementation FREDDO [14, 27] is an efficient object-oriented implementation of the DDM model [13]. It is a C++11 framework that supports data-driven execution on conventional single-node multi-core architectures. FREDDO provides a C++ API (Application Programming Interface) which includes a set of runtime functions and classes that help the programmers to develop DDM applications. The API provides the basic functionalities for parallelizing loops (up to three-level nested loops), recursive functions and simple function calls with data dependencies. In FREDDO, a program consists of DThreads which are implemented as C++ objects. FREDDO allows efficient DDM execution by utilizing three different components: an optimized C++ implementation of the TSU, the Kernels and the Runtime Support. A Kernel is a POSIX Thread (PThread) that is pinned on a specific core until the end of the DDM execution. This eliminates the overheads of the context-switching between the Kernels in the system. The Kernel is responsible for executing the ready DThread instances that are received from the TSU. The Runtime system enables the communication between the Kernels and the TSU through the Main Memory. It is also responsible for loading the Thread Templates in the TSU, for creating and running the Kernels, and for deallocating the resources allocated by DDM programs. The FREDDO’s Dependency Graph The Dependency Graph is a directed graph in which the nodes represent the DThread instances and the arcs represent the data-dependencies amongst them. Each instance of a DThread is paired with a special value called Ready Count (RC) that represents the number of its producers. An example of a Dependency Graph is shown in Figure 1 which consists of four DThreads (T1-T4). Notice that the number inside each node indicates its Context value. T1 is a SimpleDThread object, i.e. it has only one instance. T2 and T3 are MultipleDThread objects. A MultipleDThread object manages a DThread with multiple instances and can be used to parallelize one-level loops (or similar constructs). T4 is a MultipleDThread2D object, a special type of MultipleDThread, where the Context values consist of two parts, the outer and the inner. A MultipleDThread2D object can be used to parallelize a two-level nested loop where each Context value will hold an index of the outer and the inner loop. In this example T4 consists of 64 instances (with Contexts from \(<0,0>\) to \(<7,7>\)). Similarly, a user can parallelize a three-level nested loop by using a MultipleDThread3D object where its Context values consist of three parts: outer, middle and inner. The RC values are depicted as shaded values next to the nodes. For example, the instance $<3>$ of T3 has RC=2 because it has two producers, the instances $<1>$ and $<2>$ of T3. All the instances of T2 have RC=1 because they are waiting for only one producer, the instance $<0>$ of T1. The RC value is initiated statically and is dynamically decremented by the TSU each time a producer completes its execution. A DThread’s instance is deemed executable when its RC value reaches zero. In FREDDO, the operation used for decreasing the RC value is called Update. Update operations can be considered as tokens that are moving from the producer to consumer instances through the arcs of the graph. Multiple Updates are introduced in order to decrease multiple RC values of a DThread at the same time. This reduces the number of tokens in the graph. For instance, DThread T1 sends a Multiple Update command to DThread T2 in order to spawn all its instances, instead of sending 32 single Updates. A DThread instance can send single and multiple Updates to any other instance of any type, including itself (the only requirement is to have data dependencies). Thus, it is possible to build very complex Dependency Graphs. Figure 1: Example of a Dependency Graph. Figure 2: The FREDDO’s Distributed Architecture. 3 FREDDO: Distributed Support In this section we describe the FREDDO’s distributed architecture and its memory model, the scheduling and termination mechanisms, the network support, and the techniques that are used for reducing the network traffic in the system. We also briefly describe the distributed recursion support. 3.1 Distributed Architecture Figure 2 depicts the distributed architecture of FREDDO. It is composed by multi-core nodes connected by a global network interconnect (e.g., Ethernet, InfiniBand, etc.). A Network Manager is implemented in each node, that abstracts the details of the network interconnect and allows the inter-node communication. The FREDDO’s runtime system is responsible for handling the communication and data management across the nodes, for managing the applications’ Dependency Graphs and for scheduling/executing the ready DThread instances on the cores of the entire system. The same application binary is executed on all the nodes where one of them is selected as the RootNode. The RootNode is responsible for detecting the termination of the distributed FREDDO applications and for gathering the results for validation purposes (this is optional). 3.2 Memory Model FREDDO implements a software Distributed Shared Memory (DSM) system [15] with a shared Global Address Space (GAS) support. Part, or all of the main memory space on each node, is mapped to the DSM’s GAS. This approach creates an identical address space on each node, which gives the view of a single distributed address space. The conventional main memory addresses of shared objects (scalar values, vectors, etc.) are registered in the GAS by storing them in the Global Address Directory (GAD) of each node. For each such address, the runtime assigns to it a unique identifier (called GAS_ID) which is identical in each node. This allows the runtime system to transfer data between the nodes (from one local main memory to another) by using the GAS_IDs. For preserving memory consistency we employ data forwarding [16]. Particularly, the produced data of a DThread instance is forwarded to its consumers, running on remote nodes, before the latter start their execution. This is guaranteed by sending the Update operations after the data transfers are completed. To support this functionality, each Kernel is associated with a Data Forward Table (DFT). A DFT keeps track of the produced data segments of the currently executed DThread instance. When the instance finishes its execution, the runtime uses the DFT entries to transfer the produced data to the remote nodes, implicitly. The data-driven semantics of our model allow to have a lightweight memory consistency mechanism where expensive coherence operations are not required. The remote read operations are eliminated, thus, the total communication cost can be reduced. Coherence operations are applied only within each node’s memory hierarchy, by hardware, since each node is a conventional multi-core processor. 3.3 Scheduling Mechanisms FREDDO provides a lightweight distribution scheme, based on the DDM’s tagging system [13], to distribute and execute the DThread instances on the system’s nodes. Particularly, the mapping of the DThread instances to the nodes is determined at compile time based on their Context values (the tags). However, the execution of the ready DThread instances is determined at runtime, based on data-availability. This approach simplifies the scheduling and data management operations as well as it reduces the runtime overheads. The FREDDO’s distribution scheme is implemented by two different scheduling mechanisms, the intra-node and the inter-node. 3.3.1 Inter-node Scheduling Mechanism The inter-node mechanism is handled by the Distributed Scheduling Unit (DSU) which decides if the Update operations and the output data of a Producer-DThread instance will be forwarded to a remote node (or nodes) or in the local node. In the former case, the runtime will send the data (Updates and consumed data) as network messages, via the FREDDO’s Network Manager, to the corresponding remote node(s). In the latter case, the Update operations are sent to the local TSU. 3.3.2 Intra-node Scheduling Mechanism The intra-node mechanism is handled by the TSU. The TSU is responsible for storing the Dependency Graph of the applications, the Thread Templates (in the Template Memory) and the RC values of the DThread Instances (in the Synchronization Memory). The TSU fetches local Updates from the Kernels, through the DSU, or remote Updates from the Network Manager. For each Update (TID + Context), the TSU locates the Thread Template of the DThread from the Template Memory and decrements the RC value in the Synchronization Memory. If the RC value of any DThread’s instance reaches zero, then it is deemed executable and it is sent to the TSU’s Local Scheduler. The Local Scheduler distributes the ready DThread instances to the Kernels in order to achieve load-balancing (it selects the Kernel with the least amount of work). Further details about the TSU’s functionalities and its architecture can be found in [14, 27]. 3.4 Distributed Execution Termination Detecting termination of data-driven programs in distributed execution environments it’s not a straightforward procedure, since the availability of data governs the order of execution. In this work we have implemented an implicit distributed termination algorithm based on the Dijkstra and Scholten’s parental responsibility algorithm [17], which requires minimal message exchange. The algorithm assumes termination when: the state of all the nodes is passive (idle) and no messages are on their way in the system. In our implementation, the state passive refers to the state when the TSU has no pending Update operations and pending ready DThread instances that are waiting for execution. When the parent node (RootNode) detects termination, it broadcasts a termination message to the other nodes and waits for their acknowledgements in order to have a graceful system termination. The distributed termination algorithm is implemented by the Termination Detection Unit (TDU) which keeps track of the incoming and outgoing network messages in each node. We choose an implicit distributed termination detection algorithm in order to reduce the programming effort as well as to avoid introducing extra dependencies compared to explicit termination approaches [28]. Reducing dependencies can improve the performance of the data-driven programs since these extra dependencies result in extra TSU work and in more traffic in the network. 3.5 Network Manager The Network Manager is responsible for handling the inter-node communication. It is implemented as a software module that relies on the underlying network hardware interface. The Network Manager establishes connections between the system’s nodes, it exchanges network messages between the nodes and it processes the incoming network messages appropriately (e.g., it sends the Updates to the local TSU). It also supports data forwarding across the global address space. 3.5.1 Connectivity Layer The Network Manager handles the low-level connectivity by utilizing two different network interfaces: a Custom Network Interface (CNI) which is an optimized implementation with TCP sockets, and the widely used MPI library [1]. As a first step, we have implemented the CNI in order to identify all the required functionalities and mechanisms that are needed for the inter-node communication. Based on these functionalities/mechanisms we have implemented the Network Manager. on top of MPI. The major benefits of providing MPI support are portability and flexibility. On the other hand, the CNI implementation allows to have a direct and fair comparison with similar frameworks that utilize a custom network interface (e.g., DDM-VM [18] and SWARM [20]). Furthermore, it allows us to explore the performance penalties of using MPI instead of CNI. 3.5.2 Sending/Receiving Functionalities The Network Manager tolerates the network communication latencies by overlapping its sending/receiving functionalities with the DThread instances’ execution and the TSU’s functionalities. The sending functionalities, i.e., operations for sending commands and produced data, are utilized by the Kernels (through the DSU) concurrently. This removes the cost of such operations from the TSU’s critical path. For the receiving functionalities, an auxiliary thread is used, which continuously retrieves the incoming network messages from the other nodes. 3.6 Reducing the Network Traffic Reducing the network traffic in HPC systems is critical since it can help to avoid network saturation and reduce the power consumption. The US Department of Energy (DOE) [29] clearly states that the biggest energy cost in future massively parallel HPC systems will be in data movement, especially moving data on and off chip. To this end, we are recommending four simple and efficient techniques for reducing the network traffic in distributed DDM applications running on HPC systems. These techniques are mostly applied to the Update operations which are the most frequent commands executed in a DDM application. 3.6.1 Use General Network Packets A network message can carry any type of command (Update, Multiple Update, Data Descriptor, etc.). The most common practice to send such a message is to use a header (as a separate message) that describes the message’s content, like in [18]. In this work we are introducing a general packet with four fields (Type=1-byte, Value.1=4-bytes, Value.2=sizeof(Context Value), and Value.3=sizeof(Context Value)) that can carry all the basic types of commands. As a result, the number of sending network messages can be reduced to half. 3.6.2 Compressing Multiple Updates for DThreads with RC >1 Multiple Updates decrement the RC values of several instances of a DThread. Since the mapping of instances to the nodes is based on their Context values, a Multiple Update should be unrolled and each of its Updates should be sent to the appropriate node. Figure 3 shows an example where a Multiple Update, with Contexts from <0> to <47>, is distributed to a 4-node system (each node has 4 cores). We are compressing consecutive Multiple Updates that are sent to the same node based on a simple pattern recognition algorithm. The algorithm takes into account the difference between the minContext and maxContext of each Multiple Update command (called Right Distance) and the difference between the minContexts of two consecutive Multiple Updates (called Bottom Distance). In this example, the algorithm compresses the Multiple Updates that are sent to each node using RightDistance = 3 and BottomDistance = 16 (see Figure 3). As a result, the number of messages will be reduced by 75% for this specific Multiple Update command. The proposed algorithm is implemented by the DSU’s Compression Unit. When a node receives a compressed Multiple Update, the Network Manager decompresses it by its Decompression Unit. 3.6.3 Reducing the number of messages in the case of Multiple Updates for DThreads with RC=1 In FREDDO, the DThreads with RC=1 are treated differently, compared to other DDM implementations. The TSU does not allocate RC values for their instances in order to reduce the memory \footnote{FREDDO supports four different sizes for the Context values: 32-bit, 64-bit, 128-bit and 192-bit.} Instances of such DThreads are scheduled immediately when Updates are received for them. This approach allows to schedule a DThread instance for execution to any node. We can benefit from this, by dividing the range of Context values of a Multiple Update, into equal parts where the number of parts is equal to the number of nodes. As an example, consider the Multiple Update of Figure 3 and that the DThread T1 has RC=1. In this case, four different Multiple Updates will be distributed to the nodes as described in Figure 3. This methodology does not require compression and it is possible to reduce the number of messages by 75% for this specific example. 3.6.4 Packing correlated Updates together Our final technique reduces the messages that carry Update commands for the same destination node. Specifically, when a producer-instance sends several Update commands (Single Updates, (Un)compressed Multiple Updates) to a remote node, for the same DThread, the FREDDO’s runtime performs two steps. It sends the DThread’s TID along with the number of the Updates that will be sent, through a general packet. After that, the Context values of the Updates are sent as a single data packet to the remote node. 3.7 Distributed Recursion Support For supporting distributed execution of recursive algorithms in a data-driven manner, we have extended the functionalities of two FREDDO’s DThread classes: RecursiveDThread and ContinuationDThread. RecursiveDThread is a special class that allows parallelizing different types of recursive functions (linear, tail, etc.). It allocates/deallocates the arguments and the return values of the recursive instances dynamically, at runtime. The ContinuationDThread can be used in combination with the RecursiveDThread to implement algorithms with multiple recursion (or any similar algorithms). For instance, it can be used to sum the return values of two children recursive calls and return the result to their parent, in a parallel implementation of the recursive Fibonacci algorithm. Each recursive call is associated with a DistRData object. DistRData holds the arguments of a recursive call, pointers to the return values of its children (if any) and a pointer to the DistRData of its parent. Thus, the DistRData objects correlate children recursive instances with their parents. When a parent-instance calls one or more children-instances, the DSU decides which of them will be executed on remote nodes. In this case, the Network Manager will send the DistRData objects and the children-instances’ Context values to the remote nodes in order to be scheduled for execution. When a child-instance returns a value to its parent, the runtime system acknowledges if the parent-instance is mapped on the local node or on a remote node. In the latter case, the return value is sent via a network message to the remote node and finally, it is stored in the parent’s DistRData object. 4 Programming Example In this section we present a programming example of the distributed FREDDO implementation by using a benchmark with a complex Dependency Graph, the tile LU Decomposition algorithm. The algorithm is based on an earlier version developed in StarSs [30] and it factors a dense matrix into the product of a lower triangular \( L \) and an upper triangular \( U \) matrix. The dense \( n \times n \) matrix \( A \) is divided into an \( N \times N \) array of \( B \times B \) tiles (\( n = NB \)). The code of the original algorithm is shown in Figure 4a which is composed of five nested loops that perform four basic operations on a tiled matrix. For demonstration purposes we choose the following indicative names for the operations: \textit{diag}, \textit{front}, \textit{down} and \textit{comb}. \begin{figure}[h] \centering \includegraphics[width=\textwidth]{tile_lu_decomposition.png} \caption{Tile LU Decomposition.} \end{figure} In every iteration of the outermost loop, the \textit{diag} operation takes as input the diagonal tile that corresponds to the iteration number to produce its new value. The \textit{front} operation produces the remaining tiles on the same row as the diagonal tile. For each one of those tiles, it takes as input the result of the \textit{diag} in addition to the current tile to produce its new value. Similarly, the \textit{down} operation produces the remaining tiles on the same column as the diagonal tile. The \textit{comb} operation produces the rest of the tiles for that LU iteration. For every tile it produces, it takes as input three tiles: the current tile, the tile produced by the \textit{front} operation and the tile produced by the \textit{down} operation. It multiplies the second and third tiles and adds the result to the first tile to produce the final resulting tile. This computational pattern is repeated in the next LU iteration on a subset of the resulting matrix that excludes the first row and column and continues for as much iterations as the diagonal tiles of the matrix. 4.1 Dependency Graph One possible implementation of the tile LU algorithm in DDM/FREDDO is to map the outermost loop and the four basic operations into five DThreads, called \textit{thread\_1\_loop}, \textit{diag\_thread}, \textit{front\_thread}, \textit{down\_thread} and \textit{comb\_thread}. The data dependencies between the five DThreads are listed below: - The DThreads that execute the operations depend on the \textit{thread\_1\_loop} since the index of the outermost loop is used in the four operations. - The \textit{front\_thread} and \textit{down\_thread} DThreads depend on the \textit{diag\_thread}. • The \texttt{comb\_thread} depends on the \texttt{front\_thread} and \texttt{down\_thread} DThreads. • The next LU iteration depends on the results of the previous iteration. Particularly, the results produced by the \texttt{comb\_thread} invocations, in the current iteration, are consumed by the invocations of the \texttt{diag\_thread}, \texttt{front\_thread}, \texttt{down\_thread} and \texttt{comb\_thread}, of the next LU iteration. The Dependency Graph shown in Figure\ref{fig:dependence} illustrates the dependencies among the instances of the DThreads for the first two iterations of the tile LU algorithm. For simplicity, a $3 \times 3$ tile matrix ($N=3$) has been selected. Each DThread’s instance is labeled with the value of its Context. ![Figure 5: FREDDO code of the tile LU algorithm (the highlighted code is required for the distributed execution).](image-url) 4.2 FREDDO Code Figure 5 depicts the FREDDO code for the tile LU Decomposition algorithm. In FREDDO, each DThread object is associated with a DFunction [14]. The DFunction is a callable target (C++ function, Lambda expression, or functor) that holds the code of a DThread. Each DFunction has one input argument, the Context value. Different Context structures (ContextArg, Context2DArg and Context3DArg) are provided based on the type of the DThread class. In this example the code of each DThread has been placed in standard C/C++ functions. Each call of an Update command in the DThreads’ code corresponds to one dependency arrow in Figure 4b. A DThread object (DObject) provides several Single and Multiple Update methods that target itself or its consumers [14]. For example, the first Update operation of the loop code DFunction indicates a Single Update which decrements the RC value of the instance kk of the diag_thread (diagDT) by one. The second Update operation of the same DFunction indicates a Multiple Update which decrements the RC value of multiple instances of the front_thread (frontDT) by one. Moreover, the Update operations at the end of the comb code DFunction implement a switch actor, which depending on the Context of the DThread’s instance, a different consumer-instance is updated. In the main function of the program the matrices are allocated and initialized. After that, the tile matrix $A$ is registered in the GAS using the addInGAS runtime function. At this point, the FREDDO’s runtime registers the address of the tile matrix $A$ in the Global Address Directory (GAD) of each node. The runtime also creates a GAS_ID for the matrix $A$ which is stored in the gasA variable. The init runtime function initializes the FREDDO’s execution environment and it starts NUM_OF_KERNELS Kernels in each node. Each DObject’s constructor takes two arguments, the DFunction and the RC value (e.g., the diagDT object has DFunction=diag code and RC=2). After the creation of the DObjects, the initial Updates are sent to the TSUs for execution. These Updates correspond to the arrows of Figure 4b that describe dependencies on initialized data. The initial Updates have to be executed one time only. In this example the RootNode has been selected to execute these updates which are distributed across the nodes through its DSU module. Notice that the initial Updates or any other Updates can be executed by any node of the system. The run function starts the DDM scheduling and waits until the FREDDO’s runtime detects the distributed execution termination (see Section 3.4). When the run function returns, all the resources allocated by the FREDDO framework are deallocated using the finalize function. The FREDDO’s memory model in combination with its distribution scheme and the implicit distributed termination approach allows the distributed FREDDO programs to be fundamentally the same as the single-node ones. For the distributed data-driven execution the user has to: (i) provide a peer file that contains the ip addresses or the host-names of the system’s nodes, (ii) register the shared objects in the GAS using the addInGAS function and (iii) specify the output data of each DThread using the addModifiedSegmentInGAS runtime function. Additionally, for gathering the results in the RootNode, the user has to utilize the sendDataToRoot runtime function. Both the addModifiedSegmentInGAS and sendDataToRoot functions require the GAS_ID of a shared object, the conventional main memory address of that object and its size in bytes. For instance, in the diag code DFunction, the tile $A[kk][kk]$ is declared as a modified segment since is computed by the diag routine. The size of this tile is equal to $tS$ and its GAS_ID is equal to gasA since it’s a part of the tile matrix $A$. In Figure 5 the required code for the distributed execution is highlighted. As previously mentioned, the FREDDO’s memory model creates an identical address space on each node, which gives the view of a single distributed address space. At the moment, this requires the shared objects to have the same memory size in each node (e.g., the tile matrix $A$). This simplifies the implementation of the proposed programming model but it limits the total amount of memory used by a DDM program. A program can use only as much memory as is available in the RootNode since the output results are gathered in that node. Mechanisms that will overcome this limitation are in our to-do list. 5 Experimental Evaluation In this section we present the evaluation of the distributed implementation of FREDDO using eight benchmarks with different characteristics. We start with an overview of the hardware environment used in our experiments, followed by the description of the benchmarks. After that, we present the performance results and comparisons with other systems. Finally, we present network traffic analysis results. <table> <thead> <tr> <th>System Specs</th> <th>AMD</th> <th>CyTera</th> </tr> </thead> <tbody> <tr> <td>Processor Type</td> <td>AMD Opteron 6276</td> <td>Intel Xeon X5650</td> </tr> <tr> <td>Number of Nodes</td> <td>4</td> <td>64</td> </tr> <tr> <td>Per Node Specs (Total RAM for both systems: 48 GB)</td> <td></td> <td></td> </tr> <tr> <td>- Clock Frequency</td> <td>1.4 GHz</td> <td>2.67 GHz</td> </tr> <tr> <td>- Cores</td> <td>16</td> <td>12</td> </tr> <tr> <td>- Hardware Threads/Core</td> <td>2</td> <td>1</td> </tr> <tr> <td>- Total Hardware Threads</td> <td>32</td> <td>12</td> </tr> <tr> <td>- L1-I/S, L1-D/S, L2$/Core</td> <td>32 KB, 16 KB, 1 MB</td> <td>32 KB, 32 KB, 256 KB</td> </tr> <tr> <td>- L3$</td> <td>24 MB</td> <td>12 MB</td> </tr> <tr> <td>Interconnect</td> <td>Gigabit Ethernet</td> <td>Infiniband QDR (40Gb/s)</td> </tr> <tr> <td>Linux Kernel</td> <td>3.13.0</td> <td>2.6.32</td> </tr> <tr> <td>Compilers</td> <td>gcc/g++ 4.8.4</td> <td>gcc/g++ 4.9.3</td> </tr> </tbody> </table> Table 1: Systems used for benchmark evaluation. 5.1 Experimental Setup For the experimental evaluation we have used two different systems, the AMD and CyTera. The AMD is a 4-node local system. The CyTera [31] is an open-access HPC system which provides up to 64 nodes per user. The specifications of the systems are shown in Table 1. Our benchmark suite contains three applications which require low communication between the nodes (BMMULT, Blackscholes and Swaptions), three benchmarks with complex Dependency Graphs that require heavy inter-node communication (LU, QR and Cholesky) and two recursive algorithms (Fibonacci and PowerSet) that require medium inter-node communication: 1. BMMULT performs a dense blocked matrix multiplication of two square matrices. 2. Blackscholes calculates the prices for a portfolio of European options analytically with the Black-Scholes partial differential equation (PDE) [32]. 3. Swaptions uses the Heath-Jarrow-Morton (HJM) framework to price a portfolio of swaptions [32]. A Monte Carlo simulation is used to compute the prices (the simulation number variable is set to 20,000). 4. LU calculates the LU decomposition of a tile matrix. It has been based on an earlier version written in StarSs [30]. 5. QR implements the right-looking tile QR factorization as described in [33]. The algorithm uses LAPACK [34] (V3.6.1) and PLASMA [35] (V2.8.0) routines. 6. Cholesky calculates the lower triangular matrix \( L \) of a symmetric positive definite matrix \( A \), such that \( A = LL^T \) [36]. Operations on the tiles are performed using LAPACK [34] (V3.6.1) and BLAS [37] routines. 7. Fibonacci calculates the Fibonacci numbers using a double recursion algorithm. 8. PowerSet calculates the number of all subsets of a set with \( N \) elements, using a multiple recursion algorithm. The original algorithm has been retrieved from the BSC Application Repository [38]. For the benchmarks working on tile/block matrices we have used both single-precision (SP) and double-precision (DP) floating-point dense matrices. All the source codes and libraries/packages were compiled using the -O3 optimization flag. For the performance results which are reported as speedup, speedup is defined as $S_{avg} / P_{avg}$, where $S_{avg}$ is the average execution time of the sequential version of the benchmark (without any FREDDO overheads) and $P_{avg}$ is the average execution time of the FREDDO implementation. For the average execution times we have executed each benchmark (both sequential and parallel) five times. In the parallel execution time of each execution we have included the time needed for gathering the results to the RootNode. We have executed benchmarks using FREDDO with Custom Network Interface support (called FREDDO+CNI) and with MPI support (called FREDDO+MPI). Currently, FREDDO+CNI supports only Ethernet-based interconnects. The default FREDDO implementation for the AMD system is the FREDDO+CNI. In CyTera, the MPI libraries provided to us are configured for the InfiniBand interconnect. As such, we are using the FREDDO+MPI implementation as the default since it provides faster communication compared to the FREDDO+CNI. For the FREDDO+MPI implementation we are using the OpenMPI library (V1.8.4 for the CyTera system and V2.0.1 for the AMD system). Notice that for both implementations, the size of the Context values is set to 64-bit. Figure 6: Strong scalability and problem size effect on the AMD system using FREDDO+CNI (MS=Matrix Size, SP=Single-Precision, DP=Double-Precision, $K = 2^{10}$, $M = 10^6$). 5.2 Performance Evaluation We have performed a scalability study in order to evaluate the performance of the proposed framework, by varying the number of nodes on the two systems. Each benchmark is executed with three different problem sizes. For the tiled algorithms ($BMMULT$, $LU$, Cholesky and $QR$) we choose the optimal tile size, for both the sequential and parallel implementation of each algorithm. For each different execution (problem size and number of nodes), we run experiments with three different tile sizes: $32 \times 32$, $64 \times 64$ and $128 \times 128$. Out of the total number of cores in each node, one of them is used for executing the TSU code while the rest are used for executing the Kernels. Unlike the Kernels and the TSU which are pinned to specific cores, the Network Manager’s receiving thread is not pinned to any specific core. This gives the opportunity to the operating system to move the receiving thread to an idle core, or to migrate it regularly between the cores. For the single-node execution of the benchmarks, the FREDDO’s runtime disables the Network Manager’s receiving thread. Figure 7: Strong scalability and problem size effect on the CyTera system using FREDDO+MPI (MS=Matrix Size, SP=Single-Precision, $K = 2^{10}$). Figures 6 and 7 depict the results for the AMD and CyTera systems, respectively. On the former system we have executed all the benchmarks, including both single-precision and double-precision versions of the algorithms working on tile/block matrices. On the latter system we have executed the two recursive algorithms and the single-precision versions of the tiled algorithms. Blackscholes and Swaptions as well as the double-precision versions of the tiled algorithms are excluded from our performance evaluation on the CyTera system in order to save computational resources (CPU hours). From the performance results we observe that generally as the input size increases, the system scales better (especially for the benchmarks with the complex Dependency Graphs). This is expected, as larger problem sizes allow for amortizing the overheads of the parallelization. Table 2 depicts the average sequential time (in seconds) of the sequential version of the benchmarks that were executed on both systems. The double-precision versions of the algorithms achieve slightly lower speedups compared to the single-precision ones, since in the former case the data exchanged in the network is doubled. Table 2: Average sequential execution time (in seconds) of the sequential version of the benchmarks. The BMMULT, Blackscholes and Swaptions benchmarks achieve very good speedups due to the low data sharing and low data exchange between the nodes. Particularly, they achieve up to 93% speedups on the CyTera system. --- 2 CyTera allows up to 50,000 CPU hours per user. of the ideal speedup, on the AMD system, for the largest problem size, when all the nodes are used. For the same configuration, \textit{BMMULT} achieves 84\% of the ideal speedup, on the CyTera system. \textit{LU}, \textit{QR} and \textit{Cholesky} are classic dense linear algebra workloads with complex Dependency Graphs. FREDDO ended up with lower speedups as the number of nodes increases, due to the heavy inter-node communication and the complexity of the algorithms. When utilizing all the nodes on the CyTera system, for the largest problem size, FREDDO achieves up to 61\% of the ideal speedup for these complex algorithms. However, it is expected that for larger problem sizes a better performance can be achieved. The recursive algorithms (\textit{Fibonacci} and \textit{PowerSet}) also achieve very good speedups. For the 4-node configuration on the AMD system and the largest problem size, FREDDO achieves about 83\% of the ideal speedup (106 out of 128). For the 64-node configuration on CyTera, FREDDO achieves 84\% (648 out of 768) for the \textit{Fibonacci} and 79\% (604 out of 768) for the \textit{PowerSet} of the ideal speedup, also for the largest problem size. For minimizing the overheads of the parallel recursive implementations we have used thresholds in order to control the number of DThread instances that are used for executing the recursive calls. For each problem size of the algorithms we test various thresholds and we choose the one that provides the best performance. To conclude, distributed FREDDO scales well and effectively leverages the decoupling of synchronization and execution. Table 3 depicts the minimum, maximum and average speedup results, on both systems, for each problem size and number of nodes. Next to each speedup value the utilization percentage of the available cores is presented. The results show that FREDDO utilizes the resources of both systems efficiently, especially for the largest problem size. For the largest problem size and when all the available nodes are used, FREDDO achieves an average of 82\% of the ideal speedup on the AMD system and 67\% on the CyTera system. The recursive algorithms (\textit{Fibonacci} and \textit{PowerSet}) also achieve very good speedups. For the 4-node configuration on the AMD system and the largest problem size, FREDDO achieves about 83\% of the ideal speedup (106 out of 128). For the 64-node configuration on CyTera, FREDDO achieves 84\% (648 out of 768) for the \textit{Fibonacci} and 79\% (604 out of 768) for the \textit{PowerSet} of the ideal speedup, also for the largest problem size. For minimizing the overheads of the parallel recursive implementations we have used thresholds in order to control the number of DThread instances that are used for executing the recursive calls. For each problem size of the algorithms we test various thresholds and we choose the one that provides the best performance. To conclude, distributed FREDDO scales well and effectively leverages the decoupling of synchronization and execution. Table 3 depicts the minimum, maximum and average speedup results, on both systems, for each problem size and number of nodes. Next to each speedup value the utilization percentage of the available cores is presented. The results show that FREDDO utilizes the resources of both systems efficiently, especially for the largest problem size. For the largest problem size and when all the available nodes are used, FREDDO achieves an average of 82\% of the ideal speedup on the AMD system and 67\% on the CyTera system. <table> <thead> <tr> <th>System</th> <th>Problem Size</th> <th>Speedup</th> <th>Number of Nodes</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td>1</td> <td>2</td> </tr> <tr> <td>AMD</td> <td>Smaller</td> <td>Avg 27.5 (86%)</td> <td>49.2 (77%)</td> </tr> <tr> <td></td> <td>Min 22.9 (72%)</td> <td>39.3 (61%)</td> <td>54.1 (42%)</td> </tr> <tr> <td></td> <td>Max 30.6 (86%)</td> <td>59.2 (92%)</td> <td>117.0 (91%)</td> </tr> <tr> <td></td> <td>Medium</td> <td>Avg 27.5 (86%)</td> <td>52.7 (82%)</td> </tr> <tr> <td></td> <td>Min 23.7 (74%)</td> <td>44.5 (69%)</td> <td>71.3 (56%)</td> </tr> <tr> <td></td> <td>Max 30.2 (84%)</td> <td>59.5 (93%)</td> <td>117.9 (92%)</td> </tr> <tr> <td></td> <td>Largest</td> <td>Avg 28.0 (87%)</td> <td>54.9 (86%)</td> </tr> <tr> <td></td> <td>Min 25.0 (78%)</td> <td>45.4 (71%)</td> <td>80.2 (63%)</td> </tr> <tr> <td></td> <td>Max 30.3 (86%)</td> <td>59.8 (93%)</td> <td>119.3 (93%)</td> </tr> <tr> <td>CyTera</td> <td>Smaller</td> <td>Avg 10.5 (88%)</td> <td>20.5 (85%)</td> </tr> <tr> <td></td> <td>Min 10.4 (86%)</td> <td>19.7 (82%)</td> <td>34.1 (71%)</td> </tr> <tr> <td></td> <td>Max 10.8 (90%)</td> <td>21.2 (89%)</td> <td>41.9 (87%)</td> </tr> <tr> <td></td> <td>Medium</td> <td>Avg 10.7 (89%)</td> <td>20.6 (86%)</td> </tr> <tr> <td></td> <td>Min 10.4 (86%)</td> <td>19.8 (82%)</td> <td>37.2 (78%)</td> </tr> <tr> <td></td> <td>Max 11.9 (99%)</td> <td>21.2 (89%)</td> <td>42.3 (88%)</td> </tr> <tr> <td></td> <td>Largest</td> <td>Avg 10.5 (88%)</td> <td>20.7 (86%)</td> </tr> <tr> <td></td> <td>Min 10.3 (86%)</td> <td>18.8 (78%)</td> <td>38.4 (80%)</td> </tr> <tr> <td></td> <td>Max 10.9 (91%)</td> <td>21.5 (90%)</td> <td>41.9 (87%)</td> </tr> </tbody> </table> Table 3: Minimum, Maximum and Average speedup results along with the utilization percentage of the available cores in each case. 5.3 FREDDO: CNI vs MPI In this section we study the performance penalties of using MPI instead of CNI, for the benchmarks that have medium and heavy inter-node communication. For our experiments we have used the AMD system with all the available nodes. The results are shown in Figure 8 and are normalized based on the average execution time of FREDDO+CNI. The comparisons show that FREDDO+CNI is 80\%, 25\% and 6\% faster than FREDDO+MPI on average, for the smallest, medium and largest problem sizes, respectively. This indicates that MPI has more overheads which affect the performance of the Network Manager’s receiving thread as well as the sending operations of the Kernels. MPI has more overheads than CNI since it’s a much larger library which contains more functionalities than CNI. However, the MPI’s overheads are hidden as the benchmark’s execution time increases. Thus, the FREDDO+MPI can be used for real life applications that have enormous input sizes (at least in the order of our largest problem size). This solution can provide better portability to the FREDDO applications, especially when targeting large-scale HPC systems with different architectures. Furthermore, it allows the programmers to combine MPI code with FREDDO code. 5.4 Performance comparisons with other systems FREDDO is compared with two state-of-the-art frameworks for the Cholesky benchmark: ScaLAPACK [19] (V2.0.2) and SWARM [20] (V0.14). ScaLAPACK (Scalable LAPACK) is an MPI-based library which includes a subset of LAPACK [34] routines redesigned for distributed-memory parallel systems. In this work ScaLAPACK has been installed using the OpenMPI library. We have also compared our implementation with DDM-VM [18], the first distributed DDM implementation, for the Cholesky and LU benchmarks. For all frameworks we choose the configurations that achieve the optimal performance (e.g., the tile size for the tiled algorithms and the grid configuration for the ScaLAPACK implementation). Figure 9 compares FREDDO with ScaLAPACK on the CyTera system for the Cholesky benchmark using $60K \times 60K$ matrices. The results are shown as average execution times for three different node configurations (16, 32 and 64). In Figure 10, we compare FREDDO with ScaLAPACK and SWARM for the Cholesky benchmark and with DDM-VM for the Cholesky and LU benchmarks, on the AMD system. For both benchmarks we have used the largest problem size ($32K \times 32K$ matrices). In order to have fair comparisons on the AMD system, FREDDO is compared with DDM-VM and SWARM using the FREDDO+CNI implementation and with ScaLAPACK using the FREDDO+MPI implementation. The reason is that ScaLAPACK utilizes the MPI library for the inter-node communication which incurs more overheads (as shown in Figure 8) compared to a custom network network interface with less functionalities. The comparison results show that FREDDO outperforms the other frameworks in all cases. Table 4 indicates how many times FREDDO is faster than the other frameworks, in each system, for each node configuration. For instance, on the CyTera system for the 64-node configuration, FREDDO is $1.61 \times$ faster than ScaLAPACK for the Cholesky-SP and $1.56 \times$ faster for the Cholesky-DP. Notice that for the ScaLAPACK’s Cholesky implementations the \texttt{pspotrf} and \texttt{pdpotrf} routines were used. On the AMD system, FREDDO is up to $1.89 \times$ faster than ScaLAPACK, $1.26 \times$ faster than SWARM and up to $1.42 \times$ faster than DDM-VM. Figure 10: Comparing FREDDO with ScaLAPACK, DDM-VM and SWARM on the AMD system for the largest problem size ($32K \times 32K$ matrix size). The ScaLAPACK ended up with lower performance due to its inability to fully exploit thread-level parallelism on shared-memory multi-core systems [39, 36]. The main reason for this is that the ScaLAPACK’s algorithms, like \textit{Cholesky}, rely on the fork-join paradigm and the MPI’s programming model for the distributed execution [40, 41]. On the other hand, FREDDO allows data-driven concurrency using non-blocking threads, thus it achieves better performance on distributed shared-memory multi-core systems. The main reason that FREDDO outperforms SWARM is that the latter utilizes work-stealing for load-balancing across the nodes where FREDDO utilizes a simpler two-layer scheduling policy (see Section 3.3). Work-stealing increases the runtime overheads which can be avoided for benchmarks with regular Dependency Graphs, like \textit{Cholesky}. Table 4: Performance improvement ($X_{avg}/F_{avg}$) of FREDDO compared to the other frameworks ($F_{avg}$ is the average execution time of FREDDO and $X_{avg}$ is the average execution time of a compared framework). <table> <thead> <tr> <th>FREDDO vs. ScaLAPACK, SWARM and DDM-VM on AMD (Matrix Size: $32K \times 32K$)</th> <th>FREDDO vs. ScaLAPACK on CyTera (Matrix Size: $60K \times 60K$)</th> </tr> </thead> <tbody> <tr> <td></td> <td>Cholesky-SP</td> </tr> <tr> <td>FREDDO</td> <td>1.44X</td> </tr> <tr> <td>ScaLAPACK</td> <td>-</td> </tr> <tr> <td>SWARM</td> <td>1.12X</td> </tr> <tr> <td>DDM-VM</td> <td>1.22X</td> </tr> </tbody> </table> Although DDM-VM and FREDDO are based on the same execution model, FREDDO achieves better performance for three main reasons: 1. DDM-VM follows a Context-based distribution scheme (similarly to this work) where each DThread instance is mapped and executed on a specific core of the distributed system. In FREDDO, the DThread instances are mapped to specific nodes and the TSU’s Scheduler distributes them to the Kernels with the least work-load. This approach can better improve the load-balancing in each node. 2. FREDDO provides optimized TSU and Network Manager modules. For example, the FREDDO’s Network Manager uses atomic variables to count the number of outgoing and incoming messages in each node, which is required for the distributed execution termination algorithm. In DDM-VM, the same functionality is implemented using lock/unlock operations which incur more overheads. 3. In DDM-VM, the TSU and the receiving thread of the Network Interface Unit (similar to the receiving thread of the FREDDO’s Network Manager) are pinned on the same core. This approach can affect the scheduling and network operations, thus, increasing the runtime overheads. In FREDDO, the receiving thread is not pinned to any specific core which gives the flexibility to the operating system to schedule it appropriately. 5.5 Network Traffic Analysis In order to study the efficiency of the proposed mechanisms for reducing the network traffic, during a distributed data-driven execution, we have performed a traffic analysis for both FREDDO and DDM-VM. We are comparing our system with DDM-VM since the latter does not provide any mechanisms for reducing the network traffic in DDM applications. The experiments were conducted on the AMD system for two benchmarks from our benchmark suite, Cholesky and LU (single precision versions). For our experiments a root access was required for capturing the network traffic. Thus, the AMD system has been used since it’s the only system where we have root access. Figure 11 depicts the total TCP packets (in Millions) and the total data (in GB) that are exchanged between the nodes of the AMD system, for the 4-node configuration and the largest problem size $(32K \times 32K)$. Additionally, the benchmarks have been executed with three different tile sizes $(32 \times 32, 64 \times 64$ and $128 \times 128)$. For the traffic analysis experiments we have used the TShark tool [42] (V2.2.3) and we configured it to capture the traffic that is exchanged between the TCP ports that were reserved for the internode communication. It is important to note that in FREDDO the size of the Context values is set to 64-bit while DDM-VM supports only 32-bit Context values. Larger Context values allow to execute benchmarks with large problem sizes and fine-grained threads [27] (e.g., the LU benchmark on the CyTera system with $60K \times 60K$ matrix size and $32 \times 32$ tile size). The comparison results show that FREDDO reduces the total TCP packets and data, especially for the smallest tile size where the frequency of the communication is increased between the nodes of the system. In the case of Cholesky, FREDDO reduces the total TCP packets by 4.85×, 1.79× and 1.16×, for the 32×32, 64×64 and 128×128 tile sizes, respectively. Additionally, in the case of LU, FREDDO reduces the total TCP packets by 6.55×, 1.44× and 1.11×, for the 32×32, 64×64 and 128×128 tile sizes, respectively. Furthermore, FREDDO reduces the total amount of data by 16.7%, 5.5% and 2.9% for Cholesky and 12.9%, 5.2% and 3.5% for LU, for the 32×32, 64×64 and 128×128 tile sizes, respectively. It is easy to observe that the total number of TCP packets and the total amount of data are not reduced with the same ratio. This is because, the largest percentage of the total amount of data consists of the computed matrix tiles that are forwarded from the producer to consumer nodes. This percentage is approximately the same in both frameworks since FREDDO reduces the network traffic mainly through optimizations on sending Update operations. The number of Update operations is high in benchmarks with high-complexity Dependency Graphs, thus, a higher number of TCP packets is used to carry such operations in DDM-VM. Although the proposed mechanisms for reducing the network traffic are performing better for relatively small tile sizes, we expect to have a high positive impact on benchmarks that run on HPC systems with a large number of cores/nodes. In such systems usually fine-grained threads (e.g., with small tile sizes) are used in order to better utilize the large number of computation cores. In order to justify this, in Figure 12 we provide the normalized average execution time of the LU and Cholesky benchmarks that are executed on both systems (using FREDDO) for three different tile sizes. The timings are normalized based on the execution time of the 32×32 tile size. The results show that larger tile sizes (i.e., coarse-grained threads) can decrease the performance, especially in the CyTera system with the 64-node configuration. ![Figure 12: Tile size effect on the AMD and CyTera systems using FREDDO.](image) 6 Related Work The Message Passing Interface (MPI) \[1\] has been a de facto standard for programming distributed systems. It provides low-level communication primitives to transfer data among a set of processes running on the nodes of a distributed system. Although MPI allows achieving high-performance it requires a lot of effort from the programmer (partitioning/distributing data, exchanging data during execution, synchronizing nodes, etc.). On the other hand, FREDDO allows distributed data-driven execution and automatic management of a software Distributed Shared Memory which simplifies programmability. However, FREDDO uses MPI as a communication medium in order to provide portability to the DDM programs. Thread Building Blocks (TBB) is an API developed by Intel that relies on C++ templates to facilitate parallel programming \[43\]. It provides a set of data-structures and algorithmic skeletons that supports the execution of tasks. TBB also provides a set of concurrent containers (hashmaps, queues, etc.) and synchronization constructs (mutex constructs, atomic operations). The TBB runtime implements a tasks-stealing scheduling policy and adopts a fork-join approach for the creation and management of tasks, similarly to Cilk approach. On the contrary, FREDDO relies on data-dependencies for the scheduling of threads. Also, unlike FREDDO, TBB's thread management does not naturally extend across the network. Gupta and Sohi have also produced a software system that allows data-flow/data-driven execution of sequential imperative programs on multi-core systems. Particularly, they have implemented a C++ runtime library that exploits Functional-Level Parallelism (FLP) by executing functions on the cores in a data-flow fashion. The execution model of this work determines data dependences between computations/functions dynamically and executes them concurrently in a data-flow fashion. In contrast, FREDDO applies its techniques at non-blocking threads. Furthermore, like TBB, the Gupta and Sohi's runtime system does not support distributed data-driven execution. The Data-Driven Multithreading Virtual Machine (DDM-VM) is a parallel software platform that supports data-driven execution on homogeneous and heterogeneous multi-core systems. A DDM-VM program consists of ANSI-C with a set of C macros that expand into calls to the DDM-VM runtime. In FREDDO, a program consists of C++ objects, thus, the programming interface provides the benefits of object-oriented programming (Data Encapsulation, Data Abstraction, etc.). Furthermore, FREDDO achieves better performance than DDM-VM and it provides more functionalities such as: recursion support, mechanisms for reducing the network traffic and MPI-based inter-node communication for better portability. SWift Adaptive Runtime Machine (SWARM) is a software runtime that uses an execution model based on codelets. SWARM divides a program into tasks with runtime dependencies and constraints that can be executed when all runtime dependencies and constraints are met. The SWARM's runtime schedules the tasks for execution based on resource availability and it utilizes a work-stealing approach for on-demand load-balancing. Both SWARM and FREDDO allow data-driven execution on distributed systems and adopt the static dependency resolution, i.e. the programmer/compiler is responsible for constructing the Dependency Graph. FREDDO, in contrast to SWARM, handles the flow of data between producers and consumers running on different nodes, automatically. OmpSs is a variant of OpenMP extended to support asynchronous task parallelism on clusters of heterogeneous architectures. It aims programming productivity and uses an annotation-based programming model to move data across a disjoint address space. The programmer annotates the sequential code with compiler directives that are translated into calls to the Nanos++ runtime library. Nanos++ schedules tasks on the available resources of a cluster and it manages data coherence and data movement transparently. In OmpSs, the task Dependency Graph is always built at runtime, and thus this approach may introduce extra overheads. Moreover, OmpSs exposes only a part of the Dependency Graph available to the runtime, and consequently, only a fraction of the concurrency opportunities in the applications is visible at any time. The PaRSEC framework is a task-based data-flow-driven runtime designed to achieve high performance computing on heterogeneous HPC systems. It supports the Parameterized Task Graph (PTG) model where dependencies between tasks and data are expressed using a domain specific language named JDF. The PaRSEC runtime combines the information included in the PTG with supplementary information provided by the user (e.g., distribution of data onto nodes, priorities, etc.) in order to allow efficient data-driven scheduling. Both PaRSEC and FREDDO performed a static work distribution between nodes. Additionally, PaRSEC performs dynamic work stealing within each node where FREDDO distributes the DThread instances to the Kernels with the least amount of work. Finally, PaRSEC provides a C-based programming interface where the PaRSEC Compiler is used to produce the JDF representation. FREDDO provides an object-oriented C++ programming interface where the dependency graph consists of DThread objects and it is executed using the DDM's Update operations. The Decoupled Threaded Architecture - Clustered (DTA-C) is an SDF architecture with the addition of the concept of clusterizing resources. The architecture is composed of a set of clusters where each cluster consists of one or more Processing Elements (PEs) and a Distributed Scheduler Element (DSE). The Distributed Scheduler (DS) consists of all the system’s DSEs and it’s responsible for assigning threads at runtime. In SDF architectures, like DTA-C, the computation is carried out by a custom designed processor while in DDM architectures, like FREDDO, the computation is carried out by an off-the-shelf processor. 7 Conclusions and Future Work The data-flow/data-driven model is an alternative model of execution that can be used to tolerate long memory and synchronization latencies on HPC systems. In this work we have presented a portable and efficient implementation of the Data-Driven Multithreading (DDM) model that enables efficient data-driven scheduling on distributed multi-core architectures. The proposed framework has been implemented as an extension to FREDDO, a C++ implementation of the DDM model. Experiments were performed on two distributed systems with 128 and 768 cores, respectively. Our evaluation analysis has shown that the distributed FREDDO implementation scales well and it achieves comparable or better performance when is compared with other systems, such as ScaLAPACK, SWARM and DDM-VM. Particularly, on the 768-core system, FREDDO is up to 1.61× faster than ScaLAPACK. On the 128-core system, FREDDO is up to 1.89× faster than ScaLAPACK, 1.26× faster than SWARM and up to 1.42× faster than DDM-VM. Furthermore, we have proposed simple and efficient techniques for reducing network traffic during the execution of DDM applications. Our experiments on the 128-core system have shown that FREDDO can reduce the total amount of TCP packets by up to 6.55× and the total amount of data by up to 16.7% when is compared with the DDM-VM system. Future work will be focused on applying data-driven scheduling on heterogeneous HPC systems. Particularly, we are interested on many-core accelerators with software-controlled scratch-pad memories. An example of this architecture is the Sunway SW26010 processor which is the basic building block of the Sunway TaihuLight [52] (ranked 1st in TOP500). Deterministic data prefetching into scratch-pad memories using data-driven techniques can improve the locality of sequential processing. We believe that this approach can further improve the performance of HPC systems. Additionally, we would like to evaluate the distributed FREDDO implementation on larger HPC systems which currently are not available to us. Acknowledgment This work was partially funded by the IKYK foundation through a scholarship for George Math-eou. References
{"Source-Url": "https://www.cs.ucy.ac.cy/docs/techreports/TR-17-1.pdf", "len_cl100k_base": 15428, "olmocr-version": "0.1.53", "pdf-total-pages": 27, "total-fallback-pages": 0, "total-input-tokens": 66714, "total-output-tokens": 21140, "length": "2e13", "weborganizer": {"__label__adult": 0.00039768218994140625, "__label__art_design": 0.0006103515625, "__label__crime_law": 0.0003788471221923828, "__label__education_jobs": 0.0011186599731445312, "__label__entertainment": 0.0001806020736694336, "__label__fashion_beauty": 0.0002111196517944336, "__label__finance_business": 0.0004572868347167969, "__label__food_dining": 0.0004062652587890625, "__label__games": 0.0011835098266601562, "__label__hardware": 0.004390716552734375, "__label__health": 0.0006084442138671875, "__label__history": 0.0006775856018066406, "__label__home_hobbies": 0.00016880035400390625, "__label__industrial": 0.001125335693359375, "__label__literature": 0.0003173351287841797, "__label__politics": 0.00045609474182128906, "__label__religion": 0.0007886886596679688, "__label__science_tech": 0.416748046875, "__label__social_life": 0.00010031461715698242, "__label__software": 0.01352691650390625, "__label__software_dev": 0.55419921875, "__label__sports_fitness": 0.0003867149353027344, "__label__transportation": 0.0011091232299804688, "__label__travel": 0.00029015541076660156}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 79829, 0.05697]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 79829, 0.33045]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 79829, 0.87738]], "google_gemma-3-12b-it_contains_pii": [[0, 110, false], [110, 207, null], [207, 207, null], [207, 4338, null], [4338, 8476, null], [8476, 12854, null], [12854, 14159, null], [14159, 17821, null], [17821, 21754, null], [21754, 25590, null], [25590, 28511, null], [28511, 31191, null], [31191, 32074, null], [32074, 36565, null], [36565, 39502, null], [39502, 42033, null], [42033, 44007, null], [44007, 50675, null], [50675, 52611, null], [52611, 55774, null], [55774, 58688, null], [58688, 62024, null], [62024, 66608, null], [66608, 70035, null], [70035, 73037, null], [73037, 76470, null], [76470, 79829, null]], "google_gemma-3-12b-it_is_public_document": [[0, 110, true], [110, 207, null], [207, 207, null], [207, 4338, null], [4338, 8476, null], [8476, 12854, null], [12854, 14159, null], [14159, 17821, null], [17821, 21754, null], [21754, 25590, null], [25590, 28511, null], [28511, 31191, null], [31191, 32074, null], [32074, 36565, null], [36565, 39502, null], [39502, 42033, null], [42033, 44007, null], [44007, 50675, null], [50675, 52611, null], [52611, 55774, null], [55774, 58688, null], [58688, 62024, null], [62024, 66608, null], [66608, 70035, null], [70035, 73037, null], [73037, 76470, null], [76470, 79829, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 79829, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 79829, null]], "pdf_page_numbers": [[0, 110, 1], [110, 207, 2], [207, 207, 3], [207, 4338, 4], [4338, 8476, 5], [8476, 12854, 6], [12854, 14159, 7], [14159, 17821, 8], [17821, 21754, 9], [21754, 25590, 10], [25590, 28511, 11], [28511, 31191, 12], [31191, 32074, 13], [32074, 36565, 14], [36565, 39502, 15], [39502, 42033, 16], [42033, 44007, 17], [44007, 50675, 18], [50675, 52611, 19], [52611, 55774, 20], [55774, 58688, 21], [58688, 62024, 22], [62024, 66608, 23], [66608, 70035, 24], [70035, 73037, 25], [73037, 76470, 26], [76470, 79829, 27]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 79829, 0.16342]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
a3c5d33a9133dbd66320666d930659e414e0afa8
This tutorial was validated with 2018.2. Minor procedural differences might be required when using later releases. ## Revision History 10/30/2019: Released with Vivado® Design Suite 2019.2 without changes from 2018.2. <table> <thead> <tr> <th>Section</th> <th>Revision Summary</th> </tr> </thead> <tbody> <tr> <td><strong>06/06/2018 Version 2018.2</strong></td> <td></td> </tr> <tr> <td>General updates</td> <td>Editorial updates only. No technical content updates.</td> </tr> <tr> <td><strong>04/04/2018 Version 2018.1</strong></td> <td></td> </tr> <tr> <td>General updates</td> <td>Updated menu commands.</td> </tr> </tbody> </table> # Table of Contents Revision History ...................................................................................................................................................................... 2 Vivado Design Flows Overview ............................................................................................................................................. 5 Introduction ............................................................................................................................................................................. 5 Working in Project Mode and Non-Project Mode .................................................................................................... 5 Tutorial Design Description ................................................................................................................................................ 8 Hardware and Software Requirements .......................................................................................................................... 8 Preparing the Tutorial Design Files ................................................................................................................................. 8 Lab 1: Using the Non-Project Design Flow ....................................................................................................................... 9 Introduction ............................................................................................................................................................................. 9 Step 1: Examine the Example Script ................................................................................................................................ 9 Step 2: Starting Vivado with the Example Design ..................................................................................................... 9 Step 3: Synthesizing the Design .................................................................................................................................... 11 Step 4: Launching the Vivado IDE .................................................................................................................................... 11 Step 5: Defining Timing Constraints and I/O Planning ................................................................................................. 13 Step 6: Exporting the Modified Constraints ................................................................................................................ 16 Step 7: Implementing the Design .................................................................................................................................... 17 Step 8: Opening a Design Checkpoint ......................................................................................................................... 18 Step 9: Analyzing Implementation Results ................................................................................................................ 18 Step 10: Exiting the Vivado Tool ................................................................................................................................... 21 Lab 2: Using the Project Design Flow .............................................................................................................................. 22 Introduction .......................................................................................................................................................................... 22 Step 1: Creating a Project ............................................................................................................................................... 22 Step 2: Using the Sources Window and Text Editor .............................................................................................. 29 Step 3: Elaborating the RTL Design .............................................................................................................................. 32 Step 4: Using the IP Catalog ........................................................................................................................................... 34 Step 5: Running Behavioral Simulation ...................................................................................................................... 35 Step 6: Reviewing Design Run Settings ........................................................................................................................ 36 IMPORTANT: This tutorial requires the use of the Kintex®-7 family of devices. You will need to update your Vivado tools installation if you do not have this device family installed. Refer to the Vivado Design Suite User Guide: Release Notes, Installation, and Licensing (UG973) for more information on Adding Design Tools or Devices. Introduction This tutorial introduces the use models and design flows recommended for use with the Xilinx® Vivado® Integrated Design Environment (IDE). This tutorial describes the basic steps involved in taking a small example design from RTL to bitstream, using two different design flows as explained below. Both flows can take advantage of the Vivado IDE, or be run through batch Tcl scripts. The Vivado Tcl API provides considerable flexibility and power to help set up and run your designs, as well as perform analysis and debug. VIDEO: You can also learn more about the Vivado Design Suite design flows by viewing the quick take video at Vivado Design Flows and the Vivado Getting Started with the Vivado IDE quick take video. TRAINING: Xilinx provides training courses that can help you learn more about the concepts presented in this document. Use these links to explore related courses: - Designing FPGAs Using the Vivado Design Suite 1 - Designing FPGAs Using the Vivado Design Suite 2 Working in Project Mode and Non-Project Mode Some users prefer the design tool for automatically managing their design flow process and design data, while others prefer to manage sources and process themselves. The Vivado Design Suite uses a project file (.xpr) and directory structure to manage the design source files, store the results of different synthesis and implementation runs, and track the project status through the design flow. This automated management of the design data, process, and status requires a project infrastructure. For this reason, Xilinx refers to this flow as the Project Mode. Other users prefer to run the FPGA design process more like a source file compilation, to simply compile the sources, implement the design, and report the results. This compilation style flow is referred to as the Non-Project mode. The Vivado Design Suite easily accommodates both of these use models. Both of these flows utilize a project structure to compile and manage the design. The main distinctions are that Non-Project mode processes the entire design in memory. No files are written to disk. While Project mode creates and maintains a project directory structure on disk to manage design sources, results, and project settings and status. The following provides a brief overview of Project mode and Non-Project mode. For a more complete description of these design modes, and the features and benefits of each, refer to the Vivado Design Suite User Guide: Design Flows Overview (UG892). **Non-Project Mode** This use model is for script-based users who do not want Vivado tools to manage their design data or track their design state. The Vivado tools simply read the various source files and compile the design through the entire flow in-memory. At any stage of the implementation process, you can generate a variety of reports, run design rule checks (DRCs), and write design checkpoints. Throughout the entire flow, you can open the design in-memory, or any saved design checkpoint, in the Vivado IDE for design analysis or netlist/constraint modification. Source files, however, are not available for modification in the IDE when running the Non-Project mode. It is also important to note that this mode does not enable project-based features such as source file and run management, cross-probing back to source files, design state reporting, etc. Essentially, each time a source file is updated on the disk; you must know about it and reload the design. There are no default reports or intermediate files created within the Non-Project mode. You must direct the creation of reports or design checkpoints with Tcl commands. **Project Mode** This use model is for users who want the Vivado tools to manage the entire design process, including features like source file, constraint and results management, integrated IP design, and cross probing back to sources. In Project mode, the Vivado tools create a directory to manage the design source files, IP data, synthesis and implementation run results and related reports. The Vivado Design Suite manages and reports the status of the source files, configuration, and the state of the design. You can create and configure multiple runs to explore constraint or command options. In the Vivado IDE, you can cross-probe implementation results back to the RTL source files. You can also script the entire flow with Tcl commands, and open Vivado IDE as needed. Using Tcl Commands The Tcl commands and scripting approach vary depending on the design flow used. When using the Non-Project mode, the source files are loaded using \texttt{read_verilog}, \texttt{read_vhdl}, \texttt{read_edif}, \texttt{read_ip}, and \texttt{read_xdc} commands. The Vivado Design Suite creates an in-memory design database to pass to synthesis, simulation, and implementation. When using Project mode, you can use the \texttt{create_project}, \texttt{add_files}, \texttt{import_files}, and \texttt{add_directories} commands to create the project infrastructure needed to manage source files and track design status. Replace the individual “atomic” commands, \texttt{synth_design}, \texttt{opt_design}, \texttt{place_design}, \texttt{route_design}, and \texttt{write_bitstream} in the Batch flow, with an all-inclusive command called \texttt{launch_runs}. The \texttt{launch_runs} command groups the atomic commands together with other commands to generate default reports and track the run status. The resulting Tcl run scripts for the Project mode are different from the Non-Project mode. This tutorial covers the Project mode and Non-Project mode, as well as the Vivado IDE. Many of the analysis features discussed in this tutorial are covered in more detail in other tutorials. Not every command or command option is represented here. To view the entire list of Tcl commands provided in the tools, consult the \textit{Vivado Design Suite Tcl Command Reference Guide} (UG835). This tutorial contains two labs that can be performed independently. \textbf{Lab 1: Using the Non-Project Design Flow} - Walk through a sample run script to implement the \texttt{bft} design. - View various reports at each step. - Review the \texttt{vivado.log} file. - Write design checkpoints. - Open the Vivado IDE after synthesis to review timing constraint definition and I/O planning and demonstrate methods to update constraints. - Open the implemented Design Checkpoint to analyze timing, power, utilization and routing. \textbf{Lab 2: Using the Project Based Design Flow} - Create a new project. - Walk through implementing the \texttt{bft} design using the Vivado IDE. - View various reports at each step. - Open the synthesized design and review timing constraint definition, I/O planning and design analysis. - Open the implemented design to analyze timing, power, resource utilization, routing, and cross-probing. Tutorial Design Description The sample design used throughout this tutorial consists of a small design called `bft`. There are several VHDL and Verilog source files in the `bft` design, as well as a XDC constraints file. The design targets an xc7k70T device. A small design is used to allow the tutorial to be run with minimal hardware requirements and to enable timely completion of the tutorial, as well as to minimize the data size. Hardware and Software Requirements This tutorial requires that the 2018.1 Vivado Design Suite software release or later is installed. The following partial list describes the operating systems that the Vivado Design Suite supports on x86 and x86-64 processor architectures: See the *Vivado Design Suite User Guide: Release Notes, Installation, and Licensing* (UG973) for a complete list and description of the system and software requirements. Preparing the Tutorial Design Files You can find the files for this tutorial in the Vivado Design Suite examples directory at the following location: ``` <Vivado_install_area>/Vivado/<version>/examples/Vivado_Tutorial ``` You can also extract the provided ZIP file, at any time, to write the tutorial files to your local directory, or to restore the files to their starting condition. Extract the ZIP file contents from the software installation into any write-accessible location. ``` <Vivado_install_area>/Vivado/<version>/examples/Vivado_Tutorial.zip ``` The extracted Vivado_Tutorial directory is referred to as the `<Extract_Dir>` in this Tutorial. **Note:** You will modify the tutorial design data while working through this tutorial. You should use a new copy of the original Vivado_Tutorial directory each time you start this tutorial. Lab 1: Using the Non-Project Design Flow Introduction This lab focuses on Non-Project mode and the associated Tcl commands. Step 1: Examine the Example Script 1. Open the example script: `<Extract_Dir>/Vivado_Tutorial/create_bft_kintex7_batch.tcl`, in a text editor and review the different steps. STEP#0: Define output directory location. STEP#1: Setup design sources and constraints. STEP#2: Run synthesis, report utilization and timing estimates, write checkpoint design. STEP#3: Run placement and logic optimization, report utilization and timing estimates, write checkpoint design. STEP#4: Run router, report actual utilization and timing, write checkpoint design, run drc, write verilog and xdc out. STEP#5: Generate a bitstream. Notice that many of the Tcl commands are commented out. You will run them manually, one at a time. 2. Leave the example script open, as you will copy and paste commands from it later in this tutorial. Step 2: Starting Vivado with the Example Design On Linux 1. Change to the directory where the lab materials are stored: `cd <Extract_Dir>/Vivado_Tutorial` 2. Launch the Vivado Design Suite Tcl shell, and source a Tcl script to create the tutorial design: `vivado -mode tcl -source create_bft_kintex7_batch.tcl` On Windows 1. Launch the Vivado Design Suite Tcl shell: **Start > All Programs > Xilinx Design Tools > Vivado <version> > Vivado <version> Tcl Shell** *Note: Your Vivado Design Suite installation may be called something other than Xilinx Design Tools on the Start menu.* 2. In the Tcl shell, change to the directory where the lab materials are stored: ``` Vivado% cd <Extract_Dir>/Vivado_Tutorial ``` 3. Source a Tcl script to create the tutorial design: ``` Vivado% source create_bft_kintex7_batch.tcl ``` After the sourced script has completed, the Vivado Design Suite Tcl shell, hereafter called the Tcl shell, displays the Tcl prompt: **Vivado%** ![Figure 1: Start Vivado and Source Tcl Script](image) You can enter additional Tcl commands from the Tcl prompt. Step 3: Synthesizing the Design 1. Copy and paste the `synth_design` command from the `create_bft_kintex7_batch.tcl` script into the Tcl shell and wait for synthesis to complete. You can paste into the Tcl shell using the popup menu, by clicking the right mouse button. ```tcl synth_design -top bft ``` **Note:** The command in the example script is a comment. Do not copy the leading ‘#’ character, or your command will also be interpreted as a comment. 2. Examine the synthesis report as it scrolls by. 3. When the Vivado Tcl prompt has returned, copy and paste the `write_checkpoint`, `report_timing_summary`, `report_power`, `report_clock_interaction`, and `report_high_fanout_nets` commands that follow synthesis. ```tcl write_checkpoint -force $outputDir/post_synth report_timing_summary -file $outputDir/post_synth_timing_summary.rpt report_power -file $outputDir/post_synth_power.rpt report_clock_interaction -delay_type min_max -file \$outputDir/post_synth_clock_interaction.rpt report_high_fanout_nets -fanout_greater_than 200 -max_nets 50 -file \$outputDir/post_synth_high_fanout_nets.rpt ``` 4. Open another window to look at the files created in the output directory. On Windows, it may be easier to use the file browser. `<Extract_Dir>/Vivado_Tutorial/Tutorial_Created_Data/bft_output` 5. Use a text editor to open the various report (`*.rpt`) files that were created. Step 4: Launching the Vivado IDE Even though a Vivado project has not been created on disk, the in memory design is available in the tool, so from the Tcl shell you can open the Vivado IDE to view the design. Non-Project mode enables the use of the Vivado IDE at various stages of the design process. The current netlist and constraints are loaded into memory in the IDE, enabling analysis and modification. Any changes to the logic or the constraints are live in memory and are passed to the downstream tools. This is quite a different concept than with the ISE tools that require saving and reloading files. Open the IDE using the `start_gui` command. ```bash Vivado% start_gui ``` The Vivado IDE provides design visualization and exploration capabilities for your use. From the Vivado IDE, you can perform further analysis and constraint manipulation on the design. TIP: To stop the GUI and return to the Vivado Design Suite Tcl shell, use the `stop_gui` command. If you use the File > Exit command from the Vivado IDE, you will completely exit the Vivado tool. Since the design does not have a project in Non-Project mode, the Vivado IDE does not enable source file or run management. You are effectively analyzing the current in memory design. The Vivado Flow Navigator and other project based commands are also not available in Non-Project mode. Step 5: Defining Timing Constraints and I/O Planning You must often define timing and physical constraints for the design prior to implementation. The Vivado tools let you load constraints from constraints file(s), or enter constraints interactively using the IDE. Defining Timing Constraints 1. Open the Timing Constraints window: Window > Timing Constraints, as shown in the following figure: ![](image) Figure 3: Define Timing Constraints A tree view of the different types of constraints displays on the left side of the Timing Constraints window. This is a menu of timing constraints that can be quickly defined. Notice the two clock constraints, \(wbClk\) and \(bftClk\), displayed in the Timing Constraint spreadsheet on the right side of the Timing Constraints window. The values of currently defined constraints can be modified by directly editing them in the spreadsheet. 2. In the left hand tree view of the Timing Constraints window, double-click **Create Clock** under the Clocks category, as shown in Figure 3. **Note:** Expand the Clocks category if needed by clicking the +. The Create Clock wizard opens, as shown in the following figure, to help you define clock constraints. Notice the Tcl Command line on the bottom displays the XDC command that will be executed. Do not create or modify any timing constraints at this time. ![Create Clock Dialog Box](image 3. Click **Cancel**. 4. Close the **Timing Constraints** window by clicking the X in the window tab. The Vivado Design Suite offers a variety of features for design analysis and constraint assignment. Other tutorials cover these features in detail, and they are only mentioned here. Feel free to examine some of the features under the Tools menu. I/O Planning Vivado has a comprehensive set of capabilities for performing and validating I/O pin assignments. These are covered in greater detail in the I/O Planning Tutorial. 1. Open the I/O Planning view layout by selecting I/O Planning from the Layout Selector pull down, as shown in Figure 5. 2. Make the Package window the active view if it is not active. **Note:** If the Package window is not open, you can open it using the Windows > Package command from the main menu. ![Figure 5: Open I/O Planning View Layout](image-url) 5. In the Package window, double-click to select a placed I/O Port, shown as an orange block inside a package pin. 6. Drag the selected I/O Port onto another pin site in the same I/O bank. 7. Examine the I/O Ports window, look at the port name and package pin site columns. 8. Examine the data displayed in the I/O Port Properties window. Click each of the tabs at the bottom of the window. 9. Remember the port name and site of the port you moved. If necessary, write them down. You will look for the LOC constraint of the placed port in the XDC file after implementation. **Step 6: Exporting the Modified Constraints** Modified constraints can be output for later use. You can also save design checkpoints that include the latest changes. You will explore design checkpoints later in this tutorial. **IMPORTANT:** The Vivado Design Suite does not support NCF/UCF constraints. You should migrate existing UCF constraints to XDC format. Refer to the ISE to Vivado Design Suite Migration Guide (UG911) for more information. 1. Use the Export Constraints command to output a modified XDC constraints file with the new I/O LOC constraint value. **File > Export > Export Constraints** The Export Constraints dialog box opens to let you specify a file name to create, as shown in the following figure. ![Export Constraints dialog box](image.png) 2. Enter a name and location for the file and click **OK**. 3. Use the **File > Text Editor > Open File** command to open the constraints file in the Text Editor. 4. Browse to select the newly exported constraints file and click **OK**. 5. Notice the file reflects the I/O Port placement change you made earlier. **TIP:** You can open any ASCII file in the Text Editor. This is helpful for editing Tcl scripts and constraints files, and viewing reports. The Text Editor is context sensitive, and highlights keywords and comments when displaying file types such as Verilog, VHDL, XDC, and Tcl. 6. Select the **Tcl Console** tab at the bottom of the IDE, and enter the `stop_gui` command. The Vivado IDE closes, and you are returned to the Tcl prompt in the Tcl shell. --- **Step 7: Implementing the Design** 1. Open the `create_bft_kintex7_batch.tcl` script, or bring the script window to the front. 2. Individually copy and paste the Tcl commands in the script, in order from `opt_design` to `write_bitstream`: ```tcl opt_design place_design phys_opt_design write_checkpoint -force $outputDir/post_place report_timing_summary -file $outputDir/post_place_timing_summary.rpt route_design write_checkpoint -force $outputDir/post_route report_timing_summary -file $outputDir/post_route_timing_summary.rpt report_timing -sort_by group -max_paths 100 -path_type summary -file \ $outputDir/post_route_timing.rpt report_clock_utilization -file $outputDir/clock_util.rpt report_utilization -file $outputDir/post_route_util.rpt report_power -file $outputDir/post_route_power.rpt report_drc -file $outputDir/post_imp_drc.rpt write_verilog -force $outputDir/bft_impl_netlist.v write_xdc -no_fixed_only -force $outputDir/bft_impl.xdc write_bitstream -force $outputDir/bft.bit ``` 3. Examine each command and notice the various messages produced as the commands are run. 4. Close the text editor displaying the `create_bft_kintex7_batch.tcl` script. 5. Examine the files created in the output directory. `<Extract_Dir>/Vivado_Tutorial/Tutorial_Created_Data/bft_output` 6. Use a text editor to open the various report (*.rpt) files that were created. 7. Open the `bft_impl.xdc` file. 8. Validate that the design has been implemented with the I/O Port constraint that you modified earlier. --- ### Step 8: Opening a Design Checkpoint The Vivado IDE can open any saved design checkpoint. This snapshot of the design can be opened in the Vivado IDE or Tcl shell for synthesis, implementation, and analysis. 1. Open the Vivado IDE again: `start_gui` This loads the active design in-memory into the IDE. You will now load the implemented design checkpoint, closing the current in-memory design. 2. Open the implemented checkpoint. 3. Use `File > Checkpoint > Open` and browse to select the checkpoint file: `<Extract_Dir>/Vivado_Tutorial/Tutorial_Created_Data/bft_output/post_route.dcp` 4. If prompted, select `Close Without Saving` to close the current in-memory design. Now you can use the visualization and analysis capabilities of the IDE, working from a placed and routed design checkpoint. --- ### Step 9: Analyzing Implementation Results Vivado has an extensive set of features to examine the design and device data from a number of perspectives. You can generate standard reports for power, timing, utilization, clocks, etc. With the Tcl API, the custom reporting capabilities in the Vivado tools are extensive. 1. Click the Device window tab to bring it front to the screen. 2. Run the `report_timing_summary` command to analyze timing data. **Reports > Timing > Report Timing Summary** 3. In the Report Timing Summary dialog, click **OK** to accept the default run options. 4. Examine the information available in the Timing Summary window. Select the various categories from the tree on the left side of the Timing Summary window and examine the data displayed. 5. Now run the `report_timing` command to perform timing analysis. **Reports > Timing > Report Timing** 6. In the Report Timing dialog, click **OK** to accept the default run options. 7. Collapse the **bftClk** tree in the Timing Checks – Setup window. 8. Select the first path listed under the **wbClk** in the Setup area. 9. Maximize or float the Path Properties window to look at the path details. Check to ensure that the **Device** view tab is selected and displayed. ![Path Properties Window](image) **Figure 7: Float the Path Properties Window** 10. Restore the Path Properties window by clicking the **Restore** button, or the **Dock** button, in the window banner. 11. In the Timing – Report Timing window, right-click to open the popup menu and select the **Schematic** command to open a Schematic window for the selected path. **Note:** Alternatively, you can press the **F4** function key to open the Schematic window. 12. Double-click on a schematic object, such as on a cell, pin, or wire, to expand the schematic connections and traverse the design hierarchy. 13. Close the Schematic window, or click the Device window tab to bring it to the front. 14. In the Device window, check to ensure that the Routing Resources button is enabled to display the detailed device routing. In some cases you may need to select the path again. Notice the Device window displays and highlights the routing for the selected path. ![Figure 8: Displaying the Device Routing](image) 15. Select the **Auto-fit Selection** button in the Device window toolbar menu to enable the Vivado IDE to automatically zoom into selected objects. 16. Select some additional paths from the Timing results window. 17. Examine the routing for the selected paths in the Device window. 18. Expand the **Reports** main menu and examine the available analysis features. Many of these Design Analysis features are covered in other Vivado tutorials. Step 10: Exiting the Vivado Tool The Vivado tool writes a log file, called `vivado.log`, and a journal file called `vivado.jou` into the directory from which Vivado was launched. The log file is a record of the Tcl commands run during the design session, and the messages returned by the tool as a result of those commands. The journal is a record of the Tcl commands run during the session that can be used as a starting point to create new Tcl scripts. Exit the Vivado IDE: 1. Select the Tcl Console window tab and type the following: ``` stop_gui ``` 2. Exit Vivado: ``` Vivado% exit ``` 3. Close the Tcl shell window on Windows. 4. Examine the Vivado log (`vivado.log`) file. On Windows, it may be easier to use the file browser to locate and open the log file. The location of the Vivado log and journal file will be the directory from which the Vivado tool was launched, or can be separately configured in the Windows desktop icon. You will configure this in Lab #2. In this case, look for the log file at the following location: ``` <Extract_Dir>/Vivado_Tutorial/vivado.log ``` **Note:** The `vivado.log` and `vivado.jou` may also be written to ``` %APPDATA%\Xilinx\Vivado, or to your /home directory. ``` Notice the log file contains the history and results of all Tcl commands executed during the Vivado session. 5. Examine the Vivado journal (`vivado.jou`) file. On Windows, it may be easier to use the file browser. Look for the journal file at the following location: ``` <Extract_Dir>/Vivado_Tutorial/vivado.jou ``` Notice the journal file contains only the Tcl commands executed during the Vivado session, without the added details recorded in the log file. The journal file is often helpful when creating Tcl scripts from prior design sessions, as you will see in the next lab. Lab 2: Using the Project Design Flow Introduction In this lab, you will learn about the Project mode features for project creation, source file management, design analysis, constraint definition, and synthesis and implementation run management. You will walk through the entire FPGA design flow using an example design, starting in the Vivado® IDE. Then you will examine some of the major features in the IDE. Most of these features are covered in detail in other tutorials. Finally, you will create a batch run script to implement the design project and see how easy it is to switch between running Tcl scripts and working in the Vivado IDE. Step 1: Creating a Project Launching Vivado On Linux 1. Change to the directory where the lab materials are stored: ```bash cd <Extract_Dir>/Vivado_Tutorial ``` 2. Launch the Vivado IDE: ```bash vivado ``` On Windows 1. Before clicking the desktop icon to launch the Vivado tool, configure the icon to indicate where to write the `vivado.log` and `vivado.jou` files. 2. Right-click the **Vivado <version>** Desktop icon and select **Properties** from the popup menu. 3. Under the **Shortcut** tab, set the **Start in** value to the extracted Vivado Tutorial directory, as shown in **Figure 9**: ```bash <Extract_Dir>/Vivado_Tutorial/ ``` 4. Click **OK** to close the Properties dialog box. 5. Double-click the **Vivado <version>** Desktop icon to start the Vivado IDE. Creating a New Project 1. After Vivado opens, select **Create Project** on the Getting Started page. 2. Click **Next** in the New Project wizard. 3. Specify the Project Name and Location: a. Project name: *project_bft* b. Project Location: `<Extract_Dir>/Vivado_Tutorial/Tutorial_Created_Data` 4. Click **Next**. ![New Project dialog](image) **Figure 10: Create New Project** 5. Select **RTL Project** as the **Project Type** and click **Next**. 6. Click the **+** button and select **Add Files**. a. Browse to `<Extract_Dir>/Vivado_Tutorial/Sources/hdl/ b. Press and hold the **Ctrl** key, and click to select the following files: - async_fifo.v, bft.vhdl, bft_tb.v, FifoBuffer.v c. Click **OK** to close the File Browser. 7. Click the **+** button and select **Add Directories**. a. Select the `<Extract_Dir>/Vivado_Tutorial/Sources/hdl/bftLib` directory b. Click **Select**. 8. Click in the **HDL Sources For** column for the `bft_tb.v` file and change Synthesis and Simulation to **Simulation only**, as shown in Figure 11. ![Figure 11: Add RTL Sources](image) 9. Click in the **Library** column for the `bftLib`, and manually edit the value to change it from `xil_defaultlib` (or work) to `bftLib`, as shown in the following figure. 10. Enable the check boxes for **Copy sources into project**, and **Add sources from subdirectories**. 11. Set the **Target Language** to **Verilog** to define the language of the netlist generated by Vivado synthesis. 12. Set the **Simulator Language** to **Verilog** to define the language required by the logic simulator. 13. Click **Next**. 14. On the Add Constraints page, click **Add Files**. 15. Browse to and select: `<Extract_Dir>/Vivado_Tutorial/Sources/bft_full_kintex7.xdc` 16. Click **OK** to close the File Browser. 17. Enable the check box for *Copy constraints files into project.* ![Figure 12: Add Constraints](image) 18. Click **Next** to move to the Default Part page. 19. On the Default Part page, click the **Family** filter and select the **Kintex-7** family. 20. Scroll to the top of the list and select the $xc7k70tfbg484-2$ part, and click **Next**. ![Figure 13: Selecting the Default Part](image) 21. Click **Finish** to close the New Project Summary page, and create the project. The Vivado IDE opens **project_bft** in the default layout. ![Figure 14: Project BFT in the Vivado IDE](image-url) Step 2: Using the Sources Window and Text Editor The Vivado tool lets you add different design sources including Verilog, VHDL, EDIF, NGC format cores, SDC, XDC, DCP design checkpoints, TCL constraints files, and simulation test benches. These files can be sorted in a variety of ways using the tabs at the bottom of the Sources window (Hierarchy, Libraries, or Compile Order). **IMPORTANT:** NGC format files are not supported in the Vivado Design Suite for UltraScale™ devices. It is recommended that you regenerate the IP using the Vivado Design Suite IP customization tools with native output products. Alternatively, you can use the NGC2EDIF command to migrate the NGC file to EDIF format for importing. However, Xilinx recommends using native Vivado IP rather than XST-generated NGC format files going forward. The Vivado IDE includes a context sensitive text editor to create and develop RTL sources, constraints files, and Tcl scripts. You can also configure the Vivado IDE to use third party text editors. Refer to the Vivado Design Suite User Guide: Using the IDE (UG893) for information on configuring the Vivado tool. **Exploring the Sources Window and Project Summary** 1. Examine the information in the Project Summary. More detailed information is presented as the design progresses through the design flow. 2. Examine the Sources window and expand the Design Sources, Constraints and Simulation Sources folders. The Design Sources folder helps keep track of VHDL and Verilog source files and libraries. Notice the Hierarchy tab displays by default. 3. Select the Libraries tab and the Compile Order tabs in the Sources window and notice the different ways that sources are listed. 4. The Libraries tab groups source files by file type. The Compile Order tab shows the file order used for synthesis. 5. Expand the various folders to view the design source information. 6. Select the **Hierarchy** tab. **Exploring the Text Editor** 1. Select one of the VHDL sources in the Sources window. 2. Right-click to review the commands available in the popup menu. 3. Select **Open File**, and use the scroll bar to browse the file contents in the Text Editor. You can also double-click source files in the Sources window to open them in the Text Editor. ![Figure 16: Context Sensitive Text Editor](image) Notice that the Text Editor displays the RTL code with context sensitive coloring of keywords and comments. The Fonts and Colors used to display reserved words can be configured using the **Tools > Settings** command. Refer to the *Vivado Design Suite User Guide: Using the IDE* (UG893) for more information. 4. With the cursor in the Text Editor, right-click and select **Find in Files**. Note the **Replace in Files** command as well. The Find in Files dialog box opens with various search options. ![Figure 17: Using Find in Files](image) 5. Enter **clk** in the **Find what:** field, and click **Find**. The Find in Files window displays in the messaging area at the bottom of the Vivado IDE. ![Figure 18: Viewing the Find in Files Results](image) 6. In the Find in Files window, expand one of the displayed files, and select an occurrence of `clk` in the file. Notice that the Text Editor opens the selected file and displays the selected occurrence of `clk` in the file. 7. Close the Find in Files – Occurrences window. 8. Close the open Text Editor windows. The next few steps highlight some of the design configuration and analysis features available prior to running synthesis. --- **Step 3: Elaborating the RTL Design** The Vivado IDE includes an RTL analysis and IP customizing environment. There are also several RTL Design Rule Checks (DRCs) to examine ways to improve performance or power on the RTL design. 1. Select **Open Elaborated Design** in the Flow Navigator to elaborate the design. **TIP:** A dialog box appears informing you that your current settings will slow down netlist elaboration. You can click **OK** to continue or **Cancel** to return to your project and edit your Elaboration Settings, available in the Flow Navigator. ![Figure 19: Elaborate Design Dialog Box](image) 2. Ensure that the Layout Selector pull down menu in the main Toolbar has **Default Layout** selected. The Elaborated Design enables various analysis views including an RTL Netlist, Schematic, and Graphical Hierarchy. The views have a cross-select feature, which helps you to debug and optimize the RTL. 3. Explore the logic hierarchy in the RTL Netlist window and examine the Schematic. You can traverse the schematic by double-clicking on cells to push into the hierarchy, or by using commands like the **Expand Cone** or **Expand/Collapse** from the Schematic popup menu. Refer to the *Vivado Design Suite User Guide: Using the Vivado IDE* (UG893) for more information on using the Schematic window. 4. Select any logic instance in the Schematic and right-click to select the **Go to Source** or **Go to Definition** commands. The Text Editor opens the RTL source file for the selected cell with the logic instance highlighted. In the case of the **Go to Definition** command, the RTL source file containing the module definition is opened. With **Go to Source**, the RTL source containing the instance of the selected cell is opened. 5. Click the Messages window at the bottom of the Vivado IDE, and examine the messages. 6. Click the **Collapse All** button in the Messages toolbar. 7. Expand the Elaborated Design and the `synth_design -rtl -name rtl_1` messages. ![Figure 20 Messages Dialog Box](image) Notice there are links in the messages to open the RTL source files associated with a message. 8. Click one of the links and the Text Editor opens the RTL source file with the relevant line highlighted. 9. Close the Text Editor windows. 10. Close the Elaborated Design by clicking on the X on the right side of the Elaborated Design window banner, and click **OK** to confirm. Step 4: Using the IP Catalog The Xilinx IP Catalog provides access to the Vivado IP configuration and generation features. You can sort and search the Catalog in a variety of ways. IP can be customized, generated, and instantiated. 1. Click the **IP Catalog** button in the Flow Navigator, under Project Manager. 2. Browse the IP Catalog to examine the various categories and IP filtering capabilities. 3. Click the Group by taxonomy and repository icon and notice the selection to **Group by taxonomy** and **Group by repository**. 4. Expand the **Basic Elements** folder. 5. Double-click **DSP48 Macro**. - The Customize IP dialog is opened directly within Vivado Design Suite, which allows you to perform native customization and configuration of IP within the tool. To learn more about IP configuration and implementation, see the *Vivado Design Suite User Guide: Designing with IP* (UG896) and the *Vivado Design Suite Tutorial: Designing with IP* (UG939). 6. Click **Cancel** to close the Customize IP dialog without adding the IP to the current design. 7. Close the IP Catalog tab by clicking on the X on the window tab. Step 5: Running Behavioral Simulation The Vivado IDE integrates the Vivado Simulator, which enables you to add and manage simulation sources in the project. You can configure simulation options, and create and manage simulation source sets. You can run behavioral simulation on RTL sources, prior to synthesis. 1. In the Flow Navigator, under Project Manager, click the **Settings** command. The Settings dialog box opens with Project Settings at the top, and Tool Settings below that. ![Figure 21: Simulation Settings - Update](image) 2. Examine the settings available on the **Simulation** page, then click **Cancel** to close the dialog box. 3. Click the **Run Simulation** command in the Flow Navigator, then click the **Run Behavioral Simulation** in the sub-menu. 4. Examine and explore the Simulation environment. Simulation is covered in detail in the **Vivado Design Suite User Guide: Logic Simulation** (UG900) and the **Vivado Design Suite Tutorial: Logic Simulation** (UG937). 5. Close the simulation by clicking the **X** icon on the Behavioral Simulation view banner. 6. Click **OK** to close the Simulation window and click **No** if prompted to save changes. Step 6: Reviewing Design Run Settings One of the main differences between the Non-Project mode you used in Lab #1 and the Project mode, which you are now using, is the support of design runs for synthesis and implementation. Non-Project mode does not support design runs. Design runs are a way of configuring and storing the many options available in the different steps of the synthesis and implementation process. You can configure these options and save the configurations as strategies to be used in future runs. You can also define Tcl.pre and Tcl.post scripts to run before and after each step of the process, to generate reports before and after the design progresses. Before launching the synthesis and implementation runs you will review the settings and strategies for these runs. 1. In the Flow Navigator, under Project Manager, click the Settings command. The Settings dialog box opens. Figure 22: Synthesis Settings 2. Select the **Synthesis** page under Project Settings. The Synthesis Settings provide you access to the many options available for configuring Vivado synthesis. For a complete description of these options, see the *Vivado Design Suite User Guide: Synthesis* (UG901). 3. After reviewing the various synthesis options, select the **Implementation** page on the left side of the Settings dialog box, as shown in Figure 23. The Settings change to reflect the Implementation settings. You can view the available options for implementation runs. For a complete description of these options, see the *Vivado Design Suite User Guide: Implementation* (UG904). ![Figure 23: Implementation Settings](image) 4. Click **Cancel** to close the Settings dialog box. You are now ready to launch Vivado synthesis and implementation. Step 7: Synthesizing and Implementing the Design After configuring the synthesis and implementation run options, you can: - **Use the Run Synthesis command** to run only synthesis. - **Use the Run Implementation command**, which will first run synthesis if it has not been run and then run implementation. - **Use the Generate Bitstream command**, which will first run synthesis, then run implementation if they have not been run, and then write the bitstream for programming the Xilinx device. For this tutorial, we will run these steps one at a time. 1. In the Flow Navigator, click the **Run Synthesis** button. 2. Click **OK** to launch Synthesis with the default options and wait for the task to complete. Notice the progress bar in the upper-right corner of the Vivado IDE, indicating the run is in progress. Vivado launches the synthesis engine in a background process to free up the tool for other actions. While the synthesis process is running in the background, you can continue browsing Vivado IDE windows, run reports, and further evaluate the design. You will notice that the Log window displays the synthesis log at the bottom of the IDE. This is also available through the Reports window. After synthesis has completed, the Synthesis Completed dialog box prompts you to choose the next step. 3. Select **Run Implementation**, and click **OK**. 4. Click **OK** to launch Implementation with the default options and wait for the task to complete. The implementation process is launched, and placed into a background process after some initialization. The next step in this tutorial shows you how to perform design analysis of the synthesized design while waiting for implementation to complete. Step 8: Analyzing the Synthesized Design Opening the synthesized design enables design analysis, timing constraint definition, I/O planning, floorplanning and debug core insertion. These features are covered in other tutorials, but you can take a quick look in this step. 1. While implementation is running, select **Open Synthesized Design** in the Flow Navigator and wait for the design to load. Notice that as the Vivado IDE opens the synthesized design, the implementation continues running in the background. At some point while you are exploring the synthesized design, implementation will complete, and the Implementation Completed dialog box prompts you to choose the next step. ![Implementation Complete](image) **Figure 26: Implementation Complete** 2. Click **Cancel** to close the dialog without taking any action. *Note:* This leaves the synthesized design open. You will open the implemented design after you are finished examining the features of the synthesized design. 3. Ensure that the Layout Selector pull-down menu in the main Toolbar has **Default Layout** selected. 4. Click the **Reports** tab at the bottom of Vivado IDE. If the Reports window is not open, you can open it with **Windows > Reports**. 5. Double-click **Vivado Synthesis Report** to examine the report. 6. Double-click **Utilization Report** to examine the report. 7. **Close all reports** when you have finished examining them. 8. Click the Messages tab at the bottom of the Vivado IDE. If the Messages window is not open, you can open it with **Windows > Messages**. The Messages window provides message type filters in its banner that display or hide Error, Critical Warning, Warning, Info, and Status messages. 9. Click the **Collapse All** button to condense all of the Messages. 10. Expand the Synthesis messages. 11. Scroll through the Synthesis messages and notice the links to specific lines within source files. Click some of the links and notice the source file opens in the Text Editor with the appropriate line highlighted. ![Figure 27: Synthesis Messages Linked to Source Files](image) The Report Timing Summary dialog box opens. Examine the various fields and options of this command. 13. Click **OK** to run with default options. The Timing Summary Results window opens. 14. Examine the Timing Summary results showing timing estimates prior to implementation. Click on some of the reporting categories in the tree on the left side of the Timing Summary Results window. The Report Power dialog box opens. Examine the various fields and options of this command. 16. Click **OK** to run with default options. The Power Results window opens. Examine the Power Results window showing power estimates prior to implementation. The report is dynamic, with tooltips providing details of the specific sections of the report when you move the mouse over the report, as shown in Figure 29. 17. Click some of the reporting categories in the tree on the left side of the Power Results window to examine the different information presented. 18. Close the Timing Summary results, the Power Report window, and any open Text Editor windows. Step 9: Analyzing the Implemented Design The Vivado IDE is interactive, enabling editing of design constraints and netlists on the in-memory design. When you save the design, constraint changes are written back to the original source XDC files. Alternatively, you can save the changes to a new constraints file to preserve the original constraints. This flexibility supports exploration of alternate timing and physical constraints, including floorplanning, while keeping the original source files intact. Opening the Implemented Design 1. Select Open Implemented Design in the Flow Navigator. 2. If prompted, select Yes to close the synthesized design and Don’t Save. You can see the Implemented Design displayed in the Device window. 3. Click on the Reports tab at the bottom of the Vivado IDE. If the Reports window is not open, you can open it with Windows > Reports. Select and examine some of the reports from Place Design and Route Design. Close each of the reports when you are done. 4. Select the Messages tab at the bottom of the IDE. If the Messages window is not open, you can open it with Windows > Messages. 5. Click the Collapse All button to condense all of the Messages. 6. Expand the Implementation folder Analyzing Routing After the design has been placed and routed, you can generate a timing report to verify that all the timing constraints are met. You can select paths from the Timing Report window to examine the routed path in the Device window. If there are timing problems, you can revisit the RTL source files or design constraints to address any problems. 1. In the Device window, select the Routing Resources button to display the device routing. This lets you see the routed connection in the Device window. Though you will need to zoom closely into the device to see elements of the route, a zoomed-out view lets you see the route in its entirety. 2. Select the Auto-fit Selection button in the Device window toolbar menu to enable the Vivado IDE to automatically zoom into and center the selected objects. 3. On the left side pane of the Timing window, select: Intra-Clock Paths > wbClk > HOLD 4. In the table view on the right side of the Timing Summary Report window, click any timing path to select it and highlight it in the Device window. Select various paths in the Timing Summary window and examine the path routing. 5. On the left side pane of the Timing Summary Results window, select: **Intra-Clock Paths > wbClk > SETUP** 6. Click any path in the table view on the right side of the Timing Summary Results window to select it and highlight it in the Device window. Select various paths in the Timing Summary Results window and examine the path routing. ![Image of Xilinx Vivado Design Suite interface showing routing examination for timing paths.](image-url) Step 10: Generating a Bitstream File With IOSTANDARD constraints defined for all of the I/O ports, and the logic of the design placed with assigned LOCs, you can generate a bitstream. Before launching Write Bitstream, you will review the settings for this command. 1. In the Flow Navigator, under the Project Manager, select **Settings**. The Settings dialog box opens. 2. Select the Bitstream page. 3. The Bitstream Settings provides you access to the options available for the write_bitstream command. For a complete description of these options and how to use them, see the Vivado Design Suite User Guide: Programming and Debugging (UG908). 4. Click **Cancel** to close the Settings dialog box. 5. In the Flow Navigator, under the Program and Debug section, click **Generate Bitstream**. 6. Click **OK** to launch with the default options and wait for the task to complete. 7. After the bitstream has been generated, click **OK** in the Bitstream Generation Completed dialog box to view the reports from the command. Summary This concludes the tutorial. After completing this tutorial, you should be able to do the following: - Use Project mode and Non-Project mode. - Create an RTL project in Vivado IDE. - Configure and launch the Vivado synthesis, simulation, and implementation tools. - Apply constraints to the synthesized design. - Generate timing and power reports. - Examine routing results in the Device editor. - Generate a bitstream file. - Switch between the Vivado Design Suite Tcl shell and the Vivado IDE. Please Read: Important Legal Notices The information disclosed to you hereunder (the “Materials”) is provided solely for the selection and use of Xilinx products. To the maximum extent permitted by applicable law: (1) Materials are made available “AS IS” and with all faults, Xilinx hereby DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of liability) for any loss or damage of any kind related to, arising under, or in connection with, the Materials (including your use of the Materials), including for any direct, indirect, special, incidental, or consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage suffered as a result of any action brought by a third party) even if such damage or loss was reasonably foreseeable or Xilinx had been advised of the possibility of the same. Xilinx assumes no obligation to correct any errors contained in the Materials or to notify you of updates to the Materials or to product specifications. You may not reproduce, modify, distribute, or publicly display the Materials without prior written consent. Certain products are subject to the terms and conditions of Xilinx’s limited warranty, please refer to Xilinx’s Terms of Sale which can be viewed at http://www.xilinx.com/legal.htm#tos; IP cores may be subject to warranty and support terms contained in a license issued to you by Xilinx. Xilinx products are not designed or intended to be fail-safe or for use in any application requiring fail-safe performance; you assume sole risk and liability for use of Xilinx products in such critical applications, please refer to Xilinx’s Terms of Sale which can be viewed at http://www.xilinx.com/legal.htm#tos. AUTOMOTIVE APPLICATIONS DISCLAIMER AUTOMOTIVE PRODUCTS (IDENTIFIED AS “XA” IN THE PART NUMBER) ARE NOT WARRANTED FOR USE IN THE DEPLOYMENT OF AIRBAGS OR FOR USE IN APPLICATIONS THAT AFFECT CONTROL OF A VEHICLE (“SAFETY APPLICATION”) UNLESS THERE IS A SAFETY CONCEPT OR REDUNDANCY FEATURE CONSISTENT WITH THE ISO 26262 AUTOMOTIVE SAFETY STANDARD (“SAFETY DESIGN”). CUSTOMER SHALL, PRIOR TO USING OR DISTRIBUTING ANY SYSTEMS THAT INCORPORATE PRODUCTS, THOROUGHLY TEST SUCH SYSTEMS FOR SAFETY PURPOSES. USE OF PRODUCTS IN A SAFETY APPLICATION WITHOUT A SAFETY DESIGN IS FULLY AT THE RISK OF CUSTOMER, SUBJECT ONLY TO APPLICABLE LAWS AND REGULATIONS GOVERNING LIMITATIONS ON PRODUCT LIABILITY. © Copyright 2012-2018 Xilinx, Inc. Xilinx, the Xilinx logo, Artix, ISE, Kintex, Spartan, Virtex, Zynq, and other designated brands included herein are trademarks of Xilinx in the United States and other countries. All other trademarks are the property of their respective owners.
{"Source-Url": "https://www.xilinx.com/support/documentation/sw_manuals/xilinx2019_2/ug888-vivado-design-flows-overview-tutorial.pdf", "len_cl100k_base": 12076, "olmocr-version": "0.1.53", "pdf-total-pages": 47, "total-fallback-pages": 0, "total-input-tokens": 84226, "total-output-tokens": 14306, "length": "2e13", "weborganizer": {"__label__adult": 0.0007200241088867188, "__label__art_design": 0.0024261474609375, "__label__crime_law": 0.0003237724304199219, "__label__education_jobs": 0.0031757354736328125, "__label__entertainment": 0.0002865791320800781, "__label__fashion_beauty": 0.0004050731658935547, "__label__finance_business": 0.0006189346313476562, "__label__food_dining": 0.0003862380981445313, "__label__games": 0.0023021697998046875, "__label__hardware": 0.05889892578125, "__label__health": 0.00037288665771484375, "__label__history": 0.0005736351013183594, "__label__home_hobbies": 0.0005583763122558594, "__label__industrial": 0.00429534912109375, "__label__literature": 0.00032806396484375, "__label__politics": 0.0003943443298339844, "__label__religion": 0.00118255615234375, "__label__science_tech": 0.138916015625, "__label__social_life": 0.00011527538299560548, "__label__software": 0.059478759765625, "__label__software_dev": 0.72216796875, "__label__sports_fitness": 0.0004677772521972656, "__label__transportation": 0.0016222000122070312, "__label__travel": 0.00024890899658203125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 57024, 0.01205]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 57024, 0.36106]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 57024, 0.79839]], "google_gemma-3-12b-it_contains_pii": [[0, 115, false], [115, 660, null], [660, 5214, null], [5214, 5214, null], [5214, 7158, null], [7158, 9981, null], [9981, 12411, null], [12411, 14149, null], [14149, 15449, null], [15449, 16257, null], [16257, 18569, null], [18569, 19053, null], [19053, 19954, null], [19954, 20804, null], [20804, 21345, null], [21345, 22710, null], [22710, 24541, null], [24541, 26685, null], [26685, 27867, null], [27867, 28785, null], [28785, 30660, null], [30660, 32028, null], [32028, 32107, null], [32107, 33016, null], [33016, 33919, null], [33919, 34173, null], [34173, 34400, null], [34400, 34516, null], [34516, 36221, null], [36221, 37157, null], [37157, 37617, null], [37617, 38997, null], [38997, 40491, null], [40491, 41624, null], [41624, 42818, null], [42818, 43753, null], [43753, 44588, null], [44588, 45908, null], [45908, 46318, null], [46318, 48063, null], [48063, 48690, null], [48690, 49647, null], [49647, 51888, null], [51888, 52567, null], [52567, 53598, null], [53598, 54104, null], [54104, 57024, null]], "google_gemma-3-12b-it_is_public_document": [[0, 115, true], [115, 660, null], [660, 5214, null], [5214, 5214, null], [5214, 7158, null], [7158, 9981, null], [9981, 12411, null], [12411, 14149, null], [14149, 15449, null], [15449, 16257, null], [16257, 18569, null], [18569, 19053, null], [19053, 19954, null], [19954, 20804, null], [20804, 21345, null], [21345, 22710, null], [22710, 24541, null], [24541, 26685, null], [26685, 27867, null], [27867, 28785, null], [28785, 30660, null], [30660, 32028, null], [32028, 32107, null], [32107, 33016, null], [33016, 33919, null], [33919, 34173, null], [34173, 34400, null], [34400, 34516, null], [34516, 36221, null], [36221, 37157, null], [37157, 37617, null], [37617, 38997, null], [38997, 40491, null], [40491, 41624, null], [41624, 42818, null], [42818, 43753, null], [43753, 44588, null], [44588, 45908, null], [45908, 46318, null], [46318, 48063, null], [48063, 48690, null], [48690, 49647, null], [49647, 51888, null], [51888, 52567, null], [52567, 53598, null], [53598, 54104, null], [54104, 57024, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 57024, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 57024, null]], "pdf_page_numbers": [[0, 115, 1], [115, 660, 2], [660, 5214, 3], [5214, 5214, 4], [5214, 7158, 5], [7158, 9981, 6], [9981, 12411, 7], [12411, 14149, 8], [14149, 15449, 9], [15449, 16257, 10], [16257, 18569, 11], [18569, 19053, 12], [19053, 19954, 13], [19954, 20804, 14], [20804, 21345, 15], [21345, 22710, 16], [22710, 24541, 17], [24541, 26685, 18], [26685, 27867, 19], [27867, 28785, 20], [28785, 30660, 21], [30660, 32028, 22], [32028, 32107, 23], [32107, 33016, 24], [33016, 33919, 25], [33919, 34173, 26], [34173, 34400, 27], [34400, 34516, 28], [34516, 36221, 29], [36221, 37157, 30], [37157, 37617, 31], [37617, 38997, 32], [38997, 40491, 33], [40491, 41624, 34], [41624, 42818, 35], [42818, 43753, 36], [43753, 44588, 37], [44588, 45908, 38], [45908, 46318, 39], [46318, 48063, 40], [48063, 48690, 41], [48690, 49647, 42], [49647, 51888, 43], [51888, 52567, 44], [52567, 53598, 45], [53598, 54104, 46], [54104, 57024, 47]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 57024, 0.01124]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
9d05dda510ef26b2d61a7a7cca6bb92d3f1b3b23
Beyond Singleton Arc Consistency M.R.C. van Dongen 1 Abstract. Shaving algorithms, like singleton arc consistency (SAC), are currently receiving much interest. They remove values which are not part of any solution. This paper proposes an efficient shaving algorithm for enforcing stronger forms of consistency than SAC. The algorithm is based on the notion of weak k-singleton arc consistency, which is equal to SAC if \( k = 1 \) but stronger if \( k > 1 \). This paper defines the notion, explains why it is useful, and presents an algorithm for enforcing it. The algorithm generalises Lecoutre and Cardon’s algorithm for establishing SAC. Used as pre-processor for MAC it improves the solution time for structured problems. When run standalone for \( k > 1 \), it frequently removes more values than SAC at a reasonable time. Our experimental results indicate that at the SAC phase transition, it removes many more values than SAC-1 for \( k = 16 \) in less time. For many problems from the literature the algorithm discovers lucky solutions. Frequently, it returns satisfiable CSPs which it proves inverse consistent if all values participate in a lucky solution. 1 Introduction The notion of local consistency plays an important role in constraint satisfaction, and many such notions have been proposed so far. For the purpose of this paper we restrict our attention to binary Constraint Satisfaction Problems (CSPs). A CSP having variables \( X \) is \((s, t)\)-consistent [6] if any consistent assignment to the \( s \) variables in \( S \) can be extended to some consistent assignment to the \( s + t \) variables in \( S \cup T \), for any sets \( S \subseteq X \) and \( T \subseteq X \backslash S \) such that \( |S| = s \) and \( |T| = t \). Local consistency notions are usually enforced by removing tuples and/or recording nogoods. As \( s \) increases enforcing \((s, t)\)-consistency becomes difficult because it requires identifying and recording \( O((S \cup T)^d_t) = O(n^t d^t) \) nogoods, where \( n \) is the number of variables in the CSP and \( d \) is the maximum domain size. For example, \((2, 1)\)-consistency, also known as path consistency [9], is in the most benign class beyond \( s = 1 \) but it is considered prohibitive in terms of space requirements. The space complexity issues arise with increasing \( s \) are the reason why practical local consistency algorithms keep \( s \) low. Usually, this means setting \( s \) to 1, which means enforcing consistency by removing values from the domains. Shaving algorithms also enforce consistency by removing values from the domains. They fix variable-value assignments and remove values that inference deems inconsistent. They terminate if no values can be removed. A shaving algorithm, which is currently receiving much attention, is singleton arc consistency (SAC) [4; 5; 11; 1; 8]. Another computational complexity source of \((s, t)\)-consistency is the requirement that each consistent assignment to the \( s \) variables in \( S \) be extendable to a consistent assignment to the \( s + t \) variables in \( S \cup T \), for each set \( S \subseteq X \) having Cardinality \( s \) and any set \( T \subseteq X \backslash S \) having Cardinality \( t \). Relaxing this requirement by substituting some for any would make it considerably more easy to enforce the resulting consistency notion, which we call weak \((s, t)\)-consistency. At first glance weak \((s, t)\)-consistency may seem too weak to do useful propagation. However, it has strong advantages: 1. We don’t have to find a consistent extending assignment to the variables of all sets \( T \) of size \( t \). This is especially useful if the problem is already \((s, t)\)-consistent or if \( s \) is small. 2. By cleverly selecting \( T \) we may still find inconsistencies. For example, if there is no consistent assignment to the variables in \( S \cup T \) for the first set \( T \) then the current assignment to the variables in \( S \) cannot be extended. 3. By increasing \( t \) we can enforce levels of consistency which, in a certain sense, are stronger and stronger. This paper proposes to exploit these strengths, proposing an algorithm which switches between enforcing weak and full consistency, taking the best from both worlds. Given a consistent assignment to the variables in \( S \), the algorithms only seek a consistent assignment to \( S \cup T \) for a, cleverly chosen, first set \( T \), for which such consistent assignment is unlikely to exist. Should there be a consistent assignment then the current assignment to \( S \) is weakly consistent and otherwise it is inconsistent. If \( s = 1 \) then this allows us to prune the value that is currently assigned to the variable in \( S \). From now on let \( s = 1 \). We apply the idea of switching between weak and full consistency to \( k\)-singleton arc consistency, which generalises SAC [4; 5; 11; 1; 8]. Here, a CSP, \( P \), is \( k\)-singleton arc consistent (weakly \( k\)-singleton arc consistent) if for each variable \( x \) and each value \( v \) in its domain, the assignment \( x := v \) can be extended by assigning values to each (some) selection of \( k - 1 \) other variables such that \( P \) can be made arc consistent. SAC is equivalent to \( k\)-singleton arc and weak \( k\)-singleton arc consistency if \( k = 1 \) but weaker if \( k > 1 \). Switching between weak and full \( k\)-singleton arc consistency allows us, in a reasonable time, to enforce stronger levels of consistency, which go beyond SAC. Using an algorithm which enforces weak \( k\)-singleton arc consistency as a pre-processor for MAC [12] allows the solution of CSPS which cannot be solved by other known algorithms in a reasonable amount of time. Our algorithm is inspired by Lecoutre and Cardon’s algorithm for enforcing SAC [8]. Like theirs it frequently detects lucky solutions [8] (solutions discovered while enforcing consistency), making search unnecessary for certain --- 1 Cork Constraint Computation Centre (4C). 4C is supported by Science Foundation Ireland under Grant 00/PI.1/C075. satisfiable problems. Going beyond SAC, our algorithm detects certain unsatisfiable problems without search, including problems that can be made SAC. A problem is inverse consistent if all values participate in some solution. Our algorithms make and prove many problems inverse consistent, including (un)modified radio link frequency assignment problems, and forced random binary problems. Sometimes this is done more quickly than it takes SAC-1 to make these problems SAC. We start by recalling definitions of constraint satisfaction, by recalling existing notions of consistency, and by introducing new consistency notions. This includes weak k-singleton arc consistency. Next we describe an algorithm for enforcing it. Finally, we present experimental results and conclusions. 2 Constraint Satisfaction A binary constraint satisfaction problem (CSP), \( \mathcal{P} \), comprises a set of \( n \) variables \( X \), a finite domain \( D(x) \) for each \( x \in X \), and a set of \( e \) binary constraints. The maximum domain size is \( d \). Each constraint is a pair \( (\sigma, \rho) \), where \( \sigma = (x, y) \in X^2 \) is the scope, and \( \rho \subseteq D(x) \times D(y) \) is the relation of the constraint. Without loss of generality we assume that \( x \neq y \) for any scope \( \langle x, y \rangle \). We write \( \mathcal{P} \models \varphi \) if \( \mathcal{P} \) has no empty domains. Let \( \langle \langle x, y \rangle, \rho \rangle \) be a constraint. Then \( v \in D(x) \) and \( w \in D(y) \) are arc consistent if \( \{ v \} \times D(y) \cap \rho \neq \emptyset \) and \( D(x) \times \{ w \} \cap \rho = \emptyset \). The arc consistent equivalent of \( \mathcal{P} \), denoted \( ac(\mathcal{P}) \), is obtained from \( \mathcal{P} \) by repeatedly removing all arc inconsistent values (and, if needed, adjusting constraint relations). The density of \( \mathcal{P} \) is defined \( 2c/(n^2 - n) \). The tightness of constraint \( \langle \langle x, y \rangle, \rho \rangle \) is defined \( |\rho|/|D(x) \times D(y)| \). An assignment is a partial function with domain \( X \). A k-assignment assigns values to \( k \) variables (only). By abuse of notation we write \( \{ x_i = f(x_i), \ldots, x_k = f(x_k) \} \) for k-assignment \( f \). Let \( f = \{ x_1 = v_1, \ldots, x_k = v_k \} \) be a k-assignment. We call \( f \) consistent if \( k = 1 \) and \( v_i \in D(x_i) \) for any \( i \in \{ 1, \ldots, k \} \) or \( k > 1 \) and \( \{ v_i, v_j \} \in \rho \) for each constraint \( \langle \langle x_i, x_j \rangle, \rho \rangle \) such that \( 1 \leq i, j \leq k \). A consistent n-assignment is a solution. \( \mathcal{P} \models \varphi \) is obtained from \( \mathcal{P} \) by substituting \( D(x_i) \cap \{ v_i \} \) for \( D(x_i) \) for all \( i \) such that \( 1 \leq i \leq k \). 3 Consistency Definition 1 ((s,t)-consistency). A CSP with variables \( X \) is \((s,t)\)-consistent if for any variables \( S = \{ x_1, \ldots, x_s \} \subseteq X \) and any variables \( \{ x_{s+1}, \ldots, x_{s+t} \} \subseteq X \setminus S \), any consistent \( s\)-assignment to \( x_1, \ldots, x_s \) is extendable to some consistent \((s+t)\)-assignment to \( x_1, \ldots, x_{s+t} \). Enforcing \((s,t)\)-consistency may require processing (almost) all assignments to all combinations of \( s \) variables and all assignments to all combinations of \( t \) additional variables. As \( s \) and \( t \) become large, enforcing \((s,t)\)-consistency usually results in a large average running time and (generally) requires \( \mathcal{O}(n^d) \) space for recording nogoods. The following relaxes \((s,t)\)-consistency by substituting some for the second occurrence of any in the definition of \((s,t)\)-consistency. Definition 2 (Weak \((s,t)\)-Consistency). A CSP with variables \( X \) is weakly \((s,t)\)-consistent if for any variables \( S = \{ x_1, \ldots, x_s \} \subseteq X \) and some variables \( \{ x_{s+1}, \ldots, x_{s+t} \} \subseteq X \setminus S \), any consistent \( s\)-assignment to \( x_1, \ldots, x_s \) is extendable to some consistent \((s+t)\)-assignment to \( x_1, \ldots, x_{s+t} \). A CSP is inverse \( k\)-consistent if it is \((1, k - 1)\)-consistent. Inverse consistency does not require additional constraints and can be enforced by shaving. A CSP is inverse consistent if it is inverse \( n\)-consistent. It is weakly inverse \( k\)-consistent if it is weakly \((1, k - 1)\)-consistent. Then (weak) inverse \( k\)-consistency implies (weak) inverse \( k\)-consistency if \( K \geq k \). A CSP is called \((k,S)\)-consistent if it is \((k - 1, 1)\)-consistent and it is called arc consistent if it is \( 2\)-consistent. The following formally defines singleton arc consistency. Definition 3 (Singleton Arc Consistency). A CSP, \( \mathcal{P} \), with variables \( X \) is called singleton arc consistent (SAC) if \[ (\forall x_1 \in X)(\forall v_i \in D(x_1)) \left( ac(\mathcal{P}) \models \{ x_1 = v_i \} \right) \] The following seems a natural generalisation of SAC. Definition 4 (k-Singleton Arc Consistency). A CSP \( \mathcal{P} \) with variables \( X \) is called k-singleton arc consistent if \[ (\forall x_1 \in X)(\forall v_i \in D(x_1)) \left( \forall \{ x_2, \ldots, x_k \} \subseteq X \setminus \{ x_1 \} \right) \] \[ (\exists \{ v_2, \ldots, v_k \} \in D(x_2) \times \cdots \times D(x_k)) \left( ac(\mathcal{P}) \models \{ x_1 = v_i \} \right) \] We define weak k-singleton arc consistency (weak k-SAC) by substituting an existential quantifier for the last universal quantifier in Definition 4. Then weak 1-SAC is equivalent to 1-SAC and SAC, and (weak) \( k\)-SAC implies (weak) inverse \( k\)-consistency and (weak) \( k\)-SAC if \( K \geq k \). 4 A Weak \( k\)-SAC Algorithm This section presents our algorithms, which use greedy search to establish a weakly \( k\)-SAC equivalent of the input CSP \( \mathcal{P} \). They exploit that \( ac(\mathcal{P}) \models \{ x_1 = v_1, \ldots, x_k = v_k \} \) implies \( ac(\mathcal{P}) \models \{ x_1 = v_1, \ldots, x_k = v_k \} \) for any \( \{ x_1, \ldots, x_k \} \subseteq \{ x_1, \ldots, x_i \} \). This generalises the SAC algorithms in \([8]\), which use greedy search, exploiting that \( ac(\mathcal{P}) \models \{ x_1 = v_1, \ldots, x_n = v_n \} \) implies \( ac(\mathcal{P}) \models \{ x_1 = v_1, \ldots, x_n = v_n \} \) for any \( \{ x_1, \ldots, x_i \} \subseteq \{ x_1, \ldots, x_i \} \). The algorithms are depicted in Figure 1. The outer \textbf{while} loop of \texttt{wksac} is executed while there are changes, while there is no inconsistency, and while no lucky solution has been found. (Removing the statement \texttt{solved := true in extendable} prohibits finding lucky solutions.) The second outer \textbf{while} loop selects the next variable, \( x \). The inner-most \textbf{while} loop removes singleton inconsistent values. For any remaining value, \( v \), \texttt{wksac} tries to extend the assignment \( x = v \), to some \( K\)-SAC assignment, for some \( K \geq k \) by executing \texttt{extendable}(\( k - 1 \), \texttt{wksac}, \( X \setminus \{ x \} \)). If this fails then \( x \) is removed. The underlying arc consistency algorithm is \texttt{ac}. Like SAC3 and SAC3+ [\(8\)] extendable also searches for assignments of length greater than \( k \). This allows the discovery of lucky solutions [\(8\)] as part of consistency processing. If it finds a \( k\)-SAC assignment then \texttt{extendable} allows no digressions when trying to find an extending \( K\)-SAC assignment, for \( K > k \). This can be generalised to more digressions. The space complexity of \texttt{wksac} is equal to the space complexity of \texttt{MAC} plus the space required for storing the array \texttt{wksac}[\( \cdot \cdot \cdot \)]. The space complexity of \texttt{wksac}[\( \cdot \cdot \cdot \)] is \( \mathcal{O}(n^d) \), which cannot exceed the space complexity of \texttt{MAC}. Therefore, the space complexity of \texttt{wksac} is equal to the space complexity of \texttt{MAC}. The outer loop of \texttt{wksac} is executed \( \mathcal{O}(n^d) \) times. For each of the $O(n\,d)$ values, finding an extending $k$-SAC assignment takes $O(d^{k-1}\,T)$ time, where $T$ is the time complexity of $ac$. For each $k$-SAC assignment it takes $O((n-k)\,T)$ time for trying to find a lucky solution. Therefore, $ac$'s time complexity is $O(n^3\,d^{k+2}\,T + (n-k)\,n^2\,d^2\,T)$. Termination and correctness proofs are straightforward. The following two propositions provide the basis for a correctness proof. Proofs are omitted due to space restrictions. **Proposition 1.** If extendable($k-1$, $wksac$, solved, $X \setminus \{x\}$) succeeds then the assignment $x = v$ extends to a $k$-SAC assignment, for some $K \geq k$. Otherwise $x = v$ is inconsistent. **Proposition 2.** If $wksac(k, X)$ succeeds then it computes a solution or some weakly $k$-SAC equivalent of the input CSP. If it fails then the input CSP is unsatisfiable. --- **function** $wksac(k, \text{in} \ \text{X})$ do local variables consistent, change, solved; consistent := ac(); change := true; solved := false; while consistent and change and ~solved do foreach value $v$ in the domain of each variable $x$ do wksac[$x$,$v$] := false; enddo; change := false; vars := X; while consistent and ~change and ~solved and vars $\neq \emptyset$ do Select and remove any variable $x$ from vars; vals := \{$v \in D(x) : wksac[x, v]$\}; while vals $\neq \emptyset$ and consistent and ~change do Select and remove any $v$ from vals; assign $v$ to $x$; if ac() and extendable($k-1$, $wksac$, solved, $X \setminus \{x\}$) then wksac[$x$,$v$] := true; else remove $v$ from D($x$); change := true; undo ac(); unassign $v$; consistent := ac(); fi; fi; od; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; do; domeasub [3] is good for our algorithms. This heuristic uses the current degrees and the numbers of previously failed revisions, selecting a variable that quickly leads to a dead-end [3]. queen problems $wksac$ is removing more values as $k$ increases, but for $k = 16$ it needs too much time. For these structured problems the new algorithms are about as efficient as SAC-1 for $k = 1$, if not better. All unsatisfiable modified $rlfap$ instances (the unsatisfiable unmodified instances are proved inconsistent by arc consistency) are proved inconsistent by $wksac$ for $k > 8$, whereas SAC-1 fails to prove some of these instances inconsistent. Note that instance scen11-f1 is very difficult and, to the best of our knowledge, has not been classified; days of MAC search could not solve it. However, enforcing weak 8-SAC proves it inconsistent within an hour. Finally, some satisfiable problems (they are not all listed in Table 1) are made and proved inverse consistent within a few seconds. Here a problem is proved inverse consistent if all values participate to some lucky solution. For example, scen2 is proved to be already inverse consistent, $graph2$, scen3, scen4, and scen5 are made and proved inverse consistent by making them weak $k$-SAC ($k \geq 1$), and all fifteen instances from the classes $frb=30-15$, $frb=35-17$, and $frb=40-19$ are made and proved inverse consistent by making them weakly $k$-SAC for $k = 8$ or $k = 16$. **Shaving Random Problems** We now study the behaviour of the algorithms for random B problems [7]. A model B class is typically denoted $(n, d, D, T)$, where $n$ is the number of variables, $d$ is the uniform domain size, $D$ is the density, and $T$ is the uniform tightness. Results are presented for the same class of problems as presented in [1; 8]. For each tightness $t = 0.05i$, $2 \leq i \leq 18$, the average shaving time is over 50 random instances from $(100, 20, 0.05, t)$. Figure 3 does not depict all data. For $T \leq 0.50$ all algorithms remove less than 0.06, and for $T > 0.8$ they remove about 1989.6 values on average. Figure 3 confirms that SAC and weak 1-SAC are equivalent. Comparing SAC-1 and $visac$ in Figure 2, $visac$ is better in time when $T$ is small and large. However, near the SAC complexity peak SAC-1 is about three times quicker than $visac$. The majority of the problems in that region are unsatisfiable and most values are SAC. Typically, SAC-1 will find that a value is SAC and stop. The extra work put in by $visac$ in trying to find a lucky solution will fail at a shallow level. This work cannot do pruning and does not lead to many values that were not known to be SAC. The weak $k$-SAC algorithms only behave differently near the SAC phase transition. The higher $k$ the more values are removed. At $T = 0.7$, the nearest point to the SAC phase transition, it is observed that weak16sac outperforms SAC-1 marginally in time and significantly in the number of removed values. At $T = 0.65$ w1sac removes about 114.2 values on average, whereas all other algorithms remove between 2 and 3 values on average. However, w1sac spends (much) more time. Clearly the algorithms cannot be compared in time at $T = 0.65$. **Search** We now compare the algorithms as a preprocessor for MAC. The first solver is MAC, denoted mac, the second is $sac+mac$, which is SAC-1 followed by MAC, and the third and fourth solvers are $visac+mac$ and $wksac+mac$, i.e. $wksac$ for enforcing weak $k$-singleton arc consistency followed by MAC, for $k \in \{1, 8\}$. All solvers used the variable ordering dom/wdom [3] and the value ordering $svbb2$ [10], breaking ties lexically. The support counters [10] for the value ordering are initialised after establishing initial arc consistency. Should $wksac$ prune more values, then they are also initialised before search. Table 2 lists the results. The column sat denotes the satisfiability of the instances. A + and an L indicates satisfiable instances, the L indicating the discovery of lucky solutions. For all problems, if lucky solutions are found by $visac+mac$ then they are also found by $wksac+mac$ and vice versa. Overall, and these results are typical for these problems, $sac+mac$ performs worse in time and checks than $visac+mac$. MAC performs better than $sac+mac$ for some instances, especially some $graph$ instances, otherwise the two algorithms are about equally efficient. Compared to $visac+mac$ and $wksac+mac$ it is clear that $sac+mac$ is worse in time and checks. Compared to MAC the results are not so clear but overall $visac+mac$ and $wksac+mac$ are better. The only exceptions are for "easy" problems, for which MAC is easy. For these problems there is no need to establish more consistency before search and this results in slightly more solution time. We have also observed this for unsatisfiable problem instances where MAC alone is sufficient to detect the inconsistency. For example, for the queens-knight problems $q1k$ [2] SAC-1 is more efficient than the weak SAC algorithms. However, these problems are relatively easy and do not require much time, even with $wksac$. For the problems that are difficult for MAC and $sac+mac$ the two need a considerable amount of time more than $wksac$. It is recalled that it turned out impossible to compute the weak $k$-SAC equivalent of the job-shop instances for $k = 8$ and $k = 16$. However, when the algorithms are used to find solutions, they perform much better and find lucky solutions. Lucky solutions are also found for all satisfiable $rlfap$, and all satisfiable modified r1fap instances, including instances from these classes for which no results are presented in Table 1. It is interesting to note that if lucky solutions are found, it takes the same amount of checks for $k = 8$ and $k = 16$. This may indicate that both algorithms carry out exactly the same decisions about value and variable ordering. If this is true, then it is probably because these problems are loose, making any arc consistent 1-assignment, easily extendable to an arc consistent k-assignment for $k \geq 8$, which makes it impossible to prune more for v8sac than for visac. Table 2. Problem solving capabilities of search algorithms. <table> <thead> <tr> <th>Problem</th> <th>SAC</th> <th>MAC</th> <th>Heuristics</th> <th>WKSAC</th> </tr> </thead> <tbody> <tr> <td>scen1-f8</td> <td>-0.36</td> <td>0.38</td> <td>0.38</td> <td>-0.36</td> </tr> <tr> <td>scen1-f9</td> <td>0.31</td> <td>1.23</td> <td>1.23</td> <td>0.31</td> </tr> <tr> <td>scen2-f24</td> <td>-0.16</td> <td>1.97</td> <td>1.97</td> <td>-0.16</td> </tr> <tr> <td>scen2-f25</td> <td>-0.16</td> <td>1.97</td> <td>1.97</td> <td>-0.16</td> </tr> <tr> <td>scen5</td> <td>0.13</td> <td>1.52</td> <td>1.52</td> <td>0.13</td> </tr> <tr> <td>scen6-w1</td> <td>-0.84</td> <td>1.74</td> <td>1.74</td> <td>-0.84</td> </tr> <tr> <td>scen6-w1-f2</td> <td>0.04</td> <td>0.45</td> <td>0.45</td> <td>0.04</td> </tr> <tr> <td>scen6-w1-f3</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen6-w2</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w1-f4</td> <td>0.04</td> <td>0.45</td> <td>0.45</td> <td>0.04</td> </tr> <tr> <td>scen7-w1-f5</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w1-f6</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w2-f1</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w2-f2</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w2-f3</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w2-f4</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w2-f5</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w2-f6</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w3-f1</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w3-f2</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w3-f3</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w3-f4</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w3-f5</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> <tr> <td>scen7-w3-f6</td> <td>0.03</td> <td>0.45</td> <td>0.45</td> <td>0.03</td> </tr> </tbody> </table> 6 Conclusions This paper introduces k-singleton consistency (k-SAC) and weak k-SAC, which are generalisations of SAC and inverse k-consistency. Weak k-SAC is equal to SAC if $k = 1$ but stronger if $k > 1$. A weak k-SAC algorithm is presented, which uses greedy search. At the SAC phase transition, it removes many more values than SAC-1 for $k = 16$ using less time. Figure 2. Shaving time for random B class $(100, 20, 0.05, t)$ for different algorithms, where $0.1 \leq T \leq 0.9$. Figure 3. Number of shaved values for random B class $(100, 20, 0.05, t)$ for different algorithms, where $0.5 \leq T \leq 0.8$. REFERENCES
{"Source-Url": "http://cse.unl.edu/~choueiry/Documents/vanDongen-ECAI06-SAC.pdf", "len_cl100k_base": 9040, "olmocr-version": "0.1.53", "pdf-total-pages": 5, "total-fallback-pages": 0, "total-input-tokens": 24007, "total-output-tokens": 10021, "length": "2e13", "weborganizer": {"__label__adult": 0.0004949569702148438, "__label__art_design": 0.0005612373352050781, "__label__crime_law": 0.0009250640869140624, "__label__education_jobs": 0.0010881423950195312, "__label__entertainment": 0.00017499923706054688, "__label__fashion_beauty": 0.0002932548522949219, "__label__finance_business": 0.0006341934204101562, "__label__food_dining": 0.0006322860717773438, "__label__games": 0.0014886856079101562, "__label__hardware": 0.0015554428100585938, "__label__health": 0.0015115737915039062, "__label__history": 0.0005507469177246094, "__label__home_hobbies": 0.00021541118621826172, "__label__industrial": 0.0012502670288085938, "__label__literature": 0.0004777908325195313, "__label__politics": 0.0005793571472167969, "__label__religion": 0.0008306503295898438, "__label__science_tech": 0.450927734375, "__label__social_life": 0.00015747547149658203, "__label__software": 0.0087890625, "__label__software_dev": 0.52490234375, "__label__sports_fitness": 0.0005154609680175781, "__label__transportation": 0.0009908676147460938, "__label__travel": 0.0002875328063964844}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 30104, 0.00867]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 30104, 0.44197]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 30104, 0.77974]], "google_gemma-3-12b-it_contains_pii": [[0, 6127, false], [6127, 14245, null], [14245, 19284, null], [19284, 24656, null], [24656, 30104, null]], "google_gemma-3-12b-it_is_public_document": [[0, 6127, true], [6127, 14245, null], [14245, 19284, null], [19284, 24656, null], [24656, 30104, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 30104, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 30104, null]], "pdf_page_numbers": [[0, 6127, 1], [6127, 14245, 2], [14245, 19284, 3], [19284, 24656, 4], [24656, 30104, 5]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 30104, 0.02796]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
d27d215cea40d5ee6e134b1fe8c2aa8c6bcf34ad
Generalities Implementation strategies System OML Qualified types Type classes Design space Modularity, *Surcharge* *MPRI* course 2-4-2, Part 3, Lesson 2 Didier Rémy INRIA-Rocquencourt Janvier 27, 2009 <table> <thead> <tr> <th>Generalities</th> <th>Implementation</th> <th>OML</th> <th>Qualified types</th> <th>Type classes</th> <th>Design space</th> </tr> </thead> <tbody> <tr> <td>Generalities</td> <td>Implementation strategies</td> <td>System OML</td> <td>Qualified types</td> <td>Type classes</td> <td>Design space</td> </tr> </tbody> </table> **Didier Rémy** (INRIA-Rocquencourt) Overloading Naming convenience Avoid suffixing similar names by type information: printing functions; numerical operations (e.g. `plus_int`, `plus_float`, ...); numerical values? Type dependent functions or ad hoc polymorphism A function defined on $\tau[\alpha]$ for all $\alpha$ may have an implementation depending on the type of $\alpha$. For instance, a marshaling function of type $\forall \alpha. \alpha \rightarrow \text{string}$ may execute different code for each base type $\alpha$. These definitions may be ad hoc (unrelated for each type), or polytypic, i.e. depending solely on the type structure (is it a sum, a product, etc.) and thus derived mechanically for all types from the base cases. A typical example of a polytypic function is the generation of random values for arbitrary types, e.g. as used in Quickcheck for Haskell. Overloading Common to all forms of overloading - At some program point (static context), an overloaded symbol $u$ has several visible definitions $a_1, \ldots, a_n$. - In a given runtime of the program, only one of them will be used. Determining which one should be used is called *overloading resolution*. Many variants of overloading - How is overloading resolved? (see next slide) - Is resolution done up to subtyping? - Are overloading definitions primitive, automatic, or user-definable? - What are the restrictions in the way definitions can be combined? - Can the definitions overlap? (Then, how is overlapping resolved) - Can overloading be on the return type? - Can overloading definitions have a local scope? Overloading Static resolution (rather simple) - If every overloaded symbol can be statically replaced by its implementation at the appropriate type. - This does not increase expressiveness, but may reduce verbosity. Dynamic resolution (more involved) - Pass types at runtime and dispatch on the runtime type (typecase). - Pass the appropriate implementations at runtime as extra arguments, eventually grouped in dictionaries. (Alternatively, one may pass runtime information that designates the appropriate implementation in a global structure.) - Tag values with their types—or an approximation of their types—and dispatch on the tags of values. In SML Definitions are primitive (numerical operators, record accesses). Typechecking fails if overloading cannot be resolved at outermost let-definitions. For example, let $\text{twice } x = x + x$ is rejected in SML, at toplevel as $+$ could be the addition on either integers or floats. In Java Overloading **In SML** Definitions are primitive (numerical operators, record accesses). Typechecking fails if overloading cannot be resolved at outermost let-definitions. For example, `let twice x = x + x` is rejected in SML, at toplevel as `+` could be the addition on either integers or floats. **In Java** Overloading is not primitive but automatically generated by subtyping. When a class extends another one and a method is redefined, the older definition is still visible, hence the method is overloaded. Overloading is resolved at compile time by choosing the most specific definition. There is always a best choice—according to current knowledge. An argument may have a runtime type that is a subtype of the best known compile-time type, and perhaps a more specific definition could have been used if overloading were resolved dynamically. Limits Static overloading does not fit well with first-class functions and polymorphism. Indeed, functions such as $\lambda(x) \times + x$ are rejected and must therefore be manually specialized at every type for which $+$ is defined. This argues in favor of some form of dynamic overloading that allows to delay resolution of overloaded symbols at least until polymorphic functions have been sufficiently specialized. Runtime type dispatch - Use an explicitly typed calculus (i.e. Church style System F) - Add a typecase function. - Type matching may be expensive, unless type patterns are restricted. - By default one pays even when overloading is not used. - Monomorphization may be used to reduce type matching statically. - Ensuring exhaustiveness of type matching is difficult. ML& (Castagna) - System F + intersection types + subtyping + type matching - An expressive type system: it keeps track of exhaustiveness; type matching functions as first-class and can be extended or overriden. - Best match resolution strategy. Overloading Pass unresolved implementations as extra arguments - Abstract over unresolved overloaded symbols and pass them later when they can be resolved. In short, let $f = \lambda(x) \ x + x$ can be elaborated into let $f = \lambda(+) \ \lambda(x) \ x + x$ and its application to a float $f \ 1.0$ elaborated into $f \ (+.) \ 1.0$. - This can be done based on the typing derivation. - After elaboration, types may be erased (Curry’s style System F) - Monomorphisation or other simplifications may reduce the number of abstractions and applications introduced by overloading resolution. Generalities Implementation strategies System OML Qualified types Type classes Design space Dynamic overloading Untyped code ``` let rec plus = (+) and plus = (lor) and plus = λ(x, y) λ(x′, y′) (plus x x′, plus y y′) in let twice = λ(x) plus x x in twice (1, true) ``` It should indeed evaluate to \((1 + 1, \text{true lor true})\), i.e. \((2, \text{true})\), whatever the implementation strategy. Church style System F with type matching Syntax \[ \begin{align*} a & ::= a \mid \lambda(x)\ a \mid a\ (a) \mid \Lambda(\alpha)\ a \mid a\ (\tau) \\ & \mid \text{match } \tau \text{ with } \langle \pi_1 \Rightarrow a_1 \ldots \mid \pi_n \Rightarrow a_n \rangle \\ \pi & ::= \tau \mid \exists(\alpha)\pi \end{align*} \] System F Typecase Typing rules: as in System F, plus... \[ \begin{align*} \Gamma \vdash \tau & \quad \Gamma, \bar{\alpha}_i \vdash \tau_i \\ \Gamma, \bar{\alpha}_i \vdash a_i : \tau' \\ \Gamma \vdash \text{match } \tau \text{ with } \langle \pi_1 \Rightarrow a_1 \ldots \mid \exists(\bar{\alpha}_i)\tau_i \Rightarrow a_i \ldots \mid \pi_n \Rightarrow a_n \rangle \leadsto a_i[\bar{\tau}_i/\bar{\alpha}_i] \end{align*} \] Church style System F with type matching Soundness for System F with type matching. - Subject-reduction holds - Progress does not hold in the simplest version: the type system cannot ensure exhaustiveness of type matching. - Solutions: - add a default case, with a construction, such as \[ \text{match } s \text{ with } \langle \pi \Rightarrow a \mid a \rangle \] - use a richer type system that ensures exhaustiveness. What to do with overlapping definitions? - Let the reduction be nondeterministic. - Restrict typechecking to disallow overlapping definitions. - Change the semantics to give priority to the first match, or to the best match (the most precise matching pattern). Overloading with typecase Exhaustiveness is not enforced let rec plus = Λ(α) match α with ⟨ | int ⇒ (+) | bool ⇒ (lor) | ∃(β, γ) β × γ ⇒ λ(x, y : β × γ) λ(x', y' : β × γ) plus β × x', plus γ y y' ⟩ in let twice = Λ(α) λ(x : α) plus α x x in twice (int × bool) (1, true) Overloading with typecase The domain may be restricted by a type constraint ``` let rec plus = Λ(α<Plus α>) match α with ⟨ | int ⇒ (+) | bool ⇒ (lor) | ∃(β<Plus β>, γ<Plus γ>) β × γ ⇒ λ(x, y : β × γ) λ(x', y' : β × γ) plus β x x', plus γ y y' ⟩ in let twice = Λ(α<Plus α>) λ(x : α) plus α x x in twice (int × bool) (1, true) ``` Overloading with typecase The type predicate $Plus \alpha$ is defined by induction $Plus \ int; \ Plus \ bool; $Plus \ \alpha \Rightarrow Plus \ \beta \Rightarrow Plus \ (\alpha \times \beta)$ let rec $plus =$ $\Lambda(\alpha \langle Plus \ \alpha \rangle)$ match $\alpha$ with \\ | int $\Rightarrow$ (+) \\ | bool $\Rightarrow$ (lor) \\ | $\exists(\beta \langle Plus \ \beta \rangle, \ \gamma \langle Plus \ \gamma \rangle) \ \beta \times \gamma \Rightarrow$ \\ | $\lambda(x, y : \beta \times \gamma) \ \lambda(x', y' : \beta \times \gamma) \ plus \ \beta \times x', \ plus \ \gamma \ y \ y'$ \\ in let $twice =$ $\Lambda(\alpha \langle Plus \ \alpha \rangle) \ \lambda(x : \alpha) \ plus \ \alpha \times x \ \times \ \in$ $twice \ (int \times bool) \ (1, \ true)$ Checking for satisfiability Overloaded declarations are restricted forms of horn clauses. For instance, the context $\Gamma$ equal to $$\text{Plus int;} \quad \text{Plus bool;} \quad \text{Plus } \alpha \Rightarrow \text{Plus } \beta \Rightarrow \text{Plus } (\alpha \times \beta)$$ can be read as deduction rules: \[ \text{PlusInt}\quad \text{PlusBool}\quad \text{PlusProd} \] \[ \begin{align*} \text{Plus int} & \quad \text{Plus bool} \\ \text{Plus } (\alpha \times \beta) & \\ \end{align*} \] We can build (infer) the following derivation: \[ \text{PlusProd}\quad \text{PlusInt} \quad \text{PlusBool} \] \[ \begin{align*} \text{Plus int} & \quad \text{Plus bool} \\ \text{Plus } (int \times bool) & \\ \end{align*} \] which can be concisely represented as the proof term on the right. Dictionary passing In fact, \( \text{Plus} \ (\text{int} \times \text{bool}) \) proves that \( \text{plus} \) is defined for type \( \text{int} \times \text{bool} \). Partially applying \( \text{plus} \) to \( \text{int} \times \text{bool} \), and reducing it, we get: \[ \text{plus} \ (\text{int} \times \text{bool}) \leadsto \\ \lambda(x, y : \text{int} \times \text{bool}) \lambda(x', y' : \text{int} \times \text{bool}) \text{plus int y, plus bool x' y'} \leadsto \\ \lambda(x, y : \text{int} \times \text{bool}) \lambda(x', y' : \text{int} \times \text{bool}) (\mathbb{+}) x y, (\mathbb{lor}) x' y' \] Unfortunately, this reduction duplicates code. Instead, we abstract each definition of \( \text{plus} \) over the types it depends on types: If \( \text{plus} \exists(\beta, \gamma)\beta \times \gamma \) is \[ \lambda(\beta) \lambda(\gamma) \lambda(\text{plus}_\beta : \beta \to \beta \to \beta) \lambda(\text{plus}_\gamma : \gamma \to \gamma \to \gamma) \\ \lambda(x, y : \beta \times \gamma) \lambda(x', y' : \beta \times \gamma) \text{plus}_\beta x y, \text{plus}_\gamma x' y' \] then the last branch of the type case is equal to \[ \text{plus} \exists(\beta, \gamma)\beta \times \gamma \beta \gamma \ (\text{plus } \beta) \ (\text{plus } \gamma) \] and is \[ \text{plus} \ (\text{int} \times \text{bool}) \leadsto \text{plus} \exists(\beta, \gamma)\beta \times \gamma \text{ int bool } \ (\text{plus } \text{int}) \ (\text{plus } \text{bool}) \] built by passing arguments to existing functions, without code duplication. Dictionary passing ```ocaml let rec plus_int = (+) and plus_bool = (lor) and plus βγ.β×γ = Λ(β) Λ(γ) λ(plusβ : β → β → β) λ(plusγ : γ → γ → γ) λ(x : β) λ(y : γ) plusβ x, plusγ y in let twice = Λ(α) λ(plusα : α → α → α) λ(x : α) plusα x x in let plus_int×bool = plus βγ.β×γ int bool plus_int plus_bool in twice plus_int×bool (1, true) ``` - Overloaded implementations and definitions are abstracted over unresolved overloaded symbols; - Derived implementations are built on demand after type inference. Dictionary passing ```ocaml let plus_int = (+) in let plus_bool = (lor) in let plus βγ.β×γ = Λ(β) Λ(γ) λ(plusβ : β → β → β) λ(plusγ : γ → γ → γ) λ(x : β) λ(y : γ) plusβ x, plusγ y in let twice = Λ(α) λ(plusα : α → α → α) λ(x : α) plusα x x in let plus_int×bool = plus βγ.β×γ int bool plus_int plus_bool in ``` - overloaded implementations and definitions are abstracted over unresolved overloaded symbols; - derived implementations are built on demand after type inference. Dictionary passing After type inference, before translation ```plaintext def Plus α = plus : α → α → α in let rec plus: int → int → int = (+) and plus: bool → bool → bool = (lor) and plus: ∀β⟨Plus β⟩ ∀γ⟨Plus γ⟩ (β × γ) → (β × γ) → (β × γ) = Λ(β⟨Plus β⟩) Λ(γ⟨Plus γ⟩) λ(x, y : β × γ) λ(x', y' : β × γ) plus β × x', plus γ y y' in let twice = Λ(α⟨Plus α⟩) λ(x : α) plus α x x in twice (int × bool) (1, true) ``` Alternatively, inlining the constraint (running code) ``` let rec plus: int → int → int = (+) and plus: bool → bool → bool = (lor) and plus: ∀β⟨plus : β → β → β⟩ ∀γ⟨plus : γ → γ → γ⟩ (β × γ) → (β × γ) → (β × γ) = Λ(β⟨plus : β → β → β⟩) Λ(γ⟨plus : γ → γ → γ⟩) λ(x, y : β × γ) λ(x′, y′ : β × γ) plus β × x′, plus γ y y′ in let twice = Λ(α⟨plus : α → α → α⟩) λ(x : α) plus α × x in twice plus(int × bool) (1, true) ``` Alternatively, inlining the constraint (source code) \[ \begin{align*} \text{let rec } & \text{plus: int } \rightarrow \text{ int } \rightarrow \text{ int } = (+) \\ & \text{and plus: bool } \rightarrow \text{ bool } \rightarrow \text{ bool } = (\text{lor}) \\ & \text{and plus: } \forall \beta \langle \text{plus : } \beta \rightarrow \beta \rightarrow \beta \rangle \ \forall \gamma \langle \text{plus : } \gamma \rightarrow \gamma \rightarrow \gamma \rangle \\ & \quad (\beta \times \gamma) \rightarrow (\beta \times \gamma) \rightarrow (\beta \times \gamma) = \\ & \quad \lambda(x, y) \ \lambda(x', y') \quad \text{plus } \ x \ x', \ plus \ y \ y' \ \text{in} \\ \text{let twice } = \\ & \quad \lambda(x) \quad \text{plus } \ x \ x \ \text{in} \\ \text{twice } & \text{ (1, true)} \end{align*} \] Generalities Implementation strategies System \textbf{OML} Qualified types Type classes Design space System **OML** A restrictive form of overloading **Short description** - System **OML** is a simple but monolithic system for overloading - Its specification is concise. - It is not a framework, i.e. everything is hard-wired in the design. - Non overlapping definitions, hence (quasi)-untyped semantics and principal types. - Single argument resolution. - Dictionary passing semantics. - Overloaded definitions need not have a common type scheme. e.g. one may overload $u : \text{int} \rightarrow \text{bool}$ and $u : \text{string} \rightarrow \text{int} \rightarrow \text{int}$ See Odersky et al. (1995) System OML \[\begin{align*} z & ::= \ x \mid u \\ v & ::= \ z \mid \lambda(x) \ a \\ a & ::= \ v \mid a \ a \mid \text{let } x = a \ \text{in } a \\ p & ::= \ a \mid \text{def } u : \sigma = v \ \text{in } p \end{align*}\] Symbols Value forms Expressions Overloaded definitions - We distinguish overloaded symbols \( u \) from other variables. - Expressions are as usual, but a program \( p \) starts with a sequence of toplevel overloaded definitions: \[ \text{def } u_1 : s_1 = v_1 \ \text{in } \ldots \ \text{def } u_n : s_n = v_n \ \text{in } a \] which should be understood as if recursively defined: \[ \text{let rec } u_1 : s_1 = v_1 \ \text{and } \ldots \ u_n : s_n = v_n \ \text{in } a \] The notation reflects more the way they will be compiled, by abstracting over all unresolved overloaded symbols. - Only values can be overloaded. **System OML** ### Types \[ \tau ::= \alpha \mid \tau \rightarrow \tau \mid c(\bar{\tau}) \] \[ \rho_\alpha ::= \emptyset \mid u : \alpha \rightarrow \tau ; \rho_\alpha \] \[ \sigma ::= \tau \mid \forall \alpha \langle \rho_\alpha \rangle \sigma \] ### Comments - Types are as in ML. However, each polymorphic variable of a type scheme is restricted by a (possibly empty) constraint. - Type constraints \( \rho_\alpha \) are record-like types whose labels are distinct overloaded symbols. Intuitively, a constraint for \( \alpha \) specifies the types of overloaded symbols that can be applied to a value of type \( \alpha \). - When \( \rho_\alpha \) is empty, we recover ML type schemes. System OML Overloaded definitions Type schemes of overloaded definitions They must be closed and of the form $\sigma_c$ $$\forall \alpha_1 \langle \rho_{\alpha_1} \rangle \ldots \forall \alpha_n \langle \rho_{\alpha_n} \rangle \ c(\bar{\alpha}_1' \ldots \alpha_2') \rightarrow \tau$$ where $\alpha'_1 \ldots \alpha'_n$ is a permutation of $\alpha_1 \ldots \alpha_n$. Important - The choice of an overloaded definition is fully determined by the topmost constructor of the first argument. - This helps having principal types and a deterministic semantics. - This also facilitates overloading resolution and coverage checking. System OML Typing contexts \[ \Gamma ::= \ z : \sigma \mid u : \sigma \] The typing relation \[ \Gamma \vdash a : \sigma \] Contain ML typing rules \textsc{Var} \begin{align*} \text{z} : \sigma & \in \Gamma \\ \hline \Gamma \vdash \text{z} : \sigma \end{align*} \textsc{Let} \begin{align*} \Gamma & \vdash a : \sigma \\ \Gamma, x : \sigma & \vdash a' : \tau \\ \hline \Gamma & \vdash \text{let } x = a \text{ in } a' : \tau \end{align*} \textsc{Arrow-Intro} \begin{align*} x & \notin \Gamma \\ \Gamma, x : \tau & \vdash a : \tau' \\ \hline \Gamma & \vdash \lambda(x) a : \tau \rightarrow \tau' \end{align*} \textsc{Arrow-Elim} \begin{align*} \Gamma & \vdash a_1 : \tau_2 \rightarrow \tau_2 \\ \Gamma & \vdash a_2 : \tau_2 \\ \hline \Gamma & \vdash a_2 \ a_1 : \tau_1 \end{align*} System OML Overloaded definitions \[ \begin{align*} \text{DEF} & \quad \Gamma \vdash u \not\# \sigma_\pi \\ & \quad \Gamma \vdash a : \sigma_\pi \\ & \quad \Gamma, u : \sigma_\pi \vdash p : \sigma \\ \hline & \quad \Gamma \vdash \text{def } u : \sigma_\pi = a \text{ in } p : \sigma \end{align*} \] We write \( \Gamma \vdash u \not\# \sigma_\pi \) to mean that for all \( u : \sigma' \in \Gamma \), \( \sigma' \) and \( \sigma_\pi \) have different topmost type constructors. This implies, in particular, that overloading definitions of \( \Gamma \) are never overlapping. Introduction and elimination of polymorphism \[ \text{All-Intro} \] \[ \Gamma, \rho_\alpha \vdash v : \sigma \\ \hline \Gamma \vdash \forall \alpha \langle \rho_\alpha \rangle \sigma \] \[ \text{All-Elim} \] \[ \Gamma \vdash \forall \alpha \langle \rho_\alpha \rangle \sigma \\ \Gamma \vdash \rho_\alpha [\tau/\alpha] \\ \hline \Gamma \vdash a : \sigma[\tau/\alpha] \] As in ML, we restrict generalization to value forms. Overloaded symbols Overloaded symbols are introduced in \( \Gamma \) by rules Def or All-Intro. They can be retrieved by rule Var and used directly, or indirectly via rule All-Elim. An example of typing is given below together with the translation to ML. System OML Compilation to ML Judgment $\Gamma \vdash p : \sigma \triangleright M$ We compile a program $p$ into an ML expression $M$ (which is also an OML expression) based on the typing derivation. The definition of the translation is by an instrumenting the typing rules. Easy cases **VAR** \[ \frac{z : \sigma \in \Gamma}{\Gamma \vdash x : \sigma \triangleright x}\] **LET** \[ \frac{\Gamma \vdash a : \sigma \triangleright M \quad \Gamma, x : \sigma \vdash a' : \tau \triangleright M'}{\Gamma \vdash \text{let } x = a \text{ in } a' : \tau \triangleright \text{let } x = M \text{ in } M'}\] **Arrow-Intro** \[ \frac{x \notin \Gamma \quad \Gamma, x : \tau \vdash a : \tau' \triangleright M}{\Gamma \vdash \lambda(x) \ a : \tau \rightarrow \tau' \triangleright \lambda(x) \ M}\] **Arrow-Elim** \[ \frac{\Gamma \vdash a_1 : \tau_2 \rightarrow \tau_1 \triangleright M_1 \quad \Gamma \vdash a_2 : \tau_2 \triangleright M_2}{\Gamma \vdash a_1 \ a_2 : \tau_1 \triangleright M_1 \ M_2}\] Introducing and using overloaded definitions \[ \text{DEF} \] \[ \Gamma \vdash u \# \sigma_{\pi} \\ \Gamma \vdash a : \sigma_{\pi} \triangleright M_{\pi} \\ \Gamma, u : \sigma_{\pi} \vdash p : \sigma \triangleright M \\ \Gamma \vdash \text{def } u : \sigma_{\pi} = a \text{ in } p : \sigma \triangleright \text{let } x_{\sigma_{\pi}}^{u} = M_{\pi} \text{ in } M \] \[ \text{VAR-OVER} \] \[ \Gamma \vdash u : \sigma \in \Gamma \\ \Gamma \vdash u : \sigma \triangleright x_{\sigma}^{u} \] Introducing and using polymorphism \[ \text{ALL-INTRO} \] \[ \Gamma, u_{1} : \tau_{1}, \ldots, u_{n} : \tau_{n} \vdash a : \sigma \triangleright M \quad \alpha \notin \Gamma \\ \Gamma \vdash \forall \alpha \langle u_{1} : \tau_{1}, \ldots, u_{n} : \tau_{n} \rangle \sigma \triangleright \lambda(x_{\tau_{1}}^{u_{1}}) \ldots \lambda(x_{\tau_{n}}^{u_{n}}) M \] \[ \text{ALL-ELIM} \] \[ \Gamma \vdash a : \forall \alpha \langle u_{1} : \tau_{1}, \ldots, u_{n} : \tau_{n} \rangle \sigma \triangleright M \\ \Gamma \vdash (u_{1} : \tau_{1}, \ldots, u_{n} : \tau_{n})[\tau / \alpha] \\ \Gamma \vdash a : \sigma[\tau / \alpha] \triangleright M \ x_{\tau_{1}[\tau / \alpha]}^{u_{1}} \ldots x_{\tau_{n}[\tau / \alpha]}^{u_{n}} \] The previous example, twice The typing derivation is as follows. We write $\tau^1$ for $\tau$ and $\tau^{n+1}$ for $\tau \rightarrow \tau^n$; $\Gamma$ for $x : \alpha$, plus: $\alpha^3$; and $\Gamma_0$ for some non conflicting context. \[ \begin{align*} \Gamma_0 \Gamma \vdash \text{plus} : \alpha^3 \triangleright x_{\alpha^3} & \quad \Gamma_0 \Gamma \vdash x : \alpha \triangleright x \\ \Gamma_0 \Gamma \vdash \text{plus} \times x : \alpha \triangleright x_{\alpha^3} \times x \\ \Gamma_0, \text{plus: } \alpha^3 \vdash \lambda(x) \text{ plus } x \times x : \alpha \rightarrow \alpha \triangleright \lambda(x) x_{\alpha^3}^\text{plus} \times x \\ \Gamma_0 \vdash \lambda(x) \text{ plus } x \times : \forall \alpha \langle \text{plus: } \alpha^3 \rangle \alpha \rightarrow \alpha \triangleright \lambda(x) x_{\alpha^3}^\text{plus} \lambda(x) x_{\alpha^3}^\text{plus} \times x \end{align*} \] Compilation of OML Let $\Gamma_0$ stand for $$\text{plus: } \text{int}^3, \text{plus: } \text{bool}^3, \text{plus: } \forall \beta \langle \text{plus: } \beta^3 \rangle \forall \gamma \langle \text{plus: } \gamma^3 \rangle (\beta \times \gamma)^3$$ and $\Gamma_1$ be $\Gamma_0$, $\text{twice : } \forall \alpha \langle \text{plus: } \alpha^3 \rangle \alpha \to \alpha$. We have: \[ \begin{align*} \text{All-Elim} \\ \Gamma_1 \vdash \text{plus: } \forall \beta \langle \text{plus: } \beta^3 \rangle \forall \gamma \langle \text{plus: } \gamma^3 \rangle (\beta \times \gamma)^3 \triangleright x_{\sigma}^ ext{plus} \\ \Gamma_1 \vdash \text{plus: } \text{int}^3 \triangleright x_{\text{int}^3}^\text{plus} & \quad \Gamma_1 \vdash \text{plus: } \text{bool}^3 \triangleright x_{\text{bool}^3}^\text{plus} \\ \hline \Gamma_1 \vdash \text{plus: } (\text{int} \times \text{bool})^3 \triangleright x_{\sigma}^\text{plus} \times x_{\text{int}^3}^\text{plus} \times x_{\text{bool}^3}^\text{plus} \end{align*} \] Therefore, \[ \begin{align*} \text{All-Elim} \\ \Gamma_0 \vdash \text{twice : } (\text{int} \times \text{bool})^2 \triangleright \text{twice } (x_{\sigma}^\text{plus} \times x_{\text{int}^3}^\text{plus} \times x_{\text{bool}^3}^\text{plus}) \\ \Gamma_0 \vdash \text{twice } (1, \text{true}) : (\text{int} \times \text{bool}) \triangleright \text{twice } (x_{\sigma}^\text{plus} \times x_{\text{int}^3}^\text{plus} \times x_{\text{bool}^3}^\text{plus}) (1, \text{true}) \end{align*} \] Properties Type preservation The translation is type preserving. This result is easy to establish. Coherence The translation is based on derivations and returns different programs for different derivations. Does the semantics depend on the typing derivation? Fortunately, this is not the case. Two translations of the same program based on two different typing derivations are observationally equivalent. We say that the semantics is coherent. This result is difficult and tedious and has in fact only been proved for variants of the language. So far, it is only a conjecture for OML. System OML Principal types There are principal types in OML, thanks to the restriction on the type schemes of overloaded functions. Monolithic type inference Principal types can be inferred by solving unification constraints on the fly as in Damas-Milner. The main difference is to treat applications of overloaded functions by generating a fresh overloaded assumption (an overloaded variable with a type constraint) in the typing environment. The non-overlapping of typing assumptions on overloaded variables implies that the overloaded assumptions may have to be transformed when a variable is instantiated during unification: assumptions may have to be merged triggering further unifications, or to be resolved and removed from the typing environment, but perhaps introducing other assumptions. Asume $\Gamma_0$ is neg: $\textit{int}^2$, neg: $\textit{bool}^2$, neg: $\forall \beta \langle \text{neg} : \beta^2 \rangle (\beta \text{ list})^2$. To solve the typing contraint $\Gamma_0 \vdash (\lambda(x) \text{ neg } x) \ 1 : \tau$, we infer \[ \Gamma_0, \text{neg: } \alpha \rightarrow \beta, \ x : \alpha \vdash \text{neg } x : \beta \] \[ \Gamma_0, \text{neg: } \alpha \rightarrow \beta \vdash \lambda(x) \text{ neg } x : \alpha \rightarrow \beta \] - The most general judgment uses the asumption neg: $\alpha \rightarrow \beta$. Asume $\Gamma_0$ is $\text{neg}: \text{int}^2, \text{neg}: \text{bool}^2, \text{neg}: \forall \beta \langle \text{neg} : \beta^2 \rangle (\beta \text{ list})^2$. To solve the typing constraint $\Gamma_0 \vdash (\lambda(x) \text{ neg } x) \ 1 : \tau$, we infer: $$\Gamma_0, \text{neg}: \text{int} \rightarrow \beta, x : \text{int} \vdash \text{neg } x : \beta$$ $$\Gamma_0, \text{neg}: \text{int} \rightarrow \beta \vdash \lambda(x) \text{ neg } x : \text{int} \rightarrow \beta$$ $\text{(Informally)}$ - The most general judgment uses the asumption $\text{neg}: \text{int} \rightarrow \beta$. - We must unify $\text{int}$ with $\text{int}$ in order to type the application. ### System OML Type inference by example Assume $\Gamma_0$ is $\text{neg}: \text{int}^2$, $\text{neg}: \text{bool}^2$, $\text{neg}: \forall \beta \langle \text{neg} : \beta^2 \rangle (\beta \text{ list})^2$. To solve the typing constraint $\Gamma_0 \vdash (\lambda(x) \text{ neg } x) \mathbf{1} : \tau$, we infer $$\frac{\Gamma_0, \text{neg}: \text{int} \rightarrow \text{int}, x : \text{int} \vdash \text{neg } x : \text{int}}{\Gamma_0, \text{neg}: \text{int} \rightarrow \text{int} \vdash \lambda(x) \text{ neg } x : \text{int} \rightarrow \text{int}}$$ (Informally) - The most general judgment uses the assumption $\text{neg}: \text{int} \rightarrow \text{int}$. - We must unify $\text{int}$ with $\text{int}$ in order to type the application. - There is a hidden well-formedness constraint: Since $\Gamma_0$ contains a assumption $\text{neg} : \text{int}^2$, it must be merged with the other assumption $\text{neg} : \text{int} \rightarrow \text{int}'$, which forces the unification of $\text{int}'$ with $\text{int}$, System OML Type inference by example Asume $\Gamma_0$ is neg: $int^2$, neg: $bool^2$, neg: $\forall \beta \langle neg : \beta^2 \rangle (\beta \text{ list})^2$. To solve the typing constraint $\Gamma_0 \vdash (\lambda(x) \ neg \ x) \ 1 : \tau$, we infer $$ \frac{ \Gamma_0, x : int \vdash neg \ x : int }{ \Gamma_0 \vdash \lambda(x) \ neg \ x : int \rightarrow int } $$ - The most general judgment - We must unify $int$ with $int$ in order to type the application. - There is a hidden well-formedness constraint: Since $\Gamma_0$ contains a assumption $neg : int^2$, it must be merged with the other assumption $neg : int \rightarrow int'$, which forces the unification of $int'$ with $int$, - Removing repeated typing assumptions from the typing environment Asume $\Gamma_0$ is neg: $\texttt{int}^2$, neg: $\texttt{bool}^2$, neg: $\forall \beta \langle \text{neg} : \beta^2 \rangle (\beta \texttt{list})^2$. To solve the typing constraint $\Gamma_0 \vdash (\lambda(x) \text{neg} x) \ 1 : \tau$, we infer \[ \Gamma_0, x : \texttt{int} \vdash \text{neg} x : \texttt{int} \] \[ \frac{ \Gamma_0 \vdash \lambda(x) \text{neg} x : \texttt{int} \rightarrow \texttt{int} \quad \Gamma_0 \vdash 1 : \texttt{int} }{\Gamma_0 \vdash (\lambda(x) \text{neg} x) \ 1 : \texttt{int}} \] - The most general judgment - We must unify $\texttt{int}$ with $\texttt{int}$ in order to type the application. - There is a hidden well-formedness constraint: Since $\Gamma_0$ contains a assumption $\text{neg} : \texttt{int}^2$, it must be merged with the other assumption $\text{neg} : \texttt{int} \rightarrow \texttt{int}'$, which forces the unification of $\texttt{int}'$ with $\texttt{int}$. - Removing repeated typing assumptions from the typing environment - Finally... <table> <thead> <tr> <th>Generalities</th> <th>Implementation strategies</th> <th>System</th> <th>OML</th> <th>Qualified types</th> <th>Type classes</th> <th>Design space</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> **Generalities** **Implementation strategies** **System OML** **Qualified types** **Type classes** **Design space** Qualified types A general framework Qualified types are a general framework for inferring types of partial functions. Overloading is just a particular case of qualified types. Idea: introduce predicates that restrict the set of types a variable may range over. For instance, $Plus \alpha$ means that $\alpha$ can only be instantiated at a type $\tau$ such that there exists a definition for $plus$ of type $\tau \rightarrow \tau \rightarrow \tau$. Parameterize over the constraint domain - Typing rules use a separate judgement to state when constraints are satisfied, which depends on the constraint domain. - This separates the resolution of constraints from their generation. - It also internalizes simplification and optimization of constraints. See Jones (1992) Generalities Implementation strategies System OML Qualified types Type classes Design space Types classes What are they? A mechanism for building overloaded definitions is a more structured way. - Overloaded definitions are grouped into type classes. - A type class defines a set of identifiers that belong to that class. - An instance of a type class provides, for a specific type, definitions for all elements of the class. - A type class may have default definitions, which are not overloaded definitions, but defaults for overloaded definitions when taking instances of that class. Type classes are more convenient to use than plain unstructured overloading and keep types more concise, both for defining new implementations and writing assumptions. Type classes can be compiled away into qualified types. Module-based overloading Modules can be used instead type classes to group overloaded definitions. - A type component distinguishes the type at which overloaded instances are provided. - Basic instances are basic modules. - Derivable instances are defined as functors. - Modules can be declared as overloading their definitions. - The basic overloaded mechanism can then be used to resolved overloaded names. - Functor application is implicitly used to generate derived instances. The advantage of module-based overloading over type classes is that modules already organize name scoping and type abstraction. However, the underlying overloading engine is essentially the same. See Dreyer et al. (2007) Generalities Implementation strategies System OML Qualified types Type classes Design space Problems and challenges **Simplification and optimizations** Because generalization and instantiation induces additional abstractions and applications, it is important to use them as little as necessary, while retaining principal types. This constrasts with ML where it does not matter. (Coherence implies that the semantics does not depend on the derivation, but the efficiency does, indeed.) **Efficiency of implementation techniques** The pros and cons of the different implementation techniques are well-understood, but they is no available detailed comparison of their respective performance, with different optimization techniques. Remaining problems and challenges Overlapping instances The semantics depend on types. This does not work well with type inference. Type inference (checking coverage) may also become expensive or even undecidable. Overloaded on return types The semantics depends on types and type inference. Overloading with local scope This introduced a potential conflict in the resolution: An overloaded symbol with a local implementation can either be resolved immediately or left generic to be resolved later, in the context of use, perhaps with another implementation. This choice cannot be left implicit. Remaining problems and challenges **Design space** Because some restrictions must be imposed on the shape and overlapping of type definitions, there are many variations in the design space. See Jones et al. (1997) Ideas to bring back home Overloading is quite useful - Static overloading may already significantly alleviate the notations - However, it is too strong a restriction, which may often be frustrating - Dynamic overloading enables polytypic programming Overloading is well-understood - Long, positive experience with Haskell. - Perhaps, more restrictive forms of overloading would be acceptable. It always require some compromises - When definitions are overlapping, the semantics depends on typechecking. With powerful type inference, the semantics may not always be obvious to the programmer. - There is still place for other, perhaps better compromises.
{"Source-Url": "http://cristal.inria.fr/~remy/mpri/2009/overloading.pdf", "len_cl100k_base": 10048, "olmocr-version": "0.1.53", "pdf-total-pages": 59, "total-fallback-pages": 0, "total-input-tokens": 108980, "total-output-tokens": 13522, "length": "2e13", "weborganizer": {"__label__adult": 0.00037789344787597656, "__label__art_design": 0.00030994415283203125, "__label__crime_law": 0.0002970695495605469, "__label__education_jobs": 0.00049591064453125, "__label__entertainment": 4.7087669372558594e-05, "__label__fashion_beauty": 0.00015306472778320312, "__label__finance_business": 0.00017464160919189453, "__label__food_dining": 0.0003883838653564453, "__label__games": 0.00041961669921875, "__label__hardware": 0.0006198883056640625, "__label__health": 0.0004575252532958984, "__label__history": 0.0002058744430541992, "__label__home_hobbies": 8.147954940795898e-05, "__label__industrial": 0.0003533363342285156, "__label__literature": 0.0002474784851074219, "__label__politics": 0.0002868175506591797, "__label__religion": 0.0005064010620117188, "__label__science_tech": 0.00478363037109375, "__label__social_life": 8.112192153930664e-05, "__label__software": 0.002780914306640625, "__label__software_dev": 0.98583984375, "__label__sports_fitness": 0.0003159046173095703, "__label__transportation": 0.00046324729919433594, "__label__travel": 0.00020706653594970703}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 36189, 0.00628]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 36189, 0.27309]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 36189, 0.68576]], "google_gemma-3-12b-it_contains_pii": [[0, 97, false], [97, 211, null], [211, 531, null], [531, 1380, null], [1380, 2109, null], [2109, 2760, null], [2760, 3060, null], [3060, 3915, null], [3915, 4337, null], [4337, 4950, null], [4950, 5548, null], [5548, 5645, null], [5645, 5962, null], [5962, 6708, null], [6708, 7409, null], [7409, 7683, null], [7683, 8037, null], [8037, 8812, null], [8812, 9609, null], [9609, 11151, null], [11151, 11668, null], [11668, 12152, null], [12152, 12584, null], [12584, 13018, null], [13018, 13820, null], [13820, 13926, null], [13926, 14542, null], [14542, 15405, null], [15405, 16107, null], [16107, 16739, null], [16739, 17532, null], [17532, 18109, null], [18109, 18718, null], [18718, 18791, null], [18791, 19788, null], [19788, 21005, null], [21005, 21901, null], [21901, 23393, null], [23393, 23984, null], [23984, 24787, null], [24787, 25329, null], [25329, 26008, null], [26008, 27037, null], [27037, 27800, null], [27800, 28793, null], [28793, 29258, null], [29258, 30031, null], [30031, 30128, null], [30128, 30851, null], [30851, 31558, null], [31558, 31655, null], [31655, 32297, null], [32297, 32899, null], [32899, 33116, null], [33116, 33773, null], [33773, 33773, null], [33773, 34540, null], [34540, 35578, null], [35578, 36189, null]], "google_gemma-3-12b-it_is_public_document": [[0, 97, true], [97, 211, null], [211, 531, null], [531, 1380, null], [1380, 2109, null], [2109, 2760, null], [2760, 3060, null], [3060, 3915, null], [3915, 4337, null], [4337, 4950, null], [4950, 5548, null], [5548, 5645, null], [5645, 5962, null], [5962, 6708, null], [6708, 7409, null], [7409, 7683, null], [7683, 8037, null], [8037, 8812, null], [8812, 9609, null], [9609, 11151, null], [11151, 11668, null], [11668, 12152, null], [12152, 12584, null], [12584, 13018, null], [13018, 13820, null], [13820, 13926, null], [13926, 14542, null], [14542, 15405, null], [15405, 16107, null], [16107, 16739, null], [16739, 17532, null], [17532, 18109, null], [18109, 18718, null], [18718, 18791, null], [18791, 19788, null], [19788, 21005, null], [21005, 21901, null], [21901, 23393, null], [23393, 23984, null], [23984, 24787, null], [24787, 25329, null], [25329, 26008, null], [26008, 27037, null], [27037, 27800, null], [27800, 28793, null], [28793, 29258, null], [29258, 30031, null], [30031, 30128, null], [30128, 30851, null], [30851, 31558, null], [31558, 31655, null], [31655, 32297, null], [32297, 32899, null], [32899, 33116, null], [33116, 33773, null], [33773, 33773, null], [33773, 34540, null], [34540, 35578, null], [35578, 36189, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 36189, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 36189, null]], "pdf_page_numbers": [[0, 97, 1], [97, 211, 2], [211, 531, 3], [531, 1380, 4], [1380, 2109, 5], [2109, 2760, 6], [2760, 3060, 7], [3060, 3915, 8], [3915, 4337, 9], [4337, 4950, 10], [4950, 5548, 11], [5548, 5645, 12], [5645, 5962, 13], [5962, 6708, 14], [6708, 7409, 15], [7409, 7683, 16], [7683, 8037, 17], [8037, 8812, 18], [8812, 9609, 19], [9609, 11151, 20], [11151, 11668, 21], [11668, 12152, 22], [12152, 12584, 23], [12584, 13018, 24], [13018, 13820, 25], [13820, 13926, 26], [13926, 14542, 27], [14542, 15405, 28], [15405, 16107, 29], [16107, 16739, 30], [16739, 17532, 31], [17532, 18109, 32], [18109, 18718, 33], [18718, 18791, 34], [18791, 19788, 35], [19788, 21005, 36], [21005, 21901, 37], [21901, 23393, 38], [23393, 23984, 39], [23984, 24787, 40], [24787, 25329, 41], [25329, 26008, 42], [26008, 27037, 43], [27037, 27800, 44], [27800, 28793, 45], [28793, 29258, 46], [29258, 30031, 47], [30031, 30128, 48], [30128, 30851, 49], [30851, 31558, 50], [31558, 31655, 51], [31655, 32297, 52], [32297, 32899, 53], [32899, 33116, 54], [33116, 33773, 55], [33773, 33773, 56], [33773, 34540, 57], [34540, 35578, 58], [35578, 36189, 59]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 36189, 0.00943]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
a0670bb28315bbe8ad8295546c025ccc076875cc
Package ‘tidyjson’ December 2, 2019 Title Tidy Complex 'JSON' Version 0.2.4 Description Turn complex 'JSON' data into tidy data frames. Depends R (>= 3.1.0) Imports assertthat, jsonlite, purrr, dplyr (>= 0.8.3), magrittr, tidyr (>= 1.0.0), tibble License MIT + file LICENSE LazyData true Suggests knitr, testthat, ggplot2, rmarkdown, forcats, wordcloud, viridis, listviewer, igraph, RColorBrewer, covr, lubridate, rlang VignetteBuilder knitr URL https://github.com/colearendt/tidyjson BugReports https://github.com/colearendt/tidyjson/issues RoxygenNote 6.1.1 NeedsCompilation no Author Jeremy Stanley [aut], Cole Arendt [aut, cre] Maintainer Cole Arendt <cole@rstudio.com> Repository CRAN Date/Publication 2019-12-02 21:39:30 R topics documented: allowed_json_types .................................................. 2 append_values .......................................................... 3 append_values_factory ................................................. 4 append_values_type .................................................... 5 as.character.tbl_json .................................................. 5 as_tibble.tbl_json ...................................................... 6 allowed_json_types Fundamental JSON types from http://json.org/, where I collapse 'true' and 'false' into 'logical' Description Fundamental JSON types from http://json.org/, where I collapse 'true' and 'false' into 'logical' Usage allowed_json_types append_values Format An object of class character of length 6. Description The append_values functions let you take any scalar JSON values of a given type ("string", "number", "logical") and add them as a new column named column.name. This is particularly useful after using gather_object to gather an object. Usage append_values_string(.x, column.name = type, force = TRUE, recursive = FALSE) append_values_number(.x, column.name = type, force = TRUE, recursive = FALSE) append_values_logical(.x, column.name = type, force = TRUE, recursive = FALSE) Arguments .x a json string or tbl_json object column.name the name of the column to append values as force should values be coerced to the appropriate type when possible, otherwise, types are checked first (requires more memory) recursive logical indicating whether to recursively extract a single value from a nested object. Only used when force = TRUE. If force = FALSE, and recursive = TRUE, throws an error. Details Any values that can not be converted to the specified will be NA in the resulting column. This includes other scalar types (e.g., numbers or logicals if you are using append_values_string) and *also* any rows where the JSON is NULL or an object or array. Note that the append_values functions do not alter the JSON attribute of the tbl_json object in any way. Value a tbl_json object append_values_factory See Also gather_object to gather an object first, spread_all to spread values into new columns Examples # Stack names '("first": "bob", "last": "jones")' %>% gather_object %>% append_values_string # This is most useful when data is stored in name-value pairs # For example, tags in recipes: recipes <- c('"name": "pie", "tags": {"apple": 10, "pie": 2, "flour": 5}}', "name": "cookie", "tags": {"chocolate": 2, "cookie": 1}}') recipes %>% spread_values(name = jstring(name)) %>% enter_object(tags) %>% gather_object("tag") %>% append_values_number("count") append_values_factory Creates the append_values_* functions Description Creates the append_values_* functions Usage append_values_factory(type, as.value) Arguments type the JSON type that will be appended as.value function to force coercion to numeric, string, or logical append_values_type get list of values from json Description get list of values from json Usage append_values_type(json, type) Arguments json extracted using attributes type input type (numeric, string, etc) as.character.tbl_json Convert the JSON in an tbl_json object back to a JSON string Description Convert the JSON in an tbl_json object back to a JSON string Usage ## S3 method for class 'tbl_json' as.character(x, ...) Arguments x a tbl_json object ... not used (map_chr used instead) Value a character vector of formatted JSON as_tibble.tbl_json Convert a tbl_json back to a tbl_df Description Drops the JSON attribute and the tbl_json class, so that we are back to a pure tbl_df. Useful for some internals. Also useful when you are done processing the JSON portion of your data and are ready to move on to other tools. Usage ```r ## S3 method for class 'tbl_json' as_tibble(x, ...) ## S3 method for class 'tbl_json' as_data_frame(x, ...) ``` Arguments - `x` a tbl_json object - `...` additional parameters Details Note that as.tbl calls tbl_df under the covers, which in turn calls as_data_frame. As a result, this should take care of all cases. Value a tbl_df object (with no tbl_json component) bind_rows Bind Rows (tidyjson) Description Since bind_rows is not currently an s3 method, this function is meant to mask dplyr::bind_rows (although it is called directly). Usage ```r bind_rows(...)``` Arguments - `...` Values passed on to dplyr::bind_rows Value If all parameters are ‘tbl_json’ objects, then the JSON attributes will be stacked and a ‘tbl_json’ will be returned. Otherwise, ‘dplyr::bind_rows’ is used, a message is displayed, and a ‘tbl_df’ is returned. See Also [Related dplyr issue](https://github.com/tidyverse/dplyr/issues/2457) bind_rows Examples ```r ## Simple example a <- as.tbl_json('["a": 1, "b": 2]') b <- as.tbl_json('["a": 3, "b": 4]') bind_rows(a, b) %>% spread_values(a=jnumber(a), b=jnumber(b)) ## as a list bind_rows(list(a, b)) %>% spread_all() ``` --- ```r library(dplyr) # Commits is a long character string commits %>% nchar # Let's make it a tbl_json object commits %>% as.tbl_json ``` # It begins as an array, so let's gather that # Now let's spread all the top level values # Are there any top level objects or arrays? # Let's look at the parents array ## Description From: http://jsonstudio.com/resources/ ## Usage companies ## Format JSON ## Examples library(dplyr) # Companies is a long character vector companies %>% str # Work with a small sample co_samp <- companies[1:5] # Gather top level values and glimpse co_samp %>% spread_all %>% glimpse # Get the key employees data for the first 100 companies key_employees <- companies[1:100] %>% spread_all %>% select(name) %>% enter_object(relationships) %>% determine_types gather_array() %>% spread_all key_employees %>% glimpse # Show the top 10 titles key_employees %>% filter(!is_past) %>% count(title) %>% arrange(desc(n)) %>% top_n(10) determine_types Determines the types of a list of parsed JSON Description Determines the types of a list of parsed JSON Usage determine_types(json_list) Arguments json_list a list of parsed JSON Value a factor with levels json_types enter_object Enter into a specific object and discard all other JSON data Description When manipulating a JSON object, enter_object lets you navigate to a specific value of the object by referencing its name. JSON can contain nested objects, and you can pass in more than one character string into enter_object to navigate through multiple objects simultaneously. Usage enter_object(.x, ...) Arguments .x a json string or tbl_json object ... a quoted or unquoted sequence of strings designating the object name or sequences of names you wish to enter Details After using `enter_object`, all further tidyjson calls happen inside the referenced object (all other JSON data outside the object is discarded). If the object doesn’t exist for a given row / index, then that row will be discarded. In pipelines, `enter_object` is often preceded by `gather_object` and followed by `gather_array` if the value is an array, or `spread_all` if the value is an object. Value a tbl_json object See Also gather_object to find sub-objects that could be entered into, gather_array to gather an array in an object and spread_all or spread_values to spread values in an object. Examples # Let's start with a simple example of parents and children json <- c('{"parent": "bob", "children": ["sally", "george"]}', '{"parent": "fred", "children": ["billy"]}', '{"parent": "anne"}') # We can see the names and types in each json %>% gather_object %>% json_types # Let's capture the parent first and then enter in the children object json %>% spread_all %>% enter_object(children) # Also works with quotes json %>% spread_all %>% enter_object("children") # Notice that "anne" was discarded, as she has no children # We can now use gather array to stack the array json %>% spread_all %>% enter_object(children) %>% gather_array("child.num") # And append_values_string to add the children names json %>% spread_all %>% enter_object(children) %>% gather_array("child.num") %>% append_values_string("child") # The path can be comma delimited to go deep into a nested object json <- '{"name": "bob", "attributes": {"age": 32, "gender": "male"}}' json %>% enter_object(attributes, age) # A more realistic example with companies data library(dplyr) companies %>% enter_object(acquisitions) %>% gather_array %>% spread_all %>% glimpse gather_array Gather a JSON array into index-value pairs Description gather_array collapses a JSON array into index-value pairs, creating a new column 'array.index' to store the index of the array, and storing values in the 'JSON' attribute for further tidyjson manipulation. All other columns are duplicated as necessary. This allows you to access the values of the array just like gather_object lets you access the values of an object. Usage gather_array(.x, column.name = default.column.name) Arguments .x a json string or tbl_json object whose JSON attribute should always be an array column.name the name to give to the array index column created Details JSON arrays can be simple vectors (fixed or varying length number, string or logical vectors with or without null values). But they also often contain lists of other objects (like a list of purchases for a user). Thus, the best analogy in R for a JSON array is an unnamed list. gather_array is often preceded by enter_object when the array is nested under a JSON object, and is often followed by gather_object or enter_object if the array values are objects, or by append_values to append all scalar values as a new column or json_types to determine the types of the array elements (JSON does not guarantee they are the same type). Value a tbl_json object See Also gather_object to gather a JSON object, enter_object to enter into an object, gather to gather name-value pairs in a data frame Examples # A simple character array example json <- c("a", "b", "c") # Check that this is an array json %>% json_types # Gather array and check types json %>% gather_array %>% json_types # Extract string values json %>% gather_array %>% append_values_string # A more complex mixed type example json <- c("a", 1, true, null, "name": "value") # Then we can use the column.name argument to change the name column json %>% gather_array %>% json_types # A nested array json <- list(c("a", "b", "c"), c("a", "d"), c("b", "c")) # Extract both levels json %>% gather_array("index.1") %>% gather_array("index.2") %>% append_values_string # Some JSON begins as an array commits %>% gather_array # We can use spread_all to capture all values # (recursive = FALSE to limit to the top level object) library(dplyr) commits %>% gather_array %>% spread_all(recursive = FALSE) %>% glimpse --- gather_factory Factory to create gather functions Description Factory to create gather functions Usage gather_factory(default.column.name, default.column.empty, expand.fun, required.type) gather_object Arguments - default.column.name: the desired name of the default added column - default.column.empty: the value to use when the default column should be empty because the JSON has length 0 - expand.fun: a function applied to the JSON that will expand the rows in the tbl_df - required.type: the json_types type that must be present in every element of the JSON for this to succeed Description gather_object collapses a JSON object into name-value pairs, creating a new column 'name' to store the pair names, and storing the values in the 'JSON' attribute for further tidyjson manipulation. All other columns are duplicated as necessary. This allows you to access the names of the object pairs just like gather_array lets you access the values of an array. Usage gather_object(.x, column.name = default.column.name) Arguments - .x: a JSON string or tbl_json object whose JSON attribute should always be an object - column.name: the name to give to the column of pair names created Details gather_object is often followed by enter_object to enter into a value that is an object, by append_values to append all scalar values as a new column or json_types to determine the types of the values. Value - a tbl_json object See Also gather_array to gather a JSON array, enter_object to enter into an object, gather to gather name-value pairs in a data frame Examples # Let's start with a very simple example json <- '{"name": "bob", "age": 32, "gender": "male"}" # Check that this is an object json %>% json_types # Gather object and check types json %>% gather_object %>% json_types # Sometimes data is stored in object pair names json <- '{"2014": 32, "2015": 56, "2016": 14}" # Then we can use the column.name argument to change the column name json %>% gather_object("year") # We can also use append_values_number to capture the values, since they are # all of the same type json %>% gather_object("year") %>% append_values_number("count") # This can even work with a more complex, nested example json <- '{"2015": {"1": 10, "3": 1, "11": 5}, "2016": {"2": 3, "5": 15}}" json %>% gather_object("year") %>% gather_object("month") %>% append_values_number("count") # Most JSON starts out as an object (or an array of objects), and # gather_object can be used to inspect the top level (or 2nd level) objects library(dplyr) worldbank %>% gather_object %>% json_types %>% count(name, type) has_names Check for Names Description Checks the input object for the existence of names Usage has_names(x) Arguments x Input object Value Boolean. Indicates whether x has names Description Issue data for the dplyr repo from github API Usage issues Format JSON Examples library(dplyr) # issues is a long character string nchar(issues) # Let's make it a tbl_json object issues %>% as.tbl_json # It begins as an array, so let's gather that issues %>% gather_array # Now let's spread all the top level values issues %>% gather_array %>% spread_all %>% glimpse # Are there any top level objects or arrays? issues %>% gather_array %>% gather_object %>% json_types %>% count(name, type) %>% filter(type %in% c("array", "object")) # Count issues labels by name labels <- issues %>% gather_array %>% spread_values(id = jnumber(id)) %>% enter_object(labels) %>% gather_array("label.index") %>% spread_all %>% glimpse # Count number of distinct issues each label appears in labels %>% group_by(name) %>% summarize(num.issues = n_distinct(id)) ### is_data_list List Check **Description** Checks whether a list is being provided **Usage** is_data_list(x) **Arguments** - **x** Input object **Value** Boolean. Indicates whether x is a list ### is_json Predicates to test for specific JSON types in tbl_json objects **Description** These functions are often useful with filter to filter complex JSON by type before applying gather_object or gather_array. **Usage** is_json_string(.x) is_json_number(.x) is_json_logical(.x) is_json_null(.x) is_json_array(.x) is_json_object(.x) is_json_scalar(.x) **Arguments** - **.x** a json string or tbl_json object is_json_factory Value a logical vector See Also json_types for creating a new column to identify the type of every JSON document Examples ```r # Test a simple example json <- '{[1, "string", true, [1, 2], {"name": "value"}, null]}' %>% gather_array json %>% is_json_number json %>% is_json_array json %>% is_json_scalar # Use with filter library(dplyr) json %>% filter(is_json_object(.)) # Combine with filter in advance of using gather_array companies[1:5] %>% gather_object %>% filter(is_json_array(.)) companies[1:5] %>% gather_object %>% filter(is_json_array(.)) %>% gather_array # Combine with filter in advance of using gather_object companies[1:5] %>% gather_object %>% filter(is_json_object(.)) companies[1:5] %>% gather_object %>% filter(is_json_object(.)) %>% gather_object("name2") ``` Description Factory to create is_json functions Usage is_json_factory(desired.types) Arguments desired.types character vector of types we want to check for Value a function **json_complexity** Compute the complexity (recursively unlisted length) of JSON data **Description** When investigating complex JSON data it can be helpful to identify the complexity of deeply nested documents. The `json_complexity` function adds a column (default name "complexity") that contains the 'complexity' of the JSON associated with each row. Essentially, every on-null scalar value is found in the object by recursively stripping away all objects or arrays, and the complexity is the count of these scalar values. Note that 'null' has complexity 0, as do empty objects and arrays. **Usage** ``` json_complexity(.x, column.name = "complexity") ``` **Arguments** - `.x` a json string or tbl_json object - `column.name` the name to specify for the length column **Value** a `tbl_json` object **See Also** `json_lengths` to compute the length of each value **Examples** ```r # A simple example json <- c('[1, 2, [3, 4]]', '{"k1": 1, "k2": [2, [3, 4]]}', '1', 'null') # Complexity is larger than length for nested objects json %>% json_lengths %>% json_complexity # Worldbank has complexity ranging from 8 to 17 library(magrittr) worldbank %>% json_complexity %>% table(complexity) # Commits are much more regular commits %>% gather_array %>% json_complexity %>% table(complexity) ``` json_factory Factory that creates the j* functions below **Description** Factory that creates the j* functions below **Usage** json_factory(map.function) **Arguments** - **map.function**: function to map to collapse json_functions Navigates nested objects to get at names of a specific type, to be used as arguments to spread_values **Description** Note that these functions fail if they encounter the incorrect type. **Usage** jstring(..., recursive = FALSE) jnumber(..., recursive = FALSE) jlogical(..., recursive = FALSE) **Arguments** - **...**: a quoted or unquoted sequence of strings designating the object name sequence you wish to follow to find a value - **recursive**: logical indicating whether second level and beyond objects should be extracted. Only works when there exists a single value in the nested json object **Value** a function that can operate on parsed JSON data **See Also** spread_values for using these functions to spread the values of a JSON object into new columns json_lengths Compute the length of JSON data Description When investigating JSON data it can be helpful to identify the lengths of the JSON objects or arrays, especially when they are 'ragged' across documents. The json_lengths function adds a column (default name "length") that contains the 'length' of the JSON associated with each row. For objects, this will be equal to the number of name-value pairs. For arrays, this will be equal to the length of the array. All scalar values will be of length 1, and null will have length 0. Usage json_lengths(.x, column.name = "length") Arguments .x a json string or tbl_json object .column.name the name to specify for the length column Value a tbl_json object See Also json_complexity to compute the recursive length of each value Examples # A simple example json <- c('[1, 2, 3]', '{"k1": 1, "k2": 2}', '1', 'null') # Complexity is larger than length for nested objects json %>% json_lengths # Worldbank objects are either length 7 or 8 library(magrittr) worldbank %>% json_lengths %>% table(length) # All commits are length 8 commits %>% gather_array %>% json_lengths %>% table(length) Create a schema for a JSON document or collection **Description** Returns a JSON document that captures the 'schema' of the collection of document(s) passed in, as a JSON string. The schema collapses complex JSON into a simple form using the following rules: **Usage** ``` json_schema(.x, type = c("string", "value")) ``` **Arguments** - `.x` a json string or `tbl_json` object - `type` whether to capture scalar nodes using the string that defines their type (e.g., "logical") or as a representative value (e.g., "true") **Details** - string -> "string", e.g., "a sentence" -> "string" - number -> "number", e.g., 32000.1 -> "number" - true -> "logical", e.g., true -> "logical" - false -> "logical", e.g., false -> "logical" - null -> "null", e.g., null -> "null" - array -> `[<type>]` e.g., [1, 2] -> ["number"] - object -> "name": <type> e.g., "age": 32 -> "age": "number" For more complex JSON objects, ties are broken by taking the most complex example (using `json_complexity`), and then by type (using `json_types`). This means that if a name has varying schema across documents, the most complex schema will be chosen as being representative. Similarly, if the elements of an array vary in schema, the most complex element is chosen, and if arrays vary in schema across documents, the most complex is chosen. Note that `json_schema` can be slow for large JSON document collections, you may want to sample your JSON collection first. **Value** a character string JSON document that represents the schema of the collection **See Also** `json_structure` to recursively structure all documents into a single data frame Examples # A simple string '"string"' %>% json_schema %>% writeLines # A simple object '("name": "value")' %>% json_schema %>% writeLines # A more complex JSON array json <- '[{"a": 1}, [1, 2], "a", 1, true, null] # Using type = 'string' (default) json %>% json_schema %>% writeLines # Using type = 'value' to show a representative value json %>% json_schema(type = "value") %>% writeLines # Schema of the first 5 github issues library(dplyr) issues %>% gather_array %>% slice(1:10) %>% json_schema(type = "value") %>% writeLines json_structure Recursively structures arbitrary JSON data into a single data frame Description Returns a tbl_json object where each row corresponds to a leaf in the JSON structure. The first row corresponds to the JSON document as a whole. If the document is a scalar value (JSON string, number, logical or null), then there will only be 1 row. If instead it is an object or an array, then subsequent rows will recursively correspond to the elements (and their children) of the object or array. Usage json_structure(.x) Arguments .x a json string or tbl_json object Details The columns in the tbl_json returned are defined as - document.id 1L if .x is a single JSON string, otherwise the index of .x. - parent.id the string identifier of the parent node for this child. • level what level of the hierarchy this child resides at, starting at 0L for the root and incrementing for each level of nested array or object. • index what index of the parent object / array this child resides at (from gather_array for arrays). • child.id a unique ID for this leaf in this document, represented as <parent>.<index> where <parent> is the ID for the parent and <index> is this index. • seq the sequence of names / indices that led to this child (parents that are arrays are excluded) as a list, where character strings denote objects and integers denote array positions • name if this is the value of an object, what was the name that it is listed under (from gather_object). • type the type of this object (from json_types). • length the length of this object (from json_lengths). Value a tbl_json object See Also json_schema to create a schema for a JSON document or collection Examples # A simple string "string" %>% json_structure # A simple object '("name": "value")' %>% json_structure # A complex array '[{"a": 1}, [1, 2], "a", 1, true, null] %>% json_structure # A sample of structure rows from a company library(dplyr) companies[1] %>% json_structure %>% sample_n(5) --- json_types Add a column that tells the 'type' of the JSON data Description The function json_types inspects the JSON associated with each row of the tbl_json object, and adds a new column ("type" by default) that identifies the type according to the JSON standard at http://json.org/. Usage json_types(.x, column.name = "type") Arguments \[.x\] a json string or tbl_json object \[\text{column.name}\] the name to specify for the type column Details This is particularly useful for inspecting your JSON data types, and can often follows after `gather_array`, `gather_object` or `enter_object` to inspect the types of the elements of JSON objects or arrays. Value a tbl_json object Examples # A simple example c(c('"a": 1', '[1, 2]', '"a"', '1', 'true', 'null') %% json_types # Type distribution in the first 10 companies library(dplyr) companies[1:10] %% gather_object %% json_types %% count(type) list_or_dots \[\text{List or Dots}\] Description Handles dots or a list, coercing into a list so that the output is easy to handle Usage list_or_dots(...) Arguments \[...\] Either a list or the ‘...' of a function call Value The input object coerced into a list for easier use **my_unlist** Unlists while preserving NULLs and only unlisting lists with one value **Description** Unlists while preserving NULLs and only unlisting lists with one value **Usage** ```r my_unlist(l, recursive = FALSE) ``` **Arguments** - `l`: a list that we want to unlist - `recursive`: logical indicating whether to unlist nested lists **path** Create a JSON path with a minimum of typing **Description** Create a JSON path with a minimum of typing **Usage** ```r path(...) ``` **Arguments** - `...`: a sequence of quoted or unquoted character strings specifying JSON object names **Value** - a path object print.tbl.json *Print a tbl.json object* **Description** Print a tbl.json object **Usage** ```r ## S3 method for class 'tbl.json' print(x, ..., json.n = 20, json.width = 15) ``` **Arguments** - `x`: a `tbl.json` object - `...`: other arguments into `print.tbl_df` - `json.n`: number of json records to add (... otherwise - `json.width`: number of json characters to print --- **rbind_tbl.json** *Bind two tbl.json objects together and preserve JSON attribute* **Description** Bind two tbl.json objects together and preserve JSON attribute **Usage** ```r rbind_tbl.json(x, y) ``` **Arguments** - `x`: a `tbl.json` object - `y`: a `tbl.json_object` **Value** `x` and `y` row-binded together with appropriate JSON attribute read_json Reads JSON from an input uri (file, url, ...) and returns a tbl_json object Description Reads JSON from an input uri (file, url, ...) and returns a tbl_json object Usage read_json(path, format = c("json", "jsonl", "infer")) Arguments path to some json data format If "json", process the data like one large JSON record. If "jsonl", process the data one JSON record per line (json lines format). If "infer", the format is the suffix of the given filepath. Value a tbl_json object spread_all Spreads all scalar values of a JSON object into new columns Description Like the spread function in tidyr but for JSON, this function spreads out any JSON objects that are scalars into new columns. If objects are nested, then the recursive flag will expand scalar values of nested objects out with a compound column name based on the sequences of nested object names concatenated with the sep character. Usage spread_all(.x, recursive = TRUE, sep = ".") Arguments .x a json string or tbl_json object recursive whether or not to recursively spread nested objects sep character used to separate nested object names when recursive is TRUE spread_values Details Note that arrays are ignored by this function, use gather_array to gather the array first, and then use spread_all if the array contains objects or use one of the append_values functions to capture the array values if they are scalars. Note that scalar JSON values (e.g., a JSON string like '1') are also ignored, as they have no names to create column names with. The order of columns is determined by the order they are encountered in the JSON document, with nested objects placed at the end. If an objects have name-value pairs with names that are duplicates, then ".n" is appended for n incrementing from 2 on to ensure that columns are unique. This also happens if .x already has a column with the name of a name-value pair. This function does not change the value of the JSON attribute of the tbl_json object in any way. Value a tbl_json object See Also spread_values to specific which specific values to spread along with their types, spread for spreading data frames Examples # A simple example json <- c("a": "x", "b": 1, "c": true, "a": "y", "c": false, "a": null, "d": "z") json %>% spread_all # A more complex example worldbank %>% spread_all # Resolving duplicate column names json <- '{"a": "x", "a": "y"} json %>% spread_all spread_values Spreads specific scalar values of a JSON object into new columns Description The spread_values function lets you extract extract specific values from (potentiall nested) JSON objects. spread_values takes jstring, jnumber or jlogical named function calls as arguments in order to specify the type of the data that should be captured at each desired name-value pair location. These values can be of varying types at varying depths. Usage spread_values(.x, ...) Arguments .x a json string or tbl_json object ... column = value pairs where column will be the column name created and value must be a call to jstring, jnumber or jlogical specifying the path to get the value (and the type implicit in the function name) Details Note that jstring, jnumber and jlogical will fail if they encounter the incorrect type in any document. The advantage of spread_values over spread_all is that you are guaranteed to get a consistent data frame structure (columns and types) out of any spread_values call. spread_all requires less typing, but because it infers the columns and their types from the JSON, it is less suitable when programming. Value a tbl_json object See Also spread_all for spreading all values, spread for spreading data frames, jstring, jnumber, jlogical for accessing specific names Examples # A simple example json <- '{"name": {"first": "Bob", "last": "Jones"}, "age": 32}' # Using spread_values json %>% spread_values( first.name = jstring(name, first), last.name = jstring(name, last), age = jnumber(age) ) # Another document, this time with a middle name (and no age) json2 <- '{"name": {"first": "Ann", "middle": "A", "last": "Smith"}}' c(json, json2) %>% spread_values( first.name = jstring(name, first), last.name = jstring(name, last), ) **Description** Constructs a `tbl_json` object, for further downstream manipulation by other tidyjson functions. Methods exist to convert JSON stored in character strings without any other associated data, as a separate character string and associated data frame, or as a single data frame with a specified character string JSON column. **Usage** ```r tbl_json(df, json.list, drop.null.json = FALSE) ``` ```r as.tbl_json(.x, ...) ``` ```r ## S3 method for class '.tbl_json' as.tbl_json(.x, ...) ``` ```r ## S3 method for class 'character' as.tbl_json(.x, ...) ``` ```r ## S3 method for class 'data.frame' as.tbl_json(.x, json.column, ...) ``` ```r is.tbl_json(.x) ``` **Arguments** - `df` : data.frame - `json.list` : list of json lists parsed with `fromJSON` - `drop.null.json` : drop NULL json entries from `df` and `json.list` - `.x` : an object to convert into a `tbl_json` object - `...` : other arguments - `json.column` : the name of the json column of data in `.x`, if `.x` is a data frame Details Most tidyjson functions accept a tbl_json object as the first argument, and return a tbl_json object unless otherwise specified. tidyjson functions will attempt to convert an object that isn’t a tbl_json object first, and so explicit construction of tidyjson objects is rarely needed. tbl_json objects consist of a data frame along with it’s associated JSON, where each row of the data frame corresponds to a single JSON document. The JSON is stored in a "JSON" attribute. Note that json.list must have the same length as nrow(df), and if json.list has any NULL elements, the corresponding rows will be removed from df. Also note that "..JSON" is a reserved column name used internally for filtering tbl_json objects, and so is not allowed in the names of df. Value a tbl_json object See Also read_json for reading json from files Examples # Construct a tbl_json object using a character string of JSON json <- '{"animal": "cat", "count": 2}' json %>% as.tbl_json # access the "JSON" argument json %>% as.tbl_json %>% attr("JSON") # Construct a tbl_json object using multiple documents json <- c('{"animal": "cat", "count": 2}', '{"animal": "parrot", "count": 1}'), json %>% as.tbl_json # Construct a tbl_json object from a data.frame with a JSON column library(tibble) farms <- tribble( ~farm, ~animals, 1L, '["animal": "pig", "count": 50}, {"animal": "cow", "count": 10}] 2L, '["animal": "chicken", "count": 20}] ) farms %>% as.tbl_json(json.column = "animals") # tidy the farms farms %>% as.tbl_json(json.column = "animals") %>% gather_array %>% spread_all **tidyjson** **Description** tidyjson. **worldbank** Projects funded by the World Bank **Description** From: http://jsonstudio.com/resources/ **Usage** worldbank **Format** JSON **Examples** ```r library(dplyr) # worldbank is a 500 length character vector of JSON length(worldbank) # Let's look at top level values worldbank %>>% spread_all %>% glimpse # Are there any arrays? worldbank %>>% gather_object %>% json_types %>% count(name, type) # Get the top 10 sectors by funded project in Africa wb_sectors <- worldbank %>% # 500 Projects funded by the world bank spread_all %>% select(project_name, regionname) %>% enter_object(majorsector_percent) %>% # Enter the 'sector' object gather_array("sector.index") %>% # Gather the array spread_values(sector = jstring(Name)) %>% # Spread the sector name # Examine the structured data wb_sectors %>% glimpse ``` # Get the top 10 sectors by funded project in Africa wb_sectors %>% filter(regionname == "Africa") %>% # Filter to just Africa count(sector) %>% # Count by sector arrange(desc(n)) %>% # Arrange descending top_n(10) # Take the top 10 --- ### `wrap_dplyr_verb` **Description** Wrapper for extending dplyr verbs to tbl_json objects **Usage** `wrap_dplyr_verb(dplyr.verb)` **Arguments** - `dplyr.verb` a dplyr::verb such as `filter`, `arrange` --- ### `[.tbl_json` **Description** Extract subsets of a tbl_json object (not replace) **Usage** ```r ## S3 method for class 'tbl_json' .x[i, j, drop = FALSE] ``` **Arguments** - `.x` a tbl_json object - `i` row elements to extract - `j` column elements to extract - `drop` whether or not to simplify results **Value** a tbl_json object Index *Topic datasets allowed_json_types, 2 [.tbl_json, 33 append_values, 3, 10, 13, 28 append_values_factory, 4 append_values_logical (append_values), 3 append_values_number (append_values), 3 append_values_string (append_values), 3 append_values_type, 5 as.character.tbl_json, 5 as.tbl_json (tbl_json), 30 as_data_frame.tbl_json (as_tibble.tbl_json), 6 as_tibble.tbl_json, 6 bind_rows, 6, 7 commits, 7 companies, 8 determine_types, 9 enter_object, 9, 10, 13, 24 filter, 16 fromJSON, 30 gather, 10, 13 gather_array, 10, 11, 13, 16, 24, 28 gather_factory, 12 gather_keys (gather_object), 13 gather_object, 3, 4, 10, 11, 13, 16, 23, 24 has_names, 14 is.tbl_json (tbl_json), 30 is_data_list, 16 is_json, 16 is_json_array (is_json), 16 is_json_factory, 17 is_json_logical (is_json), 16 is_json_null (is_json), 16 is_json_number (is_json), 16 is_json_object (is_json), 16 is_json_scalar (is_json), 16 is_json_string (is_json), 16 issues, 15 jlogical, 28, 29 jlogical (json_functions), 19 jnumber, 28, 29 jnumber (json_functions), 19 json_complexity, 18, 20, 21 json_factory, 19 json_functions, 19 json_lengths, 18, 20, 23 json_schema, 21, 23 json_structure, 21, 22 json_types, 11, 13, 17, 21, 23, 23 jstring, 28, 29 jstring (json_functions), 19 list_or_dots, 24 map_chr, 5 my_unlist, 25 path, 25 print.tbl_df, 26 print.tbl_json, 26 rbind_tbl_json, 26 read_json, 27 spread, 27–29 spread_all, 4, 10, 27, 29 spread_values, 10, 19, 28, 28 tbl_json, 3, 10, 11, 13, 16, 18, 20–24, 26–29, 30, 31, 33 INDEX tidyjson, 32 tidyjson-package (tidyjson), 32 worldbank, 32 wrap_dplyr_verb, 33
{"Source-Url": "https://cran.r-project.org/web/packages/tidyjson/tidyjson.pdf", "len_cl100k_base": 9665, "olmocr-version": "0.1.50", "pdf-total-pages": 35, "total-fallback-pages": 0, "total-input-tokens": 69419, "total-output-tokens": 11861, "length": "2e13", "weborganizer": {"__label__adult": 0.0002605915069580078, "__label__art_design": 0.00057220458984375, "__label__crime_law": 0.0001996755599975586, "__label__education_jobs": 0.00029277801513671875, "__label__entertainment": 9.1552734375e-05, "__label__fashion_beauty": 8.219480514526367e-05, "__label__finance_business": 0.00016570091247558594, "__label__food_dining": 0.0003407001495361328, "__label__games": 0.0005006790161132812, "__label__hardware": 0.0003609657287597656, "__label__health": 0.00013375282287597656, "__label__history": 0.00015819072723388672, "__label__home_hobbies": 8.475780487060547e-05, "__label__industrial": 0.00021314620971679688, "__label__literature": 0.000152587890625, "__label__politics": 0.00012600421905517578, "__label__religion": 0.0002665519714355469, "__label__science_tech": 0.005939483642578125, "__label__social_life": 8.952617645263672e-05, "__label__software": 0.03997802734375, "__label__software_dev": 0.94970703125, "__label__sports_fitness": 0.00012302398681640625, "__label__transportation": 0.00014889240264892578, "__label__travel": 0.00015878677368164062}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 37444, 0.01529]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 37444, 0.8319]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 37444, 0.6142]], "google_gemma-3-12b-it_contains_pii": [[0, 1198, false], [1198, 1453, null], [1453, 2823, null], [2823, 3686, null], [3686, 4228, null], [4228, 5182, null], [5182, 5862, null], [5862, 6497, null], [6497, 7334, null], [7334, 8976, null], [8976, 10774, null], [10774, 11855, null], [11855, 13233, null], [13233, 14462, null], [14462, 15339, null], [15339, 15952, null], [15952, 16939, null], [16939, 18256, null], [18256, 19273, null], [19273, 20430, null], [20430, 22069, null], [22069, 23388, null], [23388, 24929, null], [24929, 25794, null], [25794, 26423, null], [26423, 27164, null], [27164, 28317, null], [28317, 30048, null], [30048, 31450, null], [31450, 32458, null], [32458, 34041, null], [34041, 34934, null], [34934, 35738, null], [35738, 37356, null], [37356, 37444, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1198, true], [1198, 1453, null], [1453, 2823, null], [2823, 3686, null], [3686, 4228, null], [4228, 5182, null], [5182, 5862, null], [5862, 6497, null], [6497, 7334, null], [7334, 8976, null], [8976, 10774, null], [10774, 11855, null], [11855, 13233, null], [13233, 14462, null], [14462, 15339, null], [15339, 15952, null], [15952, 16939, null], [16939, 18256, null], [18256, 19273, null], [19273, 20430, null], [20430, 22069, null], [22069, 23388, null], [23388, 24929, null], [24929, 25794, null], [25794, 26423, null], [26423, 27164, null], [27164, 28317, null], [28317, 30048, null], [30048, 31450, null], [31450, 32458, null], [32458, 34041, null], [34041, 34934, null], [34934, 35738, null], [35738, 37356, null], [37356, 37444, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 37444, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 37444, null]], "pdf_page_numbers": [[0, 1198, 1], [1198, 1453, 2], [1453, 2823, 3], [2823, 3686, 4], [3686, 4228, 5], [4228, 5182, 6], [5182, 5862, 7], [5862, 6497, 8], [6497, 7334, 9], [7334, 8976, 10], [8976, 10774, 11], [10774, 11855, 12], [11855, 13233, 13], [13233, 14462, 14], [14462, 15339, 15], [15339, 15952, 16], [15952, 16939, 17], [16939, 18256, 18], [18256, 19273, 19], [19273, 20430, 20], [20430, 22069, 21], [22069, 23388, 22], [23388, 24929, 23], [24929, 25794, 24], [25794, 26423, 25], [26423, 27164, 26], [27164, 28317, 27], [28317, 30048, 28], [30048, 31450, 29], [31450, 32458, 30], [32458, 34041, 31], [34041, 34934, 32], [34934, 35738, 33], [35738, 37356, 34], [37356, 37444, 35]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 37444, 0.0]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
7ecb9278efa47409981ce389d6960d66f04ad46f
ICT PROJECT 258109 Monitoring Control for Remote Software Maintenance <table> <thead> <tr> <th>Project number:</th> <th>258109</th> </tr> </thead> <tbody> <tr> <td>Project Acronym:</td> <td>FastFix</td> </tr> <tr> <td>Project Title:</td> <td>Monitoring Control for Remote Software Maintenance</td> </tr> <tr> <td>Call identifier:</td> <td>FP7-ICT-2009-5</td> </tr> <tr> <td>Instrument:</td> <td>STREP</td> </tr> <tr> <td>Thematic Priority:</td> <td>Internet of Services, Software, Virtualisation</td> </tr> <tr> <td>Start date of the project:</td> <td>June 1, 2010</td> </tr> <tr> <td>Duration:</td> <td>30 months</td> </tr> </tbody> </table> Lead contractor: Lero Author(s): Benoit Gaudin, Mike Hinchey, Paddy Nixon, Raian Ali, Newres Al Haider. Submission date: November 2011 Dissemination level: Restricted Project co-founded by the European Commission under the Seventh Framework Programme © S2, TUM, LERO, INESC ID, TXT, PRODEVELOP Abstract: This document reports on a new version of the FastFix D6.3 deliverable, i.e. implementation of the 1st prototype of the FastFix self-healing and patch generation components. The initial goal of this deliverable has been modified in order to allow earlier implementation of the self-healing, hence an earlier evaluation of both the FastFIX self-healing and patch generation approaches. First this document recalls in Section 2 the main objectives and expected functionalities of these components, that will be developed as part of the FastFix project. Three main features of the self-healing components (model extraction, patch generation and runtime supervision) and their requirements are presented. Section 3 describes the current implementation of these features, corresponding to the delivery of this 1st prototype. It mainly focuses on the model extraction aspect on which the other ones are relying on. The extracted models are Finite State Machines (FSM). Section 3.2 describes the structure of these components and the constructs and specificities of the Java programming languages that it takes into account in order to extract Finite State Machines. The functionalities and usage of the implemented features are illustrated with an example in Section 4.1. Finally, Section 4 provides scalability results and describes the next steps to be performed from the implementation detailed in Section 3 in order to achieve the objectives described in Section 2. ## Contents 1 Introduction 4 2 Component Objectives 5 2.1 Conceptual Models for Self-Healing and Patch Generation 5 2.2 Requirements for the Self-Healing Component 7 2.3 Automatic Patch Generation Component 8 2.4 Existing Tools and Libraries 9 2.5 Summary 10 3 FastFixSH: 1st Prototype Iteration 11 3.1 Technology and Libraries Used 11 3.2 Self-Healing Component 12 3.2.1 Model Extraction 12 3.2.2 Supervisor Deployment 15 3.2.3 Runtime Monitoring and Supervisor (Patch) Application 18 3.3 Automatic Patch Generation Component 19 3.4 Summary and Limitations 20 4 Results and Next Steps 22 4.1 Illustrative Example 22 4.2 Scalability Results 26 4.3 Next Steps 30 Bibliography 31 1 Introduction This document reports on the implementation of the 1st prototype of the self-healing and FastFix patch generation components, FastFixSH (for FastFix Self-Healing). Unlike its initial version, this deliverable not only considers the 1st prototype of the patch generation component, but also the 1st prototype of the self-healing component. Therefore this deliverable presents limited patch generation capabilities but more developed self-healing features at this stage of the project. Such a modification will make it possible earlier evaluation of the FastFix self-healing and patch generation approach. New versions of deliverables D6.4 and D6.5 have also been considered and detailed in an updated version of the FastFix Description of Work. This report describes the current features of the prototype and the efforts provided, with respect to the functionalities to be achieved according to the conceptual model for FastFix self-healing and patch generation. This document first recalls in Section 2 the main objectives and expected functionalities of these components, that will be developed as part of the FastFix project. The contents of Section 2 recalls the FastFix conceptual models for self-healing introduced in [7]. More specifically, Section 2.1 recalls the three main features of the self-healing component: model extraction, patch generation and runtime supervision. Sections 2.2 and 2.3 respectively introduce requirements for the self-healing and patch generation components. Section 3 describes the current implementation of these features, corresponding to the delivery of this 1st prototype, and driven by the requirements described in Sections 2.2 and 2.3. It mainly focuses on the model extraction aspects on which the other ones rely on. Section 3.2 describes the structure of these components and the constructs and specificities of the Java programming languages that it takes into account in order to extract Finite State Machines. The functionalities and usage of the implemented features are illustrated with an example in Section 4.1. Finally, Section 4 provides results and describes the next steps to be performed from the implementation detailed in Section 3 in order to achieve the objectives described in Section 2. These results provide insights regarding the scalability of the model extraction and patch generation components. For this, it has been applied to three open source projects. Two of these projects possess more than 7000 method declarations. Scalability results regarding the runtime supervision mechanism require further development and improvement of the current implementation. Therefore, such results are not provided in this deliverable. 2 Component Objectives This section aims to position the current implementation of the FastFix self-healing and patch generation components with respect to the conceptual models described in the corresponding Conceptual Models deliverable (D6.2, [7]). First Section 2.1 recalls the conceptual models introduced in [7], then Sections 2.2 and 2.3 respectively provide requirements that drive our implementation for the self-healing and patch generation component prototypes. 2.1 Conceptual Models for Self-Healing and Patch Generation In this section, we recall notions about the conceptual models for self-healing and patch generation in FastFix. It is based on the corresponding deliverable: [7]. The FastFix platform follows the client-server architecture. Self-healing is involved in both the client and the server side. The server side is in charge of automatically extracting models from the application code as well as generating patches. The client side is in charge of supervision deployment and runtime execution. The 1st iteration of the self-healing and patch generation components do not follow this architecture, which will be achieved in a further version. However, it takes it into consideration by implementing the different features independently. Figure 2.1 gives an overview of the conceptual models for self-healing and patch generation in FastFix. The corresponding approach for self-healing can be split into three phases. The first phase occurs before the system is deployed and consists of extracting models of the application behaviors and deploying sensors with supervision capabilities into the application. The second phase of the approach occurs at runtime, where the application is under supervision. This supervision mechanism is based on deployed sensors and the previously extracted model of the system behaviors. At first this model of the system is used as a supervisor model, i.e. a patch, that has no impact on the implemented behaviors. The third phase corresponds to patch generation and occurs whenever an issue is detected in the application. The information sensed on the application is used to first generate a control objective, i.e. a pattern characterizing traces that lead to the observed issue. Such patterns are determined by the Event Correlation Component. In some cases, it can be achieved automatically. In other cases, this process may involve expertise and is performed manually or semi-automatically. From such patterns and the model of the application behaviors computed before deployment, the patch generator component computes new models of the behaviors of the system. These new models correspond to patched behaviors. When the application is relaunched, the new patch is taken into account by the sensors and actuators and they can observe and act on the system in order to prevent executions leading to the previously observed issue. The 3 phases for self-healing are represented in Figure 2.1 with the circles numbered 1, 2 and 3. Phase 1' corresponds to sensors and actuators deployment, which is performed through the Context System component and Phase 2' corresponds to the determination of a control objective, which is provided by the Event Correlation Component. In order to implement self-healing in FastFix, the self-healing component itself must implement: 1. a model extraction component. 2. a runtime supervision mechanism. 3. a patch generator component. Section 2.2 details the features that the model extraction component must achieve as well as the mechanism for runtime supervision of the application. Section 2.3 details features that must be implemented by the patch generator component. ![Figure 2.1: A Software Control Approach to Self-Healing.](image) The FastFix platform follows a client-server architecture. The self-healing component spreads over both the client and the server side. The patch generation component, which is part of the self-healing component is located on the server side, as well as the model extraction component. The client part of the self-healing mainly deals with the runtime supervision. This component is embedded into sensors which also contain models of patches and apply them using actuators. The observation made by these sensors are also passed onto the context system and then to the event correlation component on the server side. When an issue is detected, the observation received on the server side is analyzed in order to determine possible control objectives. These control objectives are used by the patch generation component in order to automatically compute a new model of the supervisor (patch) to be embedded in the target application. Once computed, this patch is sent to the client side and is applied using sensors/actuators. 2.2 Requirements for the Self-Healing Component This section details the features that the self-healing component must implement. It extends on the approach described in [7] by making explicit these feature requirements and their relevance. Although patch generation is part of the FastFix self-healing approach, the corresponding component features are detailed in Section 2.3. First of all, the FastFix self-healing approach is model-based and models are therefore required in order to perform self-healing. For a system to achieve self-healing principles, it must be able to automatically adapt. Models for possible adaptations are used at runtime for this effect. However, it may be difficult to automatically obtain such models. FastFix aims to provide a fully automated approach where models of the system behaviors are automatically computed from the application implementation. These models are the basis to other aspects of self-healing in FastFix, i.e. both the patch generation and runtime supervision. The models obtained by extraction must be: 1. Complete, i.e. if a piece of data is sensed at runtime, every occurrence of this sensed data should be part of the model. 2. Accurate, i.e. it must contain information that makes it possible to distinguish between different executions. 3. Scalable, i.e. the model extraction must be able to handle large pieces of software. The completeness of the model is a requirement related to the runtime supervision mechanism. This mechanism aims to keep track of the past execution and decide on whether future possible executions must be prevented. It is then important that the underlying models encodes the relationship between observed sequences of observations and future possible executions. If the model is incomplete and if an unexpected event occurs (an event whose occurrence was not modeled), then it is no more possible to apply supervision as the model not keeps tracks of the past execution of the running program anymore. Therefore, it is important that the model is complete so that no such unexpected event can occur. In the context of FastFix and the self-healing and patch generation component, model accuracy corresponds to the ability of distinguishing between different executions of the application. For instance, the Finite State Machine (FSM) represented in Figure 2.2 is complete as it can recognize any sequence of events. However, this model is not accurate as it does not make it possible to distinguish between 2 different sequences. Accuracy is an important requirement regarding the patch generation component. As described in [7], automatic patch generation in FastFix is achieved though supervisor synthesis, i.e. an FSM representing a supervisor (or patch) is automatically computed from FSMs modeling the applications behaviors and a property to be ensured on the system. The more accurate is the model of the system behaviors, the more accurate is the generated patch (i.e. supervisor). Although inaccurate patches still ensure the property provided for synthesis, they may prevent too many possible behaviors of the system in order to achieve this. In other words, the more inaccurate the model of the application behaviors, the more functionalities of the application might be prevented unnecessarily at runtime, when applying the patch. Finally, scalability must also be taken into account when extracting models. Usually, the more accurate is the model, the largest (in terms of state space) it is. One approach that is often considered to handle scalability issues when modeling systems with FSM is to model concurrency between the underlying system components. This is particularly relevant as large systems usually result from the composition of several components. ### 2.3 Automatic Patch Generation Component As explained in [7] and recalled in Section 2.1, patch generation is achieved in FastFix through supervisor synthesis, relying on the Supervisory Control Theory (SCT). This theory provides conditions and results for the automatic synthesis of models which ensure given properties. In FastFix this is applied in order to automatically generate models of supervisors which will be applied to the applications under maintenance at runtime. These supervisors ensure that executions leading to detected issues cannot occur anymore. Such supervisors are computed from models of the applications and a control objective, which models a property to be ensured (e.g. the avoidance of executions that lead to some issue). Figure 2.3 gives an example of Finite State Machine representing a possible control objective over a set of observable events $A$. This control objective indicates that any sequence of event is acceptable provided that either it only contains one occurrence of event 'b' which occurs at the end, or it contains at least three occurrences of event 'a' so that no 'b' can occur before the first and after the last 'a'. The main requirements the FastFix patch generation component aims to fulfill are: 1. Supervisor maximality. A supervisor is maximal if it ensures the control objective CO by only preventing executions that would break it, i.e. no un-necessary executions is prevented at runtime. 2. The expressiveness of the Control Objective (CO). Limiting the CO expressiveness may degrade the maximality of the computed supervisor, i.e. it may un-necessarily prevent some possible system executions. 3. Scalability. The models used for SCT are usually state machines. Their size relates to their number of states. The basic algorithms for supervisor synthesis are linear in the size of both the system model and the control objective. Although the synthesis algorithms are quite efficient, they require, in their basic forms, a model of the system represented by a single state machine. As large systems are usually composed of several components, this induces a state explosion problem when computing one single machines by composing the components’ ones. Distributed synthesis takes into account the concurrent nature of the system in order to efficiently compute a supervisor, avoiding the computation of a single machine. Several approaches have been considered in order to achieve this. They all rely on reducing the expressiveness of the control objective or by adding structural constraints on the system (e.g. regarding how the components interact). 2.4 Existing Tools and Libraries The self-healing and patch generation approaches in FastFix rely on the extraction of Finite State Machines from the application code, and the supervisory control theory that applies on these models in order to generate a supervisor that can be applied as a patch at runtime. Some libraries and tools exist in order to achieve either the model extraction or the supervisor synthesis. It is important to note that to our knowledge, no tool has ever combined both. This gap is one of the main factors that has prevented the application of the supervisory control theory to software systems so far. Being able to automatically extract Finite State Machines from software code will enable the application of this theory and allow for automatic computation of new behaviors. The Supervisory Control Theory (SCT) was initiated by Ramadge and Wonham in the early 80’s, see e.g. [10]. This theory aims to extends the principle of control theory to discrete event systems. It has mainly been considered at an academic level so far. Therefore libraries allowing for FSM manipulation and supervisory control have been developed by academic groups. Some of these libraries are now described. - TCT, STSLib (see e.g. [14]) are libraries implemented by the Systems Control Group of the University of Toronto. TCT was the first library implementing algorithms of the SCT. It offers all the features for supervisor synthesis in case of a system modeled as a single FSM. As this approach does not scale well, the STSLib was developed, which library relies on an efficient encoding of the models and provides dedicated algorithms, allowing for supervisor synthesis on larger systems. - UMDES Lib (see e.g. [13]) is developed by Discrete Event System Group of the University of Ann Arbor, Michigan. It is developed in C and provides similar features and scalability performance as TCT. Moreover, it has an emphasis on decentralized control techniques, i.e. when only partial views of the system are available. - Supremica (see e.g. [2]) is mainly developed by Department of Signals and Systems of the Chalmers University of Goetborg. It relies on similar principles to STSLib and also takes advantage of the concurrent structure of the system to be controlled. It also allows for simulation of the synthesized supervisor. SynTool (see e.g. [5]) is developed by the University of Rennes 1 in France as well as by Lero. It offers basic functionalities for supervisory control such as the ones provided by TCT and UMDES but it emphasizes control on concurrent systems, implementing the algorithms introduced in [5] in order to handle large systems. Regarding tools for model extraction, it is worthwhile noting that manually building Finite State Machines that represent the system behavior is tedious and error-prone. Therefore, approaches for automatically extracting FSM are crucial. For instance, Bandera (see e.g. [4]) allows for model extraction from Java programs. These Finite State Machines consider program variables. The different states of the FSM correspond to different values of the variables of the system. These FSM are therefore state oriented and their number of states depends on the possible value range of the system variables. Moreover, models are only from a subset of Java, leading to incompleteness. More recently, the authors of [8] considered an approach to extract FSM from several programming languages such as Java and C. Their approach is behavior oriented and considers method calls rather than system variables. The resulting extraction process is lightweight and the size of the extracted FSM remains reasonable for analysis. In this case again, the approach does not consider all of Java constructs and the extracted models are incomplete. ### 2.5 Summary This section recalled the conceptual models for self-healing and patch generation in Fast-Fix, and the corresponding features that must be implemented: model extraction, patch generation and runtime supervision. It also introduces requirements for these components: completeness, accuracy and scalability for model extraction and runtime supervision as well as expressiveness, maximality and scalability for patch generation. Section 3 describes the current implementation of the prototype of the self-healing and patch generation components. This implementation is performed taking into account the requirements listed above. The completeness of the extracted models is tackled by following the Java Language Specification ([9]) together with applying over-approximations on possible method calls. Their accuracy is tackled by limiting the use of these over-approximations as much as possible. The maximality of the patch generation is ensured by the supervisory control techniques that are considered and the maximality of the solutions obtained is currently limited the runtime supervision mechanism. Finally these requirements must be balanced with scalability. Section 4 provides details on the current implementation and gives indications regarding the scalability of the features implemented so far. 3 FastFixSH: 1st Prototype Iteration This section describes the choices made regarding the technology used to develop the FastFix self-healing and patch generation components. It also details the features implemented so far and relate these features to the objectives and challenges presented in Section 2.1. 3.1 Technology and Libraries Used The several prototypes of the FastFix platform will be developed using the Java language and the OSGi technology. The self-healing component follows this requirement and provides several features, implemented in Java. First, the 1st prototype of the model extraction component is developed as an Eclipse plugin and is detailed in Section 3.2. The first prototype of the patch generation component is based upon the SynTool library and is detailed in Section 3.3. The supervision deployment and runtime supervision mechanisms are respectively detailed in Sections 3.2.2 and 3.2.3. Figure 3.1 represents a screenshot of the eclipse plugin implementing the 1st FastFix self-healing prototype. As shown in the figure, this plugin makes it possible to extract a model of the system as well as to deploy the supervision mechanism into the target application and to generate patches. Figure 3.1: First prototype of the FastFix self-healing component. Tools and Libraries Reuse The models extracted from the Java source code are represented as Finite State Machines (FSM). In order to create and manipulate such models, the self-healing component will rely on the SynTool library (see [5]). As patch generation will also rely on the SynTool library, this will ease the compatibility between the extracted models and the ones required for patch generation. This library, which is developed by Lero, provides the following features. - Finite State Machines manipulation: this library provides functionalities to manipulate classical FSMs with sets of states (general, initial and final), an alphabet (i.e. set of events) and transitions (i.e. triples of the form \(<state, event, state>\)). SynTool provides usual FSM operations such as determinisation, reachability, co-reachability, product (parallel and synchronous), etc. Variables on the states or transitions are not taken into account by this library. - Concurrency: this library makes it possible to model concurrent FSMs on top of the usual monolithic representation, i.e. the product of 2 FSMs \(G_1\) and \(G_2\) is not explicitly computed but rather seen as a tuple \((G_1, G_2)\). This view of concurrent FSMs together with dedicated algorithms make it possible to take advantage of the system structure (i.e. concurrency) in order to perform usual tasks on FSM more efficiently. This avoids the construction of a monolithic representation of the concurrent FSMs, which is obtained by performing the product between them. The complexity of computing such a product of FSMs is exponential in the number of states of the FSMs involved in this product. - Supervisory Control: this library offers classical supervisory control algorithms when the model of the system to be controlled is represented as one single FSM and it also provides algorithms for efficient supervisory control on concurrent FSM. It makes it possible to handle system with several million states ([5]). 3.2 Self-Healing Component 3.2.1 Model Extraction As the FastFix self-healing approach is model-based and both patch generation and runtime supervision rely on these models, efforts on prototyping the FastFix self-healing component have been mainly put towards the development of the model extraction component. This component has been implemented as an Eclipse plugin (illustrated in Figure 3.1). Figures 3.2a and 3.2b illustrate its principle. Basically, the 1st prototype of the model extraction component considers method invocations and their corresponding method declarations. For instance, if we assume that method1 has been invoked in a piece of code of the target application, then a model of the behaviors of method1 is extracted from its declaration. Figure 3.2a describes the declaration of method1, which invokes method2, method3, method4 and method5. Figure 3.2b represents the FSM extracted from the declaration of method1. It shows that control flow statements such as IF-statements and FOR-statements are taken into account in the extracted model. In order to keep this example simple, it is assumed here that the declarations of method2 to method5 do not invoke any other method declared in the target application. If it was the case, these method invocations would appear in the FSM of Figure 3.2b as the extraction algorithm works recursively. Unlike for a classical call graph, the constructed models encodes branching, sequencing and loops. This allows for instance to deduct that method2 always follows method1 and that method5 occurs only after method3 has. Therefore, the extracted models are more accurate than a simple call graph would be. Figure 3.2: An example of method declaration and the corresponding FSM. At this stage of the implementation, the value of neither the program variables nor method parameters is taken into account. It is however planed that this will be the case in the 2nd prototype of this component. Therefore method invocations are seen as the basis of our application behavior modeling. First these invocations represent valuable information when debugging an application, as explained in [11]. Moreover, avoiding the variable analysis ensures better scalability of the approach. The development of the model extraction prototype is done following the Java Specification Language ([9]) as closely as possible. As there is no equivalence between the Java language and Finite State Machines, some approximations of the program behaviors are considered. Of course as completeness of the extracted models is a requirement (as explained in Section 2.2), these approximations must correspond to over-approximations. The example provided in Figure 3.2 is relatively simple and the 1st prototype of the model extraction component can take many more Java constructs into account: - Control Flow: - IF-statement, conditional expression (i.e. \(a ? b : c\)), Switch-statement, operators \(|, \&, \|, \&\&\). - FOR-statement, While-statement, Enhanced FOR-statement (i.e. “for (Object obj: Collection){...}”), enhanced While-statement. D6.3: 1st Prototype of the Self-Healing and Patch Generation Component - Break and Continue statements. - Recursiveness. - Method invocation occurrences: - In any Java expression, e.g. method parameters. - Class instance creations, super invocation. Moreover, in order for the model to be complete, the extracted models also take into account as closely as possible the Java runtime execution mechanisms in specific cases: - Exceptions. - Method overriding. - Class instance creation mechanism, e.g. instantiation of parent objects as well as class members. Finally concurrency is also taken into account by the 1st prototype of the model extraction component: - Runnable objects. - Thread objects. - Method invocations triggered by event listeners. This allows to capture in the extracted model user interactions such as button clicks. Taking into account the system concurrency is crucial in order to 1) obtain a complete model and 2) ensure scalability. Representing the composition of 2 concurrent FSMs $G_1$ and $G_2$ as one single FSM $G$ results in an FSM whose number of states is the product of the number of states of both composed FSM, i.e. if $G_1$ and $G_2$ both possess 10 states then $G$ will possess $10 \times 10$ states. This state explosion issue actually constitutes the main bottleneck for applying supervisory control on large systems (together with the absence of FSMs modeling the system behaviors). Figure 3.3: The model extraction component structure. Finally Figure 3.3 describes the structure of the model extraction component. First the SynTool library was extended with a FSM factory. This factory aims to create and combine FSMs. It contains methods to: - create new FSM objects with only one state and no transition (the only state must be initial and can be final), - create new FSM objects with only two states and one transition (the transition is in between the two states and the source of the transition is the initial state of the FSM. Both states can be final), - concatenate FSMs, i.e. two FSMs are merged into one so that the final states of one FSM are merged with the initial state of the other one. The resulting FSM represents the concatenation of the languages generated by the concatenated FSMs. This construct is useful to model program statement sequencing. - variations of the concatenation where the resulting FSM represents an over-approximation of the languages generated by the concatenated FSMs. - branch FSMS, i.e. two FSMs are merged into one so that the initial states of both FSMs are merged together. The resulting FSM represents the union of the languages generated by the branched FSMs. This construct is useful to model program branching such as IF-statements. - loop Fsm, i.e. an FSM loops over itself. The resulting FSM represents repetitions of sequences of the initial FSM, i.e. if the initial FSM generates the language $L$ then the resulting FSM generates the language $L^*$ or $L^+$ depending on how the final states of the resulting FSM are set. - add context to FSM states. This is for instance useful to keep track of states at which Break statements, Continue statements, Exception raises and recursiveness occur. The Scope and Binding component shown in Figure 3.3 aims to identify the method declarations in the code of the target application as well as the bindings that are necessary to make the link between method invocations and method declarations. Thankfully this part of the component can heavily rely on the Eclipse API for this task. Determining method bindings is a compilation activity, which is challenging for a language such as Java which allows for method overloading and overriding as well as generic parameters and return types. The contribution of the Scope and Binding part of the component mainly resides in making explicit a data structure that allows for easy binding between method invocations and method declarations of methods declared in the target applications. Finally, the FSM extractor is in charge of parsing the Eclipse AST tree, which models the code of the target application, and building FSMs using the FSM Factory and with respect to the different constructs encountered in the program code. ### 3.2.2 Supervisor Deployment The previous section described how the prototype for FastFix self-healing makes it possible to extract a model of the behavior of the target application to be FastFixed. This model D6.3: 1st Prototype of the Self-Healing and Patch Generation Component will be used in order to compute patches (i.e. new models) for the application behaviors. These patches will be applied by a supervisor on the application at runtime. At first, the model extracted as described in Section 3.2.1 can be used as a model of a supervisor. In this case, it does not control the target application at all, as it encodes all its possible behaviors. Whenever an issue is detected and automatic patch generation is computed, it results in a new model of a supervisor which will prevent some of the existing behaviors of the application from being executed. In any case, this supervisor/patch must be applied onto the target application at runtime. As explained in [7], within the FastFix framework, this supervision/patching mechanism will be performed at runtime through sensors and actuators. Therefore patch deployment can here be seen as deploying sensors. These sensors are deployed within the target application and embed a model of the supervisor. They will make it possible to sense information related to method calls, values of method parameters, threads and user input. Moreover, these sensors will also act on the system: they can refer to the embedded supervisor in order to decide whether they should prevent the execution of the observed method call or not. Therefore, the sensors observing the different method calls: 1. can communicate this information to the Context System (as any sensor would), 2. share some data locally (i.e. without referring to the Context System). The model of the supervisor represents such data, 3. and possess some local processing capabilities (i.e. without referring to the Context System), e.g. the ability to decide on whether the execution of a method body should be prevented or not, using the supervisor. This type of sensors are useful to synchronize the sensing/acting process with the execution of the target application. They enable decision making without the need to communicate with external components, e.g. Context System or Event Correlation component. Such communication would indeed introduce an important overhead when waiting for an external component on whether the method currently called should be executed. However, it is important to note that this approach does not remove the necessity of communicating the sensed values to the Context System. This enables computationally demanding analyses to be performed by external components, e.g. event correlation, fault replication and patch generation component on the FastFix server side. Such communication should be done in an asynchronous manner, i.e. the sensed value can reach the Context System any time after having been sensed. The 1st prototype of the self-healing component currently implements Points 2 and 3 above. Point 1) will be achieved in the next version of the prototype. Therefore the current version makes it possible to automatically deploy sensors and actuators but cannot yet transmit the sensed values to the Context System. Figures 3.4 and 3.5 illustrates the supervision mechanism deployment as currently implemented by the prototype, at the source code level. In this example, we consider the “main” method shown in Figure 3.4. This method calls the “invokeLater” method of the Swing library, which executes the Runnable object given as parameter on the Event Dispatch Thread. The execution performed by this thread is encoded by the “run” method of the anonymous class shown in this figure. This “run” method simply instantiates an object of the class “MainWindow2NoObs” and calls the “setVisible” method on this object. Figure 3.5 illustrates how the supervision mechanism is embedded in the code. For each method declaration in the target application, the body of the method is included in an IF-Statement. The condition of this statement calls the “accepts” method on an object named “controller” and added to the application implementation. It represents the model of a supervisor/patch previously computed. The “accepts” methods takes the name of the thread on which the method is called as well as the method name (the name generated for the compiler for the anonymous class is used in the case of the “run” method, i.e. “MainWindow2NoObs$9412”). The “accepts” method returns a boolean value which indicates whether the supervisor allows for the execution of the method body. If it does, then the body is executed. If it does not, then the execution of the method body is prevented. Such an instrumentation of the target application code is performed in an automated way, as well as the declaration and instantiation of the static controller object. Its instantiation actually corresponds to loading a file containing a model of a previously computed supervisor/patch. 3.2.3 Runtime Monitoring and Supervisor (Patch) Application The previous section explains the automated supervision deployment mechanism. Once the controller object of Figure 3.5 instantiates a model of the supervisor, it needs to update its current state which evolves when a method is called and accepted. The FSM automatically extracted from the code of the application must take into account dynamic concurrency in programs, i.e. the number and type of involved FSM varies over time. However, as being extracted from a static artifact (source code), it does not fully achieve this goal. For instance, this model does not indicate which FSM can run simultaneously and on which threads. It is however typical for a software program to run on several threads where the piece of code running on a given thread varies over time as well as the set of current running threads. In order to take into account the dynamic related to threads and graphical components, we implemented a specific FSM execution mechanism. Unlike the standard execution mechanism on FSMs, it considers that only a subset of the FSMs may run simultaneously. This mechanism is embedded in the implementation of the supervisor that is deployed as described in Section 3.2.2 and consists in - mapping at runtime the observed current thread and method call to the appropriate running FSM in order for it to update its current state, - mapping at runtime the observation of a triggering event, i.e. the first event that can be triggered from a FSM such as “main” methods, “run” methods for threads and “actionPerformed” methods, to the corresponding FSM, even when it is not already running, i.e. it is currently not involved in the program execution. Moreover, it is important to note that the supervisor embedded in the FastFix target application is a synchronized object and it is therefore safe to call it form different threads. Such an approach makes it possible for the supervisor to make decision about the concurrency of the target application, e.g. deadlock avoidance. However, this introduces some extra concurrency between threads, i.e. threads have to share an extra resource: the supervisor. Finally in FastFix, patches that are generated automatically correspond to supervisor models and are applied to the target application by controlling the application behaviors according to these models. In order to achieve this, the FastFix self-healing component relies on the SynTool library (see e.g. Section 2.4) and extends it. However, as explained in Section 3.3, these generated models are different from the ones automatically extracted and that are considered in this section. Therefore some adaptation of the existing supervisor synthesis algorithm were considered in order to overcome this issue. ### 3.3 Automatic Patch Generation Component Patch Generation is actually part of the self-healing approach. It corresponds to combining the model of the target application with the observations of undesired behaviors in order to create a model of a patch that will prevent future occurrences of these undesired behaviors. The models manipulated by this component are Finite State Machines (FSM) and it relies on the FSM library SynTool (e.g. see Section 2.4) for supervisory control. This library contains algorithms to manipulate FSMS and compute models of supervisors/controllers, which can be used as patches in FastFix. This library is particularly suitable for systems modeled as a composition of concurrent sub-systems. However, it considers that the components running in a concurrent manner is fixed over time. Therefore, it does not deal with dynamically changing thread processing, unlike the runtime model presented in Section 3.2.3. Regarding the current implementation of SynTool’s supervisor synthesis (i.e. automatic patch computation), it does not handle the case where several instances of the same process features run in parallel and especially when the number of such instances that can run in parallel is unknown during analysis. However, this can for instance occur when threads are created and started in the body of a loop, or whenever a user presses a specific button. Although this features will be implemented in the course of the project, this first prototype is limited to the implementation of an intermediary case. This corresponds to the case where no more than one instance of each extracted FSM can be executed at a given time and the control objective must describe whether method calls occur on similar threads or not. This already improves the current implementation of SynTool has it allows for not all the FSM to be executed at the same time and for an FSM to be executed on different threads over time (provided that the previous executions were completed). This new feature is achieved by: - Implementing a renaming of the labels of the FSMs automatically extracted, i.e. making these FSM behaving in an asynchronous fashion with respect to each other. - Implementing a FSM transformation that generates repeated behaviors of the initial FSM. This is done with a similar algorithm to the one that creates a looping FSM in the FSM factory presented in Section 3.2.1. This transformation is important in order to generate patches that take into account that the execution of some methods may be repeated on different threads over time. Once these transformations are performed on the FSMs that were automatically extracted, then the SynTool supervisors synthesis functionality can be applied in order to produce a model of a supervisor. This approach ensures the requirement regarding the maximality of computed solution, i.e. the solution is the most permissive supervisor ensuring the control objective on the system model. Finally, the generated model does not match the one presented in Section 3.2.3 (e.g. regarding its concurrency and dynamic). Therefore a mapping between these two types of model was also implemented so that the supervisor could be consulted in an appropriate way at runtime, i.e. so that the computed patch could be applied at runtime. ### 3.4 Summary and Limitations Section 3 describes the implementation of the model extraction, runtime supervision and patch generation mechanisms. This implementation is driven by the requirements provided in Section 2. - In order to achieve completeness, the implementation of the model extraction component considers the Java Specification Language in order to identify and take into account all the Java constructs from which methods can be called. - Although over-approximations are necessary when extracting models of method calls, this implementation takes accuracy into account by avoiding unnecessary approximations. - The program concurrency is taken into account in order to limit the size of the extracted model. Concurrent Finite State Machine are extracted instead of a single one. - Specific supervisor/patch synthesis for concurrent FSM are applied in order to tackle the scalability issue that may raise during patch generation. - Moreover, this synthesis algorithm ensures not only the patch correctness but also its maximality (i.e. it restricts the behaviors of the application model as little as possible). However, the current implementation of this first prototype induces some limitations: - The expressiveness of the control objectives is limited to properties that do not involve two different instances of the same method running on different threads. - The libraries and other project dependencies of the target application to be Fast-Fixed must not invoke methods from this application, i.e. only one-way dependencies are authorized (the components that the target application depends on must not depend on the target application). --- 1The implementation of this mapping is part of component in charge of encoding the runtime models, more than the patch generation component. However, this mapping is strongly dependent on the type of models that are generated. • Completeness of the extracted model is not guaranteed if some graphical components do not run on the event-dispatcher thread. Best practices in Java actually require so, through the use of the SwingUtilities.invokeLater method. • The initial method from which the FSMs are built (usually the "main" method) should not be in the default package but in a named one. • It cannot include in the FSM extracted models, events corresponding to the invocation of super constructors. It is important to note that the FSM modeling the execution these super methods are still extracted. Only the event representing the call of these super methods are not part of the model. This limitation is expected to be relieved in a future version of the prototype. 4 Results and Next Steps 4.1 Illustrative Example This section illustrates the use of the 1st prototype of the FastFix self-healing component. It considers a rather simple example and focuses on the main concepts of the approach: model extraction, supervision deployment and patch generation. The example under consideration is the one of a calculator implemented in Java and using the Swing Library. This calculator implements basic operations on integer. However, the exception that may be raised from dividing by zero is not handled. It is assumed in this example that this issue is present in the deployed application, i.e. it was not caught during the testing phase and its presence is therefore unknown. Although the error presented in this example is quite simple, it is characteristic of a larger class of errors, e.g. where some exceptions are not handled and are raised whenever the user performs actions in an order that the developer has not planned for. ![Figure 4.1: An illustrative Calculator Example.](image) In this example, we illustrate how the 1st prototype of the FastFix self-healing component can be used in order to overcome the possible occurrences of issues at runtime. Figure 4.2 shows a screenshot of the Eclipse plugin that was developed and that implements this first prototype. This Plugin provides a “Self-Healing” menu which gives access to the three main functionalities of the FastFix self-healing approach (see Section 2.1): model extraction, supervision mechanism and patch generation. First, models must be extracted from the code of the FastFix target application, i.e. the calculator in this case. By clicking the “Extract FSM” item of the self-healing menu in Figure 4.2, the FastFix user automatically retrieves Finite State Machines (FSM) representing the behaviors of the application, in terms of method calls. This extraction takes into account Swing components (more specifically the concurrency introduced by the event listeners) and thread creation (in this case, and following good practices in Java Swing, the graphical components are instantiated on a dedicated thread). Moreover, this D6.3: 1st Prototype of the Self-Healing and Patch Generation Component extraction is performed from the “main” method of the target application, as shown by the selection of this method in the Eclipse Outline View, on the right hand side of Figure 4.2. The FSM computed in this case encodes all the possible sequences of method calls that can occur at runtime from calling this main method. 18 FSM were extracted in this case: 1 for each of the event listeners associated to the 16 buttons of the application, 1 for the main method and 1 for the execution of the thread instantiating the graphical components. These FSMs represent the possible sequence of method calls that can occur from calling the main method, or clicking one of the buttons, or starting the Event Dispatch Thread on which are instantiated the graphical components. Figure 4.2: Eclipse implementation of the prototype of model extraction approach. Figure 4.3 represents the FSM extracted from the “actionPerformed” method of the event listener associated to the “divide” button. As the application is relatively simple, it is not surprising that the FSM obtained also are quite simple. This FSM indicates that whenever the actionPerformed method is called, it is followed by the call of a method called “process”. The “process” method is actually in charge of processing the values entered into the calculator according to the value of the operation button which is clicked. Section 4.2 provides preliminary results regarding the scalability of the 1st prototype of the FastFix model extraction component. D6.3: 1st Prototype of the Self-Healing and Patch Generation Component Once the Finite State Machine representing the behaviors of the target application are extracted, then the supervision mechanism must be deployed in the application (see Section 3.2.2). This action is performed automatically by clicking the “Deploy Supervision Mechanism” item of Figure 4.2. For this 1st prototype, deployment of the supervision mechanism is achieved through source code instrumentation as illustrated in Figure 4.4. This instrumentation consists first of automatically introducing a controller (i.e. supervisor) object in the program. Before any patch is computed, this supervisor is first instantiated as to implement the model of the application which was previously extracted. Then instructions are added to methods in order to surround their bodies with IF-THEN statements. The condition evaluated in the IF part corresponds to the acceptance by the supervisor of the execution of the method body (in Figure 4.4, this corresponds to calling the method “accepts” on the controller object). If the controller accepts the method execution, then its body is executed. If it does not accept the method execution, then no statements are executed at all. The call of the accept method not only returns the decision made by the controller at a given point of the program execution, it also updates the current state of the model to the one reached by accepting the current method execution. This makes it possible for the controller to take decisions according to the past execution. Figure 4.3: Finite State Machine automatically extracted and representing the possible executions from pressing the “Divide” button. --- \(^2\) Other approaches could be considered here, such as displaying a warning message to the user. Once models have been extracted and the supervision mechanism has been deployed, then the application can itself be deployed to users environment. Thanks to the embedded supervisor, the deployed application can monitor itself. When a user attempts a division by zero, such an exception is raised, exhibiting the need of a patch. A patch is obtained by automatically synthesizing a model of a new supervisor, using the previously extracted model of the application as well as a control objective. In future versions of the FastFix prototypes and whenever it will be possible, this control objective will be computed from the sequence of method calls that lead to the observed exception and will be provided by the correlation system. As for now, it is designed manually and is represented in Figure 4.5. Because of the size of its labels, this Finite State Machine is only partially represented in this figure. However, it is a relatively simple machine as it only contains three states (2 of them are represented in Figure 4.5). This FSM simply describes that the actionPerformed methods associated to operator buttons, i.e. $+, -, *, /$, should not occur after the user has clicked the “divide” button followed by the “zero” button. From the models previously extracted and the control objective of Figure 4.5, a new model of a supervisor is automatically computed. This is achieved by clicking the “patch Generation” item of the menu presented in Figure 4.2. This computation relies on an extension of supervisory control algorithms, as explained in Section 3.3. These algorithms take into account than not any method body execution can be prevented (i.e. not every method is controllable). In order to ensure the system stability at runtime, only methods that are not called from other methods are assumed to be controllable, i.e. the main method and all the actionPerformed methods associated to button clicks in this example. Preventing the execution of a method bodies that are called form other methods may indeed lead to issues. The prevented execution could compute new objects and assign others with values that are expected later in the execution. The concept of controllability of the supervisory control theory is therefore extremely useful in order to guarantee the correctness of the computed patch. Once this new supervisor, i.e. patch, is computed, then the file containing the previous model of the supervisor on the user environment is replaced with the newly computed one. When the target application is relaunched, this new file becomes the one from which is instantiated the controller object that appears in the code of Figure 4.4. With this controller, the execution of the body of the actionPerformed method is prevented whenever the user has just clicked the “divide” button followed by the “zero” button. It is important to note that the execution of the body of this actionPerformed method is executed normally in any other cases, hence only preventing executions that can lead to an exception. 4.2 Scalability Results In this section, we present preliminary results on the model extraction component. More specifically, this component was applied to three different target applications from the open source community: Avrora, Sunflow and JEdit. Avrora is a processor simulator and is part of the Dacapo benchmark ([3]). Sunflow is a rendering system for image synthesis and is also part of the Dacapo benchmark ([12]). Finally JEdit is a programer’s text editor ([1]). It is an Eclipse-like editor which can be extended with plugins. Avrora, Sunflow and JEdit are all written with the Java language. Figure 4.6 illustrates the application of the model extraction component to the Sunflow system. In this figure an "actionPerformed" method associated to a task cancellation button is selected. Figure 4.7 shows the generated FSM for this actionPerformed method. First the method “taskCancel” is called, which itself calls a “printInfo” method which itself calls a “print” method. This section provides scalability results for the current implementations of the model extraction and the patch generation components. Runtime supervision scalability study requires that the extracted models are complete. Although our methodology follows the Java Specification Language in order to ensure this, it is not fully achieved yet and improvements must be made in this direction. Therefore the results provided in this section focus on the model extraction and patch generation. These evaluations were performed with a MacBook Pro Dual Core i7, with a frequency of 2.66 GHz and 4GB of RAM. Table 4.1 summarizes results obtained when applying the model extraction component to the three different target applications: Avrora, Sunflow and JEEdit. It contains information regarding the target applications as well as times taken by the different model extraction computation phases. First of all, the amount of method declarations is provided for each target application, as an indicator of their size. Avrora and JEdit possess a rather similar amount of method declarations (around 8000), while Sunflow only possess 1500 ones. The model extraction consists of several phases, all reported in Table 4.1: Scope and Binding computation, FSM construction computation, FSM determinization computation and FSM saving computation. From a user’s point of view, the total time taken to obtain a file containing the model of the system is represented by the “Total Time”, which sums up the times obtained for each computation phases. The Scope and Binding computation represents the analysis of the code that is first performed in order to limit the model extraction to method invocations whose corresponding method is declared by the target application, e.g. methods declared in java.* libraries are not taken into account in the model extraction. The FSM computation corresponds to going through all the method invocations from a given point in the program, taking into account the program control flow, and building the corresponding FSMs. This process also takes into account concurrency, with the computation of separate FSM for the different threads, runnable objects and event listeners instantiated by the application. FSM determinization is known for not being efficient in the worst case: it is exponential in the size of the FSM to be determinized. However, this complexity depends on the amount of indeterminism of the initial FSM, which in our case is partly introduced by the FSM construction process. The results obtain in Table 4.1 suggest that the efficiency of determinizing the constructed FSMs is of similar order as building these FSMs. Finally the necessary time for saving the determinized FSMs is provided as hard drive access may induce a quite important overhead in the process, as shown in the case of JEdit where there are numerous FSMs to be saved and where three of them possess more than 1000 states (the largest one possessing about 2600 states). Overall, the approach for model extraction appears to be feasible for applications with several thousands method declarations and generating up-to at least 80 FSMs. This corresponds to gigantic state spaces for these models: Sunflow has at least $2^{27} \times 527$ states while JEdit has at least $2^{83} \times 2588$ states! As the model extraction is performed off-line and is a once-off computation, a duration of several minutes for it is acceptable. <table> <thead> <tr> <th></th> <th>Avrora</th> <th>Sunflow</th> <th>JEdit</th> </tr> </thead> <tbody> <tr> <td>Method Declarations</td> <td>8889</td> <td>1508</td> <td>7420</td> </tr> <tr> <td>Scope and Binding Time</td> <td>16236 ms</td> <td>3555 ms</td> <td>22056 ms</td> </tr> <tr> <td>FSM Computation Time</td> <td>1269 ms</td> <td>981 ms</td> <td>112279 ms</td> </tr> <tr> <td>FSM Determinisation Time</td> <td>355 ms</td> <td>384 ms</td> <td>126256 ms</td> </tr> <tr> <td>FSM Saving Time</td> <td>84 ms</td> <td>991 ms</td> <td>202604 ms</td> </tr> <tr> <td>Total Time</td> <td>17.94 sec</td> <td>5.91 sec</td> <td>7 min 43 sec</td> </tr> <tr> <td>Number of FSMs</td> <td>1</td> <td>28</td> <td>84</td> </tr> <tr> <td>Largest FSM</td> <td>201</td> <td>527</td> <td>2588</td> </tr> <tr> <td>Smallest FSM</td> <td>201</td> <td>2</td> <td>2</td> </tr> <tr> <td>Model (Patch) Size</td> <td>37 KB</td> <td>406 KB</td> <td>9.6 MB</td> </tr> </tbody> </table> Table 4.1: Preliminary results on FSM extraction scalability. The size of the generated models is also considered. Table 4.1 indicates for each target application, the amount of FSMs generated, the size of the largest and smallest FSM generated and finally the size of the file containing these FSMs. This table shows that although Avrora possesses many more method declarations than Sunflow, the model generated for it, is substantially smaller (201 against an estimated number of states of $2^{27} \times 527$). This shows that although the amount of method declarations in a target application is an interesting indicator, it is not sufficient in general to estimate the complexity of the generated models. Also, the size of the files containing the generated models can itself vary substantially. As shown in Table 4.1 it ranges between 37KB to nearly 10MB, for the three target applications considered. <table> <thead> <tr> <th>Control Objective Number of States</th> <th>Avrora</th> <th>Sunflow</th> <th>JEdit</th> </tr> </thead> <tbody> <tr> <td>5</td> <td>0.172 s</td> <td>2.015 s</td> <td>5 min 41 s</td> </tr> <tr> <td>10</td> <td>0.363 s</td> <td>3.397 s</td> <td>9 min 34 s</td> </tr> <tr> <td>50</td> <td>0.895 s</td> <td>11.533 s</td> <td>42 min 57 s</td> </tr> </tbody> </table> Table 4.2: Results on patch generation scalability. Finally, Table 4.2 provides scalability results regarding the patch generation component. The purpose of this evaluation is to obtain indications about the scalability of computing patch, with respect to the control objectives size. In order to achieve this, random FSMs with a given number of states were generated. Although randomly created, these control objectives follow a similar structure to the one of the control objective of the calculator example of Section 4.1, i.e. they accept any trace observed from the target application except for a the one finishing with a specific sequence. In the example of Section 4.1, every sequence except for the ones finishing by the sequence “divide”, “zero”, “equal” (or “divide”, “zero”, “plus”, etc) are accepted. In this example, the corresponding FSM possesses three states. For this evaluation, we consider control objectives encoding a similar pattern where the length of the finishing sequence has 5, 10 or 50 states. Although more evaluation will need to be performed to this respect, it is expected that control objective will be encoded with FSM with less than 50 states, as the number of states in this case represents the number of relevant events necessary to characterize the application traces that are not desired, i.e. events involved in describing a pattern of a bad trace. The algorithm used for patch computation are implemented in SynTool and described in [6]. It takes advantage of the concurrent nature of the model and computes one supervisor over each component instead of a global one. The complexity of this algorithm is linear in both the size of the component and the control objective. Table 4.2 indicates the time required to compute patches for the generated control objectives. The case of Avrora shows the time taken for a model with one single FSM of about 200 states. It takes less than a second to compute a patch, even for a control objective that possesses 50 states. As shown with Sunflow application, it takes only a few seconds to compute a patch for a model consisting of 28 FSMs where some of them have a few hundred states. The model of JEdit is at a different scale with more than 80 FSMs with several of them having more than 1000 states, the largest one possessing about 2500 states. The computation of a patch for this application takes several minutes for control objectives with less than 10 states and around 43 minutes for a control objective. D6.3: 1st Prototype of the Self-Healing and Patch Generation Component with 50 states (the computation of a patch for the FSM with 2500 states takes about 16 minutes). These figures demonstrate the feasibility of applying supervisory control on models extracted from software code. It is important to note that these figures can be improved by combining the algorithm used in Table 4.2 to other approaches which allow for instance to select a subset of FSM on which to compute patches. 4.3 Next Steps The work that will be conducted after this implementation of the 1st prototype of the FastFix self-healing component follow three different directions. First, an immediate step is about more evaluation and improving the current prototype. Especially, some evaluation of the overhead induced by the supervision mechanism must be performed. In order to achieve this, we consider the Dacapo benchmark which provides open source applications and associated test cases. Although these test cases do not exhibit any issue of these applications, they make it possible to reproduce their executions. A comparison of the time required to reproduce these executions with and without deployment of the supervision mechanism will provide an estimation of the overhead induced by our approach. Secondly, an important next step is about interaction and better integration of the self-healing component with the other FastFix components. At present, all these components fit within a unique OSGI architecture. However, no interaction between the self-healing component and others is available yet. One of the next steps towards such interactions concerns the unification of the sensing systems, i.e. the context system sensors and the embedded supervisor. Another aspect is the communication between the event correlation and the patch generation components so that control objectives can be automatically provided to the patch generator. These considerations about component interactions must also fit in the client-server architecture of the FastFix platform. Finally, a third direction to consider is the improvements of the self-healing component itself, through research. This research must include the management of dynamic concurrent systems in order to overcome the issue raised in Section 3.3. It should also include the management of the values of some of the system variables and in particular of the user input, in order to drive the patch generation, e.g. the execution of some methods may be prevented depending on the values of their parameters. The second iteration of the FastFix self-healing prototype will aim to tackle these different aspects. Bibliography D6.3: 1st Prototype of the Self-Healing and Patch Generation Component
{"Source-Url": "http://fastfixrsm.sourceforge.net/fastfix-project/sites/default/files/Deliverables/D6.3.pdf", "len_cl100k_base": 13540, "olmocr-version": "0.1.51", "pdf-total-pages": 32, "total-fallback-pages": 0, "total-input-tokens": 60766, "total-output-tokens": 15636, "length": "2e13", "weborganizer": {"__label__adult": 0.00026607513427734375, "__label__art_design": 0.000255584716796875, "__label__crime_law": 0.0002579689025878906, "__label__education_jobs": 0.000499725341796875, "__label__entertainment": 4.571676254272461e-05, "__label__fashion_beauty": 0.00011855363845825197, "__label__finance_business": 0.00016164779663085938, "__label__food_dining": 0.00021386146545410156, "__label__games": 0.0004725456237792969, "__label__hardware": 0.000690460205078125, "__label__health": 0.0002999305725097656, "__label__history": 0.0001857280731201172, "__label__home_hobbies": 6.663799285888672e-05, "__label__industrial": 0.0003104209899902344, "__label__literature": 0.0001571178436279297, "__label__politics": 0.00018715858459472656, "__label__religion": 0.0003192424774169922, "__label__science_tech": 0.0110321044921875, "__label__social_life": 6.216764450073242e-05, "__label__software": 0.005870819091796875, "__label__software_dev": 0.9775390625, "__label__sports_fitness": 0.0002257823944091797, "__label__transportation": 0.0003819465637207031, "__label__travel": 0.00016045570373535156}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 69210, 0.03778]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 69210, 0.42261]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 69210, 0.93067]], "google_gemma-3-12b-it_contains_pii": [[0, 826, false], [826, 2300, null], [2300, 3037, null], [3037, 5746, null], [5746, 8411, null], [8411, 10517, null], [10517, 13852, null], [13852, 15950, null], [15950, 19250, null], [19250, 22029, null], [22029, 23320, null], [23320, 26465, null], [26465, 28395, null], [28395, 29885, null], [29885, 32832, null], [32832, 35584, null], [35584, 36070, null], [36070, 39551, null], [39551, 43023, null], [43023, 45655, null], [45655, 46403, null], [46403, 48545, null], [48545, 50125, null], [50125, 51935, null], [51935, 53169, null], [53169, 55946, null], [55946, 56837, null], [56837, 60056, null], [60056, 63747, null], [63747, 66404, null], [66404, 68674, null], [68674, 69210, null]], "google_gemma-3-12b-it_is_public_document": [[0, 826, false], [826, 2300, null], [2300, 3037, null], [3037, 5746, null], [5746, 8411, null], [8411, 10517, null], [10517, 13852, null], [13852, 15950, null], [15950, 19250, null], [19250, 22029, null], [22029, 23320, null], [23320, 26465, null], [26465, 28395, null], [28395, 29885, null], [29885, 32832, null], [32832, 35584, null], [35584, 36070, null], [36070, 39551, null], [39551, 43023, null], [43023, 45655, null], [45655, 46403, null], [46403, 48545, null], [48545, 50125, null], [50125, 51935, null], [51935, 53169, null], [53169, 55946, null], [55946, 56837, null], [56837, 60056, null], [60056, 63747, null], [63747, 66404, null], [66404, 68674, null], [68674, 69210, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 69210, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 69210, null]], "pdf_page_numbers": [[0, 826, 1], [826, 2300, 2], [2300, 3037, 3], [3037, 5746, 4], [5746, 8411, 5], [8411, 10517, 6], [10517, 13852, 7], [13852, 15950, 8], [15950, 19250, 9], [19250, 22029, 10], [22029, 23320, 11], [23320, 26465, 12], [26465, 28395, 13], [28395, 29885, 14], [29885, 32832, 15], [32832, 35584, 16], [35584, 36070, 17], [36070, 39551, 18], [39551, 43023, 19], [43023, 45655, 20], [45655, 46403, 21], [46403, 48545, 22], [48545, 50125, 23], [50125, 51935, 24], [51935, 53169, 25], [53169, 55946, 26], [55946, 56837, 27], [56837, 60056, 28], [60056, 63747, 29], [63747, 66404, 30], [66404, 68674, 31], [68674, 69210, 32]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 69210, 0.10277]]}
olmocr_science_pdfs
2024-12-04
2024-12-04
e64049ee9298a4b3edc515142d47ec49030881e1
11. Transceiver Link Debugging Using the System Console This chapter describes how to use the Transceiver Toolkit in the Quartus® II software. The Transceiver Toolkit in the Quartus II software allows you to quickly test the functionality of transceiver channels and helps you improve the signal integrity of transceiver links in your design. You can use an example design available on the Altera® website if you want to immediately start using the Transceiver Toolkit, or you can create a custom design. In today’s high-speed interfaces, stringent bit error rate (BER) requirements are not easy to meet and debug. You can use the Transceiver Toolkit in the Quartus II software to check and improve the signal integrity of transceiver links on your board before you complete the final design, saving you time and helping you find the best physical medium attachment (PMA) settings for your high-speed interfaces. This chapter contains the following sections: - “Transceiver Toolkit Overview” - “Transceiver Link Debugging Design Examples” on page 11–3 - “Setting Up Tests for Link Debugging” on page 11–3 - “Using Tcl in System Console” on page 11–13 - “Usage Scenarios” on page 11–14 - “Quick Guide to Using the Transceiver Toolkit in the Quartus II Software” on page 11–18 Transceiver Toolkit Overview The underlying framework for the Transceiver Toolkit is the System Console. The System Console performs low-level hardware debugging of your design. The System Console provides read and write access to the IP cores instantiated in your design. Use the System Console for the initial bring-up of your PCB and low-level testing. For information about the System Console, refer to the Analyzing and Debugging Designs with the System Console chapter in volume 3 of the Quartus II Handbook. For more information about getting training to use the System Console, refer to the Altera Training page of the Altera website. The Transceiver Toolkit allows you to perform run-time tasks, including performing high-speed link tests for the transceivers in your devices. The Transceiver Toolkit allows you to test your high-speed interfaces in real-time. To launch the Transceiver Toolkit, in the main Quartus II window, on the Tools menu, click Transceiver Toolkit. Transceiver Toolkit User Interface The Transceiver Toolkit has an intuitive GUI that you open from the Tools menu of the Quartus II software. It is designed to be run from within the System Console framework. The interface is a window that consists of four panes. A left navigation System Explorer shows you connection information for the system you are testing, including designs, design instances, and scripts. Once you load a project in the System Console, all the design information is populated under the System Explorer. The Messages pane shows error messages and warnings for any actions you perform in other panes. You can enter Tcl commands through the Tcl Console pane. Most of the actions you can perform in the GUI can also be performed with Tcl commands. Most Tcl commands are listed in this chapter. The Transceiver Toolkit Channel Manager GUI consists of three tabs, including the Transmitter Channels tab, the Receiver Channels tab, and the Transceiver Links tab. These tabs have various control buttons, which you click to open the Auto Sweep Control panel and the EyeQ panel. From these three tabs you can also open Control Channel and Control Link panels, which allow you to view and modify transceiver and test settings. You can open Link Control Channel For more information, refer to About the Transceiver Toolkit in Quartus II Help. Transceiver Auto Sweep You can sweep ranges for your transceiver PMA settings and run tests automatically with the auto sweep feature. You can store a history of the test runs and keep a record of the best PMA settings. You can then use these settings in your final design. For more information, refer to the Transceiver Auto Sweep Panel in Quartus II Help. Transceiver EyeQ You can determine signal integrity with the EyeQ feature. The EyeQ feature in the Transceiver Toolkit allows you to create a bathtub curve or eye diagram (Stratix V) to have a metric other than BER to measure signal quality. After you run the EyeQ feature you can view the data in the Report pane of the Transceiver Toolkit and export the data in Comma-Separated Value (.csv) format for further analysis. For more information about the EyeQ feature, refer to Working with the Transceiver Toolkit in Quartus II Help. For more information, refer to AN 605: Using the On-Chip Signal Quality Monitoring Circuitry (EyeQ) Feature in Stratix IV Transceivers. Control Links You can test the transmitter and receiver channel links in your design in manual mode with the channel control features. The channel control panels allow you to view and manually modify settings for transmitter and receiver channels while the channels are running. For more information about the Transceiver Toolkit, refer to Working with the Transceiver Toolkit in Quartus II Help. Transceiver Link Debugging Design Examples Altera provides design examples to assist you with setting up and using the Transceiver Toolkit. To learn more about the version of the Quartus II software used to create these design examples, the target device, and development board details, refer to the readme.txt of each example. Each example is verified and tested with the Quartus II software version referenced in the readme.txt. However, you may be able to use these examples with a later version of the Quartus II software. If you are recompiling the design examples for a different board, refer to “Changing Pin Assignments” on page 11–8 to determine which pin assignments you must edit. Download the Transceiver Toolkit design examples from the On-Chip Debugging Design Examples page of the Altera website. For a quick guide to using design examples with the Transceiver Toolkit, refer to “Working with Design Examples” on page 11–19. Setting Up Tests for Link Debugging Testing signal integrity for high-speed transceiver links involves using data patterns, such as pseudo-random binary sequences (PRBS). Although the sequences appear to be random, they have specific properties that you can use to measure the quality of a link. In the example designs available on the Altera website, data patterns are generated by a pattern generator and are then transmitted by the transmitter. The transceiver on the far end can then be looped back so that the same data is then received by the receiver portion of the transceiver. The data obtained is then checked by a data checker to verify any bit errors. Figure 11–1 and Figure 11–2 show examples of the test setup for the transceiver link debugging tool. The figures show a setup that is similar to the design examples that you can download from the On-Chip Debugging Design Example page of the Altera website. You can also have the transmitter on one FPGA and the receiver on a different FPGA. Figure 11–1. Transceiver Link Debugging Tool Test Setup Figure 11–2 shows a similar test setup for the second design example described in this section, except that there are four sets of transceivers and receivers rather than one. Figure 11–2. Transceiver Link Debugging Tool Test Setup (Four Channels) The design examples use the Qsys system integration tool and contain the following components: Chapter 11: Transceiver Link Debugging Using the System Console Transceiver Link Debugging Design Examples - Custom PHY IP Core or Low Latency PHY IP Core - Avalon-ST Data Pattern Generator - Avalon-ST Data Pattern Checker - JTAG-to-Avalon Master Bridge For a quick guide to set up tests for link debugging with the Transceiver Toolkit, refer to “Working with Design Examples” on page 11–19. **Custom PHY IP Core** You can use the Custom PHY IP core to test all possible parallel data widths of the transceivers in these design examples. You can configure the Custom PHY IP core as 8, 10, 16, 20, 32 or 40-bit. The sweep tools disable word alignment during sweep, which is enabled to simplify timing closure. You can also use the Data Format Adapter IP component as required. You can have one or multiple channels in your design. You use Qsys to define and generate the Custom PHY IP core. The Custom PHY IP core in the design examples that you can download from the On-Chip Debugging Design Example page of the Altera website are generated for Stratix IV and Stratix V devices. To use the Custom PHY IP core with the Transceiver Toolkit, perform the following steps: 1. Set the following parameters to meet your project requirements: - Number of lanes - Bonded group size - Serialization factor - Data rate - Input clock frequency 2. Turn on Avalon data interfaces. 3. Disable 8B/10B 4. Set Word alignment mode to manual 5. Disable rate match FIFO 6. Disable byte ordering block For more information about the protocol settings used in the Custom PHY IP core, refer to the “Custom PHY IP User Core” section of the *Altera Transceiver PHY IP Core User Guide*. **Transceiver Reconfiguration Controller** This IP is necessary to control PMA settings and modify other transceiver settings in Stratix V devices. It must be connected to all PHY IP (custom or low_latency) to be controlled by the Transceiver Toolkit. The reconfig_from_xcvr and reconfig_to_xcvr ports should be connected together. For further information, refer to the *Altera Transceiver PHY IP Core User Guide*. These settings must be turned on: - Enable Analog controls - Enable EyeQ block - Enable AEQ block **Low Latency PHY IP Core** Use Low Latency PHY IP Core as follows: - To get more than 8.5 gbps in GT devices. - To use PMA direct mode, such as when using six channels in one quad. To meet your project requirements, use the same set of parameters that you would use with the Custom PHY IP core. The phase compensation FIFO mode must be set to embedded above certain data rates. The Transceiver Toolkit provides a warning when you exceed the data rate. To be in PMA direct mode, you must set the phase compensation FIFO mode to none, which supports a smaller range of data rates. The Low Latency PHY must have the loopback setting set to serial loopback mode. Otherwise, the serial loopback controls within the tool do not function. For more information about the protocol settings used in the Low Latency PHY IP core, refer to the “Low Latency PHY IP User Core” section of the *Altera Transceiver PHY IP Core User Guide*. **Avalon-ST Data Pattern Generator** The generator produces standard data patterns that you can use for testing. The patterns supported include prbs7, prbs15, prbs23, prbs31, high frequency, and low frequency. This component produces data patterns in the test flow. You can use a variety of popular patterns to test transceiver signal integrity (SI). The data pattern generator component is provided as an Altera IP core component. You can use any pattern, but you must have a checker to verify that you receive that pattern properly. When you use the Avalon®-ST Data Pattern Generator, the width may be different than the width the Custom PHY IP core or Low Latency PHY IP core is configured with, so you may need to use a data format adaptor. The Avalon-ST Data Pattern Generator component is available in the Qsys component library tree. The Avalon-ST Data Pattern Checker is available under **Debug and Performance** in the Qsys component library tree. The adaptor can be automatically inserted and properly configured by Qsys with the **Insert Avalon-ST Adapters** command. The Avalon-ST Data Pattern Generator generates industry-standard data patterns. Data patterns are generated on a 32-bit or 40-bit wide Avalon streaming source port. For more information about both SOPC Builder and Qsys interconnect fabric, refer to the **System Interconnect Fabric for Streaming Interfaces** chapter in the *SOPC Builder User Guide*. Figure 11–3 shows the wizard page that you use to set parameters for the Avalon-ST Data Format Adapter. **Figure 11–3. Avalon-ST Data Format Adapter** --- **Data Checker** The Avalon-ST Data Pattern Checker is provided as a Qsys component. It checks the incoming data stream against standard test patterns, which include PRBS7, PRBS15, PRBS23, PRBS31, High Frequency, and Low Frequency. It is used in conjunction with the Avalon-ST Data Pattern Generator to test transceiver links. The Avalon-ST Data Pattern Checker is available under **Debug and Performance** in the Qsys component library tree. The checker is the core logic for data pattern checking. Data patterns are accepted on 32-bit or 40-bit wide Avalon streaming sink ports. For more information, refer to *Avalon Streaming Data Pattern Generator and Checker Cores* chapter in the *Embedded Peripherals User Guide*. Use the design examples as a starting point to work with a particular signal integrity development board. You can also modify and customize the design examples to match your intended transceiver design. When you use the Transceiver Toolkit, you can check your transceiver link signal integrity without the completed final design. Use the design examples to quickly test the functionality of the receiver and transmitter channels in your design without creating any custom designs with data generators and checkers. You can quickly change the transceiver settings in the design examples to see how they affect transceiver link performance. You can also use the Transceiver Toolkit to isolate and verify the transceiver links without having to debug other logic in your design. ### Compiling Design Examples Once you have downloaded the design examples, open the Quartus II software version 10.0 or later and unarchive the project in the example. If you have access to the same development board with the same device as mentioned in the `readme.txt` file of the example, you can directly program your device with the provided programming file in that example. If you want to recompile the design, you must make your modifications to the configuration in Qsys, re-generate in Qsys, and recompile the design in the Quartus II software to get a new programming file. If you have the same board as mentioned in `readme.txt` file, but a different device on your board, you must choose the appropriate device and recompile the design. For example, some early development boards are shipped with engineering sample devices. If you have a different board, you must edit the necessary pin assignments and recompile the design examples. ### Changing Pin Assignments You can edit pin assignments for various development kits. The following paragraphs are examples of pin assignments for Stratix IV GX development kits. For further information about other development kits, read the `readme.txt` file which comes with the design examples. For more information on the pinouts refer to their respective user guide found on the All Development Kits page of the Altera website. *Table 11–1 shows the pin-assignment edits for the Stratix IV Transceiver Signal Integrity Development Kit (DK-SI-4SGX230N). You must make these assignments before you recompile your design.* <table> <thead> <tr> <th>Top-Level Signal Name</th> <th>I/O Standard</th> <th>Pin Number on DK-SI-4SGX230N Board</th> </tr> </thead> <tbody> <tr> <td>REFCLK_GXB2_156M25 (input)</td> <td>2.5 V LVTTL/LVC MOS</td> <td>PIN_G38</td> </tr> <tr> <td>S4GX_50M_CLK4P (input)</td> <td>2.5 V LVTTL/LVC MOS</td> <td>PIN_AR22</td> </tr> <tr> <td>GXB1_RX1 (input)</td> <td>1.4-V PCML</td> <td>PIN_R38</td> </tr> <tr> <td>GXB1_TX1 (output)</td> <td>1.4-V PCML</td> <td>PIN_P36</td> </tr> </tbody> </table> Table 11–2 shows the pin-assignment edits for the Stratix IV GX development kit (DK-DEV-4SGX230N). You must make these assignments before you recompile your design. <table> <thead> <tr> <th>Top-Level Signal Name</th> <th>I/O Standard</th> <th>Pin Number on DK-DEV-4SGX230N Board</th> </tr> </thead> <tbody> <tr> <td>REFCLK_GXB2_156M25 (input)</td> <td>LVDS</td> <td>PIN_AA2</td> </tr> <tr> <td>S4GX_50M_CLK4P (input)</td> <td>2.5 V LVTT/LVCMOS</td> <td>PIN_AC34</td> </tr> <tr> <td>GXB1_RX1 (input)</td> <td>1.4-V PCML</td> <td>PIN_AU2</td> </tr> <tr> <td>GXB1_TX1 (output)</td> <td>1.4-V PCML</td> <td>PIN_AT4</td> </tr> </tbody> </table> Similarly, you can change the pin assignment for your own board and recompile the design examples. **Transceiver Toolkit Link Test Setup** To set up testing with the Transceiver Toolkit, perform the following steps: 1. Ensure the device board is turned on and is available before you start the System Console or the Transceiver Toolkit. The connections are detected at startup of the tool. 2. Program the device either with the programming file provided with the .zip file or with the new programming file after you recompile your project. 3. Open the Transceiver Toolkit from the Tools menu in the Quartus II software. 4. Make sure the device is correctly programmed with the programming file in step 1 and that board settings, such as the jumper settings, are correct. **Loading the Project in System Console** From the Transceiver Toolkit, load the Quartus project file (*.qpf) by going to the File menu and selecting Load Project. Whether you have recompiled the design or not, the unzipped contents of the examples contain this file. After the project is loaded, you can review the design information under System Explorer in the System Console. **Linking the Hardware Resource** Expand the devices tree in the System Explorer pane and find the device you are using. Right click on a design and choose a device to link to. This is only necessary if you do not use the usercode for automatic linking. If you are using more than one Altera board, you can set up a test with multiple devices linked to the same design. This is useful when you want to perform a link test between a transmitter and receiver on two separate devices. For Transceiver Toolkit version 11.1 and later, to automatically instantiate and link designs after they have been loaded into the System Console, click Assignments on the main menu of the Quartus II software, click Device on the Device and Pin Options dialog box, and then turn on Auto usercode. When the project is loaded any devices programmed with this project will automatically be linked. Prior to Transceiver Toolkit version 11.1, you must manually load your design as described in the previous paragraphs. To set up the transmitter channels, receiver channels, and transceiver links, go to the Tools menu and select Transceiver Toolkit, or from the Welcome to the Transceiver Toolkit tab, click on the Transceiver Toolkit to open the main Transceiver Toolkit window. You can then create the channels, as described in the following section. Creating the Channels After you open the Transceiver Toolkit, there are three tabs in the System Console, including Transmitter Channels, Receiver Channels, and Transceiver Links tabs. The Transmitter Channel and Receiver Channel tabs are automatically populated with the existing transmitter and receiver channels in the design, respectively. However, you can create your own additional transmitter and receiver channels in a situation where the expected configuration was not automatically populated. The situation may occur if in the Link Channel tab you create a link between a transmitter and receiver channel. Links define connectivity between a particular transmitter channel and a receiver. The link forms the main logical unit that you test with the Transceiver Toolkit. Links are automatically created when a receiver channel and transmitter channel share a transceiver channel. However, if you are not actually looping data back, but using it to transmit or receive to another transceiver channel, you must define and create a new link. For example, in Figure 11–4, a link is created in the Link Channel tab between a transmitter and receiver channels of the same device. **Figure 11–4. Creating a Link Channel in Transceiver Toolkit** Chapter 11: Transceiver Link Debugging Using the System Console Transceiver Toolkit Link Test Setup You can also perform a physical link test without loopback by connecting one device transmitter channel to another device receiver channel. In this channel you would define that connection into a link, and tests would run off that link. For example, as shown in Figure 11–2, use the transmitter and receiver channels of the same device and loop them back on the far side of the board trace to check the signal integrity of your high-speed interface on the board trace. You can select the link that you created in the Transceiver Toolkit and use the different buttons to start and control link tests. You can also communicate with other devices that have the capability to generate and verify test patterns that Altera supports. Running the Link Tests Use the Link Channel tab options to control how you want to test the link. For example, use the Auto Sweep feature to sweep various transceiver settings parameters through a range of values to find the results that give the best BER value. You can also open Transmitter, Receiver and Link Control panels to manually control the PMA settings and run individual tests. You can change the various controls in the panels to suit your requirements. To perform an auto sweep link test, perform the following steps: 1. Select the link to test and click Auto Sweep to open the auto sweep panel for the selected link. 2. Set the test pattern to test. 3. Select either Smart Auto Sweep or Full Auto Sweep. Full Auto Sweep runs a test of every combination of settings that falls within the bounds that you set. Smart Auto Sweep minimizes the number of tests run to reach a good setting, which saves you time. Smart Auto Sweep does not test every possible setting, so may not achieve the very best setting possible; however, it can quickly find an acceptable setting. 4. Set up run lengths for each test iteration. The run length limits you set are ignored when you run a smart sweep. 5. Set up the PMA sweep limits within the range you want to test. 6. Press Start and let the sweep run until complete. After an Auto Sweep test has finished at least one iteration, you can create a report by clicking Create Reports, which opens the Reports tab. The report shows data from all tests that you have completed. You can sort by columns and filter data by regular expression in the Reports tab. You can also export the reports to a .csv file by right clicking on a report. If you found a setting with the Smart Sweep mode, use the reported best case PMA settings, and apply a +/- 1 setting to them, returning the test to Full Auto Sweep mode. This helps you determine if the settings you chose are the best. You can then choose your own runtime conditions, reset the Auto Sweep feature by pressing Reset, and re-running the tests to generate BER data based on your own run length conditions. This procedure allows you to obtain a good setting for PMA faster. Review the BER column at the end of the full sweep to determine the best case. When setting smart sweep ranges, try to include the 0 setting as often as possible, as that setting often provides the best results. **Viewing Results in the EyeQ Feature** Advanced FPGA devices such as Stratix IV have built-in EyeQ circuitry, which is used with the EyeQ feature in Transceiver Toolkit. The EyeQ feature allows you to estimate the horizontal eye opening at the receiver of the transceiver. With this feature, you can tune the PMA settings of your transceiver, which results in the best eye and BER at high data rates. Stratix V EyeQ circuitry adds the ability to see the vertical eye opening in addition to the horizontal eye opening at the receiver of the transceiver. With this view of the eye, you have a better idea of what is going on as you tune the PMA settings. For more information about the EyeQ feature, refer to AN 605: Using the On-Chip Signal Quality Monitoring Circuitry (EyeQ) Feature in Stratix IV Transceivers. To use the EyeQ feature in the Transceiver Toolkit to view the results of the link tests, perform the following steps: 1. Select a Transceiver Link or Receiver Channel in the main Transceiver Toolkit panel that you want to run EyeQ against. 2. Click Control Link or Control Channel to open control panels. Use these control panels to set the PMA settings and test pattern that you want the EyeQ feature to run against. You can check the report panel or Best Case column from an Auto Sweep run for the settings with the best BER value and enter those PMA values through the Transmitter and Receiver control panels. 3. Click EyeQ to open the EyeQ feature. 4. Review the test stop conditions and set them to your preference. 5. Choose a mode to run EyeQ. - **Eye Contour**—shows a BER contour graph of the eye. You can select a specific target bit error rate that the Transceiver Toolkit uses as a means to try to find the boundary. You can also select All, which allows the range of BER targets to be simultaneously found and shown. - **Bathtub**—only finds the horizontal width of the eye. You can choose options for a particular vertical step to sweep. You can also set the Transceiver Toolkit to sweep all vertical steps and get an overlay of multiple slices through the eye. When at least one run has completed, you can click Create Report to view details of completed iterations of the sweep in a report panel. 6. Choose a horizontal and vertical interval, which allows you to skip steps to get a faster though rougher view of the eye. If time is critical this can help speed up the eye generation process, but results in less resolution as to the actual point of BER crossover. 7. Click **Run**. The EyeQ Feature gathers the current settings of the channel and uses those settings to start a sweep to create the eye. As the run is active you can view the status through the progress bar. Depending on the mode you chose, you will see a bathtub curve or eye contour. The width and height (if applicable) of the eye is displayed once the run is completed. If the eye is un-centered or falls off the edge and wraps around the other side, click **Center Eye** to center the data for easier viewing. 8. You can change run options such as BER target, vertical phase step, or intervals, and run again to collect more data. Switching between these options can show previously run data so you can easily compare. If you click **Create Report**, all data collected so far is shown in table format. If you change PMA settings, you must click **Reset** to clear all data and take in the new PMA settings to be used for testing. You can also click **Reset** to clear the data and collect a new set of data due to changing conditions or circumstances. If you want to change PMA settings and re-run the EyeQ feature, make sure you first stop and reset the EyeQ feature. If you do not reset, the EyeQ feature continues testing based on the original PMA settings of the current test and overwrites any setting you may have changed through the control panel. After you stop and reset the EyeQ feature, change settings in the link or receiver channel control panel. Then click **Start** on the EyeQ feature to start a new set of tests. When you can see that you are running good PMA settings, the bathtub curve is wide, with sharp slopes near the edges. The curve may be up to 30 units wide. If the bathtub is narrow, maybe as small as two units wide, then the signal quality may be poor. The wider the bathtub curve, the wider the eye you have. Conversely, the smaller the bathtub curve, the smaller the eye. For more information about how to use the EyeQ feature, including the differences between Stratix IV and Stratix V devices, refer to *Working with the Transceiver Toolkit* in Quartus II Help. ### Using Tcl in System Console System Console is the framework in the Quartus II software that supports the Transceiver Toolkit. System Console provides a number of Tcl commands that you can use to build a custom test routine script to test the transceiver link using the data generator and checker. System Console allows you to tune PMA parameter, such as those for changing DC gain. To get help on the Tcl commands available, type `help` in the Tcl console in System Console. To run a transceiver link test flow, perform the following. You can perform all the tasks with Tcl commands in System Console. 1. Load the Quartus II project. 2. Find and link the design and service path. 3. Find and open links to transmitter channels and receiver channels. 4. Set up PRBS patterns to run on the link. 5. Set up PMA settings on transmitter and receiver channels. 6. Use PIO logic to generate a rising edge to enable the word aligner. 7. Start the link test. 8. Poll the receiver for BER data. 9. When the test is finished, stop the link test. 10. Close the link. For more information about Tcl commands, refer to the *Analyzing and Debugging Designs with the System Console* chapter in volume 3 of the *Quartus II Handbook*. When you read the Tcl scripts provided with the design examples, they help you understand how the Tcl commands are used. ### Running Tcl Scripts The tasks that you perform with the Transceiver Toolkit GUI for setting up your test environment you can also save as Tcl scripts. For example, you can save the steps you perform for loading your project in the Transceiver Toolkit by clicking **Create Tcl setup script** on the File menu. You can save your steps at various stages, such as when you add projects, create design instances, link designs to devices, and create transceiver links. You can run these scripts to reach the initial setup you created to get your specific configuration ready for debugging. All the saved scripts are shown under the **Scripts** in the **System Explorer**. You can execute a script by right-clicking on **Scripts** under the **System Explorer** in the Transceiver Toolkit, and then clicking **Run**, or you can double-click on the script. You can also execute scripts from the **System Console command line**. ### Usage Scenarios You can use the Transceiver Toolkit if you are debugging one device on one board or more than one device on a single or multiple boards. Usually for a device you have a single Quartus II design or project, but you can have one design targeted for two or more similar devices on the same or different boards. Possible scenarios for how you can use the Transceiver Toolkit in those situations follow. The scenarios assume that you have programmed the device you are testing with the relevant **.sof**. - “Linking One Design to One Device Connected By One USB Blaster Cable” on page 11–15 - “Linking Two Designs to Two Separate Devices on Same Board (JTAG Chained), Connected By One USB Blaster Cable” on page 11–15 - “Linking Two Designs to Two Separate Devices on Separate Boards, Connected to Separate USB Blaster Cables” on page 11–15 - “Linking Same Design on Two Separate Devices” on page 11–15 - “Linking Unrelated Designs” on page 11–16 - “Saving Your Setup As a Tcl Script” on page 11–16 - “Verifying Channels Are Correct When Creating Link” on page 11–16 - “Using the Recommended DFE Flow” on page 11–17 Usage Scenarios - “Running Simultaneous Tests” on page 11–17 - “Enabling Internal Serial Loopback” on page 11–18 For further information on how to use the Transceiver Toolkit GUI to perform the following scenarios, refer to Working with the Transceiver Toolkit in Quartus II Help. Linking One Design to One Device Connected By One USB Blaster Cable The following describes how to link one design to one device by one USB Blaster cable. 1. Load the design for all the Quartus II project files you might need. 2. Link each device to an appropriate design (Quartus II project) if it has not auto-linked. 3. Create the link between channels on the device to test. Linking Two Designs to Two Separate Devices on Same Board (JTAG Chained), Connected By One USB Blaster Cable The following describes how to link two designs to two separate devices on the same board, connected by one USB Blaster cable. 1. Load the design for all the Quartus II project files you might need. 2. Link each device to an appropriate design (Quartus II project) if it has not auto-linked. 3. Open the project for the second device. 4. Link the second device on the JTAG chain to the second design (unless it auto-links). 5. Create a link between the channels on the devices you want to test. Linking Two Designs to Two Separate Devices on Separate Boards, Connected to Separate USB Blaster Cables The following describes how to link two designs to two separate devices on separate boards, connected to separate USB Blaster cables. 1. Load the design for all the Quartus II project files you might need. 2. Link each device to an appropriate design (Quartus II project) if it has not auto-linked. 3. Create the link between channels on the device to test. 4. Link the device you connected to the second USB Blaster cable to the second design. 5. Create a link between the channels on the devices you want to test. Linking Same Design on Two Separate Devices The following describes how to link the same design on two separate devices. 1. In the Transceiver Toolkit, open the Quartus II project file (.qpf) you are using on both devices. 2. Link the first device to this design instance. Follow the same linking method that you used on previous steps. 3. Link the second device to the design. Follow the same linking method that you used on previous steps. 4. Create a link between the channels on the devices you want to test. **Linking Unrelated Designs** Use a combination of the above steps to load multiple Quartus II projects and make links between different systems. You can perform tests on completely separate systems that are not related to one another. All tests run through the same tool instance. Do not attempt to start multiple instances of the Transceiver Toolkit. You can only control multiple devices and run multiple tests simultaneously through the same instance of the Transceiver Toolkit. **Saving Your Setup As a Tcl Script** After you open projects and define links for the system so that the entire physical system is correctly described, use the command **Save Tcl Script** to create a setup script. Close and reopen the Transceiver Toolkit. Open the scripts folder in **System Explorer** and double-click the script to reload the system. You can also right-click and choose **Run Script**, or use the menu command **Load Script** to run the appropriate script. **Verifying Channels Are Correct When Creating Link** After you load your design and link your hardware, you should verify that the channels you have created are correct and looped back properly on the hardware. You should be able to send the data patterns and receive them correctly. Perform the following steps before you perform Auto Sweep or EyeQ tests to verify your link and correct channel, which may save time in the work flow. 1. Assuming that you have completed the system setup, choose the transmitter channel, and click **Control Transmitter Channel**. 2. Set the test pattern to **prbs 7**. 3. Start the pattern generator, press **Start**. 4. Navigate to the control panel, choose the receiver channel, and click **Control Receiver Channel**. 5. Set the test pattern to **prbs 7**. 6. Press **Start**. 7. Verify channels that the channels are correct, based on the following conditions: a. If the Run status is good (green), the receiver is receiving data. To verify that the data is coming from the expected transmitter, you can navigate to the transmitter and do either of the following: ■ Click **Stop** on the transmitter and see if **Data Locked** on the receiver turns off. ■ If the receiver shows 0 error bits, click **Inject Error** on the transmitter and see if that error shows up on the receiver. b. If the Run status is bad (yellow with flashing exclamation point), do either of the following: ■ The data quality is too poor to lock. You can manually adjust the PMA settings to see if you can get a lock. If not, use the Auto Sweep tool if you are certain the channel is correct. ■ The receiver and transmitter are not connected together. You either picked the wrong pair, or you have not made the physical connection between the pair. After you have verified that the transmitter and receiver are talking to each other, create a link in the link tab with these two transceivers so that you can perform Auto Sweep and EyeQ tests with this pair. **Using the Recommended DFE Flow** To use the DFE flow recommended by Altera, perform the following steps: 1. Use the Auto Sweep flow to find optimal PMA settings while leaving the DFE setting **OFF**. 2. Take the best PMA setting achieved, if BER = 0. Then you do not have to do anything if you use this setting. 3. If BER > 0, then use this PMA setting and set minimum and maximum values in the Auto Sweep tool to match this setting. Set the **DFE MAX** range to limits for each of the three DFE settings. 4. Run the Auto Sweep tool to determine which DFE setting results in the best BER. Use these settings in conjunction with the PMA settings for the best results. **Running Simultaneous Tests** To run link tests simultaneously in one instance of the Transceiver Toolkit, perform the following steps: 1. Set up your system correctly with one of the previous set-up scenarios. 2. In the control panel for the link you work on, run either the Auto Sweep or EyeQ tool. 3. After you start the test, return to the Transceiver Toolkit control panel. 4. Select the control panel tab. 5. Open the Tools menu and click **Transceiver Toolkit**, which returns you to the control panel. 6. Repeat step 2 until all tests are run. 7. The control panel shows which links and channel resources are in use to help identify which channels already have tests started and their current run status. **Enabling Internal Serial Loopback** You can use the Transceiver Toolkit GUI control for serial loopback. In the Transceiver Toolkit version 11.1 and later to enable the serial loopback, check the box **Serial Loopback**. To enable the serial loopback in Tcl, use the System Console commands. For more information, refer to *Working with the Transceiver Toolkit* in Quartus II Help. **Quick Guide to Using the Transceiver Toolkit in the Quartus II Software** This section provides a quick guide for using the Transceiver Toolkit, and includes the following: - “Preparing to Use the Transceiver Toolkit” on page 11–18 - “Working with Design Examples” on page 11–19 - “Modifying Design Examples” on page 11–20 - “Setting a Link in the Transceiver Toolkit for High-Speed Link Tests” on page 11–21 - “Running Auto Sweep Tests” on page 11–22 - “Running EyeQ Tests” on page 11–22 - “Running Manual Tests” on page 11–23 - “Using a Typical Flow” on page 11–23 - “Following the Online Demonstration” on page 11–24 For more information about how to use the Transceiver Toolkit, refer to the *Altera Training* page of the Altera website. **Preparing to Use the Transceiver Toolkit** Following is a list of recommended prerequisites to get you prepared for using the Transceiver Toolkit: - You should know how to use the Quartus II software. For further information on how to use the Quartus software, refer to the *Introduction to Quartus II Software*. - Become familiar with an overview description of the Transceiver Toolkit as described in “Transceiver Toolkit Overview” on page 11–1. - Design examples you may download from the Altera website were created using Qsys software, such that you should have knowledge of Qsys. Prior to Qsys, design examples were created with SOPC Builder. Knowledge of SOPC Builder will help with your understanding of Qsys. You need some experience working with Altera high-speed transceiver devices, especially Stratix IV GX and Stratix V devices. Working with the Transceiver Toolkit GUI is described in further detail in the Quartus II Help. For more information, refer to Working with the Transceiver Toolkit in Quartus II Help. You can find further reference materials, including Quartus II design examples, on the Altera website. **Working with Design Examples** You can download design examples from the Altera website, as described in “Transceiver Link Debugging Design Examples” on page 11–3. These design examples help you get started quickly using the Transceiver Toolkit without having to make your own designs to perform high-speed link tests. The design example is a Qsys designed system using various components. The components include JTAG to Avalon Master Bridge, Custom PHY IP core, Low Latency PHY IP core, and data generator and checkers with their own data format and adapters. These components can be found in a Qsys library. The Qsys system is wrapped in a top-level HDL file in Verilog. The online design examples are targeted for device-specific signal integrity boards. You can use these design examples with other boards by changing assignments. The first design example is a one-channel design with an 8-bit interface and a Custom PHY IP core data rate of 1.25 mbps. This example contains one JTAG to Avalon Master Bridge, one Custom PHY IP core, one data generator, one data checker, and timing and data format adapters for each checker and generator. The second design example is a four-channel bonded design with a 10-bit interface and a Custom PHY IP core data rate of 2.5 gbps. Some device families have a different set of examples than this four-channel bonded design. The design contains one JTAG to Avalon master, one Custom PHY IP core, four data generators and data checkers, and timing and data format adapters for each checker and generator. To use these examples, perform the following: 1. Download the examples from the Altera website. Download the Transceiver Toolkit design examples from the On-Chip Debugging Design Examples page of the Altera website. 2. Unzip the examples files. 3. You can directly program the device with the design provided, or you can modify the design. 4. If you modify the design you must then recompile the program to get a new programming file. Use the new programming file to program your device. 5. Open the Transceiver Toolkit from the Tools menu of the Quartus II software. You do not need to create links because a default set is automatically created for you. For more information, refer to Transceiver Toolkit Window in Quartus II Help. 6. You can change settings for the links manually or you can use the Transceiver Auto Sweep panel. 7. Run the Auto Sweep and EyeQ tests from the Transceiver Toolkit window to find the optimal settings. For more information about running Auto Sweep and EyeQ tests and the difference between Stratix IV GX and Stratix V testing, refer to Working with the Transceiver Toolkit in Quartus II Help. **Modifying Design Examples** You may want to modify the design examples to change the data rate of the Custom PHY IP core, add more channels to the Custom PHY IP core, or change the device. Online training on the Altera website provides further detailed descriptions of how to modify the design examples. For more information about the online training, refer to “Following the Online Demonstration” on page 11–24. To modify the design examples that you download from the Altera website, open the existing project in the Qsys tools in the Quartus II software. Qsys has a graphical interface that is shown in the online training, so that following the instructions is straightforward. You can make changes to the design examples so that you can use a different development board or different device. You make pin assignment changes and then recompile the design, as shown in the online training. You either create a new programming file with the Programmer in the Quartus II software, or use the existing programming file that comes with the zipped design examples. The Programmer must complete its programming function 100% with no errors. When you recompile the design a new programming file is created. If you do not change the design you can use the included programming file. For more information about programming a device, refer to Programming Devices in Quartus II Help. Setting a Link in the Transceiver Toolkit for High-Speed Link Tests 1. Make sure your development board is properly configured. a. You must make the proper connections for the links you want to test. b. Your board must be up and running, and programmed with the correct programming file. c. Set-up examples are shown in the online training. Refer to the Transceiver Toolkit Online Demo on the Altera website. 2. Open the Transceiver Toolkit from the Tools menu in the Quartus II software, if the panel is not already showing on the screen. 3. The System Explorer panel on the left side of the System Console shows design connections, loaded designs, and design instances. Ensure that your hardware is shown in the System Explorer. 4. Load your design project, which is a .qpf file, into the System Console with the Load Design command. 5. Open the Transceiver Toolkit from the Tools menu in the System Console. You can now view all the design information. 6. Link the hardware you want to test to the Quartus II project. Right-click on a device and select Link device to. Then select the Quartus II project name from the list. In most cases links are automatically loaded, so you may not need to link hardware as described in step 6 if you are working with design examples. To automatically instantiate and link designs after they have been loaded into the System Console, click Assignments on the main menu of the Quartus II software, click Device on the Device and Pin Options dialog box, and then turn on Auto usercode. 7. You can save all actions you perform into a Tcl script. On the File menu of the System Console, click Create Tcl setup script. This action creates a Tcl script of your current setup, including receivers, transmitters, and links you created. The next time you start the Transceiver Toolkit, you can double-click the script to open the setup you saved. 8. All the scripts are listed under Scripts in the System Explorer pane. You can add any Tcl script when you place the script into your Scripts folder. You can then right-click the Scripts folder to open the folder and add or modify files. 9. On the Transceiver Toolkit main window, the Transceiver Links tab is automatically populated with the channel information in your design. 10. By default links are created between the transceiver and receiver of the same channel and are shown in the Transceiver Links tab. 11. You can also create an additional link between a different transceiver and receiver channel. 12. On the Transceiver Links tab, you click Control Link, Auto Sweep, or EyeQ to run tests. 13. On the Receiver Channels tab, you click Control Channel, Auto Sweep, or EyeQ to control and run tests. **Running Auto Sweep Tests** To use Auto Sweep in the Transceiver Toolkit to perform high-speed link tests perform the following: 1. On the Transceiver Links tab, click **Auto Sweep** to open the Auto Sweep panel. You use this panel to perform Auto Sweep Bit Error Rate (BER) testing. 2. Previous transceiver settings are shown in the Auto Sweep tab. You can select different combinations of settings here before starting a test. Different settings change the case count. 3. When you start the Auto Sweep test the **Current** column displays the current test results. The **Best** column displays the best results so far obtained during the test. 4. You create reports by clicking **Create Report** once Auto Sweep is completed or while the testing is in process. You can export all settings and results to reports in a .csv format. Columns in the reports show various transceiver settings and you can sort the columns, which simplifies finding the best test cases. For example, when you sort on the BER column, it gives you the settings that produce the lowest BER. For more information about running Auto Sweep tests and the difference between Stratix IV GX and Stratix V testing, refer to *Working with the Transceiver Toolkit* in Quartus II Help. **Running EyeQ Tests** To use the EyeQ feature in the Transceiver Toolkit, perform the following: 1. On the Transceiver Links tab, click **EyeQ** to open the EyeQ panel. This panel shows the transceiver settings. To change settings you open either the Transceiver Links or Receiver Links control panels, make setting changes, and run the EyeQ test again. These panels open when you click either **Control Links** or **Control Channel** on the Transceiver Links tab or the Transceiver Channels tab. 2. Use EyeQ to verify receiver settings. EyeQ can see how receiver settings affect eye width. 3. Click Reset when you change settings and want to run the EyeQ test again. 4. When the EyeQ test begins and the first sweep is completed, the bathtub curve is generated and displays. If you do not see a bathtub curve at the end of the test run, but see a hill instead, click **Center Eye** to position the bathtub curve in the middle of the pane. 5. Click **Create Report** to generate EyeQ reports. If you sort the report by BER column, the number of rows that have a BER value of 0 are considered the unit of width of the eye from the specified PMA settings. Running Manual Tests Besides performing Auto Sweep and EyeQ tests with the Transceiver Toolkit, you can also perform manual tests and change PMA settings while testing is in progress as follows: 1. Ensure that Auto Sweep tools have finished, and both Auto Sweep and EyeQ windows are closed. 2. Click Control Link on the Transceiver Links tab. The Receiver, Transmitter, and Link Control panels open. 3. Select a test pattern and begin testing. 4. While the test is running you can change the PMA settings on the Transmitter or Receiver Control panels. 5. Press Inject Error on the Transmitter Control panel and view results on the Receiver Control panel. You can only use Inject Error to verify that have connected the proper transmitter to your receiver. 6. Click Reset on the Receiver Control panel after changing the PMA settings so that the BER counter starts from the beginning. Using a Typical Flow You can use the tools in the Transceiver Toolkit however you choose. Following is a typical flow: 1. Perform an Auto Sweep test to get the best BER with various combinations of PMA settings. You can also check the Best Case column in an Auto Sweep BER report for the settings with the best BER value. You then enter those PMA values in the Transmitter Channel and Receiver Channel control tabs. 2. Use the control panels to set the PMA settings and test pattern that you want to run the EyeQ test against. Select a Transceiver Link or Receiver Channel in the Transceiver Toolkit tab that you want to run the EyeQ test against. Click Control Link or Control Channel to open the control panels. 3. Re-run EyeQ sweeps with different settings to see if the eye width changes. When you see that you are running good PMA settings, the bathtub curve is wide and has sharp slopes near the edges. The curve may be up to 30 units wide. If the bathtub curve is narrow, say two units wide for example, then the signal quality may be poor. The wider the bathtub curve, the wider the eye you have. Do not change any control panel settings while you are actively using Auto Sweep tools. If you do manually use the control panel, make sure all receivers and transmitters are stopped before attempting to use an Auto Sweep tool. Following the Online Demonstration For an online demonstration of how to use the Transceiver Toolkit to run a high-speed link test with one of the design examples, refer to the Transceiver Toolkit Online Demo on the Altera website. The demonstration shows how to perform link testing with one device. The Transceiver Toolkit is scalable for other purposes, such as performing board-to-board testing, testing device-to-device on the same development board, and testing internal loopbacking of the same channel with no external loopbacking required. Conclusion You gain productivity when optimizing high-speed transceiver links in your board designs with the Transceiver Toolkit and design examples provided from Altera. You can easily set up automatic testing of your transceiver channels so that you can monitor, debug, and optimize transceiver link channels in your board design. You then know the optimal PMA settings to use for each channel in your final FPGA design. You can download standard design examples from Altera’s website, and then customize the examples to use in your own design. Document Revision History Table 11–3 lists the revision history for this handbook chapter. <table> <thead> <tr> <th>Date</th> <th>Version</th> <th>Changes</th> </tr> </thead> <tbody> <tr> <td>November, 2011</td> <td>11.1.0</td> <td>Maintenance release. This chapter adds new Transceiver Toolkit features.</td> </tr> <tr> <td></td> <td></td> <td>Minor editorial updates.</td> </tr> <tr> <td>May, 2011</td> <td>11.0.0</td> <td>Added new Tcl scenario.</td> </tr> <tr> <td>December 2010</td> <td>10.1.0</td> <td>Changed to new document template. Added new 10.1 release features.</td> </tr> <tr> <td>August 2010</td> <td>10.0.1</td> <td>Corrected links</td> </tr> <tr> <td>July 2010</td> <td>10.0.0</td> <td>Initial release</td> </tr> </tbody> </table> For previous versions of the Quartus II Handbook, refer to the Quartus II Handbook Archive. Take an online survey to provide feedback about this handbook chapter.
{"Source-Url": "http://www.farnell.com/datasheets/1558322.pdf", "len_cl100k_base": 11812, "olmocr-version": "0.1.53", "pdf-total-pages": 24, "total-fallback-pages": 0, "total-input-tokens": 53572, "total-output-tokens": 12898, "length": "2e13", "weborganizer": {"__label__adult": 0.0009174346923828124, "__label__art_design": 0.001434326171875, "__label__crime_law": 0.0004322528839111328, "__label__education_jobs": 0.0019350051879882812, "__label__entertainment": 0.00035309791564941406, "__label__fashion_beauty": 0.0005140304565429688, "__label__finance_business": 0.0004367828369140625, "__label__food_dining": 0.0005574226379394531, "__label__games": 0.00316619873046875, "__label__hardware": 0.256591796875, "__label__health": 0.0005350112915039062, "__label__history": 0.0006246566772460938, "__label__home_hobbies": 0.0008268356323242188, "__label__industrial": 0.0063018798828125, "__label__literature": 0.0003173351287841797, "__label__politics": 0.00033402442932128906, "__label__religion": 0.0013532638549804688, "__label__science_tech": 0.197509765625, "__label__social_life": 0.00012505054473876953, "__label__software": 0.07281494140625, "__label__software_dev": 0.450439453125, "__label__sports_fitness": 0.0008215904235839844, "__label__transportation": 0.0012483596801757812, "__label__travel": 0.0002601146697998047}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 54132, 0.01521]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 54132, 0.41623]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 54132, 0.8972]], "google_gemma-3-12b-it_contains_pii": [[0, 2266, false], [2266, 4942, null], [4942, 6671, null], [6671, 7414, null], [7414, 9432, null], [9432, 11980, null], [11980, 13194, null], [13194, 15746, null], [15746, 18075, null], [18075, 20176, null], [20176, 23261, null], [23261, 25907, null], [25907, 28950, null], [28950, 31425, null], [31425, 33444, null], [33444, 35630, null], [35630, 37997, null], [37997, 40066, null], [40066, 42384, null], [42384, 44577, null], [44577, 47098, null], [47098, 49718, null], [49718, 51941, null], [51941, 54132, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2266, true], [2266, 4942, null], [4942, 6671, null], [6671, 7414, null], [7414, 9432, null], [9432, 11980, null], [11980, 13194, null], [13194, 15746, null], [15746, 18075, null], [18075, 20176, null], [20176, 23261, null], [23261, 25907, null], [25907, 28950, null], [28950, 31425, null], [31425, 33444, null], [33444, 35630, null], [35630, 37997, null], [37997, 40066, null], [40066, 42384, null], [42384, 44577, null], [44577, 47098, null], [47098, 49718, null], [49718, 51941, null], [51941, 54132, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 54132, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 54132, null]], "pdf_page_numbers": [[0, 2266, 1], [2266, 4942, 2], [4942, 6671, 3], [6671, 7414, 4], [7414, 9432, 5], [9432, 11980, 6], [11980, 13194, 7], [13194, 15746, 8], [15746, 18075, 9], [18075, 20176, 10], [20176, 23261, 11], [23261, 25907, 12], [25907, 28950, 13], [28950, 31425, 14], [31425, 33444, 15], [33444, 35630, 16], [35630, 37997, 17], [37997, 40066, 18], [40066, 42384, 19], [42384, 44577, 20], [44577, 47098, 21], [47098, 49718, 22], [49718, 51941, 23], [51941, 54132, 24]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 54132, 0.05168]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
0ea1e347c8255d5453a3df8d2dae73ff168d0ba8
Impact of Optimal Feature Selection Using Hybrid Method for a Multiclass Problem in Cross Project Defect Prediction Abeer Jalil 1,*, Rizwan Bin Faiz 1, Sultan Alyahya 2 and Mohamed Maddeh 3 1 Faculty of Computing, Riphah International University, Islamabad 46000, Pakistan 2 Department of Information Systems, King Saud University, Ar Riyadh 12372, Saudi Arabia 3 College of Applied Computer Science, King Saud University, Ar Riyadh 12372, Saudi Arabia * Correspondence: abeerjalil21@gmail.com Abstract: The objective of cross-project defect prediction (CPDP) is to develop a model that trains bugs on current source projects and predicts defects of target projects. Due to the complexity of projects, CPDP is a challenging task, and the precision estimated is not always trustworthy. Our goal is to predict the bugs in the new projects by training our model on the current projects for cross-projects to save time, cost, and effort. We used experimental research and the type of research is explanatory. Our research method is controlled experimentation, for which our independent variable is prediction accuracy and dependent variables are hyper-parameters which include learning rate, epochs, and dense layers of neural networks. Our research approach is quantitative as the dataset is quantitative. The design of our research is 1F1T (1 factor and 1 treatment). To obtain the results, we first carried out exploratory data analysis (EDA). Using EDA, we found that the dataset is multi-class. The dataset contains 11 different projects consisting of 28 different versions of all the projects in total. We also found that the dataset has significant issues of noise, class imbalance, and distribution gaps between different projects. We pre-processed the dataset for experimentation by resolving all these issues. To resolve the issue of noise, we removed duplication from the dataset by removing redundant rows. We then covered the data distribution gap between different sources and target projects using the min-max normalization technique. After covering the data distribution gap, we generated synthetic data using a CTGANsynthesizer to solve class imbalance issues. We solved the class imbalance issue by generating an equal number of instances, as well as an equal number of output classes. After carrying out all of these steps, we obtained normalized data. We applied the hybrid feature selection technique on the pre-processed data to optimize the feature set. We obtained significant results of an average AUC of 75.98%. From the empirical study, it was demonstrated that feature selection and hyper-parameter tuning have a significant impact on defect prediction accuracy in cross-projects. Keywords: hyper-parameter tuning; cross project defect prediction (CPDP); generative adversarial networks (GAN); hybrid feature selection (HFS) 1. Introduction Software defect prediction (SDP) is an important software quality assurance step of predicting the defect proneness in software project development history [1]. Despite extensive research and a long history, software failure prediction continues to be a thought-provoking problem in the field of software engineering. [2]. Software groups in particular use checking out as their main technique of detecting and preventing defects in each level of the development life cycle, specifically during implementation. Also, testing software programs can be very time-consuming, and resources for such tasks are likely to be limited, so automated bug detection can save time, money, and effort. Increase [2]. Defect records from already developed projects can be used to find bugs in new, similar projects. Prediction primarily based on the historic records amassed from the same projects... is known as within-project defect prediction (WPDP) and it has been studied widely [3]. Using available public datasets, one can discover the practicality of models created for different tasks, particularly for people with partial or no defect records repository. Most traditional software defect prediction models focus on within project defect prediction (WPDP) and the major limitations of WPDP is lack of training information in the early phases of the software development and testing process. Therefore, the proposed feature selection based prediction model is used to assess the cross project defect prediction (CPDP) on an open source repository [4]. In the latest studies, models of machine learning are successfully implemented to identify defective features, e.g., correlation analysis, neural networks, and deep learning (DL). Previous studies have shown that by using suitable and complete data, one can train a useful machine-learning model. However, it is a crucial problem that an upcoming project with partial historical data could result in better prediction model performance. In the absence of adequate amounts of historical data, cross-project defect prediction [1,2] is an acceptable answer, which discusses the development of the model trained by learning source projects which have defects, and the prediction is then carried out on target projects. However, attaining a satisfactory CPDP is stimulating. Zimmermann et al. estimated CPDP performance on 12 projects (622 cross-project pairs). Among them, 21 total pairs achieved well. The data from different projects usually have an enormous distribution gap that interrupts an elementary requirement of many of the ML technologies, i.e., similar distribution gaps. Many studies are intended to reduce the data distribution difference from different projects in CPDP [2,5]. This research has concentrated on different feature selection techniques and their impact on the defect prediction model. Deep neural network (DNN) [2,5] models have provided mountable non-linear adaptations for feature representations in classification scenarios, and DNN has been developed widely. Recently, generative adversarial networks (GANs) [6] have been proposed, in which two models are trained simultaneously in an adversarial modeling framework. To acquire a clear representation of the features of the dataset, GANs play a minimax game, resulting in two models striving with each other. Moreover, GANs can learn data distribution gaps and the representation of features very efficiently. So, training the distribution gap of different projects can be carried out using GANs. It is possible to learn the mutually distributed representation of inter-class instances and enhance the correlation learning of intra-class instances in different projects. CTGANSynthesizer performs well for generating tabular data [7,8]. During the last two decades, different feature selection methods and classification models have been used for the prediction of different defect datasets. Feature selection methods extract subsets of optimal features from the large feature set. To predict the fault in the software, there should be a good understanding of the static metrics. Among these static subset of features, some of them are features with a high priority defects, and others are low priority defects. So, it is not necessary to use slight defect features; the chosen features should be detected and employed in the prediction process. To experiment with the challenges of the distribution gap between cross-projects, and limited data, and to select an optimal subset of features, we propose a new approach for CPDP. Our approach consists of three major parts: data pre-processing, hybrid feature selection, and classification of output data. We performed the proposed approach on 35 datasets of the PROMISE repository. The experiment results show that our experiment accomplishes phenomenal evaluation compared to the semi-supervised defect prediction approach and state-of-the-art CPDP. 2. Literature Review If selected carefully, a dataset from other projects can provide a better predicting power than WP data [9] as the large pool of the available CP data has the potential to cover a larger range of the feature space. This may lead to a better match between training and test datasets and consequently to better predictions. Our research motivation is mainly based on the dataset, the distribution gap in different projects of the dataset, class imbalance issues [10] in the dataset, and hybrid feature selection. Cross-project defect prediction (CPDP) has evoked great interest recently. Many researchers began building competitive and novel CPDP models to predict defects in projects without sufficient training data. However, not all studies achieve a high level of accuracy or perform well in CPDP. Many studies reviewed in the literature have established software defect prediction models for estimating the prediction regarding the software development process, including effort estimation, resource utilization, and maintainability during the software development lifecycle. In the series of experiment Y. Sun, X.-Y. Jing, F. Wu, J. J. Li, D. Xing, H. Chen, And Y. Sun worked on cross-project defect prediction using the PROMISE repository. They introduced the adversarial learning framework into cross-project defect prediction to better address the data distribution difference problem of different projects. They normalized the data by using the commonly used min-max normalization. All the values were then transformed into intervals. They carried out feature selection by randomly selecting features with the same metrics from datasets. They used a defect label classifier to predict the class of the mapped instances in the common subspace and also added Softmax activation on the top of the neural network. The constructed experiment and the result analyses have demonstrated the effectiveness and efficiency of the proposed approach with the F-measure being 0.7034 and the G-measure being 0.6944. S. Hosseini, B. Turhan, and M. Mäntylä worked on cross-project defect prediction using the PROMISE repository. Before using the dataset, there were two major issues to solve, which were class imbalance issues and noise in the dataset. To address the class imbalance issue, they presented a hybrid instance selection with the nearest neighbor (HISNN) method using a hybrid classification. To resolve the issue of noise they used an NN-Filter. They used a combination of the nearest neighbor algorithm and the naïve Bayes learner for feature selection. In the experiment, they compared the ten-fold cross-validation with a validation of the model that used independent test data. Overall experimental results were measured in terms of F1-measure, G-measure, Precision, Recall, and AUC. Duksan Ryu, Jong-In Jang, and Jongmoon Baik, researchers worked on hybrid instance selection using nearest-neighbor for cross-project defect prediction using NASA datasets. They proposed a hybrid instance selection using the Nearest-Neighbor (HISNN) method that performs a hybrid classification, selectively learning local knowledge (via k-nearest neighbor) and global knowledge (via naïve Bayes). The major challenge of CPDP is the different distributions between the training and test data. To tackle this, they selected instances of source data similar to target data to build classifiers. In the end, results were measured in PD (probability of detection), PF (probability of false alarm), and balance performance measures. The experimental results show that HISNN produces high overall performance. Prathipati Ratna Kumar, Dr. G.P Saradhi Varma, researchers worked on different feature selection measures such as hybrid FS, information gain FS, and gain ratio FS to evaluate attribute selection measure in the proposed decision-tree model using NASA datasets. The proposed feature selection-based prediction model was used to assess the cross-company defects prediction (CCDP) on multiple defect databases. Their proposed clustering-based defect prediction model was used to group the new defects in the cross-company defects for defect prediction. They used a hybrid attribute selection measure based on information gain, correlation coefficient, and relief FS to improve the accuracy of the ensemble’s majority voting in the Mapper phase. They used different base classifiers such as improved random forest and improved decision trees to predict the new test samples in the reducer phase. In the end, results were measured as accuracy measures. The experimental results show that the proposed model results in the highest accuracy measure. By taking into account the above-mentioned literature, we found that many researchers have focused on the issue of attaining higher accuracy in terms of cross projects defect prediction. Researchers have tried to achieve a high level of accuracy but only a few of them considered the dataset as multi-class and took into account the issues of class imbalance [11], noise, distribution gap, and feature selection collectively. Research Gap Existing literature critical analysis reveals gaps in the types of repositories used, the steps carried out for data normalization, feature selection techniques, the class of dataset, classifiers, and statistical analysis, along with the measurement of results. We explain the research gap in the above literature review as follows: On carrying out EDA, it is evident that the dataset is multiclass and has issues of noise, class imbalance, and distribution gap. After conducting a literature review from different published research papers, we established that researchers solved class imbalance issues \([1,4,5]\), removed noise \([2,5]\), and reduced the distribution gap \([1,4,5]\) in a disjointed manner. However, we believe that by combining all these techniques, higher cross-project defect prediction accuracy can be achieved. It is evident from the existing literature that by using hybrid feature selection \([4]\), defect prediction accuracy can be improved. Although the researchers experimented on the NASA dataset, we will experiment using the dataset. In addition, it is also evident that for prediction, layered neural networks, as well as the SoftMax activation function \([1]\) as a classifier have been proven to give better results for predicting defects and classifying output classes in multi-class. 3. Proposed Methodology Firstly, to understand our approach better, knowledge of the dataset is important. After that, we present our proposed approach, including the data normalization, architecture settings, and training process in Figure 1 below. ![Flowchart](image.png) **Figure 1.** Our proposed methodology. 3.1. Exploratory Data Analysis (Step 1) We did Exploratory Data Analysis to understand the nature of the dataset in order to normalize the data. To do so, we carried out an exploratory data analysis (EDA). Exploratory data analysis is used by data scientists to analyze and investigate datasets and summarize their main characteristics, often employing data visualization methods. It can also help determine if the statistical techniques being considered for data analysis are appropriate. We performed the experiments on one of the widely used repositories of software defect prediction: PROMISE [12,13]. Table 1 lists the details of the datasets as follows: Table 1. Promise repository features along with their description. <table> <thead> <tr> <th>Sr. No.</th> <th>Attribute</th> <th>Abbreviations</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>WMC</td> <td>Weighted Methods per class</td> <td>The number of methods used in a given class</td> </tr> <tr> <td>2</td> <td>DIT</td> <td>Depth of Inheritance Tree</td> <td>The maximum distance from a given class to the root of an inheritance tree</td> </tr> <tr> <td>3</td> <td>NOC</td> <td>Number of Children</td> <td>The number of children of a given class in an inheritance tree</td> </tr> <tr> <td>4</td> <td>CBO</td> <td>Coupling between Object Classes</td> <td>The number of classes that are coupled to a given class</td> </tr> <tr> <td>5</td> <td>RFC</td> <td>Response for a Class</td> <td>The number of distinct methods invoked by code in a given class</td> </tr> <tr> <td>6</td> <td>LCOM</td> <td>Lack of Cohesion in Methods</td> <td>The number of method pairs in a class that do not share access to any class attributes</td> </tr> <tr> <td>7</td> <td>CA</td> <td>Afferent Coupling</td> <td>Afferent coupling, which measures the number of classes that depends upon a given class</td> </tr> <tr> <td>8</td> <td>CE</td> <td>Efferent Coupling</td> <td>Efferent coupling, which measures the number of classes that a given class depends upon</td> </tr> <tr> <td>9</td> <td>NPM</td> <td>Number of Public Methods</td> <td>The number of public methods in a given class</td> </tr> <tr> <td>10</td> <td>LCOM3</td> <td>Normalized Version of LCOM</td> <td>Another type of lcom metric proposed by Henderson-Sellers</td> </tr> <tr> <td>11</td> <td>LOC</td> <td>Lines of Code</td> <td>The number of lines of code in a given class</td> </tr> <tr> <td>12</td> <td>DAM</td> <td>Data Access Metric</td> <td>The ratio of the number of private/protected attributes to the total number of attributes in a given class</td> </tr> <tr> <td>13</td> <td>MOA</td> <td>Measure of Aggregation</td> <td>The number of attributes in a given class that are of user-defined types</td> </tr> <tr> <td>14</td> <td>MFA</td> <td>Measure of Functional Abstraction</td> <td>The number of methods inherited by a given class divided by the total number of methods that can be accessed by the member methods of the given class</td> </tr> <tr> <td>15</td> <td>CAM</td> <td>Cohesion among Methods</td> <td>The ratio of the sum of the number of different parameter types of every method in a given class to the product of the number of methods in the given class and the number of different method parameter types in the whole class</td> </tr> <tr> <td>16</td> <td>IC</td> <td>Inheritance Coupling</td> <td>The number of parent classes that a given class is coupled to</td> </tr> <tr> <td>17</td> <td>CBM</td> <td>Coupling Between Methods</td> <td>The total number of new or overwritten methods that all inherited methods in a given class are coupled to</td> </tr> <tr> <td>18</td> <td>AMC</td> <td>Average Method Complexity</td> <td>The average size of methods in a given class</td> </tr> <tr> <td>19</td> <td>MAX_CC</td> <td>Maximum Values of Methods in the same class</td> <td>The maximum McCabe’s cyclomatic complexity (CC) score of methods in a given class</td> </tr> <tr> <td>20</td> <td>AVG_CC</td> <td>Mean Values of Methods in the same class</td> <td>The arithmetic means of McCabe’s cyclomatic complexity (CC) scores of methods in a given class</td> </tr> </tbody> </table> PROMISE repository consists of different datasets such as Ant, Camel, Jedit, Log4j, Ivy, Lucene, Synapse, Velocity, Xerces, Xalan, and Poi. Each dataset consists of 20 features, shown above in Table 1. There is a total of 11 projects with 35 different versions. Table 1 lists the details of the datasets. On EDA, we established that the dataset had issues of noise, data distribution gap, class imbalance issue, and had a multi-class nature. The multi-class nature of the dataset can better be described visually, as shown in the Figures 2 and 3 below. From the above diagrams, it is obvious that the promise dataset is multi-class, so we treated the dataset as multi-class during data normalization. 1. Read CSV File After performing all these steps, we obtained normalized data for our experimentation. Let us explain each step in detail. To answer and describe each issue, we divided our process into two steps for each, which were: - Describing the method of performing an experiment - Displaying the dataset before and after performing an experiment ### 3.2. Data Pre-Processing (Step 2) To normalize the dataset, we first removed the noise from the dataset. After removing noise, we covered the distribution gap between source and target projects. In the last step, we solved the issue of class imbalance by generating synthetic data. After performing all these steps, we obtained normalized data for our experimentation. Let us explain each step of data pre-processing in detail. 3.2.1. Noise The repository has noise in the form of duplicated rows. We removed noise from the PROMISE dataset by removing the redundant data, so that our trained model predicts the defects accurately with higher accuracy. - Method to Perform Experiment To resolve the issue of noise in the dataset, we performed the following steps: 1. Read CSV File 2. Drop all unimportant columns, i.e., name and version 3. Use pandas’ duplicated method on the data retrieved from CSV file 4. Duplicating method of panda's library, traversing each row in the dataset one by one throughout the file and selecting the duplicated rows. 5. Use pandas’ method drop_duplicates on the data retrieved from the CSV file 6. Use drop_duplicates method to remove all the retrieved duplicated rows from the dataset. 7. Display dataset before and after performing the experiment Figures 4 and 5 display the result before and after experimenting. From the EDA, we established that there was noise as redundant data in the rows of the dataset. This can better be explained visually as Figure 4 below: ![Figure 4. Noise in terms of duplicated records in ant version 1.3.](image) We removed duplicated rows in the dataset in the first step of data normalization. After removing the noise, we obtained these results: ![Figure 5. Removed noise in terms of duplicated records in ant version 1.3.](image) 3.2.2. Distribution Gap After removing noise, in the next step, we covered the data distribution gap in the datasets. - Method: To cover this gap, we used an adversarial learning concept. We first combined all the versions of datasets; in other words, we combined all the versions of Ant datasets as one CSV file and did the same for all the projects. The reason for combining all the versions is to have maximum data for training. After combining them, we had 11 different projects. We performed the following steps: - read source CSV File - we created a list of all the columns - we applied a loop for each column - we calculated minimum and maximum values based on the column - we generated a list containing minimum and maximum range values for each column - we removed those values which are outside the calculated min and max acceptable column values and made sure both source and target appeared in the same space. - Dataset before and after the experiment: Figures 6 and 7 show the result before and after experimenting. ![Figure 6. Before removing the data distribution of the “dit” feature of the Ant project.](image) Above are the graphs of the “dit” feature of the Ant and Camel projects. We can see their distribution gap. We covered this gap using adversarial learning, in which we selected one project as the source and the other project as a target. There are two components in adversarial learning which bring source and target projects to a common space to remove the distribution gap between projects in CPDP. In adversarial learning, the generator component learns the source project. The target project is fed to the discriminator of the architecture which discriminates the source and target projects and also generates the min-max value. This min-max value will help the generator to train the source project as per the distribution of the target project. When the discriminator fails to recognize the distribution gap between the source and target project, our source project is completely trained and our source and target projects start to be situated in a common space. All the values outside the min-max value of the projects were considered outliers which we removed to cover the distribution gap completely. After removing the distribution gap, the above projects look as in Figures 8 and 9 below: ![Figure 7](image1) **Figure 7.** Before removing the data distribution of the “dit” feature of the Camel project. ![Figure 8](image2) **Figure 8.** After removing the data distribution of the “dit” feature of the Ant project. ![Figure 9](image3) **Figure 9.** After removing the data distribution of the “dit” feature of the Camel project. Above are the graphs of the “dit” feature of Ant and Camel projects after covering the distribution gap. ### 3.2.3. Class Imbalance In the last step of pre-processing, we solved the issue of class imbalance both in terms of the total number of instances and a total number of output classes. We solved the issue of class imbalance using a CTGANSynthesizer. - **Method:** To solve the class imbalance issue from the dataset, we performed the following steps: - Once the outliers had been removed from the dataset, we used a CTGANSynthesizer. CTGAN is a collection of deep-learning-based synthetic data generators for single-table data, which can learn from real data and generate synthetic clones with high fidelity. - We passed 100 as an epoch value as a parameter of CTGANSynthesizer to obtain the most relevant values. - We then trained the CTGANSynthesizer model by passing data and discrete columns as parameters. - We passed the sample size as 960, the highest number of rows in the PROMISE repository datasets. Then, using this technique, all the minority classes were oversampled to the majority class. - Dataset before and after the experiment: Tables 2 and 3 display the results before and after experimenting. All the projects have different numbers of classes in datasets as follows: **Table 2.** List the total number of instances for each version before resolving class imbalance. Maximum number of rows is 960 for Camel-1.6 and the minimum number of rows is 7 for Forrest-0.6. <table> <thead> <tr> <th>Class Name</th> <th>Total Columns</th> <th>Total Rows</th> </tr> </thead> <tbody> <tr> <td>Camel-1.6</td> <td>24</td> <td>966</td> </tr> <tr> <td>Xalan-2.7</td> <td>24</td> <td>910</td> </tr> <tr> <td>Xalan-2.6</td> <td>24</td> <td>886</td> </tr> <tr> <td>Camel-1.4</td> <td>24</td> <td>873</td> </tr> <tr> <td>Xalan-2.5</td> <td>24</td> <td>804</td> </tr> <tr> <td>Ant-1.7</td> <td>24</td> <td>746</td> </tr> <tr> <td>Forest-0.8</td> <td>24</td> <td>33</td> </tr> <tr> <td>Forest-0.7</td> <td>24</td> <td>30</td> </tr> <tr> <td>Pbeans-1</td> <td>24</td> <td>27</td> </tr> <tr> <td>ckjm</td> <td>24</td> <td>11</td> </tr> <tr> <td>Forest-0.6</td> <td>24</td> <td>7</td> </tr> </tbody> </table> **Table 3.** List the total number of instances for each version after resolving the class imbalance. <table> <thead> <tr> <th>Class Name</th> <th>Total Columns</th> <th>Total Rows</th> </tr> </thead> <tbody> <tr> <td>Camel-1.6</td> <td>24</td> <td>966</td> </tr> <tr> <td>Xalan-2.7</td> <td>24</td> <td>966</td> </tr> <tr> <td>Xalan-2.6</td> <td>24</td> <td>966</td> </tr> <tr> <td>Camel-1.4</td> <td>24</td> <td>966</td> </tr> <tr> <td>Xalan-2.5</td> <td>24</td> <td>966</td> </tr> <tr> <td>Ant-1.7</td> <td>24</td> <td>966</td> </tr> <tr> <td>Forest-0.8</td> <td>24</td> <td>966</td> </tr> <tr> <td>Forest-0.7</td> <td>24</td> <td>966</td> </tr> <tr> <td>Pbeans-1</td> <td>24</td> <td>966</td> </tr> <tr> <td>ckjm</td> <td>24</td> <td>966</td> </tr> <tr> <td>Forest-0.6</td> <td>24</td> <td>966</td> </tr> </tbody> </table> To resolve the class imbalance issue, we generated synthetic data using CTGAN. We established the maximum number of classes in any of the datasets, which was 966, and then generated all the datasets synthetically equal to 966. CTGAN learnt the dataset pattern and generated the data on the same pattern to solve the class imbalance issue. In a detailed study about classes, we established that most of the classes of the dataset have much less data, which ultimately decreases the performance of our approach. To achieve better results, we took class 0 and class 1 as they were, but merged the classes with the bugs’ label 2, 3, 4, 5, 6, and 7 as 2. This meant that Class 2 had all kinds of bugs of classes 2, 3, 4, 5, 6, and 7. We did so to obtain the maximum data to train our model. Among the 960 classes of each of the projects, we generated equal classes for every bug... class; in other words, we generated 320 classes for each of the bug class0, class1, and class2. We also balanced the classes of output. After solving each of the issues, we obtained the normalized data for further experimentation. 3.3. Hybrid Feature Selection (Step 3) After obtaining normalized data, we carried out feature selection to obtain the optimal feature subset for our experimentation. Hybrid methods offer a good way of combining weak feature selection methods to obtain more robust and powerful ways to select variables. Rather than using a single approach to select feature subsets as the previous methods do, hybrid methods combine the different approaches to obtain the best possible feature subset. The big advantage that hybrid methods offer is high performance and accuracy [14], better computational complexity than with wrapper methods, and models that are more flexible and robust against high dimensional data. There are two types of hybrid feature selection, i.e., 1. Filter & Wrapper methods, and 2. Embedded and Wrapper Methods. We chose embedded and wrapper methods, which can be used to select top features, and then performed a wrapper method to rank the selected features which contribute more to the results. We used the recursive feature elimination technique to obtain our optimal feature subset. Recursive feature elimination works as follows: - Train a model on all the data features. This model can be tree-based, lasso, or others that can offer feature importance. Evaluate its performance on a suitable metric of your choice. - Derive the feature importance to rank features accordingly. - Use the previous evaluation metric to calculate the performance of the resulting model. - Now, test whether the evaluation metric decreases arbitrarily. If it does, that means this feature is important. Otherwise, you can remove it. - Repeat steps 3–5 until all features are removed (i.e., evaluated). - This method removes the feature only once rather than removing all the features at each step. This is why this approach is faster than pure wrapper methods and better than pure embedded methods. - We used random forests to select the best features. We also used recursive feature elimination and cross-validation (RFECV) to rank the optimal features selected. RFECV uses different parameters for feature selection details, which are as follows: - min_feature_to_select: as its name suggests, this parameter sets the minimum number of features to be selected. - Step: how many features do we remove at each step? - CV: an integer, generator, or iterable that describes the cross-validation splitting strategy. - Scoring: the evaluation metric we use. 3.4. Dataset Division (Step 4) After selecting features using a hybrid feature selection technique, we split the datasets into training and testing projects. Since we have less data to train our classifier, we combined all the versions of the same projects into one project and used these projects as source projects, in order to have the maximum amount of data to obtain better results. We then tested our target projects against these source projects to evaluate the prediction accuracy. 3.5. Classification (Step 5) Data classification is carried out to obtain accuracy for our evaluation approach. To do this, we needed a classifier [15]. Since the dataset is multi-class and we were aiming to experiment on the cross-project, we added a two-layer NN which applies Softmax activation on the top of the neural network. The classifier takes the mapped instances as training data and generates a class probability as output. We used two layers of the neural network, which are the input layer and the LeakyReLU layer [15]. Using this classifier, we classified our results into Class 0, Class 1, and Class 2. We also took each of the projects as a source and target and evaluated their performance, i.e., we first took Ant as the target and all others as a source and checked the accuracies one by one. We repeated the steps by changing the target every time and by taking the rest of the projects as the source. 3.6. Model Tuning (Step 6) We fine-tuned our model to check our results on different architectural settings. Fine-tuning of the model includes the adjustment of weights, epochs, and other parameters. By adjusting these parameters, we calculated the errors between the last output layer and the actual target layer. Fine-tuning our model helped us to identify the settings with which our model performs the best. 3.7. Research Methodology This section describes the detailed facts of our study. All the sections for both the research questions remained the same except for independent variables and design. The content is discussed in detail. 3.7.1. Context The context of our research is cross-project defect prediction. We predicted the defects in cross-project using the neural network layer. 3.7.2. Data Collection The dataset consists of numeric and statistical data, so our research used quantitative research methods to collect data, as quantitative research methods focus on numbers and statistics. We used the numeric datasets of different projects of the PROMISE repository as input to our approach for training our model. In our research, we normalized the datasets before training our model (e.g., removing noise, and class imbalance issues and covering the distribution gap between source and target projects). 3.7.3. Research Type The research type of our approach is explanatory. The objective of explanatory research is to explain the causes and consequences of a well-defined problem. Cross-project defect prediction is a well-defined problem. We found the defect prediction accuracy using hybrid feature selection and layers of neural network, to which SoftMax activation layer was applied as a classifier. 3.7.4. Research Method Our research is based on an experimental research method to manipulate and control variables in order to determine cause and effect between variables for prediction accuracy and authenticity. Our research method consists of the following sub-sections. - Perspective The perspective of our experiment is the earlier defect prediction based on already developed non-defective projects. Through our experiment, we predicted the defects earlier by training our model using trained source projects and then testing our trained model in the target projects. - Purpose The purpose of our experiment is to evaluate the impact of optimal feature selection through hybrid feature selection in neural networks for cross-project defect prediction, and to achieve higher defect prediction accuracy by getting optimal features through hybrid feature selection after normalizing data by removing noise, solving class imbalance issues, and covering the distribution gap between source and target projects of the PROMISE Repository. - **Object of study** We set projects of the PROMISE Repository as source and target projects which are the objects of the study. - **Dependent variables** Our research has accuracy (AUC) as the dependent variable. - **Statistical Analysis** Our research will use the Wilcoxon test for cross-project defect prediction authenticity as statistical analysis. - **Independent variables for RQ1** Our research has NN as a manipulative independent variable. - **Design for RQ1** Our research design is IF1T (1 factor 1 treatment). - **Factor- Design Method** 1. NN 3.8. **Research Question** According to our literature review, research summary, and research gap, we addressed the following questions in our research paper: **RQ1**: What is the impact of hybrid feature selection in multi-class for the cross-project defect prediction accuracy of the PROMISE repository? **Null Hypothesis (H0)**: Hybrid feature selection has no impact on multi-class in predicting cross-project defect prediction accuracy of the PROMISE repository. **Alternate Hypothesis (H1)**: Hybrid feature selection has an impact on multi-class in predicting cross-project defect prediction accuracy of the PROMISE repository. 4. **Result and Analysis** In this section, we will answer our research question and will also analyze our results. The research question addressed is as follows: 4.1. **Hyper-Parameter Tuning** We fine-tuned hyper-parameters by adjusting our learning rate, epochs, and neural network layers to get the optimal hyper-parametric settings for defect prediction. Details are: 4.1.1. **Learning Rate** We took Ant as the target project and Log4j as the source project to see the impact of fine-tuning on learning rate. We performed the same experiment on a learning rate of 0.1, 0.01, and 0.001. The Figures 10–12 below show the visualization of results for each learning rate. To set the epochs for the experiment, we took Ant as the target project and Log4j as the source project to see the impact of fine-tuning epochs. We performed the same experiment on epochs 30, 100, and 200. The Figures 13–15 below show the visualization of results for each of the epochs. From the above visualization in Figures 10–12, it is clear that the optimized learning rate for the project is 0.01. 4.1.2. Epochs From the above visualization in Figures 13–15, it is clear that the set of epochs for the project should be 100, so we set 100 epochs for all the projects throughout the experiment except the Log4j and Ivy. For Log4j as the target and all others as the source, epochs vary... from 200–500. Similarly, for Ivy as the target project, epochs for every other source project vary from 300–500 due to having less data for training. Figure 13. Graphical representation of model at Epochs 30. Figure 14. Graphical representation of model at Epochs 100. Figure 15. Graphical representation of model at Epochs 200. 4.1.3. Neural Network Layers We took Ant as the target project and Log4j as the source project to see the impact of adding dense layers to our architecture. We performed the same experiment on dense layers at 16, 32, and 64. The Figures 16–18 below show the visualization of results for each of the dense layer settings. From the above visualization in Figures 16–18, it is clear that the optimized dense layers for the project are 32, so we set dense layers as 32 for all the projects throughout the experiment. 4.1.3. Adding layers **Figure 16.** Graphical representation of model with Dense Layer 16. **Figure 17.** Graphical representation of model with Dense Layer 32. **Figure 18.** Graphical representation of model with Dense Layer 64. 4.2. Experimental Configuration Experimental configurations of our experiment were as follows: - **Batch Size:** 64 - **Epochs:** We set the epochs for almost every project as 100 but for a smaller number of training datasets. We also set epochs to be 200 or 300. - **Optimizer:** Adam (learning rate = 0.001) - **Activation Function:** SoftMax - **Hybrid feature selection method and neural network model architecture is shown in below Figure 19** In this study, the number of epochs was set to 100, except for some of the projects with fewer data issues, and the time cost was less than 60 s for every target project which was run. 4.3. Results and Analysis In this section, we will answer our research question and will also analyze our results. The research question addressed was as follows: **RQ1:** What is the impact of hybrid feature selection in multi-class for the cross-project defect prediction accuracy of the PROMISE repository? To answer this question in our research, we performed a controlled experiment on open-source projects of the PROMISE repository and evaluated the results in terms of AUC measure. We first normalized the dataset by removing noise, covering the distribution gap, and solving the class imbalance issue. The PROMISE repository consists of 28 datasets of many versions of 11 different projects. We combined all the versions of each of the datasets as one project to increase the dataset, in order to improve the training of our model. We then used the hybrid feature selection method to obtain the optimal feature subset that contributes the most to defect prediction. After obtaining the optimal features, we evaluated the accuracy of our model in terms of AUC measure by using two layered neural networks with a SoftMax Activation layer on the top as a classifier to classify the results in class0, class1, and class2. We have displayed our results for each of the target and source projects of the repository and evaluate the results in AUC measure as follows in Table 4: Table 4. Results of Experiment in AUC Measure for each target project. <table> <thead> <tr> <th>Source</th> <th>AUC Measure</th> </tr> </thead> <tbody> <tr> <td>Target</td> <td>Ant</td> </tr> <tr> <td>Ant-1.3</td> <td>62.91%</td> </tr> <tr> <td>Ant-1.4</td> <td>70.76%</td> </tr> <tr> <td>Ant-1.5</td> <td>77.46%</td> </tr> <tr> <td>Ant-1.7</td> <td>76.78%</td> </tr> <tr> <td>Camel-1.2</td> <td>70.81%</td> </tr> <tr> <td>Camel-1.4</td> <td>80.96%</td> </tr> <tr> <td>Camel-1.6</td> <td>78.86%</td> </tr> <tr> <td>Ivy-2.0</td> <td>84.08%</td> </tr> <tr> <td>Jedit-3.2</td> <td>83.90%</td> </tr> </tbody> </table> Table 4. Cont. <table> <thead> <tr> <th>AUC Measure</th> <th>Source</th> <th>Target</th> <th>Ant</th> <th>Camel</th> <th>Jedit</th> <th>Lucene</th> <th>Poi</th> <th>Log4j</th> <th>Velocity</th> <th>Synapse</th> <th>Ivy</th> <th>Xalan</th> <th>Xerces</th> </tr> </thead> <tbody> <tr> <td>Jedit-4.0</td> <td>86.05%</td> <td>77.30%</td> <td>76.90%</td> <td>64.95%</td> <td>62.33%</td> <td>65.40%</td> <td>84.83%</td> <td>82.67%</td> <td>64.50%</td> <td>53.62%</td> <td></td> <td></td> <td></td> </tr> <tr> <td>Jedit-4.1</td> <td>80.75%</td> <td>71.28%</td> <td>–</td> <td>66.51%</td> <td>65.26%</td> <td>58.24%</td> <td>48.99%</td> <td>71.39%</td> <td>82.65%</td> <td>77.54%</td> <td>58.00%</td> <td></td> <td></td> </tr> <tr> <td>Log4j-1.0</td> <td>80.68%</td> <td>76.86%</td> <td>73.98%</td> <td>75.23%</td> <td>71.62%</td> <td>–</td> <td>66.16%</td> <td>64.75%</td> <td>73.01%</td> <td>65.80%</td> <td>60.53%</td> <td></td> <td></td> </tr> <tr> <td>Log4j-1.1</td> <td>86.09%</td> <td>77.48%</td> <td>75.36%</td> <td>78.90%</td> <td>69.61%</td> <td>–</td> <td>62.16%</td> <td>72.47%</td> <td>58.60%</td> <td>71.52%</td> <td>60.10%</td> <td></td> <td></td> </tr> <tr> <td>Log4j-1.2</td> <td>61.99%</td> <td>66.25%</td> <td>58.96%</td> <td>65.82%</td> <td>53.89%</td> <td>–</td> <td>50.55%</td> <td>59.68%</td> <td>49.38%</td> <td>56.86%</td> <td>48.24%</td> <td></td> <td></td> </tr> <tr> <td>Lucene-2.0</td> <td>74.84%</td> <td>69.11%</td> <td>63.11%</td> <td>–</td> <td>66.82%</td> <td>56.62%</td> <td>57.70%</td> <td>71.58%</td> <td>75.04%</td> <td>65.88%</td> <td>54.75%</td> <td></td> <td></td> </tr> <tr> <td>Lucene-2.2</td> <td>65.98%</td> <td>61.37%</td> <td>66.38%</td> <td>–</td> <td>66.24%</td> <td>61.59%</td> <td>55.50%</td> <td>65.02%</td> <td>66.61%</td> <td>60.47%</td> <td>55.59%</td> <td></td> <td></td> </tr> <tr> <td>Lucene-2.4</td> <td>68.31%</td> <td>64.91%</td> <td>66.50%</td> <td>–</td> <td>62.42%</td> <td>66.92%</td> <td>58.11%</td> <td>63.65%</td> <td>62.04%</td> <td>62.21%</td> <td>53.58%</td> <td></td> <td></td> </tr> <tr> <td>Synapse-1.0</td> <td>88.08%</td> <td>65.65%</td> <td>64.03%</td> <td>65.82%</td> <td>78.39%</td> <td>49.82%</td> <td>59.50%</td> <td>–</td> <td>77.69%</td> <td>75.36%</td> <td>49.59%</td> <td></td> <td></td> </tr> <tr> <td>Synapse-1.1</td> <td>74.45%</td> <td>71.04%</td> <td>74.07%</td> <td>64.73%</td> <td>69.38%</td> <td>57.49%</td> <td>57.98%</td> <td>–</td> <td>73.42%</td> <td>62.96%</td> <td>63.15%</td> <td></td> <td></td> </tr> <tr> <td>Synapse-1.2</td> <td>72.65%</td> <td>65.63%</td> <td>61.25%</td> <td>62.15%</td> <td>65.05%</td> <td>59.05%</td> <td>61.39%</td> <td>–</td> <td>72.36%</td> <td>66.82%</td> <td>58.91%</td> <td></td> <td></td> </tr> <tr> <td>Velocity-1.4</td> <td>61.64%</td> <td>53.99%</td> <td>59.91%</td> <td>63.86%</td> <td>61.13%</td> <td>64.92%</td> <td>–</td> <td>66.89%</td> <td>63.72%</td> <td>59.26%</td> <td>58.75%</td> <td></td> <td></td> </tr> <tr> <td>Velocity-1.5</td> <td>68.99%</td> <td>60.81%</td> <td>77.47%</td> <td>73.42%</td> <td>68.40%</td> <td>61.90%</td> <td>–</td> <td>71.65%</td> <td>65.47%</td> <td>64.60%</td> <td>64.43%</td> <td></td> <td></td> </tr> <tr> <td>Velocity-1.6</td> <td>56.93%</td> <td>55.34%</td> <td>57.90%</td> <td>58.05%</td> <td>63.65%</td> <td>48.25%</td> <td>–</td> <td>65.30%</td> <td>63.87%</td> <td>51.56%</td> <td>51.45%</td> <td></td> <td></td> </tr> <tr> <td>Xalan-2.4</td> <td>72.63%</td> <td>69.76%</td> <td>69.86%</td> <td>65.40%</td> <td>67.00%</td> <td>57.75%</td> <td>56.21%</td> <td>69.51%</td> <td>76.31%</td> <td>–</td> <td>64.72%</td> <td></td> <td></td> </tr> <tr> <td>Xalan-2.5</td> <td>79.00%</td> <td>78.57%</td> <td>74.75%</td> <td>69.07%</td> <td>73.39%</td> <td>58.82%</td> <td>55.21%</td> <td>74.44%</td> <td>78.51%</td> <td>–</td> <td>60.88%</td> <td></td> <td></td> </tr> <tr> <td>Xalan-2.6</td> <td>77.25%</td> <td>70.32%</td> <td>71.56%</td> <td>68.36%</td> <td>64.83%</td> <td>59.30%</td> <td>51.37%</td> <td>73.86%</td> <td>76.62%</td> <td>–</td> <td>67.41%</td> <td></td> <td></td> </tr> <tr> <td>Xerces-1.2</td> <td>63.35%</td> <td>64.73%</td> <td>60.31%</td> <td>55.35%</td> <td>60.20%</td> <td>54.14%</td> <td>53.95%</td> <td>65.14%</td> <td>66.32%</td> <td>54.75%</td> <td>–</td> <td></td> <td></td> </tr> <tr> <td>Xerces-1.4</td> <td>63.71%</td> <td>64.76%</td> <td>64.55%</td> <td>63.91%</td> <td>61.74%</td> <td>62.79%</td> <td>50.11%</td> <td>59.23%</td> <td>60.14%</td> <td>64.96%</td> <td>–</td> <td></td> <td></td> </tr> </tbody> </table> The above Table 4 show the results of our experiment, which we established by finding the impact of the NN classifier along with the SoftMax layer. The SoftMax layer performs the best when it comes to multi-class datasets because of its output probability range, which is from 0 to 1, and the sum of all probabilities is equal to 1. Using EDA, we established that the dataset had 63 output classes in which the majority of the instances were 0 and 1 classes. Instances greater than 1 were so few in number that we put them all in class 2. The reason was that to have the maximum amount of data for training our model, we used CTGAN to generate synthetic data. CTGAN trains the classifier based on several instances and then generates the synthetic data on the pattern of already existing classes. CTGAN learns the pattern and generates data where greater number of data is required. All the classes above 1 were fewer in number and CTGAN finds it difficult to generate the synthetic data with less data. To overcome this issue, we combined all the classes above 1 in a single class 2. To experiment, we combined all the versions of the same dataset as one project and treated it as the source. We then tested one source project against all the versions of 28 projects from the promise repository. We combined the versions to get a large range of data so that we could efficiently train our classifier. By combining the versions of one project, we also obtained the maximum range of the project to train our classifier. Table 4 shows the results we obtained from our experiment. We have highlighted the highest accuracy of one project in bold in every row. In Table 4, where source and target are same, we put dashes at their intersection point because we aren’t addressing the issue of WPDP. As our experimental domain is cross-project defect prediction, we did not predict the results for the same target projects. From our experimental results, it is evident that through hybrid feature selection we obtained the optimal set of features. By combining the SoftMax layer with the NN layer, better prediction accuracies were achieved for a multi-class dataset in terms of AUC measure for the PROMISE repository, which supports our alternative hypothesis, i.e., “Hybrid feature selection selects optimal feature sets for multi-class in predicting cross-project defect prediction accuracy of PROMISE repository”. 4.4. Research Validation We validated our results with two statistical tests i.e., the Wilcoxon Test. Details are as follows: 4.4.1. Wilcoxon Test “The Wilcoxon signed ranks test is a nonparametric statistical procedure for comparing two samples that are paired, or related. The parametric equivalent to the Wilcoxon signed ranks test goes by names such as the student’s $t$-test, $t$-test for matched pairs, $t$-test for paired samples, or $t$-test for dependent samples”. 4.4.2. Hypothesis Assumption The following are the assumptions for the hypothesis: - Observations in each sample are independent and identically distributed (iid). - Observations in each sample can be ranked. 4.4.3. Acceptance Criteria The significance level, based on the information provided, is alpha = 0.05. If the $p$-value is greater than alpha, then H0 is accepted, otherwise it is rejected. 4.4.4. Test Statistics Table 5 shows the test results using the Wilcoxon test. We calculated the value of $p$ by passing two groups in the Wilcoxon test. We considered Ant as a target project and observed the accuracy with other source projects i.e., Ivy, Camel, Synapse, Velocity, Lucene, Poi, Xerces, Xalan, and Log4j. One of the groups of the observation contained values of measure without applying hybrid feature selection and another observation contained values of the measure after applying hybrid feature selection. <table> <thead> <tr> <th>Test Statistics</th> <th>$p$-Value</th> <th>Accepted Hypothesis</th> </tr> </thead> <tbody> <tr> <td>Wilcoxon Test</td> <td>0.0039</td> <td>H1</td> </tr> </tbody> </table> 4.4.5. Analysis of Validation Test The above Table 5 shows that our alternative hypothesis was approved, which clearly shows that our approach of hybrid feature selection in neural networks does have an impact on the cross-project defect prediction. 5. Threat to Validity During an empirical study, one should be aware of the potential threats to the validity of the obtained results and derived conclusions. The potential threats to the validity identified for this study are divided into three categories, namely: internal, external, and construct validity. 5.1. Internal Validity We implemented the baselines by carefully following the base papers [1,2]. These compared related works did not provide the source codes of their works, so we did not work on the source code of the dataset. We worked on the static features of the dataset. 5.2. External Validity PROMISE datasets used for validation are open-source software project data. If our proposed approach were built on closed software projects developed under different environments, it might produce better/worse performance. 5.3. Construct Validity We mainly used AUC-measure, which has been widely used to evaluate the effectiveness of defect prediction models, to evaluate the prediction performance. On the other hand, the experimental datasets were collected by Jureczko et al., who cautioned that there could be some mistakes in non-defective labels as not all the defects had been found. This may be a potential threat to defect prediction model training and evaluation [16]. 6. Conclusions Using EDA, we established that the PROMISE dataset was multi-class, which has noise, distribution gap, and class imbalance issues, as clearly shown above in Figures 2, 4, 5, 7 and 8, and Table 3. From our experimental results, it is evident that after removing noise, covering the distribution gap and balancing the classes, and selecting optimal features set using the hybrid feature selection technique, we can obtain better results. We used the NN classifier along with the Softmax layer to predict the accuracy of our experiment as the SoftMax layer has proved to perform better for multi-class classification. We predicted the accuracy for all 28 versions of all 11 projects in terms of AUC measure, with an average of 75.96%. We validated our results using the Wilcoxon test. Our experimental results clearly illustrate that CPDP can help to predict the defects in software modules and will help in the early prediction of defects. Funding: This research paper is funded by Deanship of Scientific Research at King Saud University. Institutional Review Board Statement: Not applicable. Informed Consent Statement: Not applicable. Data Availability Statement: Not applicable. Acknowledgments: The authors would like to extend their sincere appreciation to the Deanship of Scientific Research at King Saud University for its funding this Research—Group No (RG-1436-039). Conflicts of Interest: The authors declare no conflict of interest. References
{"Source-Url": "https://mdpi-res.com/d_attachment/applsci/applsci-12-12167/article_deploy/applsci-12-12167.pdf?version=1669642458", "len_cl100k_base": 12927, "olmocr-version": "0.1.53", "pdf-total-pages": 20, "total-fallback-pages": 0, "total-input-tokens": 71799, "total-output-tokens": 15071, "length": "2e13", "weborganizer": {"__label__adult": 0.0003886222839355469, "__label__art_design": 0.00045371055603027344, "__label__crime_law": 0.0003151893615722656, "__label__education_jobs": 0.0015478134155273438, "__label__entertainment": 7.325410842895508e-05, "__label__fashion_beauty": 0.00022399425506591797, "__label__finance_business": 0.00035572052001953125, "__label__food_dining": 0.0003046989440917969, "__label__games": 0.0007052421569824219, "__label__hardware": 0.0009870529174804688, "__label__health": 0.0006074905395507812, "__label__history": 0.0002312660217285156, "__label__home_hobbies": 0.00013816356658935547, "__label__industrial": 0.0004775524139404297, "__label__literature": 0.0002646446228027344, "__label__politics": 0.00020253658294677737, "__label__religion": 0.0004420280456542969, "__label__science_tech": 0.03497314453125, "__label__social_life": 0.0001239776611328125, "__label__software": 0.007373809814453125, "__label__software_dev": 0.94873046875, "__label__sports_fitness": 0.00029587745666503906, "__label__transportation": 0.0004014968872070313, "__label__travel": 0.0001888275146484375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 55621, 0.069]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 55621, 0.12284]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 55621, 0.90875]], "google_gemma-3-12b-it_contains_pii": [[0, 3756, false], [3756, 8184, null], [8184, 12737, null], [12737, 15109, null], [15109, 19784, null], [19784, 21278, null], [21278, 23443, null], [23443, 25011, null], [25011, 28292, null], [28292, 31911, null], [31911, 35161, null], [35161, 37512, null], [37512, 38210, null], [38210, 39058, null], [39058, 39744, null], [39744, 42474, null], [42474, 47079, null], [47079, 49656, null], [49656, 53622, null], [53622, 55621, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3756, true], [3756, 8184, null], [8184, 12737, null], [12737, 15109, null], [15109, 19784, null], [19784, 21278, null], [21278, 23443, null], [23443, 25011, null], [25011, 28292, null], [28292, 31911, null], [31911, 35161, null], [35161, 37512, null], [37512, 38210, null], [38210, 39058, null], [39058, 39744, null], [39744, 42474, null], [42474, 47079, null], [47079, 49656, null], [49656, 53622, null], [53622, 55621, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 55621, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 55621, null]], "pdf_page_numbers": [[0, 3756, 1], [3756, 8184, 2], [8184, 12737, 3], [12737, 15109, 4], [15109, 19784, 5], [19784, 21278, 6], [21278, 23443, 7], [23443, 25011, 8], [25011, 28292, 9], [28292, 31911, 10], [31911, 35161, 11], [35161, 37512, 12], [37512, 38210, 13], [38210, 39058, 14], [39058, 39744, 15], [39744, 42474, 16], [42474, 47079, 17], [47079, 49656, 18], [49656, 53622, 19], [53622, 55621, 20]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 55621, 0.25455]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
9ead32301364150c41dd0b5fed2507ccd3825bf3
Relative Importance of Factors Constituting Component Reusability Fazal-e-Amin, Ahmad Kamil Mahmood and Alan Oxley Department of Computer and Information Sciences, University Technology Petronas, Bandar Seri Iskandar, 31750 Tronoh, Perak, Malaysia Corresponding Author: Fazal-e-Amin, Department of Computer and Information Sciences, University Technology Petronas, Bandar Seri Iskandar, 31750 Tronoh, Perak, Malaysia ABSTRACT The potential benefits of software reuse include a reduction in development time, effort, cost and an increase in quality and productivity. Reuse is carried out either by using component based software development or by systematic reuse as is employed by software product lines. Improved accessibility of open source software components has opened up new avenues for combining software components with software product lines. As a result, proposals for open source component based software product lines appear in the literature. This study is a step forward in this direction. An assessment approach for software component reusability is employed and reusability of several components is assessed. The results include a statistical analysis to determine the correlation between the factors of reusability. The results show a strong correlation of four out of six identified factors with reusability. Key words: Software product line, software components, reusability assessment, open source, mixed-method, interview INTRODUCTION Software reuse refers to the process of developing software by making use of existing software (Krueger, 1992). Reuse in software development is motivated by the factors of time, cost and effort. Software reuse results in better quality and productivity (Mohagheghi and Conradi, 2007). It reduces the cost and effort to develop software (Frakes and Succi, 2001). The two common forms in which reuse is employed are component based software development and Software Product Line (SPL) development. The latter is a systematic way of reuse. An SPL is defined as “development for the reuse and development with reuse” (Van der Linden et al., 2007). It is a reuse-intensive software development where reuse is the main tenet. SPLs, being a systematic way of software reuse, distinguish the common features of products from the unique ones. These commonalities are catered for by common components. The collection of common components is referred as core components. A key feature of such components is ‘variability’, i.e., the “degree to which something exists in multiple variants, each having the appropriate capabilities” (Firesmith, 2003). Open Source Software (OSS) is one of the emerging areas within software engineering. It influences the way that software is developed (Hauge et al., 2010), not only at the development level but also on the procedural level. Component based software engineering is one of the main beneficiaries of OSS components. Recent research work (Ahmed et al., 2008) suggest the use of OSS in product line development. One of the reasons the SPL community is attracted towards OSS is the fact that product lines are seldom started from scratch, rather, SPLs emerge when the domain is mature (Knodel et al., 2005). Therefore, OSS may provide an initial support to start new product lines. A SPL is reuse intense development; the focus is on reusing the core assets. The term ‘core asset’ refers to test cases, components, architecture or any common artefact shared by two or more products. The importance of the Off The Shelf components (OTS) is reflected in a claim by Driver (2008) that “It is becoming not only impractical, but also virtually impossible for mainstream IT organizations to ignore the growing presence of third party software in major segments of the IT industry. The failure to optimally manage the potential risks and rewards of using this software will put IT organizations at an increasingly serious risk in coming years”. The benefits of using OSS are explored (Morgan and Finnegan, 2007). These include reliability, security, quality, performance, flexibility of use, flexibility in other respects, low cost, having a large developer and tester base, having community support in the form of users, increased collaboration and escaping vendor lock in, encouraging innovation. These benefits are contributing to the popularity of OSS. Each artefact developed during SPL development is considered as an asset, the organization keeps this asset for reusing it in further products or even in cross product line reuse (Liu et al., 2010). OSS and OTS comes from numerous sources, therefore, the assessment of reusability has more importance in reuse intense developments. Further more, the success of a product line depends on the efficient reuse of core assets. This reuse of a core asset, i.e., its reusability, is related to the quality of the component. Reusability assessment also helps in comparing different components providing same functionality. A review of the software component reusability assessment approaches is presented in (Fazal-e-Amin et al., 2011d), it categorizes approaches according to their types, approach, application level and validation. In this paper only the metrics based approaches are considered. A model and metrics for object oriented C++ based implementations are presented (Elzkorn et al., 2001). In this paper three views of reusability are defined which are: reusability in class, reusability in a hierarchy/subsystem and reusability in the original system. Factors, sub factors and metrics are proposed to measure reusability. Results are validated using expert opinions about the reusability of the components, which is compared with results generated through the application of the proposed approach; regression analysis is used to interpret the results. In (Cho et al., 2001) metrics to measure complexity, customizability and reusability of Java components are proposed. The degree of features reused in developing an application is used to measure reusability. Two types of metrics are proposed, one is the metrics to be used at the design phase and the second is the metrics used after coding—the number of lines of code; the proportion of overall functionality that each component has. These metrics are implemented on components of the banking domain. However, no validation of results is presented in the paper. A model and set of metrics to measure reusability is presented (Dandashi, 2002); it considers adaptability, completeness, maintainability and understand ability as factors affecting reusability. These factors are measured by the metrics. These metrics are applied to the (C++ based) components of a scientific application in order to evaluate the approach. The approach is validated by finding a correlation coefficient between the results of direct measure, using the results of the proposed approach and measures collected via the survey instrument. Two metrics are proposed (Aggarwal et al., 2005) to measure the amount of generic code. The proposed metrics are applied to ten projects. The metrics are evaluated using Weyuker’s properties. Gui and Scott (2007) proposed coupling metrics to rank the reusability of components. Metrics are applied to three types of component to generate the results. The metrics to measure coupling (Gui and Scott, 2007) and cohesion (Gui, 2006) are combined by Gui and Scott (2009) to measure the reusability of software components. In (Gui and Scott, 2008), coupling and cohesion metrics are also proposed to evaluate the reusability of components. The statistical techniques of linear regression and rank correlation are used for validation of the results. This study presents a correlation analysis of attributes and reusability. These attributes are identified by a literature survey and an exploratory study which is part of our future publications. In this study we are only considering the non-functional attributes. MATERIALS AND METHODS The methodology comprises the following steps: **Step 1:** An exploratory study is conducted which identifies the factors affecting reusability along with other findings **Step 2:** The metrics were identified to measure the factors **Step 3:** The hypotheses are generated on the basis of the literature and our findings during an exploratory study about the factors affecting the reusability **Step 4:** The components are downloaded from different sources including (Planet-Source-Code.com and Merobase.com). A total of 75 classes are drawn from 12 components. Here it is important to mention that the classes were in a hierarchy (i.e., are related to each other). A random search was made during the time period January 2011 to February 2011, using the following queries (library system, banking, accounts and user management). The retrieved components were related to the following projects (address book, airline reservation system, menu builder, car sales system, class browser, flight reservation system, user bank account management system) **Step 5:** The proposed metrics are applied to the components to collect the values **Step 6:** These metric values are interpreted using the equations **Step 7:** The scatter plots are drawn and a Pearson correlation test is applied to determine the correlation **Interview:** A summary of the related work is presented in the previous section, apart from it, a detailed review of approaches can be found (Pazal-e-Amin et al., 2011d). Reusability assessment is not viewed in the context of software product lines. Therefore, the nature of the study is exploratory. So, an exploratory research method is used and the ‘interview’ is employed as a data collection tool. The interview is a means of collecting primary data; it is a conversation between two persons, one of which is a researcher. Interviews can be used for data collection where the nature of the study is exploratory. Interviews are helpful when the data to be gathered is about a person’s knowledge, preferences, attitude or values (Gray, 2009). Interviews may help to gather impressions and opinions about something. Interviews enable one to get personalized data, provide an opportunity to probe, establish technical terms that can be understood by the interviewee and facilitate mutual understanding. The interview provides an in-depth view. Interviews are best for exploring the perspective of informants (Gray, 2009). In the context of this study, the informants are those who have experience with open source and product lines and preferably have academic/research experience. The authors have contacted several people and managed to conduct interview sessions with five informants. A brief introduction of them is presented in Table 1. The results are obtained using the content analysis approach (Hsieh and Shannon, 2005; Elo and Kyngas, 2008). Open coding is performed to get meaningful results. The results are divided into different categories. The details of the study cannot be presented here due to space limitations. However, the results relevant to this paper are presented here. The details can be found (Fazal-e-Amin et al., 2011e). The category that this paper is concerned with is factors affecting reusability of OSS in an SPL environment. The scatter diagram gives a notion about the association. However, the correlation coefficient, or Pearson product-moment correlation coefficient, is a mathematical measure. It helps in understanding the strength of the relationship between the variables. **Population of interview:** The research issues investigated in this study are of a specialized nature. Not everybody working in industry or academia is able to answer these questions. The population chosen for this study is based on their expertise. It should be noted that the respondents have up to date information regarding the research in this area and industrial practices. Table 1 provides a glance of the profiles of the respondents. The means used to conduct the interviews are face to face (3), using Skype (1) and telephone (1). Three of the interviews were face to face, one was telephonic and one was conducted using Skype (online communication software). It was not possible to conduct all interviews face to face due to the geographical locations of the respondents. Flexibility is related to reusability in two capacities. First, it is the ability of a component to be used in multiple configurations. Second, it is a necessary attribute concerning future requirements and enhancements. Maintainability is related to reuse in terms of error tracking and debugging. If the component is maintainable it is more likely to be reused. In cases where OSS components are running on systems connected to another system then a bug is particularly problematic. Sometimes debugging a component on one configuration may not work on other configurations. On the other hand in black box reuse, maintainability is not considered a factor of reusability. Portability is considered a factor in the sense that a cohesive component is more portable. A component having all the necessary information within it or having less interaction with another module during its execution is more reusable. Again in the case of black box reuse it is not a factor. Another characteristic of the open source components explored is that the developer looks for a component covering more of the scope of the application. In some situations even the size does not matter but size is a concern in large sized components as it relates to increased complexity and poor understandability. Further more, scope coverage is important in situations where future enhancements are already envisioned or there are chances that more features would be added in future. The interviewees consider stability as an important factor to be considered while making decisions. Here, the term 'stability' refers to security in numbers, that is, a reasonable number of Table 2: Identified factors and representative quotes <table> <thead> <tr> <th>Sub category ID</th> <th>Sub category Name</th> <th>Representative quote</th> </tr> </thead> <tbody> <tr> <td>SC-1</td> <td>Flexibility</td> <td>“Flexibility refers to the ability to use it in multiple configurations”.</td> </tr> <tr> <td></td> <td></td> <td>“In order to reuse some component source code it should be flexible enough to be used in several contexts”.</td> </tr> <tr> <td></td> <td></td> <td>“Flexibility is necessary because there are changes required with the passage of time, so it saves you not to be bound”.</td> </tr> <tr> <td>SC-2</td> <td>Maintainability</td> <td>“Maintainability is a large problem is such situations when you use OSS and we are running the system with connectivity with other systems so every time there are some bugs and removing the bugs in others code that is developed by some other is very difficult for developer”.</td> </tr> <tr> <td>SC-3</td> <td>Portability</td> <td>“Portability is also related to the install ability, it should be taken care and portability should be economical we don’t have to install other softwares to run a component in other systems”.</td> </tr> <tr> <td>SC-4</td> <td>Scope Coverage</td> <td>“That depends on the situation but normally we choose the more coverage component as compare to the less covered one”.</td> </tr> <tr> <td></td> <td></td> <td>“... it depends on the application if we want to extend further our application then we will go for more features”.</td> </tr> <tr> <td>SC-5</td> <td>Stability</td> <td>“Stable meaning reasonably error free and it could be used with confidence that there is no bug”.</td> </tr> <tr> <td>SC-6</td> <td>Understandability</td> <td>“If I don’t understand it then I can’t show that it is reliable and prove it to myself then I am not going to use it”.</td> </tr> <tr> <td></td> <td></td> <td>“Size can be managed but if it is not understandable then it is difficult to reuse’</td> </tr> <tr> <td>SC-7</td> <td>Usage History</td> <td>“Usage history also shows the maturity of the component and how many people have used and made changes to it”.</td> </tr> <tr> <td></td> <td></td> <td>“In many cases open source software is used by many people many engineers, already proven its usefulness”.</td> </tr> <tr> <td>SC-8</td> <td>Variability</td> <td>“Variability is a two edge sword in other words there are advantages and disadvantages”.</td> </tr> <tr> <td>SC-9</td> <td>Documentation</td> <td>“If there is lack of documentation then I mean it creates hurdles to understand the code for any other developer or the software engineers”.</td> </tr> <tr> <td></td> <td></td> <td>“If there is no proper documentation then others cannot understand the software neither can change nor modify it”.</td> </tr> </tbody> </table> developers have contributed in the development of the component and also it has been used by a reasonable number of developers. Stability is also related to the usage history of the component. Usage history provides a hint about the usefulness of the component. Another side of usage history is the maturity of the component. The subjects also have a consensus on the understandability attribute. It is also related to the maintainability of the component; a component that is easy to understand is easy to maintain. Understandability affects the reliability of a component. Variability is one of the factors; it decreases understandability. Variability is also seen as the configurability of a component, that it can be configured in multiple configurations. The details of the exploratory study will be found in future publications of the authors, it is work in progress (Table 2). **Sub-Attributes and metrics:** In this section a description of the attributes and metrics which are used to assess reusability is provided. The attributes, sub-attributes and their corresponding metrics are presented in Table 3. Table 3: Attribute, sub-attributes and metrics <table> <thead> <tr> <th>Attribute</th> <th>Sub-attribute</th> <th>Metrics</th> </tr> </thead> <tbody> <tr> <td>Flexibility</td> <td>Coupling, Cohesion</td> <td>CBO, LCOM</td> </tr> <tr> <td>Understandability</td> <td>Coupling, Cohesion, Size</td> <td>CBO, LCOM, %comments, LOC, NOM</td> </tr> <tr> <td>Portability</td> <td>Independence</td> <td>DIT</td> </tr> <tr> <td>Scope Coverage</td> <td></td> <td>NOM + Total number of methods</td> </tr> <tr> <td>Maintainability</td> <td>Complexity</td> <td>MCC, MI</td> </tr> <tr> <td>Variability</td> <td></td> <td>NOC + Total number of classes, NOM + Total number of methods</td> </tr> </tbody> </table> The factors and attributes are related to each other according to the following equations: \[ \text{Reusability of Class} = 0.16 \times \text{Flexibility} + 0.16 \times \text{Understandability} + 0.16 \times \text{Portability} + 0.16 \times \text{Scope coverage} + 0.16 \times \text{Maintainability} + 0.16 \times \text{Variability} \] \[ \text{Flexibility} = 1 - (0.5 \times \text{Coupling}) + (0.5 \times \text{Cohesion}) \] \[ \text{Coupling} = \text{adjusted CBO}, \text{Cohesion} = \text{adjusted LCOM} \] \[ \text{Understandability} = 1 - (0.25 \times \text{Coupling}) + (0.25 \times \text{Cohesion}) + (0.25 \times \text{Comments}) + (0.25 \times \text{Size}) \] \[ \text{Size} = (0.5 \times \text{adjusted LOC}) + (0.5 \times \text{adjusted NOM}) \] \[ \text{Portability} = \text{Independence} = 1 - \text{adjusted DIT} \] \[ \text{Scope coverage} = \text{NOM} + \text{Total number of methods in all classes} \] \[ \text{Maintainability} = (0.5 \times \text{adjusted MCC}) + (0.5 \times \text{adjusted MI}) \] \[ \text{Variability} = 0.5 \times (\text{NOC} + \text{Total number of classes}) + 0.5 \times (\text{NOM} + \text{Total number of methods in all classes}) \] As a starting point, equal weights/coefficients are assigned to each of the attributes and factors. Equal weights are used (Etzkorn et al., 2001) and it is stated that the linear combination of equal weights works well in most cases. Another example (Bansia and Devis, 2002) where equal weights are assigned to the attributes; this study was in the context of design quality. **Maintainability:** In (IEEE, 2010) maintainability is defined as “the ease with which a software system or component can be modified to change or add capabilities, correct faults or defects, improve performance or other attributes, or adapt to a changed environment”. Two metrics, MCC and MI, are used to measure maintainability. **Portability:** It is defined as “the ease with which a system or component can be transferred from one hardware or software environment to another”. The portability of a component depends on its independence, i.e., the ability of the component to perform its functionality without external support. In a scenario where an open source component is used in SPL development, the component should have the characteristic of portability. The component, being a core asset, may be used in the development of another product/family member within the product line/family. **Flexibility:** It is defined as “the ease with which a system or component can be modified for use in applications or environments other than those for which it was specifically designed” (IEEE, 2010). In (Sant’Anna et al., 2003; Pohl et al., 2005; Sharma et al., 2009) flexibility is considered as a factor affecting the reusability of a component. In the context of an SPL, the flexibility characteristic is necessary for a core asset as it is intended to be reused in the development of other products. **Understandability:** It is defined as “the ease with which a system can be comprehended at both the system-organizational and detailed statement levels” (IEEE, 2010). In (Sant’Anna et al., 2003; Washizaki et al., 2003) understandability is considered a factor of reusability. **Scope coverage:** It is the attribute that measures the number of features provided by the component against the total number of features in the SPL scope. **Independence:** The term ‘independence’ is introduced to reflect the property of the system concerning the ability of a class to perform its responsibilities on its own. Independence is measured by DIT. The classes lower in the hierarchy are inherited by other classes; these classes depend on their ancestors to perform their functionalities. **Size metrics:** In (Fenton and Pfleeger, 1997) the aspect of the software dealing with its physical size is named the ‘length’ of the software. The metric used for size is Lines Of Code (LOC). It counts the lines of source code. The second metric used to measure size is Number Of Methods (NOM). **Coupling and cohesion metrics:** Coupling and cohesion are two key concepts in object oriented software engineering. Both of these are related to interaction between the entities. The higher the level of interaction, the higher is the level of dependency. The lower the level of interaction, the higher is the level of cohesion. Cohesion refers to the extent to which an entity can perform its responsibilities on its own. The metric used for coupling is CBO and the one used for cohesion is LCOM. **Variability metrics:** The mechanisms to introduce variability in object oriented systems are presented in (Fazal-e-Amin et al., 2011b) and an analysis of these mechanisms is presented in (Fazal-e-Amin et al., 2011a). On the basis of the analysis the variability metrics are presented and validated in (Fazal-e-Amin et al., 2011c). These metrics are used in this paper. **RESULTS** This section includes the hypothesis, scatter plots and values of the correlation coefficient r. Table 4 contain the complete correlation statistics. **Statistical test:** The scatter diagram gives a notion about the association. However, the correlation coefficient or Pearson product-moment correlation coefficient is a mathematical measure. It helps to understand the strength of the relationship between the variables. The correlation coefficient r is a numerical measure that assesses the strength of the linear relationship between two variables. The following are assumptions of Pearson correlation coefficient r: Table 4: Correlation between reusability and factors <table> <thead> <tr> <th>Correlations</th> <th>Flexibility</th> <th>Understandability</th> <th>ScopeCov</th> <th>Variability</th> <th>Maintainability</th> <th>Portability</th> <th>Reusability</th> </tr> </thead> <tbody> <tr> <td><strong>Flexibility</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson Correlation</td> <td>1</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Sig. (2-tailed)</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>N</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>Understandability</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson correlation</td> <td>0.833**</td> <td>1</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Sig. (2-tailed)</td> <td>0.000</td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>N</td> <td>75</td> <td>75</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>ScopeCov</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson correlation</td> <td>-0.436**</td> <td>-0.559**</td> <td>1</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Sig. (2-tailed)</td> <td>0.000</td> <td>0.000</td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>N</td> <td>75</td> <td>75</td> <td>75</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>Variability</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson correlation</td> <td>-0.434**</td> <td>-0.552**</td> <td>0.983**</td> <td>1</td> <td></td> <td></td> <td></td> </tr> <tr> <td>Sig. (2-tailed)</td> <td>0.000</td> <td>0.000</td> <td>0.000</td> <td>0.011</td> <td></td> <td></td> <td></td> </tr> <tr> <td>N</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td></td> <td></td> <td></td> </tr> <tr> <td><strong>Maintainability</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson correlation</td> <td>0.494**</td> <td>0.558**</td> <td>-0.313**</td> <td>-0.203*</td> <td>1</td> <td></td> <td></td> </tr> <tr> <td>Sig. (2-tailed)</td> <td>0.000</td> <td>0.000</td> <td>0.000</td> <td>0.011</td> <td></td> <td></td> <td></td> </tr> <tr> <td>N</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td></td> <td></td> </tr> <tr> <td><strong>Portability</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson correlation</td> <td>0.213</td> <td>0.264*</td> <td>0.049</td> <td>0.072</td> <td>0.340**</td> <td>1</td> <td></td> </tr> <tr> <td>Sig. (2-tailed)</td> <td>0.066</td> <td>0.022</td> <td>0.716</td> <td>0.597</td> <td>0.003</td> <td></td> <td></td> </tr> <tr> <td>N</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td></td> </tr> <tr> <td><strong>Reusability</strong></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Pearson correlation</td> <td>0.744**</td> <td>0.711**</td> <td>0.018</td> <td>-0.005</td> <td>0.794**</td> <td>0.408**</td> <td>1</td> </tr> <tr> <td>Sig. (2-tailed)</td> <td>0.000</td> <td>0.000</td> <td>0.880</td> <td>0.966</td> <td>0.000</td> <td>0.000</td> <td></td> </tr> <tr> <td>N</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td>75</td> <td></td> </tr> </tbody> </table> **Correlation is significant at the 0.01 level (2-tailed). *Correlation is significant at the 0.05 level (2-tailed)** - $r$ ranges from +1 to -1 i.e., $-1 \leq r \leq 1$. The value 1 shows a perfect positive linear correlation, while the value -1 shows a perfect negative linear correlation. The value 0 represents an absence of any linear correlation. - A positive value of $r$ is an indication that $y$ will increase with the increase in $x$. On the other hand, a negative value of $r$ implies that the value of $y$ will decrease when the value of $x$ increases. - $r$ is not affected by the order of $x$ and $y$, i.e., $r$ is the same for the pairs $(x, y)$ and $(y, x)$. - $r$ is not affected by a change in the units of the variables. The correlation coefficient $r$ is measure the strength of the association between two variables. However, it does not implicate about the cause and effect. In other words the two variables $x$, $y$ having a strong correlation and increasing or decreasing together does not mean that $x$ is cause of increase/increase in $y$. **p-value:** The p-value (probability value) represents the statistical significance of the test. The smaller the value of $p$ the smaller is the likelihood that the null hypothesis holds. The p-value is Fig. 1: Scatter plot of flexibility/reusability compared against the alpha values. The commonly used alpha values are 0.05 and 0.01. A p-value less than 0.01 shows that the probability of the null hypothesis being true is 1 time in 100 samples. A p-value less than 0.05 implies that the probability of the null hypothesis being true is 5 times in 100 samples. These values of alpha (0.01, 0.05) are lower levels of the alpha value. The null hypothesis can be rejected when the p-value falls below the chosen level. The p-values are mentioned in Table 4 in the row with the title ‘sig’. Hypothesis tests: - **H0₁**: Flexibility of software has no effect on its reusability - **H₁₁**: Flexibility of software has an effect on its reusability The correlation between flexibility and reusability is \( r (75) = 0.744, p = 0 \). It shows a strong positive correlation between flexibility and reusability. So, the null hypothesis is rejected and it can be concluded that flexibility is positively correlated to reusability. An increase in the value of flexibility increases reusability (Fig. 1). - **H0₂**: Variability of software has no effect on its reusability - **H₁₂**: Variability of software has an effect on its reusability The correlation between variability and reusability is \( r (75) = -0.005, p = 0.966 \). There is a weak negative correlation between variability and reusability; further, \( p > 0.05 \) shows how insignificant the link is between variability and reusability. The correlation analysis leads to the rejection of the alternate hypothesis. It is concluded that variability is not related to reusability in this context. This conclusion demands further validation which may mean going back and rethinking about the variability metrics (Fig. 2): **H0**: Understandability of software has no effect on its reusability **H1**: Understandability of software has an effect on its reusability The correlation between understandability and reusability is $r (75) = 0.711$, $p = 0$. The value of $r$ shows a strong positive correlation between understandability and reusability. We reject the null hypothesis and it can be concluded that an increase in the value of understandability increases reusability (Fig. 3). Fig. 4: Scatter plot of maintainability/reusability - **H0₄**: Maintainability of software has no effect on its reusability - **H1₄**: Maintainability of software has an effect on its reusability The correlation between maintainability and reusability is $r \ (75) = 0.794$, $p = 0$. The $r$ value shows a strong positive correlation between maintainability and reusability. The null hypothesis is rejected and it can be concluded that an increase in maintainability increases reusability (Fig. 4). - **H0₅**: Portability of software has no effect on its reusability - **H1₅**: Portability of software has an effect on its reusability The correlation between portability and reusability is $r \ (75) = 0.408$, $p = 0$. The $r$ value shows a weak positive correlation between portability and reusability. The value of $p$ is 0, which leads to the rejection of null hypothesis. It can be concluded that there is a positive effect of portability on reusability. Increasing value of portability increases reusability (Fig. 5). - **H0₆**: Scope-coverage of software has no effect on its reusability - **H1₆**: Scope-coverage of software has an effect on its reusability The correlation between scope coverage and reusability is $r \ (75) = -0.018$, $p = 0.88$. The $r$ value shows a weak negative correlation between scope coverage and reusability. However, the inequality $p < 0.05$ shows how insignificant this relationship is. Therefore, the alternate hypothesis is rejected and it can be concluded that scope coverage is not related to reusability in this context. These results demand further investigation (Fig. 6). CONCLUSIONS The growing interest of research into open source components based SPLs and in reuse intense software development is reflected by the number or recent papers appearing in the literature. The emergence of open source as a contender for industrial software development attracts the SPL community. In this paper, the factors of reusability are measured using established object oriented metrics. A statistical analysis is performed to gain further insight. On the basis of the results, it is concluded that, in our context, flexibility, understand ability, maintainability and portability are positively correlated to reusability, while scope coverage and variability are not reusability. These initial results may provide a foundation for further exploration in this area. Future work will involve finding more metrics to measure variability and scope coverage and reassessing their relationships with reusability. REFERENCES
{"Source-Url": "http://docsdrive.com/pdfs/academicjournals/tasr/2012/118-131.pdf", "len_cl100k_base": 8314, "olmocr-version": "0.1.50", "pdf-total-pages": 15, "total-fallback-pages": 0, "total-input-tokens": 17074, "total-output-tokens": 10380, "length": "2e13", "weborganizer": {"__label__adult": 0.00032973289489746094, "__label__art_design": 0.0003180503845214844, "__label__crime_law": 0.00026607513427734375, "__label__education_jobs": 0.0010461807250976562, "__label__entertainment": 4.4405460357666016e-05, "__label__fashion_beauty": 0.0001308917999267578, "__label__finance_business": 0.00021946430206298828, "__label__food_dining": 0.00026154518127441406, "__label__games": 0.0004982948303222656, "__label__hardware": 0.000457763671875, "__label__health": 0.0003104209899902344, "__label__history": 0.00016105175018310547, "__label__home_hobbies": 5.668401718139648e-05, "__label__industrial": 0.0001888275146484375, "__label__literature": 0.00022482872009277344, "__label__politics": 0.00017011165618896484, "__label__religion": 0.00029087066650390625, "__label__science_tech": 0.0034122467041015625, "__label__social_life": 8.130073547363281e-05, "__label__software": 0.004917144775390625, "__label__software_dev": 0.98583984375, "__label__sports_fitness": 0.00021851062774658203, "__label__transportation": 0.0002739429473876953, "__label__travel": 0.00014400482177734375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 40296, 0.03016]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 40296, 0.50591]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 40296, 0.89985]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 3074, false], [3074, 7119, null], [7119, 10729, null], [10729, 13939, null], [13939, 17742, null], [17742, 20948, null], [20948, 24050, null], [24050, 29218, null], [29218, 30991, null], [30991, 31456, null], [31456, 33079, null], [33079, 33682, null], [33682, 37078, null], [37078, 40296, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 3074, true], [3074, 7119, null], [7119, 10729, null], [10729, 13939, null], [13939, 17742, null], [17742, 20948, null], [20948, 24050, null], [24050, 29218, null], [29218, 30991, null], [30991, 31456, null], [31456, 33079, null], [33079, 33682, null], [33682, 37078, null], [37078, 40296, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 40296, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 40296, null]], "pdf_page_numbers": [[0, 0, 1], [0, 3074, 2], [3074, 7119, 3], [7119, 10729, 4], [10729, 13939, 5], [13939, 17742, 6], [17742, 20948, 7], [20948, 24050, 8], [24050, 29218, 9], [29218, 30991, 10], [30991, 31456, 11], [31456, 33079, 12], [33079, 33682, 13], [33682, 37078, 14], [37078, 40296, 15]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 40296, 0.25822]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
a525c9f193e6d2ffa77060b42444d76e56374047
Package ‘gistr’ January 9, 2020 Title Work with 'GitHub' 'Gists' Description Work with 'GitHub' 'gists' from 'R' (e.g., <http://en.wikipedia.org/wiki/GitHub#Gist>, is simply one or more files with code/text/images/etc. This package allows the user to create new 'gists', update 'gists' with new files, rename files, delete files, get and delete 'gists', star and 'un-star' 'gists', fork 'gists', open a 'gist' in your default browser, get embed code for a 'gist', list 'gist' 'commits', and get rate limit information when 'authenticated'. Some requests require authentication and some do not. 'Gists' website: Version 0.5.0 License MIT + file LICENSE URL https://github.com/ropensci/gistr (devel), https://docs.ropensci.org/gistr (website) BugReports https://github.com/ropensci/gistr/issues VignetteBuilder knitr Encoding UTF-8 Language en-US Imports jsonlite (>= 1.4), httr (>= 1.2.0), magrittr, assertthat, knitr, rmarkdown, dplyr Suggests git2r, testthat RoxygenNote 7.0.2 X-schema.org-applicationCategory Web X-schema.org-keywords http, https, API, web-services, GitHub, GitHub API, gist, gists, code, script, snippet X-schema.org-isPartOf https://ropensci.org NeedsCompilation no Author Scott Chamberlain [aut, cre] (<https://orcid.org/0000-0003-1444-9135>), Ramnath Vaidyanathan [aut], Karthik Ram [aut] gistr-package Maintainer Scott Chamberlain <myrmecocystus@gmail.com> Repository CRAN Date/Publication 2020-01-09 22:50:06 UTC R topics documented: - gistr-package ........................................... 2 - add_files ............................................ 3 - browse ............................................. 4 - commits ............................................ 4 - create_gists ....................................... 5 - delete .............................................. 5 - embed .............................................. 6 - fork ................................................ 6 - forks ............................................... 7 - gist ............................................... 8 - gists ............................................ 9 - gist_auth ......................................... 10 - gist_create ....................................... 11 - gist_create_git .................................. 14 - gist_create_obj .................................. 17 - gist_map .......................................... 18 - gist_save ......................................... 19 - rate_limit ....................................... 20 - run ............................................... 20 - star .............................................. 21 -tabl .............................................. 22 - update ........................................... 24 Index 26 gistr-package R client for GitHub gists Description R client for GitHub gists. Details gistr allows you to perform actions on gists, including listing, forking, starring, creating, deleting, updating, etc. There are two ways to authorise gistr to work with your GitHub account: - Generate a personal access token (PAT) at https://help.github.com/articles/creating-an-access-token-for and record it in the GITHUB_PAT envr. Interactively login into your GitHub account and authorise with OAuth. Using the GITHUB_PAT is recommended. Author(s) Scott Chamberlain <myrmecocystus@gmail.com> Ramnath Vaidyanathan <ramnath.vaidya@gmail.com> Karthik Ram <karthik.ram@gmail.com> add_files Add files to a gist object Description Add files to a gist object Usage add_files(gist, ...) update_files(gist, ...) delete_files(gist, ...) rename_files(gist, ...) Arguments gist A gist object or something coerceable to a gist ... Curl options passed on to GET Examples ## Not run: add_files("~/stuff.Rmd") # update_files() # delete_files() # rename_files() ## End(Not run) ### browse **Open a gist on GitHub** **Description** Open a gist on GitHub **Usage** browse(gist, what = "html") **Arguments** - **gist**: A gist object or something that can be coerced to a gist object. - **what**: One of html (default), json, forks, commits, or comments. ### commits **List gist commits** **Description** List gist commits **Usage** commits(gist, page = NULL, per_page = 30, ...) **Arguments** - **gist**: A gist object or something coerceable to a gist - **page**: (integer) Page number to return. - **per_page**: (integer) Number of items to return per page. Default 30. Max 100. - **...**: Further named args to httr::GET() **Examples** ```r ## Not run: gists()[[1]] %>% commits() gist(id = '1f399774e9eccc9153a6f') %>% commits(per_page = 5) # pass in a url gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>% commits ## End(Not run) ``` create_gists Create gists Description Creating gists in gistr can be done with any of three functions: - **gist_create()** - Create gists from files or code blocks, using the GitHub HTTP API. Because this function uses the GitHub HTTP API, it does not work for binary files. However, you can get around this for images by using knit’s hook to upload images to e.g., imgur. In addition, it’s difficult to include artifacts from the knit-ing process. - **gist_create_git()** - Create gists from files or code blocks, using git. Because this function uses git, you have more flexibility than with the above function: you can include any binary files, and can easily upload all artifacts. - **gist_create_obj()** - Create gists from R objects: data.frame, list, character string, matrix, or numeric. Uses the GitHub HTTP API. It may seem a bit odd to have three separate functions for creating gists. _gist_create()_ was created first, and was out for a bit, so when we had the idea to create gists via git (_gist_create_git()_ and from R objects (_gist_create_obj())), it made sense to have a different API for creating gists via the HTTP API, git, and from R objects. We could have thrown everything into _gist_create(),_ but it would have been a massive function, with far too many parameters. delete Delete a gist Description Delete a gist Usage delete(gist, ...) Arguments gist A gist object or something coerceable to a gist ... Curl options passed on to GET Examples ```r ## Not run: gists("minepublic")[[29]] %>% delete() ## End(Not run) ``` embed Get embed script for a gist Description Get embed script for a gist Usage embed(gist) Arguments gist A gist object or something that can be coerced to a gist object. Examples ## Not run: gists()[[1]] %>% embed() # pass in a url gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>% embed ## End(Not run) fork Fork a gist Description Fork a gist Usage fork(gist, ...) Arguments gist A gist object or something coerceable to a gist ... Further named args to GET Value A gist class object ## forks ### Examples ```r ## Not run: # fork a gist gists()[[1]] %>% fork() # browse to newly forked gist gist(id='0831f3fbd83ac4d46451') %>% fork() %>% browse() # extract the last one gist(id='1642874') %>% forks() %>% .[length(.)] ## End(Not run) ``` --- tables ### forks **List forks on a gist** #### Description List forks on a gist. #### Usage ``` forks(gist, page = NULL, per_page = 30, ...) ``` #### Arguments - **gist** - A gist object or something coerceable to a gist. - **page** - (integer) Page number to return. - **per_page** - (integer) Number of items to return per page. Default 30. Max 100. - **...** - Further named args to `httr::GET()` #### Value A list of gist class objects. #### Examples ```r ## Not run: gist(id='1642874') %>% forks(per_page=2) gist(id = "8172796") %>% forks() # pass in a url gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>% forks ## End(Not run) ``` gist Get a gist Description Get a gist Usage gist(id, revision = NULL, ...) as.gist(x) Arguments id (character) A gist id, or a gist URL revision (character) A sha. optional ... Curl options passed on to GET x Object to coerce. Can be an integer (gist id), string (gist id), a gist, or an list that can be coerced to a gist. Details If a file is larger than ~1 MB, the content of the file given back is truncated, so you won’t get the entire contents. In the return S3 object that’s printed, we tell you at the bottom whether each file is truncated or not. If a file is, simply get the raw_url URL for the file (see example below), then retrieve from that. If the file is very big, you may need to clone the file using git, etc. Examples ## Not run: gist('f1403260eb92f5dfa7e1') as.gist('f1403260eb92f5dfa7e1') as.gist(10) as.gist(gist('f1403260eb92f5dfa7e1')) # get a specific revision of a gist id <- 'c1e2cb547d9f22bd314da50fe9c7b503' gist(id, 'a5bc5c143beb697f23b2c320ff5a8dacf960b0f3') gist(id, 'b70d94a8222a4326ff46fc85bc69d0179bd1da2') gist(id, '648bb44ab9ae59d67b4ea5de7d85e24103717e8b') gist(id, '0259b137653dc95e20193133b7181188cbe6') # from a url, or partial url x <- "https://gist.github.com/expersso/4ac33b9c00751fddc7f8" x <- "gist.github.com/expersso/4ac33b9c00751fddc7f8" x <- "gist.github.com/4ac33b9c00751fddc7f8" x <- "expersso/4ac33b9c00751fddc7f8" as.gist(x) ids <- sapply(gists(), "[", "id") gist(ids[1]) gist(ids[2]) gist(ids[3]) gist(ids[4]) gist(ids[1]) %>% browse() ## If a gist file is > a certain size it is truncated ## in this case, we let you know in the return object that it is truncated ## e.g. (bigfile <- gist(id = "b74b878fd7d9176a4c52")) ## then get the raw_url, and retrieve the file url <- bigfile$files$`plossmall.json`$raw_url # httr::GET(url) ## End(Not run) --- **gists** *List gists* **Description** List public gists, your own public gists, all your gists, by gist id, or query by date. **Usage** ```r gists(what = "public", since = NULL, page = NULL, per_page = 30, ...) ``` **Arguments** - **what** *(character)* What gists to return. One of public, minepublic, mineall, or starred. If an id is given for a gist, this parameter is ignored. - **since** *(character)* A timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Only gists updated at or after this time are returned. - **page** *(integer)* Page number to return. - **per_page** *(integer)* Number of items to return per page. Default 30. Max 100. - **...** Curl options passed on to `GET` **Details** When `what = "mineall"`, we use `getOption("github.username")` internally to get your GitHub username. Make sure to set your GitHub username as an R option like `options(github.username = "foobar")` in your `.Rprofile` file. If we can’t find you’re user name, we’ll stop with an error. Examples ```r ## Not run: # Public gists gists() gists(per_page=2) gists(page=3) # Public gists created since X time gists(since='2014-05-26T00:00:00Z') # Your public gists gists('minepublic') gists('minepublic', per_page=2) # Your private and public gists gists('mineall') # Your starred gists gists('starred') # pass in curl options gists(per_page=1, config=verbose()) gists(per_page=1, config=timeout(seconds = 0.5)) ## End(Not run) ``` --- **gist_auth** *Authorize with GitHub.* Description This function is run automatically to allow gistr to access your GitHub account. Usage ```r gist_auth(app = gistr_app, reauth = FALSE) ``` Arguments - **app**: An `httr::oauth_app()` for GitHub. The default uses an application `gistr_oauth` created by Scott Chamberlain. - **reauth**: (logical) Force re-authorization? Details There are two ways to authorise gistr to work with your GitHub account: - Generate a personal access token with the gist scope selected, and set it as the `GITHUB_PAT` environment variable per session using `Sys.setenv` or across sessions by adding it to your `.Renviron` file or similar. See https://help.github.com/articles/creating-an-access-token-for-command-line-use for help - Interactively login into your GitHub account and authorise with OAuth. Using `GITHUB_PAT` is recommended. **Examples** ```r ## Not run: gist_auth() ## End(Not run) ``` **gist_create** Create a gist **Description** Create a gist **Usage** ```r gist_create( files = NULL, description = "", public = TRUE, browse = TRUE, code = NULL, filename = "code.R", knit = FALSE, knitopts = list(), renderopts = list(), include_source = FALSE, imgur_inject = FALSE, rmarkdown = FALSE, ... ) ``` **Arguments** - **files**: Files to upload. this or code param must be passed - **description**: (character) Brief description of gist (optional) - **public**: (logical) Whether gist is public (default: TRUE) - **browse**: (logical) To open newly create gist in default browser (default: TRUE) - **code**: Pass in any set of code. This can be a single R object, or many lines of code wrapped in quotes, then curly brackets (see examples below). this or files param must be passed - **filename**: Name of the file to create, only used if code parameter is used. Default to code.R - **knit**: (logical) Knit code before posting as a gist? If the file has a .Rmd or .Rnw extension, we run the file with link[knitr]{knit}, and if it has a .R extension, then we use render gist_create knitopts, renderopts (list) List of variables passed on to link[knitr]{knit}, or render include_source (logical) Only applies if knit=TRUE. Include source file in the gist in addition to the knitted output. imgur_inject (logical) Inject imgur_upload into your .Rmd file to upload files to http://imgur.com/. This will be ignored if the file is a sweave/latex file because the rendered pdf can’t be uploaded anyway. Default: FALSE rmarkdown (logical) If TRUE, use rmarkdown::render() instead of knitr::knit() to render the document. Further args passed on to link[httr]{POST} See Also gist_create_obj(), gist_create_git() Examples ```r ## Not run: file <- tempfile() cat("hello world", file = file) gist_create(files=file, description='a new cool gist') file1 <- tempfile() file2 <- tempfile() cat("foo bar", file = file1) cat("foo bar", file = file2) gist_create(files=c(file1, file2), description='spocc demo files') # include any code by passing to the code parameter gist_create(code='' x <- letters numbers <- runif(10) numbers ') # Knit an .Rmd file before posting as a gist file <- system.file("examples", "stuff.Rmd", package = "gistr") gist_create(file, description='a new cool gist', knit=TRUE) file <- system.file("examples", "plots.Rmd", package = "gistr") gist_create(file, description='some plots', knit=TRUE) # an .Rnw file file <- system.file("examples", "rnw_example.Rnw", package = "gistr") gist_create(file) gist_create(file, knit=TRUE) # Knit code input before posting as a gist gist_create(code='' `\` `\` `\` r `\` x <- letters ``` library(httr) url <- "https://github.com/ropensci/geojsonio/blob/master/inst/examples/zillow_or.geojson" res <- httr::GET(url) json <- httr::content(res, as = "text") gist_create(code = json, filename = "zillow_or.geojson") # Knit and include source file, so both files are in the gist gist_create(file, knit=TRUE, include_source=TRUE) gist_create(code={ x <- letters (numbers <- runif(8)) }, filename="code.Rmd", knit=TRUE, include_source=TRUE) # Uploading images created during knit process ## using imgur - if you're file uses imgur or similar, you're good file <- system.file("examples", "plots_imgur.Rmd", package = "gistr") cat(readLines(file), sep = "\n") # peek at file gist_create(file, knit=TRUE) # if not, GitHub doesn't allow upload of binary files via the HTTP API ## (which gistr uses) - so see gist_create_git(), which uses git file <- system.file("examples", "plots.Rmd", package = "gistr") gist_create(file, knit=TRUE, imgur_inject = TRUE) ## works with ggplot2 as well file <- system.file("examples", "ggplot_imgur.Rmd", package = "gistr") gist_create(file, knit=TRUE) # Render `.R` files file <- system.file("examples", "example1.R", package = "gistr") cat(readLines(file), sep = "\n") # peek at file gist_create(file, knit = TRUE) gist_create(file, knit = TRUE, include_source = TRUE) ## many files (file1 <- system.file("examples", "example1.R", package = "gistr")) (file2 <- system.file("examples", "example2.R", package = "gistr")) cat(readLines(file1), sep = "\n") # peek at file cat(readLines(file2), sep = "\n") # peek at file gist_create(files=list(file1, file2), knit = TRUE) ## three at once, some .R and some .Rmd file3 <- system.file("examples", "plots_imgur.Rmd", package = "gistr") gist_create(files=list(file1, file2, file3), knit = TRUE) gist_create(files=list(file1, file2, file3), knit = TRUE, include_source = TRUE) # Use rmarkdown::render instead of knitr::knit file <- system.file("examples", "rmarkdown_eg.Rmd", package = "gistr") gist_create_git Create a gist via git instead of the GitHub Gists HTTP API Description Create a gist via git instead of the GitHub Gists HTTP API Usage ``` gist_create_git( files = NULL, description = "", public = TRUE, browse = TRUE, knit = FALSE, code = NULL, filename = "code.R", knitopts = list(), renderopts = list(), include_source = FALSE, artifacts = FALSE, imgur_inject = FALSE, git_method = "ssh", sleep = 1, ... ) ``` Arguments - **files**: Files to upload. this or code param must be passed - **description**: (character) Brief description of gist (optional) - **public**: (logical) Whether gist is public (default: TRUE) - **browse**: (logical) To open newly create gist in default browser (default: TRUE) - **knit**: (logical) Knit code before posting as a gist? If the file has a .Rmd or .Rnw extension, we run the file with link[knitr]{knit}, and if it has a .R extension, then we use render - **code**: Pass in any set of code. This can be a single R object, or many lines of code wrapped in quotes, then curly brackets (see examples below). this or files param must be passed - **filename**: Name of the file to create, only used if code parameter is used. Default to code.R gist_create_git knitopts, renderopts (list) List of variables passed on to link[knitr]{knitr}, or render include_source (logical) Only applies if knit=TRUE. Include source file in the gist in addition to the knitted output. artifacts (logical/character) Include artifacts or not. If TRUE, includes all artifacts. Or you can pass in a file extension to only upload artifacts of certain file extensions. Default: FALSE imgur_inject (logical) Inject imgur_upload into your .Rmd file to upload files to http://imgur.com/. This will be ignored if the file is a sweave/latex file because the rendered pdf can’t be uploaded anyway. Default: FALSE git_method (character) One of ssh (default) or https. If a remote already exists, we use that remote, and this parameter is ignored. sleep (integer) Seconds to sleep after creating gist, but before collecting metadata on the gist. If uploading a lot of stuff, you may want to set this to a higher value, otherwise, you may not get accurate metadata for your gist. You can of course always refresh afterwards by calling gist with your gist id. ... Further args passed on to link[httr]{POST} Details Note that when browse=TRUE there is a slight delay in when we open up the gist in your default browser and when the data will display in the gist. We could have this function sleep a while and guess when it will be ready, but instead we open your gist right after we’re done sending the data to GitHub. Make sure to refresh the page if you don’t see your content right away. Likewise, the object that is returned from this function call may not have the updated and correct file information. You can retrieve that easily by calling gist() with the gist id. This function uses git instead of the HTTP API, and thus requires the R package git2r. If you don’t have git2r installed, and try to use this function, it will stop and tell you to install git2r. This function using git is better suited than gist_create() for use cases involving: - Big files - The GitHub API allows only files of up to 1 MB in size. Using git we can get around that limit. - Binary files - Often artifacts created are binary files like .png. The GitHub API doesn’t allow transport of binary files, but we can do that with git. Another difference between this function and gist_create() is that this function can collect all artifacts coming out of a knit process. If a gist is somehow deleted, or the remote changes, when you try to push to the same gist again, everything should be fine. We now use tryCatch on the push attempt, and if it fails, we’ll add a new remote (which means a new gist), and push again. See Also gist_create(), gist_create_obj() ## Examples ```r ## Not run: # prepare a directory and a file unlink("~/gitgist", recursive = TRUE) dir.create("~/gitgist") file <- system.file("examples", "stuff.md", package = "gistr") writeLines(readLines(file), con = "~/gitgist/stuff.md") # create a gist gist_create_git(files = "~/gitgist/stuff.md") ## more than one file can be passed in unlink("~/gitgist2", recursive = TRUE) dir.create("~/gitgist2") file.copy(file, "~/gitgist2/") cat("hello world", file = "~/gitgist2/hello_world.md") list.files("~/gitgist2") gist_create_git(c("~/gitgist2/stuff.md", "~/gitgist2/hello_world.md")) # Include all files in a directory unlink("~/gitgist3", recursive = TRUE) dir.create("~/gitgist3") cat("foo bar", file="~/gitgist3/foobar.txt") cat("hello", file="~/gitgist3/hello.txt") list.files("~/gitgist3") gist_create_git("~/gitgist3") # binary files png <- system.file("examples", "file.png", package = "gistr") unlink("~/gitgist4", recursive = TRUE) dir.create("~/gitgist4") file.copy(png, "~/gitgist4/") list.files("~/gitgist4") gist_create_git(files = "~/gitgist4/file.png") # knit files first, then push up # note: by default we don't upload images, but you can do that, # see next example rmd <- system.file("examples", "plots.Rmd", package = "gistr") unlink("~/gitgist5", recursive = TRUE) dir.create("~/gitgist5") file.copy(rmd, "~/gitgist5/") list.files("~/gitgist5") gist_create_git("~/gitgist5/plots.Rmd", knit = TRUE) # collect all/any artifacts from knitting process arts <- system.file("examples", "artifacts_eg1.Rmd", package = "gistr") unlink("~/gitgist6", recursive = TRUE) dir.create("~/gitgist6") file.copy(arts, "~/gitgist6/") list.files("~/gitgist6") gist_create_git("~/gitgist6/artifacts_eg1.Rmd", knit = TRUE, ``` artifacts = TRUE) # from a code block gist_create_git(code=' x <- letters numbers <- runif(8) numbers [1] 0.3229318 0.5933054 0.7778408 0.3898947 0.1309717 0.7501378 0.3206379 0.3379005 '), filename="my_cool_code.R") # Use https instead of ssh png <- system.file("examples", "file.png", package = "gistr") unlink("~/gitgist7", recursive = TRUE) dir.create("~/gitgist7") file.copy(png, "~/gitgist7/") list.files("~/gitgist7") gist_create_git(files = "~/gitgist7/file.png", git_method = "https") ## End(Not run) --- **gist_create_obj** Create a gist from an R object **Description** Create a gist from an R object **Usage** gist_create_obj( x = NULL, description = "", public = TRUE, browse = TRUE, pretty = TRUE, filename = "file.txt", ... ) **Arguments** - **x** - An R object, any of data.frame, matrix, list, character, numeric - **description** - (character) Brief description of gist (optional) - **public** - (logical) Whether gist is public (default: TRUE) - **browse** - (logical) To open newly create gist in default browser (default: TRUE) - **pretty** - (logical) For data.frame and matrix objects, create a markdown table. If FALSE, pushes up json. (default: TRUE) filename Name of the file to create. Default: file.txt Further args passed on to `httr::POST()` Details This function is specifically for going from R objects to a gist, whereas `gist_create()` is for going from files or executing code. See Also `gist_create()`, `gist_create_git()` Examples ```r ## Not run: ## data.frame ### by default makes pretty table in markdown format row.names(mtcars) <- NULL gist_create_obj(mtcars) gist_create_obj(iris) ### or just push up json gist_create_obj(mtcars, pretty = FALSE) ## matrix gist_create_obj(as.matrix(mtcars)) ## list gist_create_obj(apply(mtcars, 1, as.list)) ## character gist_create_obj("hello, world") ## numeric gist_create_obj(runif(10)) ## Assign a specific file name gist_create_obj("hey there!", filename = "my_markdown.md") ## End(Not run) ``` --- `gist_map` Opens a full screen map after uploading a geojson file Description Takes a gist object and a input geojson file name and renders fullscreen map Usage `gist_map(x, browse = TRUE)` gist_save Arguments x An object of class gist generated by `gist_create()` or `gist_create_obj()` browse Default: TRUE. Set to FALSE if you don’t want to automatically browse to the URL. Examples ```r ## Not run: file <- system.file("examples", "ecoengine_eg.geojson", package = "gistr") gist_id <- gist_create(file, browse = FALSE) gist_map(gist_id) ## End(Not run) ``` gist_save Save gist files to disk Description Save gist files to disk Usage gist_save(gist, path = ".") gist_open(x) Arguments gist A gist object or something coercable to a gist path Root path to write to, a directory, not a file b/c a gist can contain many files. A folder is created with name of the gist id within this root directory. File names will be the same as given in the gist. x An object of class gist_files (the output from `gist_save()` Details gist_save: files are written into a new folder, named by the gist id, e.g., a65ac7e56b7b3f746913 gist_open: opens files in your editor/R GUI. Internally, uses `file.edit()` to open files, using `getOption("editor")` to open the files. If you're in R.app or RStudio, or other IDE’s, files will open in the IDE (I think). Value An object of class gist_files, S3 object containing file paths Examples ```r ## Not run: gist("a65ac7e56b7b3f746913") %>% gist_save() gist("a65ac7e56b7b3f746913") %>% gist_save() %>% gist_open() gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>% gist_save() ## End(Not run) ``` rate_limit *Get rate limit information* Description Get rate limit information Usage ```r rate_limit(...) ``` Arguments ```r ... ``` Named args to `httr::GET()` Examples ```r ## Not run: ratio_limit() ## End(Not run) ``` run *Run a .Rmd file* Description Run a .Rmd file Usage ```r run(x, filename = "code.R", knitopts = list()) ``` Arguments x Input, one of: code wrapped in curly brackets and quotes, a file path to an .Rmd file, or a gist. filename Name of the file to create, only used if code parameter is used. Default to code.R knitopts (list) List of variables passed on to knitr::knit() Value A path, unless a gist object is passed in, in which case a gist object is returned. Examples ```r ## Not run: # run a local file file <- system.file("examples", "stuff.Rmd", package = "gistr") run(file) %>% gist_create # run code run({ x <- letters (numbers <- runif(8)) }) %>% gist_create # run a file from a gist, has to get file first gists('minepublic')[[2]] %>% run() %>% update() ## End(Not run) ``` star Star a gist Description Star a gist Usage star(gist, ...) unstar(gist, ...) star_check(gist, ...) Arguments ```r gist A gist object or something that can be coerced to a gist object. ... Curl options passed on to GET ``` Value A message, and a gist object, the same one input to the function. Examples ```r ## Not run: id <- '4ac33b9c00751fddc7f8' gist(id) %>% star() gist(id) %>% star_check() gist(id) %>% unstar() gist(id) %>% unstar() %>% star() gist(id) %>% star_check() gist(id) %>% star() %>% star_check() # pass in a url x <- "https://gist.github.com/expersso/4ac33b9c00751fddc7f8" gist(x) %>% star gist(x) %>% unstar ## End(Not run) ``` --- **tabl** Make a table from gist or commit class or a list of either Description Make a table from gist or commit class or a list of either Usage ```r tabl(x, ...) ``` ```r tabl_data(x) ``` Arguments ```r x Either a gist or commit class object or a list of either ... Ignored ``` Details For commits we return a single data.frame. For gists, we always return a list so that we are returning data consistently, regardless of variable return data. So you can always index to the main data.frame with gist metadata and file info by doing `result$data`, and likewise for forks `result$forks` and history `result$history`. Value A data.frame or list of data.frame’s Examples ```r ## Not run: # from a gist object x <- as.gist("f1403260eb92f5dfa7e1") res <- tabl(x) res$data res$forks res$history # from a list ss <- gists("minepublic") llapply(tabl(ss[1:3]), "[[", "data") # index to data slots, but also make single data.frame tabl_data(tabl(ss[1:3])) ## manipulate with dplyr library("dplyr") tabl_data(tabl(ss[1:3])) %>% select(id, description, owner_login) %>% filter(grepl("gist gist gist", description)) # commits x <- gists()[[2]] %>% commits() tabl(x[[1]]) ## many x <- sapply(gists(per_page = 100), commits) tabl(x) %>% select(id, login, change_status.total, url) %>% filter(change_status.total > 50) # pass in a url gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>% tabl ## many gg <- gists() (urls <- vapply(gg, "[[", "html_url")) llapply(urls[1:5], as.gist) %>% tabl() # gist with forks and history gist("1642874") %>% tabl ``` # gist with history, no forks gist('c96d2e453c95d0166408') %>% tabl ## End(Not run) desc update update Update/modify a gist Description Update/modify a gist Usage update(gist, description = gist$description, ...) Arguments <table> <thead> <tr> <th>Argument</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>gist</td> <td>A gist object or something coercable to a gist</td> </tr> <tr> <td>description</td> <td>(character) Brief description of gist (optional)</td> </tr> <tr> <td>...</td> <td>Curl options passed on to GET</td> </tr> </tbody> </table> Value an object of class gist Examples ```r ## Not run: file1 <- system.file("examples", "alm.md", package = "gistr") file2 <- system.file("examples", "zoo.json", package = "gistr") # add new files gists(what = "minepublic") add_files(file1, file2) %>% update() # update existing files ### file name has to match to current name update_files(file1) %>% update() # delete existing files ### again, file name has to match to current name delete_files(file1, file2) %>% update() ``` # rename existing files # For some reason, this operation has to upload the content too ### first name is old file name with path (must match), and second is ### new file name (w/o path) ## add first ```r gists(what = "minepublic")[[3]] %>% add_files(file1, file2) %>% update() ``` ## then rename ```r gists(what = "minepublic")[[3]] %>% rename_files(list(file1, "newfile.md")) %>% update() ``` ### you can pass in many renames ```r gists(what = "minepublic")[[3]] %>% rename_files(list(file1, "what.md"), list(file2, "new.json")) %>% update() ``` ## End(Not run) Index *Topic **package** gistr-package, 2 add_files, 3 as.gist (gist), 8 browse, 4 commits, 4 create_gists, 5 delete, 5 delete_files (add_files), 3 embed, 6 file.edit(), 19 fork, 6 forks, 7 GET, 3, 5, 6, 8, 9, 22, 24 gist, 8 gist(), 15 gist_auth, 10 gist_create, 11 gist_create(), 5, 15, 18, 19 gist_create_git, 14 gist_create_git(), 5, 12, 18 gist_create_obj, 17 gist_create_obj(), 5, 12, 15, 19 gist_map, 18 gist_open (gist_save), 19 gist_save, 19 gist_save(), 19 gistr (gistr-package), 2 gistr-package, 2 gists, 9 httr::GET(), 4, 7, 20 httr::oauth_app(), 10 httr::POST(), 18 imgur_upload, 12, 15 knitr::knit(), 12, 21 rate_limit, 20 rename_files (add_files), 3 render, 11, 12, 14, 15 rmarkdown::render(), 12 run, 20 star, 21 star_check (star), 21 tabl, 22 tabl_data (tabl), 22 unstar (star), 21 update, 24 update_files (add_files), 3
{"Source-Url": "https://cran.r-project.org/web/packages/gistr/gistr.pdf", "len_cl100k_base": 9004, "olmocr-version": "0.1.50", "pdf-total-pages": 26, "total-fallback-pages": 0, "total-input-tokens": 52969, "total-output-tokens": 11091, "length": "2e13", "weborganizer": {"__label__adult": 0.0002727508544921875, "__label__art_design": 0.0007562637329101562, "__label__crime_law": 0.0001806020736694336, "__label__education_jobs": 0.00032520294189453125, "__label__entertainment": 0.00012576580047607422, "__label__fashion_beauty": 9.930133819580078e-05, "__label__finance_business": 0.00012093782424926758, "__label__food_dining": 0.000232696533203125, "__label__games": 0.0005774497985839844, "__label__hardware": 0.000385284423828125, "__label__health": 0.00011229515075683594, "__label__history": 0.0001423358917236328, "__label__home_hobbies": 9.27448272705078e-05, "__label__industrial": 0.00016415119171142578, "__label__literature": 0.00020742416381835935, "__label__politics": 0.0001016855239868164, "__label__religion": 0.00028514862060546875, "__label__science_tech": 0.00255584716796875, "__label__social_life": 0.0001245737075805664, "__label__software": 0.050140380859375, "__label__software_dev": 0.9423828125, "__label__sports_fitness": 0.00014507770538330078, "__label__transportation": 0.00011992454528808594, "__label__travel": 0.00014030933380126953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 31831, 0.026]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 31831, 0.57503]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 31831, 0.64681]], "google_gemma-3-12b-it_contains_pii": [[0, 1417, false], [1417, 3263, null], [3263, 3901, null], [3901, 4794, null], [4794, 6358, null], [6358, 6884, null], [6884, 7825, null], [7825, 9165, null], [9165, 10641, null], [10641, 11968, null], [11968, 13150, null], [13150, 14734, null], [14734, 16716, null], [16716, 17946, null], [17946, 20630, null], [20630, 22369, null], [22369, 23582, null], [23582, 24588, null], [24588, 25825, null], [25825, 26416, null], [26416, 27216, null], [27216, 28071, null], [28071, 29360, null], [29360, 30408, null], [30408, 30988, null], [30988, 31831, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1417, true], [1417, 3263, null], [3263, 3901, null], [3901, 4794, null], [4794, 6358, null], [6358, 6884, null], [6884, 7825, null], [7825, 9165, null], [9165, 10641, null], [10641, 11968, null], [11968, 13150, null], [13150, 14734, null], [14734, 16716, null], [16716, 17946, null], [17946, 20630, null], [20630, 22369, null], [22369, 23582, null], [23582, 24588, null], [24588, 25825, null], [25825, 26416, null], [26416, 27216, null], [27216, 28071, null], [28071, 29360, null], [29360, 30408, null], [30408, 30988, null], [30988, 31831, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 31831, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 31831, null]], "pdf_page_numbers": [[0, 1417, 1], [1417, 3263, 2], [3263, 3901, 3], [3901, 4794, 4], [4794, 6358, 5], [6358, 6884, 6], [6884, 7825, 7], [7825, 9165, 8], [9165, 10641, 9], [10641, 11968, 10], [11968, 13150, 11], [13150, 14734, 12], [14734, 16716, 13], [16716, 17946, 14], [17946, 20630, 15], [20630, 22369, 16], [22369, 23582, 17], [23582, 24588, 18], [24588, 25825, 19], [25825, 26416, 20], [26416, 27216, 21], [27216, 28071, 22], [28071, 29360, 23], [29360, 30408, 24], [30408, 30988, 25], [30988, 31831, 26]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 31831, 0.00561]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
e3b83f4e778ee6d65a156a9cd2c9c023347f8002
This project is funded under the eContentplus programme, a multiannual Community programme to make digital content in Europe more accessible, usable and exploitable. EuropeanaConnect is coordinated by the Austrian National Library. D3.4.1 Catalogue of User Requirements This deliverable summarizes the requirements for the implementation of mobile access to Europeana as part of work package 3.4. co-funded by the European Union The project is co-funded by the European Union, through the eContentplus programme http://ec.europa.eu/econtentplus EuropeanaConnect is coordinated by the Austrian National Library Summary This deliverable summarizes the requirements for the implementation of mobile access to Europeana as part of work package 3.4. We start with the presentation of the approach used to derive the user requirements of this deliverable. We then describe the human-centred design process, which will be used for the development of the Europeana mobile client, and identify the sources of information used to derive the actual user requirements: User profiles identified in previous user surveys, personas identified in a personas workshop of EuropeanaConnect work package 3.3, a user survey we conducted with representatives of staff members from our project partners, and discussion sessions with mobile interaction and usability experts at our institute. To better understand the context of mobile access to Europeana, we will continue with the identification of the stakeholders for mobile access to Europeana. After that, we will present the current technical state-of-the-art in mobile computing and the mobile web, laying the technical base for the developments of the Europeana mobile client. This includes the comparison of the technical capabilities of today’s mobile devices, including screen resolution, operating systems and mobile browsers used. We also give a technological outlook for the future to ensure the developments of task 3.4 can keep up with the technological developments in the next years. What follows is the actual requirements analysis. We will start with the presentation of results from the conducted user survey. Based on that, we will derive functional requirements, describing the behaviour of the mobile client to be produced. Qualitative aspects will be covered by describing non-functional requirements. Aspects like scalability and platform compatibility play a key role in this context. Constraint requirements from external stakeholders complete the requirements definition. Table of Contents 1. Introduction ......................................................................................................................6 2. Approach .......................................................................................................................8 2.1. Process Model .......................................................................................................8 2.2. Sources of information ..........................................................................................9 3. Context of Use ...............................................................................................................10 3.1 Stakeholders ...........................................................................................................10 3.2 User profiles ..........................................................................................................10 3.3 Personas ..................................................................................................................11 3.4 State of the art: The mobile web ..........................................................................12 4. Requirements Analysis ..................................................................................................17 4.1 User Survey ..........................................................................................................17 4.2 Overview ...............................................................................................................19 4.3 Functional Requirements ......................................................................................20 4.4 Non-functional Requirements ..............................................................................22 4.5 Constraint Requirements .....................................................................................24 5. Conclusion .....................................................................................................................26 5.1 Outlook ...............................................................................................................26 6. References .....................................................................................................................27 7. Appendix A – User Requirements Questionnaire (Template) .......................................28 1. Introduction The popularity of the mobile web is ever increasing. People use many sorts of mobile devices, in particular mobile phones, to connect to the internet and gather information. In our mobile world, they can access information on the go, without needing to use fixed internet terminals or landline connections. The importance of mobile access to services on the internet is supported by several recent surveys. In late 2007, the mobile phone penetration rate in Europe reached more than 100% (see Fig. 1): Virtually every European possessed a mobile phone, some even more than one. Also, demands on mobile internet usage continue to grow. A recent study by (Nielsen Company, Q1, 2008) shows that approx. 10% of the inhabitants of the most populated European countries use their mobile device for connecting to the internet, even without counting web based email services or instant messaging traffic (see Table 1). In 2008, the number of world-wide mobile web users even grew past the number of PC based internet users (Tomi Ahonen Consulting, 2009). It is therefore essential that any online service considers the recent growth in mobile computing to react to the demands of its users. Unfortunately, ordinary web sites are generally not optimized for the use by mobile devices. However, these devices suffer from many limitations. The available screen resolution and colour depth is often limited, as is the support of many modern features of the ordinary web, like AJAX, CSS 2 or JavaScript. Mobile devices usually also do not offer full-size keyboards and mice, making the interaction with the various contents of websites awkward in many cases. This is why major web sites like Google, eBay or Wikipedia are already offering specialized mobile web sites that are optimized for the use by the heterogeneous mobile devices on the market. It is therefore only natural for Europeana to take the next step and react to the demands of the European users when it comes to the mobile use of its services. With the increasing popularity of smartphones, netbooks and other mobile devices, mobile access to Europeana is likely to become a true alternative to the access from fixed internet terminals in the future. Thus, the overall goal of EuropeanaConnect Task 3.4 is to make the rich cultural content of Europeana available to a broad spectrum of users in mobile scenarios. With the development of mobile access channels for Europeana, we will enable users to access the material inside the Europeana database and benefit from the cultural content inside Europeana using their mobile clients, when the use of stationary PCs is either impossible or unwanted. We will also turn the alleged drawbacks of mobile phones into an advantage by implementing services into Europeana that enable users to access information inside the database based on their current location. For reading convenience, we will refer to the Europeana mobile client application as eMobile in the following. The remainder of this document is structured as follows: In chapter 2, we will briefly describe our approach for the developments of Task 3.4, including the used process model and sources of information for this requirements definition. We will also put the requirements in the context of the process. In Chapter 3, we will identify and describe the context of use for the Europeana mobile client that the following requirements in this document are based on. Chapter 3.4 contains an overview about the current state of the art in mobile devices. We will analyse the current market situation regarding operating systems, mobile browsers and the capabilities of various mobile devices. Based on this, we will make a prediction for the time after the end of the EuropeanaConnect project. Chapter 5 contains the actual requirements analysis, split in functional and non-functional requirements, as well as external constraints. Use cases are presented to further detail the requirements on the mobile client. We will conclude with a summary and present the next necessary steps in the development of the mobile client in chapter 5. 2. **Approach** In this chapter we describe the approach we used to define the requirements for the development of *eMobile*, the mobile access client for Europeana. 2.1. **Process Model** The design of an interactive system, in this case a mobile web application, is no trivial task. To ensure the development of a highly usable system that is efficient, effective and satisfying, which are the three main criteria for usability as defined in ISO 9241-11 (ISO, 1998), the application design needs to follow a defined process model. The document at hand is the result of the application of the HCD process, as specified in ISO 13407 (ISO, 1999). It is particularly well suited for the design of interactive systems, as it incorporates user feedback in all stages of development, which can be considered one of the most crucial aspects in software engineering. **Human-Centred Design Process** The HCD process is illustrated in Figure 2. It consists of four steps: 1. **Specify Context of Use.** In this step, the stakeholders of the product are identified and the user environment is described. This step gives developers a “big picture” of the product and its users. 2. **Specify requirements.** The specification of requirements is the most essential step to create highly usable products. In this step, the goals of the product's users will be gathered and described in a standardized format. 3. **Produce design solutions.** Based on the first steps, the development of the actual software version is carried out. 4. **Evaluate design.** A crucial step to measure the usability of a product and to improve the product usability-wise is to perform evaluations on the product, which are conducted in this step. The process is then repeated until the developed system satisfies the formerly specified requirements. This document spans two steps in the process: The specification of the context of use and the requirements specification. In EuropeanaConnect tasks 3.4.2 and 3.4.3, we will deal with the development of the mobile clients themselves. In 3.4.4, the developed prototypes will be evaluated according to the last section of the HCD process. ### 2.2. Sources of information This requirements definition is based on several sources that are briefly described in the following: 1. We considered user profiles identified in previous user surveys by Europeana / EDL.NET. A summary of these can be found in the EuropeanaConnect Description of Work (DoW). We will put these in the context of mobile access to Europeana in chapter 3.2. 2. We used preliminary results of the Personas Workshop held as part of EuropeanaConnect WP 3.2 to identify **personas** that serve as a base for the development of the mobile client. Details on these can be found in chapter 3.3. 3. We conducted a user survey with staff from our cultural partner institutions that are experienced in terms of users’ needs, either due to frequent customer contact or due to deep knowledge about the use of mobile devices and the mobile web. For the survey, we used a questionnaire containing 10 questions about mobile access to the Europeana database. The results are summarized in chapter 4. 4. Brainstorming and discussion sessions in a task-force with mobile interaction and usability experts from our institute were used to extend the space of possibilities and determine feasible features. The combination of these four sources gives an accurate picture of the demands on mobile use of Europeana, which will be used to derive precise requirements in chapter 4. In the next chapter, we will describe the context of use for the Europeana mobile client. 3. Context of Use In this chapter, we describe the context of use of mobile access to Europeana, according to the first phase of the human-centred design process. This involves the identification of stakeholders of the mobile Europeana client. The target group will be detailed by describing user profiles and personas identified in previous surveys. We then derive three key scenarios from these descriptions that will serve as a guideline for the development of the Europeana mobile client. 3.1 Stakeholders For developers and designers alike, it is crucial to understand the target group of the product to be created. Thus, all requirements identified later in this project will be based on the stakeholders identified in this part. For the developments of eMobile, we have identified two primary stakeholders: 1. The most important stakeholders of eMobile are the actual users of Europeana. They form the target group that needs to be supported by eMobile. They will access the Europeana database from their mobile devices and want to use the various functions of Europeana in a mobile context. Furthermore, they demand features that are only available in mobile scenarios, which will be described later in this document. To meet the concerns of Europeana’s users, special attention needs to be paid to all interface related aspects when developing eMobile. By using the human-centred design process as process model, as pointed out in chapter 2.1, we will include user feedback in all stages of development. 2. The second important stakeholder is the Europeana Office, which plays an important role as coordinator of the developments of EuropeanaConnect and also formulates demands on the development of the mobile Europeana client. In particular, the Europeana Office needs to integrate the results from Task 3.4 into Europeana and maintain the code after the end of the project. From this, we can derive qualitative demands on the code, which includes proper documentation and testability. Details on these aspects can be found in the requirements definition in chapter 4. In order to get a better picture of potential Europeana users in mobile scenarios, the target group will be described in more detail in the following. 3.2 User profiles EuropeanaConnect is embedded in a wider range of projects, aiming at making the rich cultural works of Europe available to the public. One of the projects delivering important fundamentals to EuropeanaConnect is Europeana.Net. In Europeana.Net, five possible user profiles have already been identified. In the EuropeanaConnect description of work, those have been extended by two more profiles. Of the resulting seven profiles, five involve mobile access to the Europeana database. The relevant profiles and aspects for the development of a mobile client are briefly summarized in the following: 1. **General Users** General users are looking for education and entertainment. They need an interesting interface, easy navigation and interesting value-added services. They have experience with basic search services (e.g. Google) but have no specific knowledge about information retrieval. 2. **School Students** School students will access Europeana to gather information for reports or homework. They are focused on reading material. They are experienced with Web 2.0 technologies and need to be entertained while using online services. 3. **Academic Users** Academic users are looking for material for scientific publications, with a focus on reading material. They look for specific information and thus need extended / advanced search functionality. 4. **Expert Researchers** Expert Researchers are also looking for specific reading material. They thus also need extended / advanced search functionality. In addition, they may be willing to pay for special services. 5. **Professional Users (e.g. Librarians)** Professional users make use of more sophisticated search functions and need speedy responses by the system. They are experts in information retrieval, but also may add information to the database. While these profiles already provide valuable information regarding the target group of eMobile, the personas identified in WP 3.2 further enrich these profiles by adding detailed characteristics to the potential users. These will be described in the following. ### 3.3 Personas EuropeanaConnect WP 3.2 deals with the definition of so-called personas. Personas are concrete, yet virtual representatives of different user groups that help developers design their products closer to the users’ real needs. In the following, the identified personas and their characteristics are briefly summarized and put into the context of development of mobile access for Europeana. 1. **Strongly navigational user with lack of IT knowledge, that is limited to his / her native language.** He / she uses Europeana mainly for hobby and genealogy purposes. 2. **Navigational user with lack of IT knowledge and limited language skills.** He / She uses Europeana for language education and to send “fun stuff” to friends. 3. **Strongly explorative and demanding professional or researcher with significant IT knowledge.** He / She is a professional networker and uses Europeana for broad subjects, comparative studies, exhibitions and to get information about the history of architecture. 4. **Mixed explorative / navigational and educated user with sufficient IT knowledge.** He / She is a strong networker, uses material from Europeana for lessons or to plan a trip. 5. **Strongly navigational researcher or tourist.** He / She is focused on a specific way of reaching his / her goal and is unwilling to learn new methods. He / She uses material from Europeana professionally or plans a trip with the information in the database. 6. **Office worker with navigational focus.** His / her language skills are limited and he / she tends to sticks to familiar methods. He / she uses Europeana for hobby and secondary purposes. 7. **This persona’s approach is strongly explorative.** He / She may be a pupil or game player, probably using Europeana for doing their homework. He / She is used to quickly interact with user interfaces with and without using their mobile phone. He / she is focused on personalization and entertainment and loses interest quickly. 8. Enthusiastic and educated user with limited IT skills and a mixed explorative / navigational profile. He / she uses Europeana for exploration and discovery of new things. The two main lessons learned from the personas definition is that 1. It is necessary to include the user’s course of action in the development of user interfaces for EuropeanaConnect. While some users will stick to used paths only, others are likely to show a strictly explorative behaviour. 2. IT knowledge may differ a lot between different users. While some users will be IT experts, others will need significant help using the interface. We can also draw interesting conclusions from the aims of the individual personas, which will, in addition to the user surveys of Task 3.4 and the user profiles defined in the EuropeanaConnect DoW, serve as a guideline for the definition of requirements in Chapter 4. 3.4 State of the art: The mobile web Apart from the identification of the target group, another very important aspect of the context of use for eMobile is the technical state of the art in mobile computing in the coming years. To design a mobile client that is ultimately usable by people, it is necessary to study the mobile devices people use in practice to connect to internet services on the go. We will thus present an analysis of the current technical state of the art in mobile computing in this chapter. Based on the current status, we will make a prediction for the time period after EuropeanaConnect, when the mobile client is likely to go live. With mobile technology evolving at amazing speed, mobile phones even become an alternative to ordinary computer workstations. “Smartphones”, offering high performance, large display resolutions and modern input concepts, have already started to become the standard of today’s mobile phones. For Europeana, it is thus most important to catch this trend and develop applications that support this new generation of mobile phones. They thus take the biggest part of this analysis, while we still consider older mobile technology as well. 3.4.1 Mobile Operating Systems The market of mobile operating systems (OS) is currently divided among five major brands: Windows Mobile, Android, Symbian, RIM and iPhone OS. In the following, we present an overview about the different mobile operating systems and discuss their features. Windows Mobile Windows Mobile is not device specific. It is not open. It offers direct access to the devices hardware and therefore makes up as a good platform when integrating different kinds of sensors, such as GPS receivers. Android Android is an open source mobile OS based on Linux. It is developed by the Open Handset Alliance (OHA) which consists of several carriers, microchip and mobile phone vendors and software producers. Android is device independent and therefore likely to be used in many mobile applications. It is in a very early stage of development though. As of June 2009, only two Android based devices have been released to the public. **Symbian** Symbian is a closed-source OS that runs exclusively on ARM processors, it was developed by Symbian Ltd, which was acquired by Nokia. Since 2008 Symbian OS and its associated libraries, frameworks and user interfaces are maintained by the Symbian Foundation, which plans to release the source code in 2010. **Research in Motion (RIM)** The proprietary OS running on devices manufactured by RIM Ltd. is called BlackBerry OS. It is only available for BlackBerry devices and is focussing on mobile messaging using push-mail in conjunction with a dedicated mail-server to address especially the needs of enterprise customers. **iPhone OS** The iPhone OS is device specific proprietary OS that runs solely on the iPhone. Due to its hardware restrictions there is no physical keyboard, therefore the user interface is based on touch gestures and direct manipulation. **Java** When it comes to incorporating data from sensors, Java is well suited, as it runs in a virtual environment and is therefore separated from the hardware. However, Java has serious performance issues on some devices. **Others / Outlook** In November 2009, Nokia wants to release their first device running Maemo 5, an open source, Linux-based OS comparable to Android. Even though Nokia is strongly involved in the development of the Symbian platform, the company announced that they will be using Maemo on their “upper class devices” in the future according (Financial Times Deutschland, 2009). webOS, developed by Palm Inc., is a Linux-based smartphone platform with proprietary Palm components released in June, 2009. Of the time of writing, it is currently used on only one device, the Palm Pre. According to Gartner market share forecasts for 2012, Symbian will still be running on 37.4% of all smartphones sold globally. While Android will be used on 18%, Blackberry’s share will be 13.9%. On fourth place Gartner forecasts the iPhone OS with 13.6% share followed by Windows mobile with a share of 9%. The remaining 8.1% will be divided among upcoming and individual operating systems (Computerworld, 2009). ### 3.4.2 Mobile browsers Mobile browsers are constrained by the limited capabilities of mobile devices. While being stripped-down web browsers in the beginning, newly developed web browsers can handle more recent technologies like CSS 2, JavaScript and AJAX. Although there is a vast variety of mobile browsers, most of them make use of the same layout engine, resulting in a list of only four different engines for the five major mobile operating systems mentioned above (Wikipedia, 2009). **WebKit** Originally created for Mac OS X’s Safari browser by Apple Inc., WebKit is now being developed further as open source software by Apple, Nokia, Google and others. Therefore it is used on mobile devices running Android, Symbian or the iPhone OS. It supports JavaScript and the XMLHttpRequest Interface. The mobile Safari version reaches 100 out of 100 points in the Acid3 test (Acid Tests, 2009), which checks a browsers adherence to web standards. This browser is also one of the first mobile browsers to support the Geolocation API, which allows the identification of a users’ location via easy to implement API calls. **Internet Explorer Mobile** The Internet Explorer Mobile comes bundled with Windows Mobile per default. Although it offers some of the features of the desktop version of Internet Explorer 6 and 7, it is not based on the same rendering engine. Even though the engine supports JavaScript and the XMLHttpRequest interface, web applications for IE Mobile need some workarounds to support AJAX features, resulting in a failing Acid3 test with a score of 0. **Mango** The proprietary Mango layout engine is used solely in RIMs mobile browser. It reaches 54 out of 100 points in the Acid3 test even though XMLHttpRequest and Javascript are supported, but the latter being turned off by default. **Presto** The Presto engine is used in Opera Mobile, which is available as 3rd party software that can be installed on Windows Mobile and Symbian devices in addition to the built-in browser. It claims a market share that is nearly the same than the iPhone’s share (each ~24%) that can be explained with its good support of web standards and Ajax capabilities that result in 100 out of 100 points in the Acid3 test (with the beta version 9.7b1 available at the time of writing). The forecasts for mobile operating systems estimate a combined marketshare for Symbian, Android and the iPhone OS of 69% in 2012. Based on the fact that their built-in browsers are using the WebKit layout engine the possibility that it will keep a strong market share in the future is very high and therefore allowing the usage of AJAX features and location aware services for EuropeanaConnect. Keeping the capabilities of the other common layout engines in mind there may be a need for two versions of the mobile Europeana portal, one featuring dynamic options like Javascript enabled maps and geolocation services and one more static approach with a limited set of multimedia-based features. ### 3.4.3 Device capabilities (Resolution and Hardware Features) **Screen resolution** Most mobile phones, which will be dominating the mobile phone market in the future, offer a quite large display resolution. By 2008, 320x240 (Q VGA) was the most common resolution for Smartphones. Nowadays there is a significant trend to HVGA resolutions (320x480), and an increasing amount of Windows mobile based capable of resolutions up to 480x800 (WVGA) pixels (artegic AG, 2009). Apple’s iPhone, the Palm Pre and most Android based phones come with a HVGA screen resolution, while Windows mobile and Symbian devices use a wider range of screen resolutions. Modern mobile devices, like the Apple iPhone or Samsungs Omnia II also have orientation sensors that allow detecting whether the device is held horizontally or vertically, thus enabling optimized content for a landscape or portrait orientation. An adaptation to these devices is recommended to avoid zooming and scrolling. Camera According to (Tomi Ahonen Consulting, 2009), the most desired feature to drive new phone sales is the inbuilt camera. Although the camera resolution is constantly growing, camera phone pictures often lack image quality, especially in bad lighting situations. They may add additional value to mobile clients though, as they can be used to upload image content to web portals or detect objects seen by the camera. GPS Ovum Research states that 75% of all released smartphones in 2nd quarter of 2009 were GPS-equipped (Mobile Marketer, 2009). These devices often use A-GPS (Assisted Global Positioning System), a technology that uses information from the cell phone position and/or the mobile phone network to determine the user’s position faster than the “regular” satellite based positioning system. The usage of GPS allows the integration of location based services (LBS) into mobile device applications and websites, e.g. turn by turn navigation or requesting points of interest near the device’s user. The “World GPS Market Forecast” (3B, April, 2009) states that around 70% of the market share for GPS devices in 2013 will be held by GPS-enabled handsets. In addition, ABI Research forecasts that by 2013, low-cost GPS sensors will enable an integration of GPS in nearly all mobile devices by that time (ABI Research, 2009). In order to create the best possible experience for mobile Europeana users, an adaptive approach would be an interesting option: Depending on the screen resolution a device uses, the user will be presented a slightly different screen layout that makes optimal use of the available display area. The high availability of GPS equipped devices adds the opportunity to incorporate location aware services into EuropeanaConnect. 3.4.4 Protocols When dealing with transmission protocols for mobile devices, one typically is set to one of two options: WAP with WML as markup language, or HTTP with HTML/CSS as markup languages. WAP with WML With the release of version 1.1 of the WAP standard in 1999, mobile phone vendors started to add WAP-Browser to the majority of their devices, while content providers started to offer mobile services like news headlines or sports results. Since data transmission via GPRS or HSCSD was not common, users of WAP-Browsers had to deal with low bandwidths and therefore only limited functionality with these mobile services. HTTP with HTML/CSS With the development of efficient layout engines, larger screen resolutions and higher data transfer rates in mobile networks, HTTP with HTML/CSS has taken the place of WAP for mobile internet portals. As the mobile access channels for EuropeanaConnect are assumed to go live after 2010, it is most likely that the majority of devices used to access EuropeanaConnect will be capable of displaying websites written in HTML via HTTP, allowing the user to access multimedia data like images, movie and sound-clips. 3.5 Summary Since smartphones are becoming more and more important when it comes to mobile internet access, we will focus on the development on a mobile access channel for Europeana that meets the needs of mobile users with that device class. Because the development of the mobile market is constantly changing, it is important to focus on the layout engines used in modern mobile browsers. By adhering to established web standards (HTML/CSS, W3C Geolocation API) it is possible to create a user experience that is independent of the used operating system and mobile browser. To accomplish this goal, the different hardware capabilities of devices need to be considered, e.g. by adapting the size of a result list to the available screen area and resolution or offering location aware features by using the built-in GPS sensor of modern mobile devices. 4. Requirements Analysis To gather the requirements on the Europeana mobile client, we rely on several sources of information. In the previous chapter, we analysed the context of use of the mobile client. This includes the identification of the system’s stakeholders, the incorporation of results from previous surveys of Europeana.Net and personas defined in EuropeanaConnect WP 3.2. Furthermore, we have presented the current state of the art in mobile computing and gave an outlook about the technical developments of the coming years. In this chapter, we will start with the presentation of results from a survey with representatives of our project partner, the Royal Library of Denmark. We will present the results from the survey in detail and condense them into concrete requirements for mobile access to Europeana in the following. We will also take into consideration the context of use identified in chapter 3. 4.1 User Survey To derive requirements directly from representatives of potential Europeana users, we gave out questionnaires to senior staff from our project partner, the Royal Library of Denmark (see chapter 7). The participants are seniors with experience in mobile access or human factors, some with close customer contact on a daily basis. The questionnaire contained ten questions. Three were related to the experience users had with the current version of the Europeana web portal, mobile devices and usage of the mobile web in general. The other seven were related to mobile access to Europeana. The participants did also mention aspects not directly related to mobile access, but also to Europeana in general. These will probably be interesting for other work packages as well and are thus also summarized in the following. Experience with Europeana and the mobile web It can be noted that all participants had used web services from their mobile device before. The frequency of mobile web access varied from scarce to frequent use. They either already had experience using the ordinary web portal or had made themselves familiar with Europeana before answering the questionnaire. Mobile Scenarios To get a more general idea of the context in which a mobile Europeana application would be used, we asked the participants to think of three example scenarios they would think mobile access to Europeana made sense. The answers included - finding material for a presentation, e.g. images - comparing an original object to the information inside Europeana - finding related information to cultural works when at a cultural site - discussing a cultural object with a colleague - verification of questions that cannot be clarified using Google when out of office - collecting soundtracks / videos to enjoy on journeys Most important features The participants were asked to denote the three top functions they would expect from a mobile client for Europeana. The main requested feature was the support of different mobile devices, e.g. a presentation of search results or images that fits the screen resolution of the used mobile device. Also, the speed of the application was considered crucial. One participant demanded the ability to enlarge images or get more detail on items on demand. Location aware Search We asked the participants whether they would be interested in location aware search functionality. Participant A thinks that location aware search would be a very interesting feature. Participant B pointed out that location aware search would be "nice to have, not need to have", but could probably be a "selling point" for the mobile client. The third was unsure about this question but found location aware functions an advantage to get to the original works. Mobile use of Europeana The participants were also asked whether they would think users would access Europeana from their mobile device. They noted that mobile access would not be an obvious feature for Europeana and that they probably would only be using it for short search sessions. Another participant mentioned that a mobile client would probably not make much sense, as the current web portal would already lack some needed functionality. There is obviously significant skepticism towards accessing Europeana on mobile devices. The participants seemingly couldn't imagine that a mobile client would add true value to their Europeana experience. On the other hand, the participants identified various scenarios where a mobile client would make sense and would add true value to their Europeana experience. This fact primarily shows that the acceptance of a mobile client may be dependent on adding features that are not available in the web portal in mobile scenarios, such as device specific presentation of search results or location aware search functions. The results may also be influenced by experiences with the current Europeana web portal, which from the users’ points of view, seems to lack certain critical functionality at the moment. eMobile “App” The participants were asked whether they would install a third party application on their mobile device if it would add more features than an ordinary web client. The results on this aspect are ambivalent. One participant would install such an application without worrying, one was skeptical towards a third-party application and one would do so only if it provided added value compared to a web based service. We imply that a web-based frontend that doesn’t need to install software on the user’s device may thus be the best option for the development of a mobile client, especially when taking into consideration the current state of the art, which shows that the execution of rich web applications on mobile devices is already possible on many devices and is likely to become common in the next years. General Issues (Not specific to mobile use) One participant pointed out that the look and feel of the Europeana portal is good, although the purpose of the web site could be unclear to users at first. Another participant was rather frustrated by the usability of the current Europeana web portal and found it hard to use. He / She proposed the constraints of a mobile client should be transferred to the Europeana web portal to make it simpler to use. Also, community and semantic search features were missed in the current web portal. According to one participant, the interlinking with social websites, such as Facebook, should be a top priority. The speed of the current “timeline” function was also criticized. Another aspect concerns the quality of the results: One participant mentioned that Google often returned better results for his / her needs. Also, one participant missed information about the geographic location of the objects in the database. **General Issues (Specific for mobile client)** The participants were also asked if they had general comments about the development of mobile access to Europeana. These were the answers: - A mobile client should be "simple, sexy and smart" - The tagging of objects and sending of contents to a social website was considered important - The language of the user interface could be influenced by the geographic position of the user - Interactivity of the application was considered important, though hard to implement - The mobile Europeana client has to return better results than Google **Discussion and conclusion** The survey gives an interesting picture about the image of Europeana and the features users demand of a mobile client for Europeana. The participants gave some comments concerning the improvement of some aspects of the current Europeana web portal, particularly when it comes to quality of the search results, purpose of the website and speed. Thus, for a mobile client, an easy operation was explicitly demanded by some of the participants. The added value of a mobile client was not obvious to the users at first sight, although they were able to identify numerous scenarios for a mobile Europeana client, including research, educational and fun use of Europeana in mobile context. It seems their opinions may be biased by the current look and feel of the Europeana web portal, which is not optimized for mobile devices at the current time. The most important features identified were the performance of the mobile application and the support of the different capabilities of mobile devices, e.g. different resolutions of the used displays. Also, location aware search features were interesting for the users and were seen as feasible features for a mobile client. Concerning the installation of a third-party application on their devices, the users were ambivalent. One participant would install such an application, while the others were skeptical or didn’t see a need for an additional application. The users were particularly interested in social networking, good search results and, first of all, a simple, fast and interactive mobile interface to Europeana. **4.2 Overview** Along with the consideration of the formerly presented context of use, we can now conclude the requirements of this task in the following. The user requirements are split into three parts: 1. **Functional requirements** that describe the behaviour and features of the mobile Europeana client. To capture the functional requirements, we rely on the specification of use cases. 2. **Non-functional requirements** that specify qualitative aspects of the system. These result from the context EuropeanaConnect is embedded in and include the maintainability of the software code and the scalability of the system. 3. **Constraint requirements** that primarily result from external stakeholders, in our case the Europeana Office. Also, the technical development of the mobile market limits the space of possible features that can be integrated. The combination of these requirements will form the base for the design of the mobile prototypes to be developed in this task. 4.3 Functional Requirements The functional requirements presented here define the behaviour of eMobile. We use the well-known approach of formalising the functional requirements in use cases, following a template of (Cockburn, 2001). If not specified otherwise, the actors in all use cases are a mobile user accessing Europeana from his or her mobile device using the mobile client to be developed in this task (3.4). UC 1.1 Simple Search Short description: The system shall allow the user to do a simple keyword search Trigger: User wants to look up information in the Europeana database Preconditions: User has entered the simple search screen Postconditions: A set of search results is visually presented to the user on his or her mobile device. Normal flow: The user enters a search string and starts the search Alternative flow: none UC 1.2 FACETED Search Short description: The system shall allow the user to do a faceted search over different categories Trigger: User wants to look up specific information in the Europeana database Preconditions: User has entered the advanced search screen Postconditions: A set of search results is visually presented to the user on his or her mobile device. Normal flow: The user enters a search string and starts the search Alternative flow: none UC 1.3 Location Aware Search Short description: The system shall allow the user to do a location aware search based on the user’s current position Trigger: User wants to look for cultural works in the Europeana database in a specific perimeter around his current location Preconditions: User is using a mobile browser that supports the W3C Geolocation API. He or she has entered the location aware search screen. Postconditions: A set of search results is visually presented to the user on his or her mobile device. Normal flow: The user enters a search string and starts the search Alternative flows: The user enters no search string and starts the location aware search. The search result displays a list of cultural works around his current location. UC 2.1 Visualization of Search Results in text-only List Short description: The system shall allow the user to visualize results in a text-only perspective Trigger: Visualization of Results of UC1.1-1.3 Preconditions: Searching by the system is finished, results are rendered in gallery-, map- or mixed mode. User selects Text-only mode. Postconditions: The result set is visualized in a text-only perspective. Normal flow: User has initiated a search. Text-only mode is currently selected. Alternative flow: User selects text-only visualization from the results page. UC 2.2 Visualization of Search Results in gallery list Short description: The system shall allow the user to visualize results in an image-only gallery perspective Trigger: Visualization of Results of UC1.1-1.3 Preconditions: Searching by the system is finished, results are rendered in text-only, map- or mixed mode. User selects Gallery mode. Postconditions: The result set is visualized in a gallery perspective. Normal flow: User has initiated a search, results are displayed after search has finished. Alternative flow: User selects gallery visualization from the results page. UC 2.3 Visualization of Search Results in Mixed list Short description: The system shall allow the user to visualize results in a mixed image/text perspective Trigger: Visualization of Results of UC1.1-1.3 Preconditions: Searching by the system is finished, results are ready to render or already rendered in Text-only, map- or mixed mode. Mixed mode is selected (by default or through user selection). Postconditions: The result set is visualized in a mixed image / text perspective. Normal flow: User has initiated a search, results are displayed after search has finished. Alternative flow: User selects mixed mode from the results page. UC 2.4 Visualization of Search Results in a map Short description: The system shall allow the user to visualize results in a map, showing entries in a specified perimeter around his / her current location. Trigger: Visualization of Results of UC1.1-1.3 Preconditions: Searching by the system is finished, results are rendered in gallery-, text- or mixed mode. The mobile device uses a modern browser supporting the W3C Geolocation API. User selects map mode. Postconditions: The result set is visualized in a perimeter around the user’s current location. Normal flow: User has initiated a search, results are displayed after search has finished. Alternative flow: User selects map mode from the results page. UC 3 Visualize details of an item in the search results Short description: The system should allow the user visualize details of a selected item in the search results Trigger: User wants to see more details of an item Preconditions: User has entered the search results screen Postconditions: The system renders a page with details of the selected item Normal flow: The user selects an item from the search result set for detailed viewing Alternative flow: none 4.4 Non-functional Requirements In contrast to functional requirements, non-functional requirements do not make a statement about the behaviour of the system, but about its quality. They are an essential part of the requirements definition, especially in the context of larger projects as Europeana, in which thousands of users are potentially working with the system each day. In the following, we will thus present the qualitative requirements that should be met by the mobile client to be developed in EuropeanaConnect. N1 Usability The usability of the mobile client is a critical aspect that demands special attention. According to DIN EN ISO 9241-11, usability is defined as the “extent to which a product can be used by specified users to achieve specified goals with effectiveness, efficiency and satisfaction in a specified context of use.” In the context of the Europeana mobile client, these demands are detailed as follows: - The system should allow users to *efficiently* use the Europeana mobile client. The system should allow users to reach their goals without digressions. It should quickly react to the user’s actions, be non-distracting and should allow users to operate the system in a linear way. The mobile client should support the mobile users of Europeana in effectively fulfilling their tasks in a mobile context. It should aid the user in extracting the right results out of the Europeana Database and should assist users in finding the results they need. This includes a clear layout of the display and an unambiguous navigation through the various functions of the system. The user’s interaction with the system should be satisfying, with a strong emphasis on the user’s feelings when using the system and after using the system. To reach the goal of satisfaction, users need to be supported in finding the results they need. This includes aspects as a straightforward interface design and the minimization of necessary interactions by the user, as bandwidth and speed of mobile lines are usually limited. There are several aspects that need to be considered to ensure a high usability of the system. Interface design guidelines as the “ten usability heuristics” by (Nielsen, 1994), the “eight golden Rules” by (Shneiderman, et al., 2004) and usability standards, in particular DIN EN ISO 9241-110 (ISO, 2006) serve as a base for the development of a well usable system. According to the user centred design process, we will evaluate the usability of the system in a user study as part of work package 3.4.4, after the release of RHINE in M15. **N2 Security** One of the most important non-functional requirements is security. Security requirements come in different forms: *Privacy* The system shall not store any personal information about a certain user that can not be changed by the user him/herself (e.g. personalized search settings or saved queries). It shall not allow unauthorized individuals or programs access to any communication. *Access rights* The system shall verify the identity of all its users before allowing them to use personalized features. The system will therefore use existing authentication mechanisms proposed by the Europeana Office to handle authorization requests. It shall not allow unauthorized individuals or programs access to any stored personal data or allow a user to access account information of a different user. **N3 Scalability** Scalability is a critical issue for all developments in the EuropeanaConnect project. Europeana will become a central service for all Europeans and is therefore likely to experience heavy traffic from day to day. This also holds true for the mobile web client developed in this task. As we pointed out, mobile access to Europeana is likely to be used in a similar frequency than the ordinary web service. It thus needs to be made sure that eMobile will be scalable according to the increasing popularity of Europeana. This aspect needs to be considered when developing the software. Also, the steps necessary to scale eMobile horizontally need to be appropriately documented. **N4 Extensibility** Extensibility is a quality of design that takes possible future advances into consideration and attempts to accommodate them. The system shall therefore be able to allow the addition of features without impact to the existing system functions. The usage of SPRING as a framework, as recommended by the Europeana Office, will assist in keeping the system flexible and extendable. N5 Maintainability The code developed in this task needs to be maintained by external institutions, i.e., the Europeana Office, after the project. To ensure this, we support the development architecture proposed by the Europeana Office, concerning development platforms and tools, as well as programming language and frameworks as good as possible. We will also document all necessary features and parts of the code having in mind the developers of external service providers. N6 Testability To ensure a proper testability of the code, we will develop unit tests for all critical parts of the software. Unit tests can be executed automatically to confirm the correct operation of the code after changing parts of the system. We will furthermore test the operation of the system manually to ensure proper operation from a user-centric point of view. N7 Platform Compatibility As pointed out in chapter 0, the landscape of mobile devices looks quite heterogeneous. A diversity of mobile devices exists, offering different resolutions, browsers and technical features. The system should thus support a wide range of mobile devices and offer optimized versions of the mobile Europeana portal that suit the various mobile devices used. This is also backed by the results from the user survey. All users pointed out that the support of different mobile devices would be one of the key features of mobile access to Europeana. N8 Performance In a mobile scenario, performance is a critical aspect, as mentioned by two participants of the survey explained above. Since mobile internet connections still have to deal with lower bandwidths than regular internet connections, one of the main focus points for performance considerations should be the amount of transferred data. It shall only transfer data relevant to his/her query that makes sense in a mobile environment. E.g., a high-resolution image should only be loaded if the user wants to view and actively selects it. The system shall respond to a user-query immediately and as fast as possible. Mobile devices still sometimes lack processing power, so displaying hundreds of results could affect the user’s experience. 4.5 Constraint Requirements The result of WP 3.4 will be a prototype of a mobile client for Europeana. Nevertheless, the later integration of some or all results of this WP into Europeana is a primary goal that is being worked on by Task 3.4.5. Because of this, there are some constraints in the form of technical demands that are made by the Europeana office. These are described in detail in the Guidelines for the use of EuropeanaLabs (Siebinga, et al., 2009). In the following, we will describe the different external requirements and how they will be dealt with during the development of the mobile clients. C1 Development Process EuropeanaLabs is the official environment for the implementation and testing of new components to europeana.eu. When submitting a new component, the submission has to undergo a specified process that is specified in (Siebinga, et al., 2009). This includes providing a functional specification with use cases and user scenarios. The integration and acceptance of the code will then be dependent on the Europeana Office. eMobile will be an experimental approach that will not deliver final versions of software, but prototypes that show what is possible in mobile computing at this time. Despite that, the integration with Europeana is still a top priority, and the development of eMobile is dependent on parts of Europeana that will be specified later. Thus, the official development process needs to be taken into account when developing the client. **C2 Programming language** The core of Europeana Europeana.eu is based on Java technology. This is why Java will need to be used as the programming language for the development of the Europeana mobile client as well, as it has to be maintained and integrated by the Europeana Office at a later stage. **C3 Application Server** The Europeana Office requires the deployment into the Tomcat 6 or Jetty application servers. eMobile should thus also support these application servers. **C4 Testing system** For continuous integration purposes, the testability of all code with Junit4 needs to be established. eMobile should thus integrate such tests for all of its code. **C5 Dependency Injection / AOP** To ensure an easy reconfiguration and exchange of parts of the system, the system uses SPRING as a framework for dependency injection and aspect oriented programming. As a special variant for web services, the use of SPRING-MVC is encouraged. eMobile should thus be embedded in the SPRING-MVC environment. **C6 Operating System** The web client will run in a Linux based environment and should thus be compatible with operation on the Linux OS. **C7 Build manager** The Europeana Office requires the use of Maven2 or ApacheAnt as build managers. As Maven2 is the recommended way, eMobile should use Maven as build manager. **C8 RIA Toolkits** For RIA, the use of Google AWT is recommended by the Europeana Office. The development of the rich functions of eMobile should thus be based on this framework, if possible. **C9 Statelessness** Europeana applications need to be scalable by clustering and replication. This is why web applications developed in EuropeanaConnect need to be stateless, which is also enforced by disabling sessions on the servers. eMobile therefore must not rely on sessions but use stateless interaction instead. **C10 External libraries** The Europeana Office proposes the use of already integrated libraries in the development process for the sake of maintainability. eMobile should thus try to use existing libraries whenever possible. 5. Conclusion In this document, we have presented the requirements for the development of mobile access to the Europeana database. We started with the identification of the context of use for a mobile Europeana client, including the identification of stakeholders, user profiles and personas, which will serve as a guideline throughout the whole development process. The requirements derived in the following are based on a user survey we conducted with representatives of our project partners, which gave clear insights on the needs of potential Europeana users. The functional requirements, which describe the behaviour of the system, were modelled in use cases, identifying actors, functionality, pre- and postconditions. The non-functional requirements were given a special focus, as aspects like the scalability and performance of the system play a key role in a large project like EuropeanaConnect. Closing with external constraint requirements, a clear guideline was formulated for the development of the design of the eMobile prototypes. According to those requirements, eMobile should enable users to - Access information in Europeana from their mobile devices - Present a mobile version of Europeana in a way optimized for the accessing devices capabilities, considering - Colors - Resolution - Capabilities of the mobile browser (e.g. static or dynamic version) - Perform location aware searches in Europeana, i.e. search for cultural works around the user’s current position 5.1 Outlook The requirements identified herein form the base for the next steps in development of eMobile. They will deliver the necessary information to develop a design for prototypes of a mobile Europeana web gateway, tailored to the specific needs of mobile users. The support of a broad diversity of mobile devices, as well as the support of GPS sensors, which enable location aware searches in Europeana, will be top priorities. We will consider the specific limitations of mobile devices, including low resolution and screen sizes. Also, we will adapt to the available technology regarding operating systems and mobile browsers to create a well suited environment for Europeana users in mobile contexts. We will also lay the base for the integration into the Europeana framework. 6. References 7. Appendix A – User Requirements Questionnaire (Template) MOBILE ACCESS CHANNELS FOR EUROPEANA USER REQUIREMENTS QUESTIONNAIRE OFFIS INSTITUTE FOR INFORMATION TECHNOLOGY OCTOBER 2010 Information Europeana is a database containing information about 4.6 million digitized cultural works in Europe, e.g. - Images - paintings, drawings, maps, photos and pictures of museum objects - Texts - books, newspapers, letters, diaries and archival papers - Sounds - music and spoken word from cylinders, tapes, discs and radio broadcasts - Videos - films, newsreels and TV broadcasts We (OFFIS Institute for Information Technology, Oldenburg, Germany) are currently developing a mobile phone application for accessing Europeana. We are currently conducting interviews to better understand the requirements of potential Europeana users. We would thus like to ask you for your help. In this questionnaire, we would like to find out the most important features such an application should have in your opinion. Please note: 1. To properly answer this questionnaire, it is crucial to understand what Europeana is about. If you have no experience with Europeana yet, please take some time and accommodate yourself with the Europeana portal at http://europeana.eu. 2. The questionnaire. Describe all of your thoughts thoroughly and be as detailed as possible. Use as much space as needed. 3. If you have any questions, please contact me at tobias.hesselmann@offis.de or by phone +49.441.9722.139. **User Profile** First, we would like to ask you for some information about yourself. Please note that all information will be treated anonymously. Your contact information will be used for follow-up questions only. <table> <thead> <tr> <th>Name</th> <th></th> </tr> </thead> <tbody> <tr> <td>Occupation</td> <td></td> </tr> <tr> <td>Age</td> <td></td> </tr> <tr> <td>Gender (male/female)</td> <td></td> </tr> <tr> <td>Phone No.</td> <td></td> </tr> <tr> <td>Email</td> <td></td> </tr> <tr> <td>Does your job involve customer contact? If so, to what extent?</td> <td></td> </tr> </tbody> </table> ### Europeana Features When answering the following questions, please bear in mind the mobile scenario. You want to access and use the various functions of Europeana with your mobile device, e.g. mobile phone. <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>4.</strong> We are interested in situations users would access Europeana from their mobile devices. Please try to describe 3 different mobile scenarios in a few sentences.</td> <td></td> </tr> <tr> <td>1.</td> <td></td> </tr> <tr> <td>2.</td> <td></td> </tr> <tr> <td>3.</td> <td></td> </tr> </tbody> </table> <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>5.</strong> What would you think would be the 3 most important features of a mobile phone application for Europeana?</td> <td></td> </tr> <tr> <td>1.</td> <td></td> </tr> <tr> <td>2.</td> <td></td> </tr> <tr> <td>3.</td> <td></td> </tr> </tbody> </table> <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>6.</strong> Which mobile devices do you think users would like to use for accessing Europeana?</td> <td></td> </tr> </tbody> </table> <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>7.</strong> Would you imagine that users would use their mobile device to search and browse inside the Europeana database? In what way?</td> <td></td> </tr> </tbody> </table> <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>8.</strong> Would you imagine that location aware services would be useful in a mobile client for Europeana (e.g. searching for cultural works or institutions around the user’s current position)?</td> <td></td> </tr> </tbody> </table> 9. Europeana will be accessible through your mobile device via its built-in web browser. However, a standalone application may add additional features to your mobile Europeana experience. Would you accept to have an additional application installed on your mobile device and what would you expect from it? 10. Do you have any other suggestions or comments regarding the Europeana mobile phone application? Thank you very much for your time. If you have any questions, please get back to tobias.heiselmann@offis.de.
{"Source-Url": "https://pro.europeana.eu/files/Europeana_Professional/Projects/Project_list/EuropeanaConnect/Deliverables/ECONNECT-D3.4.1-Catalogue%20of%20User%20Requirements.pdf", "len_cl100k_base": 12621, "olmocr-version": "0.1.53", "pdf-total-pages": 31, "total-fallback-pages": 0, "total-input-tokens": 56947, "total-output-tokens": 14875, "length": "2e13", "weborganizer": {"__label__adult": 0.0005764961242675781, "__label__art_design": 0.002655029296875, "__label__crime_law": 0.00037026405334472656, "__label__education_jobs": 0.00974273681640625, "__label__entertainment": 0.0003752708435058594, "__label__fashion_beauty": 0.0005159378051757812, "__label__finance_business": 0.0023136138916015625, "__label__food_dining": 0.0004706382751464844, "__label__games": 0.0020160675048828125, "__label__hardware": 0.01161956787109375, "__label__health": 0.0004374980926513672, "__label__history": 0.0017671585083007812, "__label__home_hobbies": 0.0002892017364501953, "__label__industrial": 0.0005450248718261719, "__label__literature": 0.0009007453918457032, "__label__politics": 0.00036406517028808594, "__label__religion": 0.0006570816040039062, "__label__science_tech": 0.1005859375, "__label__social_life": 0.0001995563507080078, "__label__software": 0.06170654296875, "__label__software_dev": 0.80029296875, "__label__sports_fitness": 0.0002727508544921875, "__label__transportation": 0.000988006591796875, "__label__travel": 0.0003712177276611328}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 65789, 0.02418]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 65789, 0.13465]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 65789, 0.91028]], "google_gemma-3-12b-it_contains_pii": [[0, 233, false], [233, 616, null], [616, 2535, null], [2535, 4958, null], [4958, 7183, null], [7183, 9078, null], [9078, 10480, null], [10480, 12722, null], [12722, 15575, null], [15575, 19035, null], [19035, 22068, null], [22068, 25049, null], [25049, 28144, null], [28144, 31076, null], [31076, 31930, null], [31930, 34683, null], [34683, 38248, null], [38248, 41726, null], [41726, 43682, null], [43682, 45716, null], [45716, 48123, null], [48123, 51298, null], [51298, 54588, null], [54588, 57143, null], [57143, 59429, null], [59429, 62125, null], [62125, 62312, null], [62312, 63614, null], [63614, 64160, null], [64160, 65273, null], [65273, 65789, null]], "google_gemma-3-12b-it_is_public_document": [[0, 233, true], [233, 616, null], [616, 2535, null], [2535, 4958, null], [4958, 7183, null], [7183, 9078, null], [9078, 10480, null], [10480, 12722, null], [12722, 15575, null], [15575, 19035, null], [19035, 22068, null], [22068, 25049, null], [25049, 28144, null], [28144, 31076, null], [31076, 31930, null], [31930, 34683, null], [34683, 38248, null], [38248, 41726, null], [41726, 43682, null], [43682, 45716, null], [45716, 48123, null], [48123, 51298, null], [51298, 54588, null], [54588, 57143, null], [57143, 59429, null], [59429, 62125, null], [62125, 62312, null], [62312, 63614, null], [63614, 64160, null], [64160, 65273, null], [65273, 65789, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 65789, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 65789, null]], "pdf_page_numbers": [[0, 233, 1], [233, 616, 2], [616, 2535, 3], [2535, 4958, 4], [4958, 7183, 5], [7183, 9078, 6], [9078, 10480, 7], [10480, 12722, 8], [12722, 15575, 9], [15575, 19035, 10], [19035, 22068, 11], [22068, 25049, 12], [25049, 28144, 13], [28144, 31076, 14], [31076, 31930, 15], [31930, 34683, 16], [34683, 38248, 17], [38248, 41726, 18], [41726, 43682, 19], [43682, 45716, 20], [45716, 48123, 21], [48123, 51298, 22], [51298, 54588, 23], [54588, 57143, 24], [57143, 59429, 25], [59429, 62125, 26], [62125, 62312, 27], [62312, 63614, 28], [63614, 64160, 29], [64160, 65273, 30], [65273, 65789, 31]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 65789, 0.07692]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
52b785c2d8eecbd8ec734c37b6bfb2be0f701e12
Presentation for use with the textbook The goal of hash table is to be able to access an entry based on its key value, not its location. We want to be able to access an entry directly through its key value, rather than by having to determine its location first by searching for the key value in an array. Using a hash table enables us to retrieve an entry in constant time (on average, O(1)). The basis of hashing is to transform the item’s key value into an integer value (its \textit{hash code}) which is then transformed into a table index. However, what if all 65,536 Unicode characters were allowed? If you assume that on average 100 characters were used, you could use a table of 200 characters and compute the index by: ```c int index = unicode % 200 ``` Hash Tables (implemented by a Map or Set) store objects at arbitrary locations and offer an average constant time for insertion, removal, and searching. It is one of the most efficient data structures for implementing a map, and the one that is used most in practice. A hash function $h$ maps keys of a given type to integers in a fixed interval $[0, N - 1]$. A hash table for a given key type consists of: - Hash function $h$ - Array (called table) of size $N$ When implementing a map with a hash table, the goal is to store item $(k, o)$ at index $i = h(k)$. **BASE DATA STRUCTURE OF HASH TABLE** - *bucket array.* Each bucket may manage a collection of entries that are sent to a specific index by the hash function. (To save space, an empty bucket may be replaced by a null reference.) ![Diagram](image) **Figure 10.4:** A bucket array of capacity 11 with entries (1,D), (25,C), (3,F), (14,Z), (6,A), (39,C), and (7,Q), using a simple hash function. EXAMPLE - design a hash table for a map storing entries as (SSN, Name), where SSN (social security number) is a nine-digit positive integer - Our hash table uses an array of size $N = 10,000$ and the hash function $h(x) =$ last four digits of $x$ The goal of a hash function, $h$, is to map each key $k$ to an integer in the range $[0, N - 1]$, where $N$ is the capacity of the bucket array for a hash table. A hash function is usually specified as the composition of two functions: - **Hash code** (independent of hash table size – allow generic implementation): - $h_1$: keys $\rightarrow$ integers - **Compression function** (dependent of hash table size): - $h_2$: integers $\rightarrow [0, N - 1]$ The hash code is applied first, and the compression function is applied next on the result, i.e., \[ h(x) = h_2(h_1(x)) \] H1: Take an arbitrary key \( k \) in our map and compute an integer that is called the hash code for \( k \) The hash code need not be in the range \([0, N - 1]\), and may even be negative. We desire that the set of hash codes assigned to our keys should avoid collisions as much as possible. HASH CODES: BIT REPRESENTATION AS AN INTEGER - **Integer cast:** - Java relies on 32-bit hash codes - We reinterpret the bits of the key as an integer - Suitable for keys of length less than or equal to the number of bits of the integer type (e.g., byte, short, int and float in Java) - **Component sum:** - Partition the bits of the key into components of fixed length (e.g., 16 or 32 bits) and we sum (or exclusive-or) the components (ignoring overflows) - Suitable for numeric keys of fixed length greater than or equal to the number of bits of the integer type (e.g., long and double in Java) Both not good for character strings or other variable-length objects that can be viewed as tuples of the form \( (x_0, x_1, \ldots, x_{n-1}) \), where the order of the \( x_i \)'s is significant. Ex> "stop", "tops", "pots", and "spot". POLYNOMIAL HASH CODES A polynomial hash code takes into consideration the positions of the $x_i$'s by using multiplication by different powers as a way to spread out the influence of each component across the resulting hash code. - **Polynomial accumulation:** - Partition the bits of the key into a sequence of components of fixed length (e.g., 8, 16 or 32 bits) - Evaluate the polynomial \[ x_0a^{n-1} + x_1a^{n-2} + \cdots + x_{n-2}a + x_{n-1}. \] where $a!\neq 1$ is a nonzero constant, ignoring overflows - Especially suitable for strings - (33, 37, 39, and 41 are particularly good choices for $a$ when working with character strings that are English words.) - **Polynomial $p(a)$ can be evaluated in $O(n)$ time using Horner's rule:** - The following polynomials are successively computed, each from the previous one in $O(1)$ time \[ p_0(a) = x_{n-1} \] \[ p_i(a) = x_{n-i} + ax_{i-1}(a) \] \[i = 1, 2, \ldots, n-1\] - We have $p(a) = p_{n-1}(a)$ \[ x_{n-1} + a(x_{n-2} + a(x_{n-3} + \cdots + a(x_2 + a(x_1 + ax_0))) \cdots)). \] CYCLIC-SHIFT HASH CODES A variant of the polynomial hash code replaces multiplication by a with a cyclic shift of a partial sum by a certain number of bits. Ex.> 5-bit cyclic shift of the 32-bit \(00111101100101101010100010101000\) is achieved by taking the leftmost five bits and placing those on the rightmost side of the representation, resulting in \(10110010110101010001010100000111\). ```java static int hashCode(String s) { int h=0; for (int i=0; i<s.length(); i++) { h = (h << 5) | (h >>>> 27); h += (int) s.charAt(i); } return h; } ``` // 5-bit cyclic shift of the running sum // add in next character <table> <thead> <tr> <th>Shift</th> <th>Collisions Total</th> <th>Collisions Max</th> </tr> </thead> <tbody> <tr> <td>0</td> <td>234735</td> <td>623</td> </tr> <tr> <td>1</td> <td>165076</td> <td>43</td> </tr> <tr> <td>2</td> <td>38471</td> <td>13</td> </tr> <tr> <td>3</td> <td>7174</td> <td>5</td> </tr> <tr> <td>4</td> <td>1379</td> <td>3</td> </tr> <tr> <td>5</td> <td>190</td> <td>3</td> </tr> <tr> <td>6</td> <td>502</td> <td>2</td> </tr> <tr> <td>7</td> <td>560</td> <td>2</td> </tr> <tr> <td>8</td> <td>5546</td> <td>4</td> </tr> <tr> <td>9</td> <td>393</td> <td>3</td> </tr> <tr> <td>10</td> <td>5194</td> <td>5</td> </tr> <tr> <td>11</td> <td>11559</td> <td>5</td> </tr> <tr> <td>12</td> <td>822</td> <td>2</td> </tr> <tr> <td>13</td> <td>900</td> <td>4</td> </tr> <tr> <td>14</td> <td>2001</td> <td>4</td> </tr> <tr> <td>15</td> <td>19251</td> <td>8</td> </tr> <tr> <td>16</td> <td>211781</td> <td>37</td> </tr> </tbody> </table> Compression functions - Compression function maps integer hash code $i$ into an integer in the range of $[0, N-1]$ - A good compression function: probability any two different keys collide is $1/N$. - If a hash function is chosen well, it should ensure that the probability of two different keys getting hashed to the same bucket is $1/N$. - Methods: - Multiplication method - MAD method **Compression Function: Division Method** - **Function:** \[ h_2(i) = i \mod N \] (\(i\): the hash code) - **The size** \(N\) **of the hash table is usually chosen to be a prime** - Prime numbers are shown to help “spread out” the distribution of hashed values. - Example: if we insert keys with hash codes \{200,205,210,215,220,...,600\} into a bucket array of size 100, then each hash code will collide with three others. But if we use a bucket array of size 101, then there will be no collisions. - The reason has to do with number theory and is beyond the scope of this course. - **Choosing** \(N\) **to be a prime number is not always enough** - If there is a repeated pattern of hash codes of the form \(pN + q\) for several different prime numbers, \(p\), then there will still be collisions. **Compression Function: MAD Method** - **Multiply-Add-and-Divide (MAD) Method:** \[ h_2(i) = [(ai + b) \mod p] \mod N \] where \(N\) is the size of the hash table, \(p\) is a prime number larger than \(N\), and \(a\) and \(b\) are integers chosen at random from the interval \([0, p - 1]\), with \(a > 0\). - MAD is chosen in order to eliminate repeated patterns in the set of hash codes and get us closer to having a “good” hash function. The main idea of a hash table is to take a bucket array, $A$, and a hash function, $h$, and use them to implement a map by storing each entry $(k,v)$ in the “bucket” $A[h(k)]$. Even with a good hash function, collisions happen, i.e., two distinct keys, $k_1$ and $k_2$, such that $h(k_1) = h(k_2)$. Collisions - Prevents us from simply inserting a new entry $(k,v)$ directly into the bucket $A[h(k)]$ - Complicates our procedure for insertion, search, and deletion operations. Collision handling schemes: - Separate Chaining - Open Addressing - Linear Probing and Variants of Linear Probing Each table element references a linked list that contains all of the items that hash to the same table index. - The linked list often is called a bucket. - The approach sometimes is called bucket hashing. Separate Chaining Scheme: have each bucket $A[j]$ store its own secondary container, holding all entries $(k,v)$ such that $h(k) = j$. - **Advantage:** simple implementations of map operations - **Disadvantage:** requires the use of an auxiliary data structure to hold entries with colliding keys A hash table of size 13, storing 10 entries with integer keys, with collisions resolved by separate chaining. The compression function is $h(k) = k \mod 13$. Values omitted. Open Addressing: store each entry directly in a table slot. + This approach saves space because no auxiliary structures are employed + Requires a bit more complexity to properly handle collisions. Open addressing requires + Load factor is always at most 1 + Entries are stored directly in the cells of the bucket array itself. EX> Linear Probing and Its Variants Assuming we use a good hash function to index the \( n \) entries of our map in a bucket array of capacity \( N \), the expected size of a bucket is \( n/N \). Therefore, if given a good hash function, the core map operations run in \( O(\lceil n/N \rceil) \). The ratio \( \lambda = n/N \), called the load factor of the hash table, should be bounded by a small constant, preferably below 1. As long as \( \lambda \) is \( O(1) \), the core operations on the hash table run in \( O(1) \) expected time. COLLISION-HANDLING SCHEMES: LINEAR PROBING - Insertion scheme: - If we try to insert an entry \((k, v)\) into a bucket \(A[j]\) where \(j = h(k)\) - If \(A[j]\) is already occupied, then we next try \(A[(j+1) \mod N]\). - If \(A[(j+1) \mod N]\) is also occupied, then we try \(A[(j + 2) \mod N]\), - and so on, until we find an empty bucket that can accept the new entry. COLLISION-HANDLING SCHEMES: LINEAR PROBING (CONT.) - Implementation when searching for an existing key, the first step of all get, put, or remove operations, need modification. - Search Scheme: Starting from $A[h(k)]$, examine consecutive slots, until either - An entry with an equal key is found or - An empty bucket is found. $$H(k) = k \mod 11$$ **Hash Code Insertion Example** <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> Tom Dick Harry Sam Pete ![Diagram showing hash code insertion example] **Hash Code Insertion Example (Cont.)** Dick Harry Sam Pete <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> **Hash Code Insertion Example (Cont.)** <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> ``` Harry Sam Pete Dick Dick [0] [1] [2] [3] [4] ``` ``` Dick Tom [0] [1] [2] [3] [4] ``` Hash Code Insertion Example (Cont.) <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> <table> <thead> <tr> <th>Name</th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td></td> <td></td> </tr> <tr> <td>Dick</td> <td></td> </tr> <tr> <td></td> <td>[0]</td> </tr> <tr> <td>[1]</td> <td></td> </tr> <tr> <td>[2]</td> <td></td> </tr> <tr> <td>[3]</td> <td></td> </tr> <tr> <td>[4]</td> <td></td> </tr> <tr> <td></td> <td></td> </tr> </tbody> </table> HASH CODE INSERTION EXAMPLE (CONT.) <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> ``` [0] Dick [1] Sam [2] Harry [3] Pete ``` **HASH CODE INSERTION EXAMPLE (CONT.)** <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> **HASH CODE INSERTION EXAMPLE (CONT.)** <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> Diagram: - Array of size 5: - [0]: Dick - [1]: Sam - [2]: Harry - [3]: Tom - [4]: Pete **HASH CODE INSERTION EXAMPLE (CONT.)** ``` <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> ``` ```java ``` **HASH CODE INSERTION EXAMPLE (CONT.)** <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> ### Hash Code Insertion Example (Cont.) <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> HASH CODE INSERTION EXAMPLE (CONT.) <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> ### Hash Code Insertion Example (Cont.) <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%5</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>4</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>4</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>3</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>4</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>3</td> </tr> </tbody> </table> Retrieval of "Tom" or "Harry" takes one step, $O(1)$ Because of collisions, retrieval of the others requires a linear search **COLLISION-HANDLING SCHEMES: LINEAR PROBING** - **Deletion Scheme:** - Cannot simply remove a found entry from its slot in the array. - EX> after the insertion of key 15, if the entry with key 37 were trivially deleted, a subsequent search for 15 would fail because that search would start by probing at index 4, then index 5, and then index 6, at which an empty cell is found. - Resolve by replacing a deleted entry with a special “defunct” sentinel object. - Modify search algorithm so that the search for a key $k$ will skip over cells containing the defunct. - The put should remember a defunct locations during the search for $k$, and put the new entry $(k,v)$, if no existing entry is found beyond it. Linear probing tends to cluster the entries of a map into contiguous runs, which may even overlap causing searches to slow down considerably. Avoiding Clustering with variant of Linear Probing: - **Quadratic Probing**: iteratively tries the buckets $A[(h(k)+ f(i)) \mod N]$, for $i = 0,1,2,...$, where $f(i) = i^2$, until finding an empty bucket. - **Double Hashing**: choose a secondary hash function, $h'$, and if $h$ maps some key $k$ to a bucket $A[h(k)]$ that is already occupied (no clustering effect) PROBLEMS WITH QUADRATIC PROBING - Quadratic probing strategy complicates the removal operation. - It does avoid the kinds of clustering patterns that occur with linear probing but still suffers from secondary clustering. - **Secondary Clustering**: set of filled array cells still has a nonuniform pattern, even if we assume that the original hash codes are distributed uniformly. - Calculation of next index \(((h(k)+ f(i)) \mod N)\) is time-consuming, involving multiplication, addition, and modulo division. A more efficient way to calculate the next index \(((h(k)+ f(i)) \mod N)\) is: \[ \begin{align*} i & \text{ += 2;} \\ \text{index} & \text{ = (index + i) \% table.length;} \end{align*} \] Examples: + If the initial value of \(i\) is -1, successive values of \(i\) will be 1, 3, 5, ... + If the initial value of index is 5, successive value of index will be 6 (= 5 + 1), 9 (= 5 + 1 + 3), 14 (= 5 + 1 + 3 + 5), ... The proof of the equality of these two calculation methods is based on the mathematical series: \[ n^2 = 1 + 3 + 5 + ... + 2n - 1 \] A more serious problem is that not all table elements are examined when looking for an insertion index; this may mean that: - An item can't be inserted even when the table is not full. - The program will get stuck in an infinite loop searching for an empty slot. If the table size is a prime number and it is never more than half full, this won't happen. However, requiring a half empty table wastes a lot of memory. Double Hashing - Open addressing strategy that does not cause clustering of the kind produced by linear probing or the kind produced by quadratic probing. - Double hashing uses a secondary hash function $h'(k)$ and handles collisions by placing an item in the first available cell of the series $$(h(k) + i*h'(k)) \mod N$$ for $i = 0, 1, \ldots, N \mod 1$ - The table size $N$ must be a prime to allow probing of all the cells. - The secondary hash function $h'(k)$ cannot have zero values. - Common choice of compression function for the secondary hash function: $$h'(k) = q - (k \mod q)$$ for some prime $q < N$. - The possible values for $h'(k)$ are $1, 2, \ldots, q$. EXAMPLE OF DOUBLE HASHING - Consider a hash table storing integer keys that handles collision with double hashing - \( N = 13 \) - \( h(k) = k \mod 13 \) - \( h'(k) = 7 - k \mod 7 \) - Insert keys 18, 41, 22, 44, 59, 32, 31, 73, in this order LOAD FACTOR AND EFFICIENCY In the hash table schemes described thus far, it is important that the load factor, \( \lambda = \frac{n}{N} \), be kept below 1. - Ex> Separate chaining: - As \( \lambda \) gets very close to 1, the probability of a collision greatly increases - Collisions adds overhead to operations - Rely on linear-time list-based methods in buckets that have collisions - Recommended load factor is \( \lambda < 0.9 \) for hash tables with separate chaining. (Java: \( \lambda < 0.75 \).) Open addressing: - If the load factor $\lambda$ gets higher than 0.5, clusters of entries in the bucket array start to grow as well. - These clusters cause the probing strategies to “bounce around” the bucket array for a considerable amount of time before they find an empty slot. - Suggested load factor is $\lambda < 0.5$ for an open addressing scheme with linear probing, and perhaps only a bit higher for other open addressing schemes. REHASHING AND EFFICIENCY - If an insertion causes the load factor of a hash table to go above the specified threshold - resize the table (to regain the specified load factor) and reinsert all objects into this new table (Rehashing). - Rehashing: - Rehashing scatter the entries throughout the new bucket array. - Don’t need a new hash code. - Do need a new compression function - Takes into consideration the size of the new table. - It is a good requirement for the new array’s size to be a prime number approximately double the previous size (amortized analysis). ## Hash Code Insertion Example (Cont.) <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%11</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>3</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>5</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>10</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>5</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>7</td> </tr> </tbody> </table> ``` [0] Dick [1] Sam [2] Pete [3] Harry [5] [6] [7] [8] [9] [10] ``` The best way to reduce the possibility of collision (and reduce linear search retrieval time because of collisions) is to increase the table size. <table> <thead> <tr> <th>Name</th> <th>hashCode()</th> <th>hashCode()%11</th> </tr> </thead> <tbody> <tr> <td>&quot;Tom&quot;</td> <td>84274</td> <td>3</td> </tr> <tr> <td>&quot;Dick&quot;</td> <td>2129869</td> <td>5</td> </tr> <tr> <td>&quot;Harry&quot;</td> <td>69496448</td> <td>10</td> </tr> <tr> <td>&quot;Sam&quot;</td> <td>82879</td> <td>5</td> </tr> <tr> <td>&quot;Pete&quot;</td> <td>2484038</td> <td>7</td> </tr> </tbody> </table> Only one collision occurred You cannot traverse a hash table in a meaningful way since the sequence of stored values is arbitrary Dick, Sam, Pete, Harry, Tom Tom, Dick, Sam, Pete, Harry EFFICIENCY OF HASH TABLES - Probabilistic basis of average-case analysis. - If our hash function is good, then we expect the entries to be uniformly distributed in the $N$ cells of the bucket array. - Thus, to store $n$ entries, the expected number of keys in a bucket would be $\lceil n/N \rceil$, which is $O(1)$ if $n$ is $O(N)$. - The costs associated with a periodic rehashing (needed after put or remove) can be accounted for separately, leading to an additional $O(1)$ amortized cost for put and remove. - In the worst case, a poor hash function could map every entry to the same bucket. - Linear-time performance for the core operations Comparison of the running times of the methods of a map realized by means of an unsorted list or a hash table JAVA HASH TABLE IMPLEMENTATION RECALL THE MAP ADT - size(), isEmpty() - get(k): if the map $M$ has an entry with key $k$, return its associated value; else, return null - put(k, v): insert entry $(k, v)$ into the map $M$; if key $k$ is not already in $M$, then return null; else, return old value associated with $k$ - remove(k): if the map $M$ has an entry with key $k$, remove it from $M$ and return its associated value; else, return null - entrySet(): return an iterable collection of the entries in $M$ - keySet(): return an iterable collection of the keys in $M$ - values(): return an iterator of the values in $M$ ABSTRACTHASHMAP - It does **not** provide any concrete representation of a table of "buckets." - Separate chaining: each bucket will be a secondary map. - Open addressing: there is no tangible container for each bucket; the "buckets" are effectively interleaved due to the probing sequences. Implementation depends on the collision handling schemes. ```java createTable(): This method should create an initially empty table having size equal to a designated capacity instance variable. bucketGet(h, k): This method should mimic the semantics of the public get method, but for a key k that is known to hash to bucket h. bucketPut(h, k, v): This method should mimic the semantics of the public put method, but for a key k that is known to hash to bucket h. bucketRemove(h, k): This method should mimic the semantics of the public remove method, but for a key k known to hash to bucket h. dropEntry(h, k): This standard map method iterates through *all* entries of the map. We do not delegate this on a per-bucket basis because “buckets” in open addressing are not inherently disjoint. ``` AbstractHashMap class provides: - `hashValue(K key)`: Mathematical support in the form of a hash compression function using a randomized Multiply-Add-and-Divide (MAD) formula, - `Resize(int newCap)`: Support for automatically resizing the underlying hash table when the load factor reaches a certain threshold. public abstract class AbstractHashMap<K, V> extends AbstractMap<K, V> { protected int n = 0; // number of entries in the dictionary protected int capacity; // length of the table private int prime; // prime factor private long scale, shift; // the shift and scaling factors public AbstractHashMap(int cap, int p) { prime = p; capacity = cap; Random rand = new Random(); scale = rand.nextInt(prime - 1) + 1; shift = rand.nextInt(prime); createTable(); } public AbstractHashMap(int cap) { this(cap, 109345121); } // default prime public AbstractHashMap() { this(17); } // default capacity // public methods public int size() { return n; } public V get(K key) { return bucketGet(hashValue(key), key); } public V remove(K key) { return bucketRemove(hashValue(key), key); } public V put(K key, V value) { V answer = bucketPut(hashValue(key), key, value); if (n > capacity / 2) // keep load factor <= 0.5 resize(2 * capacity - 1); // (or find a nearby prime) return answer; } } MAD: \[ h_2(i) = [(ai + b) \mod p] \mod N \] \[ a: \text{scale} \quad b: \text{shift} \quad p: \text{prime} \quad N: \text{size\_of\_hash} \] To represent each bucket for separate chaining, we use an instance of the simpler UnsortedTableMap class. Entire hash table is then represented as a fixed-capacity array $A$ of thevsecondary maps. Each cell, $A[h]$, is initially a null reference; We only create a secondary map when an entry is first hashed to a particular bucket. Delegate operations to a list-based map at each cell of unsorted Map $A[]$: **Algorithm** $\text{get}(k)$: \begin{verbatim} return $A[h(k)].get(k)$ \end{verbatim} **Algorithm** $\text{put}(k,v)$: \begin{verbatim} t = $A[h(k)].put(k,v)$ if $t = \text{null}$ then $n = n + 1$ return $t$ \end{verbatim} **Algorithm** $\text{remove}(k)$: \begin{verbatim} t = $A[h(k)].remove(k)$ if $t \neq \text{null}$ then $n = n - 1$ return $t$ \end{verbatim} Because we choose to leave table cells as null until a secondary map is needed, each of these fundamental operations must begin by checking to see if $A[h]$ is null. In the case of bucketPut, a new entry must be inserted, so we instantiate a new UnsortedTableMap for $A[h]$ before continuing. In our AbstractHashMap framework, the subclass has the responsibility to properly maintain the instance variable $n$ when an entry is newly inserted or deleted. In our implementation, we determine the change in the overall size of the map, by determining if there is any change in the size of the relevant secondary map before and after an operation. public class ChainHashMap<K,V> extends AbstractHashMap<K,V> { // a fixed capacity array of UnsortedTableMap that serve as buckets private UnsortedTableMap<K,V>[] table; // initialized within createTable public ChainHashMap() { super(); } public ChainHashMap(int cap) { super(cap); } public ChainHashMap(int cap, int p) { super(cap, p); } /** Creates an empty table having length equal to current capacity. */ protected void createTable() { table = (UnsortedTableMap<K,V>[] ) new UnsortedTableMap[capacity]; } /** Returns value associated with key k in bucket with hash value h, or else null. */ protected V bucketGet(int h, K k) { UnsortedTableMap<K,V> bucket = table[h]; if (bucket == null) return null; return bucket.get(k); } /** Associates key k with value v in bucket with hash value h; returns old value. */ protected V bucketPut(int h, K k, V v) { UnsortedTableMap<K,V> bucket = table[h]; if (bucket == null) bucket = table[h] = new UnsortedTableMap<>(); int oldSize = bucket.size(); V answer = bucket.put(k,v); n += (bucket.size() - oldSize); // size may have increased return answer; } /** Removes entry having key k from bucket with hash value h (if any). */ protected V bucketRemove(int h, K k) { UnsortedTableMap<K,V> bucket = table[h]; if (bucket == null) return null; int oldSize = bucket.size(); V answer = bucket.remove(k); n -= (oldSize - bucket.size()); // size may have decreased return answer; } /** Returns an iterable collection of all key-value entries of the map. */ public Iterable<Entry<K,V>> entrySet() { ArrayList<Entry<K,V>> buffer = new ArrayList<>(); for (int h=0; h < capacity; h++) if (table[h] != null) for (Entry<K,V> entry : table[h].entrySet()) buffer.add(entry); return buffer; } Assuming load factor of \( n/N \), each bucket has expected \( O(1) \) size, provided that \( n \) is \( O(N) \), - The expected running time of operations `get`, `put`, and `remove` for this map is \( O(1) \). - The `entrySet` method (and thus the related `keySet` and `values`) runs in \( O(n+N) \) time, as it loops through the length of the table (with length \( N \)) and through all buckets (which have cumulative lengths \( n \)). Open addressing: the colliding item is placed in a different cell of the table Linear probing: handles collisions by placing the colliding item in the next (circularly) available table cell Each table cell inspected is referred to as a “probe” Colliding items lump together, causing future collisions to cause a longer sequence of probes Example: - $h(x) = x \mod 13$ - Insert keys 18, 41, 22, 44, 59, 32, 31, 73, in this order • Consider a hash table $A$ that uses linear probing • $\text{get}(k)$ + We start at cell $h(k)$ + We probe consecutive locations until one of the following occurs • An item with key $k$ is found, or • An empty cell is found, or • $N$ cells have been unsuccessfully probed Algorithm $\text{get}(k)$ \[ i \leftarrow h(k)\\p \leftarrow 0\\\text{repeat}\\\quad c \leftarrow A[i]\\\quad \text{if } c = \emptyset\\\quad \quad \text{return null}\\\quad \text{else if } c.\text{getKey}() = k\\\quad \quad \quad \text{return } c.\text{getValue}()\\\quad \text{else}\\\quad \quad i \leftarrow (i + 1) \mod N\\\quad \quad p \leftarrow p + 1\\\quad \text{until } p = N\\\quad \text{return null} \] To handle insertions and deletions, we introduce a special object, called `DEFUNCT`, which replaces deleted elements. **remove**(*k*) - We search for an entry with key *k*. - If such an entry (*k, o*) is found, we replace it with the special item `DEFUNCT` and we return element *o*. - Else, we return `null`. **put**(*k, o*) - We throw an exception if the table is full. - We start at cell *h(k)*. - We probe consecutive cells until one of the following occurs: - A cell *i* is found that is either empty or stores `DEFUNCT`, or - *N* cells have been unsuccessfully probed. - We store (*k, o*) in cell *i*. public class ProbeHashMap<K,V> extends AbstractHashMap<K,V> { private MapEntry<K,V>[] table; // a fixed array of entries (all initially null) private MapEntry<K,V> DEFUNCT = new MapEntry<>(null, null); // sentinel public ProbeHashMap() { super(); } public ProbeHashMap(int cap) { super(cap); } public ProbeHashMap(int cap, int p) { super(cap, p); } /** Creates an empty table having length equal to current capacity. */ protected void createTable() { table = (MapEntry<K,V>[])(new MapEntry[capacity]); // safe cast } /** Returns true if location is either empty or the "defunct" sentinel. */ private boolean isAvailable(int j) { return (table[j] == null || table[j] == DEFUNCT); } } /** Returns index with key k, or -(a+1) such that k could be added at index a. */ private int findSlot(int h, K k) { int avail = -1; int j = h; do { if (isAvailable(j)) { if (avail == -1) avail = j; if (table[j] == null) break; } else if (table[j].getKey().equals(k)) return j; j = (j+1) % capacity; } while (j != h); return -(avail + 1); } PROBE HASH MAP IN JAVA, 2 35 /** Associates key k with value v in bucket with hash value h; returns old value. */ 36 protected V bucketPut(int h, K k, V v) { 37 int j = findSlot(h, k); 38 if (j >= 0) { // this key has an existing entry 39 return table[j].setValue(v); 40 table[−(j+1)] = new MapEntry<k, v>(); // convert to proper index 41 n++;} 42 return null; 43 } 44 /** Removes entry having key k from bucket with hash value h (if any). */ 45 protected V bucketRemove(int h, K k) { 46 int j = findSlot(h, k); 47 if (j < 0) return null; // nothing to remove 48 V answer = table[j].getValue(); 49 table[j] = DEFUNCT; // mark this slot as deactivated 50 n--;} 51 return answer; 52 } ```java /** Returns value associated with key k in bucket with hash value h, or else null. */ protected V bucketGet(int h, K k) { int j = findSlot(h, k); if (j < 0) return null; // no match found return table[j].getValue(); } /** Returns an iterable collection of all key-value entries of the map. */ public <Entry<K,V>> entrySet() { ArrayList<Entry<K,V>> buffer = new ArrayList<>(); for (int h=0; h < capacity; h++) if (!isAvailable(h)) buffer.add(table[h]); return buffer; } ``` <table> <thead> <tr> <th>$L$</th> <th>Number of Probes with Linear Probing</th> <th>Number of Probes with Chaining</th> </tr> </thead> <tbody> <tr> <td>0.0</td> <td>1.00</td> <td>1.00</td> </tr> <tr> <td>0.25</td> <td>1.17</td> <td>1.13</td> </tr> <tr> <td>0.5</td> <td>1.50</td> <td>1.25</td> </tr> <tr> <td>0.75</td> <td>2.50</td> <td>1.38</td> </tr> <tr> <td>0.85</td> <td>3.83</td> <td>1.43</td> </tr> <tr> <td>0.9</td> <td>5.50</td> <td>1.45</td> </tr> <tr> <td>0.95</td> <td>10.50</td> <td>1.48</td> </tr> </tbody> </table> The number of comparisons required for a binary search of a sorted array is $O(\log n)$ - A sorted array of size 128 requires up to 7 probes ($2^7$ is 128) which is more than for a hash table of any size that is 90% full - A binary search tree performs similarly Insertion or removal <table> <thead> <tr> <th></th> <th>Hash Table</th> <th>Unsorted Array</th> <th>Binary Search Tree</th> </tr> </thead> <tbody> <tr> <td>Hash Table</td> <td>$O(1)$ expected; worst case $O(n)$</td> <td>$O(n)$</td> <td>$O(\log n)$; worst case $O(n)$</td> </tr> </tbody> </table> STORAGE REQUIREMENTS FOR HASH TABLES, SORTED ARRAYS, AND TREES - The performance of hashing is superior to that of binary search of an array or a binary search tree, particularly if the load factor is less than 0.75. - However, the lower the load factor, the more empty storage cells. - There are no empty cells in a sorted array. - A binary search tree requires three references per node (item, left subtree, right subtree), so more storage is required for a binary search tree than for a hash table with load factor 0.75. For open addressing, the number of references to items (key-value pairs) is $n$ (the size of the table). For chaining, the average number of nodes in a list is $L$ (the load factor) and $n$ is the number of table elements. - Using the Java API `LinkedList`, there will be three references in each node (item, next, previous). - Using our own single linked list, we can reduce the references to two by eliminating the previous-element reference. - Therefore, storage for $n + 2L$ references is needed. Example: - Assume open addressing, 60,000 items in the hash table, and a load factor of 0.75 - This requires a table of size 80,000 and results in an expected number of comparisons of 2.5 - Calculating the table size $n$ to get similar performance using chaining \[ 2.5 = 1 + \frac{L}{2} \] \[ 5.0 = 2 + L \] \[ 3.0 = \frac{60,000}{n} \] $n = 20,000$
{"Source-Url": "http://www3.cs.stonybrook.edu/~sael/teaching/cse214/slides/L12_Ch10_HashTables.pdf", "len_cl100k_base": 11658, "olmocr-version": "0.1.50", "pdf-total-pages": 74, "total-fallback-pages": 0, "total-input-tokens": 100271, "total-output-tokens": 13774, "length": "2e13", "weborganizer": {"__label__adult": 0.00028133392333984375, "__label__art_design": 0.00025463104248046875, "__label__crime_law": 0.0002799034118652344, "__label__education_jobs": 0.0014438629150390625, "__label__entertainment": 4.947185516357422e-05, "__label__fashion_beauty": 0.0001138448715209961, "__label__finance_business": 0.0001455545425415039, "__label__food_dining": 0.0003490447998046875, "__label__games": 0.0005102157592773438, "__label__hardware": 0.0007696151733398438, "__label__health": 0.0003752708435058594, "__label__history": 0.0002238750457763672, "__label__home_hobbies": 9.775161743164062e-05, "__label__industrial": 0.0003330707550048828, "__label__literature": 0.00020992755889892575, "__label__politics": 0.0001837015151977539, "__label__religion": 0.00039267539978027344, "__label__science_tech": 0.01435089111328125, "__label__social_life": 9.483098983764648e-05, "__label__software": 0.00518798828125, "__label__software_dev": 0.9736328125, "__label__sports_fitness": 0.0002987384796142578, "__label__transportation": 0.0004372596740722656, "__label__travel": 0.0002065896987915039}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 36630, 0.04303]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 36630, 0.32164]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 36630, 0.73476]], "google_gemma-3-12b-it_contains_pii": [[0, 283, false], [283, 639, null], [639, 790, null], [790, 1010, null], [1010, 1576, null], [1576, 1977, null], [1977, 2225, null], [2225, 2688, null], [2688, 3108, null], [3108, 3954, null], [3954, 5065, null], [5065, 6587, null], [6587, 6984, null], [6984, 7797, null], [7797, 8247, null], [8247, 8845, null], [8845, 9051, null], [9051, 9524, null], [9524, 9897, null], [9897, 10401, null], [10401, 10782, null], [10782, 11137, null], [11137, 11509, null], [11509, 11837, null], [11837, 12241, null], [12241, 12739, null], [12739, 13109, null], [13109, 13423, null], [13423, 13827, null], [13827, 14186, null], [14186, 14505, null], [14505, 14821, null], [14821, 15131, null], [15131, 15562, null], [15562, 16286, null], [16286, 16797, null], [16797, 17311, null], [17311, 17862, null], [17862, 18281, null], [18281, 18974, null], [18974, 19224, null], [19224, 19741, null], [19741, 20182, null], [20182, 20766, null], [20766, 21179, null], [21179, 21636, null], [21636, 21796, null], [21796, 22451, null], [22451, 22561, null], [22561, 22592, null], [22592, 23183, null], [23183, 23480, null], [23480, 24280, null], [24280, 24592, null], [24592, 25704, null], [25704, 25847, null], [25847, 26182, null], [26182, 26635, null], [26635, 27282, null], [27282, 28525, null], [28525, 29221, null], [29221, 29661, null], [29661, 30094, null], [30094, 30800, null], [30800, 31416, null], [31416, 32159, null], [32159, 32580, null], [32580, 33396, null], [33396, 33962, null], [33962, 34692, null], [34692, 35247, null], [35247, 35774, null], [35774, 36277, null], [36277, 36630, null]], "google_gemma-3-12b-it_is_public_document": [[0, 283, true], [283, 639, null], [639, 790, null], [790, 1010, null], [1010, 1576, null], [1576, 1977, null], [1977, 2225, null], [2225, 2688, null], [2688, 3108, null], [3108, 3954, null], [3954, 5065, null], [5065, 6587, null], [6587, 6984, null], [6984, 7797, null], [7797, 8247, null], [8247, 8845, null], [8845, 9051, null], [9051, 9524, null], [9524, 9897, null], [9897, 10401, null], [10401, 10782, null], [10782, 11137, null], [11137, 11509, null], [11509, 11837, null], [11837, 12241, null], [12241, 12739, null], [12739, 13109, null], [13109, 13423, null], [13423, 13827, null], [13827, 14186, null], [14186, 14505, null], [14505, 14821, null], [14821, 15131, null], [15131, 15562, null], [15562, 16286, null], [16286, 16797, null], [16797, 17311, null], [17311, 17862, null], [17862, 18281, null], [18281, 18974, null], [18974, 19224, null], [19224, 19741, null], [19741, 20182, null], [20182, 20766, null], [20766, 21179, null], [21179, 21636, null], [21636, 21796, null], [21796, 22451, null], [22451, 22561, null], [22561, 22592, null], [22592, 23183, null], [23183, 23480, null], [23480, 24280, null], [24280, 24592, null], [24592, 25704, null], [25704, 25847, null], [25847, 26182, null], [26182, 26635, null], [26635, 27282, null], [27282, 28525, null], [28525, 29221, null], [29221, 29661, null], [29661, 30094, null], [30094, 30800, null], [30800, 31416, null], [31416, 32159, null], [32159, 32580, null], [32580, 33396, null], [33396, 33962, null], [33962, 34692, null], [34692, 35247, null], [35247, 35774, null], [35774, 36277, null], [36277, 36630, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 36630, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, true], [5000, 36630, null]], "pdf_page_numbers": [[0, 283, 1], [283, 639, 2], [639, 790, 3], [790, 1010, 4], [1010, 1576, 5], [1576, 1977, 6], [1977, 2225, 7], [2225, 2688, 8], [2688, 3108, 9], [3108, 3954, 10], [3954, 5065, 11], [5065, 6587, 12], [6587, 6984, 13], [6984, 7797, 14], [7797, 8247, 15], [8247, 8845, 16], [8845, 9051, 17], [9051, 9524, 18], [9524, 9897, 19], [9897, 10401, 20], [10401, 10782, 21], [10782, 11137, 22], [11137, 11509, 23], [11509, 11837, 24], [11837, 12241, 25], [12241, 12739, 26], [12739, 13109, 27], [13109, 13423, 28], [13423, 13827, 29], [13827, 14186, 30], [14186, 14505, 31], [14505, 14821, 32], [14821, 15131, 33], [15131, 15562, 34], [15562, 16286, 35], [16286, 16797, 36], [16797, 17311, 37], [17311, 17862, 38], [17862, 18281, 39], [18281, 18974, 40], [18974, 19224, 41], [19224, 19741, 42], [19741, 20182, 43], [20182, 20766, 44], [20766, 21179, 45], [21179, 21636, 46], [21636, 21796, 47], [21796, 22451, 48], [22451, 22561, 49], [22561, 22592, 50], [22592, 23183, 51], [23183, 23480, 52], [23480, 24280, 53], [24280, 24592, 54], [24592, 25704, 55], [25704, 25847, 56], [25847, 26182, 57], [26182, 26635, 58], [26635, 27282, 59], [27282, 28525, 60], [28525, 29221, 61], [29221, 29661, 62], [29661, 30094, 63], [30094, 30800, 64], [30800, 31416, 65], [31416, 32159, 66], [32159, 32580, 67], [32580, 33396, 68], [33396, 33962, 69], [33962, 34692, 70], [34692, 35247, 71], [35247, 35774, 72], [35774, 36277, 73], [36277, 36630, 74]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 36630, 0.20827]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
5711b4ad32fbd8e7a207e9615d2dffdca3221f93
Accessing Private Data About the State of a Data Processing Machine From Storage That Is Publicly Accessible Applicant: Intel Corporation, Santa Clara, CA (US) Inventors: Scott H. Robinson, Portland, OR (US); Gustavo P. Espinosa, Portland, OR (US); Steven M. Bennett, Hillsboro, OR (US) Assignee: Intel Corporation, Santa Clara, CA (US) Notice: Subject to any disclaimer, the term of this patent is extended or adjusted under 35 U.S.C. 154(b) by 0 days. This patent is subject to a terminal disclaimer. Filed: Mar. 15, 2013 Prior Publication Data Related U.S. Application Data Continuation of application No. 13/413,176, filed on Mar. 6, 2012, which is a continuation of application No. 10/724,321, filed on Nov. 26, 2003, now Pat. No. 8,156,343. Int. Cl. G06F 11/30 (2006.01) G06F 12/14 (2006.01) Abstract According to an embodiment of the invention, a method for operating a data processing machine is described in which data about a state of the machine is written to a location in storage. The location is one that is accessible to software that may be written for the machine. The state data as written is encoded. This state data may be recovered from the storage according to a decoding process. Other embodiments are also described and claimed. 31 Claims, 6 Drawing Sheets References Cited U.S. PATENT DOCUMENTS 4,037,214 A 7/1977 Birney et al. 4,162,536 A 7/1979 Morley 4,276,594 A 6/1981 Morley 4,278,837 A 7/1981 Best 4,366,537 A 12/1982 Heller et al. 4,403,283 A 9/1983 Myant et al. 4,419,724 A 12/1983 Brandin et al. 4,430,709 A 2/1984 Slechpen 4,521,852 A 6/1985 Guttag 4,558,176 A 12/1985 Arnold et al. 4,571,672 2/1986 Hatada et al. 4,630,269 A 12/1986 Gershenson et al. 4,759,064 A 7/1988 Chaun 4,795,893 A 1/1989 Ugon 4,910,774 A 3/1990 Barakat 4,975,836 A 12/1990 Hirose et al. 5,007,082 A 4/1991 Cummins 5,073,842 A 12/1991 Lai 5,079,737 A 1/1992 Hackbarth 5,187,802 A 2/1993 Inoue et al. 5,230,069 A 7/1993 Brelsford et al. 5,237,616 A 8/1993 Abraham et al. 5,255,779 A 10/1993 Meo 5,361,375 A 11/1994 Ogi 5,386,552 A 1/1995 Garney 5,421,006 A 5/1995 Jablon et al. 5,434,999 A 7/1995 Guire et al. 5,437,033 A 7/1995 Inoue et al. 5,442,645 A 8/1995 Ugon et al. 5,455,909 A 10/1995 Bleemgen et al. 5,459,867 A 10/1995 Adams et al. 5,459,869 A 10/1995 Spilo 5,469,557 A 11/1995 Salt et al. 5,473,692 A 12/1995 Davis 5,479,500 A 12/1995 Ugon 5,506,975 A 4/1996 Ondoda 5,511,217 A 4/1996 Nakajima et al. 5,522,075 A 5/1996 Robinson et al. 5,528,231 A 6/1996 Patarin 5,533,126 A 7/1996 Hazard 5,555,385 A 9/1996 Osisek 5,555,414 9/1996 Hough et al. 5,600,013 A 9/1996 Scalzi et al. 5,644,040 A 10/1996 Kubala 5,566,123 A 10/1996 Ugon 5,568,552 A 10/1996 Davis 5,574,936 A 11/1996 Ryba et al. 5,582,717 A 12/1996 Di Santo 5,604,805 A 2/1997 Brands 5,606,617 A 2/1997 Brands 5,615,263 A 3/1997 Takaahashi 5,628,022 A 5/1997 Ueno et al. References Cited OTHER PUBLICATIONS Office Action Received for German Patent Application No. 11 2004 002 259 2, mailed on Nov. 30, 2010, 1 page of German Office Action. References Cited OTHER PUBLICATIONS * cited by examiner FIG. 1 START DETERMINE STORAGE ADDRESS FROM WHICH THE LOAD IS REQUESTED LOADING FROM ENCODED PRIVATE-STATE REGION? YES NO LOAD DATA VALUE FROM UNMODIFIED STORAGE ADDRESS, WITHOUT DATA DECODE OBfuscate ADDRESS VALUE LOAD ENCODED DATA VALUE FROM OBfUSCATED ADDRESS DECODE DATA VALUE END FIG. 2 FIG. 3 FIG. 4 FIG. 5 ADDRESS GENERATION UNIT (AGU) → LINEAR TO PHYSICAL ADDRESS TRANSLATION (TLB) → ADDRESS ENCODING UNIT Hi LinAddr, Lo LinAddr ADDRESS ENCODING UNIT → SPECIAL UOP SIGNALS ENCODING/DECODING → CACHE → MEMOR Y DECODED PRIVATE STATE → DATA DECODING/ENCODING UNIT → ENCODED CONTENT DECODED CONTENT → ENCODED CONTENT ACCESSING PRIVATE DATA ABOUT THE STATE OF A DATA PROCESSING MACHINE FROM STORAGE THAT IS PUBLICLY ACCESSIBLE CROSS REFERENCE TO RELATED APPLICATIONS This application is a continuation of U.S. patent application Ser. No. 13/413,176, filed Mar. 6, 2012, entitled "ACCESSING PRIVATE DATA ABOUT THE STATE OF A DATA PROCESSING MACHINE FROM STORAGE THAT IS PUBLICLY ACCESSIBLE" which is a continuation of U.S. patent application Ser. No. 10/724,321, filed Nov. 26, 2003, entitled "ACCESSING PRIVATE DATA ABOUT THE STATE OF A DATA PROCESSING MACHINE FROM STORAGE THAT IS PUBLICLY ACCESSIBLE," which issued on Apr. 10, 2012, as U.S. Pat. No. 8,156,343, the content of which is hereby incorporated by reference. BACKGROUND Some of the embodiments of the invention relate to how processors read and write state data from and to a storage of a computer system. Other embodiments are also described. Due to various design considerations, some processors may write private-state data to regions in publicly-accessible storage. The format, semantics and location of this private-state may vary between design implementations. In literature describing the processor, such storage regions are often marked as "RESERVED" indicating that their contents should not be read or modified because they contain private-state. Unfortunately, because this data is written to publicly-accessible storage, software applications, operating systems or external agents (e.g., input-output devices) may access the storage region and use the private-state stored therein improperly. Access and use of this private-state by such non-approved entities may lead to erroneous and/or undesirable effects for processor and platform manufacturers and end users. BRIEF DESCRIPTION OF THE DRAWINGS The embodiments of the invention are illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to "an" embodiment of the invention in this disclosure are not necessarily to the same embodiment, and they mean at least one. FIG. 1 shows a block diagram of a computer system which may obfuscate/encode the public storage of private-state data, according to an embodiment of the invention. FIG. 2 illustrates a flowchart depicting a method for reading an encoded private-state data value from a private-state storage region according to an embodiment of the invention. FIG. 3 illustrates a flowchart depicting a method for storing an encoded private-state data value to a private-state storage region according to an embodiment of the invention. FIG. 4 shows a block diagram of a computer system in which the processor is designed to obfuscate/encode its private-state data as written to public storage, according to an embodiment of the invention. FIG. 5 illustrates example functional components that may be used to implement the obfuscation/encoding of the private-state data, according to an embodiment of the invention. FIG. 6 depicts a more detailed logic diagram of part of an example address obfuscation/encoding unit, according to an embodiment of the invention. DETAILED DESCRIPTION Processor state, as written to a storage, such as memory, during operation of a processor may include two types of information or data. One type is referred to herein as architectural data, while the other is called implementation-specific data (also herein referred to as "private data" or "private-state data"). Architectural data is state information which is common to all processors of a given class as designated by the manufacturer, i.e. having substantially the same high-level interface between hardware and software. This interface is called the instruction set architecture (ISA). The use of the same ISA on a variety of processor implementations facilitates the ability of software written expressly for one implementation to run on later implementations unmodified. An ISA defines the state available to software running on the processor, its format and semantics, and available operation interfaces (e.g., instructions, events). Part of this ISA specification describes how the processor may use one or more regions in the machine’s storage (e.g., memory) to facilitate its operations. These storage regions may be accessible to software and other devices in the data processing machine in which the processor resides (e.g., input-output devices, etc.). The processor may use these storage regions to store both architectural and private-state data. For example, consider processors that have the ISA of the Intel® Pentium® processor as manufactured by Intel Corporation, herein referred to as the IA-32 ISA. The processor may utilize regions in storage during certain operations. For example, when an IA-32 ISA processor enters system management mode, it stores various values to a region of storage called the system management (SMM) state save area. A variety of architectural data is stored (e.g., various machine registers such as ESI, EBP, etc.) in locations and formats which are specified in documentation for the ISA. Additionally, a variety of private data is stored to the system management state save area. In documentation for the ISA, these private-state areas are labeled "Reserved"; the contents, format and semantics of this private data are not specified in the ISA documentation. These "reserved" regions of storage are referred to herein as "private-state regions". Different processors may be designed to have different private-state data, also herein called "private data". This may be done, for example, to improve performance or reduce manufacturing cost. For example, new internal registers may be added, some of the old ones may be used differently, and the format or location of their content that is to be written to storage may be changed for greater efficiency. As a result, the private data for these more recent processors will be different, in content, format, semantics or location, from those of the older versions. Difficulty can arise when private-state data is stored in publicly-accessible areas such as main memory or other storage. Here it is possible for software such as, for example, the basic input-output system (BIOS), operating systems, virtual machine manager or hypervisor, device drivers, or applications and hardware such as I/O devices or other external agents to access (i.e., read and/or write) this private-state data. Use of this private-state data by such entities may lead to erroneous and/or undesirable effects for processor and platform manufacturers and end users. For example, if an application depends on particular private-state data available in one processor implementation, it might function incorrectly when the application is run on a different processor implementation which implements the private-state differently (or does not implement it at all). Software that depends on private data may also fail due to internal processor-to-memory coherence behaviors/policies that change from implementation to implementation. Software reliance on private-state data may complicate and/or hobble implementation alternatives available to the processor manufacturer with regard to private-state usage. Therefore, processor manufacturers often document such private data (and its storage in memory regions) as RESERVED, indicating that it is subject to change in future implementations. The above-mentioned ability to run old software on a newer machine assumes that the old software did improperly access a machine’s private data (which can change with newer versions of the machine). However, it has been found that software developers are writing application and operating system programs that do the opposite, namely accessing and relying upon private data, as it is stored in, for example, main memory. This creates a problem because older software may not run properly on a newer machine, even though the newer machine has the same architectural data as the older machine and can still “understand” older mechanisms for accessing stored state data (e.g., load and store instructions as defined in the ISA). That is because some or all of the private data may have changed in the newer machine, causing software to function incorrectly. In addition, the manufacturer may be reluctant to add improvements to future versions of its processor because doing so would risk incompatibility problems with older software. According to an embodiment of the invention, a data processing machine and a method of operation are described which may discourage a software developer from writing software that relies upon private-state data (e.g., a certain value, its location, its semantics or its format) that is stored in a publicly-accessible region of storage. This may allow future versions of the machine to exhibit different behavior with respect to private data that may be needed as the machine’s internal hardware design evolves, yet still exhibit the same ISA needed to run older software. Some embodiments of the invention may encourage use of architected interfaces to data stored as private-state data. For example, instructions may be provided to access data that may be stored as private-state data by specifying the identity of the data to be accessed, rather than the location of the data within the private-state data region. This allows implementation freedom in how the data is stored (e.g., within the private-state region) while providing an architectural mechanism to access the data. For example, suppose that a data element stored in the system management state save area of the IA-32 ISA (as described above) is the value of the CS segment base address. The storage location of this data element within the state save area is not detailed in the ISA specification. Instead, an instruction may be provided by the ISA which indirectly addresses the data. The data element may be encoded and stored in the state save area in any manner that a processor implementation desires (or it may not be stored in the private-state area in memory at all, and instead retained in, for example, a special register or location within the processor). The invention permits private-state data to be encoded in a manner that thwarts speedy software decode of the data as compared with the prescribed, architected interfaces. Embodiments of the invention may vary the encoding complexity depending on the target processor and platform. Once the target processor is known, one skilled in the art can choose an embodiment of the invention that ensures that software-based methods to decode the chosen encoding take longer than using the prescribed interfaces (e.g., instructions). For example, non-prescribed software methods may be able to decode certain private-state data in 400 clocks (e.g., using certain instructions and algorithms) while architecturally prescribed instructions and methods would work in a fraction of that time. An embodiment of the invention lies in the use of certain metrics to measure the cost of private state decode, including, for example, the metrics of time (speed) and power consumption. Herein the term “encoding” includes concepts such as encrypting, ciphering, formatting, or the assignment or interpretation of specific bit patterns. Encodings by embodiments of this invention are said herein to “obfuscate” the private data. Referring now to FIG. 1, a block diagram of a computer system is shown. Software 120 is running on platform hardware 102. The platform hardware 102 can be a personal computer (PC), mainframe, handheld device, portable computer, set-top box, or any other computing system. The platform hardware 102 includes a processor 110, storage 130 and may include one or more input-output (I/O) devices 140. Processor 110 can be any type of processor capable of executing software, such as a microprocessor, digital signal processor, microcontroller, or the like. The processor 110 may include microcode, programmable logic or hard-coded logic for performing the execution of certain method embodiments of the present invention. Though FIG. 1 shows only one such processor 110, there may be one or more processors in the system. The one or more I/O devices 140 may be, for example network interface cards, communication ports, video controllers, disk controllers, system buses and controllers (e.g., PCI, ISA, AGP) or devices integrated into the platform chipset logic or processor (e.g., real-time clocks, programmable timers, performance counters). Some or all of the I/O devices 140 may have direct memory access (DMA) capability, allowing them to read and/or write the storage 130 independent of, or under the control of, the processor 110 or software 120. Storage 130 can be a hard disk, a floppy disk, random-access memory (RAM), cache memory, read-only memory (ROM), flash memory, static random access memory (SRAM), any combination of the above devices, or any other type of storage medium accessible by processor 110. Storage 130 may store instructions and/or data for performing the execution of method embodiments of the present invention. The storage 130 may be a publicly accessible area of a register file of the processor, or it may be an area outside of the processor such as main memory. Data about a state of the machine 112, such as the contents of certain internal registers 114, is written to a private-state region 132 in storage 130, where the state data as written is “encoded” or “obfuscated.” Thus, although the location where the state data is written is public in that it may be accessed by I/O devices 140 or software 120 (e.g., operating system 122, application software 124) running on the platform hardware 102, the encoding makes it difficult for the state data to be reverse engineered (i.e., decoded) in a timely manner. When the state data is to be recovered from the storage 130, a specified decode process, e.g., a processor-initiated decode process defined by the manufacturer of the processor, is applied. Control over the decode process may be linked to specific processor functions, such as specific instructions and control signals, as discussed below. Non-prescribed methods (alternate software instructions and algorithms) for accessing the state data would not activate these controls and accordingly may be more costly. The recovered state data may then be placed into the local state 112, which may or may not be accessible to software 120 or I/O devices 140. The local state 112 may be, for example, a region in an internal cache or registers which are not available for ungoverned access through the instruction set architecture (ISA). In some cases local state is not accessible by software or other external agents (e.g., I/O devices). In some cases, some or all of the local state is accessible to software or other external agents. In other cases local state may be indirectly accessible through specific interfaces (e.g., instructions). Because it is internal to the processor and not in "public" storage, the processor can strictly dictate access to the local state. Although the state data as written to the publicly accessible area of the storage 130 is in an encoded form, a manufacturer-defined instruction that may be part of the ISA for the processor may be used by software to recover the data from the storage 130. The encoding should be strong enough so as to discourage software developers from circumventing such an instruction, when seeking to access the state data. An example of the internal logic needed for reading or recovering the state data from storage, using a micro-operation or hardware control signal, will be described below with reference to FIG. 5. In one embodiment, the encoding process used need only be strong enough to cause an author of software 120 to apply, in writing the software, a technique that may be prescribed by a manufacturer of the processor for accessing the state data from memory, rather than circumventing the technique. In other cases, the encoding may be stronger if the manufacturer intends to make it even more difficult for the software developer to access and rely upon the state data (including a certain value, its location, its semantics or its format) that is in memory. Control signals used to control the encoding and decoding of the private-state may be coupled with or accessed by, for example, hardware state machines, processor instructions (also known as macro instructions), operational modes (e.g., PAL modes) or mode bits or operational groups of instructions, microcode or macrocode operations (uops), and hardware control signals or events. Various types of encoding processes may be used. The data written to the private-state region of memory may be changed prior to storage. This type of encoding process is called data encoding. Alternatively, the addresses used to access private state in private-state regions may be changed. This type encoding process is called address obfuscation and the transformation from the original address to the obfuscated address is referred to as address mapping. Data encoding and address obfuscation are described below. Encoding processes may be either static or dynamic. Static encodings do not change over time as a machine is running (and performing the encoding processes). (Static encodings may change or be reconfigured during the processor initialization/reset or boot phase, but not afterwards during running operation.) A process that generates static encodings is called static obfuscation. Alternatively, the encoding process may produce encoding results which change over time while the processor is running. These processes are referred to herein as dynamic obfuscation. For example, a storage format of the contents of a given element of private-state, as written in the storage 130, may change while the machine is executing. This is referred to herein as dynamic obfuscation. For example, the format may change between big-endian and little-endian according to a random or pseudo-random sequence (which the processor generates and tracks), whenever the state data needs to be written to storage; this change may only affect the memory region(s) to which the private data is read and written. Again, the intent here is to make it difficult to quickly reverse engineer and decode the state data from a region of storage that is publicly accessible in storage 130. In an embodiment, when private-state data is to be written to storage, it is written to a region of storage (e.g., main memory) with contiguous addresses. In other embodiments the private data region is non-contiguous, consisting of more than one distinct regions of storage. There is no requirement that the encoding fully populate the private-state region; i.e., some bits or bytes may remain unused. Some freedom in designing the encoding and/or obfuscation functions may be obtained by changing the private-state region size, by, for example, making it bigger than strictly required to store the private data. (For example, this would permit, as described later, larger MISR (multi-input shift register) polynomials to be used.) In an embodiment of the invention, a multi-byte (e.g., 32-bit “long” integer) value of state data is split into several parts which are then stored in non-contiguous locations, rather than all in sequence. Thus, a 4-byte value may be split into four 1-byte values that are stored in non-contiguous locations within a private-state region. The locations at which the four 1-byte values are stored may change dynamically and in a random way while the machine is operating. Of course, the embodiment should be able to locate and decode such data. Note that the ISA may impose certain requirements regarding atomicity of the accesses in cases where single data values are stored or loaded using multiple memory accesses. In an embodiment of the invention, the address bits used to access storage are encoded. This encoding of address bits may change address bit ordering (or groups of address bits). An example of this might be switching from little-endian to big-endian formats within a given memory region. Other address mixing mappings are possible, some involving more elaborate transformations. Another type of address encoding maps a set of K unique addresses to another set of K unique addresses; that is, mathematically the mapping is bijective (both injective (one-to-one) and surjective (onto)). Here, the upper address bits may remain unchanged, while the lower-order address bits are modified. In such cases it is possible to construct mappings that map a given memory range back onto itself. That is, the base address offset of the memory range is the same and the memory region size is the same. This is an attractive solution because only the data within the memory range is “obfuscated”. That is, only the address bits within the range are mixed. FIG. 4 and FIG. 6 provide examples of such mapping and associated address-mixing mechanism. Address obfuscation mechanisms may be easier to use when the private-state regions have sizes, or base addresses that are powers of the underlying N-ary logic. Most current processors use binary logic, hence private-state regions with sizes or base addresses that are powers of 2 are preferable. (Herein, binary logic and arithmetic are discussed, but N-ary logic and arithmetic could be used, where appropriate, and are assumed in the general case.) Filters and other mechanisms may be used to manage private-state regions with sizes or base addresses that are not powers of the N-ary logic. Such address bit manipulations can coexist with various memory organizations and virtual memory techniques (e.g., paging, segmentation, etc). Address obfuscation mechanisms may change the layout of data within the storage, and serve to mix up the data, but sometimes only at granularities of the storage. In most current processors, main memory is byte addressable, hence the location of individual bytes of a data element may be rearranged. within the private-state region, but the data bits within individual bytes are not changed by address obfuscation (though they may be altered by data encoding mechanisms). In these address-mapping embodiments, the original address mappings may be extracted through some decode process. This extraction is the application of the inverse function of the address mapping function. The choice of mapping function may be made in light of this requirement; not all address mapping functions are reversible. An embodiment of the invention encodes the data bits written to storage. These data encodings may reshape data stored within the private-state region without necessarily being constrained by addressability constraints such as the size of addressable storage. Segments of data may be swapped with other segments of data. For example, two nibbles (i.e., 4-bit segments within a byte) can be swapped within each byte. Data encodings may be bit-wise exclusive-OR'ed with a constant XOR mask. Data may also be bit-wise exclusive-OR'ed with the output of a multi-input feedback shift register (MISR). Data encodings may be made using a cryptographic function. In these embodiments, the original data can be extracted through some decode process. That decode process should ensure that it is faster than decode methods available to software running on the platform (e.g., use of ISA-defined load and store operations, mathematical operations, etc.). The tables 470 and 480 of FIG. 4, for example, illustrates the use of a Vigenere-like cipher applied to data (bytes) in a given 16-byte range of memory addresses. Some of the embodiments listed above may be implemented with static mappings. That is, they do not change during the time the processor or platform is running. Suitable mappings may be set at design time, during manufacture, post manufacture, or early in system operation (e.g., during system boot, at system power on, at processor reset). Different processors may or may not be configured with the same static mappings. If mappings are not bound until the system is operational (e.g., at system boot), it is possible for a new mapping to be chosen at each processor boot. In an embodiment, different control sets (e.g., operating modes, groups of instructions) can each use a different mapping configuration. Within a control set, the mapping remains constant. However, between instruction groups or modes, the mappings may (or may not) be distinct. Other embodiments may be implemented with dynamic mappings that change while the processor is operating. In an embodiment, mapping configurations can only change if there are no outstanding encoded data currently stored in any private-state regions in storage. This embodiment may use a counter that is incremented when encoded data is written to a private-state region of the storage, making it active. The counter is decremented when the private-state region is no longer considered active. When the counter is zero, the mapping configuration may be changed. In an embodiment, the mapping configuration is stored for each private-state region in a mapping descriptor. The mapping descriptor may be stored in a known, un-encoded location within the private-state region itself or maintained separately by a tracking structure such as a queue or look-up table, which may reside inside or outside the processor. In an embodiment, different mappings for each private-state region are possible. FIG. 2 illustrates process 200 for reading an encoded private-state data value from a private-state storage region according to an embodiment of the invention. The process may be performed by processing logic that may comprise hardware (e.g., circuitry, dedicated logic, programmable logic, microcode, etc.), software (such as run on a general purpose computer system or a dedicated machine), or a combination of both. In one embodiment, processing logic is implemented in processor 110 of FIG. 1. Referring to FIG. 2, process 200 begins with processing logic determining an address for the data element (processing block 202). Next, processing logic determines if the data element is stored in encoded form in a private-state region of storage (processing block 204). An embodiment of the invention uses a microcode-generated or hardware-generated control signal which indicates to the processing logic that the data element requested requires decoding. Absence of this signal causes the NO path to block 250 to be taken. If the data element is not to be decoded, then processing logic proceeds to processing block 250, where it loads the data element from storage at the address determined in processing block 202. The process may then terminate. The data loaded is not decoded; that is, no address or data decoding is performed. Note that the data read on this path may be ordinary (i.e., is not private-state data) or it may be private-state data in its encoded form (but accessed in a non-prescribed manner). If, however, the data element is to be decoded, then processing logic next determines the address at which it is stored (the address may be obfuscated based on the address determined in processing block 202 (processing block 210)). Processing logic next loads the encoded data element from storage at the address determined in processing block 210 (processing block 220). Processing logic next decodes the data element loaded from the private-state region of storage in processing step 220 (processing block 230). The decoded value is a result of process 200. The process may then terminate. Often this decoded state is placed in a private state cache or the private, local state of the processor. FIG. 3 illustrates process 300 for storing a private-state data value to a private-state region of storage according to an embodiment of the invention. The process may be performed by processing logic that may comprise hardware (e.g., circuitry, dedicated logic, programmable logic, microcode, etc.), software (such as run on a general purpose computer system or a dedicated machine), or a combination of both. In an embodiment, processing logic is implemented in processor 110 of FIG. 1. Referring to FIG. 3, process 300 begins with processing logic determining a data value and a storage address of a data element (processing block 302). Next, processing logic determines if the data element to be stored is a private-state element to be stored in encoded form to a private-state region of storage (processing block 304). An embodiment of the invention uses a microcode-generated or hardware-generated control signal to signal the processing logic that the data element being written requires encoding. Absence of this signal causes the NO path to block 350 to be taken. If the data element is not to be stored in encoded form in a private-state region, then processing logic proceeds to processing block 350, where it stores the data element in unencoded (unmodified) form to storage at the address determined in processing block 302. The process may then terminate. The data written is not encoded. If, however, the data element is to be stored in encoded form in a private-state region, then processing logic next encodes the data element (processing block 310) and determines an obfuscated address at which to store the data element (processing block 320). Processing logic then stores the now encoded data element to storage at the address determined in processing block 320 (processing block 330). The process may then terminate. Note that the processing performed in processing block 310 and processing block 320 may be performed in the reverse order, i.e. obfuscation of the address value prior to encoding of the data. Some embodiments will perform one and not both of these processing blocks. Some embodiments may perform the processing blocks in parallel. Turning now to FIG. 4, a computer system 402 is depicted in block diagram form. This system 402 has a processor 404 that is designed to support the methodology described above for obfuscating the private-state data in storage. The processor 404 has a standard cache 410 and a private cache 416, where the latter is not accessible to software executing on the system 402 and is used to store the private-state data in an un-encoded (non-obfuscated) form. In this embodiment, a system chipset 406 is also provided to allow the processor 404 to communicate with the memory 408. The chipset 406 may include a memory controller (not shown) as well as other logic needed to interface with peripheral devices of a computer (also not shown). In some embodiments, the functionality of the chipset 406, or a functional subset, may be implemented in the processor 404. In FIG. 4, the memory 408 is shown as storing, in a publicly accessible region 418, the encoded private-state data of the processor 404. This is an example where a cipher has been applied to the values of the internal processor state of the processor 404, so that the actual values cannot be easily recovered or reverse engineered by simply monitoring and reading the memory 408. As described above, the obfuscation of data stored in the encoded private-state region 418 may be achieved in a variety of ways. FIG. 4 shows an example of one such mechanism whereby both the data values are encoded and the data layout is encoded/obfuscated. First data values in table 470 are encoded using a Vigenere cipher yielding the data values shown in table 480 (described below). Then a special mapping from logical address values of the private-state data to physical address values is applied where the mapping results illustrated in table 490. The physical addresses dictate where the private-state data is actually stored in memory. The physical addresses are thus said to result from an encoding of the logical addresses. The table 470 in FIG. 4 entitled “deciphered addr/data” has a list of example logical addresses and their associated private-state data values which are stored in un-encoded form in the cache 416. Here all zero data values were chosen to demonstrate the resulting encoding. Note that an ‘X’ represents the unencoded upper bits of the virtual and physical address of the state data. The table 490 entitled “Private State Memory Address Map” shows an example of the mapping between unencoded and encoded addresses. Here, only the low-order 4 bits are encoded. FIG. 6 illustrates an embodiment of a programmable (parameterized) address mapping function that may be used in the system of FIG. 4. In FIG. 6, one would load the polynomial control register 604 with P.sub.0-1, P.sub.2-0, P.sub.2-3 to implement primitive polynomial x.sup.4+x.sup.1+x.sup.0 and load the Optional mask register 610 with all zeroes. This logic is an adaptation of the equations governing generic w-bit wide MISR’s and can be used to construct various address encoding combinational logic. The parameterized MISR state equations are: \[ S_{i}(t+1) = S_{i}(t) + P_{i}(S_{i-1}(t)), \quad i \in \{w-1\} \] \[ S_{w}(t+1) = P_{w}(S_{w-1}(t)) \] Here the operator “+” represents modulo 2 addition (XOR) and “.” represents modulo 2 multiplication (AND). Parameter “\( t \)” represents time (clock ticks), \( S_i \) the state of the \( i \)’th flip-flop, \( I_i \) the \( i \)’th input vector bit, and \( P_i \) the \( i \)’th polynomial coefficient. The \( P_w \) coefficient is implicitly 1. To achieve the address mixing embodiment of FIG. 4, replace all \( S_i(t) \) with the corresponding address \( A_i \) values and \( S_{i+1}(t+1) \) with output \( O_i \). Other embodiments are possible. Primitive polynomials of order \( w \) are useful in that they can generate a “maximal sequence”; that is, they can generate all \( w \)-bit wide binary combinations or patterns. Primitive polynomials of up to degree 300 (300 bits wide) and even higher orders may be used. To illustrate the above function, using FIG. 4, to access data at logical address offset 0001 (as shown in entry 471), the physical memory at location 0010 is accessed (as entry 491 shows). The un-encoded content value (see entry 471) associated with this address in this case happens to be all zeros. However, when stored in encoded form as shown in entry 481, a non-zero bit string (i.e., 11110101) appears in the public region 418 of the memory 408. (This encoding cipher is described in more detail later.) Although limited bit widths are shown for convenience, the technique may be applied to wider or parallel, bit-sliced data. Storage and recovery of the encoded private-state data in memory 408, as shown in FIG. 4, may be implemented using the logic blocks shown in FIG. 5. For this example, a special micro-operation (e.g., control signal) has been defined for the processor to use when storing or recovering private-state data from storage. An address generation unit (AGU) 504 receives a special micro-operation and, in this embodiment, computes a logical address having a high component and a low component. In an embodiment, the logical address is a virtual address. In another embodiment, as shown in FIG. 5, the logical address is a linear address as found in Intel® Pentium® processors. In yet another embodiment, the logical address is a physical address and no translation of the high address bits need be done. In FIG. 5, the high component of the address is fed to a linear-to-physical address translation block (also referred to as a translation look-aside buffer or TLB) 508 which translates this high component of the linear address (that may be a virtual page number) into part of a physical address 509. An address obfuscation/encoding unit 514 is to receive in this embodiment the low portion of the linear address value that is associated with the given private-state data of the processor. In response, the address obfuscation unit 514 translates this low component of the linear address to provide another portion of the physical address 509. The value of this portion of the physical address is a mixed or encoded version of the linear address, as described above with reference to FIG. 1 and FIG. 4. In an embodiment, the special micro-operation or uop signal (control signal) determines if the address encoding unit 514 is to encode the low-order address bits. If the control signal is not asserted, the low-order address bits can pass through un-encoded, or bypassing the unit 514. Even when the encoding control signal (or signals) are asserted, some address bits may pass through un-encoded. This might occur, for example, if only a subset of the address bits need encoding when the private-state memory region is smaller than the address space size addressable by the low-order bits. Other embodiments exist where address encoding occurs after linear-to-physical address translation and therefore can handle encodings of address spaces that are larger than a virtual-memory page. An advantage of the embodiment shown in FIG. 5 is that the linear-to-physical translation occurs in parallel with the encoding operation instead of serially, so it is In addition, special bus cycles may be defined for accessing the private-state region 418 of the memory 408 (FIG. 4). Turning now to FIG. 6, a more detailed design of an example, programmable 4-bit, address bit obfuscation (encoding) mechanism is shown. This design may be used in the address obfuscation/encoding unit 514 of FIG. 5 and to generate the logical-to-physical address mapping (for the low-order bits) in FIG. 4. The logic diagram of FIG. 6 is an embodiment of a combinational logic portion of a 4-bit wide, multi-input linear feedback shift register (MISR) with a fourth-order polynomial using the method described above. This combinational logic is fed by the polynomial control register 604, the optional mask register 610, and the input address source 606. Note that this logic is not an entire MISR, but does leverage the mapping properties of an MISR. In FIG. 6, the polynomial control register 604 is loaded with the binary coefficients of a polynomial. For example, to configure the circuit of FIG. 6 to implement the logical-to-physical address mapping illustrated in FIG. 4 that maps with primitive polynomial $x^4 + x^3 + 1$, one would load the polynomial control register 604 with binary coefficients $P_3 = 1$, $P_2 = 1$, $P_1 = 0$, $P_0 = 0$. The address bit vector 0000 will map to 0000, if the optional mask register 610 is set to 0000. The input address source 606 represents the 4-bit logical address to be encoded. The optional mask source 610 (e.g., control register) permits different mappings to be constructed. As described above, the mask register 610 and polynomial control register 604 may be changed dynamically at run time. For example, the values that are loaded may be derived from a pseudo-random data source during power-on reset processing. This may thwart attempts to access private-state data or to circumvent any prescribed access methods (such as a special ISA instructions described above). FIG. 6 is an embodiment which is reasonably efficient and permits programmability with binary coefficient and mask values and a modest amount of hardware with relatively few gate delays. Other logic designs are possible for implementing the address obfuscation/encoding unit 514. Additional logic or content addressable memory (CAMs) may be used to further restrict the range of addresses modified by the address bit encoding mechanism. In addition, more complex logic may be designed for the encoding and decoding processes to, for example, strengthen the encoding (if needed). The encoding of the content values of the private-state data may be accomplished in a way similar to those described above for address obfuscation. One approach is to XOR-in the logical address offsets (for aligned regions of private-state data), or XOR-in some constant seed value, with the contents of a given element of private-state to be encoded. A more sophisticated encoding mechanism may be used on a stream of private-state data values. A variant of a feedback shift register technique (linear, non-linear, multi-input, etc.) may be used with an initial seed. The initial seed is defined to be the initial state loaded into the feedback shift register. For each data value in succession, the shift register may be advanced and its contents bit-wise XOR-ed to the contents of the internal register. This is referred to as a Vigenere cipher and an example of this is shown in tables 470, 480 of FIG. 4 above, where each unencoded content (data) value in 470 (e.g., entry 471) but does not appear as such when stored in encoded form in 480 (e.g., entry 481) in memory 408. With this cipher, the shift register is used to generate a pseudo-random sequence of bit-wise XOR masks. In this case as each pseudo-random byte-wide mask is produced by an MISR (see 480), it is bit-wise XOR-ed with the next data value in the address sequence. Only the polynomial and initial shift reg- ister seed value is needed to regenerate the exact same sequence again. In an embodiment, the encode and/or decode unit's configuration information (e.g., polynomial and initial seed) could be stored along with the encoded state in memory 408. To decode the private-state, the configuration information (e.g., polynomial and initial seed) would be retrieved (and possibly decoded using another fixed encoding technique), and then used. As long as each mask in the sequence is applied to the corresponding data in the same order (e.g., one mask applied per addressable data unit), the bit-wise XOR masking will produce (decode) the original data. As discussed previously, the polynomial and initial MISR seed values may be changed (e.g., boot time, run time, etc.) using various methods or change constraints. To recover the original data, the decode method(s) appropriate for the encoding method(s) originally used should be applied, i.e. to undo the encoding. Vigenere ciphers are just one example of a private-state data value encoding mechanism, which is efficient and permits programmability with simple binary coefficient lists, seeds, etc., and a modest amount of hardware with only a few gate delays. Other embodiments are also possible. In an embodiment of the invention, the processor may make use of the private-state region 132 in storage (see FIG. 1) at transitions between modes of operations of the processor. For example, the processor may access the private-state region when entering system management mode (SMM) as described above. These transitions between modes of operation are referred to herein as mode switches. Mode switches include, for example, movement between normal and system management mode, between a virtual machine (VM) and a virtual machine monitor (VMM) in the virtual machine system, between a user-level operating system process and the operating system kernel, etc. In an embodiment of the invention, the processor may make use of the private-state region 132 in storage at any time after designation of the private-state region. For example, in a virtual machine system, the VMM may allocate a region in storage for the processor's use during virtual machine operation. The VMM may indicate the location of the private-state region to the processor (e.g., through executing an instruction defined in the ISA). After the processor receives this indication, it may be free to utilize the private-state region as it sees fit. For example, the processor may access the private-state region during transitions between a VM and the VMM (i.e., at mode switch points). Additionally, the processor may access the region during operation of a VM or the VMM. For example, the processor may access control information from the private-state region or the processor may store temporary values in the private-state region. The ISA may also provide a mechanism by which the VMM may designate that a private-state region should no longer be used (e.g., by executing an instruction). In other embodiments, private-state regions may be designated using other methods. For example, a private-state region may be designated by writing to model-specific registers (MSRs), executing instructions in the ISA, writing to locations in storage, etc. Although the above examples may describe embodiments of the present invention in the context of execution units and logic circuits, other embodiments of the present invention can be accomplished by way of software. For example, in some embodiments, the present invention may be provided as a computer program product or software which may include a machine or computer-readable medium having stored thereon instructions which may be used to program a computer (or other electronic devices) to perform a process according to an embodiment of the invention. In other embodiments, operations might be performed by specific hardware components that contain microcode, hardwired logic, or by any combination of programmed computer components and custom hardware components. Thus, a machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), but is not limited to, floppy diskettes, optical disks, Compact Disc, Read-Only Memory (CD-ROMs), and magneto-optical disks, Read-Only Memory (ROMs), Random Access Memory (RAM), Erasable Programmable Read-Only Memory (EEPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic or optical cards, flash memory, a transmission over the Internet, electrical, optical, acoustical or other forms of propagated signals (e.g., carrier waves, infrared signals, digital signals, etc.) or the like. Further, a design may go through various stages, from creation to simulation to fabrication. Data representing a design may represent the design in a number of manners. First, as is useful in simulations, the hardware may be represented using a hardware description language or another functional description language. Additionally, a circuit level model with logic and/or transistor gates may be produced at some stages of the design process. Furthermore, most designs, at some stage, reach a level of data representing the physical placement of various devices in the hardware model. In the case where conventional semiconductor fabrication techniques are used, data representing a hardware model may be the data specifying the presence or absence of various features on different mask layers for masks used to produce the integrated circuit. In any representation of the design, the data may be stored in any form of a machine-readable medium. An optical or electrical wave modulated or otherwise generated to transmit such information, a memory, or a magnetic or optical storage such as a disc may be the machine readable medium. Any of these mediums may "carry" or "indicate" the design or software information. When an electrical carrier wave indicating or carrying the code or design is transmitted, to the extent that copying, buffering, or re-transmission of the electrical signal is performed, a new copy is made. Thus, a communication provider or a network provider may make copies of an article (a carrier wave) embodying techniques of the present invention. In the foregoing specification, the invention has been described with reference to various techniques for accessing data about the state of a data processing machine from publicly accessible storage. It will, however, be appreciated that various modifications and changes may be made thereto without departing from the broader spirit and scope of embodiments of the invention, as set forth in the appended claims. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense. What is claimed is: 1. A method for operating a data processing machine, comprising: - applying by a processor an encoding process to private-state data of said processor, where the private-state data captures a state of the processor; - writing, to a location in storage, said encoded private-state data, the location being one that is accessible to software written for the processor; and - reading by the software the encoded private-state data from the storage using an instruction that causes the processor to decode the encoded private-state data and store the decoded private-state data in a private-state area accessible to software only by using the instruction; wherein 15 the private-state data refers to one of content of an internal register of the processor that is not explicitly identified in an instruction manual for the processor, and content of an internal register of the processor that is explicitly identified in the instruction manual but is stored in one of a format and a location that is not explicitly identified in the instruction manual. 2. The method of claim 1 wherein the encoding process is to thwart an attempt at recovering the private-state data from the storage by a second process different from the decoding process. 3. The method of claim 1 wherein the encoding process is configured to cause an author of the software to apply, in writing said software, a technique prescribed by a manufacturer of the processor for accessing the private-state data from storage rather than circumventing said technique. 4. The method of claim 1 wherein the private-state data is written to one of a publicly accessible location in a register file of the processor, cache, and memory. 5. The method of claim 1 wherein during the encoding process the location of written contents of a given internal register of the processor changes arbitrarily at least once, while repeating the applying and the writing. 6. The method of claim 1 wherein during the encoding process a storage format of written contents of a given internal register of the processor changes arbitrarily at least once between big-endian and little-endian, while repeating the applying and the writing. 7. The method of claim 1 wherein during the encoding process a cipher is applied to the contents of a given internal register to produce an encoded value which is then written to the location in storage. 8. The method of claim 1 further comprising storing recovered state data in a private storage of the processor. 9. An apparatus for operating a data processing machine, comprising: a data processing machine having a private internal state, the internal state to change as the data processing machine executes instructions provided to itself as part of a program, wherein the data processing machine is to encode data about the internal state and write the encoded state data to a location in a storage unit, wherein the location is readable by an instruction set architecture of the data processing machine using an instruction that causes the data processing machine to decode the encoded state data and store the decoded state data in a private state area accessible to software only by using the instruction; wherein the data about the internal state refers to one of content of an internal register of the data processing machine that is not explicitly identified in an instruction manual for the data processing machine, and content of an internal register of the data processing machine that is explicitly identified in the instruction manual but is stored in one of a format and a location that is not explicitly identified in the instruction manual. 10. The apparatus of claim 9 wherein the data processing machine is a processor that has a special read micro-operation, to be used when the processor is to recover said state data from the storage unit. 11. The apparatus of claim 10 wherein the processor further includes an internal cache and is to also write the encoded state data to a public location in the cache. 12. The apparatus of claim 10 wherein the processor is to recover the state data and write the recovered state data to a private location in the processor. 13. The apparatus of claim 10 wherein the processor is to recover the state data and configure itself with the recovered state data in preparation for resuming execution of a suspended task. 14. The apparatus of claim 10 wherein the processor comprises a manufacturer-defined instruction that, when executed by the processor, recovers the state data from the storage unit. 15. The apparatus of claim 9 wherein the data processing machine is a processor for which a special micro-operation is defined for accessing the encoded state data from the storage unit, and wherein the processor further comprises an address obfuscation unit to receive an address value associated with given state data of the processor, the address value having been derived from a dispatch of the special micro-operation, the obfuscation unit to provide an encoded, physical address value that points to the actual location in the storage unit where the given state data is stored. 16. The apparatus of claim 9 wherein the data processing machine is a processor for which a hardware control signal is defined for accessing the encoded data from the storage unit, and wherein the processor further comprises an internal cache, a data conversion unit to receive a data value from the internal cache as a result of a cache hit derived from the hardware control signal, the conversion unit to decode the data value into actual state data of the processor. 17. A computer system comprising: a processor; and a main memory communicatively coupled to the processor and having a public region designated to store the processor's private-state data in encoded form, the instruction set architecture of the processor including an instruction to decode and read said private-state data from the public region; wherein the private-state data refers to one of content of an internal register of the processor that is not explicitly identified in an instruction manual for the processor, and content of an internal register of the processor that is explicitly identified in the instruction manual but is stored in one of a format and a location that is not explicitly identified in the instruction manual. 18. The system of claim 17 wherein the processor encodes the private-state data prior to storing it to the public region. 19. The system of claim 17 wherein the processor decodes a value read from the public region prior to using it. 20. The system of claim 17 wherein the processor further includes an internal storage unit in which a public region is designated to store a copy of said private-state data in encoded form. 21. The system of claim 20 wherein the internal storage unit is one of a cache and a register file. 22. The system of claim 20 wherein a private region is designated in the internal storage unit to store said private-state data in unencoded form. 23. The system of claim 20 further comprising a system chipset communicatively coupling the processor to the main memory. 24. A method for operating a data processing machine, comprising: encoding private state data about a state of the data processing machine; and writing, to a location in storage, the encoded private state data, the location being readable to software that is running on the data processing machine using an instruction that causes the data processing machine to decode the encoded private state data and store the decoded private state data in a private state area accessible to software only by using the instruction; wherein the private state data refers to one of content of an internal register of the data processing machine that is not explicitly identified in an instruction manual for the data processing machine, and content of an internal register of the data processing machine that is explicitly identified in the instruction manual but is stored in a format or location that is not explicitly identified in the instruction manual. 25. The method of claim 24, wherein the encoding comprises ciphering a value of the private state data to yield said encoded private state data. 26. The method of claim 24, wherein the private state data about the state of the data processing machine is one of a register value and a value from the storage. 27. The method of claim 24, wherein the encoding comprises address encoding to obfuscate an address value of the private state data. 28. The method of claim 24 further comprising recovering the private state data from the storage according to a decoding process. 29. The method of claim 28 wherein the recovering comprises reading a plurality of values from memory; and combining the read plurality of values to form a single unencoded value of said private state data. 30. The method of claim 28 wherein the recovering comprises reading a plurality values from one or more discontiguous locations of memory; combining the read plurality values to form a single value; and decoding the single value to form an unencoded value of said private state data. 31. The method of claim 28 further comprising storing the recovered private state data in a private storage of the data processing machine.
{"Source-Url": "https://patentimages.storage.googleapis.com/bb/e7/e8/a4f59a6f61a3f3/US9087000.pdf", "len_cl100k_base": 12856, "olmocr-version": "0.1.53", "pdf-total-pages": 20, "total-fallback-pages": 0, "total-input-tokens": 27476, "total-output-tokens": 16251, "length": "2e13", "weborganizer": {"__label__adult": 0.0008435249328613281, "__label__art_design": 0.001285552978515625, "__label__crime_law": 0.002521514892578125, "__label__education_jobs": 0.00112152099609375, "__label__entertainment": 0.0002312660217285156, "__label__fashion_beauty": 0.0004270076751708984, "__label__finance_business": 0.004634857177734375, "__label__food_dining": 0.0008091926574707031, "__label__games": 0.0025272369384765625, "__label__hardware": 0.144775390625, "__label__health": 0.0008068084716796875, "__label__history": 0.000621795654296875, "__label__home_hobbies": 0.000396728515625, "__label__industrial": 0.0041046142578125, "__label__literature": 0.0005550384521484375, "__label__politics": 0.0007405281066894531, "__label__religion": 0.0008425712585449219, "__label__science_tech": 0.31005859375, "__label__social_life": 4.7087669372558594e-05, "__label__software": 0.03472900390625, "__label__software_dev": 0.48583984375, "__label__sports_fitness": 0.00033283233642578125, "__label__transportation": 0.001392364501953125, "__label__travel": 0.00021386146545410156}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 65318, 0.14186]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 65318, 0.78944]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 65318, 0.88026]], "google_gemma-3-12b-it_contains_pii": [[0, 1325, false], [1325, 3482, null], [3482, 3482, null], [3482, 7089, null], [7089, 7487, null], [7487, 7494, null], [7494, 7788, null], [7788, 7795, null], [7795, 7802, null], [7802, 8122, null], [8122, 8122, null], [8122, 14846, null], [14846, 22519, null], [22519, 30227, null], [30227, 37739, null], [37739, 45277, null], [45277, 49186, null], [49186, 56678, null], [56678, 63685, null], [63685, 65318, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1325, true], [1325, 3482, null], [3482, 3482, null], [3482, 7089, null], [7089, 7487, null], [7487, 7494, null], [7494, 7788, null], [7788, 7795, null], [7795, 7802, null], [7802, 8122, null], [8122, 8122, null], [8122, 14846, null], [14846, 22519, null], [22519, 30227, null], [30227, 37739, null], [37739, 45277, null], [45277, 49186, null], [49186, 56678, null], [56678, 63685, null], [63685, 65318, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 65318, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 65318, null]], "pdf_page_numbers": [[0, 1325, 1], [1325, 3482, 2], [3482, 3482, 3], [3482, 7089, 4], [7089, 7487, 5], [7487, 7494, 6], [7494, 7788, 7], [7788, 7795, 8], [7795, 7802, 9], [7802, 8122, 10], [8122, 8122, 11], [8122, 14846, 12], [14846, 22519, 13], [22519, 30227, 14], [30227, 37739, 15], [37739, 45277, 16], [45277, 49186, 17], [49186, 56678, 18], [56678, 63685, 19], [63685, 65318, 20]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 65318, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
dcf21075f8988567f8721737c963c1a0940d6186
[REMOVED]
{"Source-Url": "http://supertech.csail.mit.edu/papers/DemaineKaLiSi15.pdf", "len_cl100k_base": 8981, "olmocr-version": "0.1.53", "pdf-total-pages": 13, "total-fallback-pages": 0, "total-input-tokens": 42580, "total-output-tokens": 10246, "length": "2e13", "weborganizer": {"__label__adult": 0.00042891502380371094, "__label__art_design": 0.0005135536193847656, "__label__crime_law": 0.0004787445068359375, "__label__education_jobs": 0.0010442733764648438, "__label__entertainment": 0.000148773193359375, "__label__fashion_beauty": 0.0002574920654296875, "__label__finance_business": 0.00055694580078125, "__label__food_dining": 0.0005383491516113281, "__label__games": 0.0010776519775390625, "__label__hardware": 0.0019664764404296875, "__label__health": 0.0012264251708984375, "__label__history": 0.0005640983581542969, "__label__home_hobbies": 0.00021469593048095703, "__label__industrial": 0.0007243156433105469, "__label__literature": 0.00041794776916503906, "__label__politics": 0.00037598609924316406, "__label__religion": 0.0007066726684570312, "__label__science_tech": 0.2462158203125, "__label__social_life": 0.0001251697540283203, "__label__software": 0.01153564453125, "__label__software_dev": 0.7294921875, "__label__sports_fitness": 0.0004093647003173828, "__label__transportation": 0.0008668899536132812, "__label__travel": 0.00031113624572753906}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 36188, 0.02184]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 36188, 0.26904]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 36188, 0.85875]], "google_gemma-3-12b-it_contains_pii": [[0, 2573, false], [2573, 5908, null], [5908, 8747, null], [8747, 11541, null], [11541, 14689, null], [14689, 17938, null], [17938, 20900, null], [20900, 24316, null], [24316, 27733, null], [27733, 30957, null], [30957, 32307, null], [32307, 35159, null], [35159, 36188, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2573, true], [2573, 5908, null], [5908, 8747, null], [8747, 11541, null], [11541, 14689, null], [14689, 17938, null], [17938, 20900, null], [20900, 24316, null], [24316, 27733, null], [27733, 30957, null], [30957, 32307, null], [32307, 35159, null], [35159, 36188, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 36188, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 36188, null]], "pdf_page_numbers": [[0, 2573, 1], [2573, 5908, 2], [5908, 8747, 3], [8747, 11541, 4], [11541, 14689, 5], [14689, 17938, 6], [17938, 20900, 7], [20900, 24316, 8], [24316, 27733, 9], [27733, 30957, 10], [30957, 32307, 11], [32307, 35159, 12], [35159, 36188, 13]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 36188, 0.0]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
dc83890bf5667503b9256a8f75ca8b6126ea2462
[REMOVED]
{"Source-Url": "https://www.springer.com/cda/content/document/cda_downloaddocument/9780387255897-c2.pdf?SGWID=0-0-45-301307-p46178307", "len_cl100k_base": 11510, "olmocr-version": "0.1.53", "pdf-total-pages": 25, "total-fallback-pages": 0, "total-input-tokens": 80218, "total-output-tokens": 14022, "length": "2e13", "weborganizer": {"__label__adult": 0.0004291534423828125, "__label__art_design": 0.000812530517578125, "__label__crime_law": 0.0007109642028808594, "__label__education_jobs": 0.0244598388671875, "__label__entertainment": 0.00019276142120361328, "__label__fashion_beauty": 0.00028204917907714844, "__label__finance_business": 0.0117340087890625, "__label__food_dining": 0.00054168701171875, "__label__games": 0.0009813308715820312, "__label__hardware": 0.00197601318359375, "__label__health": 0.0008974075317382812, "__label__history": 0.000927448272705078, "__label__home_hobbies": 0.0002034902572631836, "__label__industrial": 0.0010557174682617188, "__label__literature": 0.0012378692626953125, "__label__politics": 0.0009403228759765624, "__label__religion": 0.0005974769592285156, "__label__science_tech": 0.39404296875, "__label__social_life": 0.0002589225769042969, "__label__software": 0.05230712890625, "__label__software_dev": 0.50390625, "__label__sports_fitness": 0.0003056526184082031, "__label__transportation": 0.0008802413940429688, "__label__travel": 0.0002613067626953125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 57156, 0.04367]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 57156, 0.1651]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 57156, 0.91531]], "google_gemma-3-12b-it_contains_pii": [[0, 1735, false], [1735, 5129, null], [5129, 7587, null], [7587, 10587, null], [10587, 13737, null], [13737, 16532, null], [16532, 18674, null], [18674, 20442, null], [20442, 20782, null], [20782, 22230, null], [22230, 24845, null], [24845, 27133, null], [27133, 27730, null], [27730, 29663, null], [29663, 32059, null], [32059, 33616, null], [33616, 35207, null], [35207, 36395, null], [36395, 39963, null], [39963, 43742, null], [43742, 47174, null], [47174, 50684, null], [50684, 54321, null], [54321, 56896, null], [56896, 57156, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1735, true], [1735, 5129, null], [5129, 7587, null], [7587, 10587, null], [10587, 13737, null], [13737, 16532, null], [16532, 18674, null], [18674, 20442, null], [20442, 20782, null], [20782, 22230, null], [22230, 24845, null], [24845, 27133, null], [27133, 27730, null], [27730, 29663, null], [29663, 32059, null], [32059, 33616, null], [33616, 35207, null], [35207, 36395, null], [36395, 39963, null], [39963, 43742, null], [43742, 47174, null], [47174, 50684, null], [50684, 54321, null], [54321, 56896, null], [56896, 57156, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 57156, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 57156, null]], "pdf_page_numbers": [[0, 1735, 1], [1735, 5129, 2], [5129, 7587, 3], [7587, 10587, 4], [10587, 13737, 5], [13737, 16532, 6], [16532, 18674, 7], [18674, 20442, 8], [20442, 20782, 9], [20782, 22230, 10], [22230, 24845, 11], [24845, 27133, 12], [27133, 27730, 13], [27730, 29663, 14], [29663, 32059, 15], [32059, 33616, 16], [33616, 35207, 17], [35207, 36395, 18], [36395, 39963, 19], [39963, 43742, 20], [43742, 47174, 21], [47174, 50684, 22], [50684, 54321, 23], [54321, 56896, 24], [56896, 57156, 25]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 57156, 0.27876]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
47183d0f6902ea6d0a66543afbdcc4ba643e31bc
Interested in learning more? Check out the list of upcoming events offering "Intrusion Detection In-Depth (Security 503)" at http://www.giac.org/registration/gcia How to Leverage PowerShell to Create a User-Friendly Version of WinDump GIAC (GCIA) Gold Certification Author: Robert L. Adams, robert.louis.adams@gmail.com Advisor: Hamed Khiabani, Ph.D. Accepted: January 11th 2016 Abstract WinDump is often used to analyze packet captures by incorporating Berkeley Packet Filters, to reduce large captures into manageable subsets. The filtering makes use of macros to easily specify common protocol properties, however, analyzing other properties requires a deeper understanding of the protocol and more complicated expressions. PowerShell is a Windows scripting language that has become increasingly popular within the security community. PowerShell is extremely extensible, and can be used to develop an easy way to interact with WinDump. This paper will demonstrate how to write a custom PowerShell module that serves as a wrapper around WinDump, enabling an easier and more intuitive way of unleashing the power of WinDump. 1. Introduction Security professionals rely on a myriad of tools to accomplish their job. This is no different than the toolboxes that plumbers, electricians, and other trade professionals carry with them every day. There are specific tools for various aspects of a job. These tools tend to evolve over time and in some cases, new technology influences the creation of a better tool. Some tools, like a hammer, are timeless. These types of tools are found within the information security industry as well. WinDump, the Windows version of the popular packet capture and analysis tool, tcpdump, has been an ageless asset to security professionals for decades. WinDump is really good at its job: capturing and filtering network packets. It is a command-line tool that succeeds in its minimalistic approach. A vast amount of time has passed since WinDump was released. Nine years have passed since the latest update was distributed. This begs the question: How can WinDump be better? Technology influences change. PowerShell is a Windows scripting language that has influenced much change since its original release in 2006. More recently, PowerShell has been affecting the way both attackers and defenders perform their job. PowerShell’s appeal is largely attributed to the language’s extremely natural syntax, power, and flexibility. It makes complete sense that PowerShell has been the underlying inspiration to many security trends. PowerShell has influenced PowerSploit—the PowerShell flavor of Metasploit. PowerShell has inspired Posh-Nessus--- the PowerShell take on automating the Tenable Nessus Vulnerability Scanner. Can PowerShell be used to improve WinDump? WinDump captures and reads packets. It can also be used to filter packet captures into relevant subsets to aid forensic investigation. WinDump makes uses of macros to filter in a natural language-like way. Users can specify “tcp”, “src host”, “dst host” and so on. However, the learning curve and complexity immediately spike when attempting... to identify specific (less than one byte) values in various protocol header fields: TCP flags, IPv4 attributes, and so forth. PowerShell seems like the natural choice for creating a custom tool to serve as a wrapper around WinDump. The complexity of more sophisticated filters can be eradicated with extremely easy syntax. PowerShell can be used to provide increased search functionality when working with packet captures. And finally, PowerShell can be leveraged to provide concurrent processing and filtering of multiple packet captures. 2. WinDump – A Brief Overview and History WinDump is a command-line network capture and analysis tool for Windows. The original tool, tcpdump, was first written for UNIX. The Windows variant captures network traffic through the use of the Windows Packet Capture (WinPcap) library (WinDump, 2013). WinDump is free software and is extremely useful for packet capture and analysis. WinDump is extremely performant. The tool can process large packet captures and detect patterns in very little time. The tool can be used to analyze live traffic that passes through an interface. It can also be used to process previously captured traffic (in the form of PCAP files). There are several options built into WinDump. The variety of command-line switches allow users to specify which interfaces to capture, the level of detail in the output, and the amount of traffic to capture (Cane, 2014). Additionally, analysts can use filters in the form of expressions to isolate very specific network traffic patterns. 2.1. Why is WinDump a Valuable Tool? There are several network analyzers on the market today. Many of these tools have robust graphical interfaces. Wireshark, for example, performs many of the same functions as WinDump. Also, Wireshark is equipped with a powerful interface that represents network data in a clean, organized, and colorful fashion. Wireshark grants power to its users in a point-and-click way. Robert L. Adams, robert.louis.adams@gmail.com Where does this leave WinDump? WinDump is a lot less attractive. The data is simply displayed within a command line window. No color. No robust formatting. However, this lightweight approach is what gives WinDump tremendous power. The utility has little overhead and can process a ton of packets in a small amount of time. Users interact with WinDump via the command line. The structure of commands is comprised of two parts: options and expressions (See Appendix A for a complete list of WinDump options). Options allow one to specify which interface to capture, the level of verbosity, whether or not to perform automatic hostname lookups, among others. Expressions are used to determine exactly what type of traffic to display. Users can filter on IP addresses, protocols, and ports. Expressions also support the use of “and”, “or”, and parenthetical groupings (Van Styn, 2011). WinDump’s minimalistic approach yields much power. The ability to carve packet captures with expressions allows one to identify anomalous patterns. Or to simply troubleshoot bizarre network behaviors. 2.2. What are WinDump’s Deficiencies? WinDump is quick and powerful. WinDump filters, also called Berkeley Packet Filters (BPF), afford the ability to filter on very specific protocol properties (whether individual bits are on within TCP, for example). The problem is that BPF filters require a deep understanding of multiple concepts: byte offsets, bit masking, and binary arithmetic. In other words, there is no easy way to specify, “Show me all packets that have the SYN and ACK flags set within TCP communication”. The statement would have to be specified as: “TCP[13] == Ox12”. The protocol, TCP, is first specified. Using bracket notation, the byte offset (13) is then specified which corresponds to the position of the TCP flags within the TCP header. The hexadecimal value, 12, is inserted to represent which bits (flags) to look for. Essentially, the hexadecimal is translated into binary, which then translates into specific bits (that represent TCP flags). There is a lot of information to process in order to capture a simple concept. It would be extremely beneficial if the same filter could be represented in a natural way: “TCP with SYN and ACK”. 3. PowerShell – A Brief Overview and History PowerShell is a Windows scripting language that debuted in 2006. Since, it has become heavily integrated with multiple core Microsoft technologies. As it relates to the security community, PowerShell has become a trending technology. There have been attacks that leveraged PowerShell. There are also several defender tools written in PowerShell. Jeffrey Snover, a Technical Fellow at Microsoft, is the founder of PowerShell. In Snover’s original Monad Manifesto, the core idea and value proposition are discussed: a scripting language that boasts an extremely easy syntax. All PowerShell commands, called “cmdlets” (pronounced “command lets”), follow a verb-noun syntax: Get-Eventlog. Get-ADForest. Restart-Service. New-GPO. The result of cmdlets is in the form of objects. This means that users can manipulate results in an object-oriented fashion, as PowerShell objects have properties and methods. 3.1. Mapping PowerShell’s Features to WinDump’s Deficiencies PowerShell’s natural syntax makes it an excellent candidate for automating WinDump’s core features. The complexity of WinDump’s common use-cases (specifying TCP flags in the earlier example) can be extrapolated into a PowerShell wrapper. “TCP[13] == Ox12” could be translated into “Invoke-WinDump –TCPFlags ‘SYN,ACK’”. The byte offsets and hexadecimal numbers could be handled programmatically under the hood. 4. Invoke-WinDump: Value Proposition Invoke-WinDump is a custom PowerShell module intended to simplify the use of WinDump. The idea focuses on the following value proposition: - Extraordinarily easy syntax - Elimination of byte offsets, hexadecimal and bit masking - Searchable text patterns - Lightning fast processing 4.1. Getting Started: Mapping Use-Cases The intended outcome of Invoke-WinDump needs to be crystal clear: “How will users interact with Invoke-WinDump?” “What are the common protocols and header attributes that need to be easily specified?” The blueprint of Invoke-WinDump is designed based on these types of common use-cases. Implementing a clean syntax is dependent on the underlying WinDump filters. And the underlying WinDump filters require an understanding of the respective protocol headers. What protocol support will Invoke-WinDump include? - IPv4 - TCP - UDP - ICMP WinDump is already equipped with a mechanism that allows users to specify various protocol attributes in an easy way. Users can use predefined keywords, called primitives (or macros), such as “src host”, “dst port”, “ip6”, “tcp”, “udp”, and so on. An understanding of WinDump’s built-in primitives makes it easier to derive use-cases for Invoke-WinDump. The headers for each of WinDump’s target protocols is evaluated during the design phase. Each of the headers are then distilled into matrixes that depict each protocol field, byte offset location, the size of the field, and whether or not WinDump already has a primitive for that field. Robert L. Adams, robert.louis.adams@gmail.com Internet Protocol Version 4 (IPv4) has a 20-byte header field that contains various properties: ![IPv4 Header Diagram](image) *Figure 1 - IPv4 Header (NMAP, n.d.)* The IPv4 header is distilled into the following table: <table> <thead> <tr> <th>Attribute</th> <th>Byte Offset</th> <th>Size</th> <th>Primitive</th> </tr> </thead> <tbody> <tr> <td>Version</td> <td>0</td> <td>4 bits</td> <td>ip, ip6</td> </tr> <tr> <td>IHL (Header Length)</td> <td>0</td> <td>4 bits</td> <td>n/a</td> </tr> <tr> <td>Type of Service (TOS)</td> <td>1</td> <td>1 byte</td> <td>n/a</td> </tr> <tr> <td>Total Length</td> <td>2</td> <td>2 bytes</td> <td>n/a</td> </tr> <tr> <td>Identification</td> <td>4</td> <td>2 bytes</td> <td>n/a</td> </tr> <tr> <td>IP Flags</td> <td>6</td> <td>3 bits</td> <td>n/a</td> </tr> <tr> <td>Fragment Offset</td> <td>6</td> <td>13 bits</td> <td>n/a</td> </tr> </tbody> </table> Robert L. Adams, robert.louis.adams@gmail.com How to Leverage PowerShell to Create a User-Friendly Version of WinDump <table> <thead> <tr> <th>Field</th> <th>Size</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Time to Live (TTL)</td> <td>8</td> <td>1 byte</td> <td>n/a</td> </tr> <tr> <td>Protocol</td> <td>9</td> <td>1 byte</td> <td>tcp, udp, icmp</td> </tr> <tr> <td>Header Checksum</td> <td>10</td> <td>2 bytes</td> <td>n/a</td> </tr> <tr> <td>Source Address</td> <td>12</td> <td>4 bytes</td> <td>src host</td> </tr> <tr> <td>Destination Address</td> <td>16</td> <td>4 bytes</td> <td>dst host</td> </tr> </tbody> </table> Table 1 - IPv4 Header – Mapping WinDump Primitives Every header field is compared against WinDump’s built-in primitives. Column 4 depicts that there are several fields that do not have corresponding primitives. This means that users have to specify a particular field’s byte offset position, and in some cases, provide a bit mask, in order to filter when using WinDump. The goal is to identify every protocol header field that does not have a primitive. This provides a roadmap for developing use-cases for Invoke-WinDump. Here is an example of using WinDump to check for packets that include IP options: ``` c:\Tools\WinDump\WinDump.exe -r Test.pcap -nt "ip[0] & 0x0f > 5" ``` Figure 2 - WinDump: Looking for IP Options The Invoke-WinDump equivalent eliminates the need to provide a byte offset and a bitmask: ``` Invoke-WinDump -File $file -Protocol ip -HeaderLength '>5' ``` Figure 3 - Invoke-WinDump: Looking for IP Options The process of understanding each protocol header, and which fields have a built-in primitive, is pertinent to mapping the functionality of Invoke-WinDump. (See Appendix B for TCP, UDP, and ICMP header illustrations, along with primitive mappings.) 4.1.1. Building the Invoke-WinDump Framework There is now a clear roadmap for Invoke-WinDump. Invoke-WinDump will support IPv4, TCP, UDP, and ICMP. Each of these protocol headers have been evaluated to Robert L. Adams, robert.louis.adams@gmail.com understand which have existing macros. One of the primary objectives is providing an easy way to specify any of the protocol header fields. Invoke-WinDump is a collection of PowerShell scripts (.ps1 files) that are wrapped into a module. Users interact with the tool via Invoke-WinDump.ps1. The primary script will be responsible for capturing user input and will rely on other script files for processing. The dependent scripts are comprised of helper functions. *Invoke-WinDump.ps1* has several parameter options. These parameters are inspired by the WinDump parameter options. WinDump has many command-line argument options. Invoke-WinDump incorporates the most common ones. The *Invoke-WinDump.ps1* starts off by defining these common parameter options: ```powershell $File, $ASCII, $IncludeLinkLayer, $Interface, $Quiet, $Verbose ``` *Figure 4 - Invoke-WinDump Common Parameters* Here is a snippet of the function parameter definitions: ```powershell function Invoke-WinDump { param { [Parameter(Mandatory=$false, HelpMessage="Provide path to packet capture (.pcap).")] [System.String]$File, [Parameter(Mandatory=$false, HelpMessage="Print each packet in ASCII.")] [System.Boolean]$ASCII, [Parameter(Mandatory=$false, HelpMessage="Print the link-level header on each dump line.")] [System.Boolean]$IncludeLinkLayer, [Parameter(Mandatory=$false, HelpMessage="Specify interface to listen on.")] [System.String]$Interface, ``` *Figure 5 - Invoke-WinDump Parameter Definitions* Each parameter is declared as a variable with a data type. In addition, each parameter specifies a help message that is displayed to the user when selecting options. The two datatypes used are `System.String` and `System.Boolean`. These datatypes dictate how users interact with tool and what types of values can be provided to the parameters. For example, users can specify which packet capture file to read from. Users can also depict whether or not to display ASCII while processing packet captures: ``` $file = "C:\Tools\Captures\test.pcap" Invoke-WinDump -File $file ``` *Figure 6 - Providing Value to -File Parameter* ``` Invoke-WinDump -File $file -ASCII $true ``` *Figure 7 - Choosing to Display ASCII* 5. Implementing Key Feature #1 – Easily Specified IPv4, TCP, UDP, and ICMP Header Fields The *Invoke-WinDump.ps1* parameter definitions include several other options as well. In fact, there is a parameter for each and every IPv4, TCP, UDP, and ICMP header fields. Here is a snippet of the parameters that are related to IPv4: ```powershell # IPv4 Parameters [Parameter(Mandatory=$false, HelpMessage="IP version.",)][System.String]$Version, [Parameter(Mandatory=$false, HelpMessage="Example: '0x56'")][System.String]$TOS, ``` *Figure 8 - IPv4 Parameter Definitions* The screenshot depicts how the IPv4 $Version, $HeaderLength, $TOS, and $TotalLength parameters are defined. The parameter list continues in this fashion for the remaining IPv4, TCP, UDP, and ICMP header fields. 5.1. How Are All of These Parameters Processed? *Invoke-WinDump* contains numerous parameter options. Users can specify any of the IPv4, TCP, UDP, and ICMP header fields in a natural way. The question remains: “How are these parameters mapped to the underlying execution of WinDump?” Pseudocode can help answer this question. 1. Enumerate all user-provided parameters Robert L. Adams, robert.louis.adams@gmail.com 2. Store the parameters into a hash table 3. Create a lookup between the values in the hash table and all protocol header fields 4. Convert the values into a WinDump acceptable expression format The body of the Invoke-WinDump function begins with the following code: ```powershell # Initialize a hash table that will be used to capture all # user provided parameters. Enumerate $PSBoundParameters # and add each to the hash table. $parameters = @() foreach ($param in $PSBoundParameters.GetEnumerator()) { $parameters.Add($param.Key, $param.Value) } ``` The code starts by initializing the $parameters hash table. The values of $PSBoundParameters is then enumerated and stored into the hash table: in key-value pairs. $PSBoundParameters is a default PowerShell variable (System.Management.Automation.PSBoundParametersDictionary) that holds all user-provider parameter values. For example, the output of $PSBoundParameters looks like this: ``` <table> <thead> <tr> <th>Key</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>File</td> <td>C:\Tools\WinDump\Captures\nb6-startup.pcap</td> </tr> <tr> <td>Protocol</td> <td>Arp</td> </tr> <tr> <td>DestPort</td> <td>53</td> </tr> </tbody> </table> ``` The newly created hash table is then enumerated in order to inspect the user provided values. These values are then translated into WinDump-compatible expressions: The hash table is enumerated and the name of each parameter is passed to the `Create-WinDumpFilter` function. Each parameter name (which is stored in the hash table) serves as an index that will be used to conduct translation of the value. The body of the function is really simple. It contains one switch statement. The case statements map to all of the protocols’ header fields. These case statements are organized into sections that represent each protocol: IPv4, TCP, UDP, and ICMP. The parameter names (in the form of `$key.Name`) that were passed to the function serve as the switch statement’s keyword. Here is a snippet of the switch statement: ``` "HeaderLength" { $Script:WinDumpFilter += "and (ip[0] & 0x0f "; Check-Operators -paramToCheck $HeaderLength } "TOS" { $Script:WinDumpFilter += "and (ip[1])"; Check-Operators -paramToCheck $TOS } "TotalLength" { $Script:WinDumpFilter += "and (ip[2:2])"; Check-Operators -paramToCheck $TotalLength } ``` An examination of how one of these case statements gets invoked illustrates how all of the pieces work together. Example: Using Invoke-WinDump to find all packets that have IP options. There are two parameters in our example: protocol and header length. As depicted in the code above, these parameters and values are dissected from $PSBoundParameters and stored in the $parameters hash table. The hash table looks like this: <table> <thead> <tr> <th>Name</th> <th>Value</th> </tr> </thead> <tbody> <tr> <td>Protocol</td> <td>&quot;ip&quot;</td> </tr> <tr> <td>HeaderLength</td> <td>&quot;&gt;5&quot;</td> </tr> </tbody> </table> The key-pair values are then passed to the `Create-WinDumpFilter` function in order to translate the values into WinDump-type expressions. A switch statement is used to depict what processing needs to take place per the parameters specified. HeaderLength, for example: ```wasm "HeaderLength" { $Script:WinDumpFilter += "and (ip[0] & 0x0f "; Check-Operators -paramToCheck $HeaderLength } ``` $Script:WinDumpFilter is a string that is used to construct the filter that will get passed to the underlying WinDump.exe. In this case, the results filter looks like this: ``` -fl $nt -r C:\Tools\WinDump\Captures\nb6-startup.pcap -a (ip) and (ip[0] & 0x0f >5) ``` 6. Implementing Key Feature #2 – Easily Searchable Text Patterns The functionality of WinDump can be further extended by incorporating text-based search. This could be useful when searching for a domain name, file name, or any other pattern within a packet capture. A new parameter is added to the Invoke-WinDump function: ```powershell [Parameter(Mandatory=$false, HelpMessage="Provide a pattern to search for in the capture.")] [System.String]$Pattern, ``` The new parameter is responsible for accepting a string. The user-provided string will then be used to search against the packet capture. The following code has been added to the bottom of the main script, `Invoke-WinDump.ps1`: ```powershell # If $pattern exists, execute Search-Packets; if not, display WinDump results if ($pattern) { Search-Packets -set $results -pattern $pattern } else { $results } ``` The snippet checks for the presence of the $Pattern parameter. If the user specifies a string to search for, the code then relies on the Search-Packets helper function. If not, the results from WinDump are displayed on screen. Robert L. Adams, robert.louis.adams@gmail.com How to Leverage PowerShell to Create a User-Friendly Version of WinDump Search-Packets is a function that searches the WinDump results for the presence of the user-specified string. For example, a user can specify that they want to search the packet capture for the presence of “evildomain.com”. Search-Packets accepts two parameters: ```powershell function Search-Packets { param ( [Parameter(Mandatory=$true)] [System.Object[]]$set, [Parameter(Mandatory=$true)] [System.String]$pattern ) } ``` Figure 17 - Search-Packets $set is used to store the results of WinDump and $pattern is the user-specified search string. Why is $set defined as an array of objects? WinDump returns an array of objects when executed, therefore, the data type remains consistent in the helper function. The Search-Packets helper function relies on PowerShell’s Select-String under the hood. The PowerShell help manual describes Select-String as PowerShell’s version of Unix’s grep. The core of the Search-Packets function is quite simplistic: ```powershell $matches = $set | Select-String -Pattern $pattern Write-Host $matches ``` The results of WinDump (represented as $set) is passed to PowerShell’s Select-String. The user-specified string is fed to Select-String’s pattern parameter. The search results are saved to the $matches variable and outputted to the screen. Here is an example of using the search function: Robert L. Adams, robert.louis.adams@gmail.com How to Leverage PowerShell to Create a User-Friendly Version of WinDump Invoke-WinDump -File $file -Protocol ip -Pattern cgxysy.net The results: Figure 18 - Searching a Domain The original packet capture contains 2,263 packets. Using the new search feature yields a single result for the search string, “cgxysy.net”. The returned packet is a DNS query containing the specified search string. (The packet capture was derived from WireShark.org’s samples (WireShark, n.d.).) 7. Implementing Key Feature #3 – Processing Multiple Packet Captures The final feature of Invoke-WinDump will be focused on processing multiple packet captures. An analyst may be interested in a domain IOC related to DNS traffic. It would be useful to specify the filter once and apply it to a directory full of packet captures. A new parameter is added at the top of the main Invoke-WinDump.ps1 script: ``` [Parameter(Mandatory=$false, HelpMessage="Provide directory path to multiple packet captures (.pcaps.")] [System.Object[]]$Files, ``` Figure 20 - New $Files parameter The bottom of the script will introduce a new conditional statement that will check for the presence of the $Files parameter. If the user does specify a directory (containing multiple packet captures), the code will read the files and execute WinDump.exe on each file: Robert L. Adams, robert.louis.adams@gmail.com # Check for multiple files if ($files) { # Enumerate the files $pcaps = Get-ChildItem -Path $files foreach ($pcap in $pcaps) { # Execute WinDump on each .pcap $file = $pcap.FullName $tempResults = & $windump -r $file -nt $Script:WinDumpFilter 2> $null if ($tempResults) { $results += "Found matching packets in $pcap :\n" $results += $tempResults } } } Figure 21- Enumerating Multiple Packet Captures The functionality is tested on a handful of packet captures: - Apple_IP-over-IEEE_1394_Packet.pcap - nb6-startup.pcap - SkypeRC.cap - Test.pcap Figure 22- C : \ Tools \ Captures Invoke-WinDump is executed with the newly defined $Files parameter: Invoke-WinDump -Files $Files -Protocol ip -HeaderLength '>5' Figure 23 - Searching Multiple PCAPS Invoke-WinDump returns any packet (across all files) where there are IP options: Found matching packets in nb6-startup.pcap : IP 10.251.23.139 > 239.255.255.250: igmp v2 report 239.255.255.250 IP 10.251.23.139 > 239.255.255.250: igmp v2 report 239.255.255.250 IP 10.251.23.139 > 239.255.255.250: igmp v2 report 239.255.255.250 Figure 24- Finding IP Options Results The script output annotates which packet capture (nb6-startup.pcap) contained the resulting matches, and then displays the 3 corresponding packets. ### 7.1. Performance Gains Invoke-WinDump currently processes multiple packet captures sequentially. This works fine for a limited number of reasonably sized captures. The script can be further enhanced by processing packet captures concurrently. This can be achieved by leveraging PowerShell jobs. Enumerating multiple packet captures and executing WinDump is demonstrated in the previous section. The same code will be repurposed into the body of a new helper function: ```powershell function Start-PacketJob { param ( [Parameter(Mandatory=$true)] [System.String]$pcap ) # Create and start a PS Job for each packet capture Start-Job -ScriptBlock { $packet = $args[1] if ($tempResults) { Write-Output "Found matching packets in $packet :`n" Write-Output $tempResults } } -ArgumentList $Script:windump, $pcap, $Script:WinDumpFilter, $null } ``` **Figure 25 - Start-PacketJob Function** Start-PacketJob is called as the main script (*Invoke-WinDump.ps1*) enumerates the user provided directory containing multiple packet captures. Essentially, the function instantiates a new PowerShell job for each and every packet capture. A second helper function is used to keep track of the job statuses and alerts when all the jobs have completed—signifying that WinDump has processed each packet capture: ```powershell function Check-Jobs { # Continuously check the status of the jobs # and wait for all jobs to complete while ( (Get-Job -State Running) ) { Write-Output "Still processing packet captures." Start-Sleep -Seconds 2 } Write-Output "Finished processing all packet captures." $Script:results = Get-Job | Receive-Job Get-Job | Remove-Job -Force } ``` *Figure 26 - Check-Jobs Function* The bottom of the main `Invoke-WinDump.ps1` script has been modified to incorporate the new helper functions. Here is how the main script relies on the new functions: ```powershell # Check for multiple files if ($files) { # Enumerate the files $pcaps = Get-ChildItem -Path $files foreach ($pcap in $pcaps) { # Execute WinDump on each .pcap via PowerShell Jobs $file = $pcap.FullName Start-ProcessJob -pcap $file } Check-Jobs Start-Job -pcap $file Write-Output "Starting WinDump processing job..." $job = Start-Job -pcap $file Write-Output "WinDump processing job started." $job | Receive-Job $job | Remove-Job -Force } ``` *Figure 27 – Enumerating PCAPs and Starting Jobs* Here is the output of executing Invoke-WinDump a second time with the updated code: ``` Invoke-WinDump -Files $Files -Protocol ip -HeaderLength '>5' ``` ![Figure 28 - Searching Multiple PCAPS](image) <table> <thead> <tr> <th>Id</th> <th>Name</th> <th>PSJobTypeName</th> <th>State</th> <th>HasMoreData</th> <th>Location</th> <th>Command</th> </tr> </thead> <tbody> <tr> <td>65</td> <td>Job65</td> <td>BackgroundJob</td> <td>Running</td> <td>True</td> <td>localhost</td> <td>...</td> </tr> <tr> <td>66</td> <td>Job66</td> <td>BackgroundJob</td> <td>Running</td> <td>True</td> <td>localhost</td> <td>...</td> </tr> <tr> <td>67</td> <td>Job67</td> <td>BackgroundJob</td> <td>Running</td> <td>True</td> <td>localhost</td> <td>...</td> </tr> <tr> <td>68</td> <td>Job68</td> <td>BackgroundJob</td> <td>Running</td> <td>True</td> <td>localhost</td> <td>...</td> </tr> <tr> <td>69</td> <td>Job69</td> <td>BackgroundJob</td> <td>Running</td> <td>True</td> <td>localhost</td> <td>...</td> </tr> <tr> <td>70</td> <td>Job70</td> <td>BackgroundJob</td> <td>Running</td> <td>True</td> <td>localhost</td> <td>...</td> </tr> </tbody> </table> Still processing packet captures. Finished processing all packet captures. ![Figure 29 - Output of Updated Invoke-WinDump](image) The results of instantiating a job for each packet capture file (4 in total) is now displayed. The status of the jobs is also displayed to the console as a result of the **Check-Jobs** function. The matching packets are exactly the same as before: ``` IP 10.251.23.139 > 239.255.255.250: igmp v2 report 239.255.255.250 IP 10.251.23.139 > 239.255.255.250: igmp v2 report 239.255.255.250 IP 10.251.23.139 > 239.255.255.250: igmp v2 report 239.255.255.250 ``` ![Figure 30 - Resulting Packets](image) Parallel execution increases the power of WinDump and is extremely useful for carving several packet captures simultaneously. 8. Putting It All Together The Invoke-WinDump.ps1 script is now equipped with the functionality to easily search for various header attributes in IP, TCP, UDP, and ICMP. In addition, the script can perform text-based pattern search and concurrently process packet captures. The main Invoke-WinDump.ps1 file relies on a handful of helper functions that are defined in dependent script files: Create-WinDumpFilter.ps1, Search-Pattern.ps1, and Start-PacketJob.ps1. Invoke-WinDump can be distributed to users by sending them all of the script files. However, a better solution would be aggregating all of the files into a PowerShell module. A PowerShell module is essentially a collection of related PowerShell functionalities. There are 4 types of PowerShell modules: 1. Script Modules 2. Binary Modules 3. Manifest Modules 4. Dynamic Modules A script module is simply a file (.psm1) that contains PowerShell code—to include functions and variables. Users can then load the module which contains all of the relevant code (Microsoft, n.d.). PowerGUI is a third-party PowerShell IDE (integrated development environment) that has support for converting PowerShell code into a module. The plugin essentially creates the necessary .psm1 file on behalf of the user. Users can use the “Convert to Module...” functionality (from the File dropdown menu) to handle this task: Robert L. Adams, robert.louis.adams@gmail.com How to Leverage PowerShell to Create a User-Friendly Version of WinDump Two files are created within the newly created **Invoke-WinDump** directory: `C:\Users\[User]\Documents\WindowsPowerShell\Modules\Invoke-WinDump`: The newly created Invoke-WinDump directory can be copied/moved to `C:\Windows\System32\WindowsPowerShell\v1.0\Modules` to make it accessible to everyone. Finally, the newly created module is imported into a new PowerShell session: Robert L. Adams, robert.louis.adams@gmail.com How to Leverage PowerShell to Create a User-Friendly Version of WinDump 8.1. Invoke-WinDump in Action (Examples) The following illustrates Invoke-WinDump in action. A couple of variables are initialized and defined to point to the packet captures that will be analyzed: ```powershell $files = "C:\Tools\Captures" $skypeIRCPCAP = "C:\Tools\Captures\SkypeIRC.cap" $teardropPCAP = "C:\Tools\Captures\teardrop.cap" $nb6startupPCAP = "C:\Tools\Captures\nb6-startup.pcap" ``` **Example #1:** Using Invoke-WinDump to look for packets within `SkypeIRC.cap` with the don’t fragment (DF) flag set, and containing “freenode.net”: ```powershell Invoke-WinDump -File $skypeIRCPCAP -DF $true -Pattern "freenode.net" ``` **Results:** ```plaintext IF 192.168.1.1.53 > 192.168.1.2.2128: 12576 1/0/0 PTR sterling.freenode.net. (81) IF 192.168.1.2.2128 > 192.168.1.1.53: 12577+ A? sterling.freenode.net. (39) ``` **Example #2:** Using Invoke-WinDump to look for packets within `teardrop.cap` with the more fragment (MF) flag set: How to Leverage PowerShell to Create a User-Friendly Version of WinDump Example #3: Using Invoke-WinDump to look for packets within `nb6-startup.pcap` with only the SYN flag set: ``` Invoke-WinDump -File $nb6startupPCAP -TCPFlags "SYN" ``` Results: ``` Figure 38 - Looking for SYN Flag ``` Example #4: Using Invoke-WinDump to look for packets within a directory full of captures, with only the ACK and PUSH flags set: ``` Invoke-WinDump -Files $files -TCPFlags "ACK,PUSH" ``` Results: ``` Figure 40 - Searching Across Multiple PCAPs ``` 9. Conclusion WinDump is a packet capture and analysis tool that has been around for several years. WinDump is a quintessential security tool that will always have a spot in an analyst’s toolbox. WinDump is lightweight and powerful, allowing users to trim down large packet captures in little time. WinDump is extremely easy to use. However, using the tool for granular filtering introduces a level of complexity. Windows PowerShell is a performant scripting language that is equipped with a very simplistic syntax. Windows PowerShell can be used to automate many security tasks—and this has been the case here: PowerShell to script WinDump’s more complicated use-cases. The challenges that security professionals face today are greater than ever. It is important to work efficiently to combat the evolving threats. Automation should be a key focus in these efforts. PowerShell is extremely versatile and can be used to get the job done in a proficient and clear fashion. Security professionals should continuously look for ways to optimize their tools so that they can remain agile and effective. References Robert L. Adams, robert.louis.adams@gmail.com # Appendix A – WinDump Command-Line Options <table> <thead> <tr> <th>Option</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>-A</code></td> <td>Print each packet in ASCII.</td> </tr> <tr> <td><code>-c</code></td> <td>Exit after receiving <code>count</code> packets.</td> </tr> <tr> <td><code>-C</code></td> <td>Before writing a raw packet to a savefile, check whether the file is currently larger than <code>file_size</code>.</td> </tr> <tr> <td><code>-d</code></td> <td>Dump the compiled packet-matching code in a human readable form to standard output and stop.</td> </tr> <tr> <td><code>-dd</code></td> <td>Dump packet-matching code as a C program fragment.</td> </tr> <tr> <td><code>-ddd</code></td> <td>Dump packet-matching code as decimal numbers (preceded with a count).</td> </tr> <tr> <td><code>-D</code></td> <td>Print the list of the network interfaces available on the system and on which <code>tcpdump/WinDump</code> can capture packets.</td> </tr> <tr> <td><code>-e</code></td> <td>Print the link-level header on each dump line.</td> </tr> <tr> <td><code>-E</code></td> <td>Use <code>spi@ipaddr algo:secret</code> for decrypting IPsec ESP packets that are addressed to <code>addr</code> and contain Security Parameter Index value <code>spi</code>. This combination may be repeated with comma or newline separation.</td> </tr> <tr> <td><code>-f</code></td> <td>Print <code>foreign</code> IPv4 addresses numerically rather than symbolically.</td> </tr> <tr> <td><code>-F</code></td> <td>Use <code>file</code> as input for the filter expression. An additional expression given on the command line is ignored.</td> </tr> <tr> <td><code>-i</code></td> <td>Listen on <code>interface</code>. If unspecified, <code>tcpdump</code> searches the system interface list for the lowest numbered, configured up interface (excluding loopback).</td> </tr> <tr> <td><code>-I</code></td> <td>Make stdout line buffered.</td> </tr> <tr> <td><code>-L</code></td> <td>List the known data link types for the interface and exit.</td> </tr> <tr> <td><code>-m</code></td> <td>Load SMI MIB module definitions from file <code>module</code>.</td> </tr> <tr> <td><code>-M</code></td> <td>Use <code>secret</code> as a shared secret for validating the digests found in TCP segments with the TCP-MD5 option (RFC 2385), if present.</td> </tr> <tr> <td>Option</td> <td>Description</td> </tr> <tr> <td>--------</td> <td>-------------</td> </tr> <tr> <td>-n</td> <td>Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.</td> </tr> <tr> <td>-N</td> <td>Don't print domain name qualification of host names.</td> </tr> <tr> <td>-O</td> <td>Do not run the packet-matching code optimizer.</td> </tr> <tr> <td>-p</td> <td>Don't put the interface into promiscuous mode.</td> </tr> <tr> <td>-q</td> <td>Quick (quiet?) output. Print less protocol information so output lines are shorter.</td> </tr> <tr> <td>-R</td> <td>Assume ESP/AH packets to be based on old specification (RFC1825 to RFC1829).</td> </tr> <tr> <td>-r</td> <td>Read packets from file (which was created with the -w option). Standard input is used if file is <code>-</code>.</td> </tr> <tr> <td>-S</td> <td>Print absolute, rather than relative, TCP sequence numbers.</td> </tr> <tr> <td>-s</td> <td>Snarf snaplen bytes of data from each packet rather than the default of 68.</td> </tr> <tr> <td>-T</td> <td>Force packets selected by &quot;expression&quot; to be interpreted the specified type.</td> </tr> <tr> <td>-t</td> <td>Don't print a timestamp on each dump line.</td> </tr> <tr> <td>-tt</td> <td>Print an unformatted timestamp on each dump line.</td> </tr> <tr> <td>-ttt</td> <td>Print a delta (in micro-seconds) between current and previous line on each dump line.</td> </tr> <tr> <td>-tttt</td> <td>Print a timestamp in default format proceeded by date on each dump line.</td> </tr> <tr> <td>-u</td> <td>Print undecoded NFS handles.</td> </tr> <tr> <td>-U</td> <td>Make output saved via the -w option <code>packet-buffered</code>.</td> </tr> <tr> <td>-v</td> <td>When parsing and printing, produce (slightly more) verbose output.</td> </tr> <tr> <td>-vv</td> <td>Even more verbose output. For example, additional fields are printed from NFS reply packets, and SMB packets are fully decoded.</td> </tr> <tr> <td>-vvv</td> <td>Even more verbose output. For example, telnet SB ... SE options are printed in full. With -XTelnet options are printed in hex as well.</td> </tr> <tr> <td>-w</td> <td>Write the raw packets to file rather than parsing and printing them out.</td> </tr> <tr> <td>-W</td> <td>Used in conjunction with the -C option, this will limit the number of files created to the</td> </tr> <tr> <td>Option</td> <td>Description</td> </tr> <tr> <td>--------</td> <td>-------------</td> </tr> <tr> <td>-x</td> <td>When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex.</td> </tr> <tr> <td>-xx</td> <td>When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, <strong>including</strong> its link level header, in hex.</td> </tr> <tr> <td>-X</td> <td>When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex and ASCII.</td> </tr> <tr> <td>-XX</td> <td>When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, <strong>including</strong> its link level header, in hex and ASCII.</td> </tr> <tr> <td>-y</td> <td>Set the data link type to use while capturing packets to <code>datalinktype</code>.</td> </tr> <tr> <td>-Z</td> <td>Drops privileges (if root) and changes user ID to <code>user</code> and the group ID to the primary group of <code>user</code>.</td> </tr> </tbody> </table> Appendix B – TCP, UDP, and ICMP Illustrations Figure 42 – TCP Header (NMAP, n.d.) <table> <thead> <tr> <th>TCP Header Attribute</th> <th>Byte Offset</th> <th>Size</th> <th>Primitive</th> </tr> </thead> <tbody> <tr> <td>Source Port</td> <td>0</td> <td>2 bytes</td> <td>src port</td> </tr> <tr> <td>Destination Port</td> <td>2</td> <td>2 bytes</td> <td>dst port</td> </tr> <tr> <td>Sequence Number</td> <td>4</td> <td>4 bytes</td> <td>n/a</td> </tr> <tr> <td>Acknowledgment Number</td> <td>8</td> <td>4 bytes</td> <td>n/a</td> </tr> <tr> <td>Data Offset</td> <td>12</td> <td>4 bits</td> <td>n/a</td> </tr> <tr> <td>Reserved</td> <td>12</td> <td>4 bits</td> <td>n/a</td> </tr> <tr> <td>Flags</td> <td>13</td> <td>1 byte</td> <td>n/a</td> </tr> <tr> <td>Window Size</td> <td>14</td> <td>2 bytes</td> <td>n/a</td> </tr> <tr> <td>Checksum</td> <td>16</td> <td>2 bytes</td> <td>n/a</td> </tr> <tr> <td>Urgent Pointer</td> <td>18</td> <td>2 bytes</td> <td>n/a</td> </tr> </tbody> </table> Table 2 - TCP Header – Mapping NMAP Primitives How to Leverage PowerShell to Create a User-Friendly Version of WinDump | 33 Figure 42 - UDP Header (NMAP, n.d.) <table> <thead> <tr> <th>Attribute</th> <th>Byte Offset</th> <th>Size</th> <th>Primitive</th> </tr> </thead> <tbody> <tr> <td>Source Port</td> <td>0</td> <td>2 bytes</td> <td>src port</td> </tr> <tr> <td>Destination Port</td> <td>2</td> <td>2 bytes</td> <td>dst port</td> </tr> <tr> <td>Length</td> <td>4</td> <td>2 bytes</td> <td>n/a</td> </tr> <tr> <td>Checksum</td> <td>6</td> <td>2 bytes</td> <td>n/a</td> </tr> </tbody> </table> Table 2 - UDP Header – Mapping NMAP Primitives Figure 43 - ICMP Header (NMAP, n.d.) <table> <thead> <tr> <th>ICMP Header Attribute</th> <th>Byte Offset</th> <th>Size</th> <th>Primitive</th> </tr> </thead> <tbody> <tr> <td>Type</td> <td>0</td> <td>1 byte</td> <td>n/a</td> </tr> <tr> <td>Code</td> <td>1</td> <td>1 byte</td> <td>n/a</td> </tr> <tr> <td>Checksum</td> <td>2</td> <td>2 bytes</td> <td>n/a</td> </tr> </tbody> </table> Table 3 - ICMP Header – Mapping NMAP Primitives Robert L. Adams, robert.louis.adams@gmail.com # Upcoming Training <table> <thead> <tr> <th>Event</th> <th>Location</th> <th>Dates</th> <th>Type</th> </tr> </thead> <tbody> <tr> <td>SANS 2020</td> <td>Orlando, FL</td> <td>Apr 03, 2020 - Apr 10, 2020</td> <td>CyberCon</td> </tr> <tr> <td>SANS London April 2020</td> <td>London, United Kingdom</td> <td>Apr 20, 2020 - Apr 25, 2020</td> <td>CyberCon</td> </tr> <tr> <td>SANS Baltimore Spring 2020</td> <td>Baltimore, MD</td> <td>Apr 27, 2020 - May 02, 2020</td> <td>CyberCon</td> </tr> <tr> <td>SANS Amsterdam May 2020</td> <td>Amsterdam, Netherlands</td> <td>May 11, 2020 - May 18, 2020</td> <td>CyberCon</td> </tr> <tr> <td>SANS Security West 2020</td> <td>San Diego, CA</td> <td>May 11, 2020 - May 16, 2020</td> <td>CyberCon</td> </tr> <tr> <td>SANS San Antonio 2020</td> <td>San Antonio, TX</td> <td>May 17, 2020 - May 22, 2020</td> <td>CyberCon</td> </tr> <tr> <td>SANS Las Vegas Summer 2020</td> <td>Las Vegas, NV</td> <td>Jun 08, 2020 - Jun 13, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Munich July 2020</td> <td>Munich, Germany</td> <td>Jul 06, 2020 - Jul 11, 2020</td> <td>Live Event</td> </tr> <tr> <td>Rocky Mountain Summer 2020 - SEC503: Intrusion Detection In-Depth</td> <td>Denver, CO</td> <td>Jul 20, 2020 - Jul 25, 2020</td> <td>vLive</td> </tr> <tr> <td>SANS Columbia 2020</td> <td>Columbia, MD</td> <td>Jul 20, 2020 - Jul 25, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Rocky Mountain Summer 2020</td> <td>Denver, CO</td> <td>Jul 20, 2020 - Jul 25, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS vLive - SEC503: Intrusion Detection In-Depth</td> <td>SEC503 - 202008,</td> <td>Aug 10, 2020 - Sep 16, 2020</td> <td>vLive</td> </tr> <tr> <td>SANS Amsterdam August 2020</td> <td>Amsterdam, Netherlands</td> <td>Aug 17, 2020 - Aug 22, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Melbourne 2020</td> <td>Melbourne, Australia</td> <td>Aug 17, 2020 - Aug 22, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Virginia Beach 2020</td> <td>Virginia Beach, VA</td> <td>Aug 24, 2020 - Sep 04, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS New York City Summer 2020</td> <td>New York City, NY</td> <td>Aug 30, 2020 - Sep 04, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS London September 2020</td> <td>London, United Kingdom</td> <td>Sep 07, 2020 - Sep 12, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Munich September 2020</td> <td>Munich, Germany</td> <td>Sep 14, 2020 - Sep 19, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Network Security 2020</td> <td>Las Vegas, NV</td> <td>Sep 20, 2020 - Sep 27, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS Northern VA - Reston Fall 2020</td> <td>Reston, VA</td> <td>Sep 28, 2020 - Oct 03, 2020</td> <td>Live Event</td> </tr> <tr> <td>SANS OnDemand</td> <td>Online</td> <td>Anytime</td> <td>Self Paced</td> </tr> <tr> <td>SANS SelfStudy</td> <td>Books &amp; MP3s Only</td> <td>Anytime</td> <td>Self Paced</td> </tr> </tbody> </table>
{"Source-Url": "https://www.giac.org/paper/gcia/10994/leverage-powershell-create-user-friendly-version-windump/148647", "len_cl100k_base": 12152, "olmocr-version": "0.1.53", "pdf-total-pages": 35, "total-fallback-pages": 0, "total-input-tokens": 65458, "total-output-tokens": 13468, "length": "2e13", "weborganizer": {"__label__adult": 0.0004091262817382813, "__label__art_design": 0.0005030632019042969, "__label__crime_law": 0.00157928466796875, "__label__education_jobs": 0.00347137451171875, "__label__entertainment": 0.00017464160919189453, "__label__fashion_beauty": 0.0001807212829589844, "__label__finance_business": 0.00044083595275878906, "__label__food_dining": 0.00027751922607421875, "__label__games": 0.0009140968322753906, "__label__hardware": 0.0014934539794921875, "__label__health": 0.00034809112548828125, "__label__history": 0.00030422210693359375, "__label__home_hobbies": 0.00013840198516845703, "__label__industrial": 0.0006833076477050781, "__label__literature": 0.00034880638122558594, "__label__politics": 0.0004279613494873047, "__label__religion": 0.00039839744567871094, "__label__science_tech": 0.072021484375, "__label__social_life": 0.0002112388610839844, "__label__software": 0.087890625, "__label__software_dev": 0.8271484375, "__label__sports_fitness": 0.00023066997528076172, "__label__transportation": 0.00029468536376953125, "__label__travel": 0.00017249584197998047}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 47075, 0.02434]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 47075, 0.29569]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 47075, 0.77897]], "google_gemma-3-12b-it_contains_pii": [[0, 163, false], [163, 1130, null], [1130, 3147, null], [3147, 5152, null], [5152, 7209, null], [7209, 8826, null], [8826, 10418, null], [10418, 11345, null], [11345, 13290, null], [13290, 14899, null], [14899, 15615, null], [15615, 17043, null], [17043, 18382, null], [18382, 19595, null], [19595, 20590, null], [20590, 21745, null], [21745, 23244, null], [23244, 24619, null], [24619, 25831, null], [25831, 27278, null], [27278, 28635, null], [28635, 30188, null], [30188, 31604, null], [31604, 32104, null], [32104, 33123, null], [33123, 33668, null], [33668, 34769, null], [34769, 36860, null], [36860, 37228, null], [37228, 38888, null], [38888, 40745, null], [40745, 41676, null], [41676, 42552, null], [42552, 43515, null], [43515, 47075, null]], "google_gemma-3-12b-it_is_public_document": [[0, 163, true], [163, 1130, null], [1130, 3147, null], [3147, 5152, null], [5152, 7209, null], [7209, 8826, null], [8826, 10418, null], [10418, 11345, null], [11345, 13290, null], [13290, 14899, null], [14899, 15615, null], [15615, 17043, null], [17043, 18382, null], [18382, 19595, null], [19595, 20590, null], [20590, 21745, null], [21745, 23244, null], [23244, 24619, null], [24619, 25831, null], [25831, 27278, null], [27278, 28635, null], [28635, 30188, null], [30188, 31604, null], [31604, 32104, null], [32104, 33123, null], [33123, 33668, null], [33668, 34769, null], [34769, 36860, null], [36860, 37228, null], [37228, 38888, null], [38888, 40745, null], [40745, 41676, null], [41676, 42552, null], [42552, 43515, null], [43515, 47075, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 47075, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 47075, null]], "pdf_page_numbers": [[0, 163, 1], [163, 1130, 2], [1130, 3147, 3], [3147, 5152, 4], [5152, 7209, 5], [7209, 8826, 6], [8826, 10418, 7], [10418, 11345, 8], [11345, 13290, 9], [13290, 14899, 10], [14899, 15615, 11], [15615, 17043, 12], [17043, 18382, 13], [18382, 19595, 14], [19595, 20590, 15], [20590, 21745, 16], [21745, 23244, 17], [23244, 24619, 18], [24619, 25831, 19], [25831, 27278, 20], [27278, 28635, 21], [28635, 30188, 22], [30188, 31604, 23], [31604, 32104, 24], [32104, 33123, 25], [33123, 33668, 26], [33668, 34769, 27], [34769, 36860, 28], [36860, 37228, 29], [37228, 38888, 30], [38888, 40745, 31], [40745, 41676, 32], [41676, 42552, 33], [42552, 43515, 34], [43515, 47075, 35]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 47075, 0.23592]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
366a46f02415b1ca8819fe2db949b2c8707765e6
Optimizing Multiset Metagrammars. Formal Definitions Igor Sheremet¹ and Igor Zhukov² ¹ Financial University under the Government of Russian Federation, Moscow, Russian Federation ² National Research Nuclear University Moscow Engineering Physical Institute, Moscow, Russian Federation ¹iasheremet@fa.ru, ²i.zhukov@inbox.ru ABSTRACT A multiset-based approach to optimization problems formalizing and solving is considered. Optimizing multiset metagrammars (OMMG) are described as specific knowledge representation model developed precisely for this purposes. OMMG provide convergence of classical optimization theory and modern knowledge engineering combining the best features of mathematical and logical programming. Paper is dedicated to the formal definition of OMMG syntax and semantics as well as to the multigrammatical representation of the most well-known classical optimization problems. Keywords: Multisets, Multiset grammars and metagrammars, Optimizing multiset metagrammars, Multigrammatical representation of optimization problems, Unconventional programming paradigms, Knowledge representation, Mathematical programming, Logical programming. 1. INTRODUCTION Multisets (MS) for many years are one of the most interesting and promising mathematical objects which application to various areas of modern computer science is investigated thoroughly [1-13]. One of the most useful directions of multisets processing theory and technologies development is rule-based multiset programming paradigm [14-16], which ideology is exploited widely in DNA and membrane computing [17-19] as well as in Gamma-like programming languages [10,20,21], and chemical programming, which is operating macrosets, or generalized multisets [22-25]. As for the state of the art practical applications, the most valuable are constraint multiset grammars (CMSG) developed mainly for visual objects (first of all handwritten symbols) recognition [26-28]. CSMG inherit key features of constraints logical programming [29-31], and are convenient tool for the description of planar objects with complicated recursive structure. Author’s contribution to the area considered are so called optimizing multiset metagrammars (OMMG) [32, 33] developed for problem solving in system analysis and optimization area (first of all, analysis and construction of the large-scale sociotechnical systems like business structures, manufacturing facilities, macroeconomic objects etc.) From the practical point of view OMMG are specific knowledge representation model providing convergence of classical optimization theory and modern knowledge engineering. OMMG integrate basic features of mathematical programming (optimal solutions search in solutions space which is strictly defined by goal functions and constraints) and logical programming (natural and easily modified top-down recursive representation of complex objects and processed as well as systems operation logic). Presented paper is dedicated to further development of OMMG pragmatics by constructing multigrammatical representation (formulation) of classical optimization problems. The first part of the paper contains formal definitions of OMMG family and its various subsets, while main content of the second part is mentioned representations description and investigation in order to establish some standard techniques useful for practical problems solving and OMMG application hardware implementation. 2. BASIC NOTIONS AND DEFINITIONS Theory of multisets background is notion of multiset which is understood mainly as set of so called multiojbjects composed of indistinguishable elements (objects). Multiojbject containing \( n \) objects of type \( a \) is denoted as \( n \cdot a \), where \( n \) is called multiplicity of object \( a \) (\( \cdot \) is composing symbol). Record \[ \nu = \{n_1 \cdot a_1, \ldots, n_m \cdot a_m\} \tag{1} \] means that multiset \( \nu \) contains \( n_1 \) objects of type \( a_1 \), \ldots, \( n_m \) objects of type \( a_m \). We shall use one and the same symbol \( \in \) for denotation of object and multiojbject entering multiset \( \nu \), so \( a_i \in \nu \) and \( n_i \cdot a_i \in \nu \) means that object \( a_i \) enters \( v \) as well as multiobject \( n_1 \cdot a_i \). From the substantial point of view set \( \{a_1, ..., a_m\} \) and multiset \( \{1 \cdot a_1, ..., 1 \cdot a_m\} \) are equivalent as well as object \( a \) and multiobject \( 1 \cdot a \). Empty multiset and empty set are denoted as \( \{\} \). If object \( a \) multiplicity is zero, it is equivalent to the absence of \( a \) in the multiset \( v \), what is recorded, as usual, \( a \not\in v \). We shall say that multiset \[ \begin{align*} v &= \{n_1 \cdot a_1, ..., n_m \cdot a_m\} \\ v' &= \{n'_1 \cdot a'_1, ..., n'_m \cdot a'_m\} \end{align*} \] is included to multiset \[ \begin{align*} v' &= \{n'_1 \cdot a'_1, ..., n'_m \cdot a'_m\} \end{align*} \] what is denoted as \( v \subseteq v' \), if \[ \left( \forall \ n \cdot a \in v \right) \left( \exists n' \cdot a \in v' \right) \ n \leq n', \] and \( v \) is strictly included to \( v' \), what is denoted \( v \varsubsetneq v' \), when \( v \subseteq v' \) and \( v \neq v' \). We shall use small "a" with lower indices as well as small "a", "b" etc. for objects denotation; multisets will be denoted by small "v" with or without indices. **Example 1.** Multiset \( v = \{3 \cdot a, 4 \cdot b, 1 \cdot c\} \) is strictly included to multiset \( v' = \{4 \cdot a, 4 \cdot b, 1 \cdot c, 1 \cdot d\} \). There are five basic operations on multisets: addition, subtraction, multiplication by integer number, join and intersection. Result of \( v \) and \( v' \) multisets addition denoted as bold symbol "+" is multiset \[ \begin{align*} v + v' &= (\bigcup_{a \in \{a_1, ..., a_m\}} \{n \cdot a\}) \cup \bigcup_{a \in \{a'_1, ..., a'_m\}} \{n' \cdot a\} \end{align*} \] result of \( v \) subtraction from \( v' \) denoted as bold symbol "-" is defined as follows: \[ \begin{align*} v - v' &= \bigcup_{a \in \{a_1, ..., a_m\}} \{n \cdot a\} \cup \bigcup_{a \in \{a'_1, ..., a'_m\}} \{n' \cdot a\} \end{align*} \] result of multiplicity multiplication by integer number, what is denoted as \( v \ast n \), is multiset: \[ \begin{align*} v \ast n &= (\bigcup_{a \in \{a_1, ..., a_m\}} \{n \cdot a\}) \cup \bigcup_{a \in \{a'_1, ..., a'_m\}} \{n' \cdot a\} \end{align*} \] result of join and intersection denoted as bold symbol "\( \cup \)" and "\( \cap \)" is multiset: \[ \begin{align*} v \cup v' &= (\bigcup_{a \in \{a_1, ..., a_m\}} \{n \cdot a\}) \cup (\bigcup_{a \in \{a'_1, ..., a'_m\}} \{n' \cdot a\}) \end{align*} \] result of multiplication by integer number, what is denoted as \( v \cdot n \), is multiset: \[ \begin{align*} v \cdot n &= (\bigcup_{a \in \{a_1, ..., a_m\}} \{n \cdot a\}) \cup (\bigcup_{a \in \{a'_1, ..., a'_m\}} \{n' \cdot a\}) \end{align*} \] Multisets may be used for generating another multisets by means of multiset grammars. By analogy with classical grammars operating on strings of symbols \([34,35]\), we shall define multigrammar as a couple \[ S = \langle \nu_0, R \rangle, \] where \(\nu_0\) is a multiset called kernel, while \(R\) called scheme is a finite set of so-called rules which are used for generation of new multisets from already generated. Rule has form \[ v \rightarrow v', \] where \(v\) and \(v'\), called left and right parts of the rule correspondingly, are multisets, and \(v \neq \{\emptyset\}\). Semantics of rule is defined as follows. Let \(\overline{v}\) be a multiset. We shall say that rule (11) is applicable to \(\overline{v}\), if \[ v \subseteq \overline{v}. \] Then result of application is a multiset \[ \overline{v}' = \overline{v} \cdot v + v', \] (13) and is strictly defined as follows: \[ v_0 \quad \overset{R}{\Rightarrow} \quad v, \] Set of multisets generated by MG \(S = \langle \nu_0, R \rangle\) is denoted as \[ V_S = \{v \mid v_0 \overset{R}{\Rightarrow} v\}. \] (17) MS \(v\) is called terminal multiset (TMS) if there is no one rule \(r \in R\) which is applicable to \(v\). Set of terminal sets (STMS) will be denoted \(V_T\). Iterative representation of MG semantics, i.e. SMS \(V_S\) generated by MG \(S = \langle \nu_0, R \rangle\), is following: \[ V_S(0) = \{v_0\}, \] (18) \[ V_S(i+1) = V_S(i) \cup \left( \bigcup_{r \in R} \bigcup_{\overline{v} \in V_S(i)} \pi(\overline{v}, r) \right), \] (19) \[ V_S = V_S(\infty), \] (20) where \[ \pi(\overline{v}, v \rightarrow v') = \begin{cases} \{\overline{v} \cdot v + v'\}, & \text{if } v \subseteq \overline{v}, \\ \{\emptyset\}, & \text{otherwise}. \end{cases} \] (21) As seen, (21) implements application of rule \(v \rightarrow v'\) as defined by (12) – (13). SMS \(V_S\) is fixed point of the described process, i.e. \(V_S = V_S(i)\) with \(i \rightarrow \infty\). If for some finite \(i\) \(V_S(i) = V_S(i+1)\), then \(V_S = V_S(i)\), and \(V_S\) is also finite. For SMS \(v\) \[ \pi(v, r) = \{\emptyset\} \] (22) for all rules \(r \in R\), i.e. no one multiset may be generated from TMS, and \[ \overline{V}_S = \{v \mid v \in V_S \& (\forall r \in R) \pi(v, r) = \{\emptyset\}\}. \] By analogy with classical string-generating grammars, multiset grammars may be general, or context-sensitive (CS), and context-free (CF). In the last, left parts of all rules \(r \in R\) are multisets of a form \(\{1 \cdot a\}\) while rules in CS MG contain arbitrary left and right parts (the only limitation already mentioned is that left part must be non-empty). **Example 3.** Consider context-free multigrammar \[ S = \{1 \cdot a, 2 \cdot b\}, \{r_1, r_2, r_3, r_4\} >, \] where \[ r_1 = \{1 \cdot a\} \rightarrow \{3 \cdot b, 2 \cdot c\}, \] \[ r_2 = \{1 \cdot a\} \rightarrow \{1 \cdot b, 3 \cdot c\}, \] \[ r_3 = \{1 \cdot b\} \rightarrow \{2 \cdot c\}, \] \[ r_4 = \{1 \cdot b\} \rightarrow \{1 \cdot c\}, \] According to (18) – (19), there are following generation chains: \[ \{1 \cdot a, 2 \cdot b\} \rightarrow [5 \cdot b, 2 \cdot c] \rightarrow [7 \cdot c], \] \[ \{1 \cdot a, 2 \cdot b\} \rightarrow [3 \cdot b, 3 \cdot c] \rightarrow [9 \cdot c], \] \[ \{1 \cdot a, 2 \cdot b\} \rightarrow [3 \cdot b, 3 \cdot c] \rightarrow [6 \cdot c], \] and \[ V_S = \{1 \cdot b, 2 \cdot c\}, \{5 \cdot b, 2 \cdot c\}, \{3 \cdot b, 3 \cdot c\}, \{6 \cdot c\}, \{7 \cdot c\}, \{9 \cdot c\}, \{12 \cdot c\}\]. **3. UNITARY MULTIGRAMMARS** One practice-oriented and useful modification of CF multigrammars is called unitary multigrammars (UMG) having slightly different syntax and semantics of basic constructions. UMG is couple \(S = \langle a_0, R \rangle\), where \(a_0\) is called title object, and \(R\) is, as higher, scheme, being here set of so-called unitary rules (UR) having form \[ a \rightarrow n_1 \cdot a_1, ..., n_m \cdot a_m, \] (24) where \(a\) is called head while unordered list of multiobjects \(n_1 \cdot a_1, ..., n_m \cdot a_m\) is called body of the unitary rule ("unordered" means all permutations of \(n_1 \cdot a_1, ..., n_m \cdot a_m\) represent one and the same body, or \(n_1 \cdot a_1, ..., n_m \cdot a_m\) is interpreted as multiset \(\{n_1 \cdot a_1, ..., n_m \cdot a_m\}\)). Application of unitary rule (24) to multiset \(\overline{v}\) containing multiobject \(n \cdot a\) is, as higher, called generation step, and is defined by the following equality not contradicting to (12) – (13) and (21): \[ \vec{v}' = \vec{v} \cdot \{n \cdot a\} \ast n \cdot \{n_1 \cdot a_1, ..., n_m \cdot a_m\}, \] (25) what corresponds to \(n\) times application of CF rule \(\{1 \cdot a\} \rightarrow \{n_1 \cdot a_1, ..., n_m \cdot a_m\}\). (26) However, record is not the only difference between context-free and unitary multigrams. Being applied to practical problems, unitary rules are most frequently interpreted as descriptions of complex objects through their elements (which, in turn, may be decomposed, and so on until non-divided entities); \(24\) means that object (of type \(a\)) consists of \(n_1\) objects (of type) \(a_1, ..., n_m\) objects (of type) \(a_m\). So if there are \(m > 1\) alternative ways of object \(a\) structuring – for example, along with \(24\) there is one more UR with head \(a\) – \[ a \rightarrow n_1' \cdot a_1', ..., n_m' \cdot a_m', \] (27) and we apply unitary rule \(24\) once in the generation chain, then for all following generation steps, if they occur, we shall use the same UR \(24\). For short, object \(a\) is postulated constant within all generation chain. As seen, UMG semantics is based on “variable-like” interpretation of objects, which differ by this feature from non-terminals in classical CF string-generating grammars, which semantics allows arbitrary alternatives of any non-terminal substitution at every generation step where this non-terminal may be replaced. Iterative representation of UMG \(S = a_0, R >\) semantics is following: \[ X_{(i)} = \{\{1 \cdot a_0\}, R\} >, \] (28) \[ X_{(i+1)} = \bigcup_{\vec{v}, R > \in X_{(i)}} \{\vec{v}, R, r\} \in R, \] (29) \[ V_S = \{\vec{v} | \vec{v} < \vec{v}, R > \in X_{(0)}\}, \] (30) where \[ \vec{v}, \vec{R}, r = \{\vec{v} \ast \{n \cdot a\} \ast n \ast \{n_1 \cdot a_1, ..., n_m \cdot a_m, \{\{0\}\} \text{ otherwise,} \] (31) \[ alt(a \rightarrow w) = \{a \rightarrow w' | a \rightarrow w' \in R \ast w' \neq w\}. \] (32) where \(w\) and \(w'\) designate \(n_1 \cdot a_1, ..., n_m \cdot a_m\) and \(n_1' \cdot a_1', ..., n_m' \cdot a_m'\) correspondingly, and \(r\) is unitary rule \(a \rightarrow n_1 \cdot a_1, ..., n_m \cdot a_m\). Inequality \(w \neq w'\) in \(32\) is interpreted as if \(w\) and \(w'\) were multisets. In \(28 - 30\) \(X_{(i)}\) is set of couples of the form \(\vec{v}, \vec{R}\), where \(\vec{v}\) is multiset created by already executed generation steps, and \(\vec{R}\) is subset of \(R\) scheme including all unitary rules which may be applied to \(\vec{v}\) at the next such step. As seen, difference between \(21\) and \(31\) is that in the last case \(a \rightarrow w\) application to \(\vec{v}\) implemented by \(\vec{v}\) results not only in substitution of \(n\) objects \(a\) having place in \(\vec{v}\) by \(n \times n_1\) objects \(a_1, ..., n \times n_m\) objects \(a_m\), but also in elimination from \(\vec{R}\), which is current \(\vec{R}\) subset of applicable unitary rules, all URs \(a \rightarrow w'\) with the same head \(a\) and alternative bodies \(w' \neq w\). This prevents from applying \(a \rightarrow w'\) in future generation steps, that strictly corresponds to URs semantics verbally described higher; so object \(a\) will be “detailed” by the same only UR \(a \rightarrow w\), as at the executed step. As seen, result of function \(alt\) application is set of all URs with the same head \(a\) and bodies different from \(w\) having place in the argument \(a \rightarrow w\). Lower we shall designate by \(\beta(v)\) set of all objects having place in multiset \(v\) (it is called multiset basis \([11, 12]\)): \[ \beta(v) = \{a \mid a \in v\}. \] (33) By \(A_2\) we shall designate set of all objects having place in UMG \(S = a_0, R >\), while by \(A_2\) – set of all terminal objects having place in \(S\), i.e. objects which are not heads of unitary rules \(r \in R\) and present only in URs bodies. As seen, \[ A_2 \subseteq A_2. \] (34) Multiset \(v \in V_2\) such that all objects of \(v\) are terminal is, as higher, called terminal multiset; this notion fully corresponds to the defined one in relation to multigrams. Formally, \[ V_2 = \{v | v \in V_2 \ast \beta(v) \subseteq A_2\}. \] (35) Let us present an example illustrating main semantical feature of unitary multigrams in comparison with context-free multigrams. **Example 4.** Consider UMG \(S = a_0, R >\), where \(R\) contains following unitary rules (recorded for unambiguity in angle brackets): \[ r_1 = (a \rightarrow 2 \cdot b, 3 \cdot c), \] \[ r_2 = (a \rightarrow 3 \cdot b, 2 \cdot c), \] \[ r_3 = (b \rightarrow 1 \cdot d), \] \[ r_4 = (b \rightarrow 2 \cdot d), \] \[ r_5 = (c \rightarrow 1 \cdot b, 2 \cdot d), \] \[ r_6 = (c \rightarrow 3 \cdot b, 1 \cdot d). \] There are following generation chains: \[ a \Rightarrow \{2 \cdot b, 3 \cdot c\} \Rightarrow \{3 \cdot c, 2 \cdot d\} \Rightarrow \{3 \cdot b, 6 \cdot d\} \Rightarrow \{9 \cdot d\}, \] \[ a \Rightarrow \{2 \cdot b, 3 \cdot c\} \Rightarrow \{3 \cdot c, 2 \cdot d\} \Rightarrow \{9 \cdot b, 3 \cdot d\} \Rightarrow \{12 \cdot d\}, \] \[ a \Rightarrow \{2 \cdot b, 3 \cdot c\} \Rightarrow \{3 \cdot c, 4 \cdot d\} \Rightarrow \{3 \cdot b, 10 \cdot d\} \Rightarrow \{16 \cdot d\}, \] \[ a \Rightarrow \{2 \cdot b, 3 \cdot c\} \Rightarrow \{3 \cdot c, 4 \cdot d\} \Rightarrow \{9 \cdot b, 7 \cdot d\} \Rightarrow \{25 \cdot d\}, \] etc. (generation chains beginning from \(r_2\) unitary rule may be constructed by the concerned reader independently). As seen, there is no one generation chain which contains \(r_3\) and \(r_4\) simultaneously: application of \(r_3\) at the second generation step excludes application of \(r_4\) at the fourth one, and vice versa. **4. FILTERS AND FILTERING UNITARY MULTIGRAMMARS** Filters are constructions which provide selection of subsets of sets of generated TMS. One may consider filters as query language with special features used for selection of solutions from solutions space. Filters consist from atomary constructions called conditions. There are two types of conditions: boundary and optimizing. The first, in turn, may be elementary and chain. Elementary boundary condition (EBC) may have form $apn$, $npa$ and $apa'$, where $a$ and $a'$ are objects, $n$ is integer number, and $\rho \in \{<,=,\leq\}$ is symbol of relation. EBC semantics is following. Let $V$ be set of multisets. Multiset $v \in V$ satisfies EBC $\bar{npa}$, if $n \cdot a \in v$, and $\bar{npn}$ is true. Similarly, $v \in V$ satisfies EBC $apn$, if $npn$ is true. And, at last, $v \in V$ satisfies EBC $apa'$, if $\bar{a} \cdot a \in v$, $\bar{a} \cdot a' \in v$ and $\bar{npn}$ is true. **Example 5.** Let $V = \{v_1, v_2, v_3\}$, where \[ \begin{align*} v_1 &= \{3 \cdot a, 2 \cdot b, 4 \cdot c\}, \\ v_2 &= \{1 \cdot a, 3 \cdot b\}, \\ v_3 &= \{1 \cdot b, 5 \cdot c\}. \end{align*} \] Then result of application of EBC $a < 2$ to $v$ is set $\{v_2, v_3\}$ (note, that $v_3$ is included to this set because, as said higher, absence of object in the multiset is equivalent to zero multiplicity of this object). If EBC is $b > 3$, then result is empty set, if $c = 5$, then result is $\{v_3\}$; if $b > c$, then result is $\{v_2\}$. Optimizing condition has form $a = opt$, where $a$ is object, and $opt \in \{min, max\}$. Multiset $v \in V$ satisfies optimizing condition $a = min$ if for every $v' \in V$, such that $v' \neq v$, multiplicity $n$ in multiset $n \cdot a \in v$ is not less than multiplicity $n'$ in multiset $n' \cdot a \in v'$, i.e. $n \geq n'$. As higher, case $a \not\in v$ ($a' \not\in v$) is equivalent to $0 \cdot a \in v (0 \cdot a' \in v')$. **Example 6.** Let $V$ be the same as in the previous example, and optimizing condition is $a = max$. Then result of its application to $v$ is set $\{v_1\}$. If optimizing condition is $b = min$, then result is $\{v_3\}$. Filter $F$ is set of conditions and may be represented as join of boundary $F_\varnothing$ and optimizing $F_{opt}$ subfilters: \[ F = F_\varnothing \cup F_{opt}, \] where $F_\varnothing$ is set of EBC and $F_{opt}$ is set of optimizing conditions. Result of filtration of MS $V$ by filter $F$ is denoted $V \downarrow F$ and is defined as follows: \[ V \downarrow F = (V \downarrow F_\varnothing) \downarrow F_{opt}, \] i.e. $V$ is filtered by boundary subfilter, and obtained result is filtered by optimizing subfilter: \[ F_\varnothing = \{bc_1, ..., bc_k\}, \quad F_{opt} = \{opt_1, ..., opt_l\}, \] \[ v \downarrow F_\varnothing = \bigcap_{i=1}^k (v \downarrow \{bc_i\}) = v', \] \[ v' \downarrow F_{opt} = \bigcap_{j=1}^l (v' \downarrow \{opt_j\}). \] **Example 7.** Let $V$ is the same as in two previous examples, and filter $F = \{b > 1, b \leq 3, c = min\}$. Then \[ V \downarrow F = (V \downarrow F_\varnothing) \downarrow F_{opt} = (V \downarrow \{b > 1, b \leq 3\}) \downarrow \{c = min\} = ([v_1, v_2] \cap [v_1, v_2, v_3]) \downarrow \{c = min\} = [v_1, v_2] \downarrow \{c = min\} = [v_2], \] because $c \not\in v_2$, so object $c$ multiplicity is zero. Note that due to commutativity of set-theoretical join and intersection operations filtration inside subfilters may be executed in arbitrary order. Let us now define syntax and semantics of so called filtering multigrams (FMG) and filtering unitary multigrams (FUMG). FMG $S = \langle v_0, R, F >$, where $v_0$ and $R$ have the same sense as in MG, and $F$ is filter, defines set of terminal multisets in the following way: \[ V_s = V_{s'} \downarrow F, \] where $S' = \langle v_0, R >$, i.e. STMS, generated by MG $S'$, is filtered by $F$, and result is defined as generated by FMG $S$. Similarly, FUMG $S = \langle a_0, R, F >$, where $a_0$ and $R$ have the same sense as in UMG, and $F$ is filter, defines set of terminal multisets as follows: \[ V_s = V_{s'} \downarrow F, \] where $S' = \langle a_0, R >$. **Example 8.** Let $S = \langle a, R, F >$, where $R = \{r_1, r_2, r_3, r_4\}$, and \[ \begin{align*} r_1 &= \langle a \rightarrow 3 \cdot b, 2 \cdot c >, \\ r_2 &= \langle a \rightarrow 2 \cdot b, 5 \cdot c >, \\ r_3 &= \langle b \rightarrow 2 \cdot c, 1 \cdot d >, \\ r_4 &= \langle b \rightarrow 1 \cdot c, 3 \cdot d >, \end{align*} \] and $F = \{c \leq 8, d > 3, c = max, d = min\}$. Then $S' = \langle a, R >,$ \[ \begin{align*} V_{s'} &= \{8 \cdot c, 3 \cdot d, \{5 \cdot c, 9 \cdot d\}, \{9 \cdot c, 2 \cdot d\}, \{7 \cdot c, 6 \cdot d\}\}, \\ V_s &= V_{s'} \downarrow F = (V_{s'} \downarrow \{c \leq 8, d > 2\}) \downarrow \{c = max, d = min\} = \\ &= \{8 \cdot c, 3 \cdot d\}. \end{align*} \] Type equation here. There may be more sophisticated boundary subfilters containing not only elementary but also so called chain boundary condition (CBC). Each CBC is constructed from EBC by writing them sequentially: \[ e_1 \rho_1 e_2 \rho_2 e_3 ... e_i \rho_i e_{i+1} ... e_m \rho_m e_{m+1}, \] where $e_1, ..., e_{m+1}$ are objects or non-negative integers while $\rho_1, ..., \rho_m$ are symbols of relations ($<, =, \leq$). CBC semantics is defined as follows. CBC (44) is replaced by boundary filter \[ \{e_1 \rho_1 e_2, e_2 \rho_2 e_3, ..., e_i \rho_i e_{i+1}, ..., e_m \rho_m e_{m+1}\}. \] 5. UNITARY MULTISET METAGRAMMARS Unitary multigrams are useful for the description of objects which structure variants number is relatively little, and this variety may be simply reflected by explicit representation of alternative structures as unitary rules with the same head and different bodies. But in practically interesting cases this number may be such that explicit representation of sets of alternatives for all objects, which structure if a priori unknown, is really impossible. So there is necessary such UMG extension which would allow compact description of arbitrary number of alternative variants of object structure. This extension is called unitary multiset metagrammars (multimetagrammars), or, for short, UMMG. Unitary multiset metagrammar \( S \) is triple \(< a_0, R, F >\), where \( a_0 \) and \( F \) are, as higher, title object and filter correspondingly, while \( R \) is scheme containing unitary rules and so called unitary metarules (UMR). Unitary metarule has form \[ a \rightarrow \mu_1 \cdot a_1, ..., \mu_m \cdot a_m. \] (46) where \( \mu_i \) is positive integer number, as in sections 2–3, or variable \( \gamma \in \Gamma \), where \( \Gamma \) is universum of variables. When \( \mu_i \) is variable then it is called multiplicity-variable (MV). As seen, unitary rule is partial case of unitary metarule, which multiplicities \( \mu_1, ..., \mu_m \) having place in (46) are constants. As in (24), object \( a \) is called head, while unordered (in the same sense as in UR definition) list \( \mu_1 \cdot a_1, ..., \mu_m \cdot a_m \) – body of UMR. Filter \( F \) of UMMG \( S = < a_0, R, F > \) is set of conditions, which may be boundary and optimizing as in UMG, i.e. having form \( a_0 \cdot n_pa_0pa' \) and \( \gamma = a \cdot \alpha t \), where \( \rho \in \{<, =, \leq\} \), \( \alpha t \in \{\min, \max\} \). At the same time \( F \) contains chain boundary conditions of the form \[ \gamma \leq n \leq n'. \] (47) which contain variables not objects \((n \geq 0)\); there is one and only one CBC (47) for every variable \( \gamma \) having place in unitary metarules entering scheme \( R \). This CBC is called variable declaration and has quite evident semantics. If \( F \) includes subfilter \( F_T = \{n_1 \leq \gamma_1 \leq n_1', ..., n_l \leq \gamma_l \leq n_l'\} \) containing all variables declarations, then every tuple \((\overline{n}_1, ..., \overline{n}_l)\) such that \( \overline{n}_i \in [n_i, n_i'] \) for \( i = 1, ..., l \) provides creation of one unitary multigrammar by substitution of \( \overline{n}_i \) to all unitary metarules having place in \( R \) scheme instead of multiplicities-variables being in their bodies. Unitary rules entering \( R \) are transferred to new scheme denoted \( R \circ \langle \overline{n}_1, ..., \overline{n}_l \rangle \) without any transformations. Every such UMG generates set of terminal multisets by the help of filter \( F = F - F_T \), which contains all “usual” (without variables) conditions (both boundary and optimizing). As may be seen from this short informal description, UMMG \( S = \langle a_0, R, F \rangle \) is simple unified tool for compact representation of set of FUMG denoted \( S^* \): for practically valuable problems number of such FUMG, i.e. \( S^* \) cardinality, may reach extremely large numbers. It is easy to see that this number is not greater than product of all variables domains cardinalities: \[ |S^*| \leq \prod_{j=1}^l (n_j' - n_j + 1) \] (48) (if there are no identical UMG after variables values substitution then (48) becomes equality). Let us now give strict definition of unitary multiset metagrammars semantics. (From the described it is obvious nature of “multiset metagrammar” notion – as “metalanguage” is used for description of another language, so “multiset metagrammar” is “unitary-like” multigrammar used for description of other UMG by means of unitary metarules, variables-multiplicities as well as by boundary conditions defining their domains). UMMG \( S = \langle a_0, R, F \rangle \) defines set of terminal multisets \( \mathcal{V}_S \) in such a way: \[ \mathcal{V}_S = \left( \bigcup_{S \in S^*} \mathcal{V}_S \right) \downarrow \mathcal{F}, \] (49) \[ S^* = \bigcup_{\overline{n}_i \in [n_i, n_i']} \bigcup_{\overline{n}_j \in [n_j, n_j'] \circ \langle \overline{n}_1, ..., \overline{n}_l \rangle} \{\langle a_0, R \} \] (50) R \circ \langle \vec{n}_1, ..., \vec{n}_l \rangle = \{ r \circ \langle \vec{n}_1, ..., \vec{n}_l \rangle | r \in R \}. (51) \mathcal{F} = F - F_\Gamma. (52) F_\Gamma = \bigcup_{j=1}^{l} \{ \vec{n}_j | y_j' \leq y_j \}. (53) and, if r is a \leftarrow \mu_1 \cdot a_1, ..., \mu_m \cdot a_m, then \ r \circ \langle \vec{n}_1, ..., \vec{n}_l \rangle is unitary rule a \leftarrow (\mu_1 \circ \langle \vec{n}_1, ..., \vec{n}_l \rangle) \cdot a_1, ..., (\mu_m \circ \langle \vec{n}_1, ..., \vec{n}_l \rangle) \cdot a_m. (54) where \mu_i \circ \langle \vec{n}_1, ..., \vec{n}_l \rangle = \begin{cases} \mu_i, & \text{if } \mu_i \in [1, \infty], \\ \vec{n}_i, & \text{if } \mu_i \in \Gamma. \end{cases} (55) As seen, according to (54) – (55), all multiplicities-variables of UMR a \leftarrow \mu_1 \cdot a_1, ..., \mu_m \cdot a_m are substituted by their corresponding values from tuple \langle \vec{n}_1, ..., \vec{n}_l \rangle while all multiplicities-constants remain unchanged. Evidently, if all \mu_1, ..., \mu_m are constants, i.e. UMR is UR, it remains unchanged. Note, that multiplicities-variables area of actuality is whole \ R scheme, i.e. if there are \ n > 1 \ occurrences of one and the same variable \ y \ in different unitary metarules, they all are substituted by one and the same value from the applied tuple \langle \vec{n}_1, ..., \vec{n}_l \rangle. Example 10. Consider UMMG \ S = \langle a, R, F \rangle, where \ R contains following three unitary metarules: r_1 = (a \rightarrow 3 \cdot b, y_1 \cdot c), r_2 = (b \rightarrow 1 \cdot c, y_2 \cdot d), r_3 = (b \rightarrow y_1 \cdot c, y_2 \cdot d), while filter \ F contains following conditions: 2 \leq c \leq 4, 1 \leq y_1 \leq 2, 0 \leq y_2 \leq 1, d = max. According to (49) – (55), \ S defines four UMG: S_1 = \langle a, R \circ (1,0) \rangle, S_2 = \langle a, R \circ (1,1) \rangle, S_3 = \langle a, R \circ (2,0) \rangle, S_4 = \langle a, R \circ (2,1) \rangle, which correspond to \ 4 = 2 \times 2 \ sets of two-values domains of \ y_1 \ and \ y_2 \ variables. As seen, R_1 = R \circ (1,0) = \{ (a \rightarrow 3 \cdot b, 1 \cdot c), (b \rightarrow 1 \cdot c) \}, \mathcal{V}_{T_1} = \{4 \cdot c\}, R_2 = R \circ (1,1) = \{ (a \rightarrow 3 \cdot b, 1 \cdot c), (b \rightarrow 1 \cdot c, 1 \cdot d) \}, \mathcal{V}_{T_2} = \{4 \cdot c, 3 \cdot d\}, R_3 = R \circ (2,0) = \{ (a \rightarrow 3 \cdot b, 2 \cdot c), (b \rightarrow 1 \cdot c) \}, \mathcal{V}_{T_3} = \{5 \cdot c\}, R_4 = R \circ (2,1) = \{ (a \rightarrow 3 \cdot b, 2 \cdot c), (b \rightarrow 1 \cdot c, 1 \cdot d) \}, \mathcal{V}_{T_4} = \{5 \cdot c, 3 \cdot d\}, \{8 \cdot c, 3 \cdot d\}. (56) (57) (58) (note, that after variables values substitution there may occur identical URs as in \ R_1, R_2 and \ R_3 \ cases, that’s why number of URs in constructed UMG may be less than number of UMRs in initial UMMG). After that, \mathcal{V}_e = \langle \mathcal{V}_{T_1} \cup \mathcal{V}_{T_2} \cup \mathcal{V}_{T_3} \cup \mathcal{V}_{T_4} \rangle \downarrow \{ 2 \leq c \leq 4, d = max \} = \{ \{4 \cdot c\}, \{4 \cdot c, 3 \cdot d\}, \{5 \cdot c\}, \{5 \cdot c, 3 \cdot d\}, \{8 \cdot c, 3 \cdot d\} \} \downarrow \{ 2 \leq c \leq d \}) \downarrow \{ d = max \} = \{ \{4 \cdot c\}, \{4 \cdot c, 3 \cdot d\} \} \downarrow \{ d = max \} = \{ \{4 \cdot c\}, \{4 \cdot c, 3 \cdot d\} \}. As seen, UMMG filters contain boundary conditions concerning objects and variables but optimizing conditions concerning only objects. That’s why from both theoretical and practical points of view it is reasonable to extend mentioned filters by optimizing conditions relating variables and having form \ y = opt. (56) This form defines generated TMS optimality through multiplicities-variables values used while these terminal multisets generation. Semantics of optimizing condition (56) is quite clear: select those TMS which are generated by the help of \ y \ value which is optimal (minimal, maximal) among all other TMS generated by the help of all other values from \ y \ domain. By this verbal description we extend TMS optimality notion from multiplicities-constants to also multiplicities-variables having place in unitary metarules applied while TMS generation. Formal definition of the sense of (56) verbally described higher is as follows. Let us introduce \ l \ auxiliary terminal objects \ \vec{y}_1, ..., \vec{y}_l \ corresponding to variables \ y_1, ..., y_1 \ having place in UMMG \ S = \langle a_0, R, F \rangle, i.e. in unitary metarules and boundary conditions defining multiplicities-variables domains. After that let us add one new unitary metarule \vec{a}_0 \rightarrow 1 \cdot a_0, y_1 \cdot \vec{y}_1, ..., y_l \cdot \vec{y}_l (57) to \ R \ scheme thus creating new \ \tilde{R} \ scheme which contains (57) and all elements (URs and UMRs) of \ R. After that we shall replace all optimizing conditions of the form \ y = opt, having place in \ F \ filter, by \ \vec{y} = opt, thus converting them to the “canonical” object-containing form; let us repeat, that \ \vec{y} \ is object not variable and, more, terminal object because there is no any UR or UMR with the head \ \vec{y} \ in \ R. Constructed filter will be denoted lower as \ \tilde{F}. As seen now, UMMG \( \bar{S} = (\bar{a_0}, \bar{R}, \bar{F}) \) generates terminal multisets of the form \[ \{n_{i_1} \cdot a_{i_1}, ..., n_{i_k} \cdot a_{i_k}, n_{\bar{y}_1}, ..., n_{\bar{y}_l}\}, \] which are selected to \( V_{\bar{S}} \), if and only if TMS \[ \{n_{i_1} \cdot a_{i_1}, ..., n_{i_k} \cdot a_{i_k}\} \] satisfies all conditions entering \( F \) and concerning terminal objects having place in \( R \) scheme, as well as TMS \[ \{n_{\bar{y}_1}, ..., n_{\bar{y}_l}\} \] satisfies all optimizing conditions of the form \( \bar{y}_j = opt_i \). It is not difficult to define \( V_{\bar{S}} \) by subtracting multisets of the form (60) from all TMS \( v \in V_{\bar{S}} \), but from the practical point of view it is more useful to consider \( V_{\bar{S}} \) not \( V_{\bar{S}} \) as a result of \( S \) application. It’s clear that all TMS \( v \in V_{\bar{S}} \) contain variables \( y_1, ..., y_l \) values as multiplicities-constants of terminal objects \( \bar{y}_1, ..., \bar{y}_l \), which computation is usually main purpose of the mentioned unitary multimetagrammar application. **Example 11.** Consider UMMG \( S = (a, R, F) \), where \( R \) contains the same unitary metarules as in the previous example while filter \( F \) contains all conditions from this example and one more optimizing condition \( y_1 = max \). Then \( R = R \cup \{r_0\} \) where \( r_0 = (\bar{a} \rightarrow 1 \cdot a, \bar{y}_1, \bar{y}_2) \), and \( \bar{S} = (\bar{a}, R, \bar{F}) \), where \( \bar{F} = F \cup \{\bar{y}_1 = \text{max}\} \). According to (49) – (55), UMMG \( S \) defines four UMMGs \( S_1 = (a, R \circ (1,0)) \), \( S_2 = (a, R \circ (1,1)) \), \( S_3 = (a, R \circ (2,0)) \), \( S_4 = (a, R \circ (2,1)) \), which, as in the Example 10, correspond to four sets of variables \( y_1 \) and \( y_2 \) values. Then, as higher, \[ R_1 = R \circ (1,0) = \{(a_0 \rightarrow 1 \cdot a, 1 \cdot \bar{y}_1), (a \rightarrow 3 \cdot b, 1 \cdot c), (b \rightarrow 1 \cdot c)\}, \] \[ V_{s_1} = \{\{4 \cdot c, 1 \cdot \bar{y}_1\}\} \] \[ R_2 = R \circ (1,1) = \{(a_0 \rightarrow 1 \cdot a, 1 \cdot \bar{y}_1, 1 \cdot \bar{y}_2), (a \rightarrow 3 \cdot b, 1 \cdot c), (b \rightarrow 1 \cdot c)\}, \] \[ V_{s_2} = \{\{4 \cdot c, 3 \cdot d, 1 \cdot \bar{y}_1, 1 \cdot \bar{y}_2\}\} \] \[ R_3 = R \circ (2,0) = \{(a_0 \rightarrow 1 \cdot a, 2 \cdot \bar{y}_1), (a \rightarrow 3 \cdot b, 2 \cdot c), (b \rightarrow 1 \cdot c)\}, \] \[ V_{s_3} = \{\{5 \cdot c, 2 \cdot \bar{y}_1\}\} \] \[ R_4 = R \circ (2,1) = \{(a_0 \rightarrow 1 \cdot a, 2 \cdot \bar{y}_1, 1 \cdot \bar{y}_2), (a \rightarrow 3 \cdot b, 2 \cdot c), (b \rightarrow 1 \cdot c, 1 \cdot d)\}, \] \[ V_{s_4} = \{\{5 \cdot c, 3 \cdot d, 2 \cdot \bar{y}_1, 1 \cdot \bar{y}_2\}, \{8 \cdot c, 3 \cdot d, 2 \cdot \bar{y}_1, 1 \cdot \bar{y}_2\}\}. \] After that \[ \bar{V}_s = (\bar{V}_{s_1} \cup \bar{V}_{s_2} \cup \bar{V}_{s_3} \cup \bar{V}_{s_4}) \] \[ \downarrow \{2 \leq c \leq 4, d = max, \bar{y}_1 = max\} = \{\{4 \cdot c, 1 \cdot \bar{y}_1\}, \{4 \cdot c, 3 \cdot d, 1 \cdot \bar{y}_1, 1 \cdot \bar{y}_2\}\} \] \[ \downarrow \{d = max, \bar{y}_1 = max\} = \{\{4 \cdot c, 3 \cdot d, 1 \cdot \bar{y}_1, 1 \cdot \bar{y}_2\}\}. \] i.e. set of terminal multisets generated by UMMG \( S \) contains the only TMS \( \{4 \cdot c, 3 \cdot d, 1 \cdot \bar{y}_1, 1 \cdot \bar{y}_2\} \), which corresponds to variables values \( y_1 = 1 \) and \( y_2 = 1 \). As seen, it is very practically useful to consider namely \( V_s \) as a result of UMMG \( S = (a_0, R, F) \) application (even in the cases where \( R \) does not contain optimizing conditions of the form \( y = opt \)). The only inconvenience which attentive reader may notice due to the last example is the absence of multiobjects of the form \( n \cdot \bar{y} \), where \( n = 0 \). This inconvenience, however, may be eliminated simply by imperative inclusion of multiobjects of the form \( 0 \cdot \bar{y} \) to the generated multiset. UMMG, which filter contains at least one optimizing condition, is called *optimizing multimetagrammar*. As may be seen, optimizing multimetagrammars are special form of constraints logic programming language, oriented to systems analysis and optimization applications. Mutual interconnections of different classes of unitary multiset grammars are presented at Fig.1. **Fig. 1.** OMMG algorithms as well as OMMG family subsets and formal features (internal alternativity, integrity, cyclicity, finitarity) are described in details in [32,33], while multigrammatical representation of classical optimization problems – in the second part of this paper. **REFERENCES**
{"Source-Url": "http://www.ijceit.org/published/volume8/issue7/1Vol8No7.pdf", "len_cl100k_base": 12216, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 41512, "total-output-tokens": 15087, "length": "2e13", "weborganizer": {"__label__adult": 0.0003666877746582031, "__label__art_design": 0.000762939453125, "__label__crime_law": 0.0005278587341308594, "__label__education_jobs": 0.0029697418212890625, "__label__entertainment": 0.0001341104507446289, "__label__fashion_beauty": 0.0002224445343017578, "__label__finance_business": 0.000705718994140625, "__label__food_dining": 0.00047135353088378906, "__label__games": 0.0006918907165527344, "__label__hardware": 0.0012254714965820312, "__label__health": 0.0009012222290039062, "__label__history": 0.0004701614379882813, "__label__home_hobbies": 0.0002243518829345703, "__label__industrial": 0.001323699951171875, "__label__literature": 0.0007171630859375, "__label__politics": 0.00047707557678222656, "__label__religion": 0.0007863044738769531, "__label__science_tech": 0.36474609375, "__label__social_life": 0.00017321109771728516, "__label__software": 0.012359619140625, "__label__software_dev": 0.6083984375, "__label__sports_fitness": 0.0002593994140625, "__label__transportation": 0.0007920265197753906, "__label__travel": 0.0002129077911376953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 41639, 0.0629]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 41639, 0.86904]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 41639, 0.75927]], "google_gemma-3-12b-it_contains_pii": [[0, 4209, false], [4209, 6903, null], [6903, 11396, null], [11396, 17464, null], [17464, 22565, null], [22565, 26980, null], [26980, 32222, null], [32222, 37102, null], [37102, 41639, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4209, true], [4209, 6903, null], [6903, 11396, null], [11396, 17464, null], [17464, 22565, null], [22565, 26980, null], [26980, 32222, null], [32222, 37102, null], [37102, 41639, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 41639, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 41639, null]], "pdf_page_numbers": [[0, 4209, 1], [4209, 6903, 2], [6903, 11396, 3], [11396, 17464, 4], [17464, 22565, 5], [22565, 26980, 6], [26980, 32222, 7], [32222, 37102, 8], [37102, 41639, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 41639, 0.0]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
0763a4585a8cec3bac1cdce4b867f1fc65dba8aa
A Six Sigma Security Software Quality Management Vojo Bubevski Bubevski Consulting™, Brighton, UK Email: vbubevski@aol.com, vojo.bubevski@landg.com Received: July 15, 2016 Accepted: October 23, 2016 Published: October 26, 2016 Copyright © 2016 by author and Scientific Research Publishing Inc. This work is licensed under the Creative Commons Attribution International License (CC BY 4.0). http://creativecommons.org/licenses/by/4.0/ Abstract Today, the demand for security software is Six Sigma quality, i.e. practically zero-defects. A practical and stochastic method is proposed for a Six Sigma security software quality management. Monte Carlo Simulation is used in a Six Sigma DMAIC (Define, Measure, Analyze, Improve, Control) approach to security software testing. This elaboration used a published real project’s data from the final product testing lasted for 15 weeks, after which the product was delivered. The experiment utilised the first 12 weeks’ data to allow the results verification on the actual data from the last three weeks. A hypothetical testing project was applied, supposed to be completed in 15 weeks. The product due-date was Week 16 with zero-defects quality assurance aim. The testing project was analysed at the end of the 12th week with three weeks of testing remaining. Running a Monte Carlo Simulation with data from the first 12 weeks produced results which indicated that the product would not be able to meet its due-date with the desired zero-defects quality. To quantify an improvement, another simulation was run to find when zero-defects would be achieved. Simulation predicted that zero-defects would be achieved in week 35 with 56% probability, and there would be 82 defects from Weeks 16 - 35. Therefore, to meet the quality goals, either more resources should be allocated to the project, or the deadline for the project should be moved to Week 36. The paper concluded that utilising Monte Carlo Simulations in a Six Sigma DMAIC structured framework is better than conventional approaches using static analysis methods. When the simulation results were compared to the actual data, it was found to be accurate within −3.5% to +1.3%. This approach helps to improve software quality and achieve the zero-defects quality assurance goal, while assigning quality confidence levels to scheduled product releases. Keywords Security Software, Quality Management, Six Sigma, DMAIC, Monte Carlo Simulation 1. Introduction Six Sigma methodologies were originally formulated by Motorola in the mid-1980s. Subsequently, Six Sigma evolved into a set of comprehensive and powerful improvement frameworks and tools. Six Sigma refers to having six standard deviations between the mean of the actual performance of the process and the expected performance limits of the process. That translates to a 0.999997 probability (99.9997%) that the process performance is as desired, or to fewer than 3.4 failures per one million opportunities. Most industries today recognize Six Sigma as a standard means to accomplish process and quality improvements. One of the principal Six Sigma methodologies is Define, Measure, Analyse, Improve, and Control (DMAIC). DMAIC comprises [1] [2]: 1) Define: defining the process, objectives and quality goals; 2) Measure: establishing the metrics and measuring the current process performance; 3) Analyse: analysing the measurement results and collected data to determine the root causes of the process variability and risk; 4) Improve: considering alternatives to eliminate the root causes and determining and applying the improvement solution to upgrade the process; and 5) Control: continuous monitoring and establishing corrective mechanisms to rectify the deviations and control the process performance in the future. It has been well understood for more than a decade now that the root-cause of most security exposures is in the software itself, and that these vulnerabilities are introduced during the development process. The software development is an inherently uncertain process, thus security defects are part of it. Software organisations in the past were not striving for Six Sigma quality as they had profited from quickly releasing imperfect software and fix the defects later in the field. In particular for security software, this is now changing because software security vulnerabilities can be exploited before the security defects are patched. The “ship, pray and patch” approach is not anymore so the software organisations should aim Six Sigma quality for security software [3]. Nowadays, security is one of the most important quality challenges of software systems and organisations. It is difficult though to keep the systems safe because of the security evolution. In order to adequately manage the security evolution, it should be considered for all artefacts throughout the software development lifecycle. The article published by Felderer et al. elaborated on the evolution of security software engineering considering the security requirements, architectures, code, testing, models, risks and monitoring [4]. Falah et al. presented an alternative approach to security software testing. In this paper, the focus is on improving the effectiveness of the categorization of threats by using Open 10 Web Application Security Project’s (OWASP) that are the most critical web application security risks in generating threat trees in order to cover widely known security attacks [5]. A fuzz approach to security testing was presented by Pietikäinen et al. The authors emphasised the challenges, experiences, and practical ways of utilizing fuzzing in soft- Software quality is a multidimensional property of a software product including customer satisfaction factors such as reliability, functionality, usability, performance, capability, installability, serviceability, maintainability and documentation. Software processes are inherently variable and uncertain, thus involving potential risks. A key factor in software quality is Software Reliability as it is the quality attribute most exposed to customer observation. In this chapter, the terms “reliability” and “quality” are used interchangeably. The Orthogonal Security Defect Classification (OSDC) was established and used by Hunny to assess and improve the quality of security software [7]. OSDC also provides for applying qualitative analysis to the security software risk management. OSDC is based on the Orthogonal Defect Classification (ODC), which was elaborated by Chillarege and implemented by IBM™ (Ref., Chapter 9 in [8]). Chillarege applied the Inflection S-shaped Software Reliability Growth Model for relative risk assessment. Software Reliability is a main subject in Software Reliability Engineering (SRE) [8]. The software reliability analytic models have been used since the early 1970s [8]-[10]. The need for a simulation approach to software reliability was recognized in 1993 by Von Mayrhauser et al. [11]. Subsequently, substantial work on simulation was published [12]-[15]. Applications of Six Sigma in software development have been published since 1985 [16]-[22]. Six Sigma software practitioners usually employ analytic models, but it has been reported that for Six Sigma, simulation models are superior [23]. Nanda and Robinson published a Six Sigma roadmap for software quality improvements [24]. Galinac & Car [25] elaborated an application of Six Sigma in continuous software processes’ improvement. In addition, Macke & Galinac [26] applied Six Sigma improvements in software development. A six sigma DMAIC software quality improvement was presented by Redzic & Baik [27]. Also, Xiaosong et al. [28] used Six Sigma DMAIC to model the software engineering process. Some other work related to software quality risk management was published [14], in which simulation was applied for software reliability assessment. Gokhale, Lyu & Trivedi [12] [13] developed simulation models for failure behaviour. Also, Gokhale & Lyu [29] applied simulation for tailoring the testing and repair strategies. Monte Carlo simulation is a methodology which iteratively evaluates a deterministic model by applying a distribution of random numbers to account for uncertainty. Simulation allows the use of probability and statistics for analysis [30] [31]. Security software plays a major role in Information Security and Computer Fraud as defects in security software promote insecurity and fraud. So, the security software quality is crucial for improving security and reducing fraud. Considering the losses resulting from insecurity and fraud, nowadays Six Sigma quality of security software (which practically translates to zero-defects security software) is a necessity. Traditional security software quality management of ongoing software projects have two observed deficiencies: 1) structured methods are not utilised to accomplish Six Sigma quality; A practical and stochastic method is presented in this paper that is Six Sigma security software quality management. This method utilises proven-in-practice methodologies such as Six Sigma Define, Measure, Analyse, Improve and Control (DMAIC), Monte Carlo simulation and Orthogonal Security Defect Classification (OSDC). The DMAIC framework is used to tactically enhance the software process which is inherently uncertain in order to accomplish Six Sigma quality. Monte Carlo simulation is used to: 1) measure software process performance using Six Sigma process capability metrics; 2) measure and evaluate the quality (reliability); and 3) identifies and quantifies the quality risk. OSDC provides for considering the qualitative aspects of quality management, which complements the quantitative analysis. DMAIC is a recognised structured methodology across industries today for systematic process and quality improvements. Analytic risk models are very much inferior to Monte Carlo simulation, which is a stochastic method. Significant qualitative improvements of quality management are provided by OSDC. Therefore, the perceived deficiencies are eliminated, which significantly improves the security software quality thus increasing information security and reducing the computer fraud risk. The method provides for achieving Six Sigma security software quality thus gaining imperative benefits such as savings and customer satisfaction. The method is compliant with CMMI® (Capability Maturity Model Integration). Published real project data are used to elaborate the method. It should be noted that the method is presented from practical perspective only providing references for the reader to explore the theory. The method has been successfully used in practice on commercial projects gaining significant benefits [32]. The simulation models in the paper were implemented in Microsoft™ Excel® using the Palisade™ @RISK® add-in. 2. Six Sigma Security Software Quality Management: The Method This paper is based on author’s published work [32]-[35]. The method elaboration follows the DMAIC methodology stage-by-stage. The DMAIC stage reference is given in the topics for understanding. 3. Hypothetical Scenario (DMAIC Define) The elaboration is based on a real IBM™ software development project using published data (Ref. Dataset ODC4 in [8]). The project is finished so this case is hypothetical. The original defects are classified by using the ODC (Ref. Chapter 9 in [8]). In order to emulate the security software scenario, the original defect classification is remapped to OSDC based on the ODC-OSDC mapping matrix published by Hunny [7]. So in this hypothetical security software scenario, the security software defects are available for the entire testing cycle of 15 weeks. The OSDC Defect Types considered are: Security Functionality (SF), Security Logic (SL) and Miscellaneous (Other). To emulate the scenario of an ongoing process, the data from the first 12 weeks of testing are used. The data from the last three weeks are used to verify the results of the method. 4. Project Definition (DMAIC Define) The assumption is that the project is within the final testing stage at the end of Week 12 (TI(12)), which is three weeks from the targeted delivery date of the product. The project is defined as follows: Project Objective: Complete final test phase by the end of Week 15 (TI(15)) as planned and deliver the system on time, whilst achieving the quality goal. The delivery date is at the beginning of Week 16. Project Quality Goal: The aim is to ensure that the system is stable and ready for delivery. All detected defects should be fixed and re-tested before the end of testing. Also, the final week of testing (Week 15) should be defect-free for all defect types including total, i.e. zero defects to match the Six Sigma quality. Problem Statement: Assess and mitigate the risk to deliver the system on time, whilst achieving the quality goal. CTQ: Critical to Quality for the project is the software reliability of the system. 5. Project Metrics (DMAIC Measure) For the data in details, please refer to the Appendix section. The Failure Intensity Function (FIF) is used. The Poisson distribution is used to simulate FIF in the model. So, FIF by Defect-Type need to be approximated. The logarithmic and exponential approximations were applied. The R-square values for the logarithmic approximations were the following: 1) SF: $R^2 = 0.9254$; 2) SL: $R^2 = 0.8981$; 3) Other: $R^2 = 0.7385$; and 4) Total: $R^2 = 0.9604$. For the exponential approximation the R-square values were as follows: a) SF: $R^2 = 0.8999$; b) SL: $R^2 = 0.9276$; c) Other: $R^2 = 0.7642$; and d) Total: $R^2 = 0.9665$. Comparing the R-square values, the exponential approximation is more accurate than the logarithmic approximation. Thus, the exponential approximation of the FIF is used applying the Musa’s Basic Execution Time Model for simulation. The aproximation of the transformed FIF by Defect Type (Figure 1) is as follows: $$\text{FIF}_{sf}(k) = 262.33 \exp(-0.274k)$$ $$\text{FIF}_{sl}(k) = 179.17 \exp(-0.217k)$$ $$\text{FIF}_{other}(k) = 41.138 \exp(-0.127k)$$ $$\text{FIF}_{total}(k) = \text{FIF}_{sf}(k) + \text{FIF}_{sl}(k) + \text{FIF}_{other}(k)$$ where, FIF$_{sf}$, FIF$_{sl}$, FIF$_{other}$ and FIF$_{total}$ are the FIF for SF, SL & Other Defect-Type and the Total, and $k$ is the time interval ($k = 1, 2, \ldots, n$). 6. Process Simulation (DMAIC Measure) In order to analyze the process, the software reliability for the future period of three weeks, i.e. from TI(13) to TI(15) inclusive, will be predicted (simulated). The simulation model is the discrete event simulation based on Musa’s Basic Execution Time Model. This model is used to predict the future course of the FIF. The Poisson distribution is used in the model in order to account for the variability and uncertainty of reliability. The FIF by Defect-Type are simulated for the three week period TI(13)-TI(15), thus the mean of the Poisson distribution for every defect type for TI(13), TI(14) and TI(15) will be equal to the value of the approximated FIF for TI(13), TI(14) and TI(15) respectively (1 - 3). The Total for TI(13), TI(14) and TI(15) is simply the sum of defects for all three types for TI(13), TI(14) and TI(15) respectively (4). To define the quality target according to the Quality Goal statement, the FIF will be used. The target is to achieve Six Sigma quality, i.e. practically zero-defects in Week 15 for all Defect-Types including Total, i.e. the FIF should be equal to zero for all defect types including total defects in the final week of testing. In order to define the quality targets in the model, the Six Sigma Target Value, Lower Specified Limit (LSL) and Upper Specified Limit (USL) will be used: a) Target Value is zero (0) for all defect types including Total; b) USL is three (3) for all defect types including Total; b) LSL should be zero, but for all defect types including Total it will be set to minus three (−3), i.e. a small negative number, to prevent an error in the Six Sigma metrics calculations. The Six Sigma metrics in the model are used to measure the performance of the process. In this model the following Six Sigma metrics are used: a) Process Capability (Cp); b) Process Capability Index (Cpk); and c) Sigma Level. To apply the Poisson distribution, the @RISK® Poisson distribution function was used. To calculate Standard Deviation, Minimum Value and Maximum Value, the corresponding @RISK® functions for Standard Deviation, Minimum Value and Maximum Value were used. To calculate the Six Sigma process metrics Cp, Cpk and Sigma Level, the @RISK® Cp, Cpk and Sigma Level functions were respectively used. For the Six Sigma metrics calculations. Sigma Target Value, USL and LSL, constants were specified. It should be noted that the Six Sigma Cp, Cpk and Sigma Level metrics are calculated from the resulting probability distribution from the simulation. The Six Sigma process simulation results on Figure 2 show that the Total’s distribution in the final week of testing TI(15) totally deviates from the process target specifications (LSL, Target Value and USL are marked on the graph). Also, there is a 0.9 (90%) probability that the Total in TI(15) would be in the range 11 - 24; 0.05 (5%) probability that the Total would be more than 24; and 0.05 (5%) probability that the Total would be less than 11. Table 1 shows the predicted mean (µ) total number of defects by Defect-Type in the final week of testing TI(15) including the Total. Also, the associated Standard Deviation (σ) and Minimum and Maximum Values obtained from the simulation are shown. The predicted Total in TI(15) is 17, with Standard Deviation of 4.17 defects. This strongly indicates that the product will not be stable for delivery at the end of Week 15. Figure 2. Total defects probability distribution for week 15. <table> <thead> <tr> <th>Process</th> <th>µ</th> <th>σ</th> <th>Min value</th> <th>Max value</th> </tr> </thead> <tbody> <tr> <td>SF</td> <td>4</td> <td>2.08</td> <td>0</td> <td>15</td> </tr> <tr> <td>SL</td> <td>7</td> <td>2.63</td> <td>0</td> <td>21</td> </tr> <tr> <td>Other</td> <td>6</td> <td>2.48</td> <td>0</td> <td>18</td> </tr> <tr> <td>Total</td> <td>17</td> <td>4.17</td> <td>4</td> <td>35</td> </tr> </tbody> </table> Table 1. Predicted FIF for week 15. The Six Sigma metrics by Defect-Type for Week 15 is given in Table 2. The Cp metric is extremely low for all defect types including the Total, so the chances that the process will deliver the desired quality are extremely low. Also, the Cpk metric for all defect types incl. total defects is negative, which confirms that the quality target won’t be met. Finally, the Sigma Level is almost zero for all defect types including the Total. Thus, there are no chances that the process will perform as expected. For example, the process Sigma Level metrics is 0.50, 0.11 and 0.18 for SF, SL and Other defects respectively. Finally, Sigma Level for total defects is practically zero (i.e. 0.0001), which confirms that the process will not perform at all, so it will not deliver the desired Six Sigma quality at the end of Week 15. 7. Sensitivity Analysis (DMAIC Analyse) The Six Sigma simulation sensitivity analysis can show what factors have the most influence on the process variability and risk. It also can quantify this influence. It is actually used to identify the Critical-To-Qualities (CTQs) of the software process. The presented correlation and regression sensitivity analysis is performed on the predicted (simulated) data distribution for TI(13)-TI(15) only in order to determine the influence of the change of a particular Defect-Type to the change of Total Defects for all Defect Types. On the regression coefficients graph (Figure 3) it can be seen that the top risk CTQ is the SL Defect-Type with correlation coefficient to the Total of 0.63; the less risky CTQ is the Other Defect-Type with correlation coefficient to the Total of 0.59; and the minimal risk CTQ is the SF Defect-Type with correlation coefficient to the Total of 0.50. Also, on the regression mapped values graph (Figure 4) the quantitative parameters of the influence of the CTQs if they change by one Standard Deviation can be seen. Thus, if the SL defects increase by one Standard Deviation, the Total will increase by 2.64 defects; if the Other defects increase by one Standard Deviation, the Total will increase by 2.45 defects; and if SF defects increase by one Standard Deviation, the Total will increase by 2.10 defects. 8. Analysis Conclusion and Recommendation (DMAIC Analyse) The conclusions from this Six Sigma analysis: a) The testing process will not perform at all as shown by the considered Six Sigma metrics. Therefore, the system would not be ready for delivery as the Six Sigma quality goal will not be met at the beginning of Week 15. <table> <thead> <tr> <th>Process</th> <th>Cp</th> <th>Cpk</th> <th>Sigma level</th> </tr> </thead> <tbody> <tr> <td>SF</td> <td>0.4805</td> <td>-0.2056</td> <td>0.5024</td> </tr> <tr> <td>SL</td> <td>0.3801</td> <td>-0.4962</td> <td>0.1064</td> </tr> <tr> <td>Other</td> <td>0.4034</td> <td>-0.4199</td> <td>0.1757</td> </tr> <tr> <td>Total</td> <td>0.2396</td> <td>-1.1432</td> <td>0.0001</td> </tr> </tbody> </table> Table 2. Process six sigma metrics for week 15. Figure 3. Regression coefficients of total defects by defect-type. Figure 4. Regression mapped values of total defects by defect-type. 16 if the project maintains the current situation; and b) The CTQ to deliver the system is the software reliability, \textit{i.e.} the predicted Total in TI(15) is 17 defects, versus the target value of zero defects. Analysis Recommendation: In order to deliver the system on time and achieve the quality goal, immediately undertake an improvement project to improve the process and enhance the software reliability to accomplish the Six Sigma quality, which is the CTQ. 9. Improvement Simulation (DMAIC Improve) In order to undertake the recommended action, the software process needs to be analysed again. The purpose of this Six Sigma simulation is to quantitatively determine the solution for improvement, which is an example of Six Sigma Design of Experiments (DOE). For this purpose, all the escaped defects will be predicted, \textit{i.e.} the defects that are believed to be in the system but they are not captured. Therefore, the software reliability for the future period will be simulated to predict when the reliability goal will be achieved, \textit{i.e.} in which time interval (week) there will be zero defects in total. It was identified that the Six Sigma quality target could be met in Week 35. Hence again, the discrete event simulation is applied based on Musa’s Basic Execution Time Model to predict the future course of the FIF. All the parameters of this simulation were exactly the same as the parameters of the previous simulation. FIF by Defect-Type was simulated for the future period of 23 weeks, \textit{i.e.} from Week 13 to Week 35. As Figure 5 shows, the Total’s distribution in Week 35 of testing fits in the process ![Figure 5. Total defects probability distribution for week 35.](image) target specifications (LSL, Target Value and USL are marked on the graph). Also, there is a 0.90 (90%) probability that the Total in TI(35) would be in the specified target range 0 - 2 defects; and 0.05 (5%) probability that the Total would be more than two defects. The probability that there will be zero defects in total is approximately 0.56 (56%). According to this prediction, the process can achieve the Six Sigma quality goal (i.e. zero defects in total) in Week 35 if the project maintains the current situation. The confidence levels of the predicted Total for Week 35 are around: 1) 56%, for zero defects; 2) 32%, for one defect; and 3) 10% for two defects. Thus, this indicates that the system will be stable for delivery at the end of the prolonged testing achieving the Six Sigma quality goal. The simulation results for Week 35 are presented in Table 3. The predicted number of defects for all types, including the Total, is within the specified target range. The Standard Deviation for all types including the Total is low, i.e. nearly zero defects. The process Six Sigma metrics at the end of Week 35 are given in Table 4. The Cp metric is greater than one for all defect types including the Total, so the chances that the process will deliver the desired quality are extremely good. Also, the Cpk metric for all defect types incl. total defects is greater than one, which confirms that the quality target will be met. Finally, the Sigma Level is very high for all defect types including the Total. Thus, there are very good chances that the process will perform as expected. For example, the process Sigma Level metrics is 16.91, 7.28 and 3.17 for SF, SL and Other defects respectively. Finally, Sigma Level for total defects is almost three (i.e. 2.97), which confirms that the process will certainly perform well, so it will deliver the desired Six Sigma quality at the end of Week 35. Compared with the Six Sigma metrics of the preceding Six Sigma simulation in Table 2, the metrics in Table 4 are exceptionally better. All three Six Sigma metrics suggest that there are very realistic chances that the process will perform and deliver the desired Six Sigma quality at the end of Week 35. This is <table> <thead> <tr> <th>Process</th> <th>( \mu )</th> <th>( \sigma )</th> <th>Min Value</th> <th>Max Value</th> </tr> </thead> <tbody> <tr> <td>SF</td> <td>0</td> <td>0.13</td> <td>0</td> <td>2</td> </tr> <tr> <td>SL</td> <td>0</td> <td>0.31</td> <td>0</td> <td>2</td> </tr> <tr> <td>Other</td> <td>0</td> <td>0.70</td> <td>0</td> <td>5</td> </tr> <tr> <td>Total</td> <td>0</td> <td>0.78</td> <td>0</td> <td>5</td> </tr> </tbody> </table> <table> <thead> <tr> <th>Process</th> <th>Cp</th> <th>Cpk</th> <th>Sigma Level</th> </tr> </thead> <tbody> <tr> <td>SF</td> <td>7.6031</td> <td>7.5590</td> <td>16.9116</td> </tr> <tr> <td>SL</td> <td>3.2710</td> <td>3.1673</td> <td>7.2756</td> </tr> <tr> <td>Other</td> <td>1.4273</td> <td>1.1953</td> <td>3.1747</td> </tr> <tr> <td>Total</td> <td>1.2875</td> <td>1.0300</td> <td>2.9677</td> </tr> </tbody> </table> also strongly supported by the very low Standard Deviation, that is 0.13, 0.31, 0.70 and 0.78 for SF, SL, Other and Total defects respectively in Week 35, which is practically zero defects. 10. Improvement Recommendation (DMAIC Improve) The following defines and quantifies the solution for the improvement. The predicted total numbers of defects by Defect-Type including the Total for the future periods are shown in Table 5. The predicted defects for Week 13 - 15 are expected to be detected and removed by the current project until the end of Week 15. The predicted defects expected to be found in the system from Week 16 to Week 35 are unaccounted for. These defects need to be detected and removed until the end of Week 15 in order to achieve the quality goal. Therefore, the process improvement recommendation is: Immediately undertake an improvement project to deliver the system quality improvements as required to achieve the quality goals. It is very important to assign a Surgical Team to accomplish the improvement [36]. The objectives of this project are: 1) Reanalyse the unstable defects applying Casual Analysis and Resolution (CAR); 2) Consider and prioritise defects by type as identified in the sensitivity analysis (Ref. Sec. Sensitivity Analysis) to complement the quantitative analysis with qualitative analysis provided by OSDC; 3) Determine the quality improvement action plan, establishing an additional tactical test plan; 4) Execute the tactical test plan to additionally test the system and detect and repair the escaped defects, i.e. the defects that is believed are in the system but have not been detected. According to the simulation above, there are 82 predicted escaped defects in total (TI(16)-TI(35), Table 6); Table 5. Predicted defects per defect-type for future periods. <table> <thead> <tr> <th>Time Period</th> <th>SF</th> <th>SL</th> <th>Other</th> <th>Total</th> </tr> </thead> <tbody> <tr> <td>TI(13)-TI(15)</td> <td>17</td> <td>27</td> <td>21</td> <td>65</td> </tr> <tr> <td>TI(16)-TI(35)</td> <td>11</td> <td>28</td> <td>43</td> <td>82</td> </tr> <tr> <td>TI(13)-TI(35)</td> <td>28</td> <td>55</td> <td>64</td> <td>147</td> </tr> </tbody> </table> Table 6. Results comparison by week. <table> <thead> <tr> <th></th> <th>Week 13</th> <th>Week 14</th> <th>Week 15</th> </tr> </thead> <tbody> <tr> <td></td> <td>(Actual) Predicted</td> <td>Error %</td> <td>(Actual) Predicted</td> </tr> <tr> <td>SF</td> <td>7</td> <td>16.67</td> <td>6</td> </tr> <tr> <td>SL</td> <td>11</td> <td>-21.43</td> <td>9</td> </tr> <tr> <td>Other</td> <td>8</td> <td>0</td> <td>7</td> </tr> <tr> <td>Total</td> <td>26</td> <td>-7.14</td> <td>22</td> </tr> </tbody> </table> 5) The additional testing, detection and correction of the escaped defects should be completed by the end of Week 15 to achieve the quality goal. 11. Improvement Definition (DMAIC Improve) It should be stressed that the process improvement is a new testing project, which is totally independent of the current testing in progress. For project planning purposes, it is needed to determine the desired performance of the improvement testing process during the future three weeks. There are only three weeks available to accomplish the improvement, as the quality goal needs to be met at the end of testing (i.e. at the end of Week 15). Within the last stage of DMAIC it is required to monitor the process performance and variances, and implement corrective measures if deviations from the desired performance are found in the future. For this purpose, keeping one week as the time interval for observation is not good because it provides for only two future check points. Thus, the time interval for observation will be reduced to one day, which provides for five check points per week. The three weeks available for the project is equivalent to 15 working days. Thus, the proposed schedule for the testing improvement project during the next 15 Days is: 1) one day to start the project and appoint the staff; 2) three days to complete the required analysis and test plans; and 3) 11 days of testing where the escaped defects will be detected and fixed. The predicted distribution of the escaped defects by Defect-Type including the Total, which need to be detected and fixed during the testing period of 11 days, i.e. TI(1)-TI(11), is: 1) SF: 11 Defects; 2) SL: 28 Defects; 3) Other: 43 Defects; and 4) Total: 82 Defects. 12. Alternative (DMAIC Improve) Alternatively, if the project maintains the status quo situation, the system will be ready for delivery in Week 35. Thus, testing needs to continue until Week 35 inclusive, i.e. 23 weeks more than initially planned. The confidence level is 56% that the Six Sigma quality requirements will be met. 13. Simulation for Monitoring (DMAIC Control) It should be emphasized that in order to manage the quality risk, it is imperative to establish continuous monitoring in order to discover any variances in the process performance, and determine and implement the appropriate corrective actions to eliminate the deviations. This will ultimately mitigate the risk and allow for the delivery of the product on time and the achievement of the quality goals. In order to deliver the product on time and meet the quality goals, the control phase should be applied to both the current and the improvement testing process. It is recommended to create two additional Six Sigma simulation models and to apply them regularly on a daily basis to both processes until the end of the projects. The Six Sigma simulation models for monitoring of the improvement testing process will be very similar to the models presented above. Considering the fact that we have no original failure (defect) data for the purpose of monitoring, it will be speculative to craft the data to demonstrate the DMAIC Control phase. 14. Verification of Results The experimental results, i.e. the predictions, are compared with the actual available data for verification. It should be underlined that there are no data available from System’s Operation. Thus, it is impossible to verify the predictions for improvements and predictions for control. Three comparisons are performed as presented below: 1) Comparison by Week; 2) Partial Data Comparison; and 3) Overall Data Comparison. Comparison by Week: The results are verified by comparing the predicted total number of defects per Defect-Type by week including the Total, versus the corresponding actual defects for period TI(13)−TI(15). This comparison is presented in Table 6. The SF defects and the Total are reasonably predicted. The SL defects are underestimated for two weeks and overestimated for one week with moderate errors. The Other defects are precisely predicted for one week and badly overestimated for two weeks. Overall, these prediction results are tolerable. Partial Data Comparison: The results are verified by comparing the predicted total number of defects by Defect-Type including the Total for the three weeks period TI(13)−TI(15), versus the corresponding actual defects. The software reliability MTTF is also compared (Table 7). Here, the SF defects and the Total are exactly predicted. The SL defects are underestimated with a moderate error. The Other defects are substantially overestimated. Overall, these prediction results are acceptable. Overall Data Comparison: The results are verified by comparing the actual and predicted total number of defects by Defect-Type including the Total for the entire period TI(1)−TI(15), with the corresponding actual defects; The MTTF is also compared. The period of observation is 15 weeks. This comparison is presented in Table 8. Again, the SF defects and the Total are accurately predicted. The SL defects are underestimated with a minimal error. The Other defects are slightly overestimated. Thus, <table> <thead> <tr> <th>Process</th> <th>Defects</th> <th>MTTF (Weeks)</th> </tr> </thead> <tbody> <tr> <td></td> <td>Actual</td> <td>Pred.</td> </tr> <tr> <td>SF</td> <td>17</td> <td>17</td> </tr> <tr> <td>SL</td> <td>36</td> <td>27</td> </tr> <tr> <td>Other</td> <td>12</td> <td>21</td> </tr> <tr> <td>Total</td> <td>65</td> <td>65</td> </tr> </tbody> </table> these prediction results are very good. Considering the calculated errors in Tables 6-8, the experimental results are satisfactorily verified. It should be emphasized that the DMAIC-Simulation analysis is more reliable compared to the conventional models. This is because the variability and uncertainty in the software quality process are catered for by applying probability tools. This substantially increases the confidence in the DMAIC-simulation decision support, which is very important for the project. 15. Conclusions The quality of security software is one of the crucial contributing factors to Information Security and Computer Fraud. So, efficient and comprehensive security software quality management is a necessity to improve the quality, enhance information security and reduce the risk of computer fraud. Considering the importance of Information Security and Computer Fraud today, the demand for security software is Six Sigma quality, i.e. practically zero-defects security software. The conventional security software quality management of ongoing projects has two major weaknesses: 1) analytic risk models are used; and 2) structured methodologies for process and quality improvements are not systematically applied. The proposed practical method applies Six Sigma DMAIC, Monte Carlo simulation and OSDC methodologies. Simulation is superior to analytic risk models and DMAIC is a proven and recognized methodology for systematic process and quality improvements. OSDC provides for qualitative analysis offering qualitative improvements. This synergetic method eliminates the observed limitations of the conventional approach. The method fully follows the DMAIC framework including the five phases: define, control, analyse, improve and control. The elaboration of the method is outlined below. 1) DMAIC Define: a) The hypothetical security software scenario was explained highlighting that: A. The published real project was finished; B. The testing data were classified by using ODC; C. To emulate the scenario of security software, the ODC classification was remapped to OSDC by using ODC-OSDC mapping matrix; D. The data were available for the entire testing cycle of 15 weeks; and E. The OSDC defect types used were SF, SL and Other. b) The project was defined from Six Sigma DMAIC perspective including: --- Table 8. Overall data comparison. <table> <thead> <tr> <th>Process</th> <th>Defects</th> <th>MTTF (Weeks)</th> </tr> </thead> <tbody> <tr> <td></td> <td>Actual</td> <td>Pred.</td> </tr> <tr> <td>SF</td> <td>907</td> <td>907</td> </tr> <tr> <td>SL</td> <td>712</td> <td>703</td> </tr> <tr> <td>Other</td> <td>251</td> <td>260</td> </tr> <tr> <td>Total</td> <td>1870</td> <td>1870</td> </tr> </tbody> </table> --- A. The assumption that the testing stage was at the end of Week 15 B. The objective to complete the testing in Week 15 and deliver the product in Week 16 achieving the quality target; C. All defects should be fixed by the end of testing; D. The quality goal is that the final week of testing (i.e. Week 15) should be defect-free; E. The problem statement is to assess and mitigate the risk to deliver the product on time achieving the quality goal; and F. The Six Sigma CTQ is the software reliability. 2) DMAIC Measure: a) The project metrics was elaborated focusing on the testing data: A. The original FIF was transformed in order to be used; B. The transformed FIF was approximated; C. The exponential approximation was selected based on the R-square values; D. Poisson distribution was used to simulate FIF; and E. The Poisson distribution parameters were determined for the simulation. b) Monte Carlo Simulation was run with data from the first 12 weeks; c) Simulation results strongly indicated that the product would not be able to meet its due-date with the desired zero-defects quality. 3) DMAIC Analyse: Simulation sensitivity analysis was performed to identify and quantify the influence of the individual defect types, on the total defects: a) The Regression Coefficients determined the coefficients of: 0.63 for the top risk SL defects; 0.59 for the less risky Other defects; and 0.50 for the minimal risk SF defect type. b) Regression Mapped Values quantified the influence to the Total defects in terms of standard deviation if individual defect types change for one standard deviation. So the Total will increase as follows: 2.64 defects for SL; 2.45 defects for Other; and 2.10 for the SF defect type. 4) DMAIC Improve: a) Monte Carlo Simulation was run with data from the first 12 weeks to predict when the zero-defects would be achieved; b) Simulation results indicated that the product would achieve the desired zero-defects quality in week 35 with confidence level of 56%; 5) DMAIC Improve: Improvement recommendation was determined as follows: a) Immediately undertake an improvement project to deliver the system with zero-defects on time; b) Assign a Surgical Team to accomplish the improvement; c) The objectives are: A. Reanalyse the unstable defects applying Casual Analysis and Resolution (CAR); B. Consider and prioritise defects by type as identified in the sensitivity analysis (#3 above) to complement the quantitative analysis with qualitative analysis provided by OSDC; C. Determine the quality improvement action plan, establishing an additional tactical test plan; D. Execute the tactical test plan to additionally test the system and detect and repair the escaped defects, i.e. there are 82 predicted escaped defects in total (TI(16)-TI(35); E. The additional testing, detection and correction of the escaped defects should be completed by the end of Week 15 to deliver the product on time and achieve the quality goal. 6) DIMAIC Improve: Improvement Definition: a) There are only three weeks available to accomplish the improvement, i.e. 15 working days; b) The proposed project schedule is: A. One day to start the project and appoint the staff; B. Three days to complete the required analysis and test plans; and C. 11 days of testing where the escaped defects will be detected and fixed. c) The predicted escaped defects which need to be detected and fixed was: A. SF: 11 Defects; B. SL: 28 Defects; C. Other: 43 Defects; and D. Total: 82 Defects. 7) DIMAIC Improve: Alternatively: a) If the project continues as is, the product would achieve zero-defects in Week 35; b) Testing needs to continue until Week 35 inclusive, i.e. 23 weeks more than initially planned; c) Product would be delivered in Week 36; d) Probability could be 56% that the Six Sigma quality requirements would be met. 8) DIMAIC Control: a) It is vital to continuously monitor the 11 days of testing on daily bases; b) Two additional Six Sigma simulation models need to be applied for monitoring to provide for measuring and analysis of the testing process; c) As there are no original defects data for the purpose of monitoring, the control stage is not demonstrated. The method results were satisfactorily verified. Comparing the simulation results with the actual data, the results were found to be accurate within −3.5% to +1.3%. The method is compatible with CMMI* and can substantially help software projects to deliver the product on time and achieve the Six Sigma quality goals. It tactically uses the synergy of the three applied methodologies, i.e. Six Sigma DMAIC, Monte Carlo Simulation and OSDC, which provides for strong performance-driven software process improvements and achieves important benefits including savings, quality and customer satisfaction. In comparison with the conventional methods, the stochastic approach is more reliable and comprehensive as the inherent variability and uncertainty are accounted for, allowing for probability analysis of the risk. Therefore, the confidence in the method’s decision support is substantial, which is of mission-critical importance for software projects. Acknowledgements I would like to acknowledge Lyu, Michael R. [8] for publishing the real software projects data. I have used these data to experiment with the new method and additionally prove the concept on external commercial projects. This substantially increased the confidence in the new approach and allowed me to publish my work. Very special and warm thanks to my daughter, Ivana Bubevska, for reviewing the manuscript and suggesting very relevant improvements. She has also substantially helped with the editing and formatting of the text. Her contribution has been essential for the successful publication of this work. References http://dx.doi.org/10.1109/prfts.1997.640143 http://dx.doi.org/10.1145/4372.4375 http://dx.doi.org/10.1007/BF01026825 http://dx.doi.org/10.1109/MS.2003.1184165 http://dx.doi.org/10.1109/wsc.2002.1166415 http://dx.doi.org/10.1007/978-3-540-73460-4_8 http://dx.doi.org/10.1007/978-3-540-79588-9_34 http://dx.doi.org/10.1109/sera.2006.61 http://dx.doi.org/10.1109/iih-msp.2008.63 Appendix The elaboration is based on a real IBM™ software development project using published data (Ref. Dataset ODC4 in [8]). The project is finished so this case is hypothetical. The original defects are classified by using the ODC (Ref. Chapter 9 in [8]). In order to emulate the security software scenario, the original defect classification is remapped to OSDC based on the ODC-OSDC mapping matrix [7]. So in this hypothetical security software scenario, the security software defects are available for the entire testing cycle of 15 weeks. Therefore, the pretended security software defects found in testing are given in Table A1. Considered are the OSDC Defect Types of Security Functionality (SF), Security Logic (SL) and Miscellaneous (Other). The time interval of observation is one week. In order to demonstrate the method, it is assumed that the project is at the end of the week 12. So, the data from week 1 - 12 is used for analysis, shown in Black in Table A1. The data from the final three weeks of testing (week 13 - 15) shown in Blue, in Table A1, will be used to verify the method’s results. The time interval of analysis start with week one and ends with week 12, that is the start Time Interval TI(1), etc., and the end Time Interval TI(12). The Failure Intensity Function (FIF) cannot be derived from raw data. So we apply Rank Transformation [37] to get a smooth FIF, which will be approximated for the analysis. The entire time period of our observation is 15 weeks based on selected data available from the first 12 weeks. Table A1. Security software defects count data. <table> <thead> <tr> <th>Week</th> <th>SF</th> <th>SL</th> <th>Other</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>23</td> <td>93</td> <td>23</td> </tr> <tr> <td>2</td> <td>25</td> <td>33</td> <td>23</td> </tr> <tr> <td>3</td> <td>240</td> <td>43</td> <td>21</td> </tr> <tr> <td>4</td> <td>37</td> <td>20</td> <td>7</td> </tr> <tr> <td>5</td> <td>147</td> <td>98</td> <td>23</td> </tr> <tr> <td>6</td> <td>203</td> <td>36</td> <td>22</td> </tr> <tr> <td>7</td> <td>27</td> <td>64</td> <td>18</td> </tr> <tr> <td>8</td> <td>30</td> <td>112</td> <td>23</td> </tr> <tr> <td>9</td> <td>107</td> <td>43</td> <td>13</td> </tr> <tr> <td>10</td> <td>24</td> <td>93</td> <td>23</td> </tr> <tr> <td>11</td> <td>16</td> <td>20</td> <td>32</td> </tr> <tr> <td>12</td> <td>11</td> <td>8</td> <td>6</td> </tr> <tr> <td>13</td> <td>4</td> <td>15</td> <td>1</td> </tr> <tr> <td>14</td> <td>7</td> <td>7</td> <td>3</td> </tr> <tr> <td>15</td> <td>6</td> <td>14</td> <td>8</td> </tr> </tbody> </table> Submit or recommend next manuscript to SCIRP and we will provide best service for you: - Accepting pre-submission inquiries through Email, Facebook, LinkedIn, Twitter, etc. - A wide selection of journals (inclusive of 9 subjects, more than 200 journals) - Providing 24-hour high-quality service - User-friendly online submission system - Fair and swift peer-review system - Efficient typesetting and proofreading procedure - Display of the result of downloads and visits, as well as the number of cited articles - Maximum dissemination of your research work Submit your manuscript at: http://papersubmission.scirp.org/ Or contact jcc@scirp.org
{"Source-Url": "http://file.scirp.org/pdf/JCC_2016102615555292.pdf", "len_cl100k_base": 11221, "olmocr-version": "0.1.53", "pdf-total-pages": 22, "total-fallback-pages": 0, "total-input-tokens": 48548, "total-output-tokens": 14652, "length": "2e13", "weborganizer": {"__label__adult": 0.00037980079650878906, "__label__art_design": 0.0004210472106933594, "__label__crime_law": 0.0004322528839111328, "__label__education_jobs": 0.00208282470703125, "__label__entertainment": 8.147954940795898e-05, "__label__fashion_beauty": 0.0001817941665649414, "__label__finance_business": 0.0007562637329101562, "__label__food_dining": 0.0003769397735595703, "__label__games": 0.0009756088256835938, "__label__hardware": 0.0006823539733886719, "__label__health": 0.0005812644958496094, "__label__history": 0.00020992755889892575, "__label__home_hobbies": 0.00010764598846435548, "__label__industrial": 0.0004334449768066406, "__label__literature": 0.0003554821014404297, "__label__politics": 0.00016295909881591797, "__label__religion": 0.00031566619873046875, "__label__science_tech": 0.028167724609375, "__label__social_life": 0.00011289119720458984, "__label__software": 0.0091094970703125, "__label__software_dev": 0.953125, "__label__sports_fitness": 0.0002903938293457031, "__label__transportation": 0.0003838539123535156, "__label__travel": 0.0001842975616455078}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52696, 0.07266]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52696, 0.11856]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52696, 0.90512]], "google_gemma-3-12b-it_contains_pii": [[0, 2635, false], [2635, 5836, null], [5836, 9108, null], [9108, 12126, null], [12126, 14862, null], [14862, 16916, null], [16916, 18377, null], [18377, 21261, null], [21261, 21397, null], [21397, 23125, null], [23125, 25947, null], [25947, 28540, null], [28540, 31390, null], [31390, 34109, null], [34109, 36982, null], [36982, 39655, null], [39655, 42264, null], [42264, 45067, null], [45067, 48388, null], [48388, 49956, null], [49956, 52051, null], [52051, 52696, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2635, true], [2635, 5836, null], [5836, 9108, null], [9108, 12126, null], [12126, 14862, null], [14862, 16916, null], [16916, 18377, null], [18377, 21261, null], [21261, 21397, null], [21397, 23125, null], [23125, 25947, null], [25947, 28540, null], [28540, 31390, null], [31390, 34109, null], [34109, 36982, null], [36982, 39655, null], [39655, 42264, null], [42264, 45067, null], [45067, 48388, null], [48388, 49956, null], [49956, 52051, null], [52051, 52696, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52696, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52696, null]], "pdf_page_numbers": [[0, 2635, 1], [2635, 5836, 2], [5836, 9108, 3], [9108, 12126, 4], [12126, 14862, 5], [14862, 16916, 6], [16916, 18377, 7], [18377, 21261, 8], [21261, 21397, 9], [21397, 23125, 10], [23125, 25947, 11], [25947, 28540, 12], [28540, 31390, 13], [31390, 34109, 14], [34109, 36982, 15], [36982, 39655, 16], [39655, 42264, 17], [42264, 45067, 18], [45067, 48388, 19], [48388, 49956, 20], [49956, 52051, 21], [52051, 52696, 22]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52696, 0.20242]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
1577386c0f41a8e0e732e5b245ebf38adea4908d
Assembling Branch Instructions (chapter 3) Branch beq $rs,$rt,offset16 $pc = ($rt == $rs)? ($pc+4+(δ32(offset16)<<2))):($pc+4); Suppose the fib_exit = 0x81fc084C, pc = 0x81fc08124, beq $s3,$s7,fib_exit Relative addr = addr–(pc+4) =0x81fc084C–0x81fc08128 =0x24 Then rel addr>>2 = fib_exit >> 2 = 0x00000024 >> 2 = 0000 0000 0000 0000 0000 0000 0010 0100>>2 = 0000 0000 0000 0000 0000 0000 0000 1001 = 0x0000009 0x1fc08124 beq $s3,$s7,fib_exit 000100: 00011 00111 0000000000001001 Executing Branch Instructions Branch \[ \text{beq} \ \$rs,\$rt,\text{offset16} \] \[ \$pc = (\$rt == \$rs)? (\$pc+4+(\delta^{32}(\text{offset16})<<2))): (\$pc+4); \] Suppose the \( \text{pc} = 0x81fc08124 \), \[ \text{beq} \ \$s3,\$s7,\text{fib}_\text{exit} \] \[ \begin{array}{c} 000100: 00011 00111 00000000000001001 \\ \end{array} \] Then address = 0x00000009 Then address \( << 2 \) = 0x00000024 Then \( \$pc+4 \) = 0x81fc08128 Then \( \$pc+4 + \text{address}<<2 \) = 0x81fc0814c If branch occurred then \( \text{pc} \) = 0x81fc0814c else \( \text{pc} \) = 0x81fc08128 Signed Binary numbers Assume the word size is 4 bits, Then each bit represents a power = \([-2^3]2^22^12^0 = S421\] \(S\) represents the minus sign bit = \(-2^3 = -8\) <table> <thead> <tr> <th>S421</th> <th>0000</th> <th>0</th> </tr> </thead> <tbody> <tr> <td>S421</td> <td>0001</td> <td>1</td> </tr> <tr> <td>S421</td> <td>0010</td> <td>2</td> </tr> <tr> <td>S421</td> <td>0011</td> <td>3 = 2+1</td> </tr> <tr> <td>S421</td> <td>0100</td> <td>4</td> </tr> <tr> <td>S421</td> <td>0101</td> <td>5 = 4+1</td> </tr> <tr> <td>S421</td> <td>0110</td> <td>6 = 4+2</td> </tr> <tr> <td>S421</td> <td>0111</td> <td>7 = 4+2+1</td> </tr> <tr> <td>S421</td> <td>1000</td> <td>-8 = -8+0</td> </tr> <tr> <td>S421</td> <td>1001</td> <td>-7 = -8+1</td> </tr> <tr> <td>S421</td> <td>1010</td> <td>-6 = -8+2</td> </tr> <tr> <td>S421</td> <td>1011</td> <td>-5 = -8+2+1</td> </tr> <tr> <td>S421</td> <td>1100</td> <td>-4 = -8+4</td> </tr> <tr> <td>S421</td> <td>1101</td> <td>-3 = -8+4+1</td> </tr> <tr> <td>S421</td> <td>1110</td> <td>-2 = -8+4+2</td> </tr> <tr> <td>S421</td> <td>1111</td> <td>-1 = -8+4+2+1</td> </tr> </tbody> </table> unsigned 4 bit number: 0 to \(2^4 = 0..15\) signed 4 bit number: \(-2^3 \) to \(2^3 - 1 = -8 .. 7\) Sign numbers causes the loss of 1 bit accuracy This is why C language provides signed & unsigned keywords 1’s and 2’s complement One`s complement: invert each bit For example: 0100 becomes 1011 (Note: 1011 is –5 and not –4) The C language has a 1’s complement bitwise operator tilde (~). (i.e. ~1011 becomes 0100) The 1’s complement operator has the property: $X = ~~~X$; Two’s complement number (also negation) is expressed as two’s complement $= -X = (~X)+1$ The 2’s complement operator has the property: $X = - -X$; For example: 4 becomes –4 For example: 0100 becomes $(1011+0001) = 1100 = -4$ Sign extension Suppose we want to sign extend a 4-bit word to 8 bits. Then take the value of the sign bit and propagate it. For example: 1011 becomes 11111011 - Two’s complement allows the number to retain the same value even though we are adding 1’s! - $11111011 = -128 + 64 + 32 + 16 + 8 + 2 + 1 = -5$ - $1011 = -8 + 2 + 1 = -5$ - Two’s complement allows us to treat the sign bit as another digit! 1-bit addition The rules to add 1 bit numbers: Cin=Carry in; Cout=Carry Out <table> <thead> <tr> <th>Input</th> <th>2^1</th> <th>2^0</th> <th>=2^1 2^0</th> </tr> </thead> <tbody> <tr> <td>A</td> <td>B</td> <td>Cin</td> <td>Cout</td> </tr> <tr> <td>0</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>0</td> <td>1</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>0</td> <td>1</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>0</td> <td>0</td> <td>0</td> </tr> <tr> <td>1</td> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>1</td> <td>1</td> <td>0</td> <td>1</td> </tr> <tr> <td>1</td> <td>1</td> <td>1</td> <td>1</td> </tr> </tbody> </table> Sum = oddparity(A, B, Cin) = “odd number of bits” Cout = majority(A, B, Cin) = “majority vote” 1-bit sum is the same as adding the bits modular 2 (i.e base 2). N-bit addition N-bit addition requires using only the 1-bit addition table Suppose we want to add: 0101 + 0011 = 5 + 3 = 8 <table> <thead> <tr> <th>Cin</th> <th>1</th> <th>1</th> <th>1</th> </tr> </thead> <tbody> <tr> <td>5</td> <td>0</td> <td>1</td> <td>0</td> </tr> <tr> <td>3</td> <td>0</td> <td>0</td> <td>1</td> </tr> <tr> <td>Sum</td> <td>1</td> <td>0</td> <td>0</td> </tr> <tr> <td>Cout</td> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> If the word size is a 4 bits then the Sum of 1000 is really -8 which is incorrect. Hence the number field is too small. This is called arithmetic overflow = Cin_{sign} \^ Cout_{sign} Is the exclusive-or of the Cin and the Cout of the sign bit field N-bit subtraction Two’s complement allows us to treat N-bit subtraction as N-bit addition. Suppose we want to add: \( 5 - 3 = 0101 - 0011 = 3 \) First 2’s complement 3: \( 0011 \Rightarrow 1100 + 1 \Rightarrow 1101 \) Now just do addition: \( 5 + -3 = 0101 + 1101 \) <table> <thead> <tr> <th>Cin</th> <th>1</th> <th>1</th> </tr> </thead> <tbody> <tr> <td>5</td> <td>0</td> <td>1</td> </tr> <tr> <td>-3</td> <td>1</td> <td>1</td> </tr> <tr> <td>Sum</td> <td>0</td> <td>0</td> </tr> <tr> <td>Cout</td> <td>1</td> <td>1</td> </tr> </tbody> </table> Overflow = 0 \[ \text{arithmetic overflow bit} = \text{Cin}_{\text{sign}} \wedge \text{Cout}_{\text{sign}} = 1 \wedge 1 = 0 \] Multiply instruction Two’s complement allows us to also multiply by addition \[ 1 \times 1 = 1 \quad \text{and} \quad 0 \times M = 0 \] Warning: for each sub-product, you must extend the sign bit Note: a \( N \times N \) multiply results in a \( 2N \) product = \( 4 \times 4 = 8 \) bit \[ \begin{array}{cccccccccccc} -3 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 1 & 1 \\ +5 & & & & & & & & 0 & 1 & 0 & 1 \\ \hline \\ \multicolumn{12}{c}{1} \\ \end{array} \] \[ \begin{array}{cccccccccccc} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 1 & 1 \\ \hline \\ 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 1 \\ \end{array} \] Thus a \( 4 \times 4 \) multiply = 8 bit product. Add time = 1 clock. N x N Multiply Easier to place positive on top? \[ \begin{array}{cccccc} 5 & 0 & 1 & 0 & 1 \\ -3 & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 1 \\ \end{array} \] Add time = 6 clocks MIPS multiply instruction The MIPS does not have a general purpose multiply. It is required to copy the values in to special registers. Also, 32 x 32 multiply results in a 64 bit product. In fact, some RISC machines, use only shift instructions and claim the same performance as machines with a hardware multiply! Unsigned multiply: \texttt{multu} $rs,$rt # hi\_lo\_64 = $rs \times $rt Signed multiply: \texttt{mult} $rs,$rt # hi\_lo\_64 = $rs \times $rt move from low: \texttt{mflo} $rd # $rd = \text{lo} move from high: \texttt{mfhi} $rd # $rd = \text{hi} What is the MIPS for the following C code? \begin{align*} \text{int } x, y; & \quad y = 9*x + 2; \end{align*} Multiply by powers of 2: using shift - The binary radix allows for easy multiply by powers of 2. - The reason to use shifting is because it is fast (just move bits). - In fact, many computers use a barrel shifter. - A barrel shifter, shifts any amount in one clock cycle. - Whereas a so-so multiplier may take up to \( n \) clocks. - Multiply by a constant allows for further optimization. - For example, \( x \times 9 = x \times (8 + 1) = x \times 8 + x \times 1 \) \[ \begin{align*} & \text{sll } \$s1,\$s0,3 \quad \# 8 = 2^3 \\ & \text{add } \$s1,\$s0,\$0 \quad \# x \times 9 \end{align*} \] What is the MIPS for the following C code? ```c int x, y; y = 18*x + x/4; ``` Review: R-type instruction datapath (chapter 5) R - Format <table> <thead> <tr> <th>op</th> <th>rs</th> <th>rt</th> <th>rd</th> <th>shamt</th> <th>func</th> </tr> </thead> </table> ALU func $rd, $rs, $rt ALU control Zero ALU result Read register 1 Read register 2 Write register Write data Read data 1 Read data 2 RegWrite 32 5 32 5 32 5 32 5 Review: Lw I-type instruction datapath I - Format <table> <thead> <tr> <th>op</th> <th>rs</th> <th>rt</th> <th>offset</th> </tr> </thead> </table> Data Transfer ``` lw $rt, offset($rs) ``` ``` op rs rt offset ``` Review: Sw I-type instruction datapath I - Format <table> <thead> <tr> <th>op</th> <th>rs</th> <th>rt</th> <th>offset</th> </tr> </thead> </table> Data Transfer: `sw $rt, offset($rs)` Review: Branch I-type instruction datapath I - Format <table> <thead> <tr> <th>op</th> <th>rs</th> <th>rt</th> <th>offset</th> </tr> </thead> </table> Branch instruction: ``` beq $rs,$rt,offset ``` ALU control Sign extend Shift left 2 Write register Read data 1 Read data 2 RegWrite ALU Zero PC +4 ALU Zero PC ### ALU decoder <table> <thead> <tr> <th>Machine opcode</th> <th>Instruct Format</th> <th>IR[31-26] Opcode</th> <th>ALUop</th> <th>IR[5-0]</th> <th>ALUctl</th> <th>ALUctl</th> </tr> </thead> <tbody> <tr> <td>lw</td> <td>I-type</td> <td>100011</td> <td>00</td> <td>XXXXXX</td> <td>add</td> <td>010</td> </tr> <tr> <td>sw</td> <td>I-type</td> <td>101011</td> <td>00</td> <td>XXXXXX</td> <td>add</td> <td>010</td> </tr> <tr> <td>beq</td> <td>I-type</td> <td>000100</td> <td>01</td> <td>XXXXXX</td> <td>sub</td> <td>110</td> </tr> <tr> <td>add</td> <td>R-type</td> <td>000000</td> <td>10</td> <td>100000</td> <td>add</td> <td>010</td> </tr> <tr> <td>sub</td> <td>R-type</td> <td>000000</td> <td>10</td> <td>100010</td> <td>sub</td> <td>110</td> </tr> <tr> <td>and</td> <td>R-type</td> <td>000000</td> <td>10</td> <td>100100</td> <td>and</td> <td>000</td> </tr> <tr> <td>or</td> <td>R-type</td> <td>000000</td> <td>10</td> <td>100101</td> <td>or</td> <td>001</td> </tr> <tr> <td>slt</td> <td>R-type</td> <td>000000</td> <td>10</td> <td>101010</td> <td>slt</td> <td>111</td> </tr> </tbody> </table> \[ \text{ALUop} = \text{ALUopDecoder}(\text{Opcode}); \] \[ \text{ALUctl} = \text{ALUctlDecoder}(\text{ALUop}, \text{Funct}); \] Note: the Opcode field determines the I-type and R-type Note: the Funct field determines the ALUctl for R-type ALU decoders: ALUop and ALUctl <table> <thead> <tr> <th>op</th> <th>IR[31-26]</th> <th>ALUop</th> </tr> </thead> <tbody> <tr> <td>lw</td> <td>100011</td> <td>00</td> </tr> <tr> <td>sw</td> <td>101011</td> <td>00</td> </tr> <tr> <td>beq</td> <td>000100</td> <td>01</td> </tr> <tr> <td>add</td> <td>000000</td> <td>10</td> </tr> <tr> <td>sub</td> <td>000000</td> <td>10</td> </tr> <tr> <td>and</td> <td>000000</td> <td>10</td> </tr> <tr> <td>or</td> <td>000000</td> <td>10</td> </tr> <tr> <td>slt</td> <td>000000</td> <td>10</td> </tr> </tbody> </table> <table> <thead> <tr> <th>op</th> <th>IR[5-0]</th> </tr> </thead> <tbody> <tr> <td>lw</td> <td>xxxxxxxx</td> </tr> <tr> <td>sw</td> <td>xxxxxxxx</td> </tr> <tr> <td>beq</td> <td>xxxxxxxx</td> </tr> <tr> <td>add</td> <td>100000</td> </tr> <tr> <td>sub</td> <td>100010</td> </tr> <tr> <td>and</td> <td>100100</td> </tr> </tbody> </table> <table> <thead> <tr> <th>ALUctl</th> <th>Function</th> </tr> </thead> <tbody> <tr> <td>000</td> <td>bitwise and</td> </tr> <tr> <td>001</td> <td>bitwise or</td> </tr> <tr> <td>010</td> <td>integer add</td> </tr> <tr> <td>110</td> <td>integer sub</td> </tr> <tr> <td>111</td> <td>set less than</td> </tr> </tbody> </table> ALUop 31-26 ALU ctl 32 ALU control 32 Processor architecture with ALU decoder Opcode: IR[31-26] Funct: IR[5-0] R-format datapath control (Figures 5.20-24) <table> <thead> <tr> <th>Machine</th> <th>opcode</th> <th>R-format</th> <th>RegDst</th> <th>ALUSrc</th> <th>Memto</th> <th>Reg</th> <th>Write</th> <th>Mem</th> <th>Mem</th> <th>Mem</th> <th>Branch</th> <th>ALUop</th> </tr> </thead> <tbody> <tr> <td></td> <td>R-format</td> <td>1 ($rd)</td> <td>0 ($rt)</td> <td>0(alu)</td> <td></td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>10</td> </tr> </tbody> </table> ![Diagram of R-format datapath control](image_url) lw datapath control (Figure 5.25) <table> <thead> <tr> <th>Machine</th> <th>opcode</th> <th>RegDst</th> <th>ALUSrc</th> <th>Memto</th> <th>Reg</th> <th>Write</th> <th>Read</th> <th>Mem</th> <th>Write</th> <th>Branch</th> <th>ALUop</th> </tr> </thead> <tbody> <tr> <td>lw</td> <td>0</td> <td>($rt)</td> <td>1</td> <td>1</td> <td>1</td> <td>1</td> <td>0</td> <td>0</td> <td>0</td> <td>0</td> <td>01</td> </tr> </tbody> </table> [Diagram showing the lw datapath control with instructions and data flow.] sw datapath control <table> <thead> <tr> <th>Machine</th> <th>opcode</th> <th>RegDst</th> <th>ALUSrc</th> <th>Memto</th> <th>Reg Write</th> <th>Mem Read</th> <th>Mem Write</th> <th>Branch</th> <th>ALUop</th> </tr> </thead> <tbody> <tr> <td></td> <td>sw</td> <td>X</td> <td>1 (offset)</td> <td>X</td> <td>0</td> <td>0</td> <td>1</td> <td>0</td> <td>01 (add)</td> </tr> </tbody> </table> ![Diagram of SW Datapath Control] beq datapath control (Figure 5.26) <table> <thead> <tr> <th>Machine</th> <th>opcode</th> <th>RegDst</th> <th>ALUSrc</th> <th>Memto</th> <th>Reg</th> <th>Write</th> <th>Mem Read</th> <th>Mem Write</th> <th>Branch</th> <th>ALUop</th> </tr> </thead> <tbody> <tr> <td></td> <td>beq</td> <td>X</td> <td>0</td> <td></td> <td>X</td> <td>0</td> <td>0</td> <td>0</td> <td>1</td> <td>01 (sub)</td> </tr> </tbody> </table> Diagram of the beq instruction's datapath control. A multi-cycle processor has the following instruction times: - **add (44%)** = 6ns = Fetch(2ns) + RegR(1ns) + ALU(2ns) + RegW(1ns) - **lw (24%)** = 8ns = Fetch(2ns) + RegR(1ns) + ALU(2ns) + MemR(2ns) + RegW(1ns) - **sw (12%)** = 7ns = Fetch(2ns) + RegR(1ns) + ALU(2ns) + MemW(2ns) - **beq (18%)** = 5ns = Fetch(2ns) + RegR(1ns) + ALU(2ns) - **j (2%)** = 2ns = Fetch(2ns) Single-cycle CPI = 44%×8ns + 24%×8ns + 12%×8ns + 18%×8ns + 2%×8ns = 8ns Multi-cycle CPI = 44%×6ns + 24%×8ns + 12%×7ns + 18%×5ns + 2%×2ns = 6.3ns \[ \frac{\text{single - cycle CPI}}{\text{multi - cycle CPI}} = \frac{8ns}{6.3ns} = 1.27 \text{ times faster} \] **Architectural improved performance without speeding up the clock!** Single-cycle problems - **Single Cycle Problems:** - Clock cycle is the slowest instruction delay = 8ns = 125MHz - What if we had a more complicated instruction like floating point? (fadd = 30ns, fmul=100ns) Then clock cycle = 100ns = 10 MHz - Wasteful of chip area (2 adders + 1 ALU). Cannot reuse resources. - Wasteful of memory: separate instructions & data (Harvard architecture) - **Solutions:** - Use a “smaller” cycle time (if the technology can do it) - Have different instructions take different numbers of cycles (multi-cycle) - Better reuse of functional units: a “multicycle” datapath (1 ALU instead of 3 adders) - **Multi-cycle approach** - Clock cycle is the slowest function unit = 2ns = 500MHz - We will be reusing functional units: - ALU used to increment PC (Adder1) & compute address (Adder2) - Memory reused for instruction and data (Von Neuman architecture) Some Design Trade-offs High level design techniques Algorithms: change instruction usage \[ \text{minimize } \sum n_{\text{instruction}} \times t_{\text{instruction}} \] Architecture: Datapath, FSM, Microprogramming adders: ripple versus carry lookahead multiplier types, … Lower level design techniques (closer to physical design) clocking: single versus multi clock technology: layout tools: better place and route process technology: 0.5 micron to .18 micron Multi-cycle Datapath: with controller Multi-cycle Datapath Multi-cycle = 1 Mem + 5.5 Muxes + 1 ALU + 5 Registers (A,B,IR,MDR,ALUOut) Single-cycle = 2 Mem + 4.0 Muxes + 1 ALU + 2 adders Multi-cycle: 5 execution steps - $T_1 (a, lw, sw, beq, j)$ Instruction Fetch - $T_2 (a, lw, sw, beq, j)$ Instruction Decode and Register Fetch - $T_3 (a, lw, sw, beq, j)$ Execution, Memory Address Calculation, or Branch Completion - $T_4 (a, lw, sw)$ Memory Access or R-type instruction completion - $T_5 (a, lw)$ Write-back step **INSTRUCTIONS TAKE FROM 3 - 5 CYCLES!** # Multi-cycle Approach All operations in each clock cycle $T_i$ are done in parallel not sequential! For example, $T_1$, IR = Memory[PC] and PC=PC+4 are done simultaneously! <table> <thead> <tr> <th>Step name</th> <th>Action for R-type instructions</th> <th>Action for memory-reference instructions</th> <th>Action for branches</th> <th>Action for jumps</th> </tr> </thead> <tbody> <tr> <td>$T_1$ Instruction fetch</td> <td></td> <td>IR = Memory[PC]</td> <td>PC = PC + 4</td> <td></td> </tr> <tr> <td>$T_2$ Instruction decode/ register fetch</td> <td></td> <td>A = Reg [IR[25-21]]</td> <td>B = Reg [IR[20-16]]</td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td>ALUOut = PC + (sign-extend (IR[15-0]) &lt;&lt; 2)</td> <td></td> </tr> <tr> <td>$T_3$ Execution, address computation, branch/</td> <td>ALUOut = A op B</td> <td>ALUOut = A + sign-extend (IR[15-0])</td> <td>if (A == B) then</td> <td></td> </tr> <tr> <td>jump completion</td> <td></td> <td></td> <td>PC = ALUOut</td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td>PC = PC [31-28] II</td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td>(IR[25-0]&lt;&lt;2)</td> <td></td> </tr> <tr> <td>$T_4$ Memory access or R-type completion</td> <td>Reg [IR[15-11]] = ALUOut</td> <td>Load: MDR = Memory[ALUOut] or Store: Memory [ALUOut] = B</td> <td></td> <td></td> </tr> <tr> <td>$T_5$ Memory read completion</td> <td></td> <td>Load: Reg[IR[20-16]] = MDR</td> <td></td> <td></td> </tr> </tbody> </table> Between Clock $T_2$ and $T_3$ the microcode sequencer will do a dispatch 1 Multi-cycle using Microprogramming Finite State Machine (hardwired control) - Inputs from instruction register opcode field - State register - Outputs from combinational control logic - Datapath control outputs - Next state Microcode controller - Microcode storage - Outputs - Datapath control outputs - Input - Sequencing control - Adder - Address select logic - Microprogram counter - Inputs from instruction register opcode field Requires microcode memory to be faster than main memory Microcode: Trade-offs - Distinction between specification & implementation is sometimes blurred - Specification Advantages: - Easy to design and write (maintenance) - Design architecture and microcode in parallel - Implementation (off-chip ROM) Advantages - Easy to change since values are in memory - Can emulate other architectures - Can make use of internal registers - Implementation Disadvantages, SLOWER now that: - Control is implemented on same chip as processor - ROM is no longer faster than RAM - No need to go back and make changes ## Microinstruction format <table> <thead> <tr> <th>Field name</th> <th>Value</th> <th>Signals active</th> <th>Comment</th> </tr> </thead> <tbody> <tr> <td><strong>ALU control</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Add</td> <td>ALUOp = 00</td> <td></td> <td>Cause the ALU to add.</td> </tr> <tr> <td>Subt</td> <td>ALUOp = 01</td> <td></td> <td>Cause the ALU to subtract; this implements the compare for branches.</td> </tr> <tr> <td>Func code</td> <td>ALUOp = 10</td> <td></td> <td>Use the instruction’s function code to determine ALU control.</td> </tr> <tr> <td><strong>SRC1</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>PC</td> <td>ALUSrcA = 0</td> <td></td> <td>Use the PC as the first ALU input.</td> </tr> <tr> <td>A</td> <td>ALUSrcA = 1</td> <td></td> <td>Register A is the first ALU input.</td> </tr> <tr> <td><strong>SRC2</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>B</td> <td>ALUSrcB = 00</td> <td></td> <td>Register B is the second ALU input.</td> </tr> <tr> <td>4</td> <td>ALUSrcB = 01</td> <td></td> <td>Use 4 as the second ALU input.</td> </tr> <tr> <td>Extend</td> <td>ALUSrcB = 10</td> <td></td> <td>Use output of the sign extension unit as the second ALU input.</td> </tr> <tr> <td>Extshift</td> <td>ALUSrcB = 11</td> <td></td> <td>Use the output of the shift-by-two unit as the second ALU input.</td> </tr> <tr> <td><strong>Register control</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Read</td> <td></td> <td></td> <td>Read two registers using the rs and rt fields of the IR as the register numbers and putting the data into registers A and B.</td> </tr> <tr> <td>Write ALU</td> <td>RegWrite,</td> <td>RegDst = 1, MemtoReg = 0</td> <td>Write a register using the rd field of the IR as the register number and the contents of the ALUOut as the data.</td> </tr> <tr> <td>Write MDR</td> <td>RegWrite,</td> <td>RegDst = 0, MemtoReg = 1</td> <td>Write a register using the rt field of the IR as the register number and the contents of the MDR as the data.</td> </tr> <tr> <td><strong>Memory</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Read PC</td> <td>MemRead,</td> <td>lorD = 0</td> <td>Read memory using the PC as address; write result into IR (and the MDR).</td> </tr> <tr> <td>Read ALU</td> <td>MemRead,</td> <td>lorD = 1</td> <td>Read memory using the ALUOut as address; write result into MDR.</td> </tr> <tr> <td>Write ALU</td> <td>MemWrite,</td> <td>lorD = 1</td> <td>Write memory using the ALUOut as address, contents of B as the data.</td> </tr> <tr> <td><strong>PC write control</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>ALU</td> <td>PCSource = 00</td> <td></td> <td>Write the output of the ALU into the PC.</td> </tr> <tr> <td>ALUOut-cond</td> <td>PCSource = 01</td> <td></td> <td>If the Zero output of the ALU is active, write the PC with the contents of the register ALUOut.</td> </tr> <tr> <td>jump address</td> <td>PCSource = 10</td> <td></td> <td>Write the PC with the jump address from the instruction.</td> </tr> <tr> <td><strong>Sequencing</strong></td> <td></td> <td></td> <td></td> </tr> <tr> <td>Seq</td> <td>AddrCtl = 11</td> <td></td> <td>Choose the next microinstruction sequentially.</td> </tr> <tr> <td>Fetch</td> <td>AddrCtl = 00</td> <td></td> <td>Go to the first microinstruction to begin a new instruction.</td> </tr> <tr> <td>Dispatch 1</td> <td>AddrCtl = 01</td> <td></td> <td>Dispatch using the ROM 1.</td> </tr> <tr> <td>Dispatch 2</td> <td>AddrCtl = 10</td> <td></td> <td>Dispatch using the ROM 2.</td> </tr> </tbody> </table> Microinstruction format: Maximally vs. Minimally Encoded • **No encoding:** – 1 bit for each datapath operation – faster, requires more memory (logic) – used for Vax 780 — an astonishing 400K of memory! • **Lots of encoding:** – send the microinstructions through logic to get control signals – uses less memory, slower • **Historical context of CISC:** – Too much logic to put on a single chip with everything else – Use a ROM (or even RAM) to hold the microcode – It’s easy to add new instructions **Microprogramming: program** <table> <thead> <tr> <th>Label</th> <th>ALU control</th> <th>SRC1</th> <th>SRC2</th> <th>Register control</th> <th>Memory</th> <th>PCWrite control</th> <th>Sequencing</th> </tr> </thead> <tbody> <tr> <td>Fetch</td> <td>Add</td> <td>PC</td> <td>4</td> <td>Read PC</td> <td>ALU</td> <td>Seq</td> <td></td> </tr> <tr> <td></td> <td>Add</td> <td>PC</td> <td>Extshft</td> <td>Read</td> <td></td> <td>Dispatch 1</td> <td></td> </tr> <tr> <td>Mem1</td> <td>Add</td> <td>A</td> <td>Extend</td> <td></td> <td></td> <td>Dispatch 2</td> <td></td> </tr> <tr> <td>LW2</td> <td>Add</td> <td>A</td> <td>Extend</td> <td>Read ALU</td> <td>Seq</td> <td></td> <td></td> </tr> <tr> <td>SW2</td> <td></td> <td></td> <td></td> <td>Write MDR</td> <td>Fetch</td> <td></td> <td></td> </tr> <tr> <td>Rformat1</td> <td>Func code</td> <td>A</td> <td>B</td> <td>Write ALU</td> <td>Seq</td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> <td></td> <td>Fetch</td> <td></td> <td></td> </tr> <tr> <td>BEQ1</td> <td>Subt</td> <td>A</td> <td>B</td> <td>ALUOut-cond</td> <td>Fetch</td> <td></td> <td></td> </tr> <tr> <td>JUMP1</td> <td></td> <td></td> <td></td> <td>Jump address</td> <td>Fetch</td> <td></td> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th><strong>Step name</strong></th> <th><strong>Action for R-type instructions</strong></th> <th><strong>Action for memory-reference instructions</strong></th> <th><strong>Action for branches</strong></th> <th><strong>Action for jumps</strong></th> </tr> </thead> <tbody> <tr> <td>Instruction fetch</td> <td>IR = Memory[PC]</td> <td></td> <td>PC = PC + 4</td> <td></td> </tr> <tr> <td>Instruction decode/register fetch</td> <td></td> <td>A = Reg [IR[25-21]]</td> <td>B = Reg [IR[20-16]]</td> <td></td> </tr> <tr> <td></td> <td></td> <td>ALUOut = PC + (sign-extend (IR[15-0]) &lt;&lt; 2)</td> <td></td> <td></td> </tr> <tr> <td>Execution, address computation, branch/</td> <td>ALUOut = A op B</td> <td>ALUOut = A + sign-extend (IR[15-0])</td> <td>if (A == B) then</td> <td>PC = PC [31-28] II</td> </tr> <tr> <td>jump completion</td> <td></td> <td></td> <td>PC = ALUOut</td> <td>(IR[25-0]&lt;&lt;&lt;2)</td> </tr> <tr> <td>Memory access or R-type completion</td> <td>Reg [IR[15-11]] = ALUOut</td> <td>Load: MDR = Memory[ALUOut] or</td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td>Store: Memory [ALUOut] = B</td> <td></td> <td></td> </tr> <tr> <td>Memory read completion</td> <td>Load: Reg[IR[20-16]] = MDR</td> <td></td> <td></td> <td></td> </tr> </tbody> </table> Microprogramming: program overview Fetch Fetch+1 Dispatch 1 T1 Rformat1 BEQ1 JUMP1 Mem1 LW2 SW2 T2 T3 T4 Rformat1+1 T5 LW2+1 Microprogram stepping: \( T_1 \) Fetch (Done in parallel) \( IR \leftarrow \text{MEMORY}[PC] \) & \( PC \leftarrow PC + 4 \) \[ T_2 \text{ Fetch } + 1 \] \[ A \leftarrow \text{Reg[IR[25-21]]} \land B \leftarrow \text{Reg[IR[20-16]]} \land \text{ALUOut} \leftarrow \text{PC+signext(IR[15-0])} \ll 2 \] \[ \text{ALUOut} \leftarrow A + \text{sign\_extend}([IR[15-0]]) \] Dispatch 2: LW2 MDR ← Memory[ALUOut] Reg[ IR[20-16] ] ← MDR Dispatch 2: SW2 Memory[ ALUOut ] ← B Label ALU SRC1 SRC2 RCntl Memory WriteALU PCwrite Seq Fetch SW2 CWRU EECS 322 44 T₃ Dispatch 1: Rformat1 \[ \text{ALUOut} \leftarrow A \ \text{op}(\text{IR}[31-26]) \ B \] **Diagram:** - **PC** - **0 Mux 1** - **Address Memory MemData** - **Write data** - **Instruction [25–21]** - **Instruction [20–16]** - **Instruction [15–11]** - **Instruction [15–0]** - **Memory data register** - **0 Mux 1** - **0 Mux 1** - **Instruction [15–0]** - **Instruction [5–0]** - **MemtoReg** - **ALU result** - **ALU OUT** - **ALU control** - **Zero** - **ALUSrcB ALUOp** **Tables:** - **Label**: Rf...1 - **ALU op**: A - **SRC1**: A - **SRC2**: B - **RCntl**: op(IR[31-26]) - **Memory**: Seq - **PCwrite**: Seq - **Seq**: Seq **Dispatch 1: Rformat1+1** Diagram showing the flow of data and control signals through various modules such as PC, ALU, Instruction Register (IR), Memory, and registries. The diagram illustrates the process of fetching, decoding, and executing instructions with specific paths for addressing, data read/write, and control signals. ### Labels and Symbols - **Label**: Instructions or control signals. - **ALU**: Arithmetic Logic Unit. - **SRC1**: Source register 1. - **SRC2**: Source register 2. - **RCntl**: Register control. - **Memory**: Memory access. - **IR**: Instruction Register. - **WALU**: Word ALU. - **PCwrite**: Program Counter write. - **Seg**: Segment. - **Fetch**: Instruction fetch. ### Key Concepts - **Instruction Decode**: The process of interpreting the instruction fields to determine the operation and operands. - **ALU Operations**: Include arithmetic and logic operations like add, subtract, logical AND, OR, etc. - **Memory Access**: Reading and writing data to memory for instructions and intermediate results. - **Register Operations**: Read, write, and transfer data between registers. ### DiagramDetails - **PC (Program Counter)**: Batches the program counter with a multiplexer (MUX) to select the next address. - **Address**: Calculates the memory address based on the program counter. - **Memory**: Accesses memory data, which can be read or written. - **ALU**: Performs arithmetic and logic operations based on the input data and control signals. - **Instruction**: Represents the current instruction being processed. - **Registers**: Contain data used for intermediate calculations and final results. - **Sign Extend**: Extends the sign bit of the input data for certain operations. - **Shift**: Performs left shift operations on data. - **ALU Out**: The output of the ALU, which can be directed to various destinations. The diagram highlights the flow of data and control signals, showcasing how each component interacts to execute instructions efficiently. If \((A - B == 0)\) \{ \text{PC} \leftarrow \text{ALUOut}; \} $T_3$ Dispatch 1: Jump1 $PC \leftarrow PC[31-28] \ || \ IR[25-0] \ll< 2$ --- **Label** ALU SRC1 SRC2 RCntl Memory PCwrite Seq Fetch Jump1
{"Source-Url": "http://bear.ces.cwru.edu:80/eecs_314/eecs_322_20010228.pdf", "len_cl100k_base": 10653, "olmocr-version": "0.1.50", "pdf-total-pages": 48, "total-fallback-pages": 0, "total-input-tokens": 87014, "total-output-tokens": 11097, "length": "2e13", "weborganizer": {"__label__adult": 0.000644683837890625, "__label__art_design": 0.0010938644409179688, "__label__crime_law": 0.0005064010620117188, "__label__education_jobs": 0.0009069442749023438, "__label__entertainment": 0.0001550912857055664, "__label__fashion_beauty": 0.0003199577331542969, "__label__finance_business": 0.0006194114685058594, "__label__food_dining": 0.0007357597351074219, "__label__games": 0.001743316650390625, "__label__hardware": 0.055206298828125, "__label__health": 0.0006742477416992188, "__label__history": 0.000682830810546875, "__label__home_hobbies": 0.0006628036499023438, "__label__industrial": 0.003841400146484375, "__label__literature": 0.0003287792205810547, "__label__politics": 0.0005092620849609375, "__label__religion": 0.0009050369262695312, "__label__science_tech": 0.20068359375, "__label__social_life": 8.612871170043945e-05, "__label__software": 0.0095672607421875, "__label__software_dev": 0.71728515625, "__label__sports_fitness": 0.0007863044738769531, "__label__transportation": 0.0017747879028320312, "__label__travel": 0.0003592967987060547}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 28285, 0.0925]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 28285, 0.48525]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 28285, 0.65502]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 493, false], [493, 1072, null], [1072, 1909, null], [1909, 2420, null], [2420, 2828, null], [2828, 3495, null], [3495, 4042, null], [4042, 4595, null], [4595, 5269, null], [5269, 5443, null], [5443, 6119, null], [6119, 6796, null], [6796, 7109, null], [7109, 7288, null], [7288, 7430, null], [7430, 7710, null], [7710, 7710, null], [7710, 8891, null], [8891, 9748, null], [9748, 9825, null], [9825, 10248, null], [10248, 10657, null], [10657, 11017, null], [11017, 11411, null], [11411, 12114, null], [12114, 13020, null], [13020, 13487, null], [13487, 13525, null], [13525, 13674, null], [13674, 14047, null], [14047, 16195, null], [16195, 16689, null], [16689, 17253, null], [17253, 21303, null], [21303, 21822, null], [21822, 24717, null], [24717, 24858, null], [24858, 24984, null], [24984, 25161, null], [25161, 25228, null], [25228, 25266, null], [25266, 25289, null], [25289, 25411, null], [25411, 26044, null], [26044, 28075, null], [28075, 28137, null], [28137, 28285, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 493, true], [493, 1072, null], [1072, 1909, null], [1909, 2420, null], [2420, 2828, null], [2828, 3495, null], [3495, 4042, null], [4042, 4595, null], [4595, 5269, null], [5269, 5443, null], [5443, 6119, null], [6119, 6796, null], [6796, 7109, null], [7109, 7288, null], [7288, 7430, null], [7430, 7710, null], [7710, 7710, null], [7710, 8891, null], [8891, 9748, null], [9748, 9825, null], [9825, 10248, null], [10248, 10657, null], [10657, 11017, null], [11017, 11411, null], [11411, 12114, null], [12114, 13020, null], [13020, 13487, null], [13487, 13525, null], [13525, 13674, null], [13674, 14047, null], [14047, 16195, null], [16195, 16689, null], [16689, 17253, null], [17253, 21303, null], [21303, 21822, null], [21822, 24717, null], [24717, 24858, null], [24858, 24984, null], [24984, 25161, null], [25161, 25228, null], [25228, 25266, null], [25266, 25289, null], [25289, 25411, null], [25411, 26044, null], [26044, 28075, null], [28075, 28137, null], [28137, 28285, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, true], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 28285, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, true], [5000, 28285, null]], "pdf_page_numbers": [[0, 0, 1], [0, 493, 2], [493, 1072, 3], [1072, 1909, 4], [1909, 2420, 5], [2420, 2828, 6], [2828, 3495, 7], [3495, 4042, 8], [4042, 4595, 9], [4595, 5269, 10], [5269, 5443, 11], [5443, 6119, 12], [6119, 6796, 13], [6796, 7109, 14], [7109, 7288, 15], [7288, 7430, 16], [7430, 7710, 17], [7710, 7710, 18], [7710, 8891, 19], [8891, 9748, 20], [9748, 9825, 21], [9825, 10248, 22], [10248, 10657, 23], [10657, 11017, 24], [11017, 11411, 25], [11411, 12114, 26], [12114, 13020, 27], [13020, 13487, 28], [13487, 13525, 29], [13525, 13674, 30], [13674, 14047, 31], [14047, 16195, 32], [16195, 16689, 33], [16689, 17253, 34], [17253, 21303, 35], [21303, 21822, 36], [21822, 24717, 37], [24717, 24858, 38], [24858, 24984, 39], [24984, 25161, 40], [25161, 25228, 41], [25228, 25266, 42], [25266, 25289, 43], [25289, 25411, 44], [25411, 26044, 45], [26044, 28075, 46], [28075, 28137, 47], [28137, 28285, 48]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 28285, 0.27993]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
a001e5acf475d44407f6a320ccdd5dc2da4ba0b4
From verification to synthesis Verification: first write program (or model of a system), then specify formal properties, then check correctness. Synthesis: first specify formal properties, then let synthesizer automatically generate a correct program. Put another way: from imperative (how) to declarative (what) design; “raising the level of abstraction”. What is synthesis? Roughly: \[ \exists P : \forall x : \varphi(x, P(x)) \] Many different variants, depending on what is \( P \), \( \varphi \), and how search is done. Very old topic (Church, 1960s) recently rejuvenated. Program synthesis and proofs From 2\textsuperscript{nd} order formula \[ \exists P : \forall x : \varphi(x, P(x)) \] to 1\textsuperscript{st} order formula \[ \forall x : \exists y : \varphi(x, y) \] Synthesizing program \( P \) can be done by proving \textit{constructively} that the above formula is valid. \textbf{Deductive} program synthesis. ### Dimensions in Synthesis (Gulwani) **Concept Language** (Application) - Programs - Straight-line programs - Automata - Queries - Sequences **User Intent** (Ambiguity) - Logic, Natural Language - Examples, Demonstrations/Traces **Search Technique** (Algorithm) - SAT/SMT solvers (Formal Methods) - A*-style goal-directed search (AI) - Version space algebras (Machine Learning) Also: logic synthesis --- ### Compilers vs. Synthesizers (Gulwani) <table> <thead> <tr> <th>Dimension</th> <th>Compilers</th> <th>Synthesizers</th> </tr> </thead> <tbody> <tr> <td>Concept Language</td> <td>Executable Program</td> <td>Variety of concepts: Program, Automata, Query, Sequence</td> </tr> <tr> <td>User Intent</td> <td>Structured language</td> <td>Variety/mixed form of constraints: logic, examples, traces</td> </tr> <tr> <td>Search Technique</td> <td>Syntax-directed translation (No new algorithmic insights)</td> <td>Uses some kind of search (Discovers new algorithmic insights)</td> </tr> </tbody> </table> Designing controllers can be tricky and time consuming Example: Electrical Power Generation and Distribution System (EPS) of a modern aircraft Thanks to: Pierluigi Nuzzo Antonio Iannapollo Designing controllers can be tricky and time consuming Example: EPS requirements (in English) Assumptions: A2) At least one power source is always “healthy” (i.e. it is operational and can be inserted into the network to deliver power); A3) Failures can only affect the power sources; once a power source becomes “unhealthy” (i.e. it is not operational and cannot be inserted into the network to deliver power), it will never return to be “healthy” (e.g., turned back on) during the cruising phase of the mission; A4) An AC bus is correctly powered if the root-mean-square (RMS) voltage at its loads is between 110 V and 120 V and the frequency is 400 Hz. Guarantees: Under the above assumptions, the BPCU offers the following guarantees: G1) At start-up all the power source contactors are “open”; G2) In normal conditions (i.e. no faults or failures in the system) G_l and G_h are “on” and provide power for the left side and the right side of the system, respectively; auxiliary power units are “off”; C_4 and C_10 are open (“off”); G3) No AC bus is powered by more than one power source at the same time, i.e. AC power sources can never be paralleled; G4) It never happens that both the APU are inserted into the network at the same time; G5) AC buses cannot be unpowered for more than a well-defined length of time; G6) DC buses have to stay powered, at least in a “reduced performance” mode, which occurs when only one HVRU is used; G7) The left AC bus B_l must always be powered from the first available source from the ordered list (G_1, A_1, A_2, G_3); G8) The right AC bus B_r must always be powered from the first available source from the ordered list (G_10, A_10, A_11, G_1). Designing controllers can be tricky and time consuming Example: EPS requirements (in English) – zooming in A2) At least one power source is always “healthy” (i.e. it is operational and can be inserted into the network to deliver power); G1) At start-up all the power source contactors are “open”; G3) No AC bus is powered by more than one power source at the same time, i.e. AC power sources can never be paralleled; Designing controllers can be tricky and time consuming Example: EPS “hand-written” controller Designing controllers can be tricky and time consuming Example: EPS “hand-written” controller Design time ~ 1 week [Nuzzo] (but have to verify also) For a real controller, it could be months [e.g., robotic controllers, Willow Garage] Can design time be improved? Declarative specification of controllers At the outset the controller is just a box with inputs and outputs: Declarative specification of controllers At the outset the controller is just a box with inputs and outputs: Example: EPS controller We can specify the input-output behavior of the controller in a high-level language, e.g., in **temporal logic**. Declarative specification of controllers Example: LTL specification for EPS ~40 lines # Assumptions \[ \begin{align*} & \neg \text{gl\_healthy} \land \neg \text{gr\_healthy} \land \neg \text{al\_healthy} \land \neg \text{ar\_healthy} \\ & \neg \text{gl\_healthy} \lor \neg \text{gr\_healthy} \lor \neg \text{al\_healthy} \lor \neg \text{ar\_healthy} \\ & \neg \text{gl\_healthy} \implies X(\neg \text{gl\_healthy}) \\ & \neg \text{gr\_healthy} \implies X(\neg \text{gr\_healthy}) \\ & \neg \text{al\_healthy} \implies X(\neg \text{al\_healthy}) \\ & \neg \text{ar\_healthy} \implies X(\neg \text{ar\_healthy}) \end{align*} \] # Guarantees \[ \begin{align*} & \neg \text{c1} \land \neg \text{c2} \land \neg \text{c3} \land \neg \text{c4} \land \neg \text{c5} \land \neg \text{c6} \land \neg \text{c7} \land \neg \text{c8} \land \neg \text{c9} \land \neg \text{c10} \land \neg \text{c11} \land \neg \text{c12} \land \neg \text{c13} \\ & \neg \text{c7} \land X(\text{c8}) \land X(\text{c11}) \land X(\text{c12}) \land X(\text{c13}) \\ & \neg (\text{c2} \land \text{c3}) \\ & \neg (\text{c1} \land \text{c5} \land (\text{al\_healthy} \lor \text{ar\_healthy})) \\ & \neg (\text{c4} \land \text{c6} \land (\text{al\_healthy} \lor \text{ar\_healthy})) \\ & (X(\text{gl\_healthy}) \land X(\text{gr\_healthy})) \implies X(\neg \text{c2}) \land X(\neg \text{c3}) \land X(\neg \text{c9}) \land X(\neg \text{c10}) \\ & (X(\neg \text{gl\_healthy}) \land X(\neg \text{gr\_healthy})) \implies X(\text{c9}) \land X(\text{c10}) \\ & X(\neg \text{gl\_healthy}) \implies X(\neg \text{c1}) \\ & X(\neg \text{gr\_healthy}) \implies X(\neg \text{c4}) \\ & X(\neg \text{al\_healthy}) \implies X(\neg \text{c2}) \\ & X(\neg \text{ar\_healthy}) \implies X(\neg \text{c3}) \\ & X(\text{gl\_healthy}) \implies X(\text{c1}) \\ & X(\text{gr\_healthy}) \implies X(\text{c4}) \\ & \ldots \\ & \neg \text{gl\_healthy} \implies X(\text{c5}) \\ & \neg \text{gr\_healthy} \implies X(\text{c6}) \\ & (X(\text{gl\_healthy}) \land X(\text{gr\_healthy})) \implies (X(\neg \text{c5}) \land X(\neg \text{c6})) \\ & \neg X(\text{gl\_healthy}) \land X(\text{gr\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \\ & \neg X(\text{gl\_healthy}) \land X(\text{gr\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \\ && \implies (X(\text{c2}) \land X(\text{c3})) \\ & \neg X(\text{gl\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \land X(\text{ar\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \\ && \implies X(\text{c2}) \\ & \neg X(\text{al\_healthy}) \land X(\text{c2}) \\ & X(\text{al\_healthy}) \land X(\text{c2}) \\ & \neg X(\text{ar\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy}) \\ && \implies X(\text{c3}) \\ & (X(\text{gl\_healthy}) \land X(\text{gr\_healthy}) \land X(\text{al\_healthy}) \land X(\text{ar\_healthy})) \implies (X(\text{c2}) \land X(\text{c3})) \end{align*} \] The controller synthesis problem Given formula specification (e.g., in LTL) synthesize controller (e.g., FSM) which implements the specification (or state that such a controller does not exist). Automatic controller synthesis from declarative specifications Example: controller for EPS synthesized from previous LTL spec using Tulip (Caltech) ~3k lines of Matlab Automatic controller synthesis from declarative specifications Example: controller for EPS synthesized using Tulip (Caltech), ~40 states – zooming in ``` switch state case 1 if isequal(g1_healthy, 1) && isequal(g2_healthy, 1) && isequal(g3_healthy, 1) && isequal(g4_healthy, 1) state = 0; c6 = 0; c3 = 0; c9 = 0; c8 = 0; c2 = 0; c13 = 0; c12 = 0; c11 = 0; c10 = 0; c7 = 0; c6 = 0; c5 = 0; c4 = 0; else disp('Cannot find a valid successor, environment assumption is likely to be violated'); c6 = 0; c3 = 0; c9 = 0; c8 = 0; c2 = 0; ``` Synthesis in these two lectures Part 1: Controller synthesis and game solving. Part 2: Example-guided and syntax-guided synthesis. Declarative specification of controllers At the outset the controller is just a box with inputs and outputs: We can specify the input-output behavior of the controller in a high-level language, e.g., in temporal logic. Controller synthesis (reactive synthesis) [Pnueli-Rosner, POPL 1989] Given interface of controller: \[ \begin{array}{c} p_1 \quad \vdots \quad p_n \\ \quad \vdots \\ q_1 \quad \vdots \quad q_m \end{array} \] and given temporal logic formula $\phi$ over set of input/output variables, synthesize a controller (= state machine) $M$, such that all behaviors of $M$ (for any sequence of inputs) satisfy $\phi$. Note: other notions of controller synthesis exist in the literature. See "Bridging the gap" paper on the course web site for details. Examples Consider controller interface: \[ \begin{array}{c} p \\ \rightarrow \\ \rightarrow \quad q \end{array} \] and specifications \[ \begin{align*} \varphi_1 &= G(p \rightarrow Xq) \\ \varphi_2 &= G(p \leftrightarrow Xq) \\ \varphi_3 &= G(q \leftrightarrow Xp) \end{align*} \] Examples Consider controller interface: \[ \begin{align*} \varphi_1 &= G(p \rightarrow Xq) \\ \varphi_2 &= G(p \leftrightarrow Xq) \\ \varphi_3 &= G(q \leftrightarrow Xp) \end{align*} \] No solution: controller cannot foresee the future! Satisfiability vs. realizability Satisfiability: exists some behavior that satisfies the specification. (In this behavior, we may choose both inputs and outputs as we wish.) Realizability: exists controller that implements the specification. Must work for all input sequences, since inputs are uncontrollable. Inherently different problems, also w.r.t. complexity: LTL satisfiability: PSPACE LTL realizability: 2EXPTIME Controller synthesis algorithms: computing strategies in games Solving safety games Solving reachability games Solving deterministic Büchi games (liveness) Remarks on the general LTL synthesis problem Safety automata In some fortunate cases, the LTL specification can be translated to a safety automaton. Example: \( \varphi = G(p \rightarrow q) \) Automaton: “Spreading” a safety automaton to a game We need to separate the input moves from the output moves: Automaton: Game: Safety games Input (environment) states: Output (controller) states: Bad state: Goal: find **winning strategy** = avoiding bad state Solving safety games 1. Compute set of losing states, starting with $Losing := \{\bullet\}$. 2. If initial state in $Losing$, no strategy exists. 3. Otherwise, all remaining states are winning. Extract strategy from them by choosing outputs that avoid the losing states. Solving safety games 1. Compute set of losing states, starting with \( \text{Losing} := \{ \square \} \); - repeat - \( \text{UncontrollablyLosing} := \{ s \mid s \text{ has uncontrollable succ in } \text{Losing} \} \); - \( \text{ControllablyLosing} := \{ s \mid \text{all controllable succs of } s \text{ are in } \text{Losing} \} \); - \( \text{Losing} := \text{Losing} \cup \text{UncontrollablyLosing} \cup \text{ControllablyLosing} \); - until \( \text{Losing} \) does not change; Solving safety games - Extracting the strategy: “cut” controllable transitions in order to avoid losing states. - Strategy is **state-based** (also called “positional”, or “memoryless”). Controller synthesis algorithms Solving safety games **Solving reachability games** Solving deterministic Büchi games (liveness) Remarks on the general LTL synthesis problem Reachability games: dual of safety games Reachability game: trying to reach a target state. Observation: what is Losing for the safety player is Winning for the reachability player (and vice versa). Solving reachability games: direct algorithm 1. Compute set of Winning states; - \( \text{Winning} := \{ \text{happy} \} \); - repeat - \( \text{Winning} := \text{Winning} \cup \text{ForceNext}(\text{Winning}) \); - until \( \text{Winning} \) does not change; - \( \text{ForceNext}(S) := \{ s \mid \text{all uncontrollable succs of } s \text{ are in } S \} \cup \{ s \mid s \text{ has controllable succ in } S \} \) How to extract strategies in reachability games? Similarly as for safety games: Extract strategy from **ForceNext**(S): ensure you choose the right controllable transition that leads in winning state. Is strategy state-based? Yes! --- How to extract strategies in reachability games? Similarly as for safety games: **BUT**, a subtlety: Need to fix successor the first time state is added in **Winning**. Controller synthesis algorithms Solving safety games Solving reachability games **Beyond safety and reachability games** Remarks on the general LTL synthesis problem --- What about other types of properties? **Bounded response** specifications can be translated to safety automata/games: \[ \varphi = G(p \rightarrow (q \lor Xq \lor XXq)) \] Automaton: What about liveness properties? What about unbounded response? \[ p \rightarrow q \quad \varphi = G(p \rightarrow Fq) \] More interesting example: \[ p_1 \rightarrow q_1 \quad \varphi = G(p_1 \rightarrow Fq_1) \land G(p_2 \rightarrow Fq_2) \land G(\neg(q_1 \land q_2)) \] --- Synthesis for general LTL specifications Given LTL specification \( \varphi \): If \( \varphi \) can be translated to a deterministic Büchi automaton, then can extend the previous ideas to solving Büchi games. Otherwise, solution involves more advanced topics, such as tree automata. Will not be covered in this course. Note: LTL cannot always be translated to deterministic Büchi automata. Büchi automata Syntactically same as finite state automata: \[ A = (\Sigma, S, s_0, \delta, F) \] - **alphabet** - **states** - **initial state** - **transition function** - **accepting states:** \( F \subseteq S \) But Büchi automata accept **infinite words**. A run must visit an accepting state **infinitely often**. From LTL to Büchi automata Consider unbounded response property: \[ \varphi = G(p \rightarrow Fq) \] Büchi automaton: ``` \[ \bar{p} + q \quad \bar{q} \] ``` accepting state \[ p\bar{q} \quad q \] From LTL to Büchi automata Consider LTL formula: \[ \varphi = F G q \] Büchi automaton? (s.t. **there exists** an accepting run) Is there a deterministic Büchi automaton for this spec? No! Controller synthesis algorithms Solving safety games Solving reachability games **Solving deterministic Büchi games (liveness)** Remarks on the general LTL synthesis problem Spreading Büchi automata to Büchi games Büchi automaton: Büchi game: Solving deterministic Büchi games 1. Compute set of RecurrentAccepting states = accepting states from which controller can force returning to an accepting state infinitely often. 2. Solve reachability game with target = RecurrentAccepting. Solving deterministic Büchi games 1. Compute set of **RecurrentAccepting** states = accepting states from which controller can force returning to an accepting state infinitely often. - $\text{RecAcc} := $ set of all accepting states; - repeat - $\text{Revisit} := \emptyset$; - repeat - $\text{Revisit} := \text{Revisit} \cup \text{ForceNext}(\text{Revisit} \cup \text{RecAcc})$; - until $\text{Revisit}$ does not change; - $\text{RecAcc} := \text{RecAcc} \cap \text{Revisit}$; - until set $\text{RecAcc}$ does not change; Recall **ForceNext**($S$) := \{ $s$ | all uncontrollable succs of $s$ are in $S$ \} $\cup$ \{ $s$ | $s$ has controllable succ in $S$ \} ![Diagram](image-url) Solving deterministic Büchi games – Example - $\text{RecAcc} := \text{set of all accepting states}$; - repeat - $\text{Revisit} := \emptyset$; - repeat - $\text{Revisit} := \text{Revisit} \cup \text{ForceNext(Revisit} \cup \text{RecAcc})$; - until $\text{Revisit}$ does not change; - $\text{RecAcc} := \text{RecAcc} \cap \text{Revisit}$; - until set $\text{RecAcc}$ does not change; Computing recurrent accepting states: a subtle relation with reachability games 1. Compute set of $\textbf{RecurrentAccepting}$ states = accepting states from which controller can force returning to an accepting state infinitely often. - $\text{RecAcc} := \text{set of all accepting states}$; - repeat - $\text{Revisit} := \emptyset$; - repeat - $\text{Revisit} := \text{Revisit} \cup \text{ForceNext(Revisit} \cup \text{RecAcc})$; - until $\text{Revisit}$ does not change; - $\text{RecAcc} := \text{RecAcc} \cap \text{Revisit}$; - until set $\text{RecAcc}$ does not change; Solving reachability games vs. computing Revisit 1. **Compute set of Winning states:** - \( \text{Winning} := \{ \} \); - repeat - \( \text{Winning} := \text{Winning} \cup \text{ForceNext}(\text{Winning}) \); - until \( \text{Winning} \) does not change; 2. **Compute Revisit:** - \( \text{Revisit} := \{ \} \); - repeat - \( \text{Revisit} := \text{Revisit} \cup \text{ForceNext}(\text{Revisit} \cup \text{RecAcc}) \); - until \( \text{Revisit} \) does not change; What is the difference? Does it matter? Solving deterministic Büchi games – modified example \[ \begin{array}{c} \begin{array}{c} \pmb{1} \quad \pmb{2} \\ \quad \text{true} \\ \quad \text{p} \\ \quad \text{p} \\ \quad \overline{q} \\ \quad \text{q} \\ \quad \text{ok} \\ \quad \text{p} \\ \quad \text{true} \\ \end{array} \end{array} \] - \( \text{RecAcc} := \text{set of all accepting states}; \) - repeat - \( \text{Revisit} := \{ \} \); - repeat - \( \text{Revisit} := \text{Revisit} \cup \text{ForceNext}(\text{Revisit} \cup \text{RecAcc}) \); - until \( \text{Revisit} \) does not change; - \( \text{RecAcc} := \text{RecAcc} \cap \text{Revisit}; \) - until set \( \text{RecAcc} \) does not change; How to extract strategies in deterministic Büchi games? Similarly as for reachability games: Extract strategy from **ForceNext**(S): ensure you choose the right controllable transition that leads in winning state. Careful to choose the transition the first time state is added to S. Is strategy state-based? Yes! What about non-deterministic Büchi games? Does same algorithm work? Not quite: algorithm sound but incomplete. Non-deterministic automaton for \((GFr \land G\overline{g}) \lor (FG \overline{r} \land FG \overline{g})\) Non-deterministic Büchi game [Ruediger Ehlers, PhD thesis, 2013] Controller synthesis algorithms Solving safety games Solving reachability games Solving deterministic Büchi games (liveness) Remarks on the general LTL synthesis problem Controller synthesis: EE vs. CS? CS: synthesize outputs to implement $\varphi$: $\square$ EE: synthesize inputs to stabilize a physical process/plant: Not different: plant inputs = controller outputs (and vice versa). Can we capture plants in the CS synthesis problem? CS: given plant P (say, a FSM), synthesize controller C, so that closed-loop system satisfies $\varphi$: Can we reduce this problem to the standard LTL synthesis problem? Remarks, assessment Despite some (mostly isolated) success stories, controller synthesis hasn’t really caught on yet in practice. Why is that? - Normal: things like that take time (c.f. model-checking) - 2EXPTIME is a horrible (worst-case) complexity (remember: even linear is too expensive because of state explosion!) - Tools still impractical - Synthesis of real, complex systems from complete specs impractical (imagine full synthesis of complete Intel microchip from LTL specs …) - Lack of good debugging (e.g., counter-examples) - Need: better tools, better methods (incremental, interactive, …) - Great opportunities for research! References PROGRAM SYNTHESIS The “modern” approach to program synthesis - Interactive: - computer-aided programming - programmer solves key problems (e.g., provides program skeleton), synthesizer fills in (boring or tedious) details (e.g., missing guards/assignments) - Search-for-patterns based: - synthesis = search among set of user-defined patterns - Solver based: - heavily uses verifiers like SAT and SMT solvers - often in a counter-example guided loop Example: programming by sketching [Solar-Lezama, Bodik, et al.] Parallel Parking by Sketching Ref: Chaudhuri, Solar-Lezama (PLDI 2010) Enables programmers to focus on high-level solution strategy Using SAT and SMT solvers for synthesis Recall: what is synthesis? \[ \exists P: \forall x: \varphi(x, P(x)) \] Usually re-written as: \[ \exists P: \forall x: pre(x) \rightarrow post(x, P(x)) \] i.e., if input satisfies precondition, then output will satisfy postcondition. Using SAT and SMT solvers for synthesis \[ \exists P: \forall x: pre(x) \rightarrow post(x, P(x)) \] Example of pre(), post(): \[ pre(x_1, x_2): \text{number}(x_1) \land \text{number}(x_2) \] \[ post(x_1, x_2, y): x_1 \leq y \land x_2 \leq y \land (x_1 = y \lor x_2 = y) \] i.e., the spec for max(x1,x2). First: using SAT and SMT solvers for verification Suppose we already have a program P. Then instead of checking whether P is correct \[ \forall x : \text{pre}(x) \rightarrow \text{post}(x, P(x)) \] we can check whether P is wrong \[ \exists x : \text{pre}(x) \land \neg \text{post}(x, P(x)) \] i.e., we can check satisfiability of the formula \[ \text{pre}(x) \land \neg \text{post}(x, P(x)) \] Hold on: are programs formulas? Consider a simple loop-free program: ```c function P(int x) returns (real y) { int tmp := 0; if (x >= 0) then { tmp++; y := tmp * x; } else y := -x; return y; } ``` Formula: \[ P(x, y) = (x \geq 0 \land y = x) \lor (x < 0 \land y = -x) \] Hold on: are programs formulas? What about real programs? Loops, data structures, libraries, pointers, threads, … Translation to formulas much harder, but verification tools are available that do this, constantly making progress. We will assume we have a formula $P(x,y)$ representing the program $P$: “$y$ is the output of $P$ for input $x$”. Back to using SAT and SMT solvers for verification We can check satisfiability of the formula $$pre(x) \land \neg post(x, P(x))$$ or, writing $P$ as predicate on both input and output variables: $$pre(x) \land P(x, y) \land \neg post(x, y)$$ Satisfiable $\Rightarrow$ $P$ is wrong: we get a counter-example $(x,y)$ Unsatisfiable $\Rightarrow$ $P$ is correct (for all $x$) Using SAT and SMT solvers for synthesis What can be done when we don't have the program \( P \)? \[ pre(x) \land P(x, y) \land \neg post(x, y) \] Hint: what if we have a finite/small number of candidate programs? Iterate and search! Programs with “holes” Almost-complete programs: ```plaintext Err = 0.0; for(t = 0; t<T; t+=dT){ if(stage==STRAIGHT){ if(t+??) stage= INTURN; } if(stage==INTURN){ car_ang = car_ang < ??; if(t+??) stage= OUTTURN; } if(stage==OUTTURN){ car_ang = car_ang + ??; if(t+??) break; } simulate_car(car); Err += check_collision(car); } Err += check_destination(car); ``` Programs with “holes” What should we replace “??” with? Patterns: - integer constants - linear expressions of the form \( ax + by + c \) where \( x, y \) are variables in the program ... Even with these restrictions, infinite set of candidates … Search may take a long time or never terminate. Can we do better? Asking the solver to find the program Suppose our program has 1 hole, to be filled with an integer variable. Then, the formula characterizing the program becomes \[ P(h, x, y) \] Can we use the solver to find the right \( h \)? Check satisfiability of \[ \forall x, y : \text{pre}(x) \land P(h, x, y) \rightarrow \text{post}(x, y) \] Problem: universal quantification … \[ \forall x, y: \text{pre}(x) \land P(h, x, y) \rightarrow \text{post}(x, y) \] Today’s solvers check satisfiability of quantifier-free formulas (mostly). What can we do about that? Hint: what if we have a finite number of **positive examples**? i.e., I/O pairs \((x, y)\) satisfying \(\text{pre}(x) \land \text{post}(x, y)\). --- Example-guided synthesis Suppose we have a finite number of positive examples, say 2: \((x_1, y_1), (x_2, y_2)\). That is: we know that these hold: \[ \text{pre}(x_1), \text{pre}(x_2), \text{post}(x_1, y_1), \text{post}(x_2, y_2) \] So it suffices to check satisfiability of \[ P(h, x_1, y_1) \land P(h, x_2, y_2) \] Example-guided synthesis In general, for n positive examples and k hole variables: $$\bigwedge_{i=1}^{n} P(h_1, h_2, ..., h_k, x_i, y_i)$$ We turned universal quantification into finite conjunction! Example-guided synthesis What if solver finds this formula unsatisfiable? $$\bigwedge_{i=1}^{n} P(h_1, h_2, ..., h_k, x_i, y_i)$$ Unsatisfiable => no program exists! This is **sound**: if no program exists that works even in this finite set of examples, we cannot hope to find a program that works for all examples. Example-guided synthesis What if solver finds this formula **satisfiable**? \[ \bigwedge_{i=1}^{n} P(h_1, h_2, ..., h_k, x_i, y_i) \] **Satisfiable** \(\Rightarrow P(h_1, h_2, ..., h_k)\) is only a **candidate**. It still needs to be **verified** for all I/O pairs. We can again use the solver for that! --- Example-guided synthesis Satisfiable \(\Rightarrow P(h_1, h_2, ..., h_k)\) is only a **candidate**. Verify it by checking satisfiability of \[ pre(x) \land P(h_1, h_2, ..., h_k, x, y) \land \neg post(x, y) \] These are now fixed If formula is unsatisfiable then we are done! What if formula is satisfiable? Our candidate is wrong. We get a counter-example: \((x^*, y^*)\) What then? Adding negative examples to the synthesizer’s inputs In general, for \( n \) positive examples, \( m \) negative examples, and \( k \) hole variables: \[ \bigwedge_{i=1}^{n} P(h_1, h_2, \ldots, h_k, x_i, y_i) \land \bigwedge_{i=1}^{m} \neg P(h_1, h_2, \ldots, h_k, x_i^*, y_i^*) \] Alternative: the user could provide the correct output for the counter-example input, or we could use a reference (correct and deterministic) program. Counter-example guided synthesis <table> <thead> <tr> <th>no program exists!</th> <th>Synthesizer (may also use solver internally)</th> <th>Verifier (e.g., SMT solver)</th> </tr> </thead> <tbody> <tr> <td>fail</td> <td>succeed</td> <td>spec, e.g., pre, post</td> </tr> <tr> <td>succeed</td> <td>program skeleton, initial set of examples</td> <td>OK</td> </tr> <tr> <td>counter-example</td> <td>found correct program!</td> <td>Not OK</td> </tr> <tr> <td>((x_i^<em>, y_i^</em>))</td> <td></td> <td></td> </tr> </tbody> </table> EECS 144/244, UC Berkeley: 85 EECS 144/244, UC Berkeley: 86 References
{"Source-Url": "https://embedded.eecs.berkeley.edu/eecsx44/lectures/08-synthesis.pdf", "len_cl100k_base": 8293, "olmocr-version": "0.1.48", "pdf-total-pages": 44, "total-fallback-pages": 0, "total-input-tokens": 76316, "total-output-tokens": 10834, "length": "2e13", "weborganizer": {"__label__adult": 0.00036716461181640625, "__label__art_design": 0.0004444122314453125, "__label__crime_law": 0.0003292560577392578, "__label__education_jobs": 0.0016794204711914062, "__label__entertainment": 6.490945816040039e-05, "__label__fashion_beauty": 0.00015878677368164062, "__label__finance_business": 0.00018489360809326172, "__label__food_dining": 0.0003814697265625, "__label__games": 0.0006809234619140625, "__label__hardware": 0.001201629638671875, "__label__health": 0.0004611015319824219, "__label__history": 0.00026988983154296875, "__label__home_hobbies": 0.00016641616821289062, "__label__industrial": 0.0005764961242675781, "__label__literature": 0.0002925395965576172, "__label__politics": 0.0002932548522949219, "__label__religion": 0.0006189346313476562, "__label__science_tech": 0.024505615234375, "__label__social_life": 0.00011718273162841796, "__label__software": 0.00396728515625, "__label__software_dev": 0.9619140625, "__label__sports_fitness": 0.0003724098205566406, "__label__transportation": 0.0008096694946289062, "__label__travel": 0.0002015829086303711}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 29113, 0.01191]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 29113, 0.6361]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 29113, 0.75384]], "google_gemma-3-12b-it_contains_pii": [[0, 366, false], [366, 946, null], [946, 2035, null], [2035, 2226, null], [2226, 4341, null], [4341, 4436, null], [4436, 4811, null], [4811, 5061, null], [5061, 8114, null], [8114, 8479, null], [8479, 9408, null], [9408, 9629, null], [9629, 10461, null], [10461, 11127, null], [11127, 11332, null], [11332, 11642, null], [11642, 12052, null], [12052, 12560, null], [12560, 12927, null], [12927, 13565, null], [13565, 13976, null], [13976, 14338, null], [14338, 15015, null], [15015, 15543, null], [15543, 15916, null], [15916, 16229, null], [16229, 16952, null], [16952, 17971, null], [17971, 19186, null], [19186, 19793, null], [19793, 20189, null], [20189, 21055, null], [21055, 21642, null], [21642, 22285, null], [22285, 22875, null], [22875, 23597, null], [23597, 24324, null], [24324, 24960, null], [24960, 25618, null], [25618, 26314, null], [26314, 26837, null], [26837, 27543, null], [27543, 28664, null], [28664, 29113, null]], "google_gemma-3-12b-it_is_public_document": [[0, 366, true], [366, 946, null], [946, 2035, null], [2035, 2226, null], [2226, 4341, null], [4341, 4436, null], [4436, 4811, null], [4811, 5061, null], [5061, 8114, null], [8114, 8479, null], [8479, 9408, null], [9408, 9629, null], [9629, 10461, null], [10461, 11127, null], [11127, 11332, null], [11332, 11642, null], [11642, 12052, null], [12052, 12560, null], [12560, 12927, null], [12927, 13565, null], [13565, 13976, null], [13976, 14338, null], [14338, 15015, null], [15015, 15543, null], [15543, 15916, null], [15916, 16229, null], [16229, 16952, null], [16952, 17971, null], [17971, 19186, null], [19186, 19793, null], [19793, 20189, null], [20189, 21055, null], [21055, 21642, null], [21642, 22285, null], [22285, 22875, null], [22875, 23597, null], [23597, 24324, null], [24324, 24960, null], [24960, 25618, null], [25618, 26314, null], [26314, 26837, null], [26837, 27543, null], [27543, 28664, null], [28664, 29113, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 29113, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 29113, null]], "pdf_page_numbers": [[0, 366, 1], [366, 946, 2], [946, 2035, 3], [2035, 2226, 4], [2226, 4341, 5], [4341, 4436, 6], [4436, 4811, 7], [4811, 5061, 8], [5061, 8114, 9], [8114, 8479, 10], [8479, 9408, 11], [9408, 9629, 12], [9629, 10461, 13], [10461, 11127, 14], [11127, 11332, 15], [11332, 11642, 16], [11642, 12052, 17], [12052, 12560, 18], [12560, 12927, 19], [12927, 13565, 20], [13565, 13976, 21], [13976, 14338, 22], [14338, 15015, 23], [15015, 15543, 24], [15543, 15916, 25], [15916, 16229, 26], [16229, 16952, 27], [16952, 17971, 28], [17971, 19186, 29], [19186, 19793, 30], [19793, 20189, 31], [20189, 21055, 32], [21055, 21642, 33], [21642, 22285, 34], [22285, 22875, 35], [22875, 23597, 36], [23597, 24324, 37], [24324, 24960, 38], [24960, 25618, 39], [25618, 26314, 40], [26314, 26837, 41], [26837, 27543, 42], [27543, 28664, 43], [28664, 29113, 44]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 29113, 0.01836]]}
olmocr_science_pdfs
2024-11-25
2024-11-25
d32a18c912346371fc75c97a2275929062d08a4e
AUTOMATED CHECK-IN AND SCHEDULING SYSTEM FOR A WEB-BASED TESTING APPLICATION by Ashwin V. Kumar A report submitted in partial fulfillment of the requirements for the degree of MASTER OF SCIENCE in Computer Science Approved: Dr. Donald Cooley Major Professor Dr. Nicholas Flann Committee Member Dr. Daniel Watson Committee Member UTAH STATE UNIVERSITY Logan, Utah June, 2013 Abstract Automated Check-In and Scheduling System for a Web-Based Testing Application by Ashwin V. Kumar, Master of Science Utah State University, June, 2013 Major Professor: Dr. Donald Cooley Department: Computer Science Ideally, a testing center and associated software should be an effective tool for learning assessment. It should serve as a link between faculty members who create tests and their students who are assessed by those tests. Testing centers are generally limited in the number of computer systems available as compared to the number of students taking tests. Automated testing plays an important role in such situations. Automated testing outside the classroom offers students the flexibility of choosing a preferred time for taking tests. A completely automated system also contributes in reducing a portion of the workload by automatically grading some or all of the exams. This report presents a feature called Automated Check-In and Scheduling. This feature uses magnetic card readers to provide an interface between a student and the testing system. This report also discusses a card swiper interface which is linked to a new scheduling system. Together, they provide for better utilization of a laboratory's resources. (51 pages) ## Contents <table> <thead> <tr> <th>Section</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>Abstract</td> <td>iii</td> </tr> <tr> <td>List of Figures</td> <td>vi</td> </tr> <tr> <td>Acronyms</td> <td>vii</td> </tr> <tr> <td>1 Introduction</td> <td>1</td> </tr> <tr> <td>1.1 Testing Centers</td> <td>1</td> </tr> <tr> <td>1.2 Automated Testing</td> <td>2</td> </tr> <tr> <td>2 Problem Analysis</td> <td>4</td> </tr> <tr> <td>2.1 Overview</td> <td>4</td> </tr> <tr> <td>2.2 User Roles</td> <td>5</td> </tr> <tr> <td>2.2.1 Student</td> <td>6</td> </tr> <tr> <td>2.2.2 Proctor</td> <td>6</td> </tr> <tr> <td>2.2.3 Instructor</td> <td>6</td> </tr> <tr> <td>2.2.4 Administrator</td> <td>6</td> </tr> <tr> <td>2.3 Existing Scheduling Model</td> <td>6</td> </tr> <tr> <td>2.4 Motivation</td> <td>8</td> </tr> <tr> <td>2.5 New Scheduling Model and Interface</td> <td>10</td> </tr> <tr> <td>2.5.1 The Card Swiper Interface</td> <td>11</td> </tr> <tr> <td>2.5.2 The New Scheduling Model</td> <td>11</td> </tr> <tr> <td>3 Design Analysis</td> <td>15</td> </tr> <tr> <td>3.1 Overview</td> <td>15</td> </tr> <tr> <td>3.2 Software Analysis</td> <td>15</td> </tr> <tr> <td>3.2.1 User Roles</td> <td>16</td> </tr> <tr> <td>3.2.2 The Card Swiper Interface</td> <td>18</td> </tr> <tr> <td>3.2.3 Automated Check-in and Scheduling System</td> <td>21</td> </tr> <tr> <td>3.3 Hardware Analysis</td> <td>25</td> </tr> <tr> <td>3.3.1 The Magnetic Card Reader</td> <td>25</td> </tr> <tr> <td>4 Implementation</td> <td>28</td> </tr> <tr> <td>4.1 The Card Swiper Interface</td> <td>28</td> </tr> <tr> <td>4.2 Automated Check-in and Scheduling System</td> <td>33</td> </tr> <tr> <td>5 Testing</td> <td>39</td> </tr> <tr> <td>6 Future Work</td> <td>42</td> </tr> <tr> <td>7 Conclusion</td> <td>43</td> </tr> </tbody> </table> References List of Figures <table> <thead> <tr> <th>Figure</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>2.1</td> <td>4</td> </tr> <tr> <td>2.2</td> <td>4</td> </tr> <tr> <td>2.3</td> <td>5</td> </tr> <tr> <td>2.4</td> <td>5</td> </tr> <tr> <td>2.5</td> <td>9</td> </tr> <tr> <td>2.6</td> <td>10</td> </tr> <tr> <td>3.1</td> <td>26</td> </tr> <tr> <td>3.2</td> <td>27</td> </tr> <tr> <td>4.1</td> <td>29</td> </tr> <tr> <td>4.2</td> <td>30</td> </tr> <tr> <td>4.3</td> <td>32</td> </tr> <tr> <td>4.4</td> <td>33</td> </tr> <tr> <td>4.5</td> <td>34</td> </tr> <tr> <td>4.6</td> <td>35</td> </tr> <tr> <td>4.7</td> <td>36</td> </tr> <tr> <td>4.8</td> <td>37</td> </tr> </tbody> </table> Instructor view of iNetTest’s test scheduling system. Portion of student’s page indicating him/her to make a reservation. List of time slots opened for a student to make a reservation. Test is unlocked when a student’s reservation time starts. Proctor unlock. Proctors interface to commit check-ins. The Magnetic Card reader. The Magnetic Card reader with A-Card being swiped. The card swiper interface displaying only the student input section. The card swiper interface displaying the lab-information section. The card swiper interface displaying the check-in section. Interface indicating a successful check-in. Interface indicating failure for check-in as no seats are currently vacant. Simple design illustration of the automated check-in and scheduling system. Workflow of Action 1 to make seats available and predict timestamps. Workflow of Action 2 to process on-the-spot reservations and commit check-ins. **Acronyms** <table> <thead> <tr> <th>Acronym</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>TST</td> <td>Test Start Time</td> </tr> <tr> <td>TET</td> <td>Test End Time</td> </tr> <tr> <td>FWT</td> <td>Finished With Test</td> </tr> </tbody> </table> Chapter 1 Introduction. 1.1 Testing Centers. Testing centers are controlled environments that house a finite number of computer systems. These computer systems are authorized by a server to administer tests. Students can come in during the working hours of the testing center and take the allotted test(s) for a particular course. Thus, testing centers resemble a dedicated environment provided within an institution for test-taking purposes. Associated with testing centers are personnel called “proctors” that aid in authenticating and authorizing a student to take a test. The proctor has the permission to unlock a requested test, only if a seat is available. Over time, the Internet has become a large repository of data related to almost any type of question. In order to provide anti-cheating mechanisms, most computer systems in a testing center have limited access to the Internet and certain software tools. This helps in maintaining a healthy and honest testing environment while dissuading students from cheating. Furthermore, testing centers may also have restrictions on the material brought in by a student, and even include security cameras for monitoring of students taking a test. Proctors may also enforce some level of cheating prevention by seating students randomly. One of the biggest benefits of using testing centers to administer tests is that it provides flexibility to a student in choosing a test time. With a testing center, students are not necessarily constrained to take a test on a specific day and time. Tests administered at a testing center are usually kept active or open for a number of days. Depending on each student’s unique schedule, he/she may opt for a time slot as per his/her convenience. With computer-based tests, the need for paper is completely eliminated. The student submits only an electronic copy of an attempt which is stored in the testing software’s database. At some institutions’ testing centers, specific personnel are paid for the purpose of managing students taking paper-based tests and collecting their test sheets. 1.2 Automated Testing. With a testing center, greater efficiency is achieved. Time, money, and effort expended by an institution for assessment purposes are also significantly reduced. Paper-based tests need to be graded by an individual, typically a grader or the professor. Grading is generally a cumbersome and time consuming process, involving giving appropriate credit to answers. Computer systems are capable of processing data at higher speeds with less erroneous results, if the underlying design is accurate. Automation in the form of auto-grading substantially helps reduce time, effort and therefore money. Automation may restrict students from malpractices and enforce stronger security validations during the taking of a test. iNetTest is an automated computer-based testing system that was developed by Utah State University’s Computer Science Department and is housed in the TARLab (ESLC 131), an on-campus automated testing center. Instructors using iNetTest can choose from multiple options such as creating, editing, updating, deleting, or scheduling a test for either an individual or a group of students. They can choose from ten different types of pre-defined template questions (e.g. fill in the blank, matching, programming, etc.) while creating tests. Automatic grading works in the background for each of these question types except the essay type question, and for certain forms, the programming question. This helps in ensuring a quick and efficient on-the-spot grading. With instructor permission, students may choose to see their grades as soon as they finish taking a test. Other attributes such as a time limit, expiration date, an IP range, etc. may also be set for a test, to provide security. iNetTest has a range of over 20 different permission levels to choose from in order to restrict access to sensitive data. The ability to create groups and share access to these groups between instructors is also possible. Miscellaneous features such as sending e-mail notifications, text message notifications, cheating logs, and on-the-spot test unlocks help in making iNetTest ready for commercial purposes. iNetTest is a Java-based system that utilizes current J2EE technologies running within a JBoss Application Server 6. Older but stable technologies such as struts are used to interact with the business logic between a client and server. A postgresql database holds all relevant data accessed and managed by iNetTest and is interfaced using Enterprise Java Beans. The front end or user interface utilizes the most recent jQuery tools to provide a dynamic web environment. Chapter 2 Problem Analysis 2.1 Overview. Although iNetTest was well equipped to handle all its demands from students and instructors, because of limited resources, it was necessary to develop a scheduling capability to allow for efficient use of computer workstations for test takers. Such a reservation system was recently developed and put to use on iNetTest [1]. This reservation system required an instructor to schedule a test with a valid start and end date. Only tests created by an instructor or tests to which an instructor was granted access were allowed to be scheduled by him/her. After the instructor had scheduled a test (see Fig. 2.1), the students were required to log-in to their respective iNetTest accounts and make a reservation. ![Fig. 2.1: Instructor view of iNetTest’s test scheduling system.](image) Only authorized scheduled tests would be highlighted on a student’s log-in page, requesting him/her to make a reservation (see Fig. 2.2). ![Fig. 2.2: Portion of student’s page indicating him/her to make a reservation.](image) To make a reservation, a student was asked to choose from a list of days and available time slots. After the student made a reservation for a test, the system would reserve a seat until the student appeared during his/her reservation time to take it (see Fig. 2.3). Fig. 2.3: List of time slots opened for a student to make a reservation. On the day and time of a student’s reservation, a proctor would first authenticate the identity of the student via an ID-card and then assign the student to a computer to take the test. The test was automatically unlocked after the reservation time began and the “take test” button on the student’s page was made active (see Fig. 2.4). Fig. 2.4: Test is unlocked when a student’s reservation time starts. 2.2 User Roles. To better understand the existing scheduling model, the needs of all users interacting with the model must first be defined [1]. Four such users with their respective roles are: 2.2.1 Student. Students are users with lowest privileges and permissions. Their interactions are only limited to the student interface. Being test takers, they can take tests, make reservations and cancel or reschedule their reservations. 2.2.2 Proctor. Proctors are personnel appointed by the testing center, who have privileges to administer tests. Their duties include authenticating student identities, admitting students and supervising the testing center. They have limited privileges; they can neither manipulate or schedule a test, nor change a reservation. They can however, override the scheduling system by unlocking a test. A student without a prior registration can thereby take a test in case of a vacant seat. 2.2.3 Instructor. Instructors are persons responsible to create, edit, delete or schedule a test for a student. They author tests and have higher privileges and permissions than both students and proctors. 2.2.4 Administrator. Administrators are synonymous to super users. They have full privileges and permissions to iNetTest. They also have access to adding, deleting, and editing information of students, proctors and instructors in the database. They can also access test and lab information, as well as perform most over rides to make changes within iNetTest. 2.3 Existing Scheduling Model. The existing scheduling model laid a simple and straightforward workflow. The instructor created and scheduled a test within a range of valid dates. All students included in the instructor’s group had an automatically enabled option to reserve a seat for the corresponding test after logging into their accounts. If email reminders had been enabled by the instructor, the student would get a reminder mail providing test time and date information, on registering for the test. To stratify time intervals during the working hours of a lab for which a student reserves a seat, a decision to have a granularity of 30 minutes was chosen in the existing scheduling system. Thus, the student could choose time instants round the clock separated at 30 minutes to reserve a test. i.e., 12:00, 12:30, 1:00 and so on. The scheduling algorithm ensured that no student was allowed to make a reservation, if a full portion of the time frame was not available during the time instant that he/she wished to make a reservation. This was also the case when the lab was completely reserved for the day. One of the challenging aspects the scheduling system dealt with was the element of uncertainty. That is, if the student came in late for a test, the system would check to see if the matching reservation could be incremented by factors of 30 minutes until the student got his/her full time, or would give him/her an option of rescheduling the test. If the student still wished to take the test, he/she would have to take the test in the remaining time. A seat could only be guaranteed, if a reservation had been made by the student. The scheduling system allowed for multiple tests to be scheduled at the same lab, and also dealt with conflicts of variable test times. With the existing system, it was seen that an optimal scheduling for a lab relied entirely on the promptness and assurance of a student to reserve a test once it was scheduled. The lab faced a problem of uneven distribution of reservations, which meant that certain peak hours of the day were entirely filled while other hours were relatively vacant. Suboptimal distributions of reserved tests also led to waste of time segments. For example, if a 60 minute test was reserved by student “A” between 12:00pm to 1:30pm and student B made a reservation from 2:00pm to 3:30pm, the time segment between 1:30pm to 2:00pm was unused. The granularity for making a reservation on the system was placed at 30 minutes. While making a reservation, the system added 10 minutes to the test duration. These 10 minutes were provided as a buffer time for each student to collect their belongings after they finished with a test. Thus a 60 minute test was calculated at 70 minutes while making the reservation, and since the granularity was placed at 30 minutes, the 70 minute test made a 90 minute reservation. However, a 50 minute test made a 60 minute reservation. It was also noticed that a set of students always made last minute reservations, and were hence limited to inconvenient time slots. (Ex: early morning or late night). Furthermore, the loss in time segments compounded when students made reservations for various kinds of tests having completely different reservation lengths (Ex: test 1 = 30 minute duration, test 2 = 60 minute duration, etc). 2.4 Motivation. The existing scheduling system brought about a significant change by alleviating most of iNetTest’s scheduling problems. TARLab, the testing center running on iNetTest was now capable of handling and addressing the needs demanded by an automatic testing center. However, after using the scheduling system, it became clear that a new set of strategies needed to be implemented to resolve certain problems unaddressed by the old scheduling system. These were: - **Time Efficiency:** As explained earlier, while scheduling a 60 minute test, a reservation of 90 minutes was made by the system, leading to a static wastage of 30 minutes. - **Inconvenience in registration:** There was no provision for students to make on-the-spot reservations. Students always had to make a prior reservation for taking a test. The soonest a student could make a reservation for a test was at the next 30th minute interval. - **Additional responsibility on the proctor.** The first version of iNetTest was without a scheduling system. It required a student to walk in during the working hours of the testing center, and if seats were available, the proctor could authorize him and manually unlock the test on a computer. The proctor performed this unlock on the student’s computer by entering his/her credentials (user id, password). This required the proctor to physically move to the student’s computer and unlock it for the student. To ensure that no test continued beyond the testing center’s working hours, the proctor needed to know the duration of a test he/she was about to unlock for the student (see Fig. 2.5). ![Proctor unlock](image) **Fig. 2.5: Proctor unlock.** With the addition of the scheduling system, a test was automatically unlocked for students as soon as their reservation time started. This eliminated the need for the proctor to move around performing unlocks. The scheduling system enforced stringent measures to ensure that no reservation time exceeded the testing center’s working hours. A reservation to a student was denied if the system detected a time conflict. So, a proctor never needed to know the duration of a test that a student was about to take. This was a great improvement, but the system did not address the possibility of students arriving at the testing center without a reservation, but wishing to take a test. This meant that the proctor had to utilize the old method of performing unlocks while overriding the scheduling system. Ideally, this problem would not have arisen if students always made prior reservations. However, with the scheduling system on iNetTest running at TARLab for a year, it was observed that there were a large number of students who never made prior reservations and relied on the proctors to unlock tests. • Mandatory reservations and speed of check-in As noted, the system did not automate the process of accommodating students without prior reservations. Moreover, for every student who came in during his/her reserved time, the system required the proctor to open up a dialog box for that time and monitor the list of students who had made reservations at that time. The proctors had to checkmark the corresponding student’s name from the list and press a button to check-in the student (See Fig. 2.6). This meant additional work for a proctor while also decreasing the speed of a check-in for a student. ![Proctors interface to commit check-ins.](image) The existing scheduling system did bring about a greater efficiency to iNetTest as a module in whole, but the opportunity to improve the system continued to exist. This report explains how a few discrepancies were eliminated and a new interface for taking tests was provided. Detailed analysis is provided in the next section. 2.5 New Scheduling Model and Interface. The new scheduling model proposed an entirely new interface. Here, all check-ins for students under single or multiple instructors having single or multiple tests were made accessible to a proctor. The new model relieved a proctor from unlocks, created on-the-spot reservations for students without prior reservations, and increased the testing center’s time efficiency. 2.5.1 The Card Swiper Interface. I. Since test takers are generally registered USU students, they each have a unique identity card (with a unique A-Number). Throughout iNetTest, these A-Numbers were used to uniquely identify students and retrieve their related information. Because the A-Number plays a key role in accessing a student’s information it was used for performing further tasks such as check-ins, making reservations, etc. To take full advantage of a physical ID-card and use it as a key to access information, the new interface was designed to accept data directly from an ID-card. II. A magnetic card swipe reader was used to accept data from an ID-card which was then parsed to find the actual A-Number and perform automatic check-ins for students. The new card swiper interface was designed to directly access iNetTest’s database for relevant student and test information upon the entry of a valid A-Number. The new interface retrieved a students information after swiping the ID-card. All relevant upcoming test details were displayed on the proctors screen so he/she could assign a student to a test station and unlock the desired test. In case the card reader generated an error in reading a student ID-card, or if the student did not have an ID-card present with him/her, the interface allowed the proctor to perform a keyboard entry of an A-Number. 2.5.2 The New Scheduling Model. The original design of the scheduling system required all students taking a test to have prior reservations. A significant challenge for the new scheduling system was to accommodate students without a reservation. A central requirement of the automated check-in and scheduling system was to provide iNetTest’s existing scheduling system with these additional features. I. In order to accommodate students with no reservation and to make on-the-spot reservations with check-ins, all student modalities were considered. These modalities were as follows: [1.] Student is scheduled for only one test and has made a reservation. [2.] Student is scheduled for multiple tests and has made multiple matching reservations. [3.] Student is scheduled for multiple tests and has made reservations for some but not all tests. [4.] Student is scheduled for either single or multiple tests and has not made reservation(s). [5.] Student has arrived to take a test, but their instructor has not entered the test in the scheduling system (no information). II. Given a student with only one test and a corresponding reservation (case 1), the interface assumes that he/she should be checked-in and commits a check-in. If the student arrived early for the test, the interface prompts with a message indicating when the reservation was set and the wait period before his/her reservation starts. III. Given a student with multiple scheduled tests and matching reservations (case 2), the interface allows the student to choose a test that he/she wishes to be checked-in for. The interface also enumerates all valid details such as test name, duration of the test, test reservation status, calculator options, etc. This enables the proctor to confirm with the student the test that he/she wishes to take and thereby remind him/her of the test details before selecting an option. IV. Given a student with one or more tests without reservations (case 3 and 4), the interface again enumerates all test details. Upon attempting to take a test with no prior reservation, the system makes an on-the-spot reservation for the student by checking future available time slots to accommodate the entire test. The system also checks to see if there are vacant seats available within the testing center at the current time. If there are time conflicts, the system prompts a message notifying the cause. If not, the system makes an on-the-spot reservation, creates an entry in the reservation table, checks-in the student and automatically unlocks the matching test so that the student may take the test immediately. V. If a student has no tests scheduled at the moment by any instructors, the interface detects this and prompts with a message stating the same. The proctor may then inform the student that he/she has no tests scheduled and hence cannot take a test. VI. As discussed earlier, reservations in the old scheduling system were set to a granularity of 30 minutes for a test. If the duration for a test was 60 minutes, the existing scheduling system made a 90 minute reservation. In order to prevent this wastage of time and provide an exact time slot for a student taking a test, a method to clock-in the precise start and end times of a test was required. Two cases are possible when a student makes a reservation and starts a test: [1.] If a reservation is made at 3:00pm for a 60 minute test, the seat is reserved until 4:30pm. So an entry with a start time set at 3:00pm and end time set at 4:30pm is made in the reservation table. However, when the student actually logs in and hits the “take test” button, the start time of the corresponding reservation must be set to the actual start time which is the system’s current time (say 3:06pm). The end time of the test is computed using the actual start time. Thus the end time of the reservation must be changed to 4:06pm from 4:30pm. This is because that would be the last time instant at which the student can take the test. It is not needed to keep the student’s reservation active after 4:06pm. Here, the student gets an exact reservation length equal to his/her test duration and is not allowed to occupy the seat after the end time. [2.] Student makes an on-the-spot reservation and starts with a test, but finishes it earlier than the calculated test end time (say 3:30pm). Although the test end time is till 4:06pm, there is again no need to keep this reservation active beyond 3:30 pm. So, a method is created to detect when students hit the “finish with test” button. The student is no longer allowed to occupy his/her seat after he/she finishes with a test. VII. In order to increase the testing center’s time efficiency by meeting the preceding two requirements, a mechanism to continuously update the lab information was also created. This information included the total number of seats available, the number of seats occupied, and the authorized IP range for test access. A time label accurately indicating the time at which the next seat in a lab would be available is also be displayed on the interface. If a student tries to check-in when there are no vacancies in the lab, this information is useful in informing the student when a seat is most likely to be available for taking a test. The uncertainties of developing such a system on a previously laid architecture made it challenging and at the same time extremely educational. The new scheduling system takes advantage of the previous scheduling system’s features and attempts to make it more efficient by adding new features to it. Chapter 3 Design Analysis 3.1 Overview. The new scheduling model adds an additional layer to the existing scheduling model. In order to provide for on-the-spot reservations and check-in with the use of ID-Cards, a new interface was designed. This interface manages most of the work through software and leaves less work for the proctor. The new scheduling system may be split into two components: 1. The card swiper interface: The front-end responsible for interfacing iNetTest’s new scheduling model to a magnetic card swipe reader. II. Automated check-in and scheduling model: The back-end that provides features such as automatic unlocks and on-the-spot reservations while increasing the testing center’s time efficiency. 3.2 Software Analysis. Interactions with the new scheduling system can be understood in detail if considered from the user’s point-of-view. Since the new scheduling system was designed to accommodate more dynamic decisions, it presents many sub-cases corresponding to many options and possibilities. Before describing how the card swiper interface and the automated check-in and scheduling systems work, interactions between users and the system are described briefly with the help of certain roles. 3.2.1 User Roles. User roles can be classified into student roles, proctor role, instructor role and administrator role. These roles are described below. Student Role: The previous scheduling system required the student to make a reservation to be assured of a seat. An automatic unlock was also created for the reserved test. The new scheduling system accommodates students without reservations. Hence the student has two choices: 1. Student wishes to make a reservation: When a test has been scheduled by an instructor for a student, the student is notified via an e-mail to make a reservation for the test. The student logs in to iNetTest and looks at the “To Do” section for any notifications. For each test scheduled for a student, the “To Do” section highlights the test name along with the option to reserve it. On clicking the “Reserve button”, the student is presented with a list of days and time slots for making a reservation. Once a suitable choice is confirmed, the reservation is made and another e-mail indicating the date and time of the reservation is sent to the student. After the student has reserved a seat, the reservation remains active until he/she has finished taking the test or the reservation expires. A student can cancel or reschedule a reservation, if the option is enabled by the instructor while scheduling the test. On the day and time of the test, the student needs to present an ID-card to the proctor for checking-in. The proctor would swipe the ID-Card on the magnetic card reader and depending on what time the student arrived, the interface decides if the student may be checked in or gives a reason for failure. Upon check-in, the student automatically has his/her matching test unlocked and can immediately start taking the test. 2. Student does not wish to make a reservation: In this case, the student fails to make a reservation after receiving an e-mail from an instructor about a scheduled test. The student attempts to find an available seat at the time he/she arrives at the testing center. As in case (1), the student enters the testing center with an ID-Card and the proctor will swipe the card to determine if there is an available seat. If the result is successful, the student is allotted a seat and the test is automatically unlocked. If there is a failure, i.e. no seats are available; the system notifies the proctor of the next available time a seat is likely to be vacant. The student is informed of this time, so that he/she may come to the testing center at that time. There is no accommodation for development of a waiting list. However, if the student wished, they could go to another lab and log into iNetTest, and make a reservation. Proctor Role. In the new scheduling system, the proctor is not required to unlock a student’s test by logging in to the student’s computer. He/she is also not required to keep a count of the number of seats available in the lab. The system takes care of this and updates the proctor of the lab information every 8 seconds. The proctor is only required to validate a student’s identity prior to a check-in. The proctor also has the option to follow the old no-reservation checking method of admitting a student by checking a hard-copy list of students for a given test to perform check-ins. As before, he/she may also perform unlocks directly on the student’s computer. Whether a student comes in with or without a reservation, the proctor is always presented with information regarding a student’s reservation status from the system. Instructor Role. The role of an instructor is to create and schedule tests. Generally, an instructor schedules a test for all the students in a group (class). An instructor may choose to create a new test or use a previously created test. He/she may also request access to tests owned by other instructors to include questions, sections or perhaps the entire test. Once an instructor has finalized their question set and assigned weights (values) for the questions, he/she may proceed to schedule it. On clicking the “schedule” button the instructor gets a list of options. These include selecting the time frame for scheduling a test, options for allowing students to reschedule the test, and options for an instructor to be notified via e-mail when a student schedules a test. Next, the instructor specifies a location and region where the test would be administered (ex. TARLab). He/she may also choose to create a text field to indicate the list of materials a student is allowed to bring in to the lab (ex. calculator, index cards, periodic table printouts etc.). Once these options are submitted, iNetTest determines if there are sufficient available resources (seats) to administer the test in the specified lab during the selected times. If the scheduling is successful, the instructor is informed of this and the students are asked to schedule the test(s) at the specified day(s)/time. If there are any errors in scheduling a test the system informs the instructor of the reason for failure. Administrator Role. The role of an administrator is similar to a super user. They may assume any or all privileges in iNetTest to create, edit, delete, or reschedule tests, and make database changes. They hold control over the most sensitive information in iNetTest. Administrators are required to perform these operations on iNetTest when something goes wrong or the iNetTest interface restricts any of the above users from legally changing information. Hence, administrators are only sought after when a valid reason to make changes to information within iNetTest is made unavailable on the interface, but is crucially important. 3.2.2 The Card Swiper Interface. The card swiper interface is explained in greater detail in this section. In order for a student to check into iNetTest, the previous scheduling model required the proctor to view a list of reservation entries made by students and commit check-ins. This meant that when a student entered the testing center to check-in, the proctor had to verify the student’s identity and check to see if he/she existed on the list of reservations, and then, check him or her in. The new interface uses a student’s ID-Card to facilitate and speed check-in. The typical format for any USU registered students ID-card/A-Number is a character “A” followed by 8 digits (ex. A00000000). This number is assigned uniquely to each USU registered student and remains during their tenure at USU. The ID-Card is issued to a student when he/she enrolls at USU as a student or faculty member. Since the A-Number is unique, it is also encrypted on the magnetic strip at the back of the ID-Card. This allows every student to gain quick access into USU’s recreational facilities such as gymnasiums, racquet ball courts, swimming pools and other places such as libraries, labs, etc. by swiping their ID-cards. iNetTest provides computer based tests to be housed in a testing center within USU’s campus called the TARLab. The TARLab houses approximately 35 computers that are recognized by iNetTest as authorized testing machines. To make check-ins to the TARLab as straightforward as for other USU facilities, a magnetic card reader and swiper interface were needed to be integrated into the existing iNetTest scheduling system. The interface required the following capabilities: Terms: - Simple check-in: Procedure to validate a student’s identity and perform a check-in if he/she has made a reservation and arrived at the testing center during the reservation time. - Complex check-in: Procedure to validate a student’s identity and attempt to perform an on-the-spot reservation if the student had made no prior reservation for a test, and then perform a check-in. The criteria required for the interface are listed below: - The interface must only be made available to users with permission levels from a proctor and higher. A brief text label instructing how to interact with the interface and an area where dynamic interactions take place between the proctor and system must be clearly delineated. - The interface should be designed to always be ready to accept inputs from the magnetic card reader when it is started. • As the interface would be used only by a proctor to commit check-ins, the information displayed on it must be restricted to only limited and valid test details and student information. This becomes crucial as the interface queries iNetTest with a student’s A-Number. iNetTest’s database holds all records for a student, some of which are confidential and do not pertain to a proctor’s role. • The interface must also provide for creating on-the-spot reservations for students. For this, it is necessary for a proctor to know if he/she was directly committing a simple check-in or complex check-in. • A simple editable text-box displaying the student’s A-Number upon a card swipe should also be present. In case of any system parsing errors or a damage to the magnetic strip on the card, the proctor should also be able to manually enter the A-Number to proceed with regular interactions on the interface. • As data from a magnetic card reader is in the form of serial keystrokes, the interface must include a method that checks the text box for a possible A-Number format-match to directly trigger a check-in procedure. If this is not done, the proctor may be required to hit a button after every card swipe entry to trigger the check-in event. • A separate portion of the interface must be dedicated to detailing the testing center’s information. Details such as lab-name, total computers available in a lab, total computers vacant and an IP-range of all authorized computers within the testing center must be updated periodically and displayed in this portion. • Details enumerating the students A-Number as well as the first and last name must always be displayed on the interface upon a successful swipe. Given a set of tests a student is scheduled to take, the interface must also enlist details such as test-name, test-duration, test-status and calculator options for each test. • The interface is designed to reduce load on a proctor and yield dynamic results for a card swipe. Quick textual responses from the system should be accompanied by consistent graphical icons representing a success or failure. • In the possibility of a system error, a “reset” button to reset the interface is also required to be present at all times. To quit the interface a “cancel” button should also be present. 3.2.3 Automated Check-in and Scheduling System. From the previous discussion, we can summarize the following points: • The old scheduling system required every student to make reservations before they could take a test. • Reservations could only be made on the half-hour, since the granularity to make reservations on the calendar was set to 30 minutes. As discussed earlier, when a reservation is made for a test, the reservation length is set to the duration of a test plus a constant of 10 minutes. This additional 10 minutes is included as a buffer time for a student to collect their belongings before they leave a station after taking a test. So, a reservation for a 60 minute test would increase to 70 minutes, and since the granularity was set to 30 minutes, the reservation time would increment to 90 minutes. However, a 50 minute test would be set to a reservation length of 60 minutes. • If a student “A” starts taking a 60 minute test exactly when the reservation started, he/she would finish with the test at the most in 60 minutes. But since a 60 minute test makes a 90 minute reservation, 30 minutes are entirely wasted. • If a student “B” were to finish a 60 minute test within the first 10 minutes, the scheduler will not make a seat available for the remaining 80 minutes. If another student “C” arriving at the testing center wants to take a test on the vacant computer left by student “B”, student “C” would have to request the proctor to manually unlock a test. Furthermore, neither does student “C” or the proctor has knowledge about the exact time left on student “B”’s computer. This meant that there was no mechanism in the old system to fetch the time instant at which a student started and ended a test. There were no checks performed on the number of students who finished their tests earlier than their reservation time. There was also no method that deleted a student’s record from the reservation table after a test was finished. When a reservation is deleted immediately after a student finishes a test, the chances for another student to reserve a test are higher. Lastly, there was no automatic procedure to legally make an on-the-spot reservation for a student wanting to take a test. After a year of housing tests at TARLab with the scheduling system, a trend was observed that very few students actually made prior reservations. Most students relied on the proctor to unlock tests for them if a seat was available. TARLab faced an unequal distribution of test takers. **Providing legal on-the-spot reservations** After verifying a student’s A-Number, the system gets a list of all scheduled tests for a particular student. It stores the “test id” of all the scheduled tests. The system then looks into the reservation table, and checks via the received A-number for any entries. If the system finds any entries, it only extracts the “test id” column from the set of entries in the reservation table and stores it. It is now possible to determine the number of tests a student has reserved and not reserved. The system compares the two lists of “test id” and if a match is found, the test is declared as a reserved test. If no matches are found the test is declared unreserved for a student and a new list of “test id” containing only unreserved tests is created. With this list of unreserved “test id”, the system proceeds to make on-the-spot reservations. The old scheduling system defined a granularity of 30 minutes to make a reservation. Reservations could only be made at the 30th minute round the clock. i.e. 12:00pm, 12:30pm, 1:00pm etc. Furthermore, a reservation could only be made at a future timestamp. So, if a student arrived at the testing center at 12:15pm, a reservation could only be made at 12:30pm and not 12:00pm. So an on-the-spot reservation is made at the next 30th minute interval. i.e. 12:30pm. The need for providing an on-the-spot reservation is so a student can be checked-in immediately after a reservation is made and have the test unlocked. In the old scheduling system, a check-in was only possible if a student’s reservation had started. However, since the reservation was made for a future timestamp, the student would have to wait until the reservation started. So, the reservation time for a student is now brought back to the previous 30th minute interval. i.e: 12:00 pm. Now as the system’s current time is 12:15 pm and the reservation had started at 12:00 pm, a student can be checked-in. Whenever a reservation is made, a corresponding unlock for a test is also created at the reservation time. When the reservation begins, the test is automatically unlocked for a student. So, since the reservation time was brought back to the previous 30th minute interval, the corresponding unlock in the unlock table was also set to the previous 30th minute interval. Now after a student is checked-in, the matching test is automatically unlocked. **Calculating the exact time period for a test.** The previous scheduling model did not have a method to calculate the precise time period used by a student to complete a test. There was also no method that detected if a student had completed a test. To calculate the exact time period used by a student to complete a test, two additional timestamp columns are included in the reservation table. When the student starts taking a test, the start time of the test is stored in one column labeled “test start time”. This start time is the system’s current time. A precise end time is also calculated by adding the test duration to the start timestamp. This end timestamp is stored in the other column labeled “test end time”. When a reservation is made, the value of the start time column is set to null and the value of the end time is set to the reservation length. After a student logs-in and starts taking a test, the precise start time and end times are calculated and stored in the matching entry of the reservation table. This information is useful for making seats available in the future. The test end time is an exact value for which a student can occupy a seat in the testing center for taking a test. To indicate if a student has finished with a test, a Boolean column labeled finished with test is also added to the existing reservation table. This column is set to false by default when an on-the-spot reservation is made for a student. When a student taking a test decides to finish with a test, the matching entry for the student in the reservation table is referred, and the finished with test column is set to true. This column in the reservation table helps to determine all the students who completed their test before the calculated test end time. **Releasing vacant seats.** With a testing center’s lab-id, the system looks up the lab table and obtains the total number of seats available for a lab. It compares this count with the total count of entries in the reservation table which represents the number of seats currently occupied. If the count of entries in the reservation table is less than the total count of seats in the lab, it concludes that a seat is vacant. If the count of entries in the reservation table (seats currently occupied) is equal to the total count of seats in a lab, it concludes that a seat is unavailable. The current system uses the reservation table to store entries of reservations that are ongoing. That is, it only keeps entries of test takers who are currently taking a test at the testing center and deletes entries when they are finished. i.e. if the TET column entry in the reservation table shows a time in the past, the entry in the reservation table is deleted. The TET values are compared with the system’s current time before they are deleted. The TET value for every student in the reservation table is the exact time at which the student’s test would time out. So a student can no longer occupy a seat in the testing center if a test is timed-out, the system assumes that he/she has completed the test. Reservations for students who complete the test before the TET are also deleted from the reservation table. The FWT flag is a Boolean column that is set to false when a reservation is made. When a student finishes with a test, the FWT column for the student’s entry in the reservation table is set to true. The system looks into the FWT column in the reservation table and deletes all entries that are set to true. This helps the system to release unused seats. The procedure to delete entries from the reservation table is called periodically at 8 seconds. So, every 8 seconds the system attempts to release unused seats. This procedure starts when the card swiper interface is launched and exits when the card swiper interface is closed. Every 8 seconds, if the system releases a seat, it informs the proctor via the card swiper interface of a seat availability. It also allows for on-the-spot reservations. If the testing center is at capacity and the system is unable to release seats, it informs the proctor of the next time at which a seat can be made available. It does this by storing a list of all TETs and displays the smallest TET in a date-time format. Even if seats are unavailable and the proctor gets a timestamp of the next seat availability, a seat can potentially become available before the predicted time. This occurs if a student finishes their test before the allotted TET. 3.3 Hardware Analysis. The hardware used in the automated scheduling and check-in system is described in this section. 3.3.1 The Magnetic Card Reader. In order to read information from a student’s ID-Card, a magnetic card reader “4000M series by Scan Technology, Inc” is used. Magnetic card readers are capable of reading the information stored in magnetic stripe cards. This information is usually in an encrypted form and is stored by modifying the magnetism of tiny iron-based particles on the band of a magnetic stripe card [2]. The output obtained from the magnetic card reader is in the form of simple key strokes, like symbols from a keyboard. To extract relevant information from the output of the magnetic stripe card, the information has to be first decrypted and then parsed. Data on a magnetic card reader is stored in the form of “tracks” [3]. Current day magnetic stripe cards have up to three tracks and different information can be stored on each of these tracks. This stored data can be read in numerous ways, such as serially reading either all or a few of the tracks, or through another method called field parsing. Field parsing is used in the system so that the A-Number can be directly extracted from the card reader and unwanted data can be omitted. Field parsing helps in creating pre- ambles and post-ambles to the information, and it also makes provisions for setting offsets for reading the data. The 4000M series card reader supports interfacing with a computer via a keyboard wedge, USB, USB-HID, or USB-Serial, and up to 3 different card formats. In this applica- tion, the proctor’s computer is interfaced with the magnetic card reader via a USB. The magnetic card reader is also capable of reading information from other sources such as credit or debit cards and driver’s licenses. Scan technology provides a Windows based software and driver to program the unit in order to extract only relevant information. Since the magnetic card reader for the card swiper interface is only used to extract a student’s A- number, it is programmed accordingly. Magnetic card readers have low power consumption, compact size, and are portable (see Fig. 3.1 and Fig. 3.2). Fig. 3.1: The Magnetic Card reader. Fig. 3.2: The Magnetic Card reader with A-Card being swiped. Chapter 4 Implementation 4.1 The Card Swiper Interface. The card swiper interface is the front end of the automated check-in and scheduling system. It is interfaced with the magnetic card reader 4000M series. It is also the sole medium through which all the information is displayed to commit check-ins. The interface is programmed to receive data from the magnetic card reader every time a card is swiped. It uses the latest JQuerry-UI technologies to render sharp appropriate graphics. The interface is designed using numerous JQuerry effects and transitions to facilitate easier understanding for the proctor while presenting information and accepting inputs. The card swiper interface is divided to 3 parts, 2 of which render dynamic results and one which stays static. The first section is called the student input section and illustrates how to interact with the interface. A textbox is provided to display a students A-Number when a card is swiped. If a student is unable to present an ID-Card on entering the testing center, or if the magnetic card reader renders an error, the proctor can directly input an A-Number in the textbox via their keyboard. To submit the A-Number to the automated check-in and scheduling system, there is no need to hit the enter key or click any button. This is because the interface uses a smart regular expression matching technique to look for a possible A-Number format match. An A-Number has a total of 9 characters, of which the first character is an A, followed by 8 digits. When an A-Number match is found, the interface directly sends the information to the automated check-in and scheduling system. The regular expression matching technique helps to reduce the overall time required for a proctor to perform a student check-in (see Fig. 4.1). The second section is called lab-information section on the card swiper interface and includes a container for displaying the testing center’s information. The card swiper interface receives the testing center’s information from the automated check-in and scheduling system when it is launched. The information presented to the proctor includes the lab-name, total available seats, total vacant seats, the authorized IP-range etc. This information changes when a student finishes a test or times-out from a test and makes the matching seat vacant. In order to display seat availability to the proctor, the information is updated every 8 seconds through an AJAX call from the automated check-in and scheduling system. The time limit of 8 seconds is chosen to reduce the number of times the system references the iNetTest database while also providing for real time seat availability. The proctor can also extract information on the current availability of seats through the interface. If a seat is available, a message indicating the seat availability is displayed. If a seat is unavailable, a message indicating the next time instant at which a seat is likely to be available is displayed. Apart from text messages, an added feature used is color coding to display the availability of seats. The colors red and green are used to highlight messages. Red indicates no seats available, while green indicates that seats are available. Such a color coding technique makes it easier for the proctor to perform check-ins as the need to read messages becomes optional. To further aid the proctor, a progress bar indicating the percentage of lab occupancy is also created using the JQuerry-UI. Information regarding the percentage of seats currently occupied can be obtained from the progress bar (see Fig. 4.2). Fig. 4.2: The card swiper interface displaying the lab-information section. The third section is called the check-in section and displays detailed information pertaining to all tests scheduled for a student. The proctor uses this information to check in a student. After an A-Number is processed, if a student has any test(s) scheduled at the testing center, the automated check-in and scheduling system displays this information in the check-in section of the card swiper interface. If a student does not have any tests scheduled, no data is presented to the proctor, forbidding him from committing a check-in. Furthermore, only if a seat is available at the current time at the testing center, can the proctor receive information from the automated check-in and scheduling system to commit check-ins. After an A-Number is processed, a label with a student’s first and last name is displayed. Other useful information such as the number of scheduled tests and a reservation status is also displayed within the same label. For every test that is scheduled for a student, the matching information required for a check-in is presented to the proctor through a JQuery-UI widget called an “accordion”. Each tab on the accordion is set to automatically open and display relevant test information on a mouse-hover event. Each tab heading contains a test name and the student’s reservation status for that particular test. The reservation status shows the keyword “reserved” if the student has made a prior reservation for the test, or shows the keyword “unreserved” if the student has not made any reservations. With this basic information presented to a proctor as tab headings, the proctor does not need to hover over every tab to access the test details. He/she can obtain the test name directly from the student and proceed to check-in by hovering the cursor on the matching tab. On opening a tab in the accordion, a list of test details is displayed to the proctor for committing a check-in. This list contains: - Test name - Test duration - Test status - Calculator options Each tab also contains a button labeled “Attempt check-in”. A check-in for a student can be attempted by clicking this button. In the accordion, only one tab can be opened at a time. Hovering the mouse over another tab causes the previous tab to close. This helps in displaying only relevant information to a proctor during a check-in. Since a magnetic card reader reads data only when a magnetic stripe card is swiped across it, a JQuerry-UI effect is used when data is displayed on the interface. The data is presented from left to right as a slide effect (see Fig. 4.3). ![Fig. 4.3: The card swiper interface displaying the check-in section.](image) In each stage of a check-in, colored icons are used for graphical representation of a success or failure, along with text messages and JQuerry-UI effects. Successful check-in of a student is displayed with a “Tick” icon. Errors or failure to check-in a student is displayed with a “Cross” icon. An “Exclamation” icon is displayed when more information is needed from the proctor. Without having to read the text message, just by looking at the icon displayed, the proctor can obtain the information that he/she needs. When the interface is idle, an animated-GIF of a swiping card in motion is kept active prompting the proctor to perform card-swipes. Messages are displayed on the proctors screen for 5 seconds, after which they timeout, requiring the proctor to retry a check-in or try another student’s check-in (see Fig. 4.4 and Fig. 4.5). ![Figure 4.4: Interface indicating a successful check-in.](image) Since magnetic card readers are also capable of reading debit and credit cards and drivers-licenses, only valid A-Number formats get positive results. Errors on the screen accompanied with a “Cross” icon are displayed if a card other than a valid USU ID-Card is swiped. At any stage, the proctor may choose to reset the interface if there are any HTML errors or scripting errors. It is recommended to use Mozilla-Firefox as a browser to log-in. The reset button clears all the HTML content on the interface and restarts the interface while keeping all lab-information intact. ### 4.2 Automated Check-in and Scheduling System. The automated check-in and scheduling system is the backend for the card swiper Fig. 4.5: Interface indicating failure for check-in as no seats are currently vacant. interface. The connection between the card swiper interface and the automated check-in and scheduling system is made using a struts framework. The card swiper interface invokes two AJAX calls to the scheduling system, requesting information. These calls are handled by an action class in the scheduling system and a response is sent back to the interface. The scheduling system also responds to other AJAX calls that are made when a student logs into iNetTest. A postresql database is used to store all records and the system is connected to the database via enterprise java beans (Ejb). The first call to the scheduling system is automatically made when the interface is launched. A javascript “setinterval” function is used to periodically make this call every 8 seconds. This call is responsible to update the testing center’s information on the card swiper interface. Additionally, it also attempts at making seats available to students at 8 seconds. If seats are currently unavailable, it predicts a time instant at which the next seat is likely to be available. The “clearInterval” function is called when the card swiper interface is closed. The second call from the interface is made when a valid student A-Number is received. This call is responsible to provide on-the-spot reservation for students and commit check-ins. The system binds all the test information for a particular student and sends it back as a response to the interface (see Fig. 4.6). ![Diagram of automated check-in and scheduling system] **Fig. 4.6**: Simple design illustration of the automated check-in and scheduling system. **Action 1**: Periodic call at 8 seconds to free seats, predict seat availability and update lab information. To make seats available in the testing center, this action looks into the reservation table to delete all entries that have a “finished with test” column set to true. This is because, the “finished with test” column is set to false when a reservation is made and is set to true when a student finishes taking a test. The scheduling system also compares the system’s current time stamp with all the values in the column “test end time” in the reservation table. It deletes all entries in the reservation table that have a “test end time” value lesser than the current timestamp. This is done since the “test end time” is an exact value for each student taking a test. A student’s test cannot be active after the timer runs. out (see Fig. 4.7). Fig. 4.7: Workflow of Action 1 to make seats available and predict timestamps. Action 2: Attempting on-the-spot reservations and check-in when a card is swiped To provide for on-the-spot reservations requires two AJAX calls to the scheduling system. The first call, named ‘get test information’ is made after a valid A-Number is processed to get a student’s test information. As a student can have single or multiple tests scheduled, some which may be reserved or not reserved, the system binds all necessary information for each scheduled test and sends a response to the card swiper interface. After all test details are displayed on the proctor’s screen, a test is selected by clicking the “attempt check-in” button. The second call named ‘attempt check-in’ is made to determine if the student requires an on-the-spot reservation and commits a check-in. If the reservation and check-in are successful, a response is sent back to the interface. If the on-the-spot reservation is unsuccessful, the process is rolled back and an error is sent back as a response (see Fig. 4.8). Fig. 4.8: Workflow of Action 2 to process on-the-spot reservations and commit check-ins. Lastly, when a student logs into an iNetTest account after checking-in and hits the “Start with test” button, an AJAX call to calculate and set the exact TST and TET is made. After the student finishes a test and hits the “Grade and Exit” button, the FWT column is set to true. Thus, with providing for on-the-spot reservations for students and constantly making seats available at a testing center, the automated check-in and scheduling system along with the card swiper interface increases the efficiency of a lab by allowing students to immediately take tests. Chapter 5 Testing Testing on the automated check-in and scheduling system was conducted with the following setup. - 10 dummy students with A-numbers ranging from A00000001A00000010 were created. Each dummy student's first name had a prefix “tester” and a suffix of the A-number in words. They each had a last name “swiper”. For example, the student with an A-Number “A00000001” had a first name of “testerOne” and last name of “swiper”. The student with an A-Number of “A00000002” had a first name of “testerTwo” and a last name of “swiper” and so on. - Two dummy tests named “GradTest” and “UndergradTest” were created. The duration for “GradTest” was set to 60 minutes and the duration for “UndergradTest” was set to 30 minutes. - A lab with the name of “SwiperLab” was created where the two tests were scheduled. “SwiperLab” was limited to only accommodate 5 students at any given time. So the total seats available for testing at SwiperLab were 5. - The 10 dummy students were scheduled at “SwiperLab” to take “GradTest” and “UndergradTest”. - The lab was set to be open between 9:00am to 3:00pm. So a total of 6 hours was available on each of the 5 machines at the testing center. Thus SwiperLab was capable of accommodating 30 hours testing in a day. - As the students had to take both GradTest and UndergradTest, they each required 1.5 hours to complete both their tests at SwiperLab. So all the 10 students required a total of 15 hours at the testing center to complete with their tests. Testing was conducted for the following three cases. 1. All students made reservations for both tests before taking them. 2. Some students made reservations while others did not. 3. No student made a reservation. Two distribution patterns of students arriving at a testing center are also considered. 1. Regular distribution: During the working hours of the lab, there is at least one student taking a test in the lab. 2. Irregular distribution: The lab is relatively vacant during a few hours of the day, and is flooded with students at a few peak hours. When all students make a reservation for both tests, each student makes a reservation for a 60 minute test and a 30 minute test. As discussed earlier, the reservation length for a 60 minute test was set at 90 minutes and the reservation length of a 30 minute test was set at 60 minutes. Since each student makes a reservation for their own respective tests, a total of 90 + 60 = 150 minutes (2.5 hours) is reserved for each student. As there are 10 such students, a total of 25 hours are reserved on the computers at the testing center. Once a student starts with a test, the automated check-in and scheduling system tries to make seats available for other students. However, since all students have made prior reservations there is no use in making other seats available. The lab can accommodate all the students only during a regular distribution (see definition above) of students through its working hours. When no students make reservations, the total number of hours reserved on the computers at the testing center is reduced. This is because, after making an on-the-spot reservation and when the student begins the test, the student is allotted only the amount of time required to complete their test. As soon as a student is timed-out from a test or finishes with a test, the seat is made free. Thus assuming a student makes an on-the-spot reservation at 12:15 pm, and starts with a 30 minute test at 12:25 pm, the student’s seat is made free at 12:55 pm and another student can make an on-the-spot reservation for 1:00 pm. In an ideal case, if each student was to start taking a test exactly at the time of making an on-the-spot reservation, a total of 60 + 30 minutes = 90 minutes (1.5 hours) is reserved for each student. As there are 10 such students, a total of 15 hours are reserved on the computers at the testing center. The system in this case can accommodate students at both regular distributions and irregular distributions. In the case when only some students make reservations, the time efficiency of the testing center reduces as compared to when no students make reservations. Assume the testing center has seats available for say the next 60 minutes, and at the end of that time the testing center has students coming in with prior reservations. Now if student “SwiperOne” (A000000001) wants to take “GradTest” (60 minutes) by attempting an on-the-spot reservation, the system would generate an error. This is because the system always makes a reservation at the next 30th time interval on the clock, and since the system detects the prior reservations made by other students, it cannot accommodate “SwiperOne” to “GradTest”. Thus, although there are 60 minutes available, because of prior reservations, the system cannot process on-the-spot reservations. TARLab never faced a situation where all students made reservations; most students relied on proctors to unlock tests without making reservations. The testing chapter proves that even in cases where no students make reservations in TARLab, the scheduling system would not only ensure a valid seat but also increase the testing centers overall efficiency. Chapter 6 Future Work The Automated check-in and scheduling feature provides an enhancement to increase time efficiency. It decreases the time for a student to check-in and allows for more efficient use of the available workstations by maximizing seat availability to students. The proctors screen now predicts the time at which a next seat is likely to be available. Students need not come to a testing center if seats are currently unavailable for testing. If details such as the next seat availability, total seats currently occupied, the testing centers working hours, etc. were made publically available to all USU students, each student who did not have a reservation could either more efficiently make a reservation, or know when a seat is likely to come available. USU has an existing mobile app implemented for both iOS and Android enabled smart phones. With this app, a student has direct access to all upcoming events at USU, newsletters and articles, maps, USU radio etc. The app also allows students to log-in to their banner accounts. If a separate bulletin board containing TARLab’s information was created, students could simply check app for seat availability. Another enhancement could be a waiting list. The current scheduling system does not provide a waiting list for students. When the testing center is at capacity, a waiting list could hold for each student, a name and phone number associated with a wait timestamp. When a seat is made available, the student could be immediately informed, via a text message of the seat availability. Chapter 7 Conclusion The architecture of the old scheduling system on iNetTest enables the automated check-in and scheduling system to seamlessly integrate with it. iNetTest can now manage computer based tests housed at a testing center much efficiently. The card swiper interface provides a quick medium to fetch a student’s input, while presenting all details for a check-in within one container. It reduces the workload on a proctor and also increases the speed of a check-in for a student. The Automated check-in and scheduling system provides for on-the-spot reservations for students while also making seats available to them. Time efficiency for a testing center is highly improved as seats can potentially be made available every 8 seconds. The testing center can now accommodate a larger set of students at a given day for testing. Since the entire reservation process is automated, students can feel free to take a test without prior reservations. TARLab is ready to go into use with iNetTest’s automated check-in and scheduling system. References
{"Source-Url": "http://cs.usu.edu/pdf/PlanB_Report_Example.pdf", "len_cl100k_base": 15347, "olmocr-version": "0.1.50", "pdf-total-pages": 51, "total-fallback-pages": 0, "total-input-tokens": 84373, "total-output-tokens": 17125, "length": "2e13", "weborganizer": {"__label__adult": 0.0005970001220703125, "__label__art_design": 0.0022373199462890625, "__label__crime_law": 0.000579833984375, "__label__education_jobs": 0.2142333984375, "__label__entertainment": 0.00029850006103515625, "__label__fashion_beauty": 0.00049591064453125, "__label__finance_business": 0.0014028549194335938, "__label__food_dining": 0.0009465217590332032, "__label__games": 0.0019207000732421875, "__label__hardware": 0.00342559814453125, "__label__health": 0.0006117820739746094, "__label__history": 0.0010585784912109375, "__label__home_hobbies": 0.0004150867462158203, "__label__industrial": 0.0008387565612792969, "__label__literature": 0.0007510185241699219, "__label__politics": 0.0003938674926757813, "__label__religion": 0.0008683204650878906, "__label__science_tech": 0.034088134765625, "__label__social_life": 0.0003921985626220703, "__label__software": 0.064697265625, "__label__software_dev": 0.66748046875, "__label__sports_fitness": 0.000492095947265625, "__label__transportation": 0.0011758804321289062, "__label__travel": 0.0006051063537597656}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 70944, 0.0334]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 70944, 0.25376]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 70944, 0.94265]], "google_gemma-3-12b-it_contains_pii": [[0, 385, false], [385, 385, null], [385, 1648, null], [1648, 3151, null], [3151, 3162, null], [3162, 4419, null], [4419, 4593, null], [4593, 6611, null], [6611, 8812, null], [8812, 9293, null], [9293, 10348, null], [10348, 11291, null], [11291, 12977, null], [12977, 15356, null], [15356, 17331, null], [17331, 18709, null], [18709, 20104, null], [20104, 22063, null], [22063, 23972, null], [23972, 26117, null], [26117, 27054, null], [27054, 28285, null], [28285, 30297, null], [30297, 32343, null], [32343, 34566, null], [34566, 36511, null], [36511, 38631, null], [38631, 40603, null], [40603, 42863, null], [42863, 45221, null], [45221, 47501, null], [47501, 49447, null], [49447, 50453, null], [50453, 50514, null], [50514, 52490, null], [52490, 53577, null], [53577, 54726, null], [54726, 56529, null], [56529, 57587, null], [57587, 58468, null], [58468, 59592, null], [59592, 61000, null], [61000, 61796, null], [61796, 62471, null], [62471, 62757, null], [62757, 64261, null], [64261, 66279, null], [66279, 67963, null], [67963, 69527, null], [69527, 70577, null], [70577, 70944, null]], "google_gemma-3-12b-it_is_public_document": [[0, 385, true], [385, 385, null], [385, 1648, null], [1648, 3151, null], [3151, 3162, null], [3162, 4419, null], [4419, 4593, null], [4593, 6611, null], [6611, 8812, null], [8812, 9293, null], [9293, 10348, null], [10348, 11291, null], [11291, 12977, null], [12977, 15356, null], [15356, 17331, null], [17331, 18709, null], [18709, 20104, null], [20104, 22063, null], [22063, 23972, null], [23972, 26117, null], [26117, 27054, null], [27054, 28285, null], [28285, 30297, null], [30297, 32343, null], [32343, 34566, null], [34566, 36511, null], [36511, 38631, null], [38631, 40603, null], [40603, 42863, null], [42863, 45221, null], [45221, 47501, null], [47501, 49447, null], [49447, 50453, null], [50453, 50514, null], [50514, 52490, null], [52490, 53577, null], [53577, 54726, null], [54726, 56529, null], [56529, 57587, null], [57587, 58468, null], [58468, 59592, null], [59592, 61000, null], [61000, 61796, null], [61796, 62471, null], [62471, 62757, null], [62757, 64261, null], [64261, 66279, null], [66279, 67963, null], [67963, 69527, null], [69527, 70577, null], [70577, 70944, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 70944, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 70944, null]], "pdf_page_numbers": [[0, 385, 1], [385, 385, 2], [385, 1648, 3], [1648, 3151, 4], [3151, 3162, 5], [3162, 4419, 6], [4419, 4593, 7], [4593, 6611, 8], [6611, 8812, 9], [8812, 9293, 10], [9293, 10348, 11], [10348, 11291, 12], [11291, 12977, 13], [12977, 15356, 14], [15356, 17331, 15], [17331, 18709, 16], [18709, 20104, 17], [20104, 22063, 18], [22063, 23972, 19], [23972, 26117, 20], [26117, 27054, 21], [27054, 28285, 22], [28285, 30297, 23], [30297, 32343, 24], [32343, 34566, 25], [34566, 36511, 26], [36511, 38631, 27], [38631, 40603, 28], [40603, 42863, 29], [42863, 45221, 30], [45221, 47501, 31], [47501, 49447, 32], [49447, 50453, 33], [50453, 50514, 34], [50514, 52490, 35], [52490, 53577, 36], [53577, 54726, 37], [54726, 56529, 38], [56529, 57587, 39], [57587, 58468, 40], [58468, 59592, 41], [59592, 61000, 42], [61000, 61796, 43], [61796, 62471, 44], [62471, 62757, 45], [62757, 64261, 46], [64261, 66279, 47], [66279, 67963, 48], [67963, 69527, 49], [69527, 70577, 50], [70577, 70944, 51]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 70944, 0.15702]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
27c25de5218a53324656d78c4f0e53db0c6b4fd1
[REMOVED]
{"len_cl100k_base": 9166, "olmocr-version": "0.1.53", "pdf-total-pages": 10, "total-fallback-pages": 0, "total-input-tokens": 32871, "total-output-tokens": 11711, "length": "2e13", "weborganizer": {"__label__adult": 0.0003180503845214844, "__label__art_design": 0.0002989768981933594, "__label__crime_law": 0.0002732276916503906, "__label__education_jobs": 0.0010986328125, "__label__entertainment": 9.566545486450197e-05, "__label__fashion_beauty": 0.0001628398895263672, "__label__finance_business": 0.0005044937133789062, "__label__food_dining": 0.0002989768981933594, "__label__games": 0.0008463859558105469, "__label__hardware": 0.0021114349365234375, "__label__health": 0.0005574226379394531, "__label__history": 0.00032138824462890625, "__label__home_hobbies": 0.00011539459228515624, "__label__industrial": 0.00042891502380371094, "__label__literature": 0.0003402233123779297, "__label__politics": 0.0001995563507080078, "__label__religion": 0.0004143714904785156, "__label__science_tech": 0.10040283203125, "__label__social_life": 8.171796798706055e-05, "__label__software": 0.0196075439453125, "__label__software_dev": 0.87060546875, "__label__sports_fitness": 0.0002276897430419922, "__label__transportation": 0.0005588531494140625, "__label__travel": 0.00018870830535888672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52285, 0.0253]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52285, 0.47948]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52285, 0.92398]], "google_gemma-3-12b-it_contains_pii": [[0, 4417, false], [4417, 10773, null], [10773, 14439, null], [14439, 20929, null], [20929, 27624, null], [27624, 33584, null], [33584, 40555, null], [40555, 46220, null], [46220, 51272, null], [51272, 52285, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4417, true], [4417, 10773, null], [10773, 14439, null], [14439, 20929, null], [20929, 27624, null], [27624, 33584, null], [33584, 40555, null], [40555, 46220, null], [46220, 51272, null], [51272, 52285, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52285, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52285, null]], "pdf_page_numbers": [[0, 4417, 1], [4417, 10773, 2], [10773, 14439, 3], [14439, 20929, 4], [20929, 27624, 5], [27624, 33584, 6], [33584, 40555, 7], [40555, 46220, 8], [46220, 51272, 9], [51272, 52285, 10]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52285, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
e36fda8a847145e8e838eea58a67032790d701f6
First class feature abstractions for product derivation A.G.J. Jansen, R. Smedinga, J. van Gurp and J. Bosch Abstract: The authors have observed that large software systems are increasingly defined in terms of the features they implement. Consequently, there is a need to express the commonalities and variability between products of a product family in terms of features. Unfortunately, technology support for the early aspect of a feature is currently limited to the requirements level. There is a need to extend this support to the design and implementation level as well. Existing separation of concerns technologies, such as AOP and SOP, may be of use here. However, features are not first class citizens in these paradigms. To address this and to explore the problems and issues with respect to features and feature composition, the authors have formalised the notion of features in a feature model. The feature model relates features to a component role model. Using our model and a composition algorithm, a number of base components and a number of features may be selected from a software product family and a product derived. As a proof of concept, the authors have experimented extensively with a prototype Java implementation of their approach. 1 Introduction Software applications grow larger and larger, are maintained for longer periods of time and need to be updated frequently to evolve with new needs and changing consumer requirements. To cope with this increasing size of software applications a software product family (SPF) [1, 2] approach can be used. An SPF is designed for a family of (domain) related applications. It consists of a product-line architecture and a set of reusable components. Specific applications may be derived from the SPF by selecting, enhancing and adapting components. We have observed that, during product derivation, the differences between products are usually defined in terms of features [1, 3–5]. Features are an example of early aspects [6], crosscutting concerns at the requirements and architectural level. Features are used in requirement engineering to define optional or incremental units of change [7]. They have a many-to-many relationship to the individual requirements [1]. Tracing features to the implementing SPF components is complex. In ideal cases, a particular feature implementation is localised to a single module; but in many cases features will cut across multiple components [8]. Consequently, features are an important early aspect to consider, as they try to bridge the gap between the problem domain and solution domain [9]. The product derivation process in an SPF is a time-consuming and therefore expensive process. The reason for this is that there is a mismatch between the way products are defined (i.e. in terms of features) and the variability offered by the SPF. Requirements changes generally result in changing and/or adding features to the SPF. However, typically features have no first class representation in the SPF implementation. During product derivation, developers must make adaptations to the SPF’s provided feature set in order to implement product specific features. Consequently, changing the implementation to meet new requirements is potentially expensive because code related to one feature may be spread over multiple software components. Ideally, new or changed features would be captured in separate pieces of code that can be changed and maintained independently. Thus changes during the product derivation would be limited to those pieces of code. The main topic of this paper is giving features a first class representation in SPFs so that during product derivation, product developers may select features from the SPF and reuse them in their products. There are a number of problems associated with this type of product derivation. A key contribution of this paper is that we identify those problems and demonstrate in our approach how these can be worked around or solved. We use a top-down approach of analysing the issue of feature based product derivation. Our top-down approach starts with the modelling of concepts such as features and SPFs in terms of sets. With the help of this formal description of the feature model composition problems are identified. Several solutions to these composition problems are presented. One of these solutions is used in a prototype implementation that is also presented in this paper. The three contributions of this paper are: - a feature model, which relates features of an SPF with component roles - a classification of feature composition problems and potential solutions to these problems - a demonstration of how features can be realised at the implementation level. This opens the way to automatically derive a product from an SPF based on a selection of available features. 2 Features in software product families To clarify our approach, an examination of how features and SPFs are related is presented. After this, an informal outline of our approach is presented. The approach involves features, actors and roles. At the end of the Section the approach is exemplified using the example of a video shop renting system. 2.1 Software product families (SPFs) An SPF consists of a base implementation (e.g. $B$) and a number of features (e.g. $F_1$, ..., $F_3$). A product may be derived from the SPF by selecting an arbitrary number of these features and combining these with the base implementation (e.g. $B + F_1 + F_2 + \cdots + F_3$). The base implementation itself can also been seen as a set of (standard) features, i.e. an SPF then becomes, for example, $F_1 + F_2 + F_3 + F_4 + F_5 + \cdots + F_3$, where some features (e.g. 1 to 4) are standard features (in FODA these are called mandatory features [3]) and others are optional features. In this paper, base components model entities, which cannot easily be decomposed into features. Legacy code components and domain components are examples of these base components. The properties of the composition-operator ‘$+$’ are our primary interest in this paper. Of course, it would be ideal if that operator were associative i.e. $[(F_1 + F_2) + F_3] = [F_1 + (F_2 + F_3)]$, and commutative, i.e. $F_1 + F_2 = F_2 + F_1$. Then, a product developer would be able to arbitrarily combine features. The developer of each feature would not need to worry about interaction with other features. This way it would not make any difference at what point in time and/or development a certain feature is brought into a feature composition. However, in general (as will be argued in the following Section) this operator is neither associative nor commutative, because of feature dependencies: one feature may depend on another feature. This is, for example, the case if one feature cannot operate without another feature. A further complication factor is that the composition of features might introduce feature interaction [7]: a feature interaction is some way in which one or more features modify or influence another feature in describing the system’s behaviour set. An example of feature interaction can be found in Microsoft Outlook. Outlook, a popular e-mail client for Windows, has two related features: ‘work off-line’ and ‘send immediately’. The work-off-line feature enables users to use the e-mail client without having a permanent connection to their mail server. While working off-line, Outlook caches the different actions of the user and executes them when the user switches to on-line mode. On the other hand, if the send immediately feature is enabled, a message is sent immediately when a user presses the send button. Clearly both features influence each other. The send immediately feature should be disabled if the user is working off-line. However, this is not the case in Outlook. At present, Outlook still tries to send a message even though the user is working off-line. A potential cause for this problem could be that both features were implemented independently from each other. The problem only surfaces when both features are enabled. Consequently, unit testing will not detect this problem. Feature interactions, like the example of Outlook, are very common in large software systems. As Zave observes, this type of problem potentially makes the composition of features incomplete, inconsistent, nondeterministic, hard to implement, etc. (see [10]). The method introduced in this paper aims to keep the composition complete, consistent, deterministic, and implementable. 2.2 Roles, actors and base components The modelling of an SPF as a base implementation composed of a set of selected features demands a more detailed modelling of a feature. Our approach does not assume how the inner workings of the base components are defined, only the assumption that some of them exist. The relationship between a feature and the base components is defined through a role-based approach. Role modelling is used, because features typically affect more than one domain component simultaneously. In this perspective a feature can be viewed as a collection of base components playing roles of a feature. However, there is no simple one-to-one relationship between the roles of a feature and the roles ‘played’ by the base components. This simple relationship does not exist, because we want to define the features and their roles independent of the base components. As a consequence of this flexibility, there may be a base component playing more than one role of a feature. The opposite is also possible – one role of a feature can be played by several base components. To model this many-to-many mapping of roles and base components, our approach uses the concept of actors. Note that with the term ‘actor’ a different concept is meant than is used in parallel object-oriented programming [11]. In the feature model, an actor is a first-class representation of a base component and the roles it plays for a single feature. Figure 1 visualises the various feature model elements and their relationships. The base components visualised in the top part of Fig. 1 are entities, which cannot easily be decomposed into features and belong to the base SPF implementation. On the left side of Fig. 1 two features containing one and two roles are presented, visualising the fact that roles are part of a feature. At the centre there are four actors. The top two actors consist of base components 1 and 2, both playing role 1. The bottom two actors are base component 1 playing role 2 and base component 2 playing role 3. At the bottom of Fig. 1 the derived components are situated. A derived component is a base component incorporating actors playing the roles of the selected features. The concepts we discussed here form the basis of our composition approach, which will be elaborated on in Section 3. Before that, however, we provide an example. Fig. 1 Conceptual view of feature model 2.3 Case Throughout the rest of this paper a video renting administration system is used to illustrate various aspects of the feature model. A quick domain analysis provides the following domain components for the video-shop system: a VideoShop component, a Video component and a Customer component. These three domain components are the base components of this case. For the remaining part of the paper components are typeset **bold**. Features are typeset **underlined**. The following features have been selected for this case: - **VideoRental**: A Customer can rent a Video - **ReturnVideo**: A Customer can return a Video that is rented - **AmountDiscount**: A Customer receives a certain discount when renting more then one Video - **RegularCustomerDiscount**: A regular Customer receives a certain discount when renting a Video - **AgeControl**: Only a Customer above a certain age may rent a certain Video These features are selected because they illustrate the various issues of the feature model. The system should always contain the features VideoRental and ReturnVideo, for the system to have a minimal of functionality. Both features, however, will not be part of the base components because the specification of the features might change over time. The other features are optional. Some features are dependent on each other, e.g. all optional features depend on VideoRental. Also, some features will have feature interaction, for example AmountDiscount and RegularCustomerDiscount, both influence the amount of money a customer has to spend. Figure 2 presents an overview of the video-shop case. The different features of the video-shop, e.g. VideoRental, ReturnVideo, etc., can be found on the left side. The base components (VideoShop, Customer, Video) are found on the top. The features consist of one or more roles, for example the VideoRental feature consists of the following roles (roles are in teletype): Contract, Contract Maintenance, RentedItem, Renter and Maintenance. The first role, Contract of the VideoRental feature, introduces a new concept into the feature model. The Contract role introduces a new component in the composition, the **Contract**, which is not directly related to any existing base component. New concepts in the domain may be added by roles defining new components. Because features are decomposed further into roles, the core of our composition method consists of mapping the defined roles onto the base components. The mapping of the different features and roles is visualised in Fig. 2. For each of the features the roles are presented and the functionality of the roles is visualised by displaying the signatures of the corresponding methods. Furthermore, the functionality of the base components is visualised. When a role is mapped onto a base component an intermediate component is created (we refer to these intermediate components as actors); these are the little rectangles in the middle. Each actor has a unique name, for example the name of the Contract actor is A1-4. The first number indicates that the actor belongs to the first feature (i.e. VideoRental). The second number indicates the base component to which the role has been mapped. The Contract role has been mapped to a new 4th base component. 3 Formalising the notion of features Composition of features such as described in Section 2 is far from trivial. Therefore, to be able to identify potential composition problems, the notion of features is formalised. In Section 4, we use this formal model to derive the properties of the composition operator. The feature model is formally defined in terms of sets. Mappings of elements (e.g. $A \rightarrow B$) of one set to elements of another set denote relationships between those elements. In the model a method signature is denoted by an operationSignature, a unique identifier for the complete definition of the method itself without an implementation; for example, in Java this is the header of a method, including the method name, the list of parameters, and the type of the returned value. A set of such signatures is called an interface: $$\text{interface} = \{ \text{operationSignature}_i | i \in \text{signatureSet} \}$$ With this notation an interface is denoted as a set of operation signatures, named operationSignature$_1$, operationSignature$_2$, etc., where signatureSet is the complete set of the available operation signatures. A role is a set of interfaces and a one-to-one mapping of the operation signatures of the interfaces to implementations of these operation signatures. In imperative languages this implementation can be seen as a code block, i.e. the body of a method without the header. A role can now be defined as: $$\text{role} = \{ \{ \text{interface}_k | k \in \text{interfaceSet} \}, \{ \text{operationSignature}_k \rightarrow \text{implementation}_k | k \in \text{interfaceSet} \land i \in \text{signatureSet}_k \} \}$$ The mapping describes that an operation signature is implemented by associating an implementation with the operation signature. A role is a partial implementation, mapped onto a component. Separate roles in a feature are required to model the fact that one component can have multiple roles in the context of a feature. To do the mapping of a role onto a base component an intermediate form may be used. In a feature the implementations are mapped onto actors. An actor is a set of roles from a feature, mapped to a base component. An actor can be seen as an intermediate component. A feature is a set of roles, a set of actors, and a many-to-many mapping from roles to actors, i.e.: $$\text{feature} = \{ \{ \text{role}_r | r \in \text{roleSet} \}, \{ \text{actor}_o | o \in \text{actorSet} \}, \{ \text{role}_r \rightarrow \text{actor}_o | r \in \text{roleSet} \land o \in \text{actorSet} \} \}$$ A role may be mapped to more than one actor. Also, more than one role can be mapped to the same actor. One role can map to more than one actor, if the corresponding code is going to be used in more than one component. Although this will in general be considered a signal of bad design, it is not excluded in our model. A software product family (SPF) consists of all features and all base components: $$\text{SPF} = \{ \text{feature}_f | f \in \text{featureSet} \} \cup \{ \text{baseComponent}_o | o \in \text{baseSet} \}$$ ![Graphical representation of feature composition](image) A specific product, derived from a SPF, consists of a selected number of features, a set of derived components and the mapping from the actors to the derived component implementations, which in turn are derived from the base components, i.e.: \[ \text{product} = \{ \{ \text{feature}, s \in \text{selectedFeatures} \subseteq \text{featureSet} \}, \{ \text{component}, c \in \text{compSet} \}, \{ \text{actor}, a \rightarrow \text{component}, i \in \text{actorSet}, j \in \text{compSet} \} \} \] The set of derived components is derived from the set of base components, through the mapping of the actors to the base components. The component set is explicitly included, as there can be a need for base components which do not have roles mapped on them but are used by included features. For example, this is the case for BC1 in Fig. 3. As a consequence of this definition, the set of derived components contains at least as many elements as the set of base components, i.e. \[ \{ \text{baseComponent}, s \} \subseteq \{ \text{components}, i \} \] The transformation from a base component to a derived component is not formalised here. This transformation is the main issue in our approach and is investigated further in the following Sections. Figure 3 illustrates our approach: methods are mapped onto the components, through the actors. Actors may introduce new components, which are independent of the defined base components. These new components are dependent on an additional, initially empty, base component **none**. Note that we have introduced three types of components: the base components, new components and derived components. The base components come from a domain model or are legacy components. The new components are components introduced by the roles of new features. The derived components are components generated for a specific derivation. Our model currently does not model feature dependencies. The reason for this is that modelling dependencies complicates the feature model too much for our purposes. Therefore, the assumption has been made that the dependencies among the features are known and can be resolved before applying the composition operator. Feature dependencies only influence the order in which the composition operator is applied. However, this does not affect how the composition operator should work. Consequently we do not explicitly model feature dependencies because they are not relevant for our purpose of examining the properties of the composition operator. ### 4 Composition operator In this Section, the composition operator for the feature model is investigated. The composition operator in the feature model is used to compose features with base components. A feature, however, consists of one or more roles that map onto an actor. This Section investigates how an actor can be composed of roles and base components, what the associated composition problems are and how these problems may be solved. #### 4.1 Introduction An actor consists of roles and base components. In the feature model, the derived components contain the functionality of the corresponding base components and actors of the selected features that are mapped to the base component. As mentioned earlier, feature dependencies complicate the composition process. Ideally the order in which features are mapped to base components would not affect the semantics of the derived components. However, because of the dependencies the order does matter (i.e. the composition operator is not commutative). Conceptually, the actors are accumulated on top of the base components (i.e. each actor is composed with the composition of all previous actors and the base components). Each actor combines various roles of a feature that are mapped to the same base component. For example, Fig. 4 visualises the composition of two roles (R1 and R2). To simplify the composition problem, Fig. 4 does take into account that an actor can be composed with a base component or another actor. However, this has no consequences for the composition operator. Both roles (R1 and R2) consist of one operation, denoted by S1 and S2, and an implementation for this operation (i.e. I1 and I2). The actor that results from the composition of role A and B should contain the unified behaviour of roles A and B. Both implementations A and B are considered to be black boxes. The composition of the actor then becomes the problem of ‘gluing’ both implementations together, as denoted in Fig. 4 with the question marks. #### 4.2 Analysing the composition of roles Both operation signature and implementation have an effect on the ‘glue’ that is needed to compose the implementations. By looking at the relationships between the operation signatures and the implementations, four different types of composition can be identified: 1. Signatures and implementations are all different. Figure 3 illustrates this: roles R2 (with S2 and I2) and R6 (with S6 and I6). R2 is mapped onto actor A1-2 and R6 is mapped onto actor A3-2. Both A1-2 and A3-2 are mapped onto the same base component BC2. An example in the video shop (Fig. 2) is the Renter and Returning roles. This situation does not raise any problems because there is no interaction between the implementations. 2. The signatures are different and the implementations are equal. In Fig. 3 this is illustrated in roles R2 (with S2 and I2) and R4 (with S1 and I2). Role R2 is mapped onto actor A1-2 and R4 onto A2-2. Both A1-2 and A2-2 are mapped onto the same base component BC2. The video shop example does not contain this situation. This situation does not present any problems either. It might signal bad design because different signatures can be implemented using the same implementation so the signatures might be considered equal instead of different. 3. Both the signatures and implementations are equal. This looks like copy–paste reuse and also a bad practice. In Fig. 3 this is illustrated in roles R1 (with \( s_1 \rightarrow i_1 \)) and R7 (again \( s_1 \rightarrow i_1 \)). R1 is mapped onto actor A1-4, R7 onto A3-4 and both actors are mapped onto the same base component BC4. The video shop example does not contain this situation. Although code fragments appear double in the resulting application there are no serious problems. Problems may arise, however, when maintenance is needed (code needs to be repaired in different places). A simple solution for this kind of problems is simply mapping the different code fragments to just one fragment. 4. The signatures are equal and the implementations are different. In Fig. 3 this is illustrated in roles R4 (with \( s_1 \rightarrow i_1 \)) and R6 (with \( s_2 \rightarrow i_2 \)). Role R4 is mapped onto actor A2-2, R6 onto actor A3-2 and both actors are mapped onto the same base component BC2. In the video shop case an example of this situation can be found with the Account model of the Renter and AmountDiscount. This is a serious problem that requires further investigation. The remainder of this Section is devoted to this problem. Of the four described combinations for composing the roles, only the last one is problematic. The combination of one signature with more than one implementation can be illustrated best with Lego building blocks. An operation signature is the header and the implementation the body of a method. Equal operation signatures therefore means that the headers are equal, and thus the parameter list and return type of the methods implementing the operation signature are equal – only the body is different. A Lego brick can be seen as a shape representing the operation signature: the shape of the top of the brick illustrates the parameter list and the shape of the bottom of the brick illustrates the return type. The inside of the brick represents the implementation. Because in situation four, the signature is the same for both implementations, the Lego bricks have the same shape. This results in three ways to combine the implementations, as illustrated in Fig. 5: - **A. No input parameters, no output.** The operation signature of the implementations has no return type and no parameters. This is the easiest situation because the implementations may just be concatenated. - **B. Input is equal to output.** If the implementations have the same input type as the return type, the implementations may be piped together. However, this requires that the semantics of the input and output match. - **C. Input and output are different.** In this situation the implementations can neither be concatenated nor piped together. Some glue code may be needed to transform both implementations into one implementation. In all cases a transformation is needed that combines two different implementations into one implementation for the same operation signature. In Lego terms this compares to building a new stone with the same shape (i.e. with the same input parameters and output parameter). Problems arise because of initialisation at the beginning of each of the two implementations, the output parameters of each of the implementations, and side-effects such as, for example, exception handling and results arising. Any implementation of a feature composition will need to make specific design choices with respect to these transformations. Next we look at three alternatives for these transformations. In Section 5, we discuss a prototype algorithm we developed in Java where several design choices with respect to these transformations are made. ### 4.3 Composing implementation blocks There are several ways of combining the two implementations with the same operation signatures, but there are three basic forms: - **Concatenation:** The implementations can be concatenated: \( i_1; i_2 \) or \( i_2; i_1 \). Concatenating the implementations can only be done if the output of the first implementation can be used as input for the second. Thus, concatenation can only be used in situations A and B of Fig. 5. Even then, side-effects such as exception handling may prevent successful concatenation. - **Skipping:** One of the implementations can be skipped: \( i_1 \) or \( i_2 \). Skipping one of the implementations requires an additional criterion to be able to select which one of the implementations to skip. - **Implementation mixing:** The implementations may be mixed (e.g. by superimposing [12], inheritance or delegation). Mixing the implementations, the last possibility of the three, requires knowledge of both the implementations \( i_1 \) and \( i_2 \). Suppose \( i_1 \) is in a feature \( F_a \) and \( i_2 \) is in a feature \( F_b \). Then it is possible to use \( i_2 \) everywhere in the code of \( i_1 \) because they have equal operation signatures. At this point this is best illustrated by comparing this kind of mixing with using an original method of a superclass in the redefined method in the subclass by calling `super` in Java. There are a number of issues with the different combination strategies described above: - **Scope of variables:** Both implementations may have a common set of local variables with different semantics, which may raise some conflicts when both implementations are combined. A possible solution is to automatically rename conflicting local variables. - **Side-effects:** Both implementations may have conflicting side-effects. For example, both implementations may throw an exception. The code of the second implementation may never be executed if the first implementation throws an exception. There are many subtle ways both implementations may conflict which need to be considered when combining the implementations. It should be pointed out that other approaches (e.g. AspectJ [13, 14]) exhibit the same sort of problems. In particular, AspectJ has become a complex language due to the fact that it tries to solve/work around these issues. ### 4.4 Summary In this Section the formal model of the feature composition model has been used to examine where exactly this composition becomes problematic, namely when combining implementations with the same signature into one implementation. We have outlined three strategies, that may be combined, for doing so. However, there are a number of issues that prevent a universal solution to this problem. Any implementation of our feature composition model requires that these issues be addressed in some way. In the following Section we will outline the composition algorithm we used to implement the video shop prototype. 5 Prototype implementation of feature model In this Section a prototype implementation of the feature model is presented. The implementation has been implemented in the object-oriented programming language Java. The prototype, the implementation choices and potential alternative solutions are presented. The Section ends with an overview of implementation issues and their solutions. 5.1 Prototype The prototype that is presented in this Section is intended as a proof of concept. Consequently, a limitation of this is that the prototype is missing some features that would be available in a complete implementation. The composition operator as implemented only supports one variant of the implementation mixing composition solution (see Section 4.3). In addition, an important limitation is that automatic product derivation is not supported with a compiler. Instead, the transformation of the features and the base components into the derived components is done manually. However, it is possible to automate this in the future. The main motivation for building the prototype was to demonstrate that the composition technique described earlier can be implemented in a mainstream programming language, such as Java. However, features are not a first-class entity in Java. Consequently, the feature model entities have to be mapped to Java language constructs. Some of the design choices regarding this mapping are: - **Feature**: A feature is a collection of roles in the feature model. Both features and roles do not have a representation in the Java language. However, Java supports the concept of a package that may be used to group various classes together. The prototype uses the package construct to group roles of the same feature together. - **Role**: In the feature model a role is a collection of interfaces and some code blocks. A Java class also has interfaces and code blocks. Therefore a role is implemented as a Java class in our prototype. - **Base component**: Similarly, base components are also implemented as Java classes. - **Actor**: The goal of feature composition is to combine the base components and the roles in such a way that the result is has the composed behaviour of both. When a role is mapped to a base component an intermediate placeholder class (i.e. an actor) is created that inherits from the base component class. - **Derived component**: Derived components are the result of the composition of selected features and base components. As stated before, actors combine base components and roles using inheritance. However, the derived components should incorporate all the composed behaviour of all the actors and base components. Since Java does not have multiple inheritance, the derived component cannot be constructed by letting them inherit from all the actors classes. To work around this problem, actors inherit from each other. Consequently, the last actor of a base component will have the required composed behaviour of a derived component. Therefore the derived component is an empty placeholder Java class, which inherits from the last actor defined on a base component. An example of this can be found in Fig. 6. A more in-depth description of the composition process and an algorithm for the composition in the Java language can be found in [15]. In Fig. 6 a UML example of the prototype for the feature model of Fig. 1 is presented. The packages of the prototype are visualised as grey boxes which can contain other packagers or classes. The classes are the white rectangles and inheritance is illustrated as an arrow from the subclass to the parent class. 5.2 Potential issues for automatic composition This Section presents a description of the various implementation issues that arose during the implementation of the prototype. The found issues are believed to be general for implementing automatic feature composition based on the feature model. The main issues found during the implementation of the prototype are: - the lack of a dependency model in the feature model - an instantiation problem in the roles - traceability of roles, features and actors. The lack of a dependency model in the feature model is an issue an implementation has to deal with. The feature model assumes that a feature earlier introduced is not dependent on a later feature. The fact that this does not have to be the case in an implementation requires modelling of the dependencies at least at the implementation level. Dependencies also help to define the context of a feature in which a role is specified; hence it restricts the knowledge an implementer needs to implement a role. Experience has taught that there are four types of dependencies: - **Dependency between roles of the same feature**: An example of dependencies among roles in the same feature can be found in the VideoRental feature of the video-shop case (see Fig. 2). One can only rent a Video if the concept of a Contract is introduced (this is in the Contract-role) and the necessary Contract operations in the Customer and Video (these are in the ContractMaintenance-role) are known. - **Dependency between roles of different features**: Dependencies between roles of different features are the basis for feature dependencies. Feature dependencies in the feature model are the result of roles depending on roles or actors of a different feature. An example is the role ExpiredContract of ReturnVideo, which is dependent on the VideoRental feature, because of the needed concept of a Contract. This concept is introduced in the VideoRental feature by the Contract role. - **Dependency between a role and an actor**: This dependency is different from a role depending on another role, because in this dependency a role is dependent on the composition of a role and a specific base component, which is an actor. An example is the Returning role of the Return-Video feature. The Contract that the Returning role uses should have the Contract role (from the VideoRental feature) and also the ExpiredContract role (from the ReturnVideo feature), to be able to expire a contract for this Customer. - **Dependency between a role and a composition of multiple actors**: This dependency is a dependency between a role and a composition of roles and a base component. An example of this dependency is in the Returning role of the ReturnVideo feature. The Video returned should contain the ContractMaintenance role and the RentingMaintenance role to be able to determine whether the Video is already rented and to add a new Contract to the Video if this is not the case. The prototype implements the two role related dependencies with the help of the traditional Java dependency model (i.e. the use of the import statement). The two other dependencies are only partially realised. The recursive way actors are composed, makes the use of traditional Java dependencies between a role and an actor semantically different. The second implementation issue is the instantiation problem. At the moment the roles are written it is not determined which class should be instantiated, because other features can be added or removed on the fly. Observe that the last actor of a component contains the complete composed behaviour for that component; this is due to the recursive composition behaviour of the actors. Each of the components has its own derived component, which should contain the complete composed behaviour for that component depending on the selected features. The derived component therefore could inherit from the last defined actor for the component. If, during the derivation process, the derived component confirms to this inheritance and has a stable name, then it can be instantiated in the different roles. Another implementation issue is the traceability of roles, features and actors, which is required for debugging the derived components. In the prototype the traceability of the different actors is accomplished by the first class representation of the actors. The name of the package in which the actor class is defined is determined by the feature and role names. The name of the actor class is equal to the name of the base component on which it is mapped, resulting in a complete reverse mapping from the derived components back to the roles, features and base components. 5.3 Summary This Section presented a prototype implementation of the feature model. The composition process used in the implementation was motivated and explained. The concrete form of features, roles and actors in the implementation was presented. Implementation issues such as the lack of a dependency model in the feature model, traceability of roles, features and base components, and an instantiation problem were discussed. 6 Related work This Section provides an overview of related work and their relationship with this paper. Separation of concerns, features, role modelling, and software product families and software architecture are the four areas of interest of which related work is examined. 6.1 Separation of concerns Separation of concerns is the appliance of the divide-and-conquer paradigm on software design. By separating different concerns in separated entities the design becomes easier, but the ‘gluing’ of the pieces becomes harder. Subject orientated programming (SOP) [16] uses the concept of different views on an entity. Each view has its own object hierarchy. Composition rules define how the different object hierarchies can be combined into a single unified object hierarchy. Our approach differs in the focus, which is on the collaboration aspect of feature related variability and not on functional hierarchical differences. Aspect oriented programming (AOP) [13] uses the concept of aspects to capture functionality that is crosscut in normal object decomposition. So-called join points provide hooks to merge aspects with the objects. One of the implementations of AOP is AspectJ [14]; here the join points are the method activations. A conceptual model stating what aspects are is missing in AOP. The presented feature model in this paper can be used as a conceptual model for aspects, with the aspects implementing the composition of our feature model. Multi-dimensional separation of concerns [17], as implemented in the HyperJ [18] approach, models different concerns in independent individual dimensions. Rules defining the relationships between the independent entities of the dimensions guide the necessary composition process for system generation. Our feature model can be viewed as a two-dimensional instance of a multidimensional separation of concerns model. The first dimension is the concern of the base components, the second the feature related variability dimension. The resulting matrix of actors is very similar to a composition expression in hyperslice programming. However, our model is different as it explicitly distinguishes features, and adds additional semantics (interface, roles) and notation (see Fig. 3). The feature model is not restricted to only these two dimensions of separation of concerns, because no restrictions on the dimensionality of the base components or features are defined. The composition problem found in this paper (see Section 4) is universal for multi-dimensional separation of concerns, because each concern model will only describe a part of the behaviour of an entity. However, each concern model needs to overlap/relate to other concern models, otherwise a composed view of an entity is not possible. Multi-dimensional separation of concern therefore has the inherent problem that an operation of an entity could have multiple behaviours that should be combined, resulting in a composition problem. 6.2 Features A more global view of how features can bridge the gap between the problem and solution domain is presented in [9]. In their view features are composed out of requirements fragments and realised in one or more design fragments, which make up the complete design. In this perspective, features can be seen as an example of early aspects [6] – a crosscutting concern during the requirement engineering and architecture design phase. This paper presents a more detailed description of how the design fragments, i.e. aspects, making up the feature can be modelled and composed for making the complete design. Our approach is not unique in trying to model features in the solution domain. The feature-oriented domain analysis (FODA) [3] method is a method for identifying features during domain analysis. FODA uses the representation of feature trees to visualise the variability and dependencies of features. Later, the feature-oriented reuse method (FORM) [4], which is a superset of FODA, was developed to prescribe how the FODA feature model could be used to develop domain architectures and components for reuse. The main difference between our approach and FORM is the traceability of features at the design and implementation level, which is not the case with FORM. This traceability is lost during the FORM application-engineering phase. Prehofer [19, 20], uses feature oriented programming (FOP) to compose features into objects. FOP is an extension of the object-oriented programming paradigm. It uses separate entities called lifters to model feature interaction and separates core functionality from feature functionality. Our approach differs in two ways: the first is that a first class entity (the actor) for the composed behaviour is present, enabling the definition of a feature based on the composed behaviour of two other features. The second difference is that a feature is not one static class but consists of different roles being mapped onto different domain components. Zave [10] discusses a distributed feature composition technique (DFC) for telecommunication services. She uses a pipe & filter style architecture, with the features being components, switches and routers connecting the components with connectors to form a chain of components through which data can move. Components can be added and removed by the switch, thereby changing the current feature set. The main difference with our approach is the fact that we do not require a particular architectural style to be used and features do not have to be contained in a single component. The relationship between features and SPFs is also mentioned in [5], which proposes a feature-driven aspect-oriented product-line CBSE. The main idea is to use a feature-driven analysis and design method like FeaturESEB [21] to develop a feature model. One or more aspect-orientated implementation techniques [22] can then be used to implement features in separate code fragments, which in turn can be composed based on the selected features for a given composition. The global idea is the same as the approach in this paper; however, the focus of this paper is more on the composition of features, whereas [5] is more a global modelling view. 6.3 Role modelling The idea of role modelling has also been studied by other authors. The OOram method [23] uses role models based on collaborations of different roles. Two or more role models can be synthesised to form a new and more complex role model. The general role modelling ideas presented in OOram are used at various abstraction levels. The main difference with our approach is in the synthesis or composition of two role models. In OOram this is only done at a structural level; that is, only the structural requirements are validated – compositional problems have to be solved by the developer him/herself. Role models can also be integrated into object-oriented frameworks [24]. The main focus of the role model used in this approach is on the interface part. The notation proposed in [24] could be used to denote the relationships between the roles of the features in our model. The main difference is that a coupling between an interface and an implementation of a role is not made in their model – something that our feature model does. The composition problem we have identified is therefore not relevant in their approach, because the composition problem finds its roots in a coupling between an interface and an implementation. Fowler [25] defines design patterns that can be used to implement roles in an object-oriented language. The main concept of the patterns is that the objects are dealing with a single object that has multiple changeable types. An object is therefore aware of the multiple typing of the other objects and has to act on this, which in the feature model does not have to be the case, because we want to be able to develop unrelated features independently. The use of mixins [26] – abstract subclasses representing a mechanism for specifying classes that will eventually inherit form a super class – is another approach to compose collaborations. The difference with our approach lies in the mapping of the roles of the collaborations to the objects. These can only be mapped to a single domain object, and multiple roles cannot be mapped to the same domain object – something our feature model can. 6.4 Software product families and software architecture The software product family (SPF) [1] is an approach to develop software, not on an application base but on the basis of a family of related applications. The commonalities between the individual products (applications) can be used to create so-called common assets, which are reusable components that can be customised for the individual products. The field of variability management [27] of SPFs mainly concerns how the differences between the products can be managed. This paper presents a method about how the common assets can be customised for a specific product based on a selection of features and is therefore a form of variability management. In the context of SPF, [28] also use features to customise the common assets to derive a product based on a selection of features. They use packages as features and the merging of source trees to accomplish feature composition. The merging of the source trees takes place at so-called variation points. A variation point in their approach is a simple switch statement, defining the different variations on the code level. A problem with this approach is the definition of the variation points. The variation points have to be programmed out manually in the form of switches, and this mixes the feature related code with the common asset code. This reduces the traceability and the reuse capabilities of the feature related code, because of the lack of first class representation, which is present in our approach. The software architecture (SA) [29] of each derived product is a variant of the SPF architecture. The feature model incorporates the components of the SPF architecture through the use of the base components. The feature model can therefore modify the architecture of a product by adapting the existing base components by mapping new roles of features on it and introducing new connectors and components resulting from features. 7 Conclusions and future work In this paper, we have investigated the potential of using the early aspect of features in the solution domain of software product families (SPFs). Our main focus was on the design and implementation level. Starting at the design level a feature model was presented, modelling features. The model showed how features could be modelled as a collection of roles, thereby relating for the first time a feature model to a role model. The roles in turn can be played by different basecomponents, resulting in actors. At the implementation level a way to implement the model is outlined. The model and the outlined implementation strategy are illustrated and validated with a prototype implementation. With the help of a formalised version of the model a compositional problem is identified. The composition of two roles in an actor becomes problematic when both roles have different implementations for the same method. To solve the composition problem there are three potential solutions: skipping, concatenation and mixing. One or more of the three solution forms can be used to solve composition problems. By predefining how the composition is done and which composition solution to use in the case of a composition problem, we can keep the composition of our feature model complete, consistent, deterministic and implementable. This facilitates the automatic derivation of products in an SPF based on a selection of features. Remaining open issues that we intend to address in future work are: - **Automatic composition support**: An open issue of the prototype is the absence of a compiler that supports the composition process. At the moment the necessary composition steps still have to be done manually, which makes the application of the composition process a very time-consuming and error-prone one. However, we have already defined an algorithm for the composition process, which can easily be programmed out, automating the composition process. - **Scalability of the feature model**: Scalability of the feature composition model is one of the main aspects that demand additional validation. Although the feature composition model was designed for use in SPFs, it has not yet been demonstrated whether the model can be scaled up to this level of scale. - **Lack of a dependency model**: The feature model does not include a dependency model. The combinations of features that are possible for product derivation are directly related to the feature and roles dependencies. So, it is important to extend the feature model with a dependency model. The first steps have already been taken in Section 5.2, where four dependency relation types are already identified. - **Validation of the feature model**: A correct and complete validation of the feature model is difficult to accomplish. Cases can be used to validate the feature model, as does the video-shop case in this paper, for example. These open issues form the basis for further work. We would like to investigate how automatic composition support can help with the scalability of the feature model. For decent automatic composition support the feature model should be extended to include a dependency model. Additional research is planned with an additional case helping us to investigate the scalability of the feature model and providing additional validation of our approach. 8 References 7 Gibson, P.: ‘Feature requirements models: understanding interactions’. Presented at IEEE 4th Int. Workshop on Feature Interactions in Networks and Distributed Systems (FIW), Montreal, Canada, June 1997 16 Harrison, W., and Ossher, H.: ‘Subject-oriented programming a critique of pure objects’. Proc. 1993 Conf. on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA), Washington, DC, 26 September – 1 October 1993, pp. 411–428 23 Reenskaug, T.: ‘Working with objects - The OOram software engineering method’ (Manning, Greenwich, CT, 1996)
{"Source-Url": "https://pure.rug.nl/ws/portalfiles/portal/2948067/2004IEEProcSoftwJansen.pdf", "len_cl100k_base": 10544, "olmocr-version": "0.1.53", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 37621, "total-output-tokens": 12655, "length": "2e13", "weborganizer": {"__label__adult": 0.0002715587615966797, "__label__art_design": 0.00031638145446777344, "__label__crime_law": 0.00022614002227783203, "__label__education_jobs": 0.0004911422729492188, "__label__entertainment": 4.0471553802490234e-05, "__label__fashion_beauty": 0.00010842084884643556, "__label__finance_business": 0.0001323223114013672, "__label__food_dining": 0.0002276897430419922, "__label__games": 0.0003979206085205078, "__label__hardware": 0.0004239082336425781, "__label__health": 0.00019633769989013672, "__label__history": 0.00015401840209960938, "__label__home_hobbies": 4.881620407104492e-05, "__label__industrial": 0.00020456314086914065, "__label__literature": 0.00016748905181884766, "__label__politics": 0.00017178058624267578, "__label__religion": 0.0002810955047607422, "__label__science_tech": 0.002685546875, "__label__social_life": 4.982948303222656e-05, "__label__software": 0.004291534423828125, "__label__software_dev": 0.98828125, "__label__sports_fitness": 0.00019407272338867188, "__label__transportation": 0.0002810955047607422, "__label__travel": 0.00014495849609375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 57290, 0.02179]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 57290, 0.31884]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 57290, 0.92829]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 5193, false], [5193, 10926, null], [10926, 14512, null], [14512, 17356, null], [17356, 23072, null], [23072, 29424, null], [29424, 36163, null], [36163, 38892, null], [38892, 46061, null], [46061, 53400, null], [53400, 57290, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 5193, true], [5193, 10926, null], [10926, 14512, null], [14512, 17356, null], [17356, 23072, null], [23072, 29424, null], [29424, 36163, null], [36163, 38892, null], [38892, 46061, null], [46061, 53400, null], [53400, 57290, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 57290, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 57290, null]], "pdf_page_numbers": [[0, 0, 1], [0, 5193, 2], [5193, 10926, 3], [10926, 14512, 4], [14512, 17356, 5], [17356, 23072, 6], [23072, 29424, 7], [29424, 36163, 8], [36163, 38892, 9], [38892, 46061, 10], [46061, 53400, 11], [53400, 57290, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 57290, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
ad7873786e260319d28025f38d4b7e59e68f88ef
hMETIS* A Hypergraph Partitioning Package Version 1.5.3 George Karypis and Vipin Kumar University of Minnesota, Department of Computer Science & Engineering Army HPC Research Center Minneapolis, MN 55455 {karypis, kumar}@cs.umn.edu November 22, 1998 Metis [MEE tis]: Metis was a titaness in Greek mythology. She was the consort of Zeus and the mother of Athena. She presided over all wisdom and knowledge. Contents 1 Introduction .......................................................... 3 2 What is \texttt{hMetis} .................................................. 3 2.1 Overview of the Algorithms used in \texttt{hMetis} ...................... 4 3 \texttt{hMetis}'s Stand-Alone Programs ............................ 4 3.1 \texttt{shmetis} .......................................................... 5 3.2 \texttt{hmetis} .......................................................... 7 3.3 \texttt{khmetis} ........................................................ 8 3.4 Format of Hypergraph Input File ................................. 10 3.5 Format of the Fix File ............................................ 11 3.6 Format of Output File ............................................. 11 4 \texttt{hMetis}'s Library Interface .................................. 11 4.1 \texttt{HMETIS$\_PartRecursive} .................................... 11 4.2 \texttt{HMETIS$\_PartKway} ........................................ 14 5 General Guidelines on How to Use \texttt{hMetis} ..................... 15 5.1 Selecting the Proper Parameters .................................. 15 5.1.1 Effect of the CType Parameter .............................. 15 5.1.2 Effect of the RType Parameter .............................. 16 5.2 Computing a k-way Partitioning ................................ 16 5.2.1 Effect of the Nruns Parameter ............................. 16 5.2.2 Effect of the Reconst Parameter ......................... 18 6 System Requirements and Contact Information ..................... 19 1 Introduction Hypergraph partitioning is an important problem and has extensive applications in many areas, including VLSI design [2], efficient storage of large databases on disks [13], transportation management, and data-mining [5]. The problem is to partition the vertices of a hypergraph in \( k \) roughly equal parts, such that the number of hyperedges connecting vertices in different parts is minimized. A hypergraph is a generalization of a graph, where the set of edges is replaced by a set of hyperedges. A hyperedge extends the notion of an edge by allowing more than two vertices to be connected by a hyperedge. 2 What is \textsc{hMetis} \textsc{hMetis} is a software package for partitioning large hypergraphs, especially those arising in circuit design. The algorithms in \textsc{hMetis} are based on multilevel hypergraph partitioning described in [10, 11, 7], and they are an extension of the widely used \textsc{Metis} graph partitioning package described in [9, 8]. Traditional graph partitioning algorithms compute a partition of a graph by operating directly on the original graph as illustrated in Figure 1(a). These algorithms are often too slow and/or produce poor quality partitions. Multilevel partitioning algorithms, on the other hand, take a completely different approach[6, 9, 8, 10]. These algorithms, as illustrated in Figure 1(b), reduce the size of the graph (or hypergraph) by collapsing vertices and edges (during the coarsening phase), partition the smaller graph (initial partitioning phase), and then uncoarsen it to construct a partition for the original graph (uncoarsening and refinement phase). \textsc{hMetis} uses novel approaches to successively reduce the size of the hypergraph as well as to further refine the partition during the uncoarsening phase. During coarsening, \textsc{hMetis} employs algorithms that make it easier to find a high-quality partition at the coarsest graph. During refinement, \textsc{hMetis} focuses primarily on the portion of the graph that is close to the partition boundary. These highly tuned algorithms allow \textsc{hMetis} to quickly produce high-quality partitions for a large variety of hypergraphs. ![Figure 1](image.png) Figure 1: (a) Traditional partitioning algorithms. (b) Multilevel partitioning algorithms. The advantages of \textsc{hMetis} compared to other similar algorithms are the following: - **Provides high quality partitions!** Experiments on a large number of hypergraphs arising in various domains including VLSI, databases, and data mining show that \textsc{hMetis} produces partitions that are consistently better than those produced by other widely used algorithms, such as KL, FM, LA, PROP, CLIP, etc.. - **It is extremely fast!** Experiments on a wide range of hypergraphs has shown that \textsc{hMetis} is one to two orders of magnitude faster than other widely used partitioning algorithms. \textsc{hMetis} can produce extremely high quality bisections of hypergraphs with 100,000 vertices in well under 3 minutes on an R10000-based SGI workstation and a Pentium Pro-based personal computer. 2.1 Overview of the Algorithms used in hMETIS In the rest of this section, we briefly describe the various phases of the multilevel algorithm. The reader should refer to [10] for further details. Coarsening Phase During the hypergraph coarsening phase, a sequence of successively smaller hypergraphs is constructed. The purpose of coarsening is to create a small hypergraph, such that a good bisection of the small hypergraph is not significantly worse than the bisection directly obtained for the original hypergraph. In addition to that, hypergraph coarsening also helps in successively reducing the size of the hyperedges. That is, after several levels of coarsening, large hyperedges are contracted to hyperedges connecting just a few vertices. This is particularly helpful, since refinement heuristics based on the Kernighan-Lin algorithm [12, 4] are very effective in refining small hyperedges but are quite ineffective in refining hyperedges with a large number of vertices belonging to different partitions. The group of vertices that are contracted together to form single vertices in the next level coarse hypergraph can be selected in different ways. hMETIS implements various such grouping schemes (also called matching schemes) some of which are described in [10]. Initial Partitioning Phase During the initial partitioning phase, a bisection of the coarsened hypergraph is computed. Since this hypergraph has a very small number of vertices (usually less than 100 vertices) many different algorithms can be used without significantly affecting the overall runtime and quality of the algorithm. hMETIS uses multiple random bisections followed by the Fiduccia-Mattheyses(FM) refinement algorithm. Uncoarsening and refinement phase During the uncoarsening phase, the partitioning of the coarsest hypergraph is used to obtain a partitioning for the finer hypergraph. This is done by successively projecting the partitioning to the next level finer hypergraph and using a partitioning refinement algorithm to reduce the cut and thus improve the quality of the partitioning. Since the next level finer hypergraph has more degrees of freedom, such refinement algorithms tend to improve the quality. hMETIS implements a variety of algorithms that are based on the FM algorithm [4]. The details of some of these schemes can be found in [10]. V-Cycle Refinement The idea behind this refinement algorithm is to use the power of the multilevel paradigm to further improve the quality of a bisection. The V-cycle refinement algorithm consists of two phases, namely a coarsening and an uncoarsening phase. The coarsening phase preserves the initial partitioning that is input to the algorithm. We will refer to this as restricted coarsening scheme. In this restricted coarsening scheme, the groups of vertices that are combined to form the vertices of the coarse graphs correspond to vertices that belong only to one of the two partitions. As a result, the original bisection is preserved through out the coarsening process, and becomes the initial partition from which we start performing refinement during the uncoarsening phase. The uncoarsening phase of the V-cycle refinement algorithm is identical to the uncoarsening phase of the multilevel hypergraph partitioning algorithm described earlier. It moves vertices between partitions as long as such moves improve the quality of the bisection. Note that the various coarse representations of the original hypergraph, allow refinement to further improve the quality as it helps it climb out of local minima. 3 hMETIS’s Stand-Alone Programs hMETIS provides the shmetis, hmetis, and khmetis programs that can be used to partition a hypergraph into k parts. The first two programs (shmetis and hmetis) compute a k-way partitioning using multilevel recursive bisection [10]. The shmetis program is suited for those users who want to use hMETIS without getting into the details of the underlying algorithms, while hmetis is suited for those users that want to experiment with the various algorithms used by hMETIS. Both shmetis and hmetis can also compute a k-way partitioning when certain vertices of the hypergraph have pre-assigned partitions (i.e., there are at most k sets of vertices each fixed to a particular partition). The third program (khmetis) computes a k-way partitioning using multilevel k-way partitioning [8]. This is a new feature of hMETIS 1.5, and the underlying algorithms are still under development. 3.1 shmetis The shmetis program is invoked by providing three or four arguments at the command line as follows: ``` shmetis HGraphFile Nparts UBfactor ``` or ``` shmetis HGraphFile FixFile Nparts UBfactor ``` The meaning of the various parameters is as follows: **HGraphFile** This is the name of the file that stores the hypergraph (the format is described in Section 3.4). **FixFile** This is the name of the file that stores information about the pre-assignment of vertices to partitions (the format is described in Section 3.5). **Nparts** This is the number of desired partitions. shmetis can partition a hypergraph into an arbitrary number of partitions, using recursive bisection. That is, for a 4-way partition, shmetis first computes a 2-way partition of the original hypergraph, then constructs two smaller hypergraphs, each corresponding to one of the two partitions, and then computes 2-way partitions of these smaller hypergraphs to obtain the desired 4-way partition. Note that shmetis, while constructing the smaller hypergraphs, completely removes the hyperedges that were cut during the bisection. **UBfactor** This parameter is used to specify the allowed imbalance between the partitions during recursive bisection. This is an integer number between 1 and 49, and specifies the allowed load imbalance in the following way. Consider a hypergraph with \( n \) vertices, each having a unit weight, and let \( b \) be the UBfactor. Then, if the number of desired partitions is two (i.e., we perform a bisection), then the number of vertices assigned to each one of the two partitions will be between \((50 - b)n/100\) and \((50 + b)n/100\). For example, for \( b = 5 \), then we will be allowing a 45-55 bisection, that is, the number of vertices in each partition will be between 0.45\( n \) and 0.55\( n \). Note that this allowed imbalance is applied at each bisection step, so if instead of a 2-way partition we are interested in a 4-way partition, then a UBfactor of 5 will result in partitions that can contain between 0.45\(^2\)\( n \) = 0.20\( n \) and 0.55\(^2\)\( n \) = 0.30\( n \) vertices. Also note that shmetis does not allow you to produce perfectly balanced partitions. This is a limitation that will be lifted in future releases. Upon successful execution, shmetis displays statistics regarding the quality of the computed partitioning and the amount of time taken to perform the partitioning (the times are shown in seconds). The actual partitioning is stored in a file named `HGraphFile.part.Nparts`, whose format is described in Section 3.6. Figure 2 shows the output of shmetis for partitioning a hypergraph into four parts. From this figure we see that shmetis initially prints information about the hypergraph, such as its name, the number of vertices (#Vtxs), the number of hyperedges (#Hedges), and also the number of desired partitions (#Parts) and allowed imbalance (UBfactor). Next, prints information about the different bisections that were computed. In this example, since we asked for four partitions, the algorithm computes a total of three bisections, and for each one prints information regarding the size of the hypergraph that is bisected and the quality of the computed bisections. In particular, with respect to quality, it prints the minimum and average number of cuts, and also the balance corresponding to the minimum cut. The overall quality of the obtained partitioning is summarized by computing the following quality measures (in the case of hypergraphs with weighted hyperedges, these definitions are extended in a straight-forward manner): 1. **Hyperedge Cut** This is the number of the hyperedges that span multiple partitions. The partitioning routines in hMetis try to directly minimize this quantity. --- \(^1\)shmetis can handle non-power of 2 partitions, by performing unbalanced bisections. That is, for a 3-way partition it computes a 2-way partition such that the first part has 2/3 of the total number of vertices, and the other part has 1/3. It then it bisects the first part into two equal-size parts, each containing 1/3 of the original number of vertices. \(^2\)The hmetis program allows you to change this behavior. 2. **Sum of External Degrees** The external degree $|E(P_i)|$ of a partition $P_i$ is defined as the number of hyperedges that are incident but not fully inside this partition. The sum of the external degrees of a $k$-way partitioning is then $\sum_{i=1}^{k} |E(P_i)|$. 3. **Scaled Cost** This is defined as \[ \frac{1}{n(k-1)} \sum_{i=1}^{k} \frac{|E(P_i)|}{w(P_i)}, \] where $w(P_i)$ is the sum of the vertex weights of partition $P_i$ (note that if the vertices do not have weights, then $w(P_i) = |P_i|$). 4. **Absorption** This is defined as \[ \sum_{i=1}^{k} \sum_{e \in E} \frac{|e \cap P_i| - 1}{|e| - 1} \] where $E$ is the set of hyperedges, $|e \cap P_i|$ is the number of vertices of hyperedge $e$ that are also in partition $P_i$, and $|e|$ is the number of vertices in the hyperedge $e$. Following these quality measures, `shmetis` prints the size of the various partitions as well as the external degrees of each partition. Finally, it shows the time taken by the various phases of the algorithm. All times are in seconds. ``` prompt% shmetis ibm02.hgr 4 5 ******************************************************************************* HMETIS 1.5.3 Copyright 1998, Regents of the University of Minnesota HyperGraph Information ----------------------------------------------- Name: ibm02.hgr, #Vtxs: 19601, #Hedges: 19584, #Parts: 4, UBfactor: 0.05 Options: HFC, FM, Reconst-False, V-cycles @ End, No Fixed Vertices Recursive Partitioning... -------------------------------------------- Bisecting a hgraph of size [vertices=19601, hedges=19584, balance=0.50] The mincut for this bisection = 262, (average = 277.8) (balance = 0.46) Bisecting a hgraph of size [vertices=9028, hedges=8501, balance=0.50] The mincut for this bisection = 186, (average = 241.4) (balance = 0.49) Bisecting a hgraph of size [vertices=10573, hedges=10821, balance=0.50] The mincut for this bisection = 192, (average = 193.5) (balance = 0.47) Summary for the 4-way partition: Hyperedge Cut: 619 (minimize) Sum of External Degrees: 1305 (minimize) Scaled Cost: 4.56e-06 (minimize) Absorption: 19336.20 (maximize) Partition Sizes & External Degrees: Timing Information ----------------------------------------------- Partitioning Time: 73.340sec I/O Time: 0.230sec ******************************************************************************* ``` **Figure 2**: Output of `shmetis` for `ibm02.hgr` and a 4-way partition 3.2 hmetis The program hmetis is invoked by providing 9 or 10 command line arguments as follows: ``` hmetis HGraphFile Nparts UBfactor Nruns CType RType Vcycle Reconst dbgvl ``` or ``` hmetis HGraphFile FixFile Nparts UBfactor Nruns CType RType Vcycle Reconst dbgvl ``` The meaning of the various parameters is as follows: **HGraphFile, FixFile, Nparts, UBfactor** The meaning of these parameters is identical to those of shmetis. **Nruns** This is the number of the different bisections that are performed by hmetis. It is a number greater or equal to one, and instructs hmetis to compute Nruns different bisections, and select the best as the final solution. A default value of 10 is used by shmetis. Section 5.2.1 provides an experimental evaluation of the effect of Nruns in the quality of k-way partitionings. **CType** This is the type of vertex grouping scheme (i.e., matching scheme) to use during the coarsening phase. It is an integer parameter and the possible values are: 1. Selects the hybrid first-choice scheme (HFC). This scheme is a combination of the first-choice and greedy first-choice scheme described later. This is the scheme used by shmetis. 2. Selects the first-choice scheme (FC). In this scheme vertices are grouped together if they are present in multiple hyperedges. Groups of vertices of arbitrary size are allowed to be collapsed together. 3. Selects the greedy first-choice scheme (GFC). In this scheme vertices are grouped based on the first-choice scheme, but the grouping is biased in favor of faster reduction in the number of the hyperedges that remain in the coarse hypergraphs. 4. Selects the hyperedge scheme. In this scheme vertices are grouped together that correspond to entire hyperedges. Preference is given to hyperedges that have large weight. 5. Selects the edge scheme. In this scheme pairs of vertices are grouped together if they are connected by multiple hyperedges. You may have to experiment with this parameter to see which scheme works better for the classes of hypergraphs that you are using. Section 5.1.1 provides an experimental evaluation of the various values of CType for a range of hypergraphs. **RType** This is the type of refinement policy to use during the uncoarsening phase. It is an integer parameter and the possible values are: 1. Selects the Fiduccia-Mattheyses (FM) refinement scheme. This is the scheme used by shmetis. 2. Selects the one-way Fiduccia-Mattheyses refinement scheme. In this scheme, during each iteration of the FM algorithm, vertices are allowed to move only in a single direction. 3. Selects the early-exit FM refinement scheme. In this scheme, the FM iteration is aborted if the quality of the solution does not improve after a relatively small number of vertex moves. Experiments have shown that FM and one-way FM produce better results than early-exit FM. However, early-exit FM is considerably faster, and the overall quality is not significantly worse. Section 5.1.2 provides an experimental evaluation of the various values of RType for a range of hypergraphs. **Vcycle** This parameter selects the type of V-cycle refinement to be used by the algorithm. It is an integer parameter and the possible values are: 0 Does not perform any form of $V$-cycle refinement. 1 Performs $V$-cycle refinement on the final solution of each bisection step. That is, only the best of the $N_{runs}$ bisections are refined using $V$-cycles. This is the options used by *shmetis*. 2 Performs $V$-cycle refinement on each intermediate solution whose quality is equally good or better than the best found so far. That is, as *hmetis* computes $N_{runs}$ bisections, for each bisection that matches or improves the best one, it is also further refined using $V$-cycles. 3 Performs $V$-cycle refinement on each intermediate solution. That is, each one of the $N_{runs}$ bisections is also refined using $V$-cycles. Experiments have shown that the second and third choices offer the best time/quality tradeoffs. If time is not an issue, the fourth choice (i.e., $V_{cycle} = 3$) should be used. **Reconst** This parameter is used to select the scheme to be used in dealing with hyperedges that are being cut during the recursive bisection. It is an integer parameter and the possible values are: 0 This scheme removes any hyperedges that were cut while constructing the two smaller hypergraphs in the recursive bisection step. In other words, once a hyperedge is being cut, it is removed from further consideration. Essentially this scheme focuses on minimizing the number of hyperedges that are being cut. This is the scheme that is used by *shmetis*. 1 This scheme reconstructs the hyperedges that are being cut, so that each of the two partitions retain the portion of the hyperedge that corresponds to its set of vertices. Section 5.2.2 provides an experimental evaluation of the effect of Reconst in the quality of $k$-way partitionings. **dbglvl** This is used to request *hMETIS* to print debugging information. The value of $dbglvl$ is computed as the sum of codes associated with each option of *hmetis*. The various options and their values are as follows: 0 Show no additional information. 1 Show information about the coarsening phase. 2 Show information about the initial partitioning phase. 4 Show information about the refinement phase. 8 Show information about the multiple runs. 16 Show additional information about the multiple runs. For example, if we want to see all information about the multiple runs the value of $dbglvl$ should be $8 + 16 = 24$. Note that some of the options may generate a lot of output. Use them with caution. Upon successful execution, *hmetis* displays statistics regarding the quality of the computed partitioning and the amount of time taken to perform the partitioning. The actual partitioning is stored in a file named *HGraph-File.part.Nparts*, whose format is described in Section 3.6. Figure 3 shows the output of *hmetis* for a 2-way partition. ### 3.3 khmetis The *khmetis* program is invoked by providing 7 command line arguments as follows: ``` khmetis HGraphFile Nparts UBfactor Nruns CType OType Vcycle dbglvl ``` The meaning of the various parameters is as follows: **HGraphFile, Nparts, Nruns, CType, Vcycle, dbglvl** The meaning of these parameters is identical to those of *hmetis*. prompt% hmetis ibm03.hgr 2 5 10 1 1 3 0 24 ******************************************************************************* HMETIS 1.5.3 Copyright 1998, Regents of the University of Minnesota HyperGraph Information Name: ibm03.hgr, #Vtxs: 23136, #Hedges: 27401, #Parts: 2, UBfactor: 0.05 Options: HFC, FM, Reconst-False, Always V-cycle, No Fixed Vertices Recursive Partitioning... Bisecting a hgraph of size [vertices=23136, hedges=27401, balance=0.50] Cut of trial 0: 979 [0.50] Cut of trial 1: 957 [0.46] Cut of trial 2: 979 [0.50] Cut of trial 3: 982 [0.48] Cut of trial 4: 1010 [0.47] Cut of trial 5: 956 [0.46] Cut of trial 6: 990 [0.50] Cut of trial 7: 957 [0.46] Cut of trial 8: 1142 [0.48] Cut of trial 9: 956 [0.46] The mincut for this bisection = 956, (average = 990.8) (balance = 0.46) -------------------------------------------------------------------------- Summary for the 2-way partition: Hyperedge Cut: 956 (minimize) Sum of External Degrees: 1912 (minimize) Scaled Cost: 7.18e-06 (minimize) Absorption: 27029.76 (maximize) Partition Sizes & External Degrees: 12419[ 956] 10717[ 956] Timing Information Partitioning Time: 85.190sec I/O Time: 0.280sec ******************************************************************************* Figure 3: Output of hmetis for ibm03.hgr and a 2-way partition UBfactor This parameter is used to specify the allowed imbalance between the k partitions. This is an integer greater than 5 and specifies the allowed load imbalance as follows. A value of b for UBfactor indicates that the weight of the heaviest partition should not be more than b% greater than the average weight. For example, for b = 8, k = 5, and a hypergraph with n vertices (each having unit vertex weight), the weight of the heaviest partition will be bounded from above by 1.08 * n/5. Note that this specification of the allowed imbalance between the k partitions is different from the specification used by either shmetis or hmetis. OType This determines which objective function the refinement algorithm tries to minimize. It is an integer parameter and the possible values are: 1 Minimizes the hyperedge cut. 2 Minimizes the sum of external degrees (SOED). This feature was introduced with version 1.5.3. Upon successful execution, hmetis displays statistics regarding the quality of the computed partitioning and the amount of time taken to perform the partitioning. The actual partitioning is stored in a file named HGraph-File.part.Nparts, whose format is described in Section 3.6. Figure 4 shows the output of khmetis for a 10-way partitioning. HMETIS 1.5.3 Copyright 1998, Regents of the University of Minnesota HyperGraph Information Name: ibm04.hgr, #Vtxs: 27507, #Hedges: 31970, #Parts: 10, UBfactor: 1.10 Options: HFC, Cut-minimization, V-cycle for Min K-way Partitioning... ----------------------------------------------- Partitioning a hgraph of size [vertices=27507, hedges=31970, balance=1.10] Cut/SOED of trial 0: 3259 7333 [1.10] Cut/SOED of trial 1: 3498 7946 [1.09] Cut/SOED of trial 2: 3397 7728 [1.10] Cut/SOED of trial 3: 3192 7242 [1.10] Cut/SOED of trial 4: 3277 7283 [1.10] Cut/SOED of trial 5: 3314 7555 [1.07] Cut/SOED of trial 6: 3390 7554 [1.10] Cut/SOED of trial 7: 3414 7723 [1.06] Cut/SOED of trial 8: 3307 7357 [1.10] Cut/SOED of trial 9: 3322 7433 [1.10] The mincut for this partitioning = 3192, (average = 3337.0) (balance = 1.10) Summary for the 10-way partition: Hyperedge Cut: 3192 (minimize) Sum of External Degrees: 7242 (minimize) Scaled Cost: 1.06e-05 (minimize) Absorption: 30250.46 (maximize) Partition Sizes & External Degrees: Timing Information Partitioning Time: 136.720sec I/O Time: 0.310sec Figure 4: Output of khmetis for ibm04.hgr and a 10-way partition Note that khmetis should never be used to compute a bisection (i.e., 2-way partitioning) as it produces worse results than hmetis. Furthermore, the quality of the partitionings produced by khmetis for small values of \( k \) will be worse, in general, than the corresponding partitionings computed by hmetis. However, khmetis is particularly useful for computing \( k \)-way partitionings for relatively large values of \( k \), as it often produces better partitionings and it can also enforce tighter balancing constraints. ### 3.4 Format of Hypergraph Input File The primary input of HMETIS is the hypergraph to be partitioned. This hypergraph is stored in a file and is supplied to HMETIS as one of the command line parameters. A hypergraph \( H = (V, E^h) \) with \( V \) vertices and \( E^h \) hyperedges is stored in a plain text file that contains \( |E^h| + 1 \) lines, if there are no weights on the vertices and \( |E^h| + |V| + 1 \) lines if there are weights on the vertices. Any line that starts with ‘%’ is a comment line and is skipped. The first line contains either two or three integers. The first integer is the number of hyperedges (\( |E^h| \)), the second is the number of vertices (\( |V| \)), and the third integer (\( fmt \)) contains information about the type of the hypergraph. In particular, depending on the value of \( fmt \), the hypergraph \( H \) can have weights on either the hyperedges, the vertices, or both. In the case that \( H \) is unweighted (i.e., all the hyperedges and vertices have the same weight), \( fmt \) is omitted. After this first line, the remaining $|E_h|$ lines store the vertices contained in each hyperedge—one line per hyperedge. In particular, the $i$th line (excluding comment lines) contains the vertices that are included in the $(i-1)$th hyperedge. This format is illustrated in Figure 5(a). Weighted hyperedges are specified as shown in Figure 5(b). The first integer in each line contains the weight of the respective hyperedge. Note, hyperedge weights are integer quantities. Furthermore, note that the $fmt$ parameter is equal to 1, indicating the fact that $H$ has weights on the hyperedges. Finally, weights on the vertices are also allowed, as illustrated in Figure 5(c). In this case, $|V|$ lines are appended to the input file containing the weight of the $|V|$ vertices. Note that the value of $fmt$ is equal to 10. As was the case with hyperedge weights, vertex weights are integer quantities. Figure 5(d) shows the case when both the hyperedges and the vertices are weighted. $fmt$ in this case is equal to 11. Figure 5 shows the $HGraphFile$ expected by $\text{hMETIS}$ for the example hypergraphs shown in the figure. It shows the four cases in which the hypergraph is unweighted, has weighted hyperedges, has weighted vertices and has both hyperedges and vertices weighted. The hypergraph shown in Figure 5(a) has four unweighted hyperedges $a$, $b$, $c$, and $d$. Number of vertices in the hypergraph is 7. When the hypergraph is unweighted, first line of the $HGraphFile$ contains two integers denoting the number of hyperedges and the number of the vertices in the hypergraph. After that, each line corresponds to a hyperedge containing an entry for each vertex in the hyperedge. Hypergraph shown in Figure 5(b) has hyperedge weights equal to 2, 3, 7, and 8 on each of the hyperedge $a$, $b$, $c$, and $d$ respectively. For this weighted hyperedges first line of the $HGraphFile$ consists of three integers. Third integer specify that the hyperedges are weighted and is equal to 1. Each line corresponding to each hyperedge, has first entry equal to its weight. The following entries corresponds to the vertices in the respective hyperedge. The case when both the vertices are weighted $fmt$ is equal to 10, and 7 lines corresponding to the 7 vertices are appended to the input file each containing weight of the respective vertex. This is shown in Figure 5(c). Figure 5(d) shows the case when both the hyperedges and the vertices are weighted. 3.5 Format of the Fix File The $FixFile$ is used to specify the vertices that are pre-assigned to certain partitions. In general, when computing a $k$-way partitioning, up to $k$ sets of vertices can be specified, such that each set is pre-assigned to one of the $k$ partitions. For a hypergraph with $|V|$ vertices, the $FixFile$ consists of $|V|$ lines with a single number per line. The $i$th line of the file contains either the partition number to which the $i$th vertex is pre-assigned to, or -1 if that vertex can be assigned to any partition (i.e., free to move). Note that the partition numbers start from 0. 3.6 Format of Output File The output of $\text{hMETIS}$ is a partition file. The partition file of a hypergraph with $|V|$ vertices, consists of $|V|$ lines with a single number per line. The $i$th line of the file contains the partition number that the $i$th vertex belongs to. Partition numbers start from 0. If $\text{foo.graph}$ is the name of the file storing the hypergraph, the partition for a 2-way partition is stored in a file named $\text{foo.graph.part.2}$. 4 $\text{hMETIS}$’s Library Interface The hypergraph partitioning algorithms in $\text{hMETIS}$ can also be accessed directly using the stand-alone library libhmetis.a. This library provides the $\text{HMETIS_PartRecursive()}$ and $\text{HMETIS_PartKway()}$ routines. The first routine corresponds to the $\text{hmetis}$ whereas the second routine corresponds to the $\text{khmetis}$ program. The calling sequences and the description of the various parameters of these routines are as follows: 4.1 $\text{HMETIS_PartRecursive}$ $\text{HMETIS_PartRecursive}$ (int nvtxs, int nhedges, int *vwgts, int *eptr, int *eind, int *hewgts, int nparts, int ubfactor, int *options, int *part, int *edgecut) Figure 5: (a) $H_{\text{GraphFile}}$ for unweighted hypergraph, (b) $H_{\text{GraphFile}}$ for weighted hyperedges, (c) $H_{\text{GraphFile}}$ for weighted vertices, and (d) $H_{\text{GraphFile}}$ for weighted hyperedges and vertices. nvtxs, nhedges The number of vertices and the number of hyperedges in the hypergraph, respectively. vwgts An array of size nvtxs that stores the weight of the vertices. Specifically, the weight of vertex \( i \) is stored at \( vwgts[i] \). If the vertices in the hypergraph are unweighted, then \( vwgts \) can be NULL. eptr, eind Two arrays that are used to describe the hyperedges in the graph. The first array, \( eptr \), is of size \( nhedges+1 \), and it is used to index the second array \( eind \) that stores the actual hyperedges. Each hyperedge is stored as a sequence of the vertices that it spans, in consecutive locations in \( eind \). Specifically, the \( i \)th hyperedge is stored starting at location \( eind[eptr[i]] \) up to (but not including) \( eind[eptr[i+1]] \). Figure 6 illustrates this format for a simple hypergraph. The size of the array \( eind \) depends on the number and type of hyperedges. Also note that the numbering of vertices starts from 0. hewgts An array of size \( nhedges \) that stores the weight of the hyperedges. The weight of the \( i \) hyperedge is stored at location \( hewgts[i] \). If the hyperedges in the hypergraph are unweighted, then \( hewgts \) can be NULL. nparts The number of desired partitions. ubfactor This is the relative imbalance factor to be used at each bisection step. Its meaning is identical to the UBfactor parameter of shmetis, and hmetis described in Section 3. options This is an array of 9 integers that is used to pass parameters for the various phases of the algorithm. If \( options[0]=0 \) then default values are used. If \( options[0]=1 \), then the remaining elements of \( options \) are interpreted as follows: - \( options[1] \) Determines the number of different bisections that is computed at each bisection step of the algorithm. Its meaning is identical to the Nruns parameter of hmetis (described in Section 3.2). - \( options[2] \) Determines the scheme to be used for grouping vertices during the coarsening phase. Its meaning is identical to the CType parameter of hmetis (described in Section 3.2). - \( options[3] \) Determines the scheme to be used for refinement during the uncoarsening phase. Its meaning is identical to the RType parameter of hmetis (described in Section 3.2). - \( options[4] \) Determines the scheme to be used for \( V \)-cycle refinement. Its meaning is identical to the Vcycle parameter of hmetis (described in Section 3.2). - \( options[5] \) Determines the scheme to be used for reconstructing hyperedges during recursive bisections. Its meaning is identical to the Reconst parameter of hmetis (described in Section 3.2). - \( options[6] \) Determines whether or not there are sets of vertices that need to be pre-assigned to certain partitions. A value of 0 indicates that no pre-assignment is desired, whereas a value of 1 indicates that there are sets of vertices that need to be pre-assigned. In this later case, the parameter \( part \) is used to specify the partitions to which vertices are pre-assigned. In particular, \( part[i] \) will store the partition number that vertex \( i \) is pre-assigned to, and \(-1\) if it is free to move. - \( options[7] \) Determines the random seed to be used to initialize the random number generator of hMETIS. A negative value indicates that a randomly generated seed should be used (default behavior). - \( options[8] \) Determines the level of debugging information to be printed by hMETIS. Its meaning is identical to the dbglvl parameter of hmetis (described in Section 3.2). The default value is 0. part This is an array of size nvtxs that returns the computed partition. Specifically, \( part[i] \) contains the partition number in which vertex \( i \) belongs to. Note that partition numbers start from 0. Note that if \( options[6] = 1 \), then the initial values of \( part \) are used to specify the vertex pre-assignment requirements. Figure 6: The `eptr` and `eind` arrays that are used to describe the hyperedges of the hypergraph. **edgcut** This is an integer that returns the number of hyperedges that are being cut by the partitioning algorithm. ### 4.2 HMETIS_PartKway **HMETIS_PartKway** (int nvtxs, int nhedges, int *vwgts, int *eptr, int *eind, int *hewgts, int nparts, int ubfactor, int *options, int *part, int *edgecut) **nvtxs, nhedges, vwgt, eptr, eind, hewgts, nparts** The meaning of these parameters is identical to meaning of the corresponding parameters of HMETIS_PartRecursive. **ubfactor** This is the maximum load imbalance allowed in the $k$-way partitioning. Its meaning is identical to the `UBfactor` parameter of khmetis, Section 3.3. **options** This is an array of 9 integers that is used to pass parameters for the various phases of the algorithm. If `options[0]=0` then default values are used. If `options[0]=1`, then the remaining elements of `options` are interpreted as follows: - `options[1]` Determines the number of different $k$-way partitionings that is computed. Its meaning is identical to the `Nruns` parameter of khmetis (described in Section 3.3). - `options[2]` Determines the scheme to be used for grouping vertices during the coarsening phase. Its meaning is identical to the ` CType` parameter of khmetis (described in Section 3.3). - `options[3]` Determines which objective function the partitioning algorithm tries to minimize. Its meaning is identical to the `OType` parameter of khmetis (described in Section 3.3). The default value is 1 (i.e., minimize the hyperedge cut). - `options[4]` Determines the scheme to be used for $V$-cycle refinement. Its meaning is identical to the `Vcycle` parameter of khmetis (described in Section 3.3). - `options[7]` Determines the random seed to be used to initialize the random number generator of hMetis. A negative value indicates that a randomly generated seed should be used (default behavior). - `options[8]` Determines the level of debugging information to be printed by hMetis. Its meaning is identical to the `dbglvl` parameter of khmetis (described in Section 3.3). The default value is 0. **part** This is an array of size `nvtxs` that returns the computed partition. Specifically, `part[i]` contains the partition number in which vertex $i$ belongs to. Note that partition numbers start from 0. This is an integer that depending on the value of `options[3]` returns either the number of hyperedges that are being cut by the partitioning algorithm or the sum of the external degrees of the partitioning. ## 5 General Guidelines on How to Use hMETIS ### 5.1 Selecting the Proper Parameters The `hmetis` program allows you to control the multilevel hypergraph bisection paradigm by providing a variety of algorithms for performing the various phases. In particular, it allows you to control: 1. How the vertices are grouped together during the coarsening phase. This is done by using the `CType` parameter. 2. How the quality of the bisection is refinement during the uncoarsening phase. This is done by using the `RType` parameter. In designing the `shmetis` program, we had to make some choices for the above parameters. However, depending on the classes of the hypergraphs that are partitioned, these default settings may not necessarily be optimal. You should experiment with these parameters to see which schemes work better for your classes of problems. In this section, we present an experimental evaluation of the various choices for `CType` and `RType` for various hypergraphs taken from the circuits of the ACM/SIGDA [3] and ISPD98 [1] benchmarks. The characteristics of these circuits are shown in Table 1. We hope that these experiments will help in illustrating the various quality and/or runtime trade-offs that are present in the various choices. <table> <thead> <tr> <th>Circuit</th> <th>No. of Vertices (i.e., cells + pins)</th> <th>No. of Hyperedges (i.e., nets)</th> </tr> </thead> <tbody> <tr> <td>avqsmall</td> <td>21918</td> <td>22124</td> </tr> <tr> <td>avqlarge</td> <td>25178</td> <td>25384</td> </tr> <tr> <td>industry2</td> <td>12637</td> <td>13419</td> </tr> <tr> <td>industry3</td> <td>15406</td> <td>21923</td> </tr> <tr> <td>s35932</td> <td>18148</td> <td>17828</td> </tr> <tr> <td>s38417</td> <td>23949</td> <td>23843</td> </tr> <tr> <td>s38584</td> <td>20995</td> <td>20717</td> </tr> <tr> <td>golem3</td> <td>103048</td> <td>144949</td> </tr> <tr> <td>ibm01</td> <td>12752</td> <td>14111</td> </tr> <tr> <td>ibm03</td> <td>23156</td> <td>27401</td> </tr> <tr> <td>ibm05</td> <td>29347</td> <td>28446</td> </tr> <tr> <td>ibm07</td> <td>45926</td> <td>48117</td> </tr> <tr> <td>ibm09</td> <td>53395</td> <td>60902</td> </tr> <tr> <td>ibm11</td> <td>70558</td> <td>81454</td> </tr> <tr> <td>ibm13</td> <td>84199</td> <td>99666</td> </tr> <tr> <td>ibm15</td> <td>161570</td> <td>186608</td> </tr> <tr> <td>ibm17</td> <td>185495</td> <td>189581</td> </tr> </tbody> </table> **Table 1:** The characteristics of the various circuits used in the study of the various parameters of hMETIS. ### 5.1.1 Effect of the CType Parameter Table 2 shows the quality of the bisections produced by `hmetis` for different vertex grouping schemes. The experiments in this table were performed by setting the remaining parameters of `hmetis` as follows: `Nruns = 20`, `UBfactor = 5`, `RType = 1`, `Vcycle = 1`, and `Reconst = 0`. For each different vertex grouping scheme, the column labeled “Min” shows the minimum cut out of the 20 trials, the column labeled “Avg” shows the average cut over all 20 trials, and the column labeled “Time” shows the overall amount of time required by `hmetis` (i.e., the time to perform the 20 trials and the final V-cycle refinement). As we can see from this table, different vertex grouping schemes perform better for different circuits. In general, the `HFC` scheme (that is used by default in `shmetis`) performs reasonably well for all the circuits (i.e., it is within a few percentage points of the best scheme), but it is not necessarily the best. As this table suggests, one should experiment with the different vertex grouping schemes, to determine which one is suited for the classes of problems that she/he may have. 5.1.2 Effect of the RType Parameter Table 3 shows the quality of the bisections produced by \texttt{hmetis} for different refinement schemes. The experiments in this table were performed by setting the remaining parameters of \texttt{hmetis} as follows: \textit{Nruns} = 20, \textit{UBfactor} = 5, \textit{CTYPE} = 1, \textit{Vcycle} = 1, and \textit{Reconst} = 0. For each different refinement scheme, the column labeled “Min” shows the minimum cut out of the 20 trials, the column labeled “Avg” shows the average cut over all 20 trials, and the column labeled “Time” shows the overall amount of time required by \texttt{hmetis} (i.e., the time to perform the 20 trials and the final \textit{V}-cycle refinement). As we can see from this table, the three refinement schemes offer different quality/time trade-offs. In general, the EEFM scheme requires half the time required by either the FM or the 1WayFM schemes. Moreover, the quality of the bisections produced by EEFM, are in general only slightly worse (if any) than those produced by FM or 1WayFM. For example, in the 17 circuits of Table 3, EEFM performed significantly worse than the other two schemes only for \textit{ibm15}. From the remaining two refinement schemes, the results of Table 3 suggest that they perform similarly with 1wayFM producing slightly better results and requiring somewhat less time. 5.2 Computing a \textit{k}-way Partitioning \texttt{hMetis} can compute a \textit{k}-way partitioning (for \textit{k} \(> 2\)) using either the multilevel recursive bisection paradigm (implemented by \texttt{hmetis}) or the multilevel \textit{k}-way partitioning paradigm (implemented by \texttt{khmetis}). In our discussion of \texttt{khmetis} (Section 3.3), we already provided some general guidelines as to when someone should use \texttt{hmetis} or \texttt{khmetis}. In general, when \textit{k} is large (e.g., \textit{k} > 16) \texttt{khmetis} should be preferred over \texttt{hmetis}, as it is faster and enforces load imbalance constraints that are more natural than the bisection imbalance constraints enforced by \texttt{hmetis}. In this section we focus our discussion on using \texttt{hmetis} to compute a \textit{k}-way partitioning. In particular, besides the \textit{CTYPE} and \textit{RType} parameters discussed in Section 5.1, the quality of the resulting \textit{k}-way partitioning also depends on the choice of the \textit{Nruns} and \textit{Reconst} parameters. 5.2.1 Effect of the \textit{Nruns} Parameter Recall from Section 3.2, that \textit{Nruns} is the number of different bisections that are computed by \texttt{hmetis} during each recursive bisection level. Out of these \textit{Nruns} bisections, the one with the smallest cut is selected and used to bisect the hypergraph. For example, if \textit{Nruns} = 20, then in the case of a 4-way partitioning, \texttt{hmetis} will first compute 20 bisections of the original hypergraph, and split it into two sub-hypergraphs based on the best bisection. Then, it will compute 20 bisections of each one of the two sub-hypergraphs, and again select the best solution for each one of the two sub-hypergraphs. However, an alternate approach of computing the 4-way partitioning (using the same overall number of different bisections), is to set \textit{Nruns} = 5, run \texttt{hmetis} four times, and select the best 4-way partition out of these four solutions. That is, instead of running \begin{verbatim} hmetis xxx.hgr 4 5 20 1 1 1 0 0 \end{verbatim} we can run \begin{verbatim} hmetis xxx.hgr 4 5 5 1 1 1 0 0 hmetis xxx.hgr 4 5 5 1 1 1 0 0 hmetis xxx.hgr 4 5 5 1 1 1 0 0 hmetis xxx.hgr 4 5 5 1 1 1 0 0 \end{verbatim} and select the best solution. The overall amount of time for both approaches should be comparable (even though the second approach will be somewhat slower as the amount of time it spends in \textit{V}-cycle refinement is four times higher). However, the quality of the solution obtained from the second approach may be better. <table> <thead> <tr> <th>Circuit</th> <th>HFC, C_Type=1</th> <th>FC, C_Type=2</th> <th>GFC, C_Type=3</th> <th>HEDGE, C_Type=4</th> <th>EDGE, C_Type=5</th> </tr> </thead> <tbody> <tr> <td>avqsmall</td> <td>127 145.2 70.48</td> <td>131 157.4 81.27</td> <td>127 145.6 67.93</td> <td>127 163.8 111.52</td> <td>127 174.3 96.99</td> </tr> <tr> <td>avqlarge</td> <td>127 152.2 90.69</td> <td>127 159.8 93.41</td> <td>127 133.9 78.24</td> <td>127 163.5 134.92</td> <td>127 181.5 105.65</td> </tr> <tr> <td>industry2</td> <td>163 217.2 67.8</td> <td>183 224.1 68.66</td> <td>162 212.5 60.38</td> <td>172 226.4 75.91</td> <td>170 228.7 70.85</td> </tr> <tr> <td>industry3</td> <td>255 267.1 97.46</td> <td>249 265.9 106.74</td> <td>254 273.8 85.78</td> <td>255 274.9 121.38</td> <td>255 289.2 109.94</td> </tr> <tr> <td>s35932</td> <td>43 43.6 46.18</td> <td>43 43.4 46.81</td> <td>73 73.0 41.69</td> <td>43 51.4 61.50</td> <td>41 47.2 48.43</td> </tr> <tr> <td>s38417</td> <td>49 51.8 59.83</td> <td>50 51.5 61.96</td> <td>49 51.4 55.88</td> <td>50 69.8 90.20</td> <td>50 74.5 79.03</td> </tr> <tr> <td>s38584</td> <td>48 49.0 66.45</td> <td>48 48.6 66.68</td> <td>48 50.0 63.69</td> <td>48 56.6 91.68</td> <td>48 59.4 75.26</td> </tr> <tr> <td>golem3</td> <td>1333 1357.2 749.55</td> <td>1336 1354.5 805.76</td> <td>1339 1420.2 900.33</td> <td>1485 1846.5 1518.37</td> <td>1642 2159.7 1582.20</td> </tr> <tr> <td>ibm01</td> <td>181 214.2 74.66</td> <td>180 193.0 78.58</td> <td>181 241.7 74.28</td> <td>181 252.5 93.26</td> <td>181 194.7 69.47</td> </tr> <tr> <td>ibm03</td> <td>956 1017.3 216.21</td> <td>952 1022.4 223.65</td> <td>978 1153.4 209.34</td> <td>962 1045.0 295.90</td> <td>961 1051.3 283.78</td> </tr> <tr> <td>ibm05</td> <td>1715 1809.7 321.89</td> <td>1723 1792.0 300.06</td> <td>1738 1808.0 355.94</td> <td>1747 1856.6 474.70</td> <td>1784 1892.5 434.22</td> </tr> <tr> <td>ibm07</td> <td>851 948.1 626.45</td> <td>876 996.6 569.90</td> <td>853 948.1 603.37</td> <td>896 980.2 634.90</td> <td>852 914.0 629.22</td> </tr> <tr> <td>ibm09</td> <td>638 704.9 484.33</td> <td>637 694.1 474.96</td> <td>629 675.5 412.91</td> <td>636 770.0 597.89</td> <td>648 718.2 554.23</td> </tr> <tr> <td>ibm11</td> <td>960 1159.2 848.06</td> <td>960 1051.5 741.36</td> <td>965 1184.8 744.90</td> <td>1007 1197.2 1168.02</td> <td>982 1221.1 925.57</td> </tr> <tr> <td>ibm13</td> <td>869 930.2 939.98</td> <td>861 897.9 1002.63</td> <td>833 935.1 1073.89</td> <td>836 1063.2 1304.32</td> <td>834 987.4 1115.54</td> </tr> <tr> <td>ibm15</td> <td>2624 3058.1 2459.89</td> <td>2625 2932.7 2059.90</td> <td>2753 3488.4 1903.85</td> <td>2676 3190.6 2732.28</td> <td>2732 3241.8 2609.96</td> </tr> <tr> <td>ibm17</td> <td>2248 2371.5 2643.27</td> <td>2220 2317.1 2536.81</td> <td>2324 2507.7 2358.99</td> <td>2254 2454.7 2848.69</td> <td>2295 2487.6 2985.52</td> </tr> </tbody> </table> Table 2: The performance achieved by different vertex grouping schemes (i.e., different values of `C_type`). All the results correspond to bisections computed by hmetis with `Nruns = 20, UBlFactor = 5, RType = 1, Vcycle = 1, and Reconst = 0`. All times are in seconds on a Pentium Pro @ 200 Mhz. Table 3: The performance achieved by different refinement schemes (i.e., different values of RType). All the results correspond to bisections computed by hmetis with Nruns = 20, UBfactor = 5, CType = 1, Vcycle = 1, and Reconst = 0. All times are in seconds on a Pentium Pro @ 200 Mhz. Table 4 shows the quality of the 4- and 8-way partitionings produced by the above two approaches. As we can see from this table, the second approach performs better in 16 cases, worse in 10 cases, and similarly for the remaining 8 cases. Table 4: The performance achieved for a k-way partitionings using a single k-way partitioning with Nruns = 20, and four k-way partitionings with Nruns = 5. 5.2.2 Effect of the Reconst Parameter Recall from Section 3.2, that the Reconst parameter controls how a hyperedge that is part of the cut is reconstructed in the sub-hypergraphs during recursive bisection. In particular, if Reconst = 0, then a hyperedge that is part of the cut is removed entirely from the sub-hypergraphs, and if Reconst = 1, then the hyperedge is reconstructed in each sub-hypergraph. This is done by creating two hyperedges (one for each partition), that span the vertices of the original hyperedge that are assigned to each partition. The choice for the \textit{Reconst} parameter can affect the quality and runtime of the \textit{k}-way partitioning. In particular, if \textit{Reconst} = 0, then the partitioning algorithm will run faster (as successive hypergraphs will have fewer hyperedges), and if \textit{Reconst} = 1, then the partitioning algorithm can potentially do a better job in reducing the sum of external degrees (SOED) of the \textit{k}-way partitioning. This is illustrated in Table 5 that shows the effect of the \textit{Reconst} parameter on the cut, SOED, and runtime, for a 4-way partitioning. From this table we can see that \textit{Reconst} = 0, indeed results in a somewhat faster code, and that \textit{Reconst} = 1, results in partitionings whose SOED is, in general, smaller. However, what is interesting with the results of Table 5, is that \textit{Reconst} = 0 results in partitionings that have smaller cut, compared to those obtained by setting \textit{Reconst} = 1. So, if the objective is to obtain a \textit{k}-way partitioning that has the smaller cut, one should use \textit{Reconst} = 0. However, if minimizing the SOED is the primary focus, one may want to use \textit{Reconst} = 1. <table> <thead> <tr> <th>Circuit</th> <th>No Reconstruction</th> <th>Cut</th> <th>SOED</th> <th>Time</th> <th>With Reconstruction</th> <th>Cut</th> <th>SOED</th> <th>Time</th> </tr> </thead> <tbody> <tr> <td>avqusmall</td> <td>Reconst = 0</td> <td>228</td> <td>568</td> <td>111.92</td> <td>Reconst = 1</td> <td>246</td> <td>567</td> <td>118.28</td> </tr> <tr> <td>avqlarge</td> <td>Reconst = 0</td> <td>253</td> <td>605</td> <td>126.82</td> <td>Reconst = 1</td> <td>257</td> <td>569</td> <td>137.67</td> </tr> <tr> <td>industry2</td> <td>Reconst = 0</td> <td>381</td> <td>841</td> <td>107.47</td> <td>Reconst = 1</td> <td>429</td> <td>884</td> <td>110.56</td> </tr> <tr> <td>industry3</td> <td>Reconst = 0</td> <td>791</td> <td>1704</td> <td>173.45</td> <td>Reconst = 1</td> <td>821</td> <td>1647</td> <td>179.89</td> </tr> <tr> <td>s35932</td> <td>Reconst = 0</td> <td>111</td> <td>232</td> <td>72.05</td> <td>Reconst = 1</td> <td>111</td> <td>226</td> <td>72.07</td> </tr> <tr> <td>s38417</td> <td>Reconst = 0</td> <td>100</td> <td>224</td> <td>96.78</td> <td>Reconst = 1</td> <td>109</td> <td>228</td> <td>99.70</td> </tr> <tr> <td>s38584</td> <td>Reconst = 0</td> <td>130</td> <td>294</td> <td>106.35</td> <td>Reconst = 1</td> <td>138</td> <td>291</td> <td>111.90</td> </tr> <tr> <td>gone3</td> <td>Reconst = 0</td> <td>2222</td> <td>4613</td> <td>1162.19</td> <td>Reconst = 1</td> <td>2239</td> <td>4519</td> <td>1226.38</td> </tr> <tr> <td>ibm01</td> <td>Reconst = 0</td> <td>496</td> <td>1003</td> <td>124.53</td> <td>Reconst = 1</td> <td>498</td> <td>998</td> <td>128.04</td> </tr> <tr> <td>ibm03</td> <td>Reconst = 0</td> <td>1694</td> <td>3685</td> <td>285.15</td> <td>Reconst = 1</td> <td>1717</td> <td>3573</td> <td>301.55</td> </tr> <tr> <td>ibm05</td> <td>Reconst = 0</td> <td>3023</td> <td>6701</td> <td>459.12</td> <td>Reconst = 1</td> <td>3119</td> <td>6611</td> <td>532.71</td> </tr> <tr> <td>ibm07</td> <td>Reconst = 0</td> <td>2212</td> <td>4670</td> <td>786.26</td> <td>Reconst = 1</td> <td>2253</td> <td>4579</td> <td>850.59</td> </tr> <tr> <td>ibm09</td> <td>Reconst = 0</td> <td>1691</td> <td>3485</td> <td>790.61</td> <td>Reconst = 1</td> <td>1768</td> <td>3579</td> <td>774.53</td> </tr> <tr> <td>ibm11</td> <td>Reconst = 0</td> <td>2339</td> <td>4778</td> <td>1155.37</td> <td>Reconst = 1</td> <td>2412</td> <td>4862</td> <td>1198.74</td> </tr> <tr> <td>ibm13</td> <td>Reconst = 0</td> <td>1738</td> <td>3770</td> <td>1365.23</td> <td>Reconst = 1</td> <td>1755</td> <td>3604</td> <td>1398.37</td> </tr> <tr> <td>ibm15</td> <td>Reconst = 0</td> <td>5103</td> <td>10185</td> <td>3339.88</td> <td>Reconst = 1</td> <td>5299</td> <td>10844</td> <td>3069.92</td> </tr> <tr> <td>ibm17</td> <td>Reconst = 0</td> <td>5398</td> <td>11041</td> <td>4402.78</td> <td>Reconst = 1</td> <td>5421</td> <td>10984</td> <td>4854.22</td> </tr> </tbody> </table> Table 5: The performance achieved for a 4-way partitionings using different settings for the \textit{Reconst} parameter. All the results correspond to 4-way partitioning computed by hmetis with \textit{Nruns} = 20, \textit{UBfactor} = 5, \textit{CType} = 1, \textit{RTtype} = 1, and \textit{Vcycle} = 1. All times are in seconds on a Pentium Pro @ 200 Mhz. 6 System Requirements and Contact Information \texttt{hM\textsc{etis}} has been written in C and it has been extensively tested on Sun, SGI, Linux, and IBM. Even though, \texttt{hM\textsc{etis}} contains no known bugs, it does not mean that it is bug free. If you find any problems, please send email to metis@cs.umn.edu with a brief description of the problem. Also, any future updates to \texttt{hM\textsc{etis}} will be made available on WWW at \url{http://www.cs.umn.edu/~metis}. References
{"Source-Url": "http://glaros.dtc.umn.edu/gkhome/fetch/sw/hmetis/manual.pdf", "len_cl100k_base": 15809, "olmocr-version": "0.1.50", "pdf-total-pages": 20, "total-fallback-pages": 0, "total-input-tokens": 61187, "total-output-tokens": 18019, "length": "2e13", "weborganizer": {"__label__adult": 0.00036978721618652344, "__label__art_design": 0.0008158683776855469, "__label__crime_law": 0.0003070831298828125, "__label__education_jobs": 0.001399993896484375, "__label__entertainment": 0.00018167495727539065, "__label__fashion_beauty": 0.00024819374084472656, "__label__finance_business": 0.0006089210510253906, "__label__food_dining": 0.0003113746643066406, "__label__games": 0.0013551712036132812, "__label__hardware": 0.006008148193359375, "__label__health": 0.0004470348358154297, "__label__history": 0.0005426406860351562, "__label__home_hobbies": 0.0002071857452392578, "__label__industrial": 0.0011053085327148438, "__label__literature": 0.00037479400634765625, "__label__politics": 0.00028443336486816406, "__label__religion": 0.0006394386291503906, "__label__science_tech": 0.314697265625, "__label__social_life": 0.0001105666160583496, "__label__software": 0.023468017578125, "__label__software_dev": 0.6455078125, "__label__sports_fitness": 0.0003447532653808594, "__label__transportation": 0.000606536865234375, "__label__travel": 0.00022232532501220703}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 57512, 0.09368]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 57512, 0.68156]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 57512, 0.83751]], "google_gemma-3-12b-it_contains_pii": [[0, 422, false], [422, 2043, null], [2043, 5156, null], [5156, 9636, null], [9636, 13854, null], [13854, 16353, null], [16353, 19582, null], [19582, 22717, null], [22717, 25303, null], [25303, 28184, null], [28184, 32437, null], [32437, 32672, null], [32672, 36612, null], [36612, 39033, null], [39033, 43228, null], [43228, 47361, null], [47361, 49743, null], [49743, 50982, null], [50982, 55626, null], [55626, 57512, null]], "google_gemma-3-12b-it_is_public_document": [[0, 422, true], [422, 2043, null], [2043, 5156, null], [5156, 9636, null], [9636, 13854, null], [13854, 16353, null], [16353, 19582, null], [19582, 22717, null], [22717, 25303, null], [25303, 28184, null], [28184, 32437, null], [32437, 32672, null], [32672, 36612, null], [36612, 39033, null], [39033, 43228, null], [43228, 47361, null], [47361, 49743, null], [49743, 50982, null], [50982, 55626, null], [55626, 57512, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 57512, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 57512, null]], "pdf_page_numbers": [[0, 422, 1], [422, 2043, 2], [2043, 5156, 3], [5156, 9636, 4], [9636, 13854, 5], [13854, 16353, 6], [16353, 19582, 7], [19582, 22717, 8], [22717, 25303, 9], [25303, 28184, 10], [28184, 32437, 11], [32437, 32672, 12], [32672, 36612, 13], [36612, 39033, 14], [39033, 43228, 15], [43228, 47361, 16], [47361, 49743, 17], [49743, 50982, 18], [50982, 55626, 19], [55626, 57512, 20]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 57512, 0.13669]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
d28e583592288f616633652398471d6c5a31e153
1-1-2007 TiCoBTx-Net: a model to manage temporal consistency of service oriented business collaboration Haiyang Sun Macquarie University Jian Yang Macquarie University Weiliang Zhao University of Wollongong, wzhao@uow.edu.au Jianwen Su University Of California Follow this and additional works at: https://ro.uow.edu.au/engpapers Part of the Engineering Commons https://ro.uow.edu.au/engpapers/5018 Recommended Citation Sun, Haiyang; Yang, Jian; Zhao, Weiliang; and Su, Jianwen: TiCoBTx-Net: a model to manage temporal consistency of service oriented business collaboration 2007, 207-219. https://ro.uow.edu.au/engpapers/5018 Research Online is the open access institutional repository for the University of Wollongong. For further information contact the UOW Library: research-pubs@uow.edu.au TiCoBTx-Net: A Model to Manage Temporal Consistency of Service-Oriented Business Collaboration Haiyang Sun, Jian Yang, Member, IEEE, Weiliang Zhao, and Jianwen Su, Senior Member, IEEE Abstract—Business collaboration is about coordinating the flow of information among organizations and linking their business processes into a cohesive whole. A collaborative business process operates in a distributed environment involving multiple parties with dynamic availability, and a large number of heterogeneous sources with evolving contents [1]. A consistent outcome is expected within and among the parties involved. The service technologies as the foundation to build up consistent business collaboration have an aim to allow effective composition of discrete services or processes into end-to-end service aggregation on a global scale. A consistent business collaboration is supported by the service systems through the creation of alliances between service providers, each offering services to be used or syndicated with other external services [2]. As a result, services become the building blocks of collabora- tive business processes [3]. Inconsistency in business collaboration can be caused by many reasons, e.g., structure incompatibility (the participating processes do not bear consistent process logic) or behavior nonconformance (the behaviors of participating processes are not acted as agreed by others). In this paper, we mainly focus on temporal inconsistency in business collaboration. Business collaboration is time critical within and across organizations. For example, a delay will cause cascading delays that can affect multiple business participants. Deadlocks may happen for the mutual waiting of each participant's results in collaboration. Temporal inconsistency occurs since the participating processes in business collaboration fail to coordinate the temporal policies within and across business participants, i.e., specific service in the participating processes cannot execute in a properly temporal manner. Temporal polices are developed by individual business participants to restrict when the web services in participating processes can start and finish. When services are involved in business collaboration, the following must be guaranteed: - All services in the common participating process can successfully execute within their available temporal intervals. If there exists a service that cannot execute within its available temporal interval, then the temporal policies of the service are not matched with those of other related services in the common participating process in business collaboration. - When a service is interacting with another service of a collaborative partner, the temporal policies of these services must be matched with each other. These services must start and finish within their available temporal intervals when they are interacting. The coordination on temporal policies within and across participating processes is critical to ensure the smooth execution of the business collaboration. Deadlock caused by temporal inconsistency in business collaboration must be avoided. For example, in Fig. 1, Processes A and B are syndicated by services in different organizations, respectively, and interactions can be identified between 1) Services A and B, and 2) Services A+ and B+. Messages are transferred between services in the sequences 1 to 4. We can observe the occurrence of deadlock caused by temporal inconsistency as follows: The start time of Service A is missing and the 1 INTRODUCTION Business collaboration is about coordinating the flow of information among organizations and linking their business processes into a cohesive whole. A collaborative business process operates in a distributed environment involving multiple parties with dynamic availability, and a large number of heterogeneous sources with evolving contents [1]. A consistent outcome is expected within and among the parties involved. The service technologies as the foundation to build up consistent business collaboration have an aim to allow effective composition of discrete services or processes into end-to-end service aggregation on a global scale. A consistent business collaboration is supported by the service systems through the creation of alliances between service providers, each offering services to be used or syndicated with other external services [2]. As a result, services become the building blocks of collabora- tive business processes [3]. Inconsistency in business collaboration can be caused by many reasons, e.g., structure incompatibility (the participating processes do not bear consistent process logic) or behavior nonconformance (the behaviors of participating processes are not acted as agreed by others). In this paper, we mainly focus on temporal inconsistency in business collaboration. Business collaboration is time critical within and across organizations. For example, a delay will cause cascading delays that can affect multiple business participants. Deadlocks may happen for the mutual waiting of each participant's results in collaboration. Temporal inconsistency occurs since the participating processes in business collaboration fail to coordinate the temporal policies within and across business participants, i.e., specific service in the participating processes cannot execute in a properly temporal manner. Temporal polices are developed by individual business participants to restrict when the web services in participating processes can start and finish. When services are involved in business collaboration, the following must be guaranteed: - All services in the common participating process can successfully execute within their available temporal intervals. If there exists a service that cannot execute within its available temporal interval, then the temporal policies of the service are not matched with those of other related services in the common participating process in business collaboration. - When a service is interacting with another service of a collaborative partner, the temporal policies of these services must be matched with each other. These services must start and finish within their available temporal intervals when they are interacting. The coordination on temporal policies within and across participating processes is critical to ensure the smooth execution of the business collaboration. Deadlock caused by temporal inconsistency in business collaboration must be avoided. For example, in Fig. 1, Processes A and B are syndicated by services in different organizations, respectively, and interactions can be identified between 1) Services A and B, and 2) Services A+ and B+. Messages are transferred between services in the sequences 1 to 4. We can observe the occurrence of deadlock caused by temporal inconsistency as follows: The start time of Service A is missing and the Temporal consistency management in business collaboration is required not only at design time but also at runtime. The management at design time ensures that the temporal policies coordination at collaborative business is carried out before hand. However, it is extremely difficult to know all possible temporal parameters of participants, e.g., start time or finish time, before hand in the dynamic, distributed, loosely coupled environment. Therefore, the runtime dynamic temporal policy coordination becomes essential to enforce temporal consistency for collaborative business process. It is critical to develop models and mechanisms to effectively check and enforce temporal consistency during business collaboration. A number of research have been carried out to deal with temporal consistency in collaborative business process [6], [7], [14], [15], [28]. Existing models have the limitations either being constructed from a centralized global view which includes all the detailed information of participants, or simply specifying business collaboration without considering details of internal business process. In [19], [20], [22], [23], [24], [25], multiple methods are proposed to manage temporal consistency. However, it is still lacking of a solution that includes algorithms for the runtime dynamic temporal policy coordination. In this paper, we propose a model named Timed Choreographical Business Transaction Net (TiCoBTx-Net) for individual business participants to specify and manage the temporal consistency in business collaboration. The proposed model is based on Hierarchical Colored Petri Net [4], [5], [8], [9], [16], [17], [26]. Temporal policies are processed in TiCoBTx-Net to enforce the temporal consistency at both design time and runtime. The business collaboration is modeled by the TiCoBTx-Net controlled by two types of execution policies as behavior policies (based on business process logic) and temporal policies (based on temporal logic). These policies are employed to guarantee the correct operation of business collaboration. The Hierarchical Timed Computation Tree Logic (HiTCTL) is proposed to formalize the temporal policies and specify when and where these temporal policies can be effective on TiCoBTx-Net. Algorithms are developed to check if temporal policies are matched with each other in business collaboration considering related internal activities, web services, and communication tasks. The verification mechanism is devised to detect the status of temporal inconsistency in business collaboration. Our approach addresses the temporal inconsistency issue in business collaboration. The existing approaches are normally design time-based solutions and they have an inherent limitation to cover the dynamic temporal dependencies of involved services in a business collaboration. The proposed work presented in this paper is beyond the existing approaches [6], [7], [28] due to its following main contributions: 1. The proposed approach can provide a generic solution to address the temporal inconsistency issue in business collaboration by considering internal activities, web services, and communication tasks; 2. The proposed TiCoBTx-Net model has the capability to put the concerns of temporal inconsistency at the design time and the runtime under the same umbrella; 3. The work provides the practical way to identify and rationalize the temporal policies based on the Hierarchical Timed Computation Tree Logic; 4. Verification mechanism is provided to clarify the status of temporal inconsistency at runtime. The rest of paper is organized as follows: Section 2 provides a motivating example to illustrate the temporal inconsistency. Section 3 describes Timed Choreographical Business Transaction Net which models the business collaboration with temporal semantics. Section 4 presents how temporal policies are specified and rationalized by Hierarchical Timed Computation Tree Logic. Section 5 describes the algorithms to perform policy check on business collaboration and the mechanism to clarify the status of the temporal inconsistency. Section 6 gives the implementation details of the proposed approach. Section 7 reviews some related work. Concluding remarks are presented in Section 8. 2 Motivating Example Let us take an example in dealer-automotive industry. The ordering process begins with a quote inquiry broadcasting from a Customer. After receiving an inquiry, Dealers will validate the status of the Customer. A quote will be returned if the status of Customer is valid. Then, the Customer will choose a Dealer who offers the best deal. The selected Dealer will receive a purchase order from the Customer. After checking the stock, the Dealer will send the Customer an order acknowledgment with invoice and payment details. Concurrently, the Dealer will require the Logistics Company to arrange the transportation. Once the Dealer receives both the payment from the Customer and the delivery schedule from Logistics Company, the vehicle will be transported to the Customer. The Logistics Company will then notify the Customer for the delivery of the vehicle. Fig. 2 illustrates the ordering process. Each organization in the collaboration is depicted as a set of services (round corner rectangles in Fig. 2), e.g., Order Feedback service in Dealer, or Quote service in Customer. A service is a business application unit to provide functions to the operation of the whole business collaboration; the activities are included in an individual service in Fig. 2 to provide support for the functions of the service. For instance, Specify Model and Quote Approval are two sequential activities enclosed in Quote service to support its function-prepare quote. The communication tasks support business interactions among organizations and they are represented by dash lined rectangles. For example, the Receive Query... and Send Result are two communication tasks to support the interactions between the Quote Feedback service of Dealer and the Process Quote service of Customer. For illustrative purpose, in Fig. 2, control flows and message flows within a service are represented as thin solid line arrows. Control flows and message flows between services are represented as thick solid line arrows. The message flows are represented as thin dash line arrows when the messages are between organizations and represented as thick dash line arrows when the messages are between the service and its protocol. (See Legend in Fig. 2). From the above example, we can observe the following features that make the management on the temporal consistency difficult in the business collaboration: - **The Order Feedback Service in Dealer is supported by the internal activities, Validate Order, Stock Check, and Summary Order Acknowledgement; it needs to communicate with Order Service in Customer.** Managing temporal consistency need not only consider the match of temporal policies of web services-Order Service in Customer and Order Feedback Service in Dealer. It is also necessary to take the temporal policies of internal activities and associated communication tasks into account. - **All temporal policies of web services syndicated within Dealer are defined by Dealer and they cannot be dominated by other business participants.** Managing temporal consistency in business collaboration requires each involving business participant to guarantee the temporal consistency from single organization’s point of view. Furthermore, since web services are peer-to-peer, the temporal policies for internal activity in Customer cannot be controlled by the Dealer. The Dealer can only manage the temporal consistency within and across organization by identifying the temporal policies of web services, internal activities, and communication tasks in Dealer, and those of web services and associated communication tasks in Customer. - **Temporal consistency management should be taken at both design time and runtime.** For example, the finish time of Order Feedback service is 13:00 pm, and the finish time of Quote Feedback service is 15:00 pm. At design time, the two services can be syndicated together if the Quote Feedback service finishes before 13:00 pm when the Order Feedback service is still available to work. If the finish time of Quote Feedback service is at least 4 hours later than the start time of Quote Feedback service, managing temporal consistency between the Quote Feedback service and Order Feedback service can only be operated at runtime, depending when the Quote Feedback service starts in reality. The start time, finish time, and execution duration of the service, internal activity, and communication task are non-deterministic in an individual business participant. For instance, the earliest start time of Order Feedback service in business collaboration should be immediately after sending out the quote result, and the latest start time is seven days later than the finish time of Quote Feedback service. Hence, we specify the start time and finish time of each service, internal activity, and communication task with an earliest time and latest time, and a minimum execution duration. The lower bound of the available temporal interval represents the Earliest Start Time (EST) and the upper bound of the available temporal interval is the Latest Finish Time (LFT). The Latest Start Time (LST) is calculated as the start time when the service, internal activity, or communication task reaches the Latest Finish Time after minimum execution duration. If the service, internal activity or communication task is started at the Earliest Start Time, after minimum execution duration, it reaches the Earliest Finish Time (EFT). We do not need to define the maximum execution duration of each web service since it is the time difference between EST and LFT. The actual execution duration at runtime therefore must longer than the minimum execution duration. Based on the above-observed features, the temporal inconsistency may occur in service-oriented business collaboration as - **Across participant process.** If the Dealer requires to receive the payment within one week after issuing bill to Customer, then Latest Start Time of Receive Payment task in Dealer should be \[ LST_{\text{receivePayment}} = \text{completeTime}_{\text{issueBill}} + 7\text{days}. \] The temporal policy in Customer emphasizes that the payment will be prepared earliest 14 working days later than receiving the bill, i.e., the Earliest Start Time of Send Payment task in Customer is \[ EST_{\text{sendPayment}} = \text{completeTime}_{\text{issueBill}} + 14\text{days} \text{ (We ignore the message transfer time here).} \] The Earliest Finish Time of Send Payment task \( EFT_{\text{sendPayment}} \) is later than the Earliest Start Time of Send Payment task \( EST_{\text{sendPayment}} \) (minimum execution duration is required to finish the Send Payment task). The Earliest Start Time of Send Payment task in Customer \( EST_{\text{sendPayment}} \) is also later than the Latest Start Time of Receive Payment task in Dealer \( LST_{\text{receivePayment}} \). Due to \( EFT_{\text{sendPayment}} \geq EST_{\text{sendPayment}} > LST_{\text{receivePayment}} \), the Receive Payment task is not available when the Send Payment task finishes, though as early as possible (if \( LST_{\text{ReceivePayment}} \) of Receive Payment is passed, the task cannot be initiated any more). The temporal policies coordination is failed between the services of Payment Receive in Dealer and Bill Process in Customer. - **Within participant process.** The Prepare Delivery service in Dealer may not be able to work within its available temporal interval (14:00-16:00), since the previous service—Payment Receive service—is finished at its latest finish time 17:00. The Prepare Delivery service is not available when the Payment Receive service is finalized. The temporal policies coordination on Payment Receive service and Prepare Delivery service does not succeed in the ordering process of Dealer. 3 **TCoBTx-Net Model—A Collaboration Model with Temporal Semantics** TCoBTx-Net model as an infrastructure is developed based on Hierarchical Colored Petri Net to describe the business collaboration from one organization point of view to catering for the feature of “no central control” in the service environment. The model will employ temporal semantics to identify and operate temporal policies. 3.1 Structure of TiCoBTx-Net A TiCoBTx-Net is specified for individual participants to understand the behavior of their business partners. It consists of two components: the participant’s process and the publicly visible part of its collaborators. A collaborative process in each participant is separated into three layers as shown in Fig. 2, each of which is a subnet of TiCoBTx-Net. The Execution (Exe) subnet, Abstract (Abs) subnet, and Communication (Com) subnet correspond to the generic stratified structure of web service in business collaboration in terms of internal business process, service interface, and business protocol. - At execution level, internal business activities form Exe-subnet. - At abstract level, the input/output messages of the operations defined for the service, and the control ability that can transfer messages to and from other subnets form an Abs-subnet. - At communication level, different communication patterns such as request-response, notify, form a Com-subnet. The publicly visible part of other business partners that can be observed by participants are separated into two subnets in TiCoBTx-Net: External Communication (ExCom) subnet and External Abstract (ExAbs) subnet that represent the business protocol and public interfaces of web services in other business partners, respectively. 3.2 Execution Policy of TiCoBTx-Net In TiCoBTx-Net, the movements of Application-Oriented Token (AO-Token) correspond to the message flow. AO-Token can move within and across organizational boundary. The movement of AO-Token is controlled by the execution policy of a specific participant. The execution policies related with AO-Token in TiCoBTx-Net are categorized into two types: - **Behavior Policy** identifies “where AO-Token should go.” It guides the AO-Token movement from one service to another service, or from one internal activity to another one, based on the business process logic. In TiCoBTx-Net, it is graphically modeled as lines to link net elements, e.g., places or transitions. - **Temporal Policy** identifies “when AO-Token should go” and “how long AO-Token can go.” For example, an AO-Token can only be fired at a specific transition during a time interval, or the AO-Token can only start to fire after a specific time. Fig. 3 shows a TiCoBTx-Net of a Dealer to answer the Quote Request from a Customer. The TiCoBTx-Net of the Dealer is composed of two components, the three subnets to represent the Dealer’s process and two subnets as the public part of the Customer. Colored AO-Token representing different messages, e.g., B and D, are moved in TiCoBTx-Net. 3.3 Specification of TiCoBTx-Net **Definition 1.** A TiCoBTx-Net is a tuple \( N = (P, T, F, R, \delta, \lambda, \pi, II, IO) \), where - \( P \) is a set of places graphically represented as circles. \( P_{Exe}, P_{Abs}, P_{Com}, P_{ExC}, \) and \( P_{ExA} \) are sets of places at each subnet. - \( T \) is a set of transitions graphically represented as dark bars in Fig. 3, where \( T_{Exe}, T_{Abs}, T_{Com}, T_{ExC}, \) and \( T_{ExA} \) are sets of transitions at each level. \( T^r \) is a set of empty transitions for transferring AO-Tokens. - \( F = (P \times V \times T) \cup (T \times V \times P) \) is the flow relation between places and transitions, where \( V \) is a set of variables \( \{v, y, \ldots\} \) to represent the colored tokens. - \( R: P \cup T \rightarrow \mathcal{L} \) is a refinement formula on a transition or place to connect other subnets. \( \mathcal{L} = \{ \{g(x), \{e(x), \forall \} \} \} x \in V \); \( g(x) \) is a function to evaluate the AO-Token enabled at a specific transition or arrived at an individual place, and decides which subnet(s) shall be initiated. Sometimes, multiple subnets \( V \) can be activated simultaneously. \( e(x) \) and \( r(x) \) are the guard functions of corresponding subnet \( V \) to evaluate whether or not the subnet is available to initiate and exit. - \( \delta: P \cup T \rightarrow \{ \text{EST}, \text{LST}, \text{EFT}, \text{LFT} \} \) is a function on a transition and place to illustrate the start and finish time, where \( \text{EST} \) and \( \text{LST} \) represent the Earliest Start Time and Latest Start Time that each place and transition can be fired, and \( \text{EFT} \) and \( \text{LFT} \) represent the Earliest Finish Time and Latest Finish Time that each place and transition can stop firing. - \( \lambda: P \cup T \rightarrow T_i \), where \( \lambda \) is used to represent the arrive time when the token is deposited at each place and transition. - \( \pi: P \cup T \rightarrow Q \) is an interval function representing the minimum execution duration of a place or transition. - \( II, IO \) are the sets of in and out places of TiCoBTx-Net and their subnets, including \( II = \{ T_i \} \), \( i_{Exe} \), \( i_{Abs} \), \( i_{Com} \), \( i_{ExC} \), and \( i_{ExA} \), and \( IO = \{ o_{Exe}, o_{Abs}, o_{Com}, o_{ExC}, o_{ExA} \} \). - \( P, T, II, \) and \( IO \) define the basic elements—Place and Transition—in TiCoBTx-Net; while \( F \) and \( R \) are used to design the business process logic within and across subnet, respectively. \( \delta, \lambda, \) and \( \pi \) describe the temporal logic in TiCoBTx-Net, e.g., the earliest start time of a web service. 4 Temporal Policies-Enforcement of Temporal Consistency Temporal policies in TiCoBTx-Net must be coordinated in business collaboration because services are syndicated or interacted with other web services from different participants. A web service could be bound with multiple temporal policies which are depended on the status of business collaboration. A logic named Hierarchical Timed Computation Tree Logic is developed in this section to rationalize which temporal policies should be performed based on the status of TiCoBTx-Net. 4.1 Formal Syntax of the Temporal Policies A web service, as well as internal activity and communication task, called as an event in this paper, bears specific available temporal interval when it executes. An event is associated with a minimum execution duration $\pi$. For an event, there are - The lower bound of the available time interval is the Earliest Start Time of the event. - The upper bound of the available time interval is the Latest Finish Time of the event. - The Earliest Finish Time of the event is the time when the event executes minimum duration $\pi$ from the Earliest Start Time of the event, i.e., $EFT = EST + \pi$. - The Latest Start Time of the event is the time when the event reaches its Latest Finish Time after executing minimum duration $\pi$, i.e., $LST = LFT - \pi$. The above four temporal parameters constrains how each event cooperates with other events in business collaboration. Temporal policy coordination is carried out through matching the four temporal parameters at design time and runtime. 4.1.1 Temporal Policies for Single Subnet Two types of time are taken into account in temporal policies, message transfer time and task execution time. We use $\alpha$ to indicate the real message transfer time at place $P$, while $\beta$ is used to denote the real message execution time at Transition $T$. $\Theta$ represents the real start time of an event and $\Delta$ represents the real finish time of an event. **Temporal Policy 1.** $\pi(p_j) \leq \alpha$, where $\pi$ on place $p_j$ denotes the minimum message transfer time. **Temporal Policy 2.** $\pi(t_j) \leq \beta$, where $\pi$ on transition $t_j$ is the minimum message execution time. Through above Temporal Policies 1 and 2, both real message transfer time $\alpha$ and real message execution time $\beta$ must be greater than the setup minimum execution duration, respectively. Based on the basic four temporal parameters of each event, $EST$, $LST$, $EFT$, and $LFT$, we deduce two types of temporal parameters at design time and runtime denoted by $DT_*$ and $R_*$, where * represents the basic four temporal parameters. The basic temporal parameters of each event are set up when the event is created independently. At design time, when each event is syndicated with other events within common business process or interacted with other events, e.g., web services, in participating processes, the earliest and the latest start time or finish time of each event can be affected by the other cooperated events. For example, at design time, an event is not able to start at its developed earliest start time, and it can only be initiated after all previous time-related events based on business logic have ideally started at their earliest start times and executed at minimum execution durations. When messages are transferred at runtime, the earliest and the latest of start time and finish time of each event may be modified based on the real-time information. For instance, a Runtime Earliest Start Time ($R_{EST}$) depends on the runtime finish time of another event. Temporal policies may be required to restrict the start time and finish time of each event at both design time and runtime (See Temporal Policies 3 and 4). **Temporal Policy 3.** $R_{EST} \leq DT_{EST} \leq R_{EST} \leq \Theta \leq R_{LST} \leq DT_{LST} \leq LST$, where the real start time of an event $\Theta$ must be between $EST$ and $LST$. Moreover, $\Theta$ as the start time of an event should be restricted by the Design Time Earliest Start Time ($DT_{EST}$) and Design Time Latest Start Time ($DT_{LST}$) when the event is involved in business collaboration at design time. The $DT_{EST}$ of each transition is the maximum of $EFT$ of all message transfers before the transition, while the $DT_{LST}$ is as same as $LST$. The $DT_{EST}$ and $DT_{LST}$ of each place bear similar semantics. $DT_{EST}$ and $DT_{LST}$ can be calculated as follows: $p_j (j = 1..n)$ are preplaces of a transition and $t_j (j = 1..n)$ are transitions before a place, where $$DT_{EST}_t = \max_{i=1}^n(EST(p_j) + \pi(p_j)), j < i,$$ $$DT_{LST}_t = LST_{t_j},$$ $$DT_{EST}_p = \max_{i=1}^n(EST(t_j) + \pi(t_j)), j < i,$$ $$DT_{LST}_p = LST_{p_j}.$$ $\Theta$ as the start time of an event should starts between $R_{EST}$ and $R_{LST}$, where $R_{EST}$ and $R_{LST}$ represent Runtime Earliest Start Time and Runtime Latest Start Time. $R_{EST}$ and $R_{LST}$ are deducted based on the real event execution time, which can only be identified at runtime. $R_{EST}$ for each transition is the maximum time of $(\lambda(p_i) + \pi(p_i)), j = 1..n$. Through this way, we can repeatedly calculate the $R_{LST}$ of each transition at runtime for each step of message movement among the events in business collaboration. The process is similar to $R_{LST}$ as that of $LST$. The $R_{EST}$ and $R_{LST}$ of each place bear similar semantics. They can be calculated as follows: $p_j (j = 1..n)$ are all preplaces of a transition and $t_j (j = 1..n)$ are all transitions before a place. $\lambda(p_j)$ and $\lambda(t_j)$ are token arrive times in place $p_j$ and transition $t_j$, respectively, representing the start time of message transfer and execution, where $$R_{EST}_t = \max_{i=1}^n(\lambda(p_j) + \pi(p_j)), j < i,$$ $$R_{LST}_t = LST_{t_j},$$ $$R_{EST}_p = \max_{i=1}^n(\lambda(t_j) + \pi(t_j)), j < i,$$ $$R_{LST}_p = LST_{p_j}.$$ **Temporal Policy 4.** $EFT \leq DT_{EFT} \leq R_{EFT} \leq \Delta \leq R_{LFT} \leq DT_{LFT} \leq LFT$, where the real finish time of each event $\Delta$ should be between $EFT$ and $LFT$. Moreover, $\Delta$ needs to comply with the constraints at design time, where it must finish between Design Time Earliest Finish Time $DT_{EFT}$ and Design Time Latest Finish Time $DT_{LFT}$. $DT_{EFT}$ of the transition is deducted based on its $DT_{EST}$, where the transition starts at the $DT_{EST}$ and only executes minimum execution duration. $DT_{LFT}$ of the transition is the same as the $LFT$ which is the upper bound of the available temporal interval of the transition. The $DT_{EFT}$ and $DT_{LFT}$ of each place bear similar semantics. $DT_{EFT}$ and $DT_{LFT}$ for place and transition can be calculated as follows: $p_j$ ($j = 1..n$) are all preplaces of a transition and $t_j$ ($j = 1..n$) are all transitions before a place, where $$ DT_{EFT}_t = DT_{EST}_t + \pi(t), $$ $$ DT_{LFT}_t = LFT_t, $$ $$ DT_{EFT}_p = DT_{EST}_p + \pi(p), $$ $$ DT_{LFT}_p = LFT_p. $$ $\Delta$ is the finish time of an event and it must be between $R_{EFT}$ and $R_{LFT}$, where $R_{EFT}$ and $R_{LFT}$ represent Runtime Earliest Finish Time and Runtime Latest Finish Time. $R_{EFT}$ is deducted from $R_{EST}$, and $R_{LFT}$ is the same as $LFT$, where $$ R_{EFT}_t = R_{EST}_t + \pi(t), $$ $$ R_{LFT}_t = LFT_t, $$ $$ R_{EFT}_p = R_{EST}_p + \pi(p), $$ $$ R_{LFT}_p = LFT_p. $$ Temporal Policy 5. $EFT_{t_j}^i \leq LST_{t_i}^j$, $j < i$, where $EFT_{t_j}$ represents Earliest Finish Time of an event, e.g., $EFT$, $DT_{EFT}$, and $R_{EFT}$, while $LST^*$ is Lastest Start Time of next event, e.g., $LST$, $DT_{LST}$, and $R_{LST}$. This policy ensures that the next event must be available to start when the previous event finishes as early as possible. Otherwise, when the previous event finishes, the next event cannot be initiated since its latest start time has been passed. 4.1.2 Temporal Policies for Multiple Subnets This kind of policies restricts the token movement across the subnets. For example, the $EST^*$ of a transition $t_i^{Abs}$ in Abs-subnet should not be earlier than the $EST^*$ of a transition $t_j^{Abs}$ in Exe-subnet where $t_i^{Abs}$ and $t_j^{Abs}$ are linked by refinement function $R$ in TiCoBTx-Net. The reason is that the earliest start time of an internal activity which supports specific service must be earlier than the earliest start time of the supported service. $LFT^*$ of a transition $t_i^{Abs}$ in Abs-subnet must not be later than the $LFT^*$ of a transition $t_j^{Exec}$ in Exe-subnet. It is impossible for the service to be finished later than the latest finish time of its supporting internal activity. Temporal Policies 6 and 7 formally describe above restrictions. Temporal Policy 6. $EST_{t_i}^j \leq EST_{t_j}^i$ if $t_i \in T^{Exec}$ and $t_j \in T^{Abs}$ are linked by the refinement function. Temporal Policy 7. $LFT_{t_i}^j \geq LFT_{t_j}^i$ if $t_i \in T^{Exec}$ and $t_j \in T^{Abs}$ are linked by the refinement function. 4.2 Hierarchical Timed Computation Tree Logic (HITCTL) There may be a big number of temporal policies under different circumstances that are involved in business collaboration. For example, if $DT_{EST}$ of Order Feedback service in Dealer is after 15:00 pm, the $R_{LFT}$ of Payment Receive service in Dealer will be seven days more than the real finish time of Order Feedback service; otherwise, it will be six days more only. In this case, there are two temporal policies in Payment Receive service to restrict the real finish time $\Delta$, i.e., $\Delta_{PaymentReceive} \leq R_{LFT} OrderFeedback + 7 days$ and $\Delta_{PaymentReceive} \leq R_{LFT} OrderFeedback + 6 days$. It is necessary to build up a formal way to effectively and efficiently rationalize the temporal policies based on different status of TiCoBTx-Net. In TiCoBTx-Net, the state $s$ of each subnet is formulated as $s = (m, c)$, where $m$ is a marking and $c$ is a clock valuation, $c : m \rightarrow Dur$ representing the duration elapsed in this marking. Note, marking is used in petri-net-based process model to describe the status of token movement, i.e., marking is changed with the movement of token. In this way, state $s$ becomes a continuous state where time is taken into account. For example, $s_1 = (m_1, 1 second) \ldots s_n = (m_1, n seconds) \ldots s_{n+1} = (m_2, 1 second)$, where marking $m_1$ is changed to $m_2$ after $n$ seconds, i.e., token is moved from $m_1$ to $m_2$ after $n$ seconds. Based on this background, we introduce a novel Hierarchical Timed Computation Tree Logic operated on TiCoBTx-Net to rationalize the proposition of temporal policies based on the state of TiCoBTx-Net. For example, if $\phi$ is an atomic proposition of temporal polices, e.g., $\Delta_{PaymentReceive} \leq R_{LFT} OrderFeedback + 7 days$, and $s$ is a state of the specific subnet, $\phi$ can be used at specific state of the subnet when $\{\phi : s \rightarrow \{true\}\}$. Here, below we will elaborate the HITCTL and its semantics. Hierarchical Timed Computation Tree Logic is developed based on Timed Computation Tree Logic (TCTL) by embedding hierarchical semantics. Timed Computation Tree Logic is an extension of Computation Tree Logic Star (CTL*). Computation Tree Logic star is a temporal logic to specify both liner (LTL) and branching (CTL) property. The syntax of CTL* is given by the following grammar: $$ \psi_i \equiv false | \neg \psi_i | \psi_i \land \psi_i | \forall \psi_j \exists \psi_j, $$ $$ \psi_j \equiv \psi_i | \neg \psi_j | \psi_j \land \psi_j | \forall \psi_j \exists \psi_j | F \psi_j | G \psi_j. $$ In the grammar, $\phi$ stands for an atomic proposition of temporal policy. $\forall$ ("for all path") and $\exists$ ("there exists a path") are path quantifiers, where $U$ ("until") and $X$ ("next") are temporal operators. $F$ ("eventually") and $G$ ("all future states") are also temporal operators, but can be represented by $U$ ("until") and $X$ ("next"), e.g., $F \psi = \{true \psi\}$ and $G \psi = \neg F \neg \psi$. The path quantifiers and temporal operators will be introduced below. $M$ is a tuple defined as $M = (Z, W)$, where $Z = (S, \rightarrow, s_0)$ is a state transition system in TiCoBTx-Net, $S$ is a set of states of all subnets, $\rightarrow$ is the relation between states, and $s_0$ is a set of initial states of all subnets; $W: S \rightarrow 2^W$ is valuation function which associates each state of subnets with the atomic proposition of temporal policy that the state can satisfy. Let us take Exe-subnet as an example. $s' \in S^{Exe}$ is a state in Exe-subnet. $\Lambda(s')$ is the set of all execution paths in Exe-subnet starting from the $s'$. $\rho' = s' \rightarrow s'_1 \rightarrow s'_2 \ldots \ldots$ is one of the execution path in $\Lambda(s')$. The formal semantics of $CTL^*$ is given by the satisfaction relation $\models$ defined as follows: Timed Computation Tree Logic extends CTL* with a time interval $I$. With this way, we cannot only reason if the proposition is true at a future state, but can also identify which state it is. For example, $F_I \psi$ means that $\psi$ is "eventually true" after time $I$ is past from current state. The grammar of TCTL is given as follows: $$ \psi \equiv false \mid \phi \mid \neg \psi \mid \psi \land \psi \\ \psi \equiv \forall I(\psi_I) \mid \exists I(\psi_I) \mid \forall X \psi \mid \exists X \psi \\ \forall F_I \psi \equiv \forall G_I \psi \equiv \exists G_I \psi. $$ Let us take Abs-subnet as example. $\hat{\rho}(r) = R^+ \rightarrow S^o$ is an execution path in $\Lambda(s^o)$ ($s^o$ is a state in Abs-subnet), where $\hat{\rho}(r) = s^i + \alpha$ is a continuous state in $\hat{\rho}$ (is a clock time), i.e., $r = \sum_{i=0}^{\alpha} s^i + \alpha, i \geq 0$, and $0 \leq \alpha < \psi_i$ ($\psi_i$ represents the time duration needed in state $s^o$). Since temporal operators $F$ and $G$ can be represented by $U$ and $X$, and the usage of temporal operator $X$ is the same as its usage in CTL*, we only give the formal semantics of temporal operator $U$ in TCTL: $$ \quad M, s^o \models \forall \psi U \phi \iff \forall \rho \in \Lambda(s^o), \exists r \in I, \quad M, \hat{\rho}(r) \models \phi, \quad \text{and} \quad \forall 0 \leq r' \leq r, M, \hat{\rho}(r') \models \psi. $$ The temporal logic mentioned above are only suitable for the deduction within single subnet. TiCoBTx-Net is developed based on the hierarchical petri net with five subnets. It is necessary to extend TCTL for 1) satisfying the requirements of hierarchical semantics and 2) preserving the temporal semantics in TiCoBTx-Net. Hence, we develop a novel temporal logic named as Hierarchical Timed Computation Tree Logic. The syntax of HiTCTL is given as follows: $$ \psi \equiv false \mid \phi \mid \neg \psi \mid \psi \land \psi \\ \psi \equiv \forall I(\psi_I) \mid \exists I(\psi_I) \mid \forall X \psi \mid \exists X \psi \\ \forall F_I \psi \equiv \forall G_I \psi \equiv \exists G_I \psi \\ \forall B F_I \psi \equiv \exists B F_I \psi \equiv \forall B G_I \psi \equiv \exists B G_I \psi \\ \psi \equiv \forall H (\exists H \psi) \mid \exists H (\forall H \psi) \mid \forall H (\exists I \forall H \psi) \mid \exists H (\forall I \exists H \psi) \\ \forall H (\exists I \forall H \psi) \mid \exists H (\forall I \exists H \psi) \\ \exists H (\psi_H U \psi) \mid \psi_H (\exists H \psi). $$ In HiTCTL, the path quantifiers are classified into two categories: Branch quantifier ($\forall_B$ and $\exists_B$) and Hierarchical quantifier ($\forall_H$ and $\exists_H$). Branch quantifiers are used on future states in single subnets, while Hierarchical quantifiers are used across subnets to model the stratified structure of TiCoBTx-Net. Another type operator named Hierarchical operator is also introduced to deduce proposition of temporal policy across subnets, e.g., $\forall H \forall F_I$, $\exists H \forall G_I$, and $\exists H \forall U_I$. For example, $\forall_X$ means next upper subnet, while $\forall_F$ represents there eventually exists one subnet within $J$ upper levels, $J \in R^+$. Note, since the hierarchical operators for lower levels are the mirror objects of hierarchical operators for upper levels, we omit discussion on them. Let $s^o \in S_{Expr}$ be a state in Expr-subnet, $s^o \in S_{Abs}$ be a state in Abs-subnet, $s^o \in S_{Com}$ be a state in Com-subnet, and $s^o \in S_{ExprCom}$ and $s^o \in S_{ExprAbs}$ be states in ExprCom-subnet and ExprAbs-subnet, respectively. Let $\Omega(s^o)$ be the set of all hierarchical paths from Expr-subnet starting from the $s^o$. $\pi = s^1 \rightarrow s^2 \rightarrow s^3 \rightarrow \ldots$ is one of the hierarchical path in $\Omega(s^o)$, while $\pi' = s^1 \rightarrow s^1 \rightarrow s^1 \rightarrow \ldots$ is another example of hierarchical path in $\Omega(s^o)$. Branch Quantifiers and Temporal Operators have been introduced in TCTL and CTL*; here, we only summarize the semantics of Hierarchical Quantifiers and Hierarchical Operators in HiTCTL as follows: $$ \quad M, s^o \models \forall H \psi \iff \forall \pi \in \Omega(s^o), M, \pi \models \psi. $$ Example 1 (HiTCTL works at a specific state of individual subnet of TiCoBTx-Net): At state of $s^o$ in Expr-subnet, we can reason that for all Abs-subnets encapsulating this Expr-subnet (since $G_J$ where $J = 1$, one upper level of Expr-subnet is considered), there exits a path in Abs-subnets where the proposition $\psi_1$ is hold 24 hours until $\psi_2$ to be true. $\psi_1$ and $\psi_2$ are the propositions of temporal policies enacted in TiCoBTx-Net, e.g., they may be regarding to define LFT of two sequential services in Abs-subnet. Example 2 (HiTCTL works at a specific state of individual subnet of TiCoBTx-Net): At state of $s^o$ in Abs-subnet, there exist states in Abs-subnet (since $G_J$ where $J = 0$, no upper level of Abs-subnet is considered) where we can reason that for all branches at Abs-subnet, there exists a proposition $\psi_3$ eventually hold within 50 days after the current state $s^o$ is equivalent to the state where $DT \ast FS$ of Order Feedback service in Dealer is confirmed after 15:00 pm and $\psi_3$ is the proposition of temporal policy $\Delta_{\text{PaymentReceive}} \leq R_{\text{LFT}} \text{OrderFeedback} + 7$ days. After 50 days, this proposition of temporal policy will be treated as false. 5 Detection Mechanism-Verification of Temporal Inconsistency Temporal inconsistency occurs when the temporal policy coordination is failed in TiCoBTx-Net. In this section, we propose algorithms to coordinate the temporal policy, named as Temporal Policy Match Check. If the match check is failed, a property named time-embedded dead marking freeness in TiCoBTx-Net is introduced to verify the status of the temporal inconsistency. 5.1 Temporal Policies Coordination Each service, as well as internal activity and communication task is associated with multiple temporal policies when they are created. When they are cooperated with each other in business collaboration, the coordination on temporal policies becomes necessary to ensure the successful business collaboration execution. It is not usual for these events to have precious temporal policy match. All of the involving services including the associated internal activity and communication task can be freely started and finished within their well-defined temporal intervals. We identify three statuses for the temporal policy coordination: 1) Full Policy Match. The service including the encapsulated internal activities and communication tasks can start and finish at any time within the available time interval; 2) Fuzzy Policy Match. The services, internal activities, or communication tasks can only execute within a more strict time interval to ensure the successful business collaboration execution; 3) No Policy Match. There exists at least one event which does not have time interval to execute when it cooperates with other events at design time or runtime. The business collaboration should avoid “No Policy Match.” The policy match check is therefore developed as follows to measure the temporal policy coordination: 1. Static Policy Check. Static Policy Check is used at design time to ensure if the available time interval exists for each event in business collaboration. For example, the earliest start time of Order Feedback service in Dealer is designed at 8:00 am. When the service interacts with Order service in Customer A, the earliest start time of the Order Feedback service at design time ($DT_{\text{LST}}$OrderFeedback) has to be set up as 10:00 am since the start time of the available temporal interval of Order service in Customer A is 10:00 am. In this case, Static Policy Check ensures if the available time interval of the Order Feedback service in Dealer still exists after the earliest start time is modified at design time. 2. Dynamic Policy Check. The start time and finish time of each event in business collaboration are dynamic, e.g., the earliest start time of an event depends on the real finish time of another event. Dynamic Policy Check is needed to ensure that there does not exist “No Policy Match” for each event at runtime, i.e., available time interval of each event exists at runtime. Fig. 4 shows the temporal constraints of the ordering process scenario at the service level. Each service must work within its available temporal interval. Black diamond represents $EST$ and $LST$, and white diamond represents $EFT$ and $LFT$. It can be observed that the business collaboration is at the status of “Fuzzy Policy Match” and the Static Policy Check is successful. Black circle represents $DT_{\text{EST}}$ and $DT_{\text{LST}}$, while white circle is depicted as $DT_{\text{EFT}}$ and $DT_{\text{LFT}}$. Due to space limit, we design the Algorithm 1 for static policy check to examine the relationships of four basic temporal parameters with $DT_{\text{*}}$, i.e., $DT_{\text{EST}}$, $DT_{\text{LST}}$, $DT_{\text{EFT}}$, and $DT_{\text{LFT}}$. Algorithm 1 will repeatedly check the temporal policies 3 to 7 at each place and transition in TiCoBTx-Net, to ensure the existence of the available time interval. Checks for temporal policies 1 and 2 are not included in Algorithm 1 since the execution duration of each place and transition are not related to the policy coordination at design time. Similarly, we design algorithm for dynamic policy check to examine the relationship of $R_{\text{*}}$ with $DT_{\text{*}}$ ($R_{\text{*}}$ represents $R_{\text{EST}}$, $R_{\text{LST}}$, $R_{\text{EFT}}$, and $R_{\text{LFT}}$). Due to space limit, we only provide the algorithm for static policy check as shown in Algorithm 1. Algorithm 1. Algorithm for Static Policy Check Input: $P$, $T$, $F$, $EST^*$, $LST^*$, $EFT^*$, and $LFT^*$ Output: checkResult $\rightarrow$ [True, False] Steps: 1: checkResult:= True; ob:= T; obN:= {}; obH:= {}; 2: while $\neg$ob $\in P \cup T$ do 3: while ob $\not\in O$ do 4: if \textquote{Temporal Policy 3*} then 5: if Not $(EST (ob) \leq DT_{\text{LST}} (ob) \leq DT_{\text{LST}} (ob) \leq LST (ob))$ then 6: checkResult:= False 7: end if end if 8: /"Temporal Policy 4"/ 9: if Not (LFT(\(ob\)) ≤ DT_LFT(\(ob\)) ≤ DT_LFT(\(ob\)) ≤ LFT(\(ob\))) then 10: checkResult := False 11: end if 12: /"Temporal Policy 5"/ 13: obN := next(\(ob\)); i := 1; 14: for obNi ∈ obN do 15: if (LFT(\(ob\)) > LST(\(ob\))) or (DT_LFT(\(ob\)) > DT_LST(\(ob\))) then 16: checkResult := False; 17: end if 18: i := i + 1; 19: end for 20: /"Temporal Policy 6"/ 21: obH := Hierarchical(\(ob\)); j := 1; 22: for obHj ∈ obH do 23: if (LST(\(ob\)) < LST(\(obHj\))) or (DT_LST(\(ob\)) < DT_LST(\(obHj\))) then 24: checkResult := False; 25: end if 26: j := j + 1; 27: end for 28: /"Temporal Policy 7"/ 29: obH := Hierarchical(\(ob\)); k := 1; 30: for obHj ∈ obH do 31: if (LFT(\(ob\)) > LFT(\(obHj\))) or (DT_LFT(\(ob\)) > DT_LFT(\(obHj\))) then 32: checkResult := False; 33: end if 34: k := k + 1; 35: end for 36: end while 5.2 Verification Mechanism In this section, we introduce a property named time-embedded dead marking freeness in TiCoBTx-Net to clarify the status of the temporal inconsistency, i.e., to confirm in which step of TiCoBTx-Net the temporal inconsistency occurs. The labeled transitive matrix \(L_{BP}^t\) [18] denotes the relationship between \(\bullet\) and \(\bullet\) based on transition \(t\). (Note, \(\bullet = \{ y ∈ \mathcal{P}(y, x) ∈ \mathcal{F} \cap x ∈ T \}, \bullet = \{ y ∈ \mathcal{P}(x, y) ∈ \mathcal{F} \cap x ∈ T \}. \bullet\) and \(\bullet\) indicate the preplaces and postplaces of a transition, respectively.) We extend the transitive matrix by associating it with the result of temporal policy coordination in TiCoBTx-Net, called labeled time-embedded transitive matrix, and use it to detect the temporal inconsistency. Definition 2. A time-embedded transitive matrix \[ L_{BP}^t = (A^-)^T \text{Diag} \left( \sum_{h=1}^{m} r_{h1}, \sum_{h=1}^{m} r_{h2}, \ldots, \sum_{h=1}^{m} r_{hn} \right) A^+, \] where \(A^- = [a^-_{ij}]\) and \(A^+ = [a^+_{ij}]\) are \(n \times m\) matrix (\(n\) transitions, \(m\) places). \(T\) means transpose matrix. \(x ∈ \mathcal{P}, y ∈ T\). \[ a^-_{ij} = \begin{cases} 1 & (x, y) \text{ In } \mathcal{F} \\ 0 & (x, y) \text{ Not In } \mathcal{F} \end{cases} \] \[ a^+_{ij} = \begin{cases} 1 & (y, x) \text{ In } \mathcal{F} \\ 0 & (y, x) \text{ Not In } \mathcal{F} \end{cases} \] Fig. 5. Example for temporal consistency verification. \[ r_h(b = 1, 2, \ldots, n) \text{ is an evaluation variable of temporal requirement as} \] \[ |r_h| = \begin{cases} 1 & t_h \text{ is linked by specific places and temporal policy coordination on } t_h \text{ is succeeded.} \\ 0 & t_h \text{ is not linked by specific places or temporal policy coordination on } t_h \text{ is failed.} \end{cases} \] We also use \(L_{BP}^{t'}\), a labeled time-embedded transitive matrix \((m \times m)\) to extend the original time-embedded transitive matrix in which \(r_h\) in \(L_{BP}^{t'}\) is replaced by \(r_h/d_h\) in \(L_{BP}^t\). If \(r_h\) appears \(d\) times in the same column of \(L_{BP}^{t'}\). A TiCoBTx-Net is time-embedded dead marking free if \[ \exists h ∈ T, \quad p_j^{t_h}(time) = \sum_{i=1}^{m} r_{hi}/d_h c_i ≥ 1, \] where \(M^t_i(time) = M_{h-1} \cdot L_{BP}^{t'}\), \(M^t_i(time) = P_j(time) = \sum_{h=1}^{n} p_j^{t_h}(time)\), \(c_i\) represents the \(i\)th preplace of \(t_h\). Fig. 5 describes the internal business process of Quote Feedback service in Dealer to answer the Quote service in Customer. Each transition in this internal business process represents an individual activity and is associated with specific temporal policies. \(r_h\) is correlated with corresponding transition \(t_h\) as the evaluation variable of the temporal requirement. The \(Ti(j)\) is a time spot to partition the time according to when the transition can be activated and terminated. We assume that the state of Exe-subnets at TiCoBTx-Net of Dealer is \(M_3 = [0, 0, 1, 0, 1, 0]\) as \(t_4\) is enabled by the tokens in \(p_1\) and \(p_2\) (\(c_1 = 1, c_2 = 1\)). \[ L_{BP}^{t'} = \begin{bmatrix} 0 & r_{t_1} & 0 & 0 & 0 & 0 \\ 0 & 0 & r_{t_2} & 0 & 0 & 0 \\ 0 & 0 & 0 & r_{t_3} & 0 & 0 \\ 0 & 0 & 0 & 0 & r_{t_4} & 0 \\ 0 & 0 & 0 & 0 & 0 & r_{t_5} \end{bmatrix} \] Hence, \(M^t_4(time) = M_3 \cdot (L_{BP}^{t'})_{44}\). Since \(M^t_2(time < 5) = 0\), we set \(M^t_4(time) = P_6(time) = \sum_{h=1}^{4} p_h^{t_5}(time) = \frac{r_{t_5}}{2} (c_3 + c_5)\). \[ p_j^{t_h}(time) = \frac{r_{t_h}}{2} (c_3 + c_5) = \begin{cases} 0 & \text{if time < } Ti(3) \text{ or time > } Ti(5), \text{ then } r_{t_h} = 0 \\ 1 & \text{if } Ti(3) ≤ \text{time} ≤ Ti(5), \text{ then } r_{t_h} = 1. \end{cases} \] If Dealer can execute the activity \("collection" \(t_4\) within time interval \(Ti(3)\) and \(Ti(5)\), then the temporal policies are satisfied as $r_4 = 1$ and eventually $P^T_{0\ell}(\text{time}) \geq 1$. The TiCoBTx-Net of Dealer is time-embedded dead marking free at that moment. Otherwise, $r_4 = 0$, the TiCoBTx-Net is at the status of time-embedded dead marking and $t_4$ cannot be fired (See Fig. 5). ### 6 IMPLEMENTATION The implemented TiCoBTx-Net system is developed with JAVA/SWT. It consists of three components (See Fig. 6): 1) **Business Process Editor**: gets the input of a TiCoBTx-Net through Process Choreography Editor or BPEL engine. The BPEL engine takes BPEL codes and converts them into the input of TiCoBTx-Net. In our system, we adopt the existing technology to transfer the BPEL and Petri Net based model, e.g., [14]. Temporal policies are captured by *Temporal Rules/Policies Editor*. In the future, we will extend BPEL codes with temporal semantics and enrich the function of current BPEL engine in the system to input the temporal policies with temporal-aware BPEL codes. In order to simplify and reuse the configuration, *Token Games Warehouse* is used to store the execution policy for token movement. 2) **Simulator**: performs the verification. The *Modeling* works on tokens’ movements between different subnets of various organizations. It can also clarify the status of temporal inconsistency. The *verification* enables users to choose to execute the simulation in either of two modes: *Normal Mode*, which means that tokens move continuously, or *Single-Step Mode*, which allows the user to capture every single step of token movements. The *Time Conflict Viewer* displays alerts for users. 3) **External Interface**: allows the system to be integrated with other applications. Interfaces for data importing and exporting are provided. In this paper, we only use the Petri-net-based process model to describe the business collaboration and manage temporal consistency. In the future, the complexity of Petri-net-based process model will be touched upon with our research work stepping forward to the next phase. Fig. 7 shows a system running status for the example shown in Fig. 3. Initially, a TiCoBTx-Net of Dealer is constructed. Second, temporal policies are defined for each place and transition (See Fig. 8), while $DT^--$ are calculated based on the design of temporal policies. Static policy check are enacted in TiCoBTx-Net System based on $DT^-$. Dynamic policy check is performed at runtime. The temporal inconsistency is alerted after the verification. 7 RELATED WORK In this section, we will review the related work on managing temporal consistency in service-oriented business collaboration. 7.1 Business Collaboration Modeling This section reviews some representative works of business process modeling based on Petri Net. The works in [10], [11], [12], [13] develop a series of petri-net-based process models to perform web service behavior conformance checking. Different from our work, their petri-net process models focus on service level. We believe that their approaches cannot handle the complexity of business collaboration management without explicitly considering the internal activities and communication tasks. Our proposed model has the capability to consider the services, activities, and communication tasks under the same umbrella. Furthermore, their process models are designed for checking the conformance of web service behaviors instead of temporal constraints of involved events in business collaboration. The reported work in this paper focuses on the issue of temporal inconsistency in business collaboration. The proposed model is based on the hierarchical colored petri net with the adoption of the HiTCTL for temporal policies. Yang et al. [14] propose a method to transfer WS-BPEL [27] to Colored Petri-Nets (CPN) for verifying web service composition. A model based on Hierarchical CPN is introduced in [15] for detecting the reliability issues of web service workflow. These models have the limitation of being constructed from a centralized global view which requires the detailed information of all participants. This assumption is impracticable in the peer-based loosely coupled business collaboration environment. 7.2 Managing Temporal Consistency Managing temporal consistency has attracted a lot of research recently. Here are the representative works. Authors in [22], [23], [24] mainly focus on analyzing temporal compatibility from choreography perspective, i.e., check temporal policies among services of different organizations. Several temporal conflicts are identified in asynchronous web service interactions. However, their works can only work at service level, without taking internal activities and business protocols into account. Runtime temporal policy coordination is totally ignored. Other researches spend much effort on analyzing temporal reliability based on flow-types web service orchestration. In [25], the authors use temporal logic based on BPMN-Q to ensure the compliance of rules and polices in web service orchestration. Authors in [19] present an approach to transform web service orchestration into a time-aware orchestration where temporal assessment and intervention logic are performed to ensure the reliability of service composition. In [20], the authors propose a verification approach on temporal reliability based on WS-BPEL. However, in these research works, coordination on temporal policies to ensure the temporal consistency is missing. In [21], the authors present a framework for computing activity deadlines in workflow systems. The overall process deadline and external constraints are considered. This work targets workflow systems and it does not take cross-organizational service interactions into account. There have many research efforts on managing temporal consistency in service-oriented business collaboration. However, it is still lacking of a comprehensive solution to coordinate temporal policies for business collaboration at both design time and runtime. In this paper, we propose a novel process model, TiCoBTx-Net, to manage temporal consistency in service-oriented business collaboration. The merits of TiCoBTx-Net lie in: - The model has the capability to cover the internal business activities, web service interfaces, communication tasks, and the projection of public part of collaborative web services in other business partners under the same umbrella. - The proposed approach provides a generic solution to capture the temporal requirements in the business collaboration by identifying temporal policies to be operated in TiCoBTx-Net. - Algorithms are developed for policy check based on TiCoBTx-Net to enforce the temporal consistency at design time and runtime. A verification mechanism is provided to clarify the status of the temporal inconsistency. 8 CONCLUSION A novel model has been proposed for managing temporal consistency in service-oriented business collaboration. The formal syntax and specification for temporal policies and TiCoBTx-Net have been presented, as well as a new type of temporal logic, HiTCTL, to reason temporal policies in TiCoBTx-Net. The algorithms have been provided for checking temporal policies at both design time and runtime. The mechanism based on TiCoBTx-Net has been proposed for clarifying the status of temporal inconsistency. The implementation details of the proposed mechanism have also been provided. The proposed approach provides a formal solution to address the challenging temporal inconsistency issue in the service-oriented business collaboration. REFERENCES
{"Source-Url": "https://ro.uow.edu.au/cgi/viewcontent.cgi?referer=&httpsredir=1&article=7949&context=engpapers", "len_cl100k_base": 14733, "olmocr-version": "0.1.50", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 50718, "total-output-tokens": 15865, "length": "2e13", "weborganizer": {"__label__adult": 0.0003685951232910156, "__label__art_design": 0.0006313323974609375, "__label__crime_law": 0.00045180320739746094, "__label__education_jobs": 0.0026397705078125, "__label__entertainment": 0.0001500844955444336, "__label__fashion_beauty": 0.0002083778381347656, "__label__finance_business": 0.004608154296875, "__label__food_dining": 0.0004580020904541016, "__label__games": 0.0008206367492675781, "__label__hardware": 0.0011930465698242188, "__label__health": 0.0006761550903320312, "__label__history": 0.00038504600524902344, "__label__home_hobbies": 0.00014793872833251953, "__label__industrial": 0.0007710456848144531, "__label__literature": 0.0004363059997558594, "__label__politics": 0.0004525184631347656, "__label__religion": 0.0004041194915771485, "__label__science_tech": 0.131591796875, "__label__social_life": 0.0001704692840576172, "__label__software": 0.029541015625, "__label__software_dev": 0.822265625, "__label__sports_fitness": 0.0002582073211669922, "__label__transportation": 0.0010738372802734375, "__label__travel": 0.0002505779266357422}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 61091, 0.02601]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 61091, 0.18101]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 61091, 0.87659]], "google_gemma-3-12b-it_contains_pii": [[0, 803, false], [803, 7709, null], [7709, 11035, null], [11035, 13600, null], [13600, 19964, null], [19964, 25481, null], [25481, 31743, null], [31743, 38413, null], [38413, 43710, null], [43710, 48681, null], [48681, 53409, null], [53409, 55887, null], [55887, 61091, null], [61091, 61091, null]], "google_gemma-3-12b-it_is_public_document": [[0, 803, true], [803, 7709, null], [7709, 11035, null], [11035, 13600, null], [13600, 19964, null], [19964, 25481, null], [25481, 31743, null], [31743, 38413, null], [38413, 43710, null], [43710, 48681, null], [48681, 53409, null], [53409, 55887, null], [55887, 61091, null], [61091, 61091, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 61091, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 61091, null]], "pdf_page_numbers": [[0, 803, 1], [803, 7709, 2], [7709, 11035, 3], [11035, 13600, 4], [13600, 19964, 5], [19964, 25481, 6], [25481, 31743, 7], [31743, 38413, 8], [38413, 43710, 9], [43710, 48681, 10], [48681, 53409, 11], [53409, 55887, 12], [55887, 61091, 13], [61091, 61091, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 61091, 0.0]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
9c4cea1d2d19c1c46272e98ccebdd03d33602942
What factors are Important in Developing a Successful E-commerce Website? Jenny Grannas June 2007 Thesis, 10 points, C level Computer Science Creative Programming Supervisor/Examiner: Sharon A Lazenby Co-examiner: Carina Pettersson What Factors are Important in Developing a Successful E-commerce Website? By Jenny Grannas The Institution for Mathematics, Natural and Computer Science University of Gävle S-801 76 Gävle, Sweden Email: xizting_jenny@yahoo.se Abstract As the internet has become an increasingly growing market for companies, it has also subsequently revolutionized shopping. There are countless different options on the internet for individuals. If a website does not live up to the expectations, there is always another one just a few clicks away. This raises the demands on the retailers, in terms of development and maintenance of their e-commerce websites. In order to succeed, there are many things that have to be considered and addressed. This thesis research discusses some of the most essential questions that may arise during the development of an e-commerce website. The process has been divided into four different sections; graphical design, information design, interaction design, and online trust. Each one of these sectors is important and every website developer should be familiar with them. Keywords: e-commerce, web design, graphical design, information design, interaction design, online trust. Acknowledgement To Sharon Lazenby for being my supervisor. I deeply appreciate all the support that she has given me. She made me push myself forward when I was stuck in every sense of the word. She is a truly devoted teacher, and for that I thank her. To Patrik Jonsson for everything. I am not sure I have the words to describe what your endless support during this time has meant to me. He was there when I needed someone to talk to. He encouraged me to go on when I felt like this was a never-ending project. I thank him for all his love and patience. To both of my wonderful parents for supporting me as I wrote this thesis. I think my life these last years has been a great source of worry. But they have tried not to show it. They have waited for me to find my way back again, and now I think I am finally on my way there. To Tomas Fridén for having completed his thesis before me and proving to me that it was even possible. I greatly appreciate all the good advice that he has given me and that he took the time to answer all my more or less crazy questions. Table of Contents 1 Introduction and method ................................................................. 4 1.1 Questions at issue .............................................................................. 4 1.1.1 Graphical design ................................................................. 4 1.1.2 Information design ............................................................. 4 1.1.3 Interaction design ............................................................... 4 1.1.4 Trust .................................................................................. 5 1.2 Choice of method ............................................................................ 5 1.3 Aim ............................................................................................... 5 2 Theoretical background ................................................................. 6 2.1 Current development ....................................................................... 6 2.1.1 Graphical design ................................................................. 6 2.1.2 Information design ............................................................. 8 2.1.3 Interaction design ............................................................... 9 2.1.4 Trust .................................................................................. 13 2.2 Delimitation of the problem area .................................................. 14 3 Realization ..................................................................................... 15 4 Result and discussion ..................................................................... 15 4.1 Checklist .................................................................................... 15 4.2 Guidelines .................................................................................. 16 4.3 Method ...................................................................................... 16 5 Conclusions ................................................................................... 17 5.1 Proposal for further research ..................................................... 17 6 References ................................................................................... 18 Books, reports, articles and websites ........................................... 18 7 Appendix ..................................................................................... 19 Appendix A .................................................................................. 20 Appendix B .................................................................................. 22 1 Introduction and method As of March 10, 2007, there were 1.114 billion Internet users in the world [1]. The Internet has also become an increasingly large market for companies. Some of the major companies today have grown by taking advantage of the efficient nature of low-cost advertising and commerce through the Internet, also known as e-commerce. It is the fastest system to spread information simultaneously to a vast amount of people. The Internet has also subsequently revolutionized shopping. For the buyer, this means that almost everything can be bought online. There are countless different e-commerce websites for the users to choose from. This raises the demands on the retailers. E-commerce (Electronic Commerce) is exactly analogous to a marketplace on the Internet. E-commerce consists primarily of the distributing, buying, selling, marketing and servicing of products or services over electronic systems such as the Internet and other computer networks [14]. 1.1 Questions at issue Even though it might be fairly simple to start up an e-commerce website, it is far from unproblematic to make that website successful. There are numerous aspects to take into consideration when developing a successful e-commerce website. 1.1.1 Graphical design When it comes to graphical design, a website must be aesthetically appealing to the eye, without it taking a large amount of time to load. A flashy design might be nice to look at, but if it takes too long to load the user will loose patience and find another faster website. Therefore, it is necessary to think through the graphical design and come up with something that is both aesthetically appealing and has a short loading time. But how is this done in a simple way? 1.1.2 Information design It is imperative that a customer who arrives to the e-commerce website immediately understands what it is about. How information is presented on a website has a decisive influence on how the website is received. It is crucial that the website is simple to navigate and that the customer, without difficulty, can obtain an overview of the website. When developing an e-commerce site, it is necessary to consider how to present the merchandise. Long sections of text are hard to read. But too little information might not be satisfying to the customer. How much information is adequate? How much is too much? 1.1.3 Interaction design In order to look at the merchandise or purchase anything, the user must interact with the website. The customer may have to register in order to purchase products. Most e-commerce websites have a shopping cart where customers can place items of interest. It is important that it is easy for the customer to deposit or remove merchandise from the shopping cart. The more intuitive these actions are, the more comfortable the user feels. Therefore, it is incredibly important to think about how a website can be made as intuitive as possible. A customer who is comfortable using a website is more likely to explore it and return. If a customer is afraid or hesitant to push a button, due to lack of information, the website is a failure. 1.1.4 Trust A key element in e-commerce is trust. Without trust it would be impossible to do business at all. It is not easy for customers to know if an e-commerce site is trustworthy or not. Therefore, it is essential to have a well-structured site where the customer can find the information needed. However, are there more methods to win the customer’s trust? Security is also an important issue when developing an e-commerce site. The customers should always know that the information they provide will not be sold or misused in any other way. This is essential since the customers might provide sensitive information such as their credit card number. 1.2 Choice of method The method that I used in this thesis is literature studies. Furthermore, I will create a checklist addressing the issues important when developing an e-commerce website. I will also write guidelines explaining the points in the checklist more extensively. 1.3 Aim The aim of this thesis is to gain a deeper knowledge about e-commerce and its different aspects; graphical design, information design, interaction and trust. All of these aspects are essential and will be explored in this thesis. A checklist will be put together. It will help developers remember some of the most important elements to address when creating a successful website. The checklist will be supported by a guideline that explains every point of the checklist in detail. This guideline will be beneficial when developing an e-commerce site. 2 Theoretical background 2.1 Current development 2.1.1 Graphical design J. Ahlberg, the editor and publisher of the website “Jonas Webresurs” [8] writes that one of the most important things to think about when creating a website is that the layout and colors should harmonize with the content of the website. A user that enters the website should immediately understand what the purpose of the website is. The developer should also be consistent in choice of layout and colors. Consistency in layout and color provides the user a sense of familiarity. When choosing colors for the layout, it is a good idea to use web safe colors [8]. Most browsers today can show millions of colors, but there are still some old browsers that only show 256 colors. Therefore, to make sure that the website looks the same to everyone, web safe colors is a wise choice. There are 216 web safe colors. The remaining 40 colors out of the 256 are reserved for the use of the operating system [9]. The width of a page on a website should be less than the width of the browser window, to avoid horizontal scrolling [7]. According to a worldwide statistic research published by TheCounter January 1:st [11], 75% of all internet users use a resolution of (1024x768) or higher. When writing for the web and choosing fonts, there are several rules to consider. In typography, serifs are non-structural details on the ends of some of the strokes that make up letters and symbols. A font that has serifs is called a serif font and a font without serifs is called sans-serif [14]. When writing for the web sans-serif fonts is always a good choice since sans-serifs are easier to read on a screen than serifs. Another thing to consider is to avoid colors that are too bright. Bright colors might be hard to look at for a long time. If not, the users will find another page to lean their eyes on [8]. Contrast between background color and text color also makes the text easier to read. However, white text on a dark background should if possible be avoided, since it will be a huge waste of ink if the visitor decides to print out the page [8]. ![Figure 3. Example of good contrast.](image) ![Figure 4. Example of poor contrast.](image) When choosing fonts, it is wise to use common fonts that most users will have installed on their computers. If the user does not have the chosen font installed, it will be replaced by font that is installed on the user’s computer. This can make it hard to control the design. If an unusual font has to be used, consider using an image [8]. R. Molich, the author of the book ”Webbdesign med fokus på användbarhet” [6], argues that the area of graphical design is where the developers understand their users the least. Many developers believe that the user places great weight on a fancy graphical design. But the truth is that the majority of the user’s loose patience if the loading time is too long for most individuals will wait less than 10 seconds [10]. Developers also often make the mistake of believing that all their users have as fast of an internet connection as the developers themselves, which is not true [6]. There are three different kinds of graphics [6]: **Useful graphics** – Images of products or maybe maps. This is the kind of graphics that the user may be willing to wait for while it uploads. It may be a good idea to show a thumbnail image at first and then let the users decide whether they would like to see a larger image. **Supportive graphics** – Helps structure the information on a website. For example; create a clear dividing of the navigation field and the information field. **Insignificant graphics** – This could be company logotypes or ads. The user will tolerate this kind of graphics if it loads quickly. Be careful when using animations, they can easily distract the users from the text. The only place where animations are really useful is when there is no text for the user to focus on, for example; on a page that shows when the website uploads information [6]. ### 2.1.2 Information design Provide a search engine to help the users to find what they are seeking. The search engine should be located in place where it is easy for the users to find. It is enough with a text field with a search button next to it and a link to a more advance search [6]. To make the text more perspicuous, divide large chunks of text into smaller paragraphs and provide them with clear and descriptive headings. Make sure there is some space between the paragraphs [6]. Images can also break up a text and make it easier to read. But make sure that the images are relevant and have a logical connection to the text that they illustrate [6]. A branch within the psychology, called perception psychology, deals with how we perceive entitities in images. Psychologists have formulated the findings in the so called laws of shapes. A developer of websites can keep information together visually by using these laws of shapes [6]. <table> <thead> <tr> <th>Symbols</th> <th>Law</th> </tr> </thead> <tbody> <tr> <td>○○○ ○○○ ○○ ○○○</td> <td>Vicinity, Nearness</td> </tr> <tr> <td>[○○] [○○] [○○]</td> <td>Seclusion</td> </tr> <tr> <td>○○ ○ ● ● ○ ○ ○</td> <td>Likeness, Similarity</td> </tr> <tr> <td>○●○ ○●○ ○●○</td> <td>Continuity</td> </tr> </tbody> </table> Table 1. The laws of shapes. The law of vicinity and nearness: Symbols that are located near each other are perceived as connected. The law of seclusion: Symbols that are located within the same frame are perceived as connected. The law of likeness and similarity: Symbols that are similar to each other are perceived as connected. The law of continuity: Symbols that are linked together are perceived as connected. The products on the website should be categorized in a method that is meaningful to regular customers, the depths of the categories should be no more than three [7]. Always provide accurate and detailed information about the products together with an image. It could be a thumbnail image, with the possibility of clicking on it to see a larger image. Also present the size of the products in a way that is measurable and comparable. It should be easy to compare different products. Always present the inventory information of a product [7]. 2.1.3 Interaction design Interaction design deals with how to identify users’ needs, and from this understanding, move to designing usable and enjoyable systems. The presence or absence of good interactions design can make or break an e-commerce website [12]. The process of interaction design involves four basic activities [12]: - Identifying needs and establishing requirements. - Developing alternative designs that meet those requirements. - Building interactive versions of the designs with the intention that they can be communicated and assessed. - Evaluating what is being built throughout the process. Many websites that require users to interact with them to carry out their tasks have not necessarily been designed with the users in mind. Most likely they have been engineered as systems to perform set functions. While they might work effectively from an engineering perspective, it is often at the expense of how the website will be used by real people. The aim of interaction design is to address this concern by bringing usability into the design process. In essence, it is about developing interactive products that are easy, effective and enjoyable to use from the users perspective [12]. When developing interaction design, decisions should be based on an understanding of the user [12]. - Taking into an account what people are good and bad at. - Considering what might help people with the way they currently do things. - Thinking through what might provide quality user experience. - Using tried and tested user-based techniques during the design process. In addition to the four basic activities of design, there are three key characteristics of the interaction design process [12]: - Users should be involved throughout the development of the project. - Specific usability and user experience goals should be identified, clearly documented, and agreed upon at the beginning of the project. - Iteration through the four activities is inevitable. Usability is broken down into the following six goals [12]: **Effectiveness**, effective to use. Refers to how good a system is at doing what it is supposed to do. **Efficiency**, efficient to use. Refers to the way a system supports users in carrying out their tasks. **Safety**, safe to use. Safety involves protecting the user from dangerous conditions and undesirable situations. Safety also refers to helping users in any kind of situation, to avoid the dangers of carrying out unwanted actions accidentally. It also refers to the perceived fears users might have of the consequences of making errors and how this affects their behavior. Safe interaction systems could engender confidence and allow the user opportunity to explore the interface and to try out new operations. Other safety mechanisms include undo facilities and confirmatory dialog boxes, which give users another chance to consider their intentions. **Utility**, have good utility. Refers to the extent to which the system provides the right kind of functionality so that the users can do what they need or want to do. **Learnability**, easy to learn. Refers to how easy a system is to learn how to use. **Memorability**, easy to remember how to use. Refers to how easy a system is to remember how to use, once learned. As well as focusing on improving efficiency and productivity, interaction design is increasingly concerning itself with creating systems that are [12]: - Satisfying - Enjoyable - Fun - Entertaining - Helpful - Motivating - Aesthetically pleasing - Supportive of creativity - Rewarding - Emotionally fulfilling Usability goals are central to interaction design and are operational through specific criteria. User experiences goals are shown in the outer circle are less clearly defined. Recognizing and understand the trade-offs between usability and user experience goals are important. Obviously, not all of the usability goals and user experience goals apply to every interactive product being developed. What is important depends on the use context, the task at hand, and who the intended users are [12]. Text on links and buttons should be concise, self-explained and descriptive [7]. Users should not have to be unsure of what will happen if they push a certain button. The shopping cart page on the website should provide a link that directs the customers back to the page they came from, where they can continue their shopping without having to start from the beginning again[7]. Once the users proceed to the check-out, they should only be asked to provide necessary and meaningful information, such as name and address. No marketing questions should be asked [7]. As I researched the subject of interaction design, I found numerous books and articles discussing interaction design in general. However, I could not find any information that applied specifically on interaction design for e-commerce websites. Therefore, I decided to study some of the largest and most well-known websites to how they had designed their interaction. 2.1.4 Trust Dayal, Landesberg and Zeisser, the authors of the research report “How to build trust online” [2], say “that the lack of consumer trust is a critical impediment to the success of e-commerce.” According to Lanford and Hübscher, the authors of the research report “Trustworthiness in E-commerce” [3], it is imperative to build a good reputation, not just real but also perceived trustworthiness. In order to do so, advertising in newspapers and magazines or television could be a great tool. If the consumers have heard the name of the e-commerce website repeatedly, they are more likely to make an effort to inspect the site. Technical competence is a key factor when it comes to gaining the customers trust. It is imperative that the e-commerce website is completely functional. Make sure all words are spelled correctly, there are no broken links or dead images, search engines yield proper results, etc. If the website does not function properly, it gives an unprofessional impression. Customers will rather put their trust in a website that seems qualified [3]. A photograph of a company’s representative may be a simple, yet powerful tool to increase the trustworthiness of an e-commerce website [5]. However, there is reason for caution. Different people have different experiences on the internet. Putting photographs of employees on e-commerce websites might benefit one group of shoppers while deterring another [4]. Ill-considered use of photographs might decrease both trustworthiness and usability of a website [4]. Always provide the customer with accurate and detailed product information so there are no surprises when the product arrives [3]. A customer who is disappointed in the product or product information will not return to that same e-commerce website again. Do not ask for personal information unless it is necessary. Do not make the customer log in to the website just to look at the merchandise. The user should not have to log in until the checkout. Avoid asking for personal or credit card information until the very end of the checkout procedure [3]. Consumers want to know that the personal information they submit will be handled with great sensitivity. It is a good idea to post an easy-to-read privacy statement on the website [2]. Minimize the risk that the customer is taking, when trusting the e-commerce website. The site needs to provide safe and secure transactions along with sound privacy policies. This way the customer may feel more comfortable sending personal information over the internet. Another option could be to move certain risky actions to a trusted third party [3]. PayPal is an example of these third parties, it is an e-commerce business allowing payments and money transfers to be made through the Internet. It serves as an electronic alternative to traditional paper methods such as checks and money orders. PayPal performs payment processing for online vendors, auction sites, and other corporate users, for which it charges a fee [14]. An e-commerce website should use the most reliable security measures, and communicate that this is the case to the customers in a language they understand [2]. To prove to the customers that their needs are the most important is a great way of winning their trust. Services such as money-back guarantees, competitive price matching, and product reviews should definitely be provided. If the customer had a bad experience it needs to be corrected, immediately by providing a shipping refund, store credit, or a coupon for a percentage of their next purchase. If this is fulfilled, the customer will return and also spread the word on the great customer service. The customer should always know that their satisfaction comes first and that making money comes second [3]. Companies that build and nurture trust find that the customers return to their e-commerce websites repeatedly. Websites without a core of returning customers must devote more capital to attracting new customers. These companies may find it difficult to survive in the long run [2]. In order to develop a long-term relationship, the customer must have a positive first shopping experience and come away with a good impression of the website. If the customers had a negative experience, they are definitely not going to return. To induce customers to return to the website, show them appreciation by providing discounts on return purchases, such as free shipping [3]. 2.2 Delimitation of the problem area I chose to limit my thesis research to e-commerce websites in Europe and the USA. I choose not to include e-commerce websites all over the world since this would involve not only technical research but cultural research as well. I also decided to stick to the theory of the subject, since that was what interested me the most. An actual development of an e-commerce website would not fit in to the time frame of this thesis. And it also deals a great deal with programming. I was more interested in the theory behind the programming. The reason for this is that there are so many developers out there who really know the programming, but still make simple mistakes. 3 Realization This research originated with literature studies using books, articles, and the internet. Material of current research was essential in order to provide a present-day background. Then, a checklist was developed. The checklist contained important issues to take into consideration when building an e-commerce website. In order to better explain the points in the checklist, a guideline was developed. The guidelines discuss the issues more deeply and provide first-class and inadequate examples. 4 Result and discussion The actual result of the research was a checklist and a guideline that could be used together in the development of e-commerce websites. I believe that the area of research that I chose for this thesis was far too extensive. There were numerous questions to be answered and not enough valid time to research them all in depth the way I wanted to. It would have been enough time for in depth research of some of the issues. But rather than doing that I chose to keep the research on the same level for all of the questions. Still it was difficult to know how much focus to apply to researching every issue. I also found, when I developed the guidelines, that almost every point on the checklist would need additional research than what was possible in this thesis in order to explain everything that needed explaining. I partly feel like the result turned out too shallow. It might have been an excellent idea instead to pick a controlled area of research where I could apply concentrated focus. 4.1 Checklist The checklist was created to be used in the development of e-commerce websites. Developers will be able to use the checklist to make sure that the most important issues have been addressed. Still there are many issues that could have been mentioned in the checklist that are not. The time constraints made it impossible to address every issue. I tried to focus on as many as possible. The checklist is attached as Appendix A. 4.2 Guidelines The guideline is an extension of the checklist and explains every point in further detail. I had hoped to have the time to discuss every point on the checklist more extensively than I did. However, discovering such a wide area of research was not possible with the time constraints. The guidelines are attached as Appendix B 4.3 Method For this area of research, I found that literature studies were an excellent method. I have come to the conclusion that it is mostly because the area of research is enormous. 5 Conclusions During my research I came across all kinds of different e-commerce websites. Some of them were perfect examples of how a good website should look and function, while others were horrible to say the least. As I said earlier, it might be fairly simple to start up an e-commerce website, but it is far from unproblematic to make that website successful. There is no magical formula for how to succeed. However, there are a few things that every developer should think about. I wanted to research this topic in order to find out what those things were. I do not offer any solutions to the questions at issue. My goal was to illustrate these issues and bring them out in to the light. Most of the issues turned out to be fairly simple, but surprisingly they often get overlooked. I gathered all the issues in the checklist, and explained them further in the guidelines. 5.1 Proposal for further research I propose additional and more in depth research in any of the areas that I have examined during the process of writing this research thesis. It is an interesting growing area that is still being developed and will continue to be in the future. 6 References Books, reports, articles and websites 7 Appendix Appendix A: 1 Graphical design <table> <thead> <tr> <th>1.1 Layout</th> </tr> </thead> <tbody> <tr> <td>1.1.1 The layout should harmonize with the content of the website.</td> </tr> <tr> <td>1.1.2 The color should harmonize with the content of the website.</td> </tr> <tr> <td>1.1.3 The layout should be consistent throughout the website.</td> </tr> <tr> <td>1.1.4 The colors should be consistent throughout the website.</td> </tr> <tr> <td>1.1.5 Consider using web safe colors.</td> </tr> <tr> <td>1.1.6 The width of the website should be smaller than the browser window.</td> </tr> </tbody> </table> 1.2 Text | 1.2.1 Use sans-serifs. | | 1.2.2 Use common fonts. | | 1.2.3 Do not mix more than three fonts. | | 1.2.4 Make sure there is contrast between text and background. | | 1.2.5 Do not use too small font size. | 2 Information design | 2.1 In general | | 2.1.1 If using images to break up a text make sure the images are relevant to the text. | | 2.2 Product information | | 2.2.1 Categorize the products using a method that is meaningful for the customers. | | 2.2.2 The depth of the categories should be no more than three. | | 2.2.3 Always provide accurate and detailed information about the products. | | 2.2.4 Present the size of the products in a measurable and comparable way. | | 2.2.5 Facilitate comparison of products. | | 2.2.6 Present inventory information of the products. | | 2.2.7 Always show images of the products. | | 2.2.8 Show thumbnails of the products. | 3 Interaction design | 3.1 In general | | 3.1.1 Put the usability and user experience goals in focus. | | 3.1.2 Let the users be a part of the development process. | | 3.2 Shopping cart | | 3.2.1 Provide a way to place a product in the shopping cart from the thumbnail view. | | 3.2.2 Provide a way to place a product in the shopping cart from the product page. | | 3.2.3 Provide a field where the customer can state the quantity of products wanted. | | 3.2.4 Let the customers look in to their own shopping carts. | | 3.2.5 Let the customers remove products from the shopping cart. | | 3.2.6 Let the customers change the quantity of a product in the shopping cart. | | 3.2.7 Provide an explanation of how to administrate the shopping cart. | | 3.2.8 Provide a way to start the check-out procedure from the shopping cart. | <p>| 3.3 Check-out | | 3.3.1 Let the customers know where they are in the check-out procedure. | | 3.3.2 Provide help to fill out different fields or chose between different options. |</p> <table> <thead> <tr> <th>4 Trust</th> </tr> </thead> <tbody> <tr> <td><strong>4.1</strong> Functionality</td> </tr> <tr> <td>4.1.1 Make sure the website does what is supposed to do.</td> </tr> <tr> <td>4.1.2 Make sure the spelling is correct.</td> </tr> <tr> <td>4.1.3 Make sure there are no dead images.</td> </tr> <tr> <td>4.1.4 Make sure there are no broken links.</td> </tr> <tr> <td>4.1.5 Make sure that the internal search engine yield proper results.</td> </tr> <tr> <td><strong>4.2</strong> Privacy</td> </tr> <tr> <td>4.2.1 Do not make the user log in until the checkout procedure.</td> </tr> <tr> <td>4.2.2 Do not ask for unnecessary information.</td> </tr> <tr> <td>4.2.3 Post an easy-to-read privacy statement</td> </tr> <tr> <td>4.2.4 Avoid asking for personal and credit card information until the very end of the checkout procedure.</td> </tr> <tr> <td><strong>4.3</strong> Security</td> </tr> <tr> <td>4.3.1 Provide safe and secure transactions and make sure the user knows it.</td> </tr> <tr> <td>4.3.2 Provide a possibility to move certain risky actions, such as payment, to a trusted third party, such as Pay Pal or BidPay.</td> </tr> </tbody> </table> Appendix B: Table of Contents 1 Graphical design ............................................................................................................................ 24 1.1 Layout......................................................................................................................................... 24 1.1.1 The layout should harmonize with the content of the website........................................... 24 1.1.2 The color should harmonize with the content of the website............................................ 25 1.1.3 The layout should be consistent throughout the website.................................................... 26 1.1.4 The colors should be consistent throughout the website.................................................... 26 1.1.5 Consider using web safe colors........................................................................................... 26 1.1.6 The width of the website should be smaller than the browser window............................. 27 1.2 Text........................................................................................................................................... 27 1.2.1 Use sans-serifs.................................................................................................................... 27 1.2.2 Use common fonts.............................................................................................................. 28 1.2.3 Do not mix more than three fonts....................................................................................... 30 1.2.4 Make sure there is contrast between text and background............................................. 30 1.2.5 Do not use to small font size............................................................................................... 30 2 Information design .......................................................................................................................... 30 2.1 In general..................................................................................................................................... 30 2.1.1 If using images to break up a text make sure the images are relevant to the text. .............. 30 2.2 Product information..................................................................................................................... 31 2.2.1 Categorize the products using a method that is meaningful for the customers............... 31 2.2.2 The depth of the categories should be no more than three.............................................. 31 2.2.3 Always provide accurate and detailed information about the products......................... 31 2.2.4 Present the size of the products in a measurable and comparable way........................... 31 2.2.5 Facilitate comparison of products..................................................................................... 31 2.2.6 Present inventory information of the products................................................................. 33 2.2.7 Always show images of the products............................................................................... 33 2.2.8 Show thumbnails of the products...................................................................................... 33 3 Interaction design ............................................................................................................................ 34 3.1 In general..................................................................................................................................... 34 3.1.1 Put the usability and user experience goals in focus......................................................... 34 3.1.2 Let the users be a part of the development process......................................................... 34 3.2 Shopping cart............................................................................................................................... 35 3.2.1 Provide a way to place a product in the shopping cart from the thumbnail view............ 35 3.2.2 Provide a way to place a product in the shopping cart from the product page.............. 35 3.2.3 Provide a field where the customer can state the quantity of products wanted.............. 35 3.2.4 Let the customers look in to their own shopping carts..................................................... 36 3.2.5 Let the customers remove products from the shopping cart......................................... 36 3.2.6 Let the customers change the quantity of a product in the shopping cart.................... 37 3.2.7 Provide an explanation of how to administrate the shopping cart.................................... 37 3.2.8 Provide a way to start the check-out procedure from the shopping cart........................ 37 3.3 Check-out................................................................................................................................... 37 3.3.1 Let the customers know where they are in the check-out procedure............................... 37 3.3.2 Provide help to fill out different fields or chose between different options.................... 37 4 Trust............................................................................................................................................... 38 4.1 Functionality............................................................................................................................... 38 4.1.1 Make sure the website does what is supposed to do....................................................... 38 4.1.2 Make sure the spelling is correct....................................................................................... 38 4.1.3 Make sure there are no dead images............................................................................... 38 4.1.4 Make sure there are no broken links............................................................................... 38 4.1.5 Make sure that the internal search engine yield proper results.................................... 38 4.2 Privacy...................................................................................................................................... 39 4.2.1 Do not make the user log in until the checkout procedure............................................ 39 4.2.2 Do not ask for unnecessary information .......................................................... 39 4.2.3 Post an easy-to-read privacy statement ......................................................... 39 4.2.4 Avoid asking for personal and credit card information until the very end of the checkout procedure .............................................................................................. 39 4.3 Security ............................................................................................................. 39 4.3.1 Provide safe and secure transactions and make sure the user knows it ........ 39 4.3.2 Provide a possibility to move certain risky actions, such as payment, to a trusted third party, such as Pay Pal or BidPay .............................................................. 40 1 Graphical design 1.1 Layout 1.1.1 The layout should harmonize with the content of the website. It is imperative that the layout of a website mediates the message that the website tries to send out [8]. The users should never have to wonder what kind of site they visit. Different websites will need different layouts. A layout that works perfectly for a website that put cars on the market, will probably not work at all for a website that sells wedding articles (Figure 1, 2). Below are two extremely different layouts. Both of these layouts are excellent for their specific purpose. ![Figure 1. Example of a good layout that harmonizes with the content of the website (www.saab.com).](image) The website in the figure above sells cars (Figure 1). The straight lines and the simplistic but yet powerful layout works perfectly for this site. The website in the figure below sells wedding articles (Figure 2). The layouts of the two websites are as different as night and day. But that does not mean that one of them is right and the other one is wrong. They both harmonize nicely with the content of the websites and the message they want to send. Below there is an example of a website, belonging to a kennel, where the layout definitely does not harmonize with the content (Figure 3). The users that surfed in to this website would not know what it was about until they read the text. Figure 3. Example of a poor layout that does not harmonize with the content of the website. (www.slaboda.se). ### 1.1.2 The color should harmonize with the content of the website. The choice of colors should harmonize with the content of the website [8]. Developers have to use colors that send the message of what sort of website it is. They might have to ask themselves what colors are associated to the type of website they are creating. Below there are four examples of websites where the colors scheme matches the content (Figure 4). There is a Gothic, bridal, gardening, and baby website. The developer of the Gothic website has chosen black as the main color. Gothic is definitely associated with black. The developer of the bridal website has chosen pink and white. White is often thought of as the color of weddings and pink is a color associated with girls. The developer of the gardening website has taken his colors from nature. Green is often associated with plants and growth. The developer of the baby website has chosen light pastel colors, which is often associated with babies. The pages are all extremely different. But a color that works perfectly for one website, might not work at all for another. Just imagine the Goth website with bright pastel colors. 1.1.3 The layout should be consistent throughout the website. Consistency in the layout is especially significant for the users’ sense of orientation on the website [8]. If the navigation bar is located on the left side of the website’s first page, it is not a good idea to move it somewhere else on some other page. The user might find it hard to locate the navigation bar if it is moved. 1.1.4 The colors should be consistent throughout the website. Keep the same color scheme throughout the entire website. Switching colors may confuse the customers who might believe they have entered another website by mistake. It is also more aesthetically appealing if the website has the same color scheme on every page [8]. 1.1.5 Consider using web safe colors. When choosing colors for the website, the designer needs to consider using web safe colors [8]. Most browsers today can show millions of colors. But not everyone has a modern web browser. Some people still use old browsers that only show 256 colors. Therefore, to make sure that the website looks the same to everyone, web safe colors is a wise choice. There are 216 web safe colors. The remaining 40 colors out of the 256 are reserved for the use of the operating system. Below there is any image of the 216 web safe colors [9] (Figure 5). 1.1.6 **The width of the website should be smaller than the browser window.** Internet users dislike horizontal scrolling, they want to see the whole width of the page. To avoid horizontal scrolling, the width of a page on the website should be smaller than the width of the browser window [7]. 1.2 **Text** 1.2.1 **Use sans-serifs.** Use sans-serifs when writing body-text for a website. This will make the text more effortless, for the visitor, to read [14]. In typography, a sans-serif font is one that does not have the small features called "serifs" at the end of strokes [14]. **Sans-serif Not Sans-serif** Figure 6. Sans-serif and Serif. Sans-serif fonts have become the de facto standard for body text on-screen, especially online because electronic screens such as computer monitors or otherwise provide a cleaner and more legible rendering of sans-serif fonts than they do for serif fonts. This is also true of typography on television; serif fonts are rarely used on a TV channel due to the flickering which can easily occur when they are employed. 1.2.2 Use common fonts. When choosing a font, restrain the use of fonts to the most common ones. If a website contains a font that is not installed on the visitors’ computer, that font will be substituted by a font that is, which can distort the layout [8]. Below there is a table showing the forty most common fonts installed on computers today. The percentage shows on how many percent of the computers the font in question is installed (Figure 7). If the use of an unusual font is necessary, define in your code an alternate font to be used in case the visitors of the website do not have the chosen font installed on their computer. This way the choice of substitution font can be controlled. If the use of a certain font is absolutely necessary, and a substitution is not acceptable, the best way is to use an image format. 1.2.3 **Do not mix more than three fonts.** The use of more than one font can be a powerful tool. But a mix of too many fonts appears cluttered. 1.2.4 **Make sure there is contrast between text and background.** Contrast is the difference in visual properties that makes text distinguishable from the background (Figure 8). Contrast between text and background is imperative since the lack thereof can make the text on a website almost impossible to read [8] (Figure 9). ![Figure 8. Examples of good contrast.](image) ![Figure 9. Examples of poor contrast.](image) 1.2.5 **Do not use too small font size.** Too small font sizes are hard to read for the user. Browsers usually have option of changing the font size, but most likely the users will not bother [8]. 2 **Information design** 2.1 **In general** 2.1.1 **If using images to break up a text make sure the images are relevant to the text.** A good way to break up a long text, and make it easier to read, is to insert images into the text. But make sure that the inserted image is relevant to the text in question [6]. 2.2 Product information 2.2.1 Categorize the products using a method that is meaningful for the customers. When categorizing the products, make sure to do it using a method that is meaningful to the customers [7]. Many developers make the mistake of arranging the products using a method that makes sense from an administrative perspective. If it is complicated for the customers to find what they want on a website, they will find it somewhere else. Therefore, it is imperative to organize the products with the customers in mind. 2.2.2 The depth of the categories should be no more than three. Too many levels of depth might be confusing for the customers; they might feel lost in the navigation [7]. Three is the recommended maximum of levels that should be used. The number of levels can exceed three if there is a good reason as to why. 2.2.3 Always provide accurate and detailed information about the products. It is essential that the product information is as detailed and accurate as possible [7]. The customers want to know what they are buying. They often read the text and make sure that the product is what they want. And if they order a specific product, they do not want to find out that the product in question does not live up to the expectations, due to an insufficient product description. 2.2.4 Present the size of the products in a measurable and comparable way. The customers may need to know the size of a product in order to know whether it will fit into the place that they planned on. Therefore, they will need to know the exact measurements. Make sure the measurements are correct. Inaccurate measurements could potentially cause the customers great problems [7]. 2.2.5 Facilitate comparison of products. When looking at several different products of the same type, trying to figure out which one to buy, it might not be that easy to keep all the details in mind. This makes a comparison of different products difficult. In order to facilitate this process for the customer, it is a good idea to provide a function for comparison [7]. Many of the larger e-commerce websites already provide this feature. Below there is an example from Sears e-commerce website (Figure 10). All the customers have to do is to check the box to the right of the products they wish to compare, and then press the compare button at the top right corner. When the customer has pressed the compare button the comparison view appears (Figure 11). This view lets the customers compare different attributes of the products in a simple way. 2.2.6 Present inventory information of the products. When customers order items online, they do not want to wait a long time for the products to be delivered. The delivery time might have an impact on where the customers decide to order their product from. If the customers find out that the company does not have the product in stock after they have placed the order and that the waiting time will actually be longer than expected, they will probably shop somewhere else in the future. Always present inventory information on the website [7]. This way the customers will know what to expect, and will not be disappointed and focus elsewhere in the future. They might go somewhere else for a specific product. But they will appreciate the honesty, and they are likely to return. 2.2.7 Always show images of the products. That an image says more than a thousand words is true. No matter how well the product is described, nothing will describe it better than an image. The users can not touch, feel or smell the product, but they can to see it. And they definitely want to [7]. 2.2.8 Show thumbnails of the products. The images provided on the website do not have to be large images right away. It is best to use thumbnails to present the products [7] (Figure 12). And let the users decide for themselves whether they would like to see a larger image or not. ![Figure 12. Example of products presented as thumbnails (www.sears.com).](image) On most e-commerce websites, a larger image and more detailed product information will show up if the customer click on the thumbnail image (Figure 13). 3 Interaction design 3.1 In general 3.1.1 Put the usability and user experience goals in focus. While working on the development of the interaction design make sure to keep the usability and user experience goals in focus. Not all of them apply in every case, but it is a developer’s responsibility to know which ones who do and which ones who do not [12]. 3.1.2 Let the users be a part of the development process. Developers and users have different views on numerous issues. A developer might believe that a solution is simple to understand and easy to use, while a user might find the solution complicated to understand and hard to use. This is the reason why the users should be involved during the development of a website. The users are the ones who will be using it, and their input on the development process is imperative [12]. 3.2 Shopping cart 3.2.1 Provide a way to place a product in the shopping cart from the thumbnail view. There are some customers who do not need or want to compare products or to look more closely at a certain product. These customers have already decided what they want to purchase. In order to make the website more efficient to use for these customers, provide a way to place a product in the shopping cart without them having to click their way to the page that contains product information and a larger image. This will save the customers some time and they will leave the website feeling satisfied. ![Figure 14. An example shows how easy it would have been to make it possible for the customers to place a product in the shopping cart without them having to go to the product page (www.shop.com).](image) 3.2.2 Provide a way to place a product in the shopping cart from the product page. Once the customers have read through the product information, it is imperative that it is obvious how to order the product. Position a button for placing the product in the shopping cart somewhere on the product page. This way the customers do not have to go back to the page with the thumbnails to order a product. 3.2.3 Provide a field where the customer can state the quantity of products wanted. Some customers might want to purchase more than one of each item. Therefore, always provide a field where the customers can state the quantity of products they want to place in the shopping cart. The preset default quantity should always be one. 3.2.4 Let the customers look in to their own shopping carts. When customers shop at a regular store, they might look in to their shopping cart to see if they have forgotten to buy anything important. The same thing should be possible on an e-commerce website. The users should be given the possibility to look in to their shopping cart as they are shopping, not only at the check-out. They should be able to see what products are in the shopping cart, the quantity and price of each product, the total price, and if possible the price of shipping. The price of shipping is not always possible to show since it might depend on where the products are shipped. 3.2.5 Let the customers remove products from the shopping cart. A possibility to remove products from the shopping cart should definitely be provided to the customers. It would not be pleasing to the customers to have to start all over again because they put the wrong product in the shopping cart and could not remove it. It should be simple and self-explanatory how to delete a product. Buttons are a natural method to show that something is clickable. The text on the button will provide an explanation what the button does (Figure 16). Watch out so that the method to remove the item does not blend in to the rest of the text and gets lost (Figure 17). 3.2.6 *Let the customers change the quantity of a product in the shopping cart.* If the user wishes to change the quantity of a certain product in the shopping cart, this should be possible. It would be incredibly annoying if the customers had to remove all of the products and then add some again just because it was not possible to change the quantity. 3.2.7 *Provide an explanation of how to administrate the shopping cart.* Interaction design should always be made with the user in mind. However, sometimes there are still some users that do not understand how the shopping cart and its functions work. Provide an easy-to-read explanation that the customers can turn to in case of confusion. 3.2.8 *Provide a way to start the check-out procedure from the shopping cart.* Many customers finish up their shopping by taking a final look in the shopping cart. Therefore, it is always a good thing to provide a way to go straight from the shopping cart to the check-out. 3.3 *Check-out* 3.3.1 *Let the customers know where they are in the check-out procedure.* Let the customers know which step in the check-out procedure that they are at. The check-out procedure is often the less liked part of the shopping experience. By letting the customers know where they are at, they will also know how far they have to go before they have completed their purchase. 3.3.2 *Provide help to fill out different fields or chose between different options.* The check-out procedure often includes filling out forms and making choices. This can be stressful and difficult if the user does not know how. Provide examples to help the users fill out the forms. Provide information about the different options to help the users to make the choice that is best for them. Any kind of service that will make it easier for the users to walk through the check-out procedure will be greatly appreciated. 4 Trust 4.1 Functionality 4.1.1 Make sure the website does what is supposed to do. Technical competence is a key factor when it comes to gaining the customers' trust. Always make sure that the website is fully functional. How well the website works reflects on the people behind the creation. A dysfunctional website indicates incompetence [3]. How are customers supposed to trust a website with their personal and credit card information if the person behind it is incompetent? 4.1.2 Make sure the spelling is correct. As mentioned above, appearance is imperative. Misspelled words can affect the customers’ opinion of the website. Although, spelling may not seem all that important, it truly is [3]. 4.1.3 Make sure there are no dead images. Make sure there are no dead images on the website [3]. The customers expect the website to be updated regularly. If the website does not function properly, it provides an unprofessional impression. Customers do not want anything to do with an unprofessional website. 4.1.4 Make sure there are no broken links. Make sure there are no broken links on the website [3]. If the link does not work, remove it immediately. Do not waste the customers’ time, sending them to websites that are no longer there. This will make the customers annoyed, and an annoyed customer might not return to the website. 4.1.5 Make sure that the internal search engine yield proper results. It is essential that the internal search engine on the website yield proper results [3]. If it does not, customers might not find the product they are searching for and leave the website believing that the product is not there, even though it might be. This is an unnecessary way to lose customers. Developing a functional search engine might not be a simple thing to do. However, there are other options. Google provides a free custom search engine (Figure 13). This custom search engine can be set to search only certain websites. It can be used by e-commerce websites where they could choose that the search engine should search only that certain e-commerce site. The search engine is then placed on the website for customers to use. The e-commerce website gets a free search engine and Google acquires free commercial. 4.2 Privacy 4.2.1 Do not make the user log in until the checkout procedure. If customers surf on to a website and are not allowed to look at the products without logging in, they will probably just move on. Since they have not yet seen the products, they do not know whether the products are worth their hassle. Most likely they can go somewhere else to see the same products without having to log in, and most likely they will [3]. 4.2.2 Do not ask for unnecessary information. Do not ask the customers for unnecessary information. All the customers want to do is to buy a product, pay for it and have it sent to their home. They do not wish to answer questions about their personal life and about their shopping habits [3]. 4.2.3 Post an easy-to-read privacy statement The customers want to be sure that their personal information will be handled with care. To reassure the customer that you will not sell their personal information to the highest bidder, post an easy-to-read statement on the website [2]. 4.2.4 Avoid asking for personal and credit card information until the very end of the checkout procedure. The customers are rarely completely comfortable providing a website with their credit card number, especially if they are not sure they will buy something. They do not want to provide it until they are ready to check out. Therefore, make sure that the customers do not have to provide their credit card information until the very last step of the checkout procedure [3]. 4.3 Security 4.3.1 Provide safe and secure transactions and make sure the user knows it. Provide the safest and most secure transaction that the business can offer. And let the customers know that this service is provided. This induces trust [2]. 4.3.2 Provide a possibility to move certain risky actions, such as payment, to a trusted third party, such as Pay Pal or BidPay. For some customers, it might feel safer to use a trusted third party to handle the payment transaction. The website needs to provide the customers with this possibility for there are many options to select from. The smart thing would be to use one of the well known ones that the customers recognize and trust [3].
{"Source-Url": "http://www.diva-portal.org/smash/get/diva2:119719/FULLTEXT01.pdf", "len_cl100k_base": 12692, "olmocr-version": "0.1.50", "pdf-total-pages": 41, "total-fallback-pages": 0, "total-input-tokens": 69299, "total-output-tokens": 14794, "length": "2e13", "weborganizer": {"__label__adult": 0.0009765625, "__label__art_design": 0.029693603515625, "__label__crime_law": 0.00081634521484375, "__label__education_jobs": 0.0302886962890625, "__label__entertainment": 0.0005955696105957031, "__label__fashion_beauty": 0.0008211135864257812, "__label__finance_business": 0.0204925537109375, "__label__food_dining": 0.0009222030639648438, "__label__games": 0.0025691986083984375, "__label__hardware": 0.0021953582763671875, "__label__health": 0.0006895065307617188, "__label__history": 0.0010576248168945312, "__label__home_hobbies": 0.00044655799865722656, "__label__industrial": 0.0009670257568359376, "__label__literature": 0.001514434814453125, "__label__politics": 0.0005469322204589844, "__label__religion": 0.0008730888366699219, "__label__science_tech": 0.01464080810546875, "__label__social_life": 0.00019168853759765625, "__label__software": 0.03485107421875, "__label__software_dev": 0.8525390625, "__label__sports_fitness": 0.00042939186096191406, "__label__transportation": 0.0011262893676757812, "__label__travel": 0.0005779266357421875}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 63088, 0.03651]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 63088, 0.18621]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 63088, 0.9153]], "google_gemma-3-12b-it_contains_pii": [[0, 235, false], [235, 1441, null], [1441, 2513, null], [2513, 5208, null], [5208, 7586, null], [7586, 9848, null], [9848, 10404, null], [10404, 12062, null], [12062, 14539, null], [14539, 16286, null], [16286, 18767, null], [18767, 19614, null], [19614, 20680, null], [20680, 23332, null], [23332, 26064, null], [26064, 28185, null], [28185, 28715, null], [28715, 29875, null], [29875, 31323, null], [31323, 31334, null], [31334, 33687, null], [33687, 34542, null], [34542, 41115, null], [41115, 41958, null], [41958, 43114, null], [43114, 44453, null], [44453, 45933, null], [45933, 46663, null], [46663, 47456, null], [47456, 47835, null], [47835, 48918, null], [48918, 51288, null], [51288, 51469, null], [51469, 53070, null], [53070, 53912, null], [53912, 55458, null], [55458, 56778, null], [56778, 58665, null], [58665, 60905, null], [60905, 62644, null], [62644, 63088, null]], "google_gemma-3-12b-it_is_public_document": [[0, 235, true], [235, 1441, null], [1441, 2513, null], [2513, 5208, null], [5208, 7586, null], [7586, 9848, null], [9848, 10404, null], [10404, 12062, null], [12062, 14539, null], [14539, 16286, null], [16286, 18767, null], [18767, 19614, null], [19614, 20680, null], [20680, 23332, null], [23332, 26064, null], [26064, 28185, null], [28185, 28715, null], [28715, 29875, null], [29875, 31323, null], [31323, 31334, null], [31334, 33687, null], [33687, 34542, null], [34542, 41115, null], [41115, 41958, null], [41958, 43114, null], [43114, 44453, null], [44453, 45933, null], [45933, 46663, null], [46663, 47456, null], [47456, 47835, null], [47835, 48918, null], [48918, 51288, null], [51288, 51469, null], [51469, 53070, null], [53070, 53912, null], [53912, 55458, null], [55458, 56778, null], [56778, 58665, null], [58665, 60905, null], [60905, 62644, null], [62644, 63088, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 63088, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 63088, null]], "pdf_page_numbers": [[0, 235, 1], [235, 1441, 2], [1441, 2513, 3], [2513, 5208, 4], [5208, 7586, 5], [7586, 9848, 6], [9848, 10404, 7], [10404, 12062, 8], [12062, 14539, 9], [14539, 16286, 10], [16286, 18767, 11], [18767, 19614, 12], [19614, 20680, 13], [20680, 23332, 14], [23332, 26064, 15], [26064, 28185, 16], [28185, 28715, 17], [28715, 29875, 18], [29875, 31323, 19], [31323, 31334, 20], [31334, 33687, 21], [33687, 34542, 22], [34542, 41115, 23], [41115, 41958, 24], [41958, 43114, 25], [43114, 44453, 26], [44453, 45933, 27], [45933, 46663, 28], [46663, 47456, 29], [47456, 47835, 30], [47835, 48918, 31], [48918, 51288, 32], [51288, 51469, 33], [51469, 53070, 34], [53070, 53912, 35], [53912, 55458, 36], [55458, 56778, 37], [56778, 58665, 38], [58665, 60905, 39], [60905, 62644, 40], [62644, 63088, 41]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 63088, 0.13348]]}
olmocr_science_pdfs
2024-12-02
2024-12-02
8f1613e7f20a7cb7f205a1d96341e9cbd3563067
Matching Constraints for the Lambda Calculus of Objects Viviana Bono Dipartimento di Informatica, Università di Torino C.so Svezera 185, I-10149 Torino, Italy e-mail: bono@di.unito.it Michele Bugliesi Dipartimento di Matematica, Università di Padova Via Belzoni 7, I-35131 Padova, Italy e-mail: michele@math.unipd.it Abstract. We present a new type system for the Lambda Calculus of Objects [16], based on matching. The new system retains the property of type safety of the original system, while using implicit match-bounded quantification over type variables instead of implicit quantification over row schemes (as in [16]) to capture Mytype polymorphic types for methods. Type soundness for the new system is proved as a direct corollary of subject reduction. A study of the relative expressive power of the two systems is also carried out, that shows that the new system is as powerful as the original one on derivations of closed-object typing judgements. Finally, an extension of the new system is presented, that gives provision for a class-based calculus, where primitives such as creation of class instances and method update are rendered in terms of delegation. 1 Introduction The problem of deriving safe and flexible type systems for object-oriented languages has been addressed by many theoretical studies in the last years. The interest of these studies has initially been focused on class-based languages, while, more recently, type systems have also been proposed for object-based (or delegation-based) languages. Clearly, the work on the latter has been strongly influenced by the study of the former. For example, the notion of row-variables introduced by [18] to type extensible records was refined in [16, 7, 17, 5] to type extensible objects. Similarly, recursive object types have first been used to provide functional models of class-based languages [11, 9, 12, 14, 13], and then applied to the case of an object calculus supporting method override in presence of subsumption [3]. A further notion that has been studied extensively in class-based languages (as well as in the record calculus of [10]) is that of (F-)bounded quantification as a tool for modeling the subclass relation. Following this line of research, in this paper we investigate the role of matching in the design of a type system for the delegation-based Lambda Calculus of Objects [16]. Matching is a relation over object types that has first been introduced by [8] as an alternative to F-bounded subtyping [13] in modeling the subclass relation in class-based languages, and then as a complement to subtyping to model method inheritance between classes [1, 2]. The Lambda Calculus of Objects [16] is a delegation-based calculus where method addition and override, as well as method inheritance, all take place at the object level rather than at the class level. In [16] a type system for this calculus is defined, that provides for static detection of errors, such as message not understood, while at the same time allowing types of methods to be specialized to the type of the inheriting objects. This mechanism, that is commonly referred to as Mytype specialization, is rendered in the type system in terms of a form of higher-order polymorphism which, in turn, uses implicit quantification over row schemes to capture the underlying notion of protocol extension. The system we present in this paper takes a different approach to the rendering of Mytype specialization, while retaining the property of type safety of the original system. Technically, the new solution is based on implicit match-bounded quantification over type variables to characterize methods as functions with polymorphic types, and to enforce correct instantiation of these types as methods are inherited. A similar solution for the polymorphic typing of methods in Lambda Calculus of Objects is proposed in [6]. The key difference, with respect to the system of this paper, is that [6] uses subtyping, instead of matching, and (implicit) subtype-bounded quantification. There appear to be fundamental tradeoffs between the two solutions: in fact, while subtyping has the advantage of allowing object subsumption, matching appears to be superior to subtyping in the rendering of the desired typing of methods. The reason is explained, briefly, as follows: in order to ensure safe uses of subsumption, the system of [6] allows type promotion for an object-type only when the methods in the promoted type do not reference any of the methods of the original type. As in [7], labeled types are used to encode the cross references among methods in the methods’ types. In [6], however, labeled types involve some additional limitations over [7] for subsumption, and require a rather more complex bookkeeping that affects the typing of methods as well. Relying on matching, instead, has the advantage of isolating the typing of methods from subtyping, thus allowing a rather elegant and simple rendering of the method polymorphism. The simplicity of the resulting system also allows us to draw a formal analysis of the relationship between the original system and ours. In particular, we show that every closed-object typing judgement derivable in [16] is also derivable in our system. We then show that the new system may naturally be extended to give provision for a class-based calculus, where subclassing, and primitives such as creation of class instances and method update are rendered in terms of delegation. The rest of the paper is organized as follows. In Section 2, we review the untyped calculus of [16]. In Section 3, we present the new typing rules for objects and we prove type soundness. In Section 4, we present the encoding of the type system of [16] into the new system. In Section 5, we present the extended system that gives provision for classes, and then we conclude in Section 6 with some final remarks. 2 The Untyped Calculus An expression of the untyped calculus can be any of the following: \[ e ::= x \mid e \mid \lambda x. e \mid e_1 \, e_2 \mid \langle \rangle \mid \langle e_1 \leftarrow m \Rightarrow e_2 \rangle \mid \langle e_1 \leftarrow m = e_2 \rangle \mid e \leftarrow m \] where \( x \) is a variable, \( e \) a constant and \( m \) a method name. The reading of the object-related forms is as follows: - \( \langle \rangle \) is the empty object, - \( \langle e_1 \leftarrow m \Rightarrow e_2 \rangle \) extends object \( e_1 \) with a new method \( m \) having body \( e_2 \). - \( \langle e_1 \leftarrow m = e_2 \rangle \) replaces \( e_1 \)'s method body for \( m \) with \( e_2 \). - \( e \leftarrow m \) sends message \( m \) to object \( e \). The expression \( \langle e_1 \leftarrow m = e_2 \rangle \) is defined only when \( e_1 \) denotes an object that does not have an \( m \) method, whereas \( \langle e_1 \leftarrow m \Rightarrow e_2 \rangle \) is defined only when \( e_1 \) denotes an object that \emph{does} contain an \( m \) method. As in \cite{16}, both these conditions are enforced statically by the type system. The other main object operation is method invocation, which comprises two separate actions, \emph{search} and \emph{self-application}: evaluating the message \( e \leftarrow m \) requires a search, within \( e \), of the body of the \( m \) method which is then applied to \( e \) itself. To formalize this behavior, we introduce a subsidiary object expression, \( e \leftarrow m \), whose intuitive semantics is as follows: evaluating \( e \leftarrow m \) results into a recursive traversal of the “sub-objects” of \( e \), that succeeds upon reaching the right-most addition or override of the method in question. The operational semantics \( \xrightarrow{\text{eval}} \) of the untyped calculus can be thus defined as the reflexive, transitive and contextual closure of the reduction relation defined below (\( \leftarrow \) stands for both \( \leftarrow \) and \( \leftarrow \)) \[ \begin{align*} (\beta) & \quad (\lambda x. e_1) \, e_2 & \xrightarrow{\text{eval}} \ [e_2/x] \, e_1 \\ (\leftarrow) & \quad e \leftarrow m & \xrightarrow{\text{eval}} \ (e \leftarrow m) \, e \\ (\leftarrow \text{ suc}) & \quad \langle e_1 \leftarrow m \Rightarrow e_2 \rangle \leftarrow m & \xrightarrow{\text{eval}} \ e_2 \\ (\leftarrow \text{ next}) & \quad \langle e_1 \leftarrow m = e_2 \rangle \leftarrow m & \xrightarrow{\text{eval}} \ e_1 \leftarrow m \\ (fail \ \langle \rangle ) & \quad \langle \rangle \leftarrow m & \xrightarrow{\text{eval}} \ \text{err} \\ (fail \ \text{ abs}) & \quad \lambda x. e \leftarrow m & \xrightarrow{\text{eval}} \ \text{err} \end{align*} \] plus a few additional reductions for error propagation (see Appendix A). The use of the search operator expressions in our calculus is inspired to \cite{7}, and it provides a more direct and concise technical device than the \emph{bookkeeping} relation originally introduced in \cite{16}. 3 Object Types and Matching Object types have the same structure as in [16]: an object type has the form \[ \text{Obj } t. \{m_1: \tau_1, \ldots, m_k: \tau_k\} \] where the \( m_i \)'s are method names, whereas the \( \tau_i \)'s are type expressions. The row \( \{m_1: \tau_1, \ldots, m_k: \tau_k\} \) defines the interface or protocol of the objects of that type, i.e. the list of the methods (with their types) that may be invoked on these objects. The binder \( \text{Obj} \) scopes over the row, and the bound variable \( t \) may occur free within the scope of the binder, with every free occurrence referring to the object type itself. \( \text{Obj} \)-types are thus a form of recursively-defined types, even though \( \text{Obj} \) is not to be understood as a fixed-point operator: as in [16], the self-referential nature of these types is axiomatized directly by the typing rules, rather than defined in terms of an explicit unfolding rule. 3.1 Types and Rows Type expressions include type-constants, type variables, function types and object types. The sets of rows and types are defined recursively as follows: \[ \begin{align*} \text{Rows} & \quad R ::= \{\} \mid \{R \mid m: \tau\} \\ \text{Types} & \quad \tau ::= b \mid v \mid \tau \rightarrow \tau \mid \text{Obj } t. R. \end{align*} \] The symbol \( b \) denotes type constants, \( t, u \), and \( v \) denote type variables, whereas \( \tau, \sigma, \rho, \ldots \) range over types; all symbols may appear indexed. Row expressions that differ only for the name of the bound variable, or for the order of the component \( m: \tau \) pairs are considered identical. More formally, \( \alpha \)-conversion of type variables bound by \( \text{Obj} \), as well as applications of the principle: \[ \{\{R \mid n: \tau_1\} \mid m: \tau_2\} = \{\{R \mid m: \tau_2\} \mid n: \tau_1\}, \] are taken as syntactic conventions rather than as explicit rules. The structure of valid contexts (see Appendix B) is defined as follows: \[ \Gamma ::= \epsilon \mid \Gamma, x : \tau \mid \Gamma, u \ll \tau, \] Correspondingly, the judgements are \( \Gamma \vdash s \), \( \Gamma \vdash e : \tau \), \( \Gamma \vdash \tau_1 \ll \tau_2 \), where \( \Gamma \vdash s \) stands for “\( \Gamma \) is a well-formed context”, and the reading of the other judgements is standard. As an important remark, we note that, as in [6] and in contrast to [16], rows in our system are formed only as “ground” collections of pairs “method-name: type”. One advantage of this choice is a simplified notion of well-formedness for rows: instead of the kinding judgements of [16], in our system this notion is axiomatized, syntactically, as follows. Let \( \mathcal{M}(R) \) denote the set of method names of the row \( R \) defined inductively as follows: \[ \mathcal{M}(\{\}) = \{\} \quad \text{and} \quad \mathcal{M}(\{R \mid m: \tau\}) = \mathcal{M}(R) \cup \{m\}. \] Then, we say that a row is well formed if and only if it is (i) either the empty row \( \{\} \), or (ii) a row of the form \( \{R \mid m: \tau\} \) with \( R \) well formed and \( m \notin \mathcal{M}(R) \). 3.2 Matching Matching is the only relation over types that we assume in the type system; it is a reflexive and transitive relations over all types, while for Obj-types it also formalizes the notion of protocol extension needed in the typing of inheritance. The relation we use here is a specialization of the original matching relation [8], defined by the following rule ($\overline{m;r}$ is short for $m_1;r_1,\ldots,m_k;r_k$): $$ \Gamma \vdash \text{\textit{well formed}} \\ \Gamma \vdash \text{Obj} \; t \; \langle \overline{m};r \rangle \quad \langle \# \rangle \\ \Gamma \vdash \text{Obj} \; t \; \langle \overline{m};r \rangle $$ Unlike the original definition [8], that allows the component types of a Obj-type to be promoted by subtyping, our definition requires that these types coincide with the component types of every Obj-type placed higher-up in the $\langle\#\rangle$-hierarchy. Like the original relation, on the other hand, our relation has the peculiarity that it is not used in conjunction with a subsumption rule. As noted in [2], this restriction is crucial to prevent unsound uses of type promotion in the presence of method override. 3.3 Typing Rules for Objects For the most part, the type system is routine. The object-related rules are discussed below. The first defines the type of the empty object (whose type is the top of object-types in the $\langle\#\rangle$-hierarchy): $$ \Gamma \vdash \emptyset $$ The typing rule for method invocation has the following format: $$ \Gamma \vdash e : \sigma \quad \Gamma \vdash \text{Obj} \; t \; \langle n;r \rangle \quad (\text{send}) $$ As in [16], the substitution for $t$ in $r$ reflects the recursive nature of object types. In order for a call to an $n$ method on an object $e$ to be typed, we require that $e$ has any type containing the method name $n$. An interesting aspect of the above rule is that the type $\sigma$ may either be a Obj-type matching $\text{Obj} \; t \; \langle n;r \rangle$, or else an unknown type (i.e. a type variable) occurring (match-bounded) in the context $\Gamma$. Rules like (send) are sometimes referred to as structural rules [1], and their use is critical for an adequate rendering of MyType polymorphism: it is the ability to refer to possibly unknown types in the type rules, in fact, that allows methods to act parametrically over any $u \langle\#\rangle A$, where $u$ is the type of self, and $A$ is a given Obj-type. The next rule defines the typing of an object-extension with a new method: $$ \Gamma \vdash e_1 : \text{Obj} \; t \; \langle \overline{m};p \rangle \\ \Gamma, u \langle\#\rangle \text{Obj} \; t \; \langle \overline{m};p, n;r \rangle \vdash e_2 : [u/t](t\rightarrow r) \\ \quad \quad n \not\in \mathcal{M}(\langle \overline{m};p \rangle) \\ \Gamma \vdash \langle e_1 \leftarrow n \rangle : \text{Obj} \; t \; \langle \overline{m};p, n;r \rangle $$ (ext). Typing the method addition for \( n \) requires (i) that the \( n \) method be not in the type of the object \( e_1 \) that is being extended, and (ii) that the protocol of the resulting object contains at least the \( n \) method as well as the \( m \) methods needed to type the body \( e_2 \) of \( n \). The typing of a method override is defined similarly. As for the \((\text{send})\) rule, the generality that derives from the use of the type \( \sigma \) is needed to carry out derivations where the \((\text{over})\) rule is applied with \( e_1 \) variable (e.g. \( \text{self} \)). \[ \begin{align*} \Gamma \vdash e_1 : \sigma & \quad \Gamma \vdash \sigma \not\equiv \text{Obj} \ t \ \{m_\rho \cdot n : \tau\} \\ \Gamma, u \not\equiv \text{Obj} \ t \ \{m_\rho \cdot n : \tau\} & \vdash e_2 : [u/f](t \rightarrow \tau) \\ \hline \Gamma \vdash \langle e_1 \leftarrow n = e_2 \rangle : \sigma \end{align*} \] (over). We conclude with the rule for typing a search expression: \[ \begin{align*} \Gamma \vdash e : \sigma & \quad \Gamma \vdash \sigma \not\equiv \text{Obj} \ t \ \{n : \tau\} \\ \Gamma, \varsigma \not\equiv \sigma & \vdash e \leftarrow \varsigma : \varsigma/f \ (t \rightarrow \tau) \\ \hline \Gamma \vdash e \leftarrow \varsigma : \varsigma/f \ (t \rightarrow \tau) \end{align*} \] (search). Once more we assume a possibly unknown type for \( e \): typing a search requires, however, more generality than typing a method invocation because the search of a method encompasses a recursive inspection of the recipient object (i.e. of \( \text{self} \)). This explains the intuitive roles of the two types \( \varsigma \) and \( \sigma \) in the above rule: \( \varsigma \) is the type of the \( \text{self} \) object, to which the \( n \) message was sent and to which the body of \( n \) will be applied; \( \sigma \), on the other hand, is the type of \( e \), the sub-object of \( \text{self} \) where the body of \( n \) method is eventually found while searching within \( \text{self} \). 3.4 An Example of Type Derivations We conclude the description of the type system with an example that illustrates the use of the typing rules in typing derivations. The example is borrowed from [16], and shows that the type system captures the desired form of method specialization. The following object expression represents a point object with an \( x \) coordinate and a \texttt{move} method: \[ \text{pt} \equiv \langle \langle x = \lambda \text{self} \cdot 3 \rangle \leftarrow \text{move} = \lambda \text{self} \cdot \lambda dx . \langle \text{self} \leftarrow x = \lambda x . (\text{self} \leftarrow x + dx) \rangle \rangle. \] Below, we sketch the derivation of the judgement \( \varepsilon \vdash \text{pt} : \text{Obj} \ t \ \{x : \text{int}, \text{move} : \text{int} \rightarrow t\} \), using the assumption \( \varepsilon \vdash \langle x = \lambda \text{self} \cdot 3 \rangle : \text{Obj} \ t \ \{x : \text{int}\} \). Consider then defining \( \text{cp} \) as a new point, obtained from \( \text{pt} \) with the addition of a \texttt{color} method, namely: \( \text{cp} \equiv \langle \langle \text{pt} \leftarrow \text{color} = \lambda \text{self} \cdot \text{blue} \rangle \rangle \). With a similar derivation, we may now prove that \( \text{cp} \) has type \( \text{Obj} \ t \ \{x : \text{int}, \text{move} : \text{int} \rightarrow t, \text{color} : \text{colors}\} \), thus showing how the type of \texttt{move} gets specialized as the method is inherited from a \texttt{pt} to a \texttt{cp}. 3.5 Type Soundness We conclude this section with a theorem of type soundness. We first show that types are preserved by reduction. **Theorem 1 [Subject Reduction]**. If $e_1 \rightarrow^{e_2}$ and the judgement $\Gamma \vdash e_1 : \tau$ is derivable, then so is the judgement $\Gamma \vdash e_2 : \tau$. The proof is omitted here due to the lack of space, and can be found in [4]. Type soundness follows directly as a corollary of Subject Reduction, for if we may derive a type for an expression $e$, then $e$ may not be reduced to `err` (which has no type). Hence we have: **Theorem 2 [Type Soundness]**. If $\varepsilon \vdash e : \tau$ is derivable, then $\varepsilon \rightarrow^{e_2}$ is wrong. 4 Relationship with the Type System of [FHM94] The relationship between our system and the system of [16] is best illustrated by looking at the example of Section 3.4, where we showed that the `move` method for the `pt` object may be typed with the following judgement: $$u \notin \# \text{Obj} \{x : \text{int, move : int} \rightarrow t\} \vdash \lambda \text{self.} \lambda x.(\text{self} \leftarrow x = \lambda s.(\text{self} \leftarrow x) + dx) : u \rightarrow \text{int} \rightarrow u$$ The corresponding judgement in the original system (cfr. [16], Section 3.4) is: $$r : T \rightarrow [x, \text{move}] \vdash \lambda \text{self.} \lambda x.(\text{self} \leftarrow x = \lambda s.(\text{self} \leftarrow x) + dx)$$ $$: [\text{Obj} \{r t \mid x : \text{int, move : int} \rightarrow t\} / t \rightarrow \text{int} \rightarrow t]$$ The two judgements have essentially the same structure, but the rendering of polymorphism is fundamentally different. In the original system, polymorphism is placed inside the row of the type $\text{Obj} \{r t \mid x : \text{int, move : int} \rightarrow t\}$, and arises from using the (second order) row variable $r$: instances of the $\text{Obj}$-type are obtained by substituting any well-kinded row (i.e., one that does not contain the names $x$ and move) for the row $rt$ that results from the application of $r$ to the type $t$. In our system, instead, we place polymorphism outside rows: the type of move is polymorphic in the type-variable $u$, and instances of this type are obtained by substituting any syntactically well-formed type that matches the bound $\text{Obj} t \{x:int, \text{move}:\text{int} \rightarrow t\}$ for $u$. As it turns out, the correspondence between polymorphic $\text{Obj}$-types of the original system, and the type-variables of our systems carries over to typing derivations. As a matter of fact, the correspondence works correctly as long as the polymorphic $\text{Obj}$-types are used in a “disciplined”, or regular way in typing judgements and derivations from [16]; it breaks, instead, in other cases. Consider, for instance, the following judgement: $$r : T \rightarrow [m], \quad e : \text{Obj} t \{t r t\} \vdash (e \leftarrow m \equiv \lambda s.s) : \text{Obj} t \{r t | m: t\}$$ While this judgement is derivable in [16], replacing the polymorphic $\text{Obj}$-types with the corresponding type variables fails to produce a derivable judgement in our system. There are several reasons for this, the most evident being that our (ext) rule requires a $\text{Obj}$-type (not a variable) in the type of the extended object. In general, the correspondence between row and type variables breaks whenever the same row-variable occurs in different polymorphic $\text{Obj}$-types of a derivation. Fortunately, however, it can be shown that such undesired uses of polymorphic $\text{Obj}$-type may always be dispensed with in derivations for closed-object typing judgements of the form $\varepsilon \vdash e : \tau$. The proof of this fact is rather complex, and requires a number of technical lemmas establishing some useful properties of the typing derivations of [16]. Due to the lack of space, below we only state the main result, referring the reader to [4] for full details. **Definition 3.** [4] Let $\varepsilon \vdash e : \tau$ be a judgement from [16], and let $\Xi$ be a derivation for this judgement. We say that $\Xi$ is regular if and only if every every row-variable of $\Xi$ occurs always within the same polymorphic $\text{Obj}$-type in $\Xi$. **Theorem 4.** [4] Every judgement of the form $\varepsilon \vdash e : \tau$ has a derivation in [16] if and only if it has a regular derivation. Using this result, we may then prove that every typing judgement of the form $\varepsilon \vdash e : \tau$ derivable in [16] is derivable also in our system. We do this, in the next subsection, introducing an encoding function that translates every regular derivation from [16] into a corresponding derivation in our system. Restricting to regular derivation is convenient in that it greatly simplifies the definition of the encoding; on the other hand, given the result established in Theorem 4, it involves no loss of generality for the judgements of interest. ### 4.1 Encoding the Fisher-Honsell-Mitchell Type System Throughout this subsection, types, contexts, judgements and derivations from [16] will be referred to as, respectively row-types, row-contexts, row-judgements. Also we will implicitly assume that they occur within regular derivations. Encoding of Types, Contexts and Judgements. The encoding of a row- type $\tau$ is the type $\tau^*$ that results from replacing every occurrence of a polymor- phic $\text{Obj}$-type with a corresponding type-variable. The correspondence between the polymorphic $\text{Obj}$-types of $\tau$ and the type-variables of $\tau^*$ may be established using any injective map from row-variables to corresponding type variables (this is because in every regular row-derivation there is a one-to-one correspondence between row-variables and polymorphic $\text{Obj}$-types). To ease the presentation, we will thus assume that the row-variables of regular derivations are all chosen from a given set $\mathcal{V}_r$, and that an injective map $\xi : \mathcal{V}_r \mapsto \mathcal{V}_t$ is given, where $\mathcal{V}_t$ is a corresponding set of type variables. Definition 5 [Encoding of Types]. Let $\tau$ be a row-type. The encoding of $\tau$, denoted by $\tau^*$, is defined as follows: $\tau^* = \tau$, for every type variable or type constant $\tau$; $\text{(}\tau_1 \rightarrow \tau_2)^* = \tau_1^* \rightarrow \tau_2^*$ $\text{(Obj}\, t.\{m_1; \tau_1, \ldots, m_k; \tau_k\})^* = \text{Obj}\, t.\{m_1; \tau_1^*, \ldots, m_k; \tau_k^*\}$ $\text{(Obj}\, t.\{\ell t | m_1; \tau_1, \ldots, m_k; \tau_k\})^* = \xi(\ell)$ It follows from the definition that the encoding of a “ground” type, i.e. one that does not contain any occurrence of row-variables, leaves the type unchanged; in other words, $\tau^*$ is equal to $\tau$, whenever $\tau$ is ground in the sense we just explained. The encoding of a row-context $\Gamma$ is more elaborate, and it is given with respect to the regular derivation where the context occurs. Definition 6 [Encoding of Contexts]. Let $\Gamma$ be a row-context of a regular derivation $\Sigma$, and let $\text{Obj}\, t.\{rt | \text{m}\}$ denote the polymorphic $\text{Obj}$-type of $\Sigma$ where $r$ occurs. The encoding of $\Gamma$, denoted by $\Gamma^*_e$, is defined as follows: $\varepsilon^*_e = \varepsilon$ $\text{(}\Gamma; t : T)^*_e = \Gamma^*_e$; $\text{(}\Gamma; r : \kappa)^*_e = \Gamma^*_e$, $\xi(\ell) \not\approx \text{Obj}\, t.\{\text{m}\}$ $\text{(}\Gamma; x : \tau)^*_e = \Gamma^*_e$, $x : \tau^*$. The definition is well-posed as every row-variable occurs in just one polymorphic Obj-type, $\Sigma$ being regular. Also note that the encoding of every valid row-context $\Gamma$ is a valid context, since every row-variable $r$ may occur at most once in $\Gamma$. The encoding of row-judgements is also given with respect to the regular derivation where they occur. Definition 7 [Encoding of Judgements]. Let $\Gamma \vdash e : \tau$ be a row-judgement of a regular derivation $\Sigma$. Then the encoding of this row-judgement is $\Gamma^*_e \vdash e : \tau^*$. Note that if $\varepsilon \vdash e : \tau$ is a derivable judgement, then its encoding is the judgement $\varepsilon^*_e \vdash e : \tau^*$ itself. This is easily seen as the type $\tau$ must be ground, the judgement being derivable. Encoding of Type Rules. The row-portion of the type system from \([16]\) has no counterpart in our system, as we axiomize well-formedness for rows syntactically. The encoding of a type rule for terms, instead, is the result of encoding the row-judgements in the conclusion and in the premises of the rule, with the exception of the rules \((send)\), \((ext)\) and \((over)\). **Definition 8 [Encoding of (send)].** \[ \begin{align*} \Gamma \vdash e & : \text{Obj}_t \langle R \mid \tau \rangle \quad \ast \\ (\Gamma \vdash e \iff m : \text{Obj}_t \langle R \mid \tau \rangle/\ell \tau) & \quad \Xi \\ \quad \implies \\ \Gamma^* & \vdash e : (\text{Obj}_t \langle R \mid \tau \rangle)^* \\ \Gamma^* & \vdash (\text{Obj}_t \langle R \mid \tau \rangle)^* \ast \# \text{Obj}_t \langle \text{m} \tau \rangle. \end{align*} \] where \(\Xi\) is the regular derivation where the rule occurs. The type \((\text{Obj}_t \langle R \mid \tau \rangle)^*\) may either be a \(t\text{Obj}\)-type, if \(R\) is a list of \(\text{m} \tau\) pairs, or the type variable \(u = \xi(r)\) if \(R = \{t + \ldots\}\). The two cases correspond respectively to messages to an object, and messages to self. As in \([16]\), they are treated uniformly in our type system. **Definition 9 [Encoding of (ext)].** \[ \begin{align*} \Gamma \vdash e_1 & : \text{Obj}_t \langle R \mid \tau \rangle \quad \ast \\ R, r : T & \rightarrow [\tau, n_1] \vdash e_2 : \text{Obj}_t \langle \text{r} t \mid \tau \rangle/\ell (t \rightarrow \tau) \\ (\Gamma \vdash e_1 \leftarrow n = e_2) & : \text{Obj}_t \langle R \mid \tau \rangle \\ \quad \implies \\ \Gamma^* & \vdash e_1 : \text{Obj}_t \langle R^* \mid \tau \rangle \\ (\Gamma^*, u \ast \text{Obj}_t \langle \text{m} \tau \rangle & \vdash e_2 : \text{Obj}_t \langle \text{m} \tau \rangle)^* \\ \Gamma^* & \vdash e_1 \leftarrow n = n : \text{Obj}_t \langle R^* \mid \tau \rangle \end{align*} \] where \(u = \xi(r)\), and \(\Xi\) is the regular derivation where the rule occurs. Note that the context \(\Gamma^*, u \ast \text{Obj}_t \langle \text{m} \tau \rangle\) is just the encoding, in \(\Xi\), of the row-context \(\Gamma, r : T \rightarrow [\tau, n_1]\). The notation \(R^*\) is consistent because, as we show in \([4]\), for every instance of the \((\text{ext})\) rule occurring in a regular derivation it must be the case that \(R\) is a ground row of the form \(\text{m} \tau\) for some methods \(\text{m}\) and types \(\tau\). The encoding of \((\text{over})\) is defined similarly to the \((\text{ext})\) case. **Theorem 10 [Completeness].** Let \(\varepsilon \vdash e : \tau\) be a row-judgement derivable in \([16]\). Then \(\varepsilon \vdash e : \tau\) is derivable in our system. **Proof.** Since \(\varepsilon \vdash e : \tau\) is derivable, the encoding of this judgement coincides with the judgement itself. Let then \(\Xi\) be a regular derivation for \(\varepsilon \vdash e : \tau\) (the existence of such a derivation follows from Theorem 4): to prove the claim, it is enough to show that the encoding (in \(\Xi\)) of every other judgement of \(\Xi\) is derivable in our system. Let then \( \Gamma' \vdash e' : \tau' \) be a judgement of \( \Xi' \), and let \( \Xi' \) be the sub-derivation of \( \Xi' \) rooted at \( \Gamma' \vdash e' : \tau' \). The proof is by induction on \( \Xi' \). The basis of induction, the (projection) case, follows immediately, and most of the inductive cases follow easily by induction. The only slightly more elaborate cases is when \( \Xi' \) ends up with (send). In this case the last rule of \( \Xi' \), and its encoding are, respectively: \[ \begin{align*} \Gamma \vdash e : &\text{Obj}\ t\ \{R\mid m\mid\tau\}\quad * \\ \Gamma \vdash e \Leftarrow \text{Obj}\ t\ \{R\mid m\mid\tau\} / t \Rightarrow \\ \Xi & \end{align*} \] \[ \begin{align*} \Gamma' \vdash e : &\text{Obj}\ t\ \{R\mid m\mid\tau\}^*\ \\ \Gamma'' \vdash &\text{Obj}\ t\ \{R\mid m\mid\tau\}^* \Leftarrow \text{Obj}\ t\ \{m\mid\tau\}^* \\ \Xi & \end{align*} \] That \( \Gamma'' \vdash e : (\text{Obj}\ t\ \{R\mid m\mid\tau\})^* \) is derivable follows from the induction hypothesis. For the other judgement in the premise, instead, we distinguish the two possible sub-cases. If \( (\text{Obj}\ t\ \{R\mid m\mid\tau\})^* = \text{Obj}\ t\ \{R^*\mid m\mid\tau\} \) then the judgement is question is derivable directly by (<#>). If, instead, \( (\text{Obj}\ t\ \{R\mid m\mid\tau\})^* \) is a type variable, say \( \xi(r) \), then it must be the case that \( R = \{rt\mid \overline{p}\overline{\sigma}\} \) for some \( \overline{p}\overline{\sigma} \). But then \( r \in \text{Dom}(\Gamma) \) and \( \text{Obj}\ t\ \{rt\mid \overline{p}\overline{\sigma},m\mid\tau\} \) is the polymorphic Obj-type for \( r \) in \( \Xi \). Hence, from Definition 6, we have that \( \xi(r) <\#\ \text{Obj}\ t\ \{\overline{p}\overline{\sigma},m\mid\tau\} \in \Gamma'' \), and then \( \Gamma'' \vdash (\text{Obj}\ t\ \{R\mid m\mid\tau\})^* \Leftarrow \text{Obj}\ t\ \{m\mid\tau\}^* \) is derivable by (<# proj) and (<# trans). \( \square \) ## 5 Classes Introducing classes relies on the idea of distinguishing two kinds of types, Class types whose elements are classes, and Obj types whose elements are instances created by the classes. This distinction is inspired by [17], but we use it here in a completely different way and with orthogonal purposes. ### 5.1 Class Types and Object Types Object types have the usual form \( \text{Obj}\ t\ \{m_1:\tau_1,\ldots,m_k:\tau_k\} \), with the difference that we now require that the component methods be instance-methods annotated by the superscript ‘. Class types, instead, have the form: \[ \text{Class}\ t\ \{m_1:\tau_1,\ldots,m_k:\tau_k,m_1:\sigma_1,\ldots,m_l:\sigma_l\} \] with the superscript ‘ distinguishing class-methods from the remaining instance-methods. The intention is to have each class define a set of class-methods for exclusive use of the class and its sub-classes, as well as a set of instance-methods for the instances of the class (and of the class 's sub-classes). Instance-methods may only invoke or override other instance-methods, so that classes are protected from updates caused by their instances; class-methods, instead, are not subject to this restriction. Every class defines (or inherits from its super-classes) at least one class-method - new - for creating new instances of that class. As in [17], instances of a class are created by packaging a class, an operation that does nothing but “sealing” the class, so that no methods may be added. Sealing a class changes its type into a corresponding \texttt{Obj} type, that results from hiding all of the class-methods of the class. As for subclassing, new classes may be derived from a class by adding new methods or redefining existing methods of that class. To account for the above features, the object-related forms of the untyped calculus are extended as follows: \[ e ::= \begin{align*} \texttt{topclass} & \mid \langle e_1 \leftarrow^* m \Rightarrow e_2 \rangle & \mid & \texttt{pack}(e) & \mid & \langle e_1 \leftarrow m \Rightarrow e_2 \rangle & \mid & e \Leftarrow m & \mid & e \Leftarrow^* m \end{align*} \] The operational meaning of the operations of override, send, and search is exactly as in Section 2. The meaning of the remaining expressions is given next. \texttt{topclass} is a pre-defined constant representing the empty class and defined as follows: \texttt{topclass} \equiv \langle \texttt{new}^\ell = \lambda s. \texttt{pack}(s) \rangle. This class defines class-method \texttt{new} for creating instances: the result of a call to \texttt{new} on a class is the instance of that class that results from packaging the class. New classes may be derived from the empty class by a sequence of method overrides and extensions. The symbol \leftarrow^* above denotes two different operators, \leftarrow and \leftarrow^*, denoting class-extension with, respectively, class-methods, and instance methods. The operational semantics of the \texttt{pack} operator is defined by few additional cases of the reduction relation; the effect of packaging on types, in turn, is rendered in terms of a corresponding type operator, denoted by \texttt{pack}. The new cases of reduction for \texttt{pack} and the equational rules for packaged types are defined below: \[ \begin{align*} \texttt{pack}(e) & \xrightarrow{\texttt{eval}} e & \texttt{pack}(b) & = b \\ \texttt{pack}(\lambda x.e) & \xrightarrow{\texttt{eval}} \lambda x.e & \texttt{pack}(\tau_1 \rightarrow \tau_2) & = \tau_1 \rightarrow \tau_2 \\ \texttt{pack}(e \Leftarrow m) & \xrightarrow{\texttt{eval}} \langle e \Leftarrow m \rangle \texttt{pack}(e) & \texttt{pack(Clazz.}(\langle m^{\tau} \Rightarrow n^{\sigma} \rangle \}) & = \texttt{Obj} \ t. \langle p^{\tau} \Rightarrow \rangle \\ \texttt{pack}(\texttt{pack}(e)) & \xrightarrow{\texttt{eval}} \texttt{pack}(e) & \texttt{pack}(\texttt{pack}(\tau)) & = \texttt{pack}(\tau) \end{align*} \] Packaging a class produces the corresponding \texttt{Obj} type that results from hiding all of the class-methods of the class. Packaging any other expression, instead, has no effect on the type of the expression. The introduction of the \texttt{pack} operator induces a new, and richer, notion of type equality that now allows two types to be identified if they are equal modulo the equational rules for the \texttt{pack} operator. The definition of matching is readily extended to the newly introduced types. Matching over \texttt{Clazz}-types is exactly as matching over \texttt{Obj}-types, namely: \[ \begin{align*} \Gamma \vdash s & \quad \langle m^{\tau}, n^{\sigma} \rangle \text{ well formed} \\ \Gamma \vdash \texttt{Clazz.}(\langle m^{\tau}, n^{\sigma} \rangle \rangle & \texttt{ Class.}(\langle m^{\tau}, n^{\sigma} \rangle \rangle \text{ (} \# \text{ class),} \end{align*} \] where \# may either be \# or \#. As for matching between \texttt{Clazz} and \texttt{Obj} types, we have the following rule: \[ \begin{align*} \Gamma \vdash s & \quad \langle m^{\tau}, n^{\sigma} \rangle \text{ well formed} \\ \Gamma \vdash \texttt{Clazz.}(\langle m^{\tau}, n^{\sigma} \rangle \rangle & \texttt{ Obj.}(\langle n^{\sigma} \rangle \rangle \text{ (} \# \text{ obj),} \end{align*} \] that is, every \texttt{Clazz} type matches its corresponding \texttt{Obj} type. 5.2 Typing Rules The new types require few additional changes in the object-related portion of the type system, which are described next. The following two rules define the type of the empty class and of packaged expressions. $$ \Gamma \vdash s \\ \Gamma \vdash \text{topclass} : \text{Class}\{\text{new}^c : \text{pack}(t)\} \\ \Gamma \vdash e : \tau \\ \Gamma \vdash \text{pack}(e) : \text{pack}(\tau) $$ (topclass). For the remaining object-expression, we need different rules for distinguishing the different behavior of class-methods and instance-methods. Class Methods. The typing of class-method invocation is as follows: $$ \Gamma \vdash e : \sigma \\ \Gamma \vdash \sigma \not<\# \text{Class}\{n^c : \tau\} \\ \Gamma \vdash e \leftarrow n : [\sigma/t]\tau $$ (c-send). If $n$ is a class-method (as indicated by the annotation $^c$), then $e$ must have a Class-type matching Class.$\{n^c : \tau\}$. Therefore, only class-methods may be invoked on a class; class-methods may, instead, perform (internal) invocations or overrides also on instance-methods of that class. The following rule for class-method addition allows this behaviour. $$ \Gamma \vdash e_1 : \text{Class}\{R \mid n^\rho ; n^c : \tau\} \\ \Gamma, u \not<\# \text{Class}\{n^\rho ; n^c : \tau\} \vdash e_2 : [u/t](t \rightarrow \tau) \\ \Gamma \vdash \langle e_1 \leftarrow n = e_2 \rangle : \text{Class}\{R \mid n^\rho ; n^c : \tau\} $$ (c-ext). As usual, method addition, is subject to the constraint that the $n$ method be not already in the type of class. The typing rule for method override is similar to (c-ext), while the typing of search expressions follows the same idea as (c-send) above. Instance Methods. As we said, instance-method may only invoke other instance-methods of the self object. The following typing rule enforces this constraint: $$ \Gamma \vdash e_1 : \text{Class}\{R \mid n^\rho ; n^c : \tau\} \\ \Gamma, u \not<\# \text{Obj}\{t \mid n^\rho ; n^c : \tau\} \vdash e_2 : \text{pack}(u) / [t \rightarrow \tau] \\ \Gamma \vdash \langle e_1 \leftarrow n = e_2 \rangle : \text{Class}\{R \mid n^\rho ; n^c : \tau\} $$ (t-ext). Note that the bound for $u$ is so defined as to allow the $n$ method to be applied on objects of every type matching the Obj-type corresponding to the Class-type (as in ($\not<\# \text{obj}$ rule). This way, instance-methods may safely be inherited by the instances of the class. Note, furthermore, that the polymorphic type of \( e_2 \) is so defined as to ensure that \( e_2 \) may only be applied on elements of packaged types (i.e., objects). A corresponding constraint is imposed on the typing of instance-method invocation: \[ \frac{\Gamma \vdash e : \text{pack}(\sigma)}{\Gamma \vdash e : \text{pack}(\sigma) \quad \Gamma \vdash \sigma \equiv \text{Obj}\ t\ .\ \langle n' : \tau \rangle} \] \((t\text{-send})\) The type of the receiver must be a packaged type consistent with the polymorphic type that is associated with the body of the method. The rules for method search and override may be defined following this idea. 5.3 A Simple Example Using the above type rules, it is now possible to define an object expression representing the class of points with an \( x \) coordinate and, say, a \textit{set} method for updating the position of the points in the class. Assuming that \textit{create} is a class method, and that \( x \) and \textit{set} are instance methods, the class of points may be defined as follows: \[ \text{ptClass} \equiv \langle \text{new } = \lambda s.\text{pack}(s); \text{create } = \lambda s.\lambda v.((s = \text{new}) \leftarrow \text{set}\ v); \text{set } = \lambda s.\lambda v.((s \leftarrow x = \text{set}\ v)) \rangle \] where the value of the \( x \) field is defaulted to 0 in the class definition. The following type may then be derived: \[ \text{ptClass} : \text{Class}\ t\ .\ \langle \text{new}' : \text{pack}(t), \text{create}' : \text{pack}(t), \text{set}' : \text{int} \rightarrow \text{pack}(t) \rangle \] Instances of this class may then be created with a \textit{create} message to \textit{ptclass}. For instance, the expression \( \text{ptclass} \equiv \text{create} 3 \) creates a point instance of type \( \text{Obj}\ t\ .\ \langle x : \text{int}, \text{set}' : \text{int} \rightarrow \text{pack}(t) \rangle \), with \( x \) coordinate valued 3 and a \textit{set} method. 6 Conclusions We have presented a new type system for the \textit{Lambda Calculus of Objects}. The main difference with respect to the original proposal, is that in \cite{16} method polymorphism is rendered in terms of quantification over rows-schemas, whereas in our system it is captured by means of match-bounded quantification and matching. A formal analysis of the relative expressive power of the two systems shows that they coincide on derivations for closed-object typing judgements. On the other hand, there are some fundamental tradeoffs between the two approaches, both in terms of complexity and of their logical rendering. In fact, while the new solution appears to reduce the complexity of the system, freeing it from the cal- culus of rows of the original system, on the other hand the auxiliary judgments and side-conditions needed for matching are not costless, and may have undesired consequences in the encoding of the new system in Logical Frameworks [15]. We have then presented an extension of the new system that gives provision for classes in an object-based setting. The extended calculus may, in some respects, be seen as a functional counterpart of the Imperative Object Calculus of [1]. Besides the different operational setting (i.e. imperative versus functional), that proposal differs from ours in that, while using matching to model method inheritance between classes, it relies on subtyping for the treatment of self types. Instead, our system requires no subtyping, since it relies on matching as the only relation over class and object types. Acknowledgements. We would like to thank Mariangiola Dezani-Ciancaglini for inspiring this work and for endless discussions on earlier drafts. Suggestions from the anonymous referees helped to improve the presentation substantially. References A Operational Semantics $$ \begin{align*} \beta & \quad (\lambda x.e_1) e_2 \quad \xrightarrow{eval} [e_2/x] e_1 \\ \mathbf{false} & \quad e \leftrightarrow m \quad \xrightarrow{eval} (e \leftrightarrow m) e \\ \mathbf{fail \; (\emptyset)} & \quad () \leftrightarrow m \quad \xrightarrow{eval} \mathsf{err} \\ \mathbf{fail \; abs} & \quad \lambda x.e \leftrightarrow m \quad \xrightarrow{eval} \mathsf{err} \\ \mathbf{err \; \leftrightarrow} & \quad \langle \mathsf{err} \leftrightarrow o \; m = e \rangle \quad \xrightarrow{eval} \mathsf{err} \\ \mathbf{err \; abs} & \quad \lambda x.\mathsf{err} \quad \xrightarrow{eval} \mathsf{err} \\ \mathbf{err \; app} & \quad \mathsf{err} \; e \quad \xrightarrow{eval} \mathsf{err} \\ \mathbf{err \; \leftarrow} & \quad \mathsf{err} \leftarrow n \quad \xrightarrow{eval} \mathsf{err} \end{align*} $$ B Typing Rules **General Rules:** $\Gamma \vdash A$ stands for any derivable judgement in the system. (start) $$ \epsilon \vdash *$ (projection) $$ \frac{\Gamma \vdash * \quad x : \tau \in \Gamma}{\Gamma \vdash x : \tau} $$ (weakening) $$ \frac{\Gamma \vdash A \quad \Gamma, \Gamma' \vdash *}{\Gamma, \Gamma' \vdash A} $$ Rules for Terms (var) \[ \Gamma \vdash x : \tau \quad x \not\in \text{Dom}(\Gamma) \\ \quad \inferrule{ \Gamma; x : \tau \vdash * }{ \Gamma; x : \tau \vdash x } \] (abs) \[ \Gamma; x : \tau_1 \vdash e : \tau_2 \\ \Gamma \vdash \lambda x : \tau_1 \rightarrow \tau_2 \\ \Gamma \vdash \lambda x : \tau_1 \rightarrow \tau_2 \] (app) \[ \Gamma \vdash e_1 : \tau_1 \rightarrow \tau_2 \\ \Gamma \vdash e_2 : \tau_1 \\ \Gamma \vdash e_1; e_2 : \tau_2 \\ \] (empty) \[ \Gamma \vdash * \\ \inferrule{ \{} \vdash 0 \text{obj} t(\}) }{ \Gamma \vdash \{ }\} \] (ex) \[ \Gamma \vdash e_1 : \text{Obj} t(R | \overline{m \tau}) \\ \Gamma; u <\# \text{Obj} t(m \tau, n : \tau) \vdash e_2 : [u / \ell](t \rightarrow \tau) \\ n \not\in \text{M}(\{R | \overline{m \tau}\}) \\ \inferrule{ \Gamma \vdash e_1 \leftarrow n = e_2 : \text{Obj} t(R | \overline{m \tau, n : \tau}) }{ \Gamma \vdash e_1 \leftarrow n = e_2 } \] (over) \[ \Gamma \vdash e_1 : \sigma \\ \Gamma \vdash e : \sigma <\# \text{Obj} t(m \tau, n : \tau) \\ \Gamma; u <\# \text{Obj} t(m \tau, n : \tau) \vdash e_2 : [u / \ell](t \rightarrow \tau) \\ \inferrule{ \Gamma \vdash \{ e_1 \leftarrow n = e_2 \} : \sigma }{ \Gamma \vdash e \leftarrow n = e_2 } \] (send) \[ \Gamma \vdash e : \sigma \\ \Gamma \vdash e : \sigma <\# \text{Obj} t(n : \tau) \\ \inferrule{ \Gamma \vdash e \leftarrow n : [\sigma / \ell](t \rightarrow \tau) }{ \Gamma \vdash e \leftarrow n } \] (search) \[ \Gamma \vdash e : \sigma \\ \Gamma \vdash e : \sigma <\# \text{Obj} t(n : \tau) \\ \Gamma \vdash e \leftarrow \varsigma : \sigma \\ \inferrule{ \Gamma \vdash e \leftarrow \varsigma : \sigma }{ \Gamma \vdash e \leftarrow \varsigma } \] Rules for Matching (<\# var) \[ \Gamma \vdash * \\ u \not\in \Gamma \\ u \not\in \tau \\ \inferrule{ \Gamma; u <\# \tau \vdash * }{ \Gamma; u <\# \tau \vdash u } \] (<\# proj) \[ \Gamma \vdash * \\ u \not\in \tau \in \Gamma \\ \Gamma \vdash u <\# \tau \\ \Gamma ; u <\# \tau \] (<\# refl) \[ \Gamma \vdash * \\ \Gamma \vdash u <\# \tau \\ \Gamma \vdash u <\# \tau \\ \Gamma \vdash \tau <\# \tau \] (<\# trans) \[ \Gamma \vdash \tau <\# \rho \\ \Gamma ; \tau <\# \rho \\ \Gamma \vdash \sigma <\# \rho \] (<\#) \[ \Gamma \vdash * \\ \langle m \tau, n : \tau \rangle \text{ well formed} \\ \Gamma \vdash \text{Obj} t(m \tau, n : \tau) <\# \text{Obj} t(m \tau, n : \tau) \]
{"Source-Url": "https://iris.unito.it/retrieve/handle/2318/116886/56138/TLCA97.pdf", "len_cl100k_base": 13619, "olmocr-version": "0.1.53", "pdf-total-pages": 17, "total-fallback-pages": 0, "total-input-tokens": 89317, "total-output-tokens": 16002, "length": "2e13", "weborganizer": {"__label__adult": 0.0004813671112060547, "__label__art_design": 0.000396728515625, "__label__crime_law": 0.00037598609924316406, "__label__education_jobs": 0.00115966796875, "__label__entertainment": 8.797645568847656e-05, "__label__fashion_beauty": 0.000209808349609375, "__label__finance_business": 0.0002918243408203125, "__label__food_dining": 0.00052642822265625, "__label__games": 0.0006780624389648438, "__label__hardware": 0.0007653236389160156, "__label__health": 0.000949382781982422, "__label__history": 0.00038051605224609375, "__label__home_hobbies": 0.00010895729064941406, "__label__industrial": 0.0005550384521484375, "__label__literature": 0.0006256103515625, "__label__politics": 0.0004072189331054687, "__label__religion": 0.00078582763671875, "__label__science_tech": 0.041168212890625, "__label__social_life": 0.00015425682067871094, "__label__software": 0.004276275634765625, "__label__software_dev": 0.9443359375, "__label__sports_fitness": 0.0003998279571533203, "__label__transportation": 0.0007181167602539062, "__label__travel": 0.0002467632293701172}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 49409, 0.01061]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 49409, 0.35678]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 49409, 0.80377]], "google_gemma-3-12b-it_contains_pii": [[0, 2661, false], [2661, 5898, null], [5898, 8911, null], [8911, 12034, null], [12034, 14931, null], [14931, 18467, null], [18467, 20284, null], [20284, 23719, null], [23719, 26761, null], [26761, 29874, null], [29874, 33249, null], [33249, 37095, null], [37095, 39482, null], [39482, 42289, null], [42289, 45049, null], [45049, 47063, null], [47063, 49409, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2661, true], [2661, 5898, null], [5898, 8911, null], [8911, 12034, null], [12034, 14931, null], [14931, 18467, null], [18467, 20284, null], [20284, 23719, null], [23719, 26761, null], [26761, 29874, null], [29874, 33249, null], [33249, 37095, null], [37095, 39482, null], [39482, 42289, null], [42289, 45049, null], [45049, 47063, null], [47063, 49409, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 49409, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 49409, null]], "pdf_page_numbers": [[0, 2661, 1], [2661, 5898, 2], [5898, 8911, 3], [8911, 12034, 4], [12034, 14931, 5], [14931, 18467, 6], [18467, 20284, 7], [20284, 23719, 8], [23719, 26761, 9], [26761, 29874, 10], [29874, 33249, 11], [33249, 37095, 12], [37095, 39482, 13], [39482, 42289, 14], [42289, 45049, 15], [45049, 47063, 16], [47063, 49409, 17]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 49409, 0.0]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
436fd2a207bff779b8442e94e12467976cf3daaf
EMPLOYEE COLLABORATION PORTAL IN SHAREPOINT A Master’s Project Presented to Department of Computer and Information Sciences SUNY Polytechnic Institute Utica, New York In Partial Fulfilment Of the Requirements for the Master of Science Degree by Sai Sandeep Soumithri Vempati December 2016 © Sai Sandeep Soumithri Vempati 2016 EMPLOYEE COLLABORATION PORTAL IN SHAREPOINT Master of Science Project in Computer and Information Sciences Department of Computer Sciences SUNY Polytechnic Institute Approved and recommended for acceptance as a project in partial fulfilment of the requirements for the degree of Master of Science in Computer and Information Sciences 02/14/2017 Date Chen-Fu Chiang, Ph. D. (Adviser) Jorge Novillo, Ph. D. Mohamed Rezk, Ph. D. EMPLOYEE COLLABORATION PORTAL IN SHAREPOINT Declaration I declare that this project is my own work and has not been submitted in any form for another degree or diploma at any university or other institute of tertiary education. Information derived from the published and unpublished work of others has been acknowledged in the text and a list of references is given. Sai Sandeep Soumithri Vempati Abstract This project aims at developing a portal for a company’s internal needs that include leave portal, a pre-sales dashboard and a document sharing list for the employees in SharePoint Online. SharePoint Online is web based Content Management System (CMS) provided by Microsoft. Microsoft introduced SharePoint in 2001 which was an instant winner. It had all the features that are needed for storage and collaboration. SharePoint later on evolved into two major versions, namely, On-premise and Cloud version. SharePoint the cloud version proved to be a feasible CMS for start-ups and small companies. As the usage of SharePoint Online has minimised the burden maintenance of servers and administration more companies started using SharePoint [5]. The utility of SharePoint has caught the attention of many companies lately. It has scaled up to, 75000 organisations having 160 million users [8]. The usage of SharePoint made companies develop portals that are interactive and act as platforms for collaboration and exchange of information. The workflow automation provided by SharePoint helps in simplifying the business process management. Web technologies can be used to develop the portal in a user friendly and responsive manner. In this project, a portal is developed that mainly has three functionalities – a leave application platform, a dashboard for Presales and a list that helps sharing of information. The leave application feature is based on the workflow automation service provided by SharePoint in which the user can request concerned manager for a leave approval. The whole process of approval is automated in the portal. The Presales dashboard option helps in viewing data related to projects that can be used to develop reports by the Presales team of a company. The data is shown in various forms suitable for easy understanding using web parts in the dashboard. A list that demonstrates file approval is included in the portal. Contents 1 Introduction .................................................................................................................. 5 1.1 Content Management System .............................................................................. 5 1.2 Why SharePoint? ................................................................................................. 5 1.3 What is SharePoint? ............................................................................................. 6 2 SharePoint Server Architecture .................................................................................. 8 3 Programming models in SharePoint 2013 ................................................................. 11 3.1 SharePoint server side Object Model (SSOM) .................................................. 12 3.2 Client Side Object Model (CSOM) ...................................................................... 13 4 Motives and Project Idea ........................................................................................... 14 4.1 Technologies and software’s Used ...................................................................... 15 4.2 Master Page and Page layouts ........................................................................... 15 4.3 Web Parts ........................................................................................................... 18 4.4 Workflows .......................................................................................................... 18 5 Implementation ........................................................................................................... 20 5.1 Employee Collaboration Portal ........................................................................... 20 5.2 Use Case Diagrams ............................................................................................. 22 5.3 Leave Portal ....................................................................................................... 23 5.4 PreSales Dashboard ......................................................................................... 27 6 Appendix ..................................................................................................................... 31 6.1 Master Page Code .............................................................................................. 31 6.2 Code for Presales Dashboard ............................................................................. 33 6.3 Angular JS code for recent win’s web Part ....................................................... 38 6.4 Estimation Value file upload in the add project web part ............................... 40 7 References .................................................................................................................... 41 List of Important Figures 1. Features of SharePoint ........................................................................................................... 8 2. Server Architecture of SharePoint ..................................................................................... 10 3. Web Application Structure ................................................................................................. 11 4. Site Architecture and Object Model .................................................................................. 12 5. Development Platform Stack ............................................................................................. 13 6. SharePoint Server Side Object Model .............................................................................. 14 7. Client Object Model Mechanics ....................................................................................... 16 8. SharePoint Page Layout ..................................................................................................... 20 9. Workflow Example .............................................................................................................. 23 10. Types of Workflows .......................................................................................................... 23 11. Site Topology ...................................................................................................................... 25 12. Use-case diagram for Leave portal .................................................................................. 27 13. Use-case diagram for Presales portal .............................................................................. 28 Chapter 1 Introduction 1.1 Content Management System Content Management System is a powerful and scalable tool that facilitates creation, storage and exchange of digital information. Content Management Systems are used for Enterprise content Management (ECM) and Web Content Management (WCM). ECM is used in organizations for exchange of content among the members and have an internal portal for collaboration operations such as approval processes, digital content management, providing user accounts and role-based access to the organisation’s data, having different permission levels for content. WCM is used in providing collaborative writing of content. Generally, ECM has WCM features included in the interface. A Content Management System enables user to modify, add, create content. ECM web pages are often within the organisation’s scope and are not accessible for public use. CMS also provides support to developers to create responsive and appealing web interfaces [13]. CMS consists of mainly two components CMA and CDA - CMA (Content Management Application) - CDA (Content Delivery Application) CMA provides the functionalities of the GUI (Graphical User Interface) that enable the user to add, modify, create content from the page and user interface without the knowledge of web technologies. The CMA constitutes of the front-end user interface of CMS. CDA provides the back-end relative to the CMA and help in rendering the changes done in the front end by the user [13]. 1.2 Why SharePoint? In any business organisation there is a need for a common platform to manage documents, interview process, leave applications, web services, task notifications, news bulletin, a platform for free communication and thought sharing, file sharing medium, a metadata management tool, a portal for web services, portals for HR, Project Management Strategies and other various departments, groups for maintaining contacts among the department staff and generate automated business processes for regular tasks are needed. Considering the much needed and generic requirements as stated above, SharePoint suffices the needs of a Business Organisation. SharePoint was initially used as an intra-organisational content management platform developed by Microsoft for its organisational needs. It was later developed into a product and marketed as Microsoft has seen its need in all the organisations in the technology based market. 1.3 What is SharePoint? SharePoint is a browser based collaboration and document management platform from Microsoft. SharePoint has gained good appreciation among many upcoming small businesses and companies. SharePoint enables companies to maintain intranet portals and handle sharing and exchange of documents and other vital information through the enterprise content management facility. SharePoint’s first version was released in 2001 by Microsoft as a simple document sharing and indexing software and has evolved dramatically due to increase in reception by several top business organisations. It started as a simple server management tool and evolved into a Cloud based all-in-one enterprise product having features like social networking, web designing capabilities and workflows integrations on lists and content types [14]. It makes IT professionals more productive and efficient to work on projects as it provides a portal for all the employees to collaborate and work. SharePoint is much appreciated for out of box features and web design editing features which reduces the need for professional developers and DBAs. The various features of SharePoint (SP 2013) include: ![Figure 1: Features of SharePoint [1]](image) - Enterprise Content Management - Business Process Management - Business Intelligence - Enterprise Search • Enterprise Social Networking **Enterprise Content Management (ECM)** - It includes all the content management features and functionalities that are used to create, customize and publish site collections and sites. Different types of branded sites can be developed using ECM based on the requirements of the organization. A branded site can be an intranet presence site, an internet business site, intranet site or an extranet site. Intranet presence site is a site that is targeted to the customers, partners and investors of a company. Internet business site is a site approach for promoting products and offers to companies. Intranet site is a website for making content available for sharing among the employees of an organization. Extranet site is used to provide access to information and content to remote employees. **Business Process Management (BPM)** – It includes a streamlined way of automating a company’s tasks with the workflows feature. Workflows for automated emails and task reporting and deadline driven work (task notifications) and approval of documents can be generated using SharePoint Designer. Business Process management services such as work automation services generating process models using Visio and various BPM related functions can be easily carried out using SharePoint. **Business Intelligence (BI)** – Business intelligence refers to analysing and organization’s raw data to make critical decisions. SharePoint helps in facilitating BI for generating reports using Excel services came that can be used by incorporated office 365 services. There are many third party applications that can also be used to perform business intelligence related work such as Bamboo. There are options for performing analysis of data using Excel service and Power view feature to publish and share different reports analyzed on the company data. **Enterprise Search** – Search feature in SharePoint 2013 provides several query APIs, providing multiple ways to access search results that can return search results in a variety of custom solution types. The search feature in SharePoint is very advanced and easy to use. There are various components such as crawl components, query components and indexing components which make the Microsoft’s search architecture framework a very powerful tool. Chapter 2 SharePoint Server Architecture Figure 2: Server Architecture of SharePoint [2] The figure 2 gives a basic idea about Server architecture of the SharePoint. It shows the setup and object hierarchy of the Windows SharePoint Services. The highest level of object in SharePoint topology is a Farm (SP Farm). There are one or more physical servers having SharePoint installed and all the servers are combined into a single SP Farm. An SP farm can be a combination of multiple servers or a single server. There are numerous servers that are used as SQL servers to store and retrieve data along with the SP servers. Generally, small organizations prefer having a single Farm so that the maintenance becomes simpler. A Farm is a collection of many web services that are deployed on the SharePoint servers. Services that are deployed in the servers are referred as service applications. A service application provides a medium to share the various services deployed in the servers across the Farm. Few service applications are Business data connectivity service, Excel service, App management service, Visio integration service, Machine translation service, work automation service. Different functionalities of SharePoint are configured in service applications [17]. A **web application** is a logical unit for site collections. IIS (internet information services) website which is contained in the web application is used to host site collections. There can be multiple site collections under a web application. A Farm can host about 20 web applications [17]. ![Web application structure](image) **Figure 3:** Web application structure [3] A **Site collection** is a whole collection that consists of all the subsites under it. The collection of sub-sites is kept in a hierarchical fashion under a top level site. The top-level site can have links to subsites to make the sub-sites accessible to users. Example- An HR department can be a site collection which has the top level site an HR home page and the subsites can be leave request site, employee details website etc. About 750000 site collections can be created in a farm [17]. Figure 4 shows the site architecture which includes the objects that are base for every site in SharePoint. As elaborated above the site collection is generally the wholesome collection of Subsite. Each Subsite has a basic unit called list where data can be store just as in relational database. The list consists of two fundamental objects they are fields and list items. Fields are nothing but column entities as in the SQL tables and the list item refers to data in the table. Subsite - Subsite is an independent site that has data that is contained in it that is shared to targeted users. Different permissions levels can be set up for a Subsite. For example, a group of employees can only view a particular Subsite in the site collection and the other employees are restricted from accessing the site. It simplifies classifying information [17]. List – A list can be termed as the fundamental object of SharePoint. A list consists of fields and list items. Fields are nothing but columns and list items are the data fields as in excel spreadsheets. A basic idea of lists in SharePoint is derived from the .xml model (excel spreadsheet). A Content type is a reusable set of columns (metadata). A content type can be a group of lists. A list can have multiple content types attached to it and vice-versa [17]. Figure 5 shows the development stack for the SharePoint 2010 platform. It gives brief understanding of the back end on SharePoint platform. There are few more advancements in the 2013 version which are used in the current project for developing the enterprise portal. In 2013 version feature for hosting cloud apps that can be developed using various development tools such as visual studio, NAPA office 365 development tools and SharePoint designer for editing master pages and creating workflows. SharePoint has made it simple for web developers who use web technologies such as HTML5, CSS, JavaScript, Angular JS, REST to develop solutions other than conventional Microsoft web technology (.net). The enterprise search feature is highly enhanced in the 2013 version, significant advancements are done to the Keyword Query Language (KQL) that is a search syntax for building search queries. Business connectivity services (BCS) to access data from external systems such as SAP, ERP are provisioned in SP 2013, Application services such as PowerPoint automation services, Excel and Access services were enhanced. Chapter 3 Programming models in SharePoint 2013 There are many web technologies that can be used to develop interactive websites. Few popular and trending languages are JavaScript, HTML, CSS, ASP.NET, PHP, Ruby on Rails, GO, Python. The object models in SharePoint facilitate using few of the technologies for making the web application hosted in SharePoint more interactive and creative. Mainly there are three programming models provisioned in SP 2013 that facilitate using the technologies supported by the SP platform. They are- - SharePoint Server Object Model (SSOM) - Client side object Model (CSOM and JSOM) - REST API 3.1 SharePoint Server Side Object Model (SSOM) Server Side object model is the first and the backbone for programming and development in SharePoint. SSOM is highly structured and helps referring to objects in like lists, sites to use them in the code. SSOM is used to write code when the application is being developed in ASP.NET in the SharePoint server. The languages supported in SSOM should belong to the .NET framework as it is a Microsoft product. SSOM is the fundamental model that is an assembly that provides classes and helps in mapping the components that the end user can see. SSOM can be understood by examining the figure 6. ![Figure 6: SharePoint Server Side Object Model](image-url) The “Microsoft.Sharepoint.dll” is the core assembly of SSOM that is installed in the global cache comprising two main namespaces, namely, “Microsoft.Sharepoint” and “Microsoft.Sharepoint.Administration”. The “Microsoft.Sharepoint” namespace contains classes and objects that help in developing solutions at a site collection level, it helps site developers and application developers work effectively. It is used mainly to manipulate and tweak with the site architecture. SPList, SPWeb, SPSite, SPField are objects of the “Microsoft.Sharepoint” namespace. SPList represents a list; SPWeb represents a single site that includes all the features in the site. SPSite is used to represent a site collection. SPField is used to map field data in a list. The “Microsoft.Sharepoint.Administration” namespace has classes and objects used for administration purposes. SP solutions that are developed at an administrative level are present here. SPFarm represents the whole server cluster; it is the highest object in the object hierarchy. SPService represents a server. SPWebApplication represents the web-application that is hosted in the IIS website. SPDatabase represents the SQL database that is associated with the web-application. The Server Object Model gets executed in the server side and must be deployed in the same farm. The below snippet C# code gives an example of SSOM program for adding a list items specified by the user in the text boxes to a list [15]. Assuming that the studentDemo list consists of fields Name, Major, Age. ```csharp SPWeb ssomDemo = SPContext.Current.Web; SPListItemCollection listItems1 = ssomDemo.Lists["studentDemo"].Items; SPListItem item = listItems1.Add(); item["Name"] = TextBox2.Text; item["Major"] = TextBox3.Text; item["Age"] = Convert.ToInt32(TextBox4.Text); item.Update(); ``` Disadvantages of SSOM are that, only C# and VB can be used to code in SSOM and the development has to be done in the machine in which SharePoint is installed. Server-side object model is only used in on–premise version of SharePoint. For SharePoint online, CSOM is used as the main programming model. 3.2 Client-Side object model (CSOM) In the SSOM, code runs at server front end whereas CSOM is used when the code has to run at the remote machine that is accessing SharePoint. The major advantage of CSOM is that coding can be done remotely with no need to connect to the server. CSOM provides client side application with access to a subset of SSOM which includes core objects such as sites, site collections, lists, list items etc. CSOM consists of three API’s - the .NET Framework, the ECMA script (JavaScript) and the Silverlight application. Client side processing is preferred as it works faster than the Server side as the work gets distributed; the client only processes how to display the data and server only processes the data requests. The workflow of the client object model is shown in figure 7. ![Client Object Model Mechanics](image) **Figure 7: Client Object Model Mechanics [11]** CSOM can be used to perform the CRUD (create, read, update and delete) operations and generally querying of data is done using CAML queries. Using CSOM, synchronous and asynchronous operations can be performed. The CRUD operations are implemented on the list and the front end web parts. Chapter 4 Motives and Project Idea In the current market scenario, every company needs an outlook and introspection on their performance in sales, an internal collaboration portal for day to day functional activities, and a sharing platform for the exchange of information. Moreover, the project that is developed has to be a useful idea for the sake of any user and must be a learning experience. Hence, I have thought of an idea that consolidates all the needs of a company into a single accessible location. CMS is the only apt solution when there is a need for a multiple user logins/accounts and exchange of emails, a User Interface for interactive and functional needs such as creation of dashboards etc., approval of a higher tier employee, fancy looks for the web application and bulk supervised uploads and exchanges of files. One such CMS that is used all over the software industry is SharePoint. With this perspective, the project constitutes of a presales dashboard along with few pages that show various metrics, a leave application portal for the employees and a document sharing approval list. Presales operations are performed in all product based and service based companies which must depend on sales data to understand the product’s trend. In IT industries, the presales process is done before connecting with a customer in order to know the needs a customer expects and the performance of the previous project tenders. Data about the projects that were successfully acquired or lost, type of technologies used and other activities involved in sales relative to the company is analysed by the presales team. For this, they need a dashboard to view the data in a feasible and understandable way. Therefore, in this project a presales dashboard is included. For every company, the employees apply for leave, this process can be made easier with a portal where the employees can apply and check the leave history which comprises a list of leaves, date and day information. So, to have a feasible streamlined way of leave approval and application. There is a need for having a leave application portal in all the companies. There is also need for uploading and sharing of variety documents which is essential for productivity. Control over this data is necessary, like to share only approvable data, to have a content administrator for approval of data. 4.1 Technologies and Software’s used - SharePoint Office 365. - SharePoint Designer. - Asp.net to develop Master pages and page layouts. - Html5, CSS3, Bootstrap. - Angular JS to perform CRUD operations. 4.2 Master page and Page layouts SharePoint master pages are the page layout format that is common all across the site used for development. The elements of the page that are common and have an unchanged position are predefined in the master page. Navigation bars, footers, side bars, headers are generally always the same in all the sites in the site collection, therefore, master pages can help in making designing process easier. The parts of site page that differs from each page to the other are known as Content pages such as web parts, lists, and data. The SharePoint online platform packs the content page and the master page into a single page while rendering it through the browser. Customizing the web pages to create a better user interface is termed as branding. Branding is done depending upon the application’s requirements and functionalities. SharePoint provides two out-of-the-box (inbuilt) master pages “Seattle.master”, “v4.master” and “Oslo.master”. A user can either edit these default master pages or create a new master page from scratch. Creating a master page and page layouts involves these steps: 1. Connect the SharePoint designer to the site collection. ![SharePoint Designer](image8.png) **Figure 8: SharePoint Designer** 2. Select Master page from site objects navigation bar. The navigation bar contains the ‘Site Objects’ that are part of the site collection. For every site collection there is master page. ![Master Pages List](image9.png) **Figure 9: Master Pages List in SharePoint Designer** In our project the master pages developed are from the default master pages. By using adding required features to the “seattle.master” page we have created a Presales.master and “LeavePortal.master” pages. A master page can be created using the Blank Master Page on the screen shot above. Default top-level page of a site collection looks as shown below. Figure 10: Default SharePoint Start page The general layout of the web page in SharePoint is shown in figure 11: Figure 11: SharePoint Page Layout [12] The elements such as company logo, side bars, search boxes, action menus, design and colors etc. are persistent when we navigate to the site in a company webpage. The master pages are used to define the layout, look and feel for the whole site collection pages. SharePoint shows the combination of the Master page elements and the content page elements in form of a responsive webpage when rendered through a browser. The content page part of the SharePoint page consists of web parts and content specific to the site page. Content layout and placeholders—The content place holder help in defining the layout of the content page. The position and facility to add web parts to a page are provided by the content holder. There are by default 33 content holder in master page to define the functionalities of page in SharePoint. ![Content Place holders](image) **Figure 12: Content Place holders** The content place holder in the current project gives an idea of the layout for adding web parts to the master page. **Benefits of Master pages:** - Having a consistent view all through the site, this makes navigation easier. - Look and feel of the website is consistent and easier to create new pages. - Mitigates Design Issues - Coding master pages makes job of a programmer easier. - A power user can also create site pages form the existing master page. ### 4.3 Web Parts The elements of the content page are known as web parts. Generally, there are inbuilt web parts in SharePoint. The user can add different web parts to the content page just by clicking on the content place holder and adding the web part or by adding the default web parts provided by the SharePoint. Few commonly used In-built web parts provided by SharePoint are - Lists - Content Editors - Image - Page viewer web part - Script editor To add a web part to the content page. The following steps can be followed by the user: 1. Click on the settings icon on the right side of the SharePoint page and select edit page. 2. After clicking on the edit page option, the web part zones in which the web part can be placed can be seen. Click on the link add web part and the select the type of web parts we wish to add. ![Add web parts window](image) **Figure 13:** Add web parts window ### 4.4 Workflows A series of tasks that produce an output related to a business process such as sequence of actions, automated exchange of items or documents is known as a workflow. SharePoint workflow are supported by Windows workflow Foundation (WF). The WF is designed and built based on the messaging functionality provided by Windows Communication Foundation (WCF). There are two types of workflows defined in a business environment [17]. Figure 14: Workflow example [9] - **Sequential Workflow** - Sequential workflow consist of series of steps that are performed in a standard order till the end of the process. All the steps in a sequential workflow are executed on after the other. Direction of execution order is towards the end of the process always no loops in the workflow process exist. Example of a sequential workflow is shown below [18]. - **State Machine Workflow** - State Machine Workflow has multiple steps and the order of the process is not specific. Any state can be the end state. The steps get executed asynchronously. Each process is independent to itself [18]. Figure 15: Types of Workflows [10] Chapter 5 Implementation 5.1 Employee Collaboration portal The Employee Collaboration Portal is developed using SharePoint Online platform. The user accounts can be created using the SharePoint administrator account and the developer is by default the administrator (the administrator can give developer privileges to user too selectively). Every user is considered to be an employee. The portal is targeted to all the employees of the company. The portal mainly has three functionalities – - Presales Dashboard. - Leave application management. - Managed Document Sharing Managed Document Sharing makes use of the in-built (out-of-box) SharePoint feature for document handling and sharing. Figure 16 shows the home portal after an end user logs in with an Office 365 credential. As we can see in figure 16, the tiles guide the users for accessing the functionalities. The employee can choose either of the options Leave portal and Presales. Figure 17 shows the topology of the sites in the portal that is developed. Site collections- There are fundamentally three site collections in this project. They are presales and leave application and company portal. The subpages under each site collection can be seen as shown in figure 17. Each collection has different master pages. Lists- Few common types of lists created include calendar lists, contact lists, issue tracking, custom lists. All the lists used in the project are custom generated lists. The lists created in development of the company internal portal are: Presales List: This list stores the project details and all the web parts in the presales dashboard use the data from this list to display content. The web parts that use the presales list include a presales graph, recent wins, a presales health check and project details. Presales Estimation Values List: This list stores the number of estimated hours and actual hours entered for every project. Presales Estimation Sheets List: This list stores the uploaded estimation sheet and requirement document for every project. Leave Request List: Leave request list is created to store data entered by the employee when a leave is applied and the workflow for the leave approval process is created on this list itself. A workflow can either be created on a list, a content type or a calendar list. 5.2 Use-case Diagrams The Leave portal web application use case diagram: ![Use Case Diagram for Leave Portal] **Figure 21:** Use Case diagram for leave portal Use case diagram for Presales web application: ![Use Case Diagram](image) **Figure 22: Use Case diagram for Presales** ### 5.3 Leave Portal Leave portal is a sub-site collection in the company portal. The tile that shows leave portal in the homepage enables the employee to apply for a leave by filling the details and sending a leave approval request to their concerned manager. ![Leave Request Homepage](image) **Figure 23: Leave Request Homepage** Figure 23 shows the homepage of the leave application portal which consist of a form where the employee can enter leave request details. The start date and end date fields can be filled by selecting the date picker that shows up on clicking the calendar button on the field. Number of days can be entered for the leave duration. The type of leave can be selected by using the dropdown list that has three options namely- casual leave, earned leave, parental leave. The project in which the employee works can be selected using the dropdown list and the Engagement Manager’s name is entered in the text box provided. The Engagement Manager name gets searched and prompts are shown whenever the employee starts typing by matching the name of users and the text typed. After filling the data in the form the employee can click on submit button for sending an approval request to their concerned manger. As soon as the employee clicks on the submit ![Figure 24: Leave Request Homepage](image-url) button the Leave History of the employees gets displayed. The user/employee can anytime click on the pane on the left side to access the leave history. ![Leave History page](image) **Figure 25: Leave History page** The list of leaves the employee has applied will be displayed in the Leave Requests list, as shown in the figure 25. After the employees places a leave request a workflow process gets initiated and the engagement manger gets approval request email and the user gets notified about the current stage of the approval as shown below. ![Workflow Email notification](image) **Figure 26: Workflow Email notification.** By this, the employee’s application process ends, after the leave gets approved a notification email that encloses the response of the manager is received. At the manager’s end, the leave request email is received and can set the status of the leave request to approved /declined. The request email received by the manager is shown here. ![Approval Email notification](image) **Figure 27:** Approval Email notification. By clicking the link in the mail the manager can view the request and review it. ![Leave Request List](image) **Figure 28:** Leave Request List The manager can select the option by editing the ‘LeaveStatus’ in the ‘LeaveRequests’ list as shown in figure 28. When the manager approves the leave an e-mail is sent automatically to the user as shown here. The details the user enters in the leave request page gets saved in the list- ‘LeaveRequests’ in backend as show in this screenshot. The workflow for the leave request portal that helps in streamlining the process of approval is developed using the SharePoint designer. The workflow is created on the list that stores the data about the leave requests in the backend. ![Developed Workflow](image) **Figure 29:** Developed Workflow ### 5.4 Presales Dashboard Presales dashboard has mainly three pages – - The dashboard page - The page that displays the number list of all projects - The pages that display projects based on the status of the projects List of pages for navigating in Presales site collection are – - Presales Dashboard home - All projects page - Projects won - Projects in progress - Projects lost The dashboard homepage looks as shown in figure 30: Figure 30: Presales Dashboard Homepage The dashboard home has multiple web parts that get displayed based in the projects entered by the employee. Web parts in the dashboard are: - Presales graph - Web part that displays number of projects won, lost, in progress. - Presales health check web part - Most used technologies web part - Recent wins web part. Figure 31: Presales Trend Graph The All Projects page displays the projects that are undertaken by the company previously and an option for adding new projects as shown in figure 33. There is an option for search below the column name to search for particular results. Additionally, the list can be sorted. Figure 32: Presales Dashboard widgets Figure 33: All Projects Page There are links added on the toggle bar pages that display only projects won, projects lost and homepage (company portal start page). **Figure 34**: Projects Won and Projects Lost On clicking the new project button the web part opens a form for entering project information and the information entered gets saved into the ‘Presales’ list in the backend and from that list the view web part displays the list of projects on the screen. Multiple options guide the user to enter project details. **Figure 35: Add project page** Chapter 6 Appendix 6.1 Master page code The master page is created by making some significant changes to the default master page seattle.master. Code added to the seattle master page is shown below. ``` 1. <SharePoint:Scriptlink runat="server" Name="~site/SiteAssets/JS/ui-grid/ui-grid.js" Language="javascript"/> 2. <SharePoint:Scriptlink runat="server" Name="~site/SiteAssets/Presales/App/presalesApp.js"/> 3. Language="javascript"/> 4. <SharePoint:Scriptlink runat="server" Name="~site/SiteAssets/Presales/JS/app.js" Language="javascript"/> 5. <SharePoint:CssRegistration name="<%$SPUrl:~site/SiteAssets/Presales/js/ui-grid/ui-grid.css%>" runat="server" after="SharepointCssFile"/> 6. <SharePoint:SharePointForm runat="server" onsubmit="if (typeof(_spFormOnSubmitWrapper) != 'undefined') {return _spFormOnSubmitWrapper();} else {return true;}")"> 7. <script type="text/javascript">var submitHook = function () { return false; }; theForm.theForm._spOldSubmit = theForm.submit; theForm.submit = function () { if (!submitHook()) { this._spOldSubmit(); } } </script> 8. <SharePoint:AjaxDelta id="DeltaSPWebPartManager" runat="server"/> 9. <WebPartPages:SPWebPartManager runat="Server"/> 10. <SharePoint:AjaxDelta/> 11. <asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true" /> 12. <SharePoint:AjaxDelta id="DeltaDelegateControls" runat="server"/> 13. <SharePoint:DelegateControl runat="server" ControlId="GlobalNavigation"/> 14. <SharePoint:DelegateControl ControlId="GlobalSiteLink3" Scope="Farm" runat="server" Visible="false"/> 15. <SharePoint:AjaxDelta/> 16. <div id="TurnOnAccessibility" style="display:none" class="s4-notdlg noindex"> 17. <a id="linkTurnOnAcc" href="#" class="ms-accessible ms-acc-button" onclick="SetsAccessibilityFeatureEnabled(true);UpdateAccessibilityUI();document.getElementById('linkTurnOffAcc').focus();return false;">"/> 18. <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,master_turnonaccessibility%>" EncodeMethod="HtmlEncode"/> 19. </div> 20. <div id="TurnOffAccessibility" style="display:none" class="s4-notdlg noindex"> 21. <a id="linkTurnOffAcc" href="#" class="ms-accessible ms-acc-button" onclick="SetsAccessibilityFeatureEnabled(false);UpdateAccessibilityUI();document.getElementById('linkTurnOnAcc').focus();return false;">"/> 22. <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,master_turnoffaccessibility%>" EncodeMethod="HtmlEncode"/> 23. </div> 24. <div class="s4-notdlg s4-skipribbonshortcut noindex"> 25. <a href="javascript:" onclick="document.getElementById('startNavigation').focus();" class="ms-accessible ms-acc-button runat="server">"/> 26. <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,skipRibbonCommandsLink%>" EncodeMethod="HtmlEncode"/> 27. </div> 28. <div class="s4-notdlg noindex"> 29. <a href="javascript:" onclick="document.getElementById('mainContent').focus();" class="ms-accessible ms-acc-button runat="server">"/> ``` <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,master_enableanimation%>" EncodeMethod="HtmlEncode"/> </a> <SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,master_disableanimation%>" EncodeMethod="HtmlEncode"/> </a> <script type="text/javascript"> function PresalesInsight() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/pages/PresalesInsight.aspx'; } function ProjectStatus() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/pages/ProjectStatus.aspx?Status=Status'; } function ProjectStatusInProgress() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/pages/ProjectStatus.aspx?Status=InProgress'; } function ProjectStatusWin() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/pages/ProjectStatus.aspx?Status=Win'; } function ProjectStatusLoss() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/pages/ProjectStatus.aspx?Status=Loss'; } function AboutPresales() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/Pages/AboutPreSales.aspx'; } function logoredirection() { window.location.href = _spPageContextInfo.webAbsoluteUrl + '/pages/PresalesInsight.aspx'; } function homePage() { window.location.href = "https://learningdemo.sharepoint.com/sites/sales/Pages/default.aspx"; } </script> <nav class="navbar-default navbar-side" role="navigation"> <div id="sideNav href=""><i class="fa fa-align-justify"></i></div> <div class="sidebar-collapse"> <ul class="nav" id="main-menu"> <li> <a class="navlinks " onclick="PresalesInsight()">Pre-Sales Dashboard</a> </li> <li> <a class="navlinks " onclick="ProjectStatus()">All Projects</a> </li> <li> <a class="navlinks " onclick="ProjectStatusInProgress()">All Projects in progress</a> </li> <li> <a class="navlinks " onclick="ProjectStatusWin()">Projects won</a> </li> </ul> </div> </nav> 6.2 Code for Presales Dashboard 1. Angular JS for Presales Graph web part: /*global angular*/ 2. (function () { 3. 'use strict'; 4. //Presales trend graph 5. angular.module('preSalesApp').controller('PresalesTrendController', ['$scope', function ($scope) { 6. var date = new Date(); 7. $scope.itemCol = []; 8. $scope.data = []; 9. $scope.sDate = new Date(date.getFullYear(), 0, 1); 10. $scope.eDate = new Date(date.getFullYear(), 11, 31); 11. $scope.sMaxDate = new Date(date.getFullYear(), 11, 31); 12. $scope.eMinDate = new Date($scope.sDate.getFullYear(), $scope.sDate.getMonth(), $scope.sDate.getDate()); 13. $scope.startDateChange = function () { 14. xLabelMax = new Date($scope.sDate.getFullYear() + 1, $scope.sDate.getMonth(), 0).getDate(); 15. $scope.eMinDate = new Date($scope.sDate.getFullYear() + 1, $scope.sDate.getMonth(), 0, $scope.eMinDate.getDate()); 16. $scope.eMaxDate = new Date($scope.sDate.getFullYear() + 1, $scope.sDate.getMonth() - 1, xLabelMax); 17. $scope.eDate = $scope.eMaxDate; 18. $scope.init = function () { 19. var Context = SP.ClientContext.get_current(); 20. var web = Context.get_web(); 21. var oList = Context.get_web().get_lists().getByTitle('Presales'); 22. var camlQuery = new SP.CamlQuery(); 23. camlQuery.set_viewXml('<View><RowLimit>100</RowLimit><Query><OrderBy><FieldRef Name='ID' Ascending='FALSE'/></OrderBy></Query></View>'); 24. var collImages = oList.getItems(camlQuery); 25. Context.load(oList); 26. Context.executeQueryAsync(function () { 27. var imagesEnumerator = collImages.getEnumerator(); 28. while (imagesEnumerator.moveNext()) { 29. var oImageItem = imagesEnumerator.get_current(); 30. $scope.itemCol.push(oImageItem.get_fieldValues()); 31. } 32. }); 33. }); 34. }); 35. }); 36. }); 37. }); 38. }); 39. }); 40. $scope.data = $scope.itemCol; 41. $scope.SApply(); 42. }, function (sender, args) { alert(args.get_message()); }); 43. } 44. SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () { $scope.init() }); 45. $scope.sDateOpen = function ($event) { 46. $scope.status.sDateOpened = true; 47. } 48. $scope.eDateOpen = function ($event) { 49. $scope.status.eDateOpened = true; 50. } 51. $scope.status = { 52. sDateOpened: false, 53. eDateOpened: false 54. } 55. $scope.$watch(attrs.startDate, function (startDate) { 56. selStartDate = startDate; 57. sDateMonth = selStartDate.getMonth(); 58. separateData(); 59. redrawLineChart(); 60. }); 61. directive('linearChart', ['$interval', 'dateFilter', '$window', function ($interval, dateFilter, $window) { 62. function link(scope, element, attrs) { 63. var dateToday = new Date(); 64. var fullData = []; 65. var sDateMonth = 0; 66. var eDateMonth = 11; 67. var monthDomain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]; 68. var x, y, xLabels, line, graph, xAxis, yAxisLeft; 69. var selStartDate = new Date(dateToday.getFullYear(), 0, 1); 70. var selEndDate = new Date(dateToday.getFullYear(), 11, 31); 71. scope.$watch(attrs.data, function (data) { 72. fullData = data; 73. if (fullData.length > 0) 74. separateData(); 75. }); 76. scope.$watch(attrs.startDate, function (startIndex) { 77. selStartDate = startIndex; 78. sDateMonth = selStartDate.getMonth(); 79. separateData(); 80. redrawLineChart(); 81. }); 82. scope.$watch(attrs.endDate, function (endDate) { 83. selEndDate = endDate; 84. eDateMonth = selEndDate.getMonth(); 85. separateData(); 86. redrawLineChart(); 87. }); 88. var updatedWonData = []; 89. var updatedLossData = []; 90. var wonData = [], lossData = []; 91. var padding = 20; 92. var pathClass = "path"; 93. var xScale, yScale, xAxisGen, yAxisGen, lineFun, m, w, h; 94. var d3 = $window.d3; 95. var rawSvg = element.find('svg'); 96. var svg = d3.select(rawSvg[0]); ```javascript function separateData() { wonData = []; lossData = []; var janWon = 0, febWon = 0, marWon = 0, aprWon = 0, mayWon = 0, junWon = 0, augWon = 0, sepWon = 0, octWon = 0, novWon = 0, decWon = 0; var janLoss = 0, febLoss = 0, marLoss = 0, aprLoss = 0, mayLoss = 0, junLoss = 0, augLoss = 0, sepLoss = 0, octLoss = 0, novLoss = 0, decLoss = 0; for (var i = 0; i < fullData.length; i++) { if (fullData[i].EstimationEndDate >= selStartDate && fullData[i].EstimationEndDate <= selEndDate) { if (fullData[i].PreSales_x0020_Outcome == 'Win') janWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') janLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '1') { if (fullData[i].PreSales_x0020_Outcome == 'Win') febWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') febLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '2') { if (fullData[i].PreSales_x0020_Outcome == 'Win') marWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') marLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '3') { if (fullData[i].PreSales_x0020_Outcome == 'Win') aprWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') aprLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '4') { if (fullData[i].PreSales_x0020_Outcome == 'Win') mayWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') mayLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '5') { if (fullData[i].PreSales_x0020_Outcome == 'Win') junWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') junLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '6') { if (fullData[i].PreSales_x0020_Outcome == 'Win') julWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') julLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '7') { if (fullData[i].PreSales_x0020_Outcome == 'Win') augWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') augLoss++; } else if (fullData[i].EstimationEndDate.getMonth() == '8') { if (fullData[i].PreSales_x0020_Outcome == 'Win') sepWon++; else if (fullData[i].PreSales_x0020_Outcome == 'Loss') sepLoss++; } } } ``` ```javascript 164. } else if (fullData[i].EstimationEndDate.getMonth() == 9) { 165. if (fullData[i].PreSales_x0020_Outcome == 'Win') 166. octWon++; 167. else if (fullData[i].PreSales_x0020_Outcome == 'Loss') 168. octLoss++; 169. } 170. } else if (fullData[i].EstimationEndDate.getMonth() == 10) { 171. if (fullData[i].PreSales_x0020_Outcome == 'Win') 172. novWon++; 173. else if (fullData[i].PreSales_x0020_Outcome == 'Loss') 174. novLoss++; 175. } 176. } else if (fullData[i].EstimationEndDate.getMonth() == 11) { 177. if (fullData[i].PreSales_x0020_Outcome == 'Win') 178. decWon++; 179. else if (fullData[i].PreSales_x0020_Outcome == 'Loss') 180. decLoss++; 181. } 182. } 183. } 184. wonData.push(janWon, febWon, marWon, aprWon, mayWon, junWon, julWon, augWon, sepWon, octWon, novWon, decWon); 185. updatedWonData.push(wonData); 186. lossData.push(janLoss, febLoss, marLoss, aprLoss, mayLoss, junLoss, julLoss, augLoss, sepLoss, octLoss, novLoss, decLoss); 187. updatedLossData.push(lossData); 188. drawLineChart(); 189. } 190. 191. function setChartParameters() { 192. m = [80, 80, 80, 80]; 193. w = 850 - m[1] - m[3]; 194. h = 400 - m[0] - m[2]; 195. updatedWonData = []; 196. updatedLossData = []; 197. var xMaxDomain, xLabelMax; 198. if (selStartDate.getFullYear() != selEndDate.getFullYear()) { 199. for (var i = sDateMonth; i <= eDateMonth; i++) { 200. updatedWonData.push(wonData[i]); 201. updatedLossData.push(lossData[i]); 202. } 203. for (var i = 0; i <= eDateMonth; i++) { 204. updatedWonData.push(wonData[i]); 205. updatedLossData.push(lossData[i]); 206. } 207. } else { 208. for (var i = sDateMonth; i <= eDateMonth; i++) { 209. updatedWonData.push(wonData[i]); 210. updatedLossData.push(lossData[i]); 211. } 212. } 213. 214. xMaxDomain = cDateMonth - sDateMonth + 1; 215. xLabelMax = new Date(selEndDate.getFullYear(), selEndDate.getMonth() + 1, 0).getDate(); 216. xLabels = d3.time.scale().domain([new Date(selEndDate.getFullYear(), selEndDate.getMonth(), 0), new Date(selEndDate.getFullYear(), selEndDate.getMonth(), xLabelMax)]).range([0, w]); 217. x = d3.scale.linear().domain([0, xMaxDomain]).range([0, w]); 218. } 219. return d;} 220. } 221. if (selStartDate.getFullYear() != selEndDate.getFullYear()) 222. xMaxDomain = 12 - sDateMonth + eDateMonth + 1; 223. else 224. xMaxDomain = cDateMonth - sDateMonth + 1; 225. xLabelMax = new Date(selEndDate.getFullYear(), selEndDate.getMonth() + 1, 0).getDate(); 226. xLabels = d3.time.scale().domain([new Date(selStartDate.getFullYear(), selStartDate.getMonth(), 0), new Date(selEndDate.getFullYear(), selEndDate.getMonth(), xLabelMax)]).range([0, w]); 227. x = d3.scale.linear().domain([0, xMaxDomain]).range([0, w]); ``` 224. y = d3.scale.linear().domain([0, 10]).range([h, 0]); 225. xAxis = d3.svg.axis().scale(xLabels).ticks(xMaxDomain).tickFormat(d3.time.format("%b")); 226. yAxisLeft = d3.svg.axis().scale(y).ticks(10).tickFormat(formatCurrency).orient("left"); 227. line = d3.svg.line() 228. .x(function (d, i) { 229. return x(i); 230. }) 231. .y(function (d) { 232. return y(d); 233. }) 234. } 235. 236. function drawLineChart() { 237. setChartParameters(); 238. var graph = svg.attr("width", w + m[1] + m[3]) 239. .attr("height", 350) 240. .append("svg:g") 241. .attr("transform", "translate(0," + h + "+"") 242. .call(xAxis); 243. graph.append("svg:g") 244. .attr("class", "x axis") 245. .attr("transform", "translate(0," + h + "+")") 246. .call(xAxis); 247. graph.append("svg:path") 248. .attr("class", "wonline") 249. .attr({ 250. d: line(updatedWonData) 251. }); 252. graph.append("svg:path") 253. .attr("class", "lossline") 254. .attr({ 255. d: line(updatedLlossData) 256. }); 257. graph.append("svg:path") 258. .attr("class", "wonline") 259. .attr({ 260. d: line(updatedWonData) 261. }); 262. graph.append("svg:path") 263. .attr("class", "lossline") 264. .attr({ 265. d: line(updatedLlossData) 266. }); 267. function redrawLineChart() { 268. setChartParameters(); 269. svg.selectAll(".y.axis").call(yAxisLeft); 270. svg.selectAll(".x.axis").call(xAxis); 271. svg.selectAll("." + "wonline") 272. .attr{ 273. d: line(updatedWonData) 274. }); 275. svg.selectAll("." + "lossline") 276. .attr{ 277. d: line(updatedLlossData) 278. }); 279. } 280. function drawLineChart() { 281. setChartParameters(); 282. var graph = svg.attr("width", w + m[1] + m[3]) 283. .attr("height", 350) 284. .append("svg:g") 285. .attr("transform", "translate(0," + h + "+")") 286. .call(xAxis); 287. graph.append("svg:g") 288. .attr("class", "x axis") 289. .attr("transform", "translate(0," + h + "+")") 290. .call(xAxis); 291. graph.append("svg:path") 292. .attr("class", "wonline") 293. .attr({ 294. d: line(updatedWonData) 295. }); 296. graph.append("svg:path") 297. .attr("class", "lossline") 298. .attr({ 299. d: line(updatedLlossData) 300. }); 301. } 6.3 Angular JS code for recent wins web part ```javascript /*global angular*/ (function () { 'use strict'; angular.module('preSalesApp').controller('AccordionCtrl', ['$scope', 'spManager', function ($scope) { $scope.oneAtATime = true; }]); })(); ``` Angular JS code for Health Check web part: ```javascript /*global angular*/ (function () { 'use strict'; angular.module('preSalesApp').controller('preSalesAppExtended', ['$scope', 'spManager', function ($scope, spManager) { $scope.data = []; $scope.redCor = 0; $scope.greenCor = 0; $scope.yellowCor = 0; $scope.itemsLength = 0; $scope.init = function () { var Context = SP.ClientContext.get_current(); var web = Context.get_web(); var oList = Context.get_web().get_lists().getByTitle('Presales'); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml("<View><RowLimit>100</RowLimit><Query><OrderBy><FieldRef Name='ID Ascending'='FALSE' /> <OrderBy><FieldRef Name='PreSales_x0020_Outcome' /> <Value Type='Choice'>Cancelled</Value> <Value Type='Choice'>On Hold</Value> <Value> </Value> </OrderBy></Where> </Query></View>"); var collImages = oList.getItems(camlQuery); Context.executeQueryAsync(function () { var imagesEnumerator = collImages.getEnumerator(); var imagesList = []; while (imagesEnumerator.moveNext()) { var item = imagesEnumerator.get_current(); var imageUrl = item.properties['PreSales_x0020_Doc_x0020_Url'] var description = item.properties['PreSales_x0020_Doc_x0020_Description'] $scope.data.push({ image: imageUrl, description: description }); } }, function () {}); } }); ``` while (imagesEnumerator.moveNext()) { var oImageItem = imagesEnumerator.get_current(); imagesList.push(oImageItem.get_fieldValues()); } var todayDate = new Date(); for (var i = 0; i < imagesList.length; i++) { if (imagesList[i].Requirement_x0020_Doc_x0020_exis == false) { $scope.redCor++; } else if (imagesList[i].Estimation_x0020_Reviewed == true) { $scope.yellowCor++; } else { $scope.greenCor++; } } $scope.$apply(); function(sender, args) { alert(args.get_message()); }); SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() { $scope.init() }); 6.4 Code for Estimation Values function updateEstimationValues(Context, updatedEstimates, stream) { var oList = Context.get_web().get_lists().getByTitle('PreSales Estimation Values'); var def = $q.defer(); var oListItem = oList.getItemById(updatedEstimates.ID); oListItem.set_item('Estimated_x0020_Hours', updatedEstimates.Estimated_x0020_Hours); oListItem.set_item('Actual_x0020_Hours', updatedEstimates.Actual_x0020_Hours); oListItem.set_item('Estimated_x0020_Cost', updatedEstimates.Estimated_x0020_Cost); oListItem.set_item('Actual_x0020_Cost', updatedEstimates.Actual_x0020_Cost); oListItem.set_item('Streams', stream); var projectName = ":" + $scope.itemCol.PreSalesProject.Label + ":" + $scope.itemCol.PreSalesProject.TermGuid; oListItem.set_item('PreSalesProject', projectName); oListItem.set_item('Title', $scope.itemCol.PreSalesProject.Label); oListItem.update(); Context.executeQueryAsync(function() { def.resolve(); }, function() { alert("fails"); def.reject("failed"); }); return def.promise; References 1. http://elegantsolutions.us/sharepoint-services/ 11. http://i.msdn.microsoft.com/dynimg/IC367367.jpg
{"Source-Url": "https://dspace.sunyconnect.suny.edu/bitstream/handle/1951/68904/vempati-final.pdf?isAllowed=y&sequence=1", "len_cl100k_base": 13017, "olmocr-version": "0.1.49", "pdf-total-pages": 46, "total-fallback-pages": 0, "total-input-tokens": 105125, "total-output-tokens": 16508, "length": "2e13", "weborganizer": {"__label__adult": 0.0004391670227050781, "__label__art_design": 0.0016803741455078125, "__label__crime_law": 0.00037169456481933594, "__label__education_jobs": 0.0278472900390625, "__label__entertainment": 0.000308990478515625, "__label__fashion_beauty": 0.0002646446228027344, "__label__finance_business": 0.00893402099609375, "__label__food_dining": 0.0005407333374023438, "__label__games": 0.0011739730834960938, "__label__hardware": 0.0010061264038085938, "__label__health": 0.00032067298889160156, "__label__history": 0.0004711151123046875, "__label__home_hobbies": 0.0004363059997558594, "__label__industrial": 0.000652313232421875, "__label__literature": 0.0004794597625732422, "__label__politics": 0.0002875328063964844, "__label__religion": 0.0004935264587402344, "__label__science_tech": 0.005878448486328125, "__label__social_life": 0.00032401084899902344, "__label__software": 0.0633544921875, "__label__software_dev": 0.88330078125, "__label__sports_fitness": 0.00033164024353027344, "__label__transportation": 0.0004172325134277344, "__label__travel": 0.00047659873962402344}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60256, 0.06163]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60256, 0.25097]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60256, 0.71707]], "google_gemma-3-12b-it_contains_pii": [[0, 332, false], [332, 764, null], [764, 1164, null], [1164, 3121, null], [3121, 6001, null], [6001, 7701, null], [7701, 9922, null], [9922, 11476, null], [11476, 13791, null], [13791, 14877, null], [14877, 15935, null], [15935, 17250, null], [17250, 18364, null], [18364, 19696, null], [19696, 21819, null], [21819, 23010, null], [23010, 25384, null], [25384, 26654, null], [26654, 27127, null], [27127, 28350, null], [28350, 29317, null], [29317, 30349, null], [30349, 31032, null], [31032, 31817, null], [31817, 32833, null], [32833, 33354, null], [33354, 33516, null], [33516, 33973, null], [33973, 34968, null], [34968, 35758, null], [35758, 36514, null], [36514, 37199, null], [37199, 37642, null], [37642, 37987, null], [37987, 38168, null], [38168, 38514, null], [38514, 41574, null], [41574, 43655, null], [43655, 45420, null], [45420, 47347, null], [47347, 50146, null], [50146, 52984, null], [52984, 55404, null], [55404, 57286, null], [57286, 58990, null], [58990, 60256, null]], "google_gemma-3-12b-it_is_public_document": [[0, 332, true], [332, 764, null], [764, 1164, null], [1164, 3121, null], [3121, 6001, null], [6001, 7701, null], [7701, 9922, null], [9922, 11476, null], [11476, 13791, null], [13791, 14877, null], [14877, 15935, null], [15935, 17250, null], [17250, 18364, null], [18364, 19696, null], [19696, 21819, null], [21819, 23010, null], [23010, 25384, null], [25384, 26654, null], [26654, 27127, null], [27127, 28350, null], [28350, 29317, null], [29317, 30349, null], [30349, 31032, null], [31032, 31817, null], [31817, 32833, null], [32833, 33354, null], [33354, 33516, null], [33516, 33973, null], [33973, 34968, null], [34968, 35758, null], [35758, 36514, null], [36514, 37199, null], [37199, 37642, null], [37642, 37987, null], [37987, 38168, null], [38168, 38514, null], [38514, 41574, null], [41574, 43655, null], [43655, 45420, null], [45420, 47347, null], [47347, 50146, null], [50146, 52984, null], [52984, 55404, null], [55404, 57286, null], [57286, 58990, null], [58990, 60256, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60256, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60256, null]], "pdf_page_numbers": [[0, 332, 1], [332, 764, 2], [764, 1164, 3], [1164, 3121, 4], [3121, 6001, 5], [6001, 7701, 6], [7701, 9922, 7], [9922, 11476, 8], [11476, 13791, 9], [13791, 14877, 10], [14877, 15935, 11], [15935, 17250, 12], [17250, 18364, 13], [18364, 19696, 14], [19696, 21819, 15], [21819, 23010, 16], [23010, 25384, 17], [25384, 26654, 18], [26654, 27127, 19], [27127, 28350, 20], [28350, 29317, 21], [29317, 30349, 22], [30349, 31032, 23], [31032, 31817, 24], [31817, 32833, 25], [32833, 33354, 26], [33354, 33516, 27], [33516, 33973, 28], [33973, 34968, 29], [34968, 35758, 30], [35758, 36514, 31], [36514, 37199, 32], [37199, 37642, 33], [37642, 37987, 34], [37987, 38168, 35], [38168, 38514, 36], [38514, 41574, 37], [41574, 43655, 38], [43655, 45420, 39], [45420, 47347, 40], [47347, 50146, 41], [50146, 52984, 42], [52984, 55404, 43], [55404, 57286, 44], [57286, 58990, 45], [58990, 60256, 46]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60256, 0.0]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
4df7bd55a0aa2096fb5e4207b87a4e2413ec067e
[REMOVED]
{"Source-Url": "http://researcher.ibm.com/researcher/files/us-csjutla/SAC06.pdf", "len_cl100k_base": 14303, "olmocr-version": "0.1.53", "pdf-total-pages": 18, "total-fallback-pages": 0, "total-input-tokens": 72095, "total-output-tokens": 17684, "length": "2e13", "weborganizer": {"__label__adult": 0.0006852149963378906, "__label__art_design": 0.0005211830139160156, "__label__crime_law": 0.001125335693359375, "__label__education_jobs": 0.0006413459777832031, "__label__entertainment": 0.0001633167266845703, "__label__fashion_beauty": 0.00024580955505371094, "__label__finance_business": 0.0004014968872070313, "__label__food_dining": 0.0006766319274902344, "__label__games": 0.0019512176513671875, "__label__hardware": 0.004016876220703125, "__label__health": 0.00135040283203125, "__label__history": 0.000518798828125, "__label__home_hobbies": 0.0002613067626953125, "__label__industrial": 0.0012607574462890625, "__label__literature": 0.0004329681396484375, "__label__politics": 0.00044345855712890625, "__label__religion": 0.0009083747863769532, "__label__science_tech": 0.302734375, "__label__social_life": 0.00011283159255981444, "__label__software": 0.008270263671875, "__label__software_dev": 0.67138671875, "__label__sports_fitness": 0.000659942626953125, "__label__transportation": 0.001056671142578125, "__label__travel": 0.0002911090850830078}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52287, 0.09828]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52287, 0.58114]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52287, 0.87989]], "google_gemma-3-12b-it_contains_pii": [[0, 3255, false], [3255, 7959, null], [7959, 11749, null], [11749, 15958, null], [15958, 19691, null], [19691, 23212, null], [23212, 26674, null], [26674, 29377, null], [29377, 31400, null], [31400, 32917, null], [32917, 35791, null], [35791, 38726, null], [38726, 38811, null], [38811, 41565, null], [41565, 43520, null], [43520, 46598, null], [46598, 49148, null], [49148, 52287, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3255, true], [3255, 7959, null], [7959, 11749, null], [11749, 15958, null], [15958, 19691, null], [19691, 23212, null], [23212, 26674, null], [26674, 29377, null], [29377, 31400, null], [31400, 32917, null], [32917, 35791, null], [35791, 38726, null], [38726, 38811, null], [38811, 41565, null], [41565, 43520, null], [43520, 46598, null], [46598, 49148, null], [49148, 52287, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52287, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52287, null]], "pdf_page_numbers": [[0, 3255, 1], [3255, 7959, 2], [7959, 11749, 3], [11749, 15958, 4], [15958, 19691, 5], [19691, 23212, 6], [23212, 26674, 7], [26674, 29377, 8], [29377, 31400, 9], [31400, 32917, 10], [32917, 35791, 11], [35791, 38726, 12], [38726, 38811, 13], [38811, 41565, 14], [41565, 43520, 15], [43520, 46598, 16], [46598, 49148, 17], [49148, 52287, 18]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52287, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
0102506765db910fa86e3b25272de5d94e969a66
[REMOVED]
{"Source-Url": "https://hal.archives-ouvertes.fr/hal-01089993/file/Genet-WRLA14.pdf", "len_cl100k_base": 15003, "olmocr-version": "0.1.53", "pdf-total-pages": 16, "total-fallback-pages": 0, "total-input-tokens": 67805, "total-output-tokens": 17786, "length": "2e13", "weborganizer": {"__label__adult": 0.0005040168762207031, "__label__art_design": 0.0006699562072753906, "__label__crime_law": 0.0006189346313476562, "__label__education_jobs": 0.0017099380493164062, "__label__entertainment": 0.00016176700592041016, "__label__fashion_beauty": 0.000270843505859375, "__label__finance_business": 0.0004527568817138672, "__label__food_dining": 0.0005974769592285156, "__label__games": 0.0013990402221679688, "__label__hardware": 0.0012636184692382812, "__label__health": 0.0014171600341796875, "__label__history": 0.0005259513854980469, "__label__home_hobbies": 0.00020194053649902344, "__label__industrial": 0.0008392333984375, "__label__literature": 0.0008072853088378906, "__label__politics": 0.0005016326904296875, "__label__religion": 0.0008530616760253906, "__label__science_tech": 0.251708984375, "__label__social_life": 0.00015926361083984375, "__label__software": 0.008392333984375, "__label__software_dev": 0.7255859375, "__label__sports_fitness": 0.00041103363037109375, "__label__transportation": 0.000911712646484375, "__label__travel": 0.0002613067626953125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52697, 0.02924]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52697, 0.5935]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52697, 0.77079]], "google_gemma-3-12b-it_contains_pii": [[0, 996, false], [996, 3615, null], [3615, 6588, null], [6588, 11513, null], [11513, 14801, null], [14801, 18413, null], [18413, 22105, null], [22105, 25478, null], [25478, 28393, null], [28393, 31578, null], [31578, 35237, null], [35237, 39508, null], [39508, 42535, null], [42535, 46136, null], [46136, 49296, null], [49296, 52697, null]], "google_gemma-3-12b-it_is_public_document": [[0, 996, true], [996, 3615, null], [3615, 6588, null], [6588, 11513, null], [11513, 14801, null], [14801, 18413, null], [18413, 22105, null], [22105, 25478, null], [25478, 28393, null], [28393, 31578, null], [31578, 35237, null], [35237, 39508, null], [39508, 42535, null], [42535, 46136, null], [46136, 49296, null], [49296, 52697, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52697, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52697, null]], "pdf_page_numbers": [[0, 996, 1], [996, 3615, 2], [3615, 6588, 3], [6588, 11513, 4], [11513, 14801, 5], [14801, 18413, 6], [18413, 22105, 7], [22105, 25478, 8], [25478, 28393, 9], [28393, 31578, 10], [31578, 35237, 11], [35237, 39508, 12], [39508, 42535, 13], [42535, 46136, 14], [46136, 49296, 15], [49296, 52697, 16]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52697, 0.03226]]}
olmocr_science_pdfs
2024-12-12
2024-12-12
f98a2ede6366699a1a865902393d336bb4869a2b
Monadic Fold, Monadic build, Monadic Short Cut Fusion By: Patricia Johann and Neil Ghani Abstract: Short cut fusion improves the efficiency of modularly constructed programs by eliminating intermediate data structures produced by one program component and immediately consumed by another. We define a combinator which expresses uniform production of data structures in monadic contexts, and is the natural counterpart to the well-known monadic fold which consumes them. Like the monadic fold, our new combinator quantifies over monadic algebras rather than standard ones. Together with the monadic fold, it gives rise to a new short cut fusion rule for eliminating intermediate data structures in monadic contexts. This new rule differs significantly from previous short cut fusion rules, all of which are based on combinators which quantify over standard, rather than monadic, algebras. We give examples illustrating the benefits of quantifying over monadic algebras, prove our new fusion rule correct, and show how it can improve programs. We also consider its coalgebraic dual. 1 THE PROBLEM Consider the following variation on the well-known problem of fusing modular list-processing functions [5]. Suppose we want to sum the cubes of all the integers in a list. Suppose further that cubing any of the integers in the list can generate an out-of-range error, and that each of the partial sums of their cubes can also generate an out-of-range error. If out-of-range errors are tested for using outOfRange :: Int -> Maybe Int, where the datatype data Maybe a = Nothing | Just a is the standard error-handling monad given in the Haskell prelude, then it is natural to write this program as the composition of two functions: i) a function mmapcube :: [Int] -> Maybe [Int] which checks whether the cube of any integer in its input list generates an out-of-range error and, if so, propagates the error, and ii) a function msum :: [Int] -> Maybe Int which sums the elements of a list of integers, checking along the way whether each accumulated partial sum generates an out-of-range error. We’d have msumOfCubes xs = mmapcube xs >>= msum where Nothing >>= k = Nothing and Just x >>= k = k x, as usual. If we want to optimize this program by eliminating the intermediate structure of type Maybe [Int] produced by mmapcube and consumed by \x -> x >>= msum, then we might look to the standard short cut — i.e., fold/build — fusion rule [5] for inspiration. Recalling that >>= is the analogue of composition for monadic computations, we first observe that the pure analogues mapcube and sum of the monadic functions mmapcube and msum above can be written in terms of the well-known uniform list-consuming and -producing functions foldr and build given in Figure 1. Letting cube x = x * x * x we have mapcube :: [Int] -> [Int] mapcube xs = build (\c n -> foldr (c . cube) n xs) *University of Strathclyde, Glasgow, Scotland. (patricia,ng)@cis.strath.ac.uk. foldr :: (b -> a -> a) -> a -> [b] -> a foldr c n [] = n foldr c n (x:xs) = c x (foldr c n xs) build :: (forall a. (b -> a -> a) -> a -> a) -> [b] build g = g (:) [] foldr c n (build g) = g c n FIGURE 1. The foldr and build combinators and foldr/build rule for lists. sum :: [Int] -> Int sum = foldr (+) 0 The composition of mapcube and sum gives a non-error-checking version of mmapcube which be fused via the foldr/build rule, also given in Figure 1, as follows: sum (mapcube xs) = foldr (+) 0 (build (\c n -> foldr (c . cube) n xs)) = (\c n -> foldr (c . cube) n xs) (+) 0 = foldr ((+) . cube) 0 xs Note that the intermediate list produced by mapcube and immediately consumed by sum in sum (mapcube xs) is not constructed by the fused program. In the monadic setting we wish to eliminate not just the intermediate list of cubes, but rather an entire intermediate structure of type Maybe [Int]. In general, in the monadic setting we seek to eliminate not just intermediate data structures, but intermediate data structures within monadic contexts. In the case of msumOfCubes we can write the monadic consumer msum in terms of the standard fold combinator for lists. Indeed we have msum = foldr (\x p -> do {v <- p; z <- outOfRange x outOfRange (z + v)}) (Just 0) But we cannot similarly write the monadic producer msumcube in terms of the standard build combinator for lists. The difficulty is that build produces a list of type [t], whereas msumcube produces a structure of type Maybe [t]. It is thus unclear how to write msumOfCubes in terms of fold and build for lists, or how to fuse msumOfCubes using standard short cut fusion. And although fold and build combinators and short cut fusion rules can be defined generically for all inductive types as in Figure 2, they are also unsuitable for fusing msumOfCubes because Maybe [t] is not an inductive type except in a trivial way. The central question considered in this paper is whether or not there is a variant of short cut fusion which can fuse modular monadic programs like msumOfCubes. We answer in the affirmative by first giving a monadic build combinator to complement the monadic fold combinator from the literature [1, 10, 11] in the same way that the standard build combinator complements the standard fold combinator. We then give a monadic short cut rule for fusing monadic compositions (i.e., newtype Mu f = In {unIn :: f (Mu f)} fold :: Functor f => (f a -> a) -> Mu f -> a fold h (In k) = h (fmap (fold h) k) build :: Functor f => (forall a. (f a -> a) -> c -> a) -> c -> Mu f build g = g In fold k . build g = g k FIGURE 2. The fold and build combinators and fold/build rule. binds) of functions written in terms of monadic fold and build, and show how it solves the msumOfCubes problem outlined above. Finally, we prove the correctness of our monadic short cut fusion rule. Our monadic combinators and short cut fusion rule are given in Figure 3 and explained in Section 2.2. As we shall see later, their conceptual basis lies in the observation that, in a monadic setting, it is fruitful to consider not just standard algebras — i.e., pure functions \( f : a \rightarrow a \) where \( f \) is the functor underlying the datatype of the inductive structure to be eliminated “in context” — but rather monadic algebras, i.e., functions \( f : a \rightarrow m a \) where \( m \) is the monad in question. Just as the monadic fold combinator consumes monadic, rather than standard, algebras, so the monadic build combinator introduced herein quantifies over monadic, rather than standard, algebras. Our monadic short cut fusion rule thus eliminates not just intermediate data structures, like \([t]\), but also intermediate structures situated in monadic contexts, like \(\text{Maybe } [t]\). The remainder of this paper is structured as follows. In Section 2 we discuss background and related work; in particular we consider the relative merits of structuring code using standard fold and monadic fold. In Section 3 we apply our monadic fusion rule to a larger application, namely an interpreter for nondeterministic expressions. In Section 4 we prove our main result, the correctness of our monadic fusion rule. In Section 5 we consider its coalgebraic dual. Finally, in Section 6 we set out some directions for future work and conclude. 2 BACKGROUND AND RELATED WORK 2.1 Short Cut Fusion for Inductive Types Inductive datatypes are fixed points of functors. Functors can be implemented in Haskell as type constructors supporting \( \text{fmap} \) functions as follows: \[ \text{class Functor } f \text{ where} \\ \quad \text{fmap} :: (a \rightarrow b) \rightarrow f a \rightarrow f b \] The function \( \text{fmap} \) is expected to satisfy the two semantic functor laws stating that \( \text{fmap} \) preserves identities and composition. It is well-known that analogues of \( \text{foldr} \) exist for every inductive datatype. As shown in \([3, 4]\), every inductive type also has an associated generalized \( \text{build} \) combinator and \( \text{fold/build} \) rule; these mfold :: (Functor f, Monad m, Dist f m) => (f a -> m a) -> Mu f -> m a mfold h = fold (\xs -> delta xs >>= h) mbuild :: (Functor f, Monad m) => (forall a. (f a -> m a) -> c -> m a) -> c -> m (Mu f) mbuild g = g (return . In) mbuild g c >>= mfold h = g h c FIGURE 3. The mfold and mbuild combinators and mfold/mbuild rule. can be implemented generically in Haskell as in Figure 2. There, Mu f represents the least fixed point of the functor f, and In represents the structure map for f, i.e., the “bundled” constructors for the datatype Mu f. The “extra” type c in the type of build is motivated in citegjuv05,guv03 and to lesser extent in Section 4 below. The fold/build rule for inductive types can be used to eliminate data structures of type Mu f from computations. The foldr and build combinators for lists can be recovered by taking f to be the functor whose fixed point is [b]; the foldr/build rule can be recovered by taking, in addition, c to be the unit type. 2.2 Short Cut Fusion in the Presence of Monads Monads model a variety of computational effects. They are implemented in Haskell as type constructors supporting >>= and return operations as follows: class Monad m where return :: a -> m a (>>=) :: m a -> (a -> m b) -> m b These operations are expected to satisfy the semantic monad laws [9]. The monadic fold combinator mfold given in Figure 3 is well-known [1, 10, 11]. It is defined in terms of the standard fold and a distributivity law delta :: f (m a) -> m (f a) which describes how the results of monadic computations embodied by m on components of a data structure described by a functor f are propagated to the overall data structure; distributivity laws can be implemented in Haskell using the class Dist f m of types, each of which supports a distributivity law for f and m. But, until now, a monadic build which complements the monadic fold in the same way that the standard build complements the standard fold has not been given. Thus, although monadic fusion has been studied by other researchers [8, 10, 11, 12], all techniques developed thus far involve the standard fold rather than its monadic counterpart. In particular, a monadic short cut fusion rule — i.e., a short cut rule for programs expressed in terms of monadic fold and monadic build — has until now not been studied. To define a monadic build combinator we first observe that the functional argument to such a build, and thus the monadic build combinator itself, must have a monadic return type. Moreover, just as we expect the functions the monadic fold combinator uses to consume a data structure to have monadic return types, we also expect the monadic build combinator to quantify over all uses of functions with monadic return types to consume such structures. This leads us to define the monadic build combinator mbuild given in Figure 3. Then, to optimize modular programs constructed from these combinators we can also introduce the monadic short cut fusion rule for mfold and mbUILD given there. Unlike the monadic fusion rule of [11], which eliminates the data structure but leaves the monadic context in which it is situated intact, the rule in Figure 3 eliminates both the entire intermediate data structure and its entire monadic context. The correctness of this rule is the main result of this paper. We prove it in Section 4 below. To demonstrate the monadic combinators and fusion rule, we use them to solve the msumOfCubes problem from the introduction. We can specialize the combinators and rule in Figure 3 to \( f x = N \mid C \text{ Int } x, m = \text{Maybe}, \) and \[ \text{delta } N = \text{Just } N \\ \text{delta } (C \text{ i } y) = \text{do } (v <- y; \text{Just } (C \text{ i } v)) \] to get the constructs in Figure 4. We have \[ \text{msum} = \text{mfoldl } (\Lambda x y \rightarrow \text{outOfRange } (x + y)) \ (\text{return } 0) \] \[ \text{mmapcube } = \text{mbuildl } g \text{ where} \\ g :\ (\text{Int } \rightarrow a \rightarrow \text{Maybe } a) \rightarrow \text{Maybe } a \rightarrow [\text{Int}] \rightarrow \text{Maybe } a \\ g \ c \ n \ [] = n \\ g \ c \ n \ (v:vs) = \text{do } \{k <- \text{outOfRange } (\text{cube } v); z <- g \ c \ n \ vs; c \ k \ z\} \] Applying the monadic fusion rule from Figure 4 to msumOfCubes gives \[ \text{msumOfCubes } xs = \text{mmapcube } xs \gg= \text{msum} \\ = \text{mbuildl } g \ x s \gg= \\ \text{mfoldl } (\Lambda x y \rightarrow \text{outOfRange } (x + y)) \ (\text{return } 0) \\ = g \ (\Lambda x y \rightarrow \text{outOfRange } (x + y)) \ (\text{return } 0) \ x s \] Thus \[ \text{msumOfCubes } [] = \text{return } 0 \\ \text{msumOfCubes } (v:vs) = \text{do } \{k <- \text{outOfRange } (\text{cube } v); z <- \text{msumOfCubes } vs; \text{outOfRange } (k + z)\} \] This fused version performs its range checks “on the fly” rather than prior to sum- mimg the cubes of the elements of its input list, and aborts the summing compu- tation if any individual element of \( \text{xs} \) or any of its partial sums is out-of-range. We now discuss the relative merits of structuring code with \texttt{fold} versus with \texttt{mfold}. This is critical, since the usefulness of our \texttt{mbuild} combinator and \texttt{mfold/} \texttt{mbuild} fusion rule depends on that of the \texttt{mfold} combinator. It turns out that we can write consumers like \texttt{msum} in terms of either \texttt{mfold} or \texttt{fold}. Indeed, every standard algebra \( f \ a \rightarrow a \) can be turned into a monadic one and, in the presence of distributivity, every monadic algebra can be turned into a standard one. So, in the presence of distributivity, \texttt{fold} and \texttt{mfold} are equally expressive. Which, then, should we prefer? Both of these combinators recursively act on the subterms of a term to produce results which are of monadic type. The standard \texttt{fold} combinator then uses an algebra of type \( f \ (m \ a) \rightarrow m \ a \) to combine these results into an overall result for the original term. The carrier of the standard \texttt{fold}'s algebra is \( m \ a \), which means that the programmer must specify how the monadic contexts generated by the recursive calls will be propagated to the original term. By contrast, the \texttt{mfold} combinator is used together with a distributivity law, whose role is precisely to achieve this propagation. The role of the monadic algebra of type \( f \ a \rightarrow m \ a \) is thus to describe how \textit{pure} values can be combined and/or generate new effects. Thus, there is a trade-off between structuring code with standard \texttt{folds} and monadic \texttt{folds}. Using the \texttt{mfold} combinator frees the programmer from having to manually propagate the monadic contexts produced by the recursive subcalls. The price paid is having to provide a distributivity law up front. Thus, in the presence of an appropriate distributivity law, programming can proceed as if the recursive calls produced pure, rather than monadic, computations. This seems an excellent trade: it is easier to modularize the problem and supply a monadic alge- bra than to supply a standard algebra with a monadic carrier. By contrast, using the standard \texttt{fold} essentially amounts to programming by hand the plumbing that \texttt{mfold} does automatically. Thus, were we to use \texttt{fold} rather than \texttt{mfold}, we would in effect be hardwiring the definition of \texttt{mfold} in terms of \texttt{fold} into every algebra supplied to \texttt{fold}. Abstraction of common patterns of recursion into combi- nators — as \texttt{mfold} does — is widely recognized as key to writing clear, concise, and correct code, so we advocate using the monadic approach whenever possible. 3 APPLICATION: EVALUATING NONDETERMINISTIC EXPRESSIONS Consider the following datatype of nondeterministic expressions: \[ \text{data NExp} = \text{NVar Char} \mid \text{NNum Int} \mid \text{NAdd NExp NExp} \\ \mid \text{NSet Char NExp} \mid \text{NOr NExp NExp} \] The first three clauses of this definition represent variables, integers, and sums. Ex- pressions of the form \texttt{NSet c e} assign the value of \( e \) to the variable with name \( c \), and those of the form \texttt{NOr e1 e2} represent the nondeterministic choice of \( e1 An evaluator for nondeterministic expressions must keep track of both the environment with respect to which the expression is evaluated and the nondeterminism introduced by the \texttt{NOr} constructor. Computations involving environments can be modeled by the state monad, while those involving nondeterminism can be modeled by the list monad. The canonical way to model computations involving both is to apply the state monad transformer to the list monad. This gives \begin{verbatim} newtype NState s a = NSt {runNState :: s -> [(a,s)]} instance Monad (NState s) where return x = NSt ( s -> [(x,s)]) NSt f >>= g = NSt ( s -> concat [runNState (g v) s' | (v, s') <- f s]) \end{verbatim} The type of an evaluator \texttt{evalNExp} for nondeterministic expressions is \texttt{evalNExp :: NExp -> NState Env Int}, where \texttt{type Env = Char -> Int} defines a type of environments mapping variable names to integer values. We construct \texttt{evalNExp} as a composition of two functions. The first one, called \texttt{compile}, takes as input a nondeterministic expression and returns a list of expressions not containing the \texttt{NOr} constructor; we say that such expressions are \textit{deterministic}. Rather than using \texttt{NExp} to represent both deterministic expressions and nondeterministic ones — thereby leaving the determinism constraint implicit at the meta-level — we introduce an object-level datatype to represent deterministic expressions. We have \begin{verbatim} data DExp = DVar Char | DNum Int | | DAdd DExp DExp | DSet Char DExp \end{verbatim} Thus \texttt{compile} has type \texttt{NExp -> NState Env DExp}. The second function used to construct \texttt{evalNExp} is an evaluator \texttt{evalDExp :: DExp -> NState Env Int} for deterministic expressions. In essence, the modular approach reduces the problem of constructing an evaluator for nondeterministic expressions to the problem of constructing one for deterministic expressions. We have \begin{verbatim} evalNExp e = compile e >>= evalDExp We can write \texttt{evalDExp} using the instance of \texttt{mfold} for \texttt{DExp}. We have \end{verbatim} \begin{verbatim} evalDExp = mfoldDExp fetch return (\i j -> return (i+j)) update \end{verbatim} where \begin{verbatim} fetch :: Char -> NState Env Int fetch c = NSt ( e -> [(e, c -> if c == c' then i else e c')] ) \end{verbatim} looks up the value of a variable in the current environment and \begin{verbatim} update :: Char -> Int -> NState Env Int update c i = NSt ( e -> [(i, \c' -> if c == c' then i else e c')] ) \end{verbatim} makes a new environment which is obtained from the current one by updating the binding for the variable \texttt{c} to \texttt{i}. In addition, mfoldDExp :: Monad m => (Char -> m a) -> (Int -> m a) -> (a -> a -> m a) -> (Char -> a -> m a) -> DExp -> m a mfoldDExp v n a s = foldDExp v n (\e1 e2 -> do {x1 <- e1; x2 <- e2; a x1 x2}) (\i e -> do {x <- e; s i x}) is defined in terms of the instance of the standard fold combinator for DExp: foldDExp :: (Char -> a) -> (Int -> a) -> (a -> a -> a) -> (Char -> a -> a) -> DExp -> a foldDExp v n a s (DVar x) = v x foldDExp v n a s (DNum i) = n i foldDExp v n a s (DAdd e1 e2) = a (foldDExp v n a s e1) (foldDExp v n a s e2) foldDExp v n a s (DSet x e) = s x (foldDExp v n a s e) This definition of mfoldDExp in terms of foldDExp is the result of instantiating the definition of mfold in terms of fold for the datatype DExp. Of course, we could define evalDExp in terms of foldDExp. This would require manually ex- tracting the results of evaluating subterms from the monad before combining them to produce the result for an entire term, rather than hiding the extraction within the mfoldDExp combinator. For example, using fold would require a function add :: NState Env Int -> NState Env Int -> NState Env Int to interpret the DAdd constructor, whereas using mfold requires only an inter- preting function for DAdd with type Int -> Int -> NState Env Int. This is a specific instance of the general phenomenon described at the end of Section 2. Finally, the function compile is written in terms of mbuildDExp as follows: compile = mbuildDExp g where g v n a s (NVar x) = v x g v n a s (NNum i) = n i g v n a s (NAdd el e2) = do {x1 <- g v n a s el; x2 <- g v n a s e2; a x1 x2} g v n a s (NSet x e) = do {z <- g v n a s e; s x z} g v n a s (NOr el e2) = njoin (g v n a s el) (g v n a s e2) njoin :: NState s a -> NState s a -> NState s a njoin (NST f) (NST g) = NST (\s -> f s ++ g s) Here, mbuildDExp is the instantiation of mbuild for DExp: mbuildDExp :: Monad m => (forall a. (Char -> m a) -> (Int -> m a) -> (a -> a -> m a) -> (Char -> a -> m a) -> DExp) -> m a mbuildDExp g = g (return . DVar) (return . DNum) (return . DAdd) (return . DSet) We can optimize the modular function evalNExp using the instantiation of the monadic fusion rule for the monad NState and the functor whose fixed point is DExp. The instantiation is mbuildDExp \ g \ x \ >>\ = \ mfoldDExp \ v \ n \ a \ s = \ g \ v \ n \ a \ s \ x Fusing with this rule gives \begin{align*} \text{evalNExp } & e \\ = & \text{compile } e \ >>\ = \ \text{evalDExp} \\ = & \text{mbuildDExp } g \ e \ >>\ = \ \text{mfoldDExp } \text{fetch } \text{return} \\ = & g \ \text{fetch } \text{return} \ (\lambda \ i \ j \ -> \ \text{return} \ (i+j)) \ \text{update} \\ = & \text{case } e \ \text{of} \\ = & \text{NVar } x \ -> \ \text{fetch } x \\ = & \text{NNum } i \ -> \ \text{return} \ i \\ = & \text{NAdd } e1 \ e2 \ -> \ \text{do} \ (x1 <- \ \text{evalNExp } e1; \ x2 <- \ \text{evalNExp } e2; \ \text{return} \ (x1 + x2)) \\ = & \text{NSet } x \ e \ -> \ \text{do} \ (z <- \ \text{evalNExp } e; \ \text{update } x \ z) \\ = & \text{NOr } e1 \ e2 \ -> \ \text{njoin} \ (\text{evalNExp } e1) \ (\text{evalNExp } e2) \end{align*} This fused version of \text{evalNExp} does not construct the intermediate structure of type \text{NState Env DExp} produced by \text{mbuildDExp} and consumed by \text{mfoldDExp}. 4 CORRECTNESS 4.1 Categorical Preliminaries Let \( C \) be a category and \( F \) be an endofunctor on \( C \). An \( F \)-algebra is a morphism \( h : FA \to A \) in \( C \). The object \( A \) is called the carrier of the \( F \)-algebra. The \( F \)-algebras for a functor \( F \) are objects of a category called the category of \( F \)-algebras and denoted \( F\text{-alg} \). A morphism from \( h : FA \to A \) to \( g : FB \to B \) in \( F\text{-alg} \) is a morphism \( f : A \to B \) such that \( g \circ Ff = f \circ h \). We call such a morphism an \( F \)-algebra morphism. If the category of \( F \)-algebras has an initial object then Lambek’s Lemma ensures that this initial \( F \)-algebra is an isomorphism, and thus that its carrier is a fixed point of \( F \). Initiality ensures that the carrier of the initial \( F \)-algebra is actually a least fixed point of \( F \). If it exists, the least fixed point for \( F \) is unique up to isomorphism. Henceforth we write \( \mu F \) for the least fixed point for \( F \) and \( \text{in} : F(\mu F) \to \mu F \) for the initial \( F \)-algebra. Within the paradigm of initial algebra semantics, every datatype is the carrier \( \mu F \) of the initial algebra of a suitable endofunctor \( F \) on a suitable category \( C \). The unique \( F \)-algebra morphism from \( \text{in} \) to any other \( F \)-algebra \( h : FA \to A \) is given by the interpretation \text{fold} of the \text{fold} combinator for the interpretation \( \mu F \) of the datatype \( \mu F \). The \text{fold} combinator for \( \mu F \) thus makes the following commute: \[ \begin{array}{c} \xymatrix{ F(\mu F) & FA \\ \mu F \ar[u]^-{\text{in}} \ar[r]_-{\text{fold } h} & A \\ \mu F \ar[u]_{\text{fold } h} & A \\ }\end{array} \] From this diagram, we see that \text{fold} has type \((FA \to A) \to \mu F \to A\) and that \text{fold } h satisfies \text{fold } h \ (\text{in } t) = h \ (F \ (\text{fold } h) \ t) \). The uniqueness of the mediating map between \textit{in} and \textit{h} ensures that, for every \( F \)-algebra \( h \), the map \textit{fold} \( h \) is defined uniquely. As shown in [4], the carrier of the initial algebra of an endofunctor \( F \) on \( \mathcal{C} \) can be seen not only as the carrier of the initial \( F \)-algebra, but also as the limit of the forgetful functor \( U_{F} : F\text{-}\text{Alg} \to \mathcal{C} \) mapping each \( F \)-algebra \( h : FA \to A \) to \( A \) and each morphism between \( F \)-algebras to itself. If \( G : \mathcal{C} \to \mathcal{D} \) is a functor, then a \textit{cone} \( \tau : D \to G \) to the base \( G \) with vertex \( D \) is an object \( D \) of \( \mathcal{D} \) and a family of morphisms \( \tau_{C} : D \to GC \), one for every object \( C \) of \( \mathcal{C} \), such that for every arrow \( \sigma : A \to B \) in \( \mathcal{C} \), \( \tau_{B} = G\sigma \circ \tau_{A} \) holds. We usually refer to a cone simply by its family of morphisms, rather than the pair comprising the vertex together with the family of morphisms. A \textit{limit} for \( G : \mathcal{C} \to \mathcal{D} \) is an object \( \lim G \) of \( \mathcal{D} \) and a limiting cone \( \nu : \lim G \to G \), i.e., a cone \( \nu : \lim G \to G \) with the property that if \( \tau : D \to G \) is any cone, then there is a unique morphism \( \theta : D \to \lim G \) such that \( \tau_{A} = \nu_{A} \circ \theta \) for all \( A \in \mathcal{C} \). The characterization of \( \mu F \) as \( \lim U_{F} \) provides a principled derivation of the interpretation \textit{build} of the \textit{build} combinator for \( \mu F \) which complements the derivation of its \textit{fold} combinator from standard initial algebra semantics. It also guarantees the correctness of the standard \textit{fold}/\textit{build} rule. Indeed, the universal property that the carrier \( \mu F \) of the initial \( F \)-algebra enjoys as \( \lim U_{F} \) ensures: - The projection from the limit \( \mu F \) to the carrier of each \( F \)-algebra defines the \textit{fold} operator with type \((FA \to A) \to \mu F \to A\). - Given a cone \( \theta : C \to U_{F} \), the mediating morphism from it to the limiting cone \( \nu : \lim U_{F} \to U_{F} \) defines a map from \( C \) to \( \lim U_{F} \), i.e., from \( C \) to \( \mu F \). - The correctness of the \textit{fold}/\textit{build} rule then follows from the fact that \( \textit{fold} k \) after \( \textit{build} g \) is a projection after a mediating morphism, and thus is equal to the cone \( g \) applied to the specific algebra \( k \). 4.2 A Categorical Interpretation of the Monadic Fusion Rule The key to proving the correctness of our monadic fusion rule is to interpret a suitable variant of the preceding diagram in a suitable category. Let \( \mathcal{C} \) be a category. A monad on \( \mathcal{C} \) is a functor \( M : \mathcal{C} \to \mathcal{C} \) together with two operations \( \text{bind} : MA \to (A \to MB) \to MB \) (normally written infix as \( \gg= \)) and \( \text{return} : A \to MA \) satisfying the monad laws [9]. If \( M \) is a monad on \( \mathcal{C} \), then the Kleisli category of \( M \) is the category \( \mathcal{C}_M \) whose objects are the objects of \( \mathcal{C} \), and whose morphisms from \( A \) to \( B \) are the morphisms from \( A \) to \( MB \) in \( \mathcal{C} \). The identity morphism in \( \mathcal{C}_M \) is return, and the composition of morphisms \( h : A \to B \) and \( k : B \to C \) in \( \mathcal{C}_M \) is given by \( k \circ h = k \circ h \), where \( f^* \) is defined to be \( \lambda x.(x \gg= f) \) for any morphism \( f \) in \( \mathcal{C} \), and the computation on the right-hand side is performed in \( \mathcal{C} \). A distributive law for a monad \( M : \mathcal{C} \to \mathcal{C} \) over a functor \( F : \mathcal{C} \to \mathcal{C} \) is a natural transformation \( \delta : FM \to MF \). Let \( \mu_A = \text{id}_A^* \), and note that if \( f : A \to MB \), then \( f^* = \mu_B \circ Mf \). Also note that \( Mf = (\text{return} \circ f)^* \). We use these well-known facts about monads later. Suppose \( \delta \) is a distributive law for \( M \) over \( F \) satisfying \[ \begin{align*} \delta_A \circ F\text{return} &= \text{return}_{FA} \\ \mu_{FA} \circ M\delta_A \circ \delta_{MA} &= \delta_A \circ F\mu_A \end{align*} \] We can define a functor \( \hat{F} : \mathcal{C}_M \to \mathcal{C}_M \) by \( \hat{F}A = FA \) and \( \hat{F}k = \delta \circ Fk \). The functor \( \hat{F} \) is called the monadic extension of \( F \) by \( M \). If \( k : A \to B \) then \( \hat{F}k : \hat{F}A \to \hat{F}B \). An \( M \)-monadic \( F \)-algebra, or \( MF \)-algebra for short, is an \( \hat{F} \)-algebra or, equivalently, a morphism \( h : FA \to MA \) in \( \mathcal{C} \). A morphism between \( MF \)-algebras \( k_1 : FA \to A \) and \( k_2 : FB \to B \) is an \( \hat{F} \)-algebra homomorphism in \( \mathcal{C}_M \). From the definition of composition in \( \mathcal{C}_M \), we see that such a morphism is simply a map \( f : A \to MB \) in \( \mathcal{C} \) such that \( f^* \circ k_1 = k_2 \circ \delta \circ Ff \). The forgetful functor \( U_{MF} \) from the category of \( MF \)-algebras to \( \mathcal{C}_M \) maps each \( MF \)-algebra \( h : FA \to A \) in \( \mathcal{C}_M \) to \( A \) and each morphism between \( MF \)-algebras to itself. We are thus interested in the interpretation, in \( \mathcal{C}_M \), of the following variant of the diagram at the end of Section 4.1: \[ A \xrightarrow{k} C \\ \downarrow \text{mfold} \downarrow \mu F \\ \end{array} \] Here, \( \text{mfold} \) and \( \text{mbuild} \) are the interpretations in \( \mathcal{C}_M \) of \( \text{mfold} \) and \( \text{mbuild} \), respectively. \( M \) is the interpretation of \( m \) in the types of \( \text{mfold} \) and \( \text{mbuild} \), and \( \text{bind} \) and \( \text{return} \) are the interpretations of the \( \gg= \) and \( \text{return} \) operations for \( m \), respectively. In other words, we are interested in showing that \( \mu F \) is the limit of \( U_{MF} \) in \( \mathcal{C}_M \). Then, by the same reasoning as in Section 4.1, we would have that - The projection from the limit \( \mu F \) to the carrier of each \( MF \)-algebra would define the \( mf \text{fold} \) operator mapping each \( \hat{F} \)-algebra with carrier \( A \) to a map --- 1 Implicit in the notation \( \lambda x.x \gg= f \) is the assumption that \( \mathcal{C} \) is cartesian closed. This is a reasonable assumption for programming language semantics; in particular, it is a consequence of parametricity. from \(\mu F\) to \(A\) in \(\mathcal{C}_M\), i.e., would define the \(mfold\) operator with type \((FA \rightarrow MA) \rightarrow \mu F \rightarrow MA\) in \(\mathcal{C}\). - Given a cone \(\theta : C \rightarrow U_{MF}\), the mediating morphism from it to the limiting cone \(\nu : \lim U_{MF} \rightarrow U_{MF}\) would define a map from \(C\) to \(\lim U_{MF}\), i.e., from \(C\) to \(\mu F\). Since such a cone maps each \(\hat{F}\)-algebra with carrier \(A\) to a map from \(C\) to \(A\) in \(\mathcal{C}_M\), it would define the \(mbuild\) operator with type \((\forall x. (Fx \rightarrow Mx)) \rightarrow C \rightarrow M(\mu F)\) in \(\mathcal{C}\). - The correctness of the \(mfold/mbuild\) monadic fusion rule would then follow from the fact that \(mfold k\) after \(mbuild g\) is a projection after a mediating morphism in \(\mathcal{C}_M\), and thus is equal to the cone \(g\) applied to the specific algebra \(k\). We would therefore have precisely the previous diagram for \(k : \hat{F}A \rightarrow A\) in \(\mathcal{C}_M\), i.e., we'd have \(mbuild g x \gg mfold k = g k x\), as desired. So, we need to show that \(\mu F = \lim U_{MF}\) in \(\mathcal{C}_M\), i.e., we need to show that i) \(mfold\) defines a cone to the base \(U_{MF}\) with vertex \(\mu F\). We therefore show that \(\rho \cdot mfold k_A = mfold k_B\) for all \(A\) and \(B\) and all morphisms \(\rho\) in \(\mathcal{C}_M\) from \(k_A : FA \rightarrow A\) to \(k_B : FB \rightarrow B\); and that ii) if \(g\) is a cone to the base \(U_{MF}\) with vertex \(C\), i.e., if \(\rho \cdot g_k = g_k\) for all \(A\) and \(B\) and \(\rho\) as in i), then \(mbuild g\) is the unique morphism such that, for all \(A\), \(mfold k_A \cdot mbuild g = g k_A\). Translating these conditions from \(\mathcal{C}_M\) into \(\mathcal{C}\), we see that we need to show \[ i') \quad \rho^* \circ mfold k_A = mfold k_B \quad \text{for all } A \text{ and } B \text{ and all morphisms } \rho : A \rightarrow MB \text{ in } \mathcal{C} \quad \text{such that } \rho^* \circ k_A = k_B \circ \delta \circ F \rho. \] \[ ii') \quad \text{If } \rho^* \circ g_k = g_k \text{ for all } A, B \text{ and } \rho \text{ as in } i', \text{ then } mbuild g \text{ is the unique morphism such that, for all } A, \text{ mfold } k_A \cdot mbuild g = g k_A. \] **Proof of i'**. We first note that, for all \(A\), \(mfold k_A = fold (k_A^* \circ \delta)\). So proving i' is equivalent to proving that, for all \(A, B,\) and \(\rho\) as specified there, \(\rho^* \cdot fold (k_A^* \circ \delta) = fold (k_B^* \circ \delta)\). We first observe that \[ \delta \circ F \rho^* = \delta \circ F(\mu \circ M \rho) = \mu \circ M \delta \circ \delta \circ F M \rho \quad \text{by functoriality of } F \text{ and axioms for } \delta \\ = \mu \circ M \delta \circ M F \rho \circ \delta \quad \text{by naturality of } \delta \\ = (\delta \circ F \rho)^* \circ \delta \quad \text{by functoriality of } M \text{ and characterization of } (-)^* \] Thus \[ k_B^* \circ \delta \circ F \rho^* = k_B^* \circ (\delta \circ F \rho)^* \circ \delta \\ = (k_B^* \circ (\delta \circ F \rho))^* \circ \delta \quad \text{by the monad laws for } M \\ = (\rho^* \circ k_A)^* \circ \delta \quad \text{since } \rho \text{ is an } \hat{F}\text{-algebra homomorphism} \\ = \rho^* \circ k_A^* \circ \delta \quad \text{by the monad laws for } M \] We therefore have that \[ \begin{array}{c} \begin{array}{cccc} \mu F & \xrightarrow{F(\text{fold } k_A^* \circ \delta)} & FMA & \xrightarrow{F \rho^*} FMB \\ \downarrow m & & \downarrow k_A^* \circ \delta & & \downarrow k_B^* \circ \delta \\ \mu F & \xrightarrow{\text{fold } k_A^* \circ \delta} & MA & \xrightarrow{\rho^*} MB \end{array} \end{array} \] i.e., that each of the subsquares, and thus the outer square, commutes. By the uniqueness of fold we have that \( p^* \circ fold \ (k_A \circ \delta) = fold \ (k_B \circ \delta) \), i.e., that \( p \cdot mfold k_A = mfold k_B \) as desired. **Proof of ii'.** Suppose \( g \) is such that for every morphism \( p \) from \( k_A : FA \to A \) to \( k_B : FB \to B \) in \( \mathcal{C} \), we have \( p^* \circ g_{k_A} = g_{k_B} \). Define the map \( mbuild \) by \( mbuild \ g = g \ (\text{return} \circ \text{in}) \) or, equivalently, \( mbuild \ g = \text{superbuild} \ (\lambda \alpha. g(\text{return} \circ \alpha)) \). Here, the operator \( \text{superbuild} \) is the interpretation in \( \mathcal{C} \) of the superbuilder combinator of type \((\forall a. (f a \to a) \to c \to h a) \to c \to h (\mu f)\), with fusion rule \( \text{superbuild} \ g >>= \text{fold} \ k = g \ k >>= \text{id} \), introduced in [2]. We first check that \( mbuild \ g \) satisfies the property that, for all \( A, \ mfold k_A \bullet mbuild \ g = g_{k_A} \) in \( \mathcal{C} \), i.e., \((\text{fold} \ (k_{\lambda} \circ \delta))^* \circ mbuild \ g = g_{k_A} \) in \( \mathcal{C} \). For all \( c \) in \( \mathcal{C} \), \[ \begin{align*} (\text{fold} \ (k_{\lambda} \circ \delta))^* (\text{mbuild} \ g \ c) &= \text{mbuild} \ g \ c \ \Rightarrow & = \text{fold} \ (k_{\lambda} \circ \delta) \\ & = \text{superbuild} \ (\lambda \alpha. g(\text{return} \circ \alpha)) \ c \Rightarrow & = \text{fold} \ (k_{\lambda} \circ \delta) \\ & = (\lambda \alpha. g(\text{return} \circ \alpha)) (k_{\lambda} \circ \delta) \ c \Rightarrow & = \text{id} \\ & = g (\text{return} \circ k_{\lambda} \circ \delta) \ c \Rightarrow & = \text{id} \\ & = g_{k_{\lambda} c} \end{align*} \] The final equivalence follows from the facts that \( g \) is a cone and that \( id : MA \to A \) is a morphism in \( \mathcal{C} \) from the \( MF \)-algebra \( \text{return} \circ k_{\lambda} \circ \delta : FMA \to MA \) in \( \mathcal{C} \) to the \( MF \)-algebra \( k_A : FA \to A \) in \( \mathcal{C} \). Next we verify that \( mbuild \ g \) is the unique morphism such that, for all \( k_A, \ mfold k_A \bullet mbuild \ g = g_{k_A} \). Suppose \( \phi : C \to \mu F \) is such that \( mfold k_A \bullet \phi = g_{k_A} \). We will show that \( \phi = mbuild \ g \), i.e., that \( \phi = \text{superbuild} (\lambda \alpha. g(\text{return} \circ \alpha)) \) by showing that \( \phi \) satisfies the property that \( \text{superbuild} (\lambda \alpha. g(\text{return} \circ \alpha)) \) is unique for and thus must actually be \( \text{superbuild} (\lambda \alpha. g(\text{return} \circ \alpha)) \). This property is known from [2] to be that of being a mediating morphism between the \( MU_F \)-cones \( g(\text{return} \circ h) \) and \( M(\text{fold} h) \), i.e., being such that \[ \begin{tikzcd} C & M(\mu F) \arrow{ll}{\text{superbuild} (g(\text{return} \circ h))} \arrow{dr}{M(\text{fold} h)} \arrow{ur}{g(\text{return} \circ h)} \arrow{ur}{MA} \\ \end{tikzcd} \] for every \( h : FA \to A \) under the assumption that \( M \) preserves \( \text{lim} U_F \) (which is inherited from the results in that paper). So, from the fact that \( mfold k_A \bullet \phi = g_{k_A} \) for all \( k_A \), we must show that, for all \( h : FA \to A, M(\text{fold} h) \circ \phi = g(\text{return} \circ h) \). Given such an \( h \) and any \( c \) in \( \mathcal{C} \), we have that \[ \begin{align*} M(\text{fold} h) (\phi \ c) &= \phi \ c \ \Rightarrow & = \text{return} \circ (\text{fold} \ h) \ \text{functoriality of} \ M \ \text{via} \ \Rightarrow & = \phi \ c \ \Rightarrow & = (\text{fold} \ (M h \circ \delta)) \\ & = \phi \ c \ \Rightarrow & = (\text{fold} \ ((\text{return} \circ h)^* \circ \delta)) \ \text{functoriality of} \ M \ \text{via} \ \Rightarrow & = ((\text{fold} \ ((\text{return} \circ h)^* \circ \delta))^* \circ \phi) \ c \\ & = (\text{mfold} \ ((\text{return} \circ h) \bullet \phi)) \ c \\ & = g(\text{return} \circ h) \ c \end{align*} \] The fact that \( return \circ (fold \ h) = fold \ (M \ h \circ \delta) \), which is used in the third equivalence above, is a consequence of the distributivity laws and the naturality of \( return \). Thus \( \phi \) satisfies the property for which \( mbuild \ g \) is unique and so must equal \( mbuild \ g \). Both \( i' \) and \( ii' \) therefore hold, and so \( \mu F = \lim U_{MF} \) in \( \mathcal{C}_M \). 5 DUALITY Shortage of space prevents us from giving the corresponding coalgebraic constructs and results in detail here, so we simply present their implementation. We have ```haskell class Comonad cm where coreturn :: cm a -> a (=>>) :: cm b -> (cm b -> a) -> cm a data Nu f = Out {unOut :: f (Nu f)} unfold :: Functor f => (a -> f a) -> a -> Nu f unfold k = Out . fmap (unfold k) . k cunfold :: (Comonad c, Functor f, Dist c f) => (c a -> f a) -> c a -> Nu f cunfold k = unfold (\xs -> delta (xs =>> k)) ccreate :: (Comonad c, Functor f) => (forall a. (c a -> f a) -> c a -> x) -> c (Nu f) -> x ccreate g = g (unOut . coreturn) cunfold k c =>> ccreate g = g k c ``` 6 CONCLUSION AND DIRECTIONS FOR FUTURE WORK In this paper, we recalled the monadic \( fold \), found in the literature, which consumes an inductive data structure and returns a value in a monadic context. This operator differs from the standard \( fold \) operator in that it takes as input a monadic algebra rather than a standard algebra. We have argued that, for both aesthetic and practical reasons, the monadic \( fold \) operator is often preferable to the standard \( fold \) operator. We therefore defined a monadic \( build \) combinator which is parameterized over functions which use monadic algebras to uniformly consume data structures, and is thus the natural counterpart to the monadic \( fold \) operator. We used this combinator to define a short cut fusion rule for eliminating from modular monadic programs intermediate “gluing” data structures in monadic contexts. We provided examples showing how the monadic \( fold \) and monadic \( build \) combinators can be used, and how the monadic short cut fusion rule can optimize modular programs written using them. We also established the correctness of the monadic short cut fusion rule. Finally, we sketched the coalgebraic duals of these operators and rule. A number of possibilities for future work arise. At a theoretical level, we use distributivity to construct a functor on the Kleisli category of a monad from a functor on the underlying category. It would be interesting to be able to derive the correctness of the \texttt{mfold} and \texttt{mbuild} combinators directly. This would mean proving that the Kleisli category of a monad forms a parametric model whenever the underlying category does. In addition, both the monadic short cut fusion rule introduced here and the \texttt{fold/msuper build} rule from [2] eliminate intermediate data structures in monadic contexts. We believe these two rules to offer distinct fusion options in the presence of distributivity; it would therefore be interesting to see which is more useful for programs that arise in practice. A final direction for future work involves extending the results of [6, 7] to give monadic \texttt{builds}, as well as associated fusion rules, for advanced datatypes, such as nested types, GADTs, and dependent types. The latter seems particularly challenging, since impredicative quantification is not supported by pure dependent type theory. REFERENCES
{"Source-Url": "https://libres.uncg.edu/ir/asu/f/Johann_Patricia_2009_Monadic_Fold_monadic.pdf", "len_cl100k_base": 12664, "olmocr-version": "0.1.50", "pdf-total-pages": 16, "total-fallback-pages": 0, "total-input-tokens": 53401, "total-output-tokens": 14619, "length": "2e13", "weborganizer": {"__label__adult": 0.0004222393035888672, "__label__art_design": 0.00037980079650878906, "__label__crime_law": 0.0004150867462158203, "__label__education_jobs": 0.0006661415100097656, "__label__entertainment": 7.49826431274414e-05, "__label__fashion_beauty": 0.0001842975616455078, "__label__finance_business": 0.0002582073211669922, "__label__food_dining": 0.0005202293395996094, "__label__games": 0.0005879402160644531, "__label__hardware": 0.0008006095886230469, "__label__health": 0.0008292198181152344, "__label__history": 0.00028228759765625, "__label__home_hobbies": 0.00012564659118652344, "__label__industrial": 0.0005788803100585938, "__label__literature": 0.0004127025604248047, "__label__politics": 0.00036716461181640625, "__label__religion": 0.0006885528564453125, "__label__science_tech": 0.0328369140625, "__label__social_life": 0.0001068711280822754, "__label__software": 0.004085540771484375, "__label__software_dev": 0.9541015625, "__label__sports_fitness": 0.0003736019134521485, "__label__transportation": 0.0007472038269042969, "__label__travel": 0.0002363920211791992}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 44084, 0.00687]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 44084, 0.65032]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 44084, 0.83274]], "google_gemma-3-12b-it_contains_pii": [[0, 1316, false], [1316, 3190, null], [3190, 5562, null], [5562, 8271, null], [8271, 10837, null], [10837, 13042, null], [13042, 16591, null], [16591, 19330, null], [19330, 21651, null], [21651, 24688, null], [24688, 27270, null], [27270, 31330, null], [31330, 35049, null], [35049, 39085, null], [39085, 41431, null], [41431, 44084, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1316, true], [1316, 3190, null], [3190, 5562, null], [5562, 8271, null], [8271, 10837, null], [10837, 13042, null], [13042, 16591, null], [16591, 19330, null], [19330, 21651, null], [21651, 24688, null], [24688, 27270, null], [27270, 31330, null], [31330, 35049, null], [35049, 39085, null], [39085, 41431, null], [41431, 44084, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 44084, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 44084, null]], "pdf_page_numbers": [[0, 1316, 1], [1316, 3190, 2], [3190, 5562, 3], [5562, 8271, 4], [8271, 10837, 5], [10837, 13042, 6], [13042, 16591, 7], [16591, 19330, 8], [19330, 21651, 9], [21651, 24688, 10], [24688, 27270, 11], [27270, 31330, 12], [31330, 35049, 13], [35049, 39085, 14], [39085, 41431, 15], [41431, 44084, 16]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 44084, 0.0]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
90cd1d75ab52951ea74695c13103ad30ef63abe5
Distributed Software Transactional Memories Foundations, Algorithms and Tools Maria Couceiro (with Paolo Romano and Luís Rodrigues) IST/ INESC-ID Contents - Part I: (Non-Distributed) STMs - Part II: Distributed STMs - Part III: Case-studies - Part IV: Conclusions Contents - Part I: (Non-Distributed) STMs - Part II: Distributed STMs - Part III: Case-studies - Part IV: Conclusions (Non-Distributed) STMs - Basic Concepts - Example Algorithms Basic Concepts - Concurrent programming has always been a challenge - One needs to control the concurrent access to shared data by multiple threads - This is hard for most programmers. - Concurrent programming has been a “niche” Basic Concepts - In the past: - More performance via faster CPUs - Now: - More performance via more CPUs - Concurrent programming has to become mainstream Basic Concepts - Ideally - Performance would scale linearly with the number of cores - (with 8 cores we would have a program 8 times faster) - Reality: - Speed up limited by % serial code - Small % can kill performance (Amdahl’s Law) - Say 25% of the program is serial - 8 cores = 2.9 speedup. Basic Concepts - Ideally - Performance would scale linearly with the number of cores - (with 8 cores we would have a program 8 times faster) - Reality: - Small % of serial code can kill performance (Amdahl’s Law) - Say 25% of the program is serial - 32 cores = 3.7 speedup. Basic Concepts - Ideally - Performance would scale linearly with the number of cores - (with 8 cores we would have a program 8 times faster) - Reality: - Small % of serial code can kill performance (Amdahl’s Law) - Say 25% of the program is serial - 128 cores = 3.9 speedup. Basic Concepts - It is hard or impossible to structure a program in a set of parallel independent tasks. - We need efficient and simple mechanisms to manage concurrency. Explicit synchronization - One of the most fundamental and simple synchronization primitive is the lock non-synchronized code; lock (); do stuff on shared data; unlock (); more non-synchronized code; Many problems with locks - Deadlock: - locks acquired in “wrong” order. - Races: - due to forgotten locks - Error recovery tricky: - need to restore invariants and release locks in exception handlers Fine Grained Parallelism? - Very complex: - Need to reason about deadlocks, livelocks, priority inversions. - Verification nightmare as bugs may be hard to reproduce. - Make parallel programming accessible to the masses!!! Concurrent Programming Without Locks - Lock-free algorithms. - Hard to design and prove correct. - Only for very specialized applications. - Designed and implemented by top experts. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Abstractions for simplifying concurrent programming... WE WANT YOU! M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Atomic transactions atomic { access object 1; access object 2; } M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Transactional Memories - Hide away synchronization issues from the programmer. - Advantages: - avoid deadlocks, priority inversions, convoying; - simpler to reason about, verify, compose. TMs: where we are, challenges, trends - Theoretical Aspects - Formalization of adequate consistency guarantees, performance bounds. - Hardware support - Very promising simulation-based results, but no support in commercial processors. TMs: where we are, challenges, trends - Software-based implementations (STM) - Performance/scalability improving, but overhead still not satisfactory. - Language integration - Advanced supports (parallel nesting, conditional synchronization) are appearing... - ...but lack of standard APIs & tools hampers industrial penetration. TMs: where we are, challenges, trends - Operating system support - Still in its infancy, but badly needed (conflict aware scheduling, transactional I/O). - Recent trends: - Shift towards distributed environments to enhance scalability & dependability. Run-time How does it work? - The run time implements concurrency control in an automated manner. Two main approaches: - Pessimistic concurrency control (locking). - Optimistic concurrency control. Example of pessimistic concurrency control - Each item has a read/write lock. - When an object is read, get the read lock. - Block if write lock is taken. - When an object is written, get the write lock. - Block if read or write lock is taken. - Upon commit/abort: - Release all locks. Example of optimistic concurrency control - Each item has a version number. - Read items and store read version. - Write local copy of items. - Upon commit do atomically: - If all read items still have the read version (no other concurrent transaction updated the items) - then apply all writes (increasing the version number of written items). - Else, - abort. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Many, many, variants exist - For instance, assume that two phase locking is used and a deadlock is detected. It is possible: - Abort both transactions. - Abort the oldest transaction. - Abort the newest transaction. - Abort the transaction that did less work. For instance, assume that two phase locking is used and a deadlock is detected. It is possible: - Abort both transactions - Abort the oldest transaction - Abort the newest transaction - Abort the transaction that did less work Each alternative offers different performance with different workloads. How to choose? - What is a correct behavior? - Which safety properties should be preserved? - Which liveness properties should be preserved? How to choose? - What is a correct behavior? - Which safety properties should be preserved? - Which liveness properties should be preserved? To answer these questions we need a bit of theory. Theoretical Foundations - Safety: - What schedules are acceptable by an STM? - Is classic atomicity property appropriate? - Liveness: - What progress guarantees can we expect from an STM? Theoretical Foundations - **Safety:** - What schedules are acceptable by an STM? - Is classic atomicity property appropriate? - **Liveness:** - What progress guarantees can we expect from an STM? Classic atomicity property - A transaction is a sequence of read/write operations on variables: - sequence unknown a priori (otherwise called static transactions). - asynchronous (we do not know a priori how long it takes to execute each operation). - Every operation is expected to complete. - Every transaction is expected to abort or commit. The execution of a set of transactions on a set of objects is modeled by a history. A history is a total order of operation, commit and abort events. Histories Two transactions are **sequential** (in a history) if one invokes its first operation after the other one commits or aborts; they are **concurrent** otherwise. Histories - Two transactions are **sequential** (in a history) if one invokes its first operation after the other one commits or aborts; they are **concurrent** otherwise. - Non-sequential: Histories - Two transactions are **sequential** (in a history) if one invokes its first operation after the other one commits or aborts; they are **concurrent** otherwise. - Sequential: ``` OP C OP OP OP C ``` Histories - A history is sequential if it has only sequential transactions; it is concurrent otherwise. Histories - A history is sequential if it has only sequential transactions; it is concurrent otherwise. - Sequential: ``` OP C OP OP C OP C ``` M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Histories - A history is sequential if it has only sequential transactions; it is concurrent otherwise. - Non-sequential: Histories - Two histories are **equivalent** if they have the same transactions. Histories - Two histories are equivalent if they have the same transactions - Equivalent: ``` OP C OP OP C OP C OP C OP OP OP C C ``` Two histories are **equivalent** if they have the same transactions. **Non-equivalent:** - First history: \(\text{OP} \rightarrow \text{C} \rightarrow \text{OP} \rightarrow \text{OP} \rightarrow \text{C} \rightarrow \text{OP} \rightarrow \text{C}\) - Second history: \(\text{OP} \rightarrow \text{C} \rightarrow \text{OP} \rightarrow \text{OP} \rightarrow \text{OP} \rightarrow \text{C} \rightarrow \text{C}\) What the programmer wants? - Programmer does not want to be concerned about concurrency issues. - Execute transactions “as if” they were serial - No need to be “serially executed” as long as results are the same Serializability’s definition (Papa79 - View Serializability) - A history $H$ of **committed** transactions is **serializable** if there is a history $S(H)$ that is: - equivalent to $H$ - sequential - **every read returns the last value written** Serializability Serializable? WO2(1) → RO2(1) → RO1(0) → C → WO1(1) → C Serializable Serializable! WO2(1) RO2(1) RO1(0) C WO1(1) C WO2(1) RO1(0) C RO2(1) WO1(1) C Serializable? WO2(1) → RO2(0) → RO1(0) → C → WO1(1) → C Serializability Non-serializable! - WO2(1) → RO2(0) → RO1(0) → C → WO1(1) → C - RO2(0) → WO1(1) → C → WO2(1) → RO1(0) → C - WO2(1) → RO1(0) → C → RO2(0) → WO1(1) → C Opacity Serializable (blue aborts)? WO2(1) → RO2(1) → RO1(0) → A → WO1(1) → C Opacity Serializable: only committed transactions matter! Opacity - In a database environment, transactions run SQL: - no harm if inconsistent values are read as long as the transaction aborts. - This is not the same in a general programming language: - observing inconsistent values may crash or hang an otherwise correct program! Opacity: example Initially: x:=1; y:=2 - T1: x := x+1; y := y+1 - T2: z:= 1 / (y-x); If T1 and T2 are atomic, the program is correct. Opacity: example Initially: \( x := 1; y := 2 \) - \( T1: x := x+1; y := y+1 \) - \( T2: z := \frac{1}{y-x}; \) Otherwise... Opacity: example Initially: \( x := 1; \ y := 2 \) - \( T1: \ x := x + 1; \ y := y + 1 \) - \( T2: \ z := 1 / (y - x); \) Otherwise... Opacity: example Initially: x:=1; y:=2 - T1: x := x+1; y := y+1 - T2: z:= 1 / (2-x); Otherwise... Opacity: example Initially: x:=1; y:=2 - T1: x := x+1; y := y+1 - T2: z:= 1 / (2-x); Otherwise... Opacity: example Initially: \( x := 1; y := 2 \) After \( T_1 \): \( x := 2; y := 3 \) - \( T_1: x := x + 1; y := y + 1 \) - \( T_2: z := 1 / (2 - x) \) Otherwise... Opacity: example Initially: \( x := 1; \ y := 2 \) After T1: \( x := 2; \ y := 3 \) - T1: \( x := x + 1; \ y := y + 1 \) - T2: \( z := 1 / (2 - 2) \); Otherwise... *divide by zero!* Opacity [ GK08 ] - Intuitive definition: - every operation sees a consistent state (even if the transaction ends up aborting) Opacity [GK08] - Intuitive definition: - every operation sees a consistent state (even if the transaction ends up aborting) - Following history is serializable but violates opacity! Does classic optimistic concurrency control guarantee opacity? - Writes are buffered to private workspace and applied atomically at commit time. - Reads are optimistic and the transaction is validated at commit time. - Opacity is not guaranteed! Theoretical Foundations - **Safety:** - What schedules are acceptable by an STM? - Is classic atomicity property appropriate? - **Liveness:** - What progress guarantees can we expect from an STM? Progress - STMs can abort transactions or block operations... - But we want to avoid implementations that abort all transactions! - We want operations to return and transactions to commit! Requirements - **Correct transactions:** - `commit` is invoked after a finite number of operations - either `commit` or perform an infinite number of (low-level) steps - **Well-formed histories:** - every transaction that aborts is immediately repeated until it commits Conditional progress: obstruction freedom - A correct transaction that eventually does not encounter contention eventually commits - ...but what to do upon contention? Contention-managers - Abort is unavoidable - But want to maximize the number of commits - Obstruction freedom property: progress and correctness are addressed by different modules. Contention-managers encapsulate policies for dealing with contention scenarios. Contention-managers Let TA be executing and TB a new transaction that arrives and creates a conflict with TA. CM: Aggressive Let TA be executing and TB a new transaction that arrives and creates a conflict with TA. - Aggressive contention manager: - always aborts TA CM: Backoff Let TA be executing and TB a new transaction that arrives and creates a conflict with TA. - **Backoff contention manager:** - TB waits an exponential backoff time - If conflict persists, abort TA CM: Karma Let TA be executing and TB a new transaction that arrives and creates a conflict with TA. - **Karma contention manager:** - Assign priority to TA and TB - Priority proportional to work already performed - Let $Ba$ be how many times TB has been aborted - Abort TA if $Ba > (TA-TB)$ CM: Greedy Let TA be executing and TB a new transaction that arrives and creates a conflict with TA. - **Greedy contention manager:** - Assign priority to TA and TB based on start time - If TB < TA and TA not blocked then wait - Otherwise abort TA (Non-Distributed) STMs - Basic Concepts - Example Algorithms - DSTM - JVSTM (Non-Distributed) STMs - Basic Concepts - Example Algorithms - DSTM - JVSTM DSTM - Software transactional memory for dynamic-sized data structures. - Prior designs: static transactions. - DSTM: dynamic creation of transactional objects. DSTM - Killer write: - Ownership. - Careful read: - Validation. DSTM - Writes - To write $o$, $T$ requires a write-lock on $o$. - $T$ aborts $T'$ if some $T'$ acquired a write-lock on $o$: - Locks implemented via Compare & Swap. - Contention manager can be used to reduce aborts. DSTM – Reads and Validation - Concurrent reads do not conflict. - To read o, T checks if all objects read remain valid; - else abort T. - Before committing, T checks if all objects read remain valid and releases all its locks. - Make sure that the transaction observes a consistent state. - If the validation fails, transaction is restarted. DSTM - Why is careful read needed? - No lock is acquired upon a read: - invisible reads - visible read invalidate cache lines - bad performance with read-dominate workloads due to high bus contention - What if we validated only at commit time? Serializability? Opacity? M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 DSTM - Why is careful read needed? - No lock is acquired upon a read: - invisible reads - visible read invalidate cache lines - bad performance with read-dominate workloads due to high bus contention - What if we validated only at commit time? Serializability? Y Opacity? N (Non-Distributed) STMs - Basic Concepts - Example Algorithms - DSTM - JVSTM JVSTM - Java Versioned Software Transactional Memory. - Cachopo and Rito-Silva. 2006. - Versioned boxes as the basis for memory transactions. Optimized for read-only transactions: - Never aborted or blocked; - No overhead associated with readset tracking. How? - Multi-version concurrency control. - Local writes (no locking, optimistic approach) - Commit phase in global mutual exclusion. - Recently introduced a parallel commit version [FC09]. - Global version number (GVN) JVSTM - Versioned boxes - Versioned boxes - Each transactional location uses a versioned box to hold the history of values for that location. <table> <thead> <tr> <th></th> <th>previous:</th> <th>value:</th> <th>version:</th> </tr> </thead> <tbody> <tr> <td>body:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>body:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>body:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>previous:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>value:</td> <td>2</td> <td></td> <td>87</td> </tr> <tr> <td>version:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>previous:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>value:</td> <td>1</td> <td></td> <td>23</td> </tr> <tr> <td>version:</td> <td></td> <td></td> <td></td> </tr> <tr> <td>previous:</td> <td>null</td> <td></td> <td></td> </tr> <tr> <td>value:</td> <td>0</td> <td></td> <td>5</td> </tr> <tr> <td>version:</td> <td>null</td> <td></td> <td>5</td> </tr> </tbody> </table> JVSTM - Algorithm - Upon begin **T**, read GVN and assigned it to **T** snapshot ID (sID). - Upon read on object **o**: - If **o** is in **T**’s writeset, return last value written, - else return the version of the data item whose sID is “the largest sID to be smaller than the **T**’ sID”. - If **T** is not read-only, add **o** to readset. JVSTM - Algorithm - Upon write, just add to the writeset. - No early conflict detection. - Upon commit: - Validate readset: - Abort if any object read has changed. - Acquire new sID (atomic increase of GVN). - Apply writeset: add new version in each written VBox. JVSTM - Execution Contents - Part I: (Non-Distributed) STMs - **Part II: Distributed STMs** - Part III: Case-studies - Part IV: Conclusions Distributed STMs - Origins - Goals - Distribution Strategies - Programming Models - Toolbox Origins - Convergence of two main areas: - Distributed Shared Memory - Database Replication Distributed Shared Memory - DSM aims at providing a single system image - Fault-tolerance via checkpointing - Strong consistency performs poorly - Myriad of weak-consistency models - Programming more complex - Explicit synchronization - Locks, barriers, etc DSTMs vs DSM - DSTMs are simpler to program - Transactions introduce boundaries where synchronization is required - By avoiding to keep memory consistency at every (page) access or at the level of fine-grain locks, it may be possible to achieve more efficient implementations M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Database Replication - Databases use transactions - Constrained programming model - Durability is typically a must - Database replication was considered too slow - In the last 10 years new database replication schemes have emerged - Based on atomic broadcast and on a single coordination phase at the beginning/end of the transaction. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 DSTMs vs DBMS - Transactions are often much shorter in the STM world - This makes coordination comparatively more costly - Durability is often not an issue - This makes coordination comparatively more costly - Database replication techniques can be used as a source of inspiration to build fault-tolerant DSTMs Distributed STMs - Origins - Goals - Distribution Strategies - Programming Models - Toolbox Goals - Better performance: - Doing reads in parallel on different nodes. - Computing writes in parallel on different items. - Fault-tolerance: - Replication the memory state so that it survives the failure of a subset of nodes. Distributed STMs - Origins - Goals - Distribution Strategies - Potential Problems - Toolbox Distribution Strategies - Single System Image - Distribution is hidden - Easier when full replication is implemented - No control of the data locality - Partitioned Global Address Space - Different nodes have different data - Distribution is visible to the programmer - Programmer has fine control of data locality - Complex programming model Distribution Strategies - Partitioned non-replicated - Max capacity - No fault-tolerance - No load balancing for reads on multiple nodes - Full replication - No extra capacity - Max fault-tolerance - Max potential load balancing for reads Distributed STMs - Origins - Goals - Distribution Strategies - Programming Models - Toolbox Dataflow Model - Transactions are immobile and objects move through the network. - Write: processor locates the object and acquires ownership. - Read: processor locates the object and acquires a read-only copy. - Avoids distributed coordination. - Locating objects can be very expensive. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Control Flow Model - Data is statically assigned to a home node and does not change over time. - Manipulating objects: - In the node (via RPC); - First data is copied from the node then the are changes written back. - Relies on fast data location mechanism. - Static data placement may lead to poor data locality. Distributed STMs - Origins - Goals - Distribution Strategies - Programming Models - Toolbox Toolbox - Atomic Commitment - Uniform Reliable Broadcast (URB) - Atomic Broadcast (AB) - Replication Strategies Atomic Commitment - Atomicity: all nodes either commit or abort the entire transaction. - Set of nodes, each node has input: - CanCommit - MustAbort - All nodes output same value - Commit - Abort - Commit is only output if all nodes CanCommit 2-phase commit - **Coordinator** - `prepare msg` - `vote msg (Yes or No)` - `decision msg (Commit or Abort)` - **Participant 1** - `validate/acquire locks` - `apply decision` - **Participant 2** - `validate/acquire locks` - `apply decision` M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 2PC is blocking prepare msg vote msg (Yes or No) decision msg (Commit or Abort) validate/ acquire locks validate/ acquire locks ? ? M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 3PC - **Coordinator** - Prepare msg - Pre-decision msg (Pre-Commit) - Decision msg (Commit) - **Participant** - Vote msg (Yes) - Validate/ acquire locks - Log pre-commit - Apply decision - **Participant** - Validate/ acquire locks - Log pre-commit - Apply decision M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Toolbox - Atomic Commitment - **Uniform Reliable Broadcast (URB)** - Atomic Broadcast (AB) - Replication Strategies Uniform Reliable Broadcast - Allows to broadcast a message $m$ to all replicas - If a node delivers $m$, every correct node will deliver $m$ - Useful to propagate updates Toolbox - Atomic Commitment - Uniform Reliable Broadcast (URB) - Atomic Broadcast (AB) - Replication Strategies Atomic Broadcast - Reliable broadcast with total order - If replica R1 receives $m_1$ before $m_2$, any other correct replica Ri also receives $m_1$ before $m_2$ - Can be used to allow different nodes to obtain locks in the same order. **Sequencer-based ABcast** R1: sequencer Assigns SN Receive Msg + order Receive Msg + order Commit order Commit order Commit order final uniform order R2 Sends message R3 M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Abcast with optimistic delivery - Total order with optimistic delivery. - Unless the sequencer node crashes, final uniform total order is the same as regular total order. - Application may start certificating the transaction locally based on optimistic total order delivery. ABcast with optimistic delivery M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 ABcast with optimistic delivery R1: sequencer Assigns SN Sends message R2 Spontaneous order Sends message R3 Spontaneous order Sends message Commit order Final delivery Spontaneous order delivery Commit order Commit order Commit order final uniform order Toolbox - Atomic Commitment - Uniform Reliable Broadcast (URB) - Atomic Broadcast (AB) - Replication Strategies In absence of replication, there’s no chance to fall into deadlocks with a single lock... what if we add replication? Replicating a single lock T1 lock() Update R1 Waiting for R2 T2 lock() T1 lock() T2 lock() Update R2 Waiting for R1 M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Replicating a single lock T1 lock() Update R1 unlock() T2 lock() Update R1 T1 lock() Update R2 unlock() T2 lock() Update R1 Coordination is slow Drawback of previous approach: - Coordination among replicas needs to be executed at every lock operation. - Atomic broadcast is an expensive primitive. - The system becomes too slow. Solution: - Limit the coordination among replicas to a single phase, at the beginning of the transaction or commit time. Single-phase schemes - State machine replication - Single master (primary-backup) - Multiple master (certification) - Non-voting - Voting State-machine replication - All replicas execute the same set of transactions, in the same order. - Transactions are shipped to all replicas using atomic broadcast. - Replicas receive transactions in the same order. - Replicas execute transaction by that order. - Transactions need to be deterministic! State-machine replication AB of T1’s input params R1 T1 pre-acquires its locks T1 execs T1 commits T2 is blocked due to T1 T2 execs T2 commits AB of T2’s input params R2 T1 pre-acquires its locks T1 execs T1 commits T2 is blocked due to T1 T2 execs T2 commits M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Single-phase schemes - State machine replication - **Single master (primary-backup)** - Multiple master (certification) - Non-voting - Voting M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Primary-backup - Write transactions are executed entirely in a single replica (the primary) - If the transaction aborts, no coordination is required. - If the transaction is ready to commit, coordination is required to update all the other replicas (backups). - Reliable broadcast primitive. - Read transactions may be executed on backup replicas. - Works fine for workloads with very few update transactions. - Otherwise the primary becomes a bottleneck. Primary-backup - **Synchronous updates:** - Updates are propagated during the commit phase: - Data is replicated immediately - Read transactions observe up to date data in backup replicas - Commit must wait for reliable broadcast to finish - **Asynchronous updates:** - The propagation of updates happens in the background: - Multiple updates may be batched - Commit is faster - There is a window where a single failure may cause data to be lost - Read transactions may read stale data M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Single-phase schemes - State machine replication - Single master (primary-backup) - Multiple master (certification) - Non-voting - Voting Multi-master - A transaction is executed entirely in a single replica. - Different transactions may be executed on different replicas. - If the transaction aborts, no coordination is required. - If the transaction is ready to commit, coordination is required: - To ensure serializability - To propagate the updates Multi-master - Two transactions may update concurrently the same data in different replicas. - Coordination must detect this situation and abort at least one of the transactions. - Two main alternatives: - Non-voting algorithm - Voting algorithm Single-phase schemes - State machine replication - Single master (primary-backup) - Multiple master (certification) - Non-voting - Voting Non-voting - The transaction executes locally. - When the transaction is ready to commit, the read and write set are sent to all replicas using atomic broadcast. - Transactions are certified in total order. - A transaction may commit if its read set is still valid (i.e., no other transaction has updated the read set). Non-voting Execution Transaction T1 Execution Transaction T2 AB of T1’s read & writeset Validation & Commit T1 Validation & Commit T1 Validation & Abort T2 Validation & Abort T2 AB of T2’s read & writeset R1 R2 R3 M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Single-phase schemes - State machine replication - Single master (primary-backup) - Multiple master (certification) - Non-voting - Voting Voting - The transaction executes locally at replica R - When the transaction is ready to commit, only the write set is sent to all replicas using atomic broadcast - Transactions’ commit requests are processed in total order - A transaction may commit if its read set is still valid (i.e., no other transaction has updated the read set): - Only R can certify the transaction! - R send the outcome of the transaction to all replicas: - Reliable broadcast Voting Transaction T1 R1 T1’s AB (write set) wait for R1’s vote R2 T1’s RB (vote) commit commit M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Contents - Part I: (Non-Distributed) STMs - Part II: Distributed STMs - Part III: Case-studies - Part IV: Conclusions Part III: Case-Studies - Partitioned Non-Replicated - STM for clusters (Cluster-STM) - Partitioned (Replicated) - Static Transactions (Sinfonia) - Replicated Non-Partitioned - Certification-based with Bloom Filters (D²STM) - Certification with Leases (ALC) - Active Replication with Speculation (AGGRO) Part III: Case-Studies - Partitioned Non-Replicated - STM for clusters (Cluster-STM) - Partitioned (Replicated) - Static Transactions (Sinfonia) - Replicated Non-Partitioned - Certification-based with Bloom Filters (D²STM) - Certification with Leases (ALC) - Active Replication with Speculation (AGGRO) Cluster-STM - Software Transactional Memory for Large Scale Clusters - Bocchino, Adve, and Chamberlain. 2008 - Partitioned (word-based) address space - No persistency, no replication, no caching - Supports only single thread per node - Various lock acquisition schemes + 2PC Cluster-STM - Various methods for dealing with partitioned space - Data movement (Dataflow model): - `stm get(src proc, dest, work proc, src, size, open)` - `stm put(src proc, work proc, dest, src, size, open)` - Remote execution (Control flow model): - `stm on(src proc, work proc, function, arg buf, arg buf size, result buf, result buf size)` Cluster-STM ```cpp increment(proc_t proc, int *addr) { atomic { on(proc) { +++*addr } } } ``` Cluster-STM ```c increment(proc_t proc, int* addr) { stm_start(MY_ID) stm_on(MY_ID, proc, increment_local, addr, sizeof(int*), 0, 0) stm_commit(MY_ID) } ``` Cluster-STM ```c increment_local (proc_t src_proc, void* arg, size_t arg_size, void *result, size_t result_size) { int *addr = *((int*) arg); int tmp; stm_open_read (src_proc, addr, sizeof(int)) stm_read (src_proc, &tmp, addr, sizeof(int)) ++tmp; stm_open_write (src_proc, addr, sizeof(int)) stm_write (src_proc, addr, &tmp, sizeof(int)) }``` Cluster-STM - Read locks (RL) vs. read validation (RV) - RL: - immediately acquire a lock as a read (local or remote) is issued - abort upon contention (avoid deadlock) - as coordinator ends transaction, it can be committed w/o 2PC - Note: distributed model w/o caching: - each access to non local data implies remote access: - eager locking is for free - with caching only RV could be employable Cluster-STM - Read locks (RL) vs. read validation (RV) - RV: - commit time validation (not opaque) - validity check requires 2PC Cluster-STM - Write buffering schemes - UL undo log: - write is applied and an undo log is maintained - forced sync upon each write - WB write buffering: - writes applied in local buffer - avoid communications for writes during exec phase - requires additional communication at commit time Cluster-STM - Write buffering: two lock acquisition schemes - LA: Late acquire - at commit time. - may allow for more concurrency - EA: Early acquire - as the write is issued - may avoid wasted work by doomed transactions Cluster-STM: Graph Analysis (SSCA2) Figure 5. Runtimes for SSCA2 kernel 4 implemented with locks. (b) Runtimes for SSCA2 kernel 4 implemented with Cluster-STM. Cluster-STM: Graph Analysis (SSCA2) Good scaling after $p = 4$ STM overhead about 2.5x Part III: Case-Studies - Partitioned Non-Replicated - STM for clusters (Cluster-STM) - Partitioned (Replicated) - Static Transactions (Sinfonia) - Replicated Non-Partitioned - Certification-based with Bloom Filters (D²STM) - Certification with Leases (ALC) - Active Replication with Speculation (AGGRO) Sinfonia - Sinfonia: A new paradigm for building scalable distributed systems. - Partitioned global (linear) address space - Optimized for **static** transactions Mini-transactions: - A-priori knowledge on the data to be accessed Two types of nodes: - Application nodes - Memory nodes Fault-tolerance via: - In-memory replication - Sync (log) + async checkpoint for persistency on memory nodes Sinfonia In a nutshell, Sinfonia is a service that allows hosts to share application data in a fault-tolerant, scalable, and consistent manner. We propose a new paradigm for building scalable distributed systems that enables efficient and consistent access to data, while hiding the complexities that arise from concurrency and failures. Keywords Algorithms, Design, Experimentation, Performance, Reliability 1. INTRODUCTION Distributed transactions, two-phase commit protocols—a major complication in existing distributed systems. C.2.4 [Categories and Subject Descriptors]: Distributed systems, scalability, fault tolerance, shared memory, Our implementations perform well and scale to hundreds of nodes. In a few months: a cluster file system and a group communication service. Our implementations perform well and scale to hundreds of nodes. In a few months: a cluster file system and a group communication service. At the core of Sinfonia is a novel minitransaction primitive that enables efficient and consistent access to data, while hiding the non-trivial to develop. Instead, developers just design and manipulate data structures within our service called Sinfonia. Sinfonia keeps data for applications on a set of memory nodes, each exporting a linear address space. At the core of Sinfonia is a lightweight minitransaction primitive that enables efficient and consistent access to data, while hiding the non-trivial to develop. Figure 1: Sinfonia allows application nodes to share data in a fault-tolerant, scalable, and consistent manner. We propose a new paradigm for building scalable distributed systems. Our approach targets particularly data center applications. Instead of developing complex protocols for handling distributed state, Sinfonia allows application nodes to share data in a fault-tolerant, scalable, and consistent manner. Figure 1 illustrates this paradigm. Our approach transforms the problem of protocol design into the much easier problem of data structure design. Our approach targets particularly data center applications. Instead of developing complex protocols for handling distributed state, Sinfonia allows application nodes to share data in a fault-tolerant, scalable, and consistent manner. Figure 1 illustrates this paradigm. Sinfonia seeks to provide a balance between functionality and efficiency is vital. This is because database systems provide more functionality than needed, resulting in performance overheads. For infrastructure applications, lock managers, and group communication services. These systems lack the performance needed for infrastructure applications, where performance overheads. To prevent Sinfonia from becoming a bottleneck, Sinfonia itself is designed to be scalable and fault-tolerant. Sinfonia can handle data in Sinfonia relatively independently of each other. Towards this goal, Sinfonia provides fine-grained address spaces on which to store data, without imposing any structure, such as types, schemas, tuples, or tables, which all tend to increase coupling. Thus, application hosts do not have to deal with the non-trivial to develop. As the number of nodes increases, Sinfonia’s space and bandwidth capacity of Sinfonia. Section 6 describes how to implement Sinfonia as a library. Section 7 shows that Sinfonia is easy to implement and can handle data in Sinfonia relatively independently of each other. Towards this goal, Sinfonia provides fine-grained address spaces on which to store data, without imposing any structure, such as types, schemas, tuples, or tables, which all tend to increase coupling. Thus, application hosts do not have to deal with the non-trivial to develop. Section 8 discusses some of the DSM infrastructure applications. Section 8 discusses some of the DSM infrastructure applications. Section 8 discusses some of the DSM infrastructure applications. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 are chosen before the minitransaction starts executing. Upon execution onto the commit protocol. We designed minitransactions can read the item and adjust its vote to abort if the result is zero. returns zero (and will commit otherwise), then the coordinator can piggyback this last action onto the first phase of two-Phase commit (e.g., this is the case if this action is a data update). In Sinfonia, coordinators are application nodes and participants are informed of their data better than what Sinfonia can infer. And third, controlled caching has three clear advantages: First, there is greater flexibility on policies of what to cache and what to evict. Second, as applications cache is always current (not stale). Managing caches in through Sinfonia is always current (not stale). ### Sinfonia #### API ```cpp class Minitransaction { public: void cmp(memid, addr, len, data); // add cmp item void read(memid, addr, len, buf); // add read item void write(memid, addr, len, data); // add write item int exec_and_commit(); // execute and commit }; ``` #### Example ```cpp t = new Minitransaction; t->cmp(memid, addr, len, data); t->write(memid, addr, len, newdata); status = t->exec_and_commit(); ...``` --- **Figure 2:** Minitransactions have compare items, read items, and write items. Compare items are locations to compare against given values, while read items are locations to read and write items are locations to write. Methods `cmp`, `read`, and `write` populate a minitransaction without communication. The API is straightforward: - `(const memid, addr, len, data)` - `(memid, addr, len, buf)` - `(memid, addr, len, data)` Roughly speaking, a coordinator executes a transaction by asking participants to perform one or more transaction items (equality comparison), and commit. Roughly speaking, a coordinator executes a transaction by asking participants to perform one or more transaction items (equality comparison), (2) if all comparisons succeed, or if a validation fails, abort. Thus, the compare items control whether the transaction commits or aborts. ### 3.4 Caching and consistency Sinfonia does not cache data at application nodes, but provides a minitransaction system for executing file system operations, such as`stat` (NFS's `getattr`). A minitransaction is a lightweight transaction that allows a set of operations to be executed atomically and consistently. SinfoniaFS uses this system to provide consistent data access. In Section 4 we explain how minitransactions are executed and commit. Each minitransaction has a status that indicates whether it has executed and so the validations were successful. SinfoniaFS uses minitransactions to manage cache consistency. A frequent minitransaction idiom is to use compare items to validate updates. For example, if the last action is a read, then the participant knows that the coordinator will abort if the read item is invalid. If the last action is a write, then the participant knows how the coordinator will make its decision to abort or commit, if the participant knows how the coordinator will make its decision to abort or commit, then the participant can also piggyback the action onto the commit protocol. For example, if the last action is a read, then the participant knows that the coordinator will abort if the read item is invalid. If the last action is a write, then the participant knows how the coordinator will make its decision to abort or commit, if the participant knows how the coordinator will make its decision to abort or commit, then the participant can also piggyback the action onto the commit protocol. A minitransaction execution consists of two phases: 1. **Prepare**: - The coordinator asks all participants if they are ready to execute the transaction. - Participants that are ready respond with their votes (aborted or committed). 2. **Commit**: - If all participants vote to commit, the transaction is committed. - If any participant votes to abort, the transaction is aborted. In practice, participants are assigned swap addresses using a minitransaction with one compare and one write item on the same location—a compare-and-swap operation. Methods `cmp` and `write` populate a minitransaction without communication. Methods `cmp` and `write` populate a minitransaction without communication. Methods `cmp` and `write` populate a minitransaction without communication. #### API Example ```cpp public: void write(memid, addr, len, data); // add void read(memid, addr, len, buf); // add void cmp(memid, addr, len, data); // add Minitransaction t = new Minitransaction; t->cmp(memid, addr, len, data); t->write(memid, addr, len, data); status = t->exec_and_commit(); ... ``` Sinfonia - Global space is partitioned - Transaction may need to access different memory nodes - It can only commit if it can commit at all memory nodes - 2-phase commit 4.1 Basic architecture A minitransaction in Sinfonia consists of a set of items, which can be of four types: compare items, read items, write items, and in-doubt items. To execute and commit a minitransaction, the coordinator generates a unique identifier for the minitransaction and sends it to the participants. Each participant then votes for committing or for aborting the minitransaction. 4.2 Minitransaction protocol overview Phase 1, the coordinator (application node) generates a new transac- tion id (tid), and sends the minitransaction to the participants (mem- ory nodes), so that minitransactions are blocked in-doubt (if logging is enabled); logging occurs only if the participant votes for committing. 4.3 Minitransaction protocol details The two-phase protocol in Figure 4. Phase 1 executes and prepares equality against supplied data; if any test fails, the minitransaction in-doubt. Another deadlock-avoidance scheme is to acquire locks in some predefined order, but with that scheme, the coordinator in participants are memory nodes that keep application data, so if they go coordinator crashes. This is reasonable for Sinfonia because partic- ipants are memory nodes that keep application data, so if they go coordinator crashes. This is reasonable for Sinfonia because partic- Sinfonia comprises a set of memory nodes and a server process that keeps Sinfonia data and the minitransaction of which we run the minitransaction protocol. Memory nodes run Recall that a minitransaction has compare items, read items, and write items, and we consider a transaction to be committed if all participants have a yes vote in their log. Standard two-phase commit requires the minitransaction, while phase 2 commits it. More precisely, in Recall that Sinfonia comprises a set of memory nodes and a server process that keeps Sinfonia data and the minitransaction of which we run the minitransaction protocol. Memory nodes run To execute and commit minitransaction <table> <thead> <tr> <th>participant 1</th> <th>participant 2</th> <th>participant 3</th> <th>coordinator</th> </tr> </thead> <tbody> <tr> <td>EXEC&amp;PREPARE</td> <td>vote</td> <td>COMMIT</td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table> Figure 4: Protocol for executing and committing minitransactions. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Sinfonia No support for caching: - delegated to application level - same applies for load balancing Replication: - aimed at fault-tolerance, not enhancing performance - fixed number of replicas per memory node - primary-backup scheme ran within first phase of 2PC Part III: Case-Studies - Partitioned Non-Replicated - STM for clusters (Cluster-STM) - Partitioned (Replicated) - Static Transactions (Sinfonia) - Replicated Non-Partitioned - Certification-based with Bloom Filters (D²STM) - Certification with Leases (ALC) - Active Replication with Speculation (AGGRO) D²STM - D²STM: Dependable Distributed STM - Couceiro, Romano, Rodrigues, Carvalho, 2009 - Single-image system - Full replication - Strong consistency - Certification-based replication scheme - Based on Atomic Broadcast - Built on top of JVSTM **D²STM** - Non-voting replication scheme - Transactions execute in a single replica - No communication during the execution - Writeset and readset AB at commit time - Deterministic certification executed in total order by all replicas - No distributed deadlocks D²STM Execution Transaction T1 AB of T1’s read & writeset Validation&Commit T1 Validation&Commit T1 R1 R2 R3 D$^2$STM AB of both T1’s readset & writeset Problem: (very) big message size **D²STM** - In STMs, transaction’s execution time is often 10-100 times short than in DBs: - the cost of AB is correspondingly amplified - Bloom Filter Certification: - space-efficient encoding (via Bloom Filter) to reduce message size **D²STM** - Bloom filters - A set of $n$ items is encoded through a vector of $m$ bits - Each item is associated with $k$ bits through $k$ hash functions having as image $\{1..m\}$: - insert: set $k$ bits to 1 - query: check if all $k$ bits set to 1 D²STM - **False Positives:** - An item is wrongly identified as belonging to a given set - Depend on the number of bits used per item \((m/n)\) and the number of hash functions \((k)\) - **D²STM computes the size of the Bloom filter based on:** - User-defined false positive rate - Number of items in the read set (known) - Number of BF queries, estimated via moving average over recently committed transactions D²STM - Read-only transactions: - local execution and commit \textbf{D}²\textbf{STM} \begin{itemize} \item Write transaction T: \begin{itemize} \item Local validation (read set) \item If the transaction is not locally aborted, the read set is encoded in a Bloom filter \item Atomic broadcast of a message containing: \begin{itemize} \item the Bloom filter encoding of tx readset \item the tx write set \item the snapshotID of the tx \end{itemize} \item Upon message delivery: validate tx using Bloom filter’s information \end{itemize} \end{itemize} D²STM for each committed $T'$ s.t. $T'$.snapshotID > $T$.snapshotID for each data item $d$ in the writeset of $T'$ if $d$ is in Bloom filter associated with $T'$’s readset abort $T$ // otherwise... commit $T$ D²STM - STM Bench7: Results Part III: Case-Studies - Partitioned Non-Replicated - STM for clusters (Cluster-STM) - Partitioned (Replicated) - Static Transactions (Sinfonia) - Replicated Non-Partitioned - Certification-based with Bloom Filters (D²STM) - Certification with Leases (ALC) - Active Replication with Speculation (AGGRO) AlC - Asynchronous Lease Certification Replication of Software Transactional Memory - Carvalho, Romano, Rodrigues, 2010 - Exploit data access locality by letting replicas dynamically establish ownership of memory regions: - replace AB with faster coordination primitives: - no need to establish serialization order among non-conflicting transactions - shelter transactions from remote conflicts M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Data ownership established by acquiring an Asynchronous Lease - mutual exclusion abstraction, as in classic leases... - ...but detached from the notion of time: - implementable in a partially synchronous system - Lease requests disseminated via AB to avoid distributed deadlocks. ALC - Transactions are locally processed - At commit time check for leases: - An Asynchronous Lease may need to be established - Proceed with local validation ALC - If local validation succeeds, its writeset is propagated using Uniform Reliable Broadcast (URB): - No ordering guarantee, 30-60% faster than AB - If validation fails, upon re-execution the node holds the lease: - Transaction cannot be aborted due to a remote conflict! ALC Lease Request (AB) Lease Ensured (URB) Apply (URB) P1 P2 P3 Certification M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 ALC M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 If applications exhibit some access locality: - avoid, or reduce frequency of AB - locality improved via conflict-aware load balancing Ensure transactions are aborted at most once due to remote conflicts: - essential to ensure liveness of long running transactions - benefic at high contention rate even with small running transactions ALC Application Distributed STM API Wrapper JVSTM Replication Manager Lease Manager Group Communication Service M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 ALC - Synthetic “Best case” scenario - Replicas accessing distinct memory regions ![Graph showing throughput vs. number of replicas](image) - ALC: 3x improvement - CERT: 10x improvement --- M. Conceiro, P. Romano, L. Rodrigues, HPCS 2011 ALC - Synthetic “Worst case” scenario - All replicas accessing the same memory region ![Graphs showing throughput and abort rate vs number of replicas for ALC and CERT.](image-url) Lee Benchmark Graphs showing the speed-up and abort rate of ALC and CERT with varying number of replicas. Part III: Case-Studies - Partitioned Non-Replicated - STM for clusters (Cluster-STM) - Partitioned (Replicated) - Static Transactions (Sinfonia) - Replicated Non-Partitioned - Certification-based with Bloom Filters (D²STM) - Certification with Leases (ALC) - Active Replication with Speculation (AGGRO) AGGRO - AGGRO: Boosting STM Replication via Aggressively Optimistic Transaction Processing - R. Palmieri, Paolo Romano and F. Quaglia, 2010 - Active Replication for STMs - Multiple replicas - All replicas execute update transactions - Read-only transactions can execute in any replica - Data survives failures of replicas Basic Active Replication Atomic Broadcast Tx Exec C With Optimistic Delivery - Opt - Atomic Broadcast - Tx Exec - Hold Locks - C M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Improvement Atomic Broadcast Tx Exec Opt Atomic Broadcast Tx Exec Hold Locks C M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 But... M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Speculative M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 AGGRO - Transactions are started in speculative order immediately after the optimistic delivery. - Writes kill all transactions that have read stale data. - Items touched by speculative transactions Tspec are marked as “work-in-progress (WIP)” while Tspec executes. - When Tspec terminates (but not yet committed) items are unmarked as WIP. - Transaction only read values from terminated transactions. M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 AGGRO Algorithm upon opt-Deliver(Ti) start transaction Ti in a speculative fashion AGGRO Algorithm upon \texttt{write}(Ti, X, v) \begin{itemize} \item if (X not already in Ti.WS) \begin{itemize} \item add X to Ti.WS \item mark X as WIP // C&S \end{itemize} \item for each Tj that follows Ti in OAB order: \begin{itemize} \item if (Tj read X from Tk preceding Ti) abort Tj \end{itemize} \item else \begin{itemize} \item update X in Ti.WS \end{itemize} \end{itemize} AGGRO Algorithm upon read(Ti, X) if (X in Ti.WS) return X.value from Ti.WS if (X in Ti.RS) return X.value from Ti.RS wait while (X is marked WIP) let Tj be tx preceding Ti in OAB order that wrote X Ti.readFrom.add(Tj) AGGRO Algorithm upon completed (\( Ti \)) atomically { for each \( X \) in \( Ti.WS \): unmark \( X \) as WIP by \( Ti \) } upon commit(\( Ti \)) atomically { for each \( X \) in \( Ti.WS \): mark \( X \) as committed } AGGRO Algorithm upon abort($Ti$) abort any transaction that read from $Ti$ restart $Ti$ upon TO-Deliver($Ti$) append $Ti$ to TO-order wait until all xacts preceding $Ti$ in TO-order committed if (validation of $Ti$’s readset fails) abort ($Ti$) else commit($Ti$) AGGRO Performance - Performance speed-up (20% reordering, only one SO explored) ![Graph showing performance speed-up with and without speculation. The x-axis represents transactions per second, and the y-axis represents response time in microseconds. The graph shows a significant speedup with speculation compared to no speculation.](image) Contents - Part I: (Non-Distributed) STMs - Part II: Distributed STMs - Part III: Case-studies - Part IV: Conclusions Conclusions - Replication helps in read-dominated workloads or when writes have low conflicts - Replication provides fault-tolerance - Some techniques have promising results M. Couceiro, P. Romano, L. Rodrigues, HPCS 2011 Conclusions - No technique outperforms the others for all workloads, networks, number of machines, etc. - Autonomic management of the distributed consistency and replication protocols - Change the protocols in runtime, in face of changing workloads. A bit of publicity - Time for the commercials CLOUD-TM - DTM: a programming paradigm for the Cloud? - Stay tuned on www.cloudtm.eu Euro-TM Cost Action - Research network bringing together leading European experts in the area of TMs - Contact us if you are interested in joining it: - romano@inesc-id.pt - ler@inesc-id.pt - www.eurotm.org Bibliography Bibliography Bibliography [FC10] Sérgio Fernandes and João Cachopo, A scalable and efficient commit algorithm for the JVSTM, 5th ACM SIGPLAN Workshop on Transactional Computing Bibliography - [GHP05] Rachid Guerraoui, Maurice Herlihy, Bastian Pochon: Toward a theory of transactional contention managers. PODC 2005: 258-264 - [GU09] Rachid Guerraoui, Tutorial on transactional memory, CAV 2009 Bibliography Bibliography - [KA]LKW08] Christos Kotselidis, Mohammad Ansari, Kim Jarvis, Mikel Luján, Chris Kirkham and Ian Watson, DiSTM: A Software Transactional Memory Framework for Clusters, In the 37th International Conference on Parallel Processing (ICPP'08), September 2008 Bibliography The End Thank you.
{"Source-Url": "http://www.gsd.inesc-id.pt/~romanop/files/papers/hpcs11.pdf", "len_cl100k_base": 13872, "olmocr-version": "0.1.49", "pdf-total-pages": 213, "total-fallback-pages": 0, "total-input-tokens": 296633, "total-output-tokens": 22788, "length": "2e13", "weborganizer": {"__label__adult": 0.0003070831298828125, "__label__art_design": 0.00030231475830078125, "__label__crime_law": 0.00023186206817626953, "__label__education_jobs": 0.0004165172576904297, "__label__entertainment": 6.711483001708984e-05, "__label__fashion_beauty": 0.00012612342834472656, "__label__finance_business": 0.0002789497375488281, "__label__food_dining": 0.0002906322479248047, "__label__games": 0.0007462501525878906, "__label__hardware": 0.0011272430419921875, "__label__health": 0.00034046173095703125, "__label__history": 0.00025010108947753906, "__label__home_hobbies": 8.606910705566406e-05, "__label__industrial": 0.0003197193145751953, "__label__literature": 0.0001962184906005859, "__label__politics": 0.0002123117446899414, "__label__religion": 0.0003879070281982422, "__label__science_tech": 0.020477294921875, "__label__social_life": 6.520748138427734e-05, "__label__software": 0.007076263427734375, "__label__software_dev": 0.9658203125, "__label__sports_fitness": 0.0002865791320800781, "__label__transportation": 0.0004673004150390625, "__label__travel": 0.0001989603042602539}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 58007, 0.02157]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 58007, 0.3189]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 58007, 0.80963]], "google_gemma-3-12b-it_contains_pii": [[0, 147, false], [147, 266, null], [266, 385, null], [385, 447, null], [447, 677, null], [677, 840, null], [840, 1148, null], [1148, 1434, null], [1434, 1721, null], [1721, 1892, null], [1892, 2094, null], [2094, 2303, null], [2303, 2531, null], [2531, 2763, null], [2763, 2881, null], [2881, 3004, null], [3004, 3198, null], [3198, 3439, null], [3439, 3777, null], [3777, 4035, null], [4035, 4234, null], [4234, 4527, null], [4527, 4951, null], [4951, 5220, null], [5220, 5521, null], [5521, 5663, null], [5663, 5857, null], [5857, 6053, null], [6053, 6257, null], [6257, 6609, null], [6609, 6760, null], [6760, 6931, null], [6931, 7123, null], [7123, 7336, null], [7336, 7441, null], [7441, 7636, null], [7636, 7760, null], [7760, 7842, null], [7842, 7991, null], [7991, 8403, null], [8403, 8616, null], [8616, 8869, null], [8869, 8945, null], [8945, 9052, null], [9052, 9109, null], [9109, 9277, null], [9277, 9358, null], [9358, 9417, null], [9417, 9697, null], [9697, 9834, null], [9834, 9963, null], [9963, 10101, null], [10101, 10202, null], [10202, 10303, null], [10303, 10473, null], [10473, 10659, null], [10659, 10792, null], [10792, 10982, null], [10982, 11229, null], [11229, 11433, null], [11433, 11623, null], [11623, 11901, null], [11901, 12071, null], [12071, 12334, null], [12334, 12445, null], [12445, 12606, null], [12606, 12820, null], [12820, 13123, null], [13123, 13379, null], [13379, 13460, null], [13460, 13541, null], [13541, 13753, null], [13753, 13823, null], [13823, 14042, null], [14042, 14393, null], [14393, 14723, null], [14723, 15009, null], [15009, 15090, null], [15090, 15233, null], [15233, 15570, null], [15570, 16428, null], [16428, 16778, null], [16778, 17056, null], [17056, 17074, null], [17074, 17197, null], [17197, 17290, null], [17290, 17387, null], [17387, 17656, null], [17656, 17982, null], [17982, 18373, null], [18373, 18691, null], [18691, 18784, null], [18784, 19021, null], [19021, 19114, null], [19114, 19473, null], [19473, 19726, null], [19726, 19819, null], [19819, 20157, null], [20157, 20479, null], [20479, 20572, null], [20572, 20685, null], [20685, 20940, null], [20940, 21247, null], [21247, 21434, null], [21434, 21771, null], [21771, 21888, null], [21888, 22060, null], [22060, 22173, null], [22173, 22410, null], [22410, 22641, null], [22641, 22917, null], [22917, 22998, null], [22998, 23260, null], [23260, 23373, null], [23373, 23491, null], [23491, 23660, null], [23660, 23788, null], [23788, 24116, null], [24116, 24259, null], [24259, 24565, null], [24565, 24890, null], [24890, 25086, null], [25086, 25549, null], [25549, 26118, null], [26118, 26261, null], [26261, 26581, null], [26581, 26832, null], [26832, 26975, null], [26975, 27296, null], [27296, 27570, null], [27570, 27713, null], [27713, 28172, null], [28172, 28325, null], [28325, 28444, null], [28444, 28758, null], [28758, 29074, null], [29074, 29350, null], [29350, 29703, null], [29703, 29834, null], [29834, 30004, null], [30004, 30392, null], [30392, 30818, null], [30818, 30952, null], [30952, 31255, null], [31255, 31498, null], [31498, 31659, null], [31659, 31748, null], [31748, 32064, null], [32064, 32290, null], [32290, 32523, null], [32523, 36446, null], [36446, 37234, null], [37234, 41209, null], [41209, 41386, null], [41386, 43741, null], [43741, 44007, null], [44007, 44321, null], [44321, 44573, null], [44573, 44837, null], [44837, 44953, null], [44953, 45032, null], [45032, 45274, null], [45274, 45274, null], [45274, 45537, null], [45537, 45961, null], [45961, 46025, null], [46025, 46594, null], [46594, 46816, null], [46816, 46845, null], [46845, 47161, null], [47161, 47612, null], [47612, 47892, null], [47892, 48054, null], [48054, 48335, null], [48335, 48469, null], [48469, 48469, null], [48469, 48469, null], [48469, 48522, null], [48522, 48522, null], [48522, 48859, null], [48859, 49026, null], [49026, 49269, null], [49269, 49452, null], [49452, 49559, null], [49559, 49875, null], [49875, 50207, null], [50207, 50261, null], [50261, 50388, null], [50388, 50523, null], [50523, 50579, null], [50579, 50640, null], [50640, 51096, null], [51096, 51181, null], [51181, 51585, null], [51585, 51809, null], [51809, 52041, null], [52041, 52326, null], [52326, 52672, null], [52672, 52791, null], [52791, 53015, null], [53015, 53269, null], [53269, 53316, null], [53316, 53403, null], [53403, 53403, null], [53403, 53615, null], [53615, 54340, null], [54340, 55007, null], [55007, 55547, null], [55547, 56060, null], [56060, 56795, null], [56795, 57660, null], [57660, 57988, null], [57988, 58007, null]], "google_gemma-3-12b-it_is_public_document": [[0, 147, true], [147, 266, null], [266, 385, null], [385, 447, null], [447, 677, null], [677, 840, null], [840, 1148, null], [1148, 1434, null], [1434, 1721, null], [1721, 1892, null], [1892, 2094, null], [2094, 2303, null], [2303, 2531, null], [2531, 2763, null], [2763, 2881, null], [2881, 3004, null], [3004, 3198, null], [3198, 3439, null], [3439, 3777, null], [3777, 4035, null], [4035, 4234, null], [4234, 4527, null], [4527, 4951, null], [4951, 5220, null], [5220, 5521, null], [5521, 5663, null], [5663, 5857, null], [5857, 6053, null], [6053, 6257, null], [6257, 6609, null], [6609, 6760, null], [6760, 6931, null], [6931, 7123, null], [7123, 7336, null], [7336, 7441, null], [7441, 7636, null], [7636, 7760, null], [7760, 7842, null], [7842, 7991, null], [7991, 8403, null], [8403, 8616, null], [8616, 8869, null], [8869, 8945, null], [8945, 9052, null], [9052, 9109, null], [9109, 9277, null], [9277, 9358, null], [9358, 9417, null], [9417, 9697, null], [9697, 9834, null], [9834, 9963, null], [9963, 10101, null], [10101, 10202, null], [10202, 10303, null], [10303, 10473, null], [10473, 10659, null], [10659, 10792, null], [10792, 10982, null], [10982, 11229, null], [11229, 11433, null], [11433, 11623, null], [11623, 11901, null], [11901, 12071, null], [12071, 12334, null], [12334, 12445, null], [12445, 12606, null], [12606, 12820, null], [12820, 13123, null], [13123, 13379, null], [13379, 13460, null], [13460, 13541, null], [13541, 13753, null], [13753, 13823, null], [13823, 14042, null], [14042, 14393, null], [14393, 14723, null], [14723, 15009, null], [15009, 15090, null], [15090, 15233, null], [15233, 15570, null], [15570, 16428, null], [16428, 16778, null], [16778, 17056, null], [17056, 17074, null], [17074, 17197, null], [17197, 17290, null], [17290, 17387, null], [17387, 17656, null], [17656, 17982, null], [17982, 18373, null], [18373, 18691, null], [18691, 18784, null], [18784, 19021, null], [19021, 19114, null], [19114, 19473, null], [19473, 19726, null], [19726, 19819, null], [19819, 20157, null], [20157, 20479, null], [20479, 20572, null], [20572, 20685, null], [20685, 20940, null], [20940, 21247, null], [21247, 21434, null], [21434, 21771, null], [21771, 21888, null], [21888, 22060, null], [22060, 22173, null], [22173, 22410, null], [22410, 22641, null], [22641, 22917, null], [22917, 22998, null], [22998, 23260, null], [23260, 23373, null], [23373, 23491, null], [23491, 23660, null], [23660, 23788, null], [23788, 24116, null], [24116, 24259, null], [24259, 24565, null], [24565, 24890, null], [24890, 25086, null], [25086, 25549, null], [25549, 26118, null], [26118, 26261, null], [26261, 26581, null], [26581, 26832, null], [26832, 26975, null], [26975, 27296, null], [27296, 27570, null], [27570, 27713, null], [27713, 28172, null], [28172, 28325, null], [28325, 28444, null], [28444, 28758, null], [28758, 29074, null], [29074, 29350, null], [29350, 29703, null], [29703, 29834, null], [29834, 30004, null], [30004, 30392, null], [30392, 30818, null], [30818, 30952, null], [30952, 31255, null], [31255, 31498, null], [31498, 31659, null], [31659, 31748, null], [31748, 32064, null], [32064, 32290, null], [32290, 32523, null], [32523, 36446, null], [36446, 37234, null], [37234, 41209, null], [41209, 41386, null], [41386, 43741, null], [43741, 44007, null], [44007, 44321, null], [44321, 44573, null], [44573, 44837, null], [44837, 44953, null], [44953, 45032, null], [45032, 45274, null], [45274, 45274, null], [45274, 45537, null], [45537, 45961, null], [45961, 46025, null], [46025, 46594, null], [46594, 46816, null], [46816, 46845, null], [46845, 47161, null], [47161, 47612, null], [47612, 47892, null], [47892, 48054, null], [48054, 48335, null], [48335, 48469, null], [48469, 48469, null], [48469, 48469, null], [48469, 48522, null], [48522, 48522, null], [48522, 48859, null], [48859, 49026, null], [49026, 49269, null], [49269, 49452, null], [49452, 49559, null], [49559, 49875, null], [49875, 50207, null], [50207, 50261, null], [50261, 50388, null], [50388, 50523, null], [50523, 50579, null], [50579, 50640, null], [50640, 51096, null], [51096, 51181, null], [51181, 51585, null], [51585, 51809, null], [51809, 52041, null], [52041, 52326, null], [52326, 52672, null], [52672, 52791, null], [52791, 53015, null], [53015, 53269, null], [53269, 53316, null], [53316, 53403, null], [53403, 53403, null], [53403, 53615, null], [53615, 54340, null], [54340, 55007, null], [55007, 55547, null], [55547, 56060, null], [56060, 56795, null], [56795, 57660, null], [57660, 57988, null], [57988, 58007, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 58007, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 58007, null]], "pdf_page_numbers": [[0, 147, 1], [147, 266, 2], [266, 385, 3], [385, 447, 4], [447, 677, 5], [677, 840, 6], [840, 1148, 7], [1148, 1434, 8], [1434, 1721, 9], [1721, 1892, 10], [1892, 2094, 11], [2094, 2303, 12], [2303, 2531, 13], [2531, 2763, 14], [2763, 2881, 15], [2881, 3004, 16], [3004, 3198, 17], [3198, 3439, 18], [3439, 3777, 19], [3777, 4035, 20], [4035, 4234, 21], [4234, 4527, 22], [4527, 4951, 23], [4951, 5220, 24], [5220, 5521, 25], [5521, 5663, 26], [5663, 5857, 27], [5857, 6053, 28], [6053, 6257, 29], [6257, 6609, 30], [6609, 6760, 31], [6760, 6931, 32], [6931, 7123, 33], [7123, 7336, 34], [7336, 7441, 35], [7441, 7636, 36], [7636, 7760, 37], [7760, 7842, 38], [7842, 7991, 39], [7991, 8403, 40], [8403, 8616, 41], [8616, 8869, 42], [8869, 8945, 43], [8945, 9052, 44], [9052, 9109, 45], [9109, 9277, 46], [9277, 9358, 47], [9358, 9417, 48], [9417, 9697, 49], [9697, 9834, 50], [9834, 9963, 51], [9963, 10101, 52], [10101, 10202, 53], [10202, 10303, 54], [10303, 10473, 55], [10473, 10659, 56], [10659, 10792, 57], [10792, 10982, 58], [10982, 11229, 59], [11229, 11433, 60], [11433, 11623, 61], [11623, 11901, 62], [11901, 12071, 63], [12071, 12334, 64], [12334, 12445, 65], [12445, 12606, 66], [12606, 12820, 67], [12820, 13123, 68], [13123, 13379, 69], [13379, 13460, 70], [13460, 13541, 71], [13541, 13753, 72], [13753, 13823, 73], [13823, 14042, 74], [14042, 14393, 75], [14393, 14723, 76], [14723, 15009, 77], [15009, 15090, 78], [15090, 15233, 79], [15233, 15570, 80], [15570, 16428, 81], [16428, 16778, 82], [16778, 17056, 83], [17056, 17074, 84], [17074, 17197, 85], [17197, 17290, 86], [17290, 17387, 87], [17387, 17656, 88], [17656, 17982, 89], [17982, 18373, 90], [18373, 18691, 91], [18691, 18784, 92], [18784, 19021, 93], [19021, 19114, 94], [19114, 19473, 95], [19473, 19726, 96], [19726, 19819, 97], [19819, 20157, 98], [20157, 20479, 99], [20479, 20572, 100], [20572, 20685, 101], [20685, 20940, 102], [20940, 21247, 103], [21247, 21434, 104], [21434, 21771, 105], [21771, 21888, 106], [21888, 22060, 107], [22060, 22173, 108], [22173, 22410, 109], [22410, 22641, 110], [22641, 22917, 111], [22917, 22998, 112], [22998, 23260, 113], [23260, 23373, 114], [23373, 23491, 115], [23491, 23660, 116], [23660, 23788, 117], [23788, 24116, 118], [24116, 24259, 119], [24259, 24565, 120], [24565, 24890, 121], [24890, 25086, 122], [25086, 25549, 123], [25549, 26118, 124], [26118, 26261, 125], [26261, 26581, 126], [26581, 26832, 127], [26832, 26975, 128], [26975, 27296, 129], [27296, 27570, 130], [27570, 27713, 131], [27713, 28172, 132], [28172, 28325, 133], [28325, 28444, 134], [28444, 28758, 135], [28758, 29074, 136], [29074, 29350, 137], [29350, 29703, 138], [29703, 29834, 139], [29834, 30004, 140], [30004, 30392, 141], [30392, 30818, 142], [30818, 30952, 143], [30952, 31255, 144], [31255, 31498, 145], [31498, 31659, 146], [31659, 31748, 147], [31748, 32064, 148], [32064, 32290, 149], [32290, 32523, 150], [32523, 36446, 151], [36446, 37234, 152], [37234, 41209, 153], [41209, 41386, 154], [41386, 43741, 155], [43741, 44007, 156], [44007, 44321, 157], [44321, 44573, 158], [44573, 44837, 159], [44837, 44953, 160], [44953, 45032, 161], [45032, 45274, 162], [45274, 45274, 163], [45274, 45537, 164], [45537, 45961, 165], [45961, 46025, 166], [46025, 46594, 167], [46594, 46816, 168], [46816, 46845, 169], [46845, 47161, 170], [47161, 47612, 171], [47612, 47892, 172], [47892, 48054, 173], [48054, 48335, 174], [48335, 48469, 175], [48469, 48469, 176], [48469, 48469, 177], [48469, 48522, 178], [48522, 48522, 179], [48522, 48859, 180], [48859, 49026, 181], [49026, 49269, 182], [49269, 49452, 183], [49452, 49559, 184], [49559, 49875, 185], [49875, 50207, 186], [50207, 50261, 187], [50261, 50388, 188], [50388, 50523, 189], [50523, 50579, 190], [50579, 50640, 191], [50640, 51096, 192], [51096, 51181, 193], [51181, 51585, 194], [51585, 51809, 195], [51809, 52041, 196], [52041, 52326, 197], [52326, 52672, 198], [52672, 52791, 199], [52791, 53015, 200], [53015, 53269, 201], [53269, 53316, 202], [53316, 53403, 203], [53403, 53403, 204], [53403, 53615, 205], [53615, 54340, 206], [54340, 55007, 207], [55007, 55547, 208], [55547, 56060, 209], [56060, 56795, 210], [56795, 57660, 211], [57660, 57988, 212], [57988, 58007, 213]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 58007, 0.01309]]}
olmocr_science_pdfs
2024-11-24
2024-11-24
59d6b136b47fd3c8d519724d1f90e9d5a7065ce8
The Software Architecture of DBLEARN Colin Carter, Howard J. Hamilton* and Nick Cercone Department of Computer Science University of Regina Regina, Sask., Canada S4S 0A2 {carter,hamilton,nick}@cs.uregina.ca January 31, 1994 Abstract The structure of DBLEARN is described and some improvements to its design and functionality are proposed. DBLEARN is a knowledge discovery from databases program that uses attribute oriented generalization guided by concept hierarchies. DBLEARN consists of five modules: the user interface, the command module, the database module, the concept hierarchy module, and the learning module. Each of these are described as to the function they perform, what input they require and output they produce. Detailed suggestions for improvements to four of the modules are also presented. 1 Introduction Knowledge discovery from databases is the automated extraction of useful and interesting, implicit information from large bodies of diverse data stored in databases. This information is implicit in that it is contained in the data, but it is hidden by a preponderance of overly specific data. One primary method of extracting the information is by generalizing specific data values into more general concepts. The primary objectives of such discovery is to produce new non-trivial information that is understandable, accurate and useful [Frawley et al., 1992]. DBLEARN is a machine learning program which implements attribute oriented generalization using concept hierarchies [Han et al., 1992, Han et al., 1993]. A prototype implementation was made available to us by Jiawei Han of Simon Fraser University. We modified and to some extent redesigned this prototype to produce the version of DBLEARN described in this paper. For details on changes made to improve efficiency, see [Carter and Hamilton, 1994]. Attribute oriented generalization seeks to transform diverse data stored in database relations into more general and useful information on an attribute by attribute basis. *Supported by Natural Sciences Engineering Research Council of Canada (NSERC) Research Grant OPG0121504. Generalization is accomplished by replacing the specific attribute data values of each tuple with more and more general concepts. In this way, the number of distinct values of each attribute is reduced as related values are grouped into more general concepts. Many tuples then become redundant as the information they contain becomes identical to other tuples. These redundancies are eliminated by removing all but one of the identical tuples. This generalization continues until an acceptable level of information is attained. The generalization is guided by concept hierarchies associated with each attribute of the relation to be generalized. A concept hierarchy is a tree structure defined by a domain expert that provides a hierarchical taxonomy of concepts ranging from a single most general concept at the root of the tree to some representation of all possible attribute values at the leaves. Concepts are formed by grouping related attribute values together and representing all members of this set or range by a single symbol. These symbols in turn may be grouped into more general concepts which are again represented by another unique symbol. This grouping continues until the most general concept, called ANY, is reached. The generalization process is limited by the specification of two tunable threshold values, the attribute threshold and the table threshold. The attribute threshold specifies the maximum number of distinct values of any attribute that may exist in the final generalized relation. Generalization proceeds first by reducing the number of distinct values of attributes to less than or equal to the attribute threshold. Duplicate tuples are then removed. The resulting relation is called the prime relation. The table threshold specifies the maximum number of tuples that may exist in the final generalized relation. If the number of tuples in the prime relation exceeds the table threshold, then further generalization must take place. This is accomplished by choosing an attribute by some method, generalizing it another level, and then removing duplicates. This process iterates until the number of tuples is no more than the table threshold. The result of generalization, therefore, is a relation with a limited number of tuples containing much more general, summarized information than was in the original ungeneralized relation. Each tuple in this relation represents a class of the original tuples. Any of the tuples that were generalized into this final tuple are specific members of this class. This generalization procedure is used to accomplish two types of learning tasks, characteristic learning tasks and classification or discriminate learning tasks. Characteristic learning tasks operate on one set of data and seek to discover interesting relationships between attributes of a relation. An example might be the relationship between the amount of money a researcher is granted and the area of study in which the researcher is working. Another example might be the relationship between observed symptoms and a disease. Classification or discriminate learning tasks operate on two sets of data and seek to determine interesting distinctions between the characteristics of the concepts represented in each. An example might be the amounts of money granted to researcher in one field compared to the amounts of money granted researchers in a different field. Another example might be symptoms that distinguish one disease from another. These two types of learning tasks are the primary functions of DBLEARN. At least four versions of DBLEARN are currently being used or developed, three in academic institutions and one in a commercial setting. The version running at the University of Regina has been ported to an IBM compatible 80386 microcomputer running on OS/2. version 2.1. It uses IBM’s DB2/2 database, a port of their mainframe relational database product. It is written in C using IBM’s CSetPlus compiler. It has two user interfaces, a command line interface developed with UNIX’s lex and yacc compilers, and a prototypical OS/2 Presentation Manager graphical user interface. The remainder of this paper is organized as follows. In Section 2, we describe the architecture of DBLEARN in some detail as it is and as it should be. In Section 3, we suggest some enhancements that might be incorporated into its general design and implementation. Finally in Section 4, we present conclusions. In the Endnotes section at the end of the paper, we identify specific discrepancies between our software architecture for DBLEARN and the current implementation. 2 The Architecture of DBLEARN As shown in Figure 1, DBLEARN consists of the following components: 1. User Interface Module 2. Command Module 3. Database Access Module 4. Concept Hierarchy Module 5. Learning Module The user interface module is the primary communication medium between the user and the program as a whole. It handles all input, passing user requests to the command module and receiving back information to be displayed. The command module in turn controls the majority of internal program direction. It receives its direction from the user interface and routes the requests to the appropriate module for processing. The command module communicates with the database module to gain information about available database objects, and it initializes the learning task query to the database. It also directs the concept hierarchy module to build the concept hierarchies and directs the translation of high level learning requests into low level SQL queries. When all relevant task information has been set by the user interface, the command module starts the generalization process with a call to the learning module. This module is the heart of the generalization process. After activation by the command module, the learning module interacts with both the database module to retrieve data and the concept hierarchy module to gain generalization information to reduce the database relations to informational size. These results are passed back through the command module and then to the user through the user interface module. An attempt has been made in this design to make these five units as distinct and separate from each other as possible. The current version of DBLEARN achieves this modularity to a great extent. For the most part, this paper will describe the design as it should be, noting in the Endnotes where discrepancies occur in the current actual version. Each of the modules will now be described in greater detail. ### 2.1 The User Interface The primary purpose of the user interface is to provide a way for the user to easily initiate learning tasks and set and access information about all aspects of this process. It should also allow interaction between the user and the various modules of the program to correct error conditions and give direction as needed. These and other features are described in this section. The interaction between the user interface module and the command module are shown in Figure 2. The user communicates with the interface through the keyboard at least. If a graphical interface is available, the mouse will also be a primary input tool. In addition the user may use I/O redirection to obtain input from a file. All user requests are routed to the command module for direction to other modules for handling. These other modules will carry out the request from the user and return some sort of structure or error condition to the command module. The command module will return these to the user interface. It is the user interface’s responsibility to handle all display or output of results and interaction with the user to correct error conditions.1 There are two interfaces available at the current time, a command line interface and a prototypical graphical user interface developed under OS/2’s Presentation Manager. These two interfaces will now be described and analyzed to some extent. 2.1.1 Command Line Interface The primary current interface in use is a command line style interactive interface. It has been created using UNIX’s lex and yacc programs. All information and feedback is entered in a simple text based screen, and therefore is available to any computer with an ASCII interface. The yacc interface has been described in [Huang and Cai, 1993]; here, we simply mention some modifications. In the original program, all information for a learning task is defined in one large syntactic unit. That is, the individual units of information needed for defining the task are specified in a predefined and restricted order as a part of one large task definition paragraph. If the user accidentally enters a syntactic error in a latter part of the task definition entry, such as misspelling a keyword, the whole process must be started again. This is very frustrating to the user. In the current version, the task definition process is broken down into much smaller parts, each of which establish a current default for the various parts until changed. For example, the set command sets any of four threshold values; e.g., \texttt{set attribute threshold \textless \text{number} \textgreater} sets the value of the attribute threshold in the task information structure and returns. Similarly, all other individual pieces of information that the command module provides functions for setting can be set in a similar fashion. Those that perform the construction of some data structure, such as the specification of a concept hierarchy file, build the structure right away so that error conditions can be corrected immediately. When the learning task is completed, the values remain set and only those that need changing for a subsequent task need to be specified. For example, after completing a task, the attribute threshold can be adjusted, the start command issued, and the same task would be repeated with these changes. In the modified program, commands are provided to ask queries about the databases. For example, the command \texttt{what databases} returns a list of current databases known by the DBMS. Similarly, the command \texttt{what tables} returns a list of tables that exist in the current connected database, and \texttt{what attributes for \textless \text{table name} \textgreater} returns the attributes defined for a given table. There is also provision for retrieving information about the schema of a given table.2 Finally, the current yacc interface does not use the command module structure described in this paper. The information needed to initiate a learning task is defined and then saved to a file which the learning module opens and reads to gain the information it needs. The learning module itself then directs most of the activity that this paper describes as the responsibility of the command module. 2.1.2 Prototypical Graphical Interface As an alternate to the yacc interface, a prototypical graphical user interface (GUI) has been developed under OS/2's Presentation Manager. It is an interface which uses many of the standard graphical entry and feedback mechanisms now common in many GUI's such as Microsoft Windows. It is written in C++ using IBM's CSetPlus compiler. The main windows and dialogs were designed using the dialog editor provided with the Programmer's Toolkit that IBM bundles with their compiler. The primary input structure in this interface is a task definition dialog window which has a number of different input objects used to set various specifications of a learning task. This input structure and the functions it provides are the primary focus of the following discussion. Dynamically Retrieved Information A significant advantage of the graphical interface is that it dynamically provides much of the information needed for specifying a learning task. This saves the user from having to remember such things as the precise names of databases, relations and attributes. When the GUI is started, the database manager (DBMS) system tables are queried for all defined databases. These are presented to the user in a drop down list box for selection of the desired database. That database is then connected, and the DBMS system tables are again queried for all defined tables and views in this database. These are presented to the user in a pop-up multi-select list box. The user is then able to select as many tables as are relevant for the learning task. A click on an OK button signals the end of table selection. The selected items are then entered into a plain scrollable text box so the user can see only which tables were selected. If the user selects only one, it is entered into this list in an unmodified form. If more than one table is selected, a correlation name is automatically added to each table name to make the construction of queries easier at a later time. Next the database's system tables are again queried for all defined attributes of the tables that were selected. These attributes are presented to the user in another pop-up, multi-select list box, and the user chooses a subset of attributes that are to be in the relation to be generalized. These are similarly entered into a plain list box in the main dialog window so the user can see which ones have been selected. This information is not set permanently for the current learning task, but may be changed at any time by clicking on the drop down symbol of the database list or one of two push buttons associated with the relations or attributes lists. Setting General Learning Task Parameters When the user has been guided through these steps to select the database, tables and attributes relevant to the learning task, he or she may now specify the rest of the information needed to initiate a learning task. The task type, characteristic or discriminate, may be selected from a two item drop down list box, with the user's choice being the only one to remain visible after selection. The choice of this task type also determines what further options are available to the user. If a discriminate task is chosen, then the area of the main task definition dialog window for defining a contrast predicate is activated and made available for input. If a characteristic task is chosen, these areas are deactivated so that input is not possible. This saves the inexperienced user from specifying unneeded information. The concept hierarchy files may be selected from a multi-select, browsable file list when a “Set Hierarchies” button is pressed. This frees the user from having to remember the precise name and directory of hierarchy files. The subset of attributes that the user desires prop amounts for may also be selected when a “Set Prop” button is pressed. A list of all numeric attributes is presented to the user and as many as are desired may be selected. These are marked with a 'p' in the attributes list box so the user has an easy way of telling how many props are specified. A special check box is also available for the prop(votes) function. The attribute and table thresholds may also be set by clicking in one of two simple text entry boxes. The text in these boxes is preset to the threshold defaults of 10 and 5 for table and attribute thresholds respectively, but any valid integer may be entered. The system verifies that user's entry is a valid number and pops up an information box to signal erroneous input. The titles of the target and contrast relations may also be set in simple text entry boxes. The contrast relation title box will not be activated if a characteristic task type is selected as the current task type. Finally, the target predicate and contrast predicate if needed can be entered in larger editable text entry boxes. The predicates may be entered in normal DBLEARN syntax in these areas. This is basically a minimal patch until a more powerful graphical query definer can be devised. The current syntax of DBLEARN predicates is restricted enough that the user could be guided through the definition of queries by being presented with dynamically determined choices for each step. One additional option is available to control the amount of information output by the system. A “Debug” button may be pressed to present a pop-up menu with two choices - intermediate output or final output only. The intermediate option causes such things as the high and low level queries, and the prime relation as well as the final generalized relation to be printed on the output stream. The final output only selection causes only the final generalized relation to be output. When the user has defined all information for a learning task, the generalization process may be initiated by clicking an “OK” button. This sets in action the retrieval of database information, the building of concept hierarchies and the generalization process. The task definition dialog disappears and a simple editor window appears into which the results of the learning task are entered. The results may be saved to file from this window or printed as the user desires. **Limitations of the Current Prototype** As was already mentioned, the predicate definition is still accomplished by simply typing the predicate in. A more powerful guided query builder should be written for this. There is also no features currently available for displaying information about concept hierarchies or relation schemas. There should be some way of displaying arbitrarily specified concept hierarchies from a specified file. In spite of these limitations, the graphical user interface shows great promise. Defining a learning task is much easier in this environment than the yacc command line interface, and the potential for user assistance is query building is much greater. 2.2 The Command Module The command module is the primary controller of communication between various modules of the DBLEARN system. As we have seen, it receives requests from the user interface to set various parameters of the learning task or gain information about available structures. The command module also interfaces to the other three modules, the database module, the concept hierarchy module and the learning module to control most other aspects of program operation. It interfaces to the database system to get information about available databases, tables and attributes. It controls the loading of concept hierarchies. It initiates learning tasks and receives and relays interaction requests from the learning module as generalization progresses. It then returns the results of all of these to the user interface for display. The command module will be described in terms of its interaction with the database module, the concept hierarchy module and the learning module, and other miscellaneous functions that it performs. 2.2.1 Command Module’s Interaction with the Database Module As shown in Figure 3 The command module performs various functions with regard to the database module. The primary responsibility of the database module is to provide one or two relations to be generalized for characteristic or discriminate tasks. The command module provides functions necessary to build these. This includes starting the DBMS if necessary, retrieving information about the current database objects, connecting to specific databases, retrieving more detailed information about the current connected database, and building and initiating the actual queries for target and contrast relation retrieval. Starts DBMS if Necessary On some systems, the DBMS may not be running when DBLEARN is started. In this case the command module provides a function to start the target DBMS as a background process. In some installations, this will be unnecessary in that the DBMS is running constantly as an essential part of the organization. When the DBMS is running, the current user of DBLEARN needs to be logged onto the system. DBLEARN cannot be used to circumvent database security and so every user must access the DBMS according to his or her own security level. Success or error codes signal the results of these operations. Retrieves General Database Information The user may not remember the specific names of database objects that he or she wishes to access, but the command module provides functionality to access this information. It allows for the querying of the database system tables to find out what databases are available, what tables or views are available in a specific database and what attributes are available in a specific table or view. The names are returned as lists of strings. This allows the user interface to provide this information to the user to guide the task definition process. Connects to a Database After the user interface has been provided with what databases are available, the command module may be requested to connect with a specific database. Only one database may be current at a given time. The connect command establishes that database as the current database until a subsequent connection is established or the connection is broken through an explicit disconnect or through some exceptional error condition. Retrieves Relation Schemas When a connection has been established, the user may want to know more specific information about the tables or view that are available. The command unit is able to query the database for schema information about any available table or view. The result is returned in a structure which can be passed to the user interface for display. This will enable the user to review what options are available for task definition. Initializes the Retrieval of Target and Contrast Relations One of the major inputs to the learning task is a relation or set of two relations to generalize. It is the command module’s responsibility to guide the building of the necessary query to extract these relations and to interface to the database module to initialize the query to retrieve tuples for the learning module. The command module provides functions to accomplish the various steps of this procedure. These begin with specifying the database tables or views from which the target and contrast relations will be extracted. Then the attributes of these tables which will be in the relations to be generalized can be specified. The target and contrast predicates must also be constructed. These predicates delineate more precisely what subset of data is desired from the tables to be queried. This subset of database data may be described in terms of high level concepts rather than low level, specific attribute values. The high level concepts must match concepts that are defined in the concept hierarchy tree for the attribute to which they pertain. The concepts will be then translated by a call to the concept hierarchy module into more specific values relevant to the actual data. From these various parts, the tables, attributes and predicates, one or two SQL queries are constructed and passed to the database module for initialization. The initialization process checks whether each query is valid and sets up the database to retrieve tuples. any error occurs, this will be signalled to the user through the user interface and corrective measures can be taken.\textsuperscript{16} ### 2.2.2 Command Module’s Interaction with the Concept Hierarchy Module The primary functions of the command module’s interactions with the concept hierarchy are to direct the loading of individual concept hierarchy trees, provide access to these trees so the user interface can display them, perform the translation from high level concepts to low level database attribute values, and to adjust concept hierarchies based on statistical information in database relations.\textsuperscript{17} The user may specify a file or set of files from which concept hierarchies will be read. It is the command module’s responsibility to call the appropriate concept module function to load the proper hierarchy trees from these files and to return to the interface any errors or conditions that need response. Only trees that refer to attributes in the join of the relations of the current learning task need to be read, since only these attributes will be generalized. For this reason, the target relations need to be specified before the concept hierarchies are read in. Error conditions will include ill-formed concept hierarchy definitions or missing trees for a specified attribute. There is also the possibility of two or more trees defined for the same attribute. This could be handled by simply reading the first or last to be encountered, or the user could be asked which one to load. The return to the user would be code signalling success or error. The concept hierarchy trees need to be available to the user interface for display. A simple function which accepts an attribute name as an argument and returns a pointer to the hierarchy tree for that attribute is all that is necessary here. The user interface could then display the concept in an appropriate manner. Eventually the user will specify a query that may include a predicate to extract information from the database for the target or contrast relation. This predicate may include high level concepts as part of the specification for tuple extraction. These high level concepts need to be translated into values that are actually contained in the database, and the query needs to be adjusted accordingly. It is the command module’s responsibility to call the appropriate concept functions to accomplish this when the user interface sets the target or contrast predicate. The return could be a code signalling success or error. A separate function would provide access to the translated predicate which would return the SQL string that will be used to query the database. Finally the command module will provide the user interface with the ability to adjust a concept hierarchy based on the statistical distribution of attribute values in a relation.\textsuperscript{18} ### 2.2.3 Command Module’s Interaction with the Learning Module The command module is responsible for providing all inputs to the learning procedures. These inputs include the relation(s) to be generalized and the relevant concept hierarchies needed to generalize the attributes of these relations. There are also certain parameters that specifically guide various aspects of the generalization process.\textsuperscript{19} As shown in Figure 4, the command module provides functions for setting these parameters and for starting the generalization process. The command module stores these parameters in a single task information structure, the fields of which are available through access functions. **Learning Task Types** A function is provided for setting the type of learning task. The two major task types are CHARACTERISTIC and DISCRIMINATE. The first will cause the extraction of one set of data for generalization, and the second will extract two relations to be generalized and contrasted with each other. An additional task type needed is a FURTHER GENERALIZATION task which will guide the process of taking a prime relation to a final generalized relation.\(^\text{20}\) **Threshold Values** Various threshold values guide the extent to which generalization is carried out. Functions are provided to set each of these. The attribute threshold specifies the maximum number of distinct values of any attribute that may exist in the generalized relation. When generalization reaches this stage, the prime relation is the result. The table threshold specifies the maximum number of tuples that may be in the final generalized relation. After the prime relation is achieved, if there are more tuples than the table threshold, further generalization must be accomplished. Two noise thresholds are also necessary for eliminating exceptional cases from the generalized relations.\(^\text{21}\) In characteristic learning tasks, some of the tuples in the final relation may only represent a very small percentage of the original tuples in the ungeneralized relation. A t-threshold may be specified to prune those tuples that represent, for example, less than five percent of original tuples, since this percentage of examples may be considered more as exceptional than the rule. In discriminate learning tasks, the target and contrast relations are first reduced to prime relations. An intersection of these is then performed and *overlapping tuples* (tuples that have a duplicate in the other relation) are marked. Unmarked tuples in the target relation represent classes of tuples that are derived solely from the ungeneralized target relation. Marked tuples represent classes that are represented to some degree in both target and contrast relations. The ratio of tuples represented by a class in the target relation compared to the total tuples in that class in both the target and contrast relations can be quantified as a *d-weight* for that class ([Han et al., 1993], p.37). The d-weight of unmarked, non-overlapping tuples is therefore 100%, since all examples of that class existed in the original target relation. A high d-weight signals that most of the examples in the class were derived from the target class with only a few exceptional cases from the contrast relation. A low d-weight signals that most of the examples of the class are in the contrast relation, and those in the target relation are exceptional. A medium d-weight carries very little information since the class is represented somewhat evenly in both relations. A d-threshold can be specified to include in the final generalized relation of a discriminate task those tuples that represent a high percentage of original tuples in both relations. A d-threshold set to 90%, therefore, would allow tuples with up to 10% exceptional cases in the contrast relation to still be included in the final result.\ **Prop Values** As generalization progresses, duplicate tuples are removed by the deletion of all but one of the duplicates. In this combining of tuples, there is a mechanism whereby the values of selected numeric attributes can be accumulated. The value of this total for a selected attribute of a single remaining tuple, therefore, represents the sum of all original attribute values that contributed to that tuple. When the final generalized relation has been achieved, a total for each specified numeric attribute is available for each tuple. From these values, a grand total for each selected attribute in the relation can be calculated. For each tuple, a ratio can now be calculated which represents how much an individual attribute’s amount represents in proportion to the grand total for all tuples. This ratio is currently known as a *prop value*, which is perhaps derived from “proportion.” DBLEARN will calculate prop values for only those numeric attributes that the user selects. The command modules provides a function which takes as an argument a list of attribute names and declares these as prop type attributes. When generalization is initiated, the appropriate totalling mechanism will be activated for these. There is a special prop value which can be requested by the user which performs a slightly different task. When duplicate tuple removal is in progress, a total of the number of tuples which contribute to a more general tuple is tracked as a vote amount. A final tuple’s vote count represents the total number of original tuples that are represented by that generalized tuple. A proportion of a tuple’s votes in relation to the total number of votes in the whole relation may be calculated and displayed with final generalized relation. This prop value represents the percentage of original tuples which are covered by the generalized tuple. A function of the command module is provided to signal the inclusion of this votes prop in the generalized relation. **Task Initiation and Feedback** When all information needed by a learning task has either been defined or is covered by some default value, the learning task itself may be initiated. The first stage of this is the generalization of the target relation to the prime relation. If the current task type is discriminate, the contrast relation will also be generalized. The command module provides a simple start command which initiates this process and generalizes the input relation to the attribute threshold. If errors occur, they are signalled by the command module. After initial generalization, an iterative process of further reduction must occur until the final generalized relation is attained. The user would need to be queried as to the desired reduction method and the process continued until the table threshold is reached. As an option, the user could specify one reduction method for the rest of the generalization process and allow it to continue to completion. A copy of the prime relation should be saved so that different reduction strategies could be tried without having to repeat the first expensive stage of generalization. 2.2.4 Command Module’s Other Functions The only other function that does not fall in the above categories is the quit command. Both interfaces have a quit command, which disconnects the current database, the logs off the user, and (for those systems where the DBMS was started by DBLEARN) removes the DBMS background process. 2.3 Database Module The database module provides all the functions for starting and accessing the DBMS, gaining information about database objects and querying to retrieve relations. These are written with mixed C code and inline SQL statements. The inline statements are preprocessed by a database preprocessor which translates them into C database function calls. 2.3.1 Database Connection As mentioned above, some DBLEARN implementations may run on machines where the DBMS is not running constantly. Where this is the case, the DBMS must be started as a background process. A part of this start-up procedure is the log-on procedure which establishes the current user’s security level and database access privileges. In addition a specific database must be connected. Functions are provided by the database module to accomplish all these tasks. 2.3.2 General Information Feedback The database module also provides functions to gain information about available database objects. These include what databases are available and what tables and views are defined for these databases. Functions are also provided for gaining access to relevant schema information about the currently available tables, especially attribute names and types. 2.3.3 Relation Retrieval The database module also contains functions for establishing queries and retrieving tuples from the resultant relation. Only one query may be current at a time, and this is established by passing a SQL string to a function which initializes the database to retrieve tuples from the resulting relation. After that, tuples may be retrieved one at a time until the database signals that no more are available. 2.4 Concept Hierarchy Module The concept hierarchy module is primarily responsible for building the concept hierarchy trees, translating queries involving high level concepts into low level SQL queries, and providing the matching of attribute values with concepts in the hierarchy trees. 2.4.1 Concept Hierarchy Tree Construction The internal concept hierarchy tree data structures are constructed from information specified in concept definition files. Before the user initiates a learning task, one or more files may be passed to the concept module for loading. If none are specified, a default file, called concept, is read from the current directory. In addition, a list of attributes is available which specifies what attributes will be in the full join of the relations to be generalized. Only those trees corresponding to these attributes need be read in from the concept files. The definition of concept hierarchies requires that the leaf nodes of the trees represent all possible values that may be encountered in the relation to be generalized. These attribute values may be of two types, range or non-range. Range values are values that can inherently be divided into ranges bounded by lower and upper bounds. Range values include all numbers, dates and times. The notation $x \sim y$ denotes a range value with a lower bound of $x$ and an upper bound of $y$, such that for any $z \in x \sim y$, $x \leq z < y$. In this way, attribute values with potentially limitless distinct values can be compactly represented in the concept hierarchy tree. On the other hand, non-range values are all strings and alpha-numeric codes or range types which contain only a finite, limited set of distinct values that have no inherent ordering and therefore need to be individually specified. Since non-range values represent limited sets of distinct values, the concept hierarchy trees can have the actual attribute values as leaves. The leaf nodes are arranged into related groups and these groups are represented by a single more general symbol. These higher level symbols are in turn grouped into yet more general concepts which are in turn represented by a higher level symbol. This generalization of concepts continues until the highest, most general concept “ANY” is reached at the root of the tree. The concept hierarchy is not required to be a balanced tree. The user is free to define a tree with whatever structure is desired, placing some leaf values on the same logical level as other non-leaf, generalized concepts. The learning module has been adjusted to properly handle such tree configurations. The function that builds this concept hierarchy tree, then, attaches it to a hierarchy pointer in the list of attributes built by the schema submodule of the concept hierarchy module and it becomes available to other modules. 2.4.2 High Level Concept Translation DBLEARN is designed so that extraction of data from the database may be accomplished by expressing queries in terms of high level concepts in the concept hierarchy tree. Since the tree’s leaf nodes represent all the possible values that may be encountered in the data, high level concepts can be translated into low level specifics by descending the tree from a higher node and retrieving all the leaf values for comparison against the database. For range values, a predicate such as: \[ \text{where discipline_code = "Computer"} \] might be translated into:\textsuperscript{28} \[ \text{where (discipline_code >= 23000 AND discipline_code < 23500) OR (discipline_code >= 23500 AND discipline_code < 24000) OR (discipline_code >= 24000 AND discipline_code < 24500) OR (discipline_code >= 24500 AND discipline_code < 25000)} \] which is simply a concatenation of leaf values under the concept \text{Computer}. For non range values, a predicate such as: \[ \text{where province = "Prairies"} \] might be translated into: \[ \text{where province = "Alberta" OR province = "Saskatchewan" OR province = "Manitoba"} \] When the user has entered the predicates for the target and contrast relations, these are passed by the command module to the concept module and this translation is accomplished. Errors may be signalled for syntactically incorrect predicates or concepts which are not found in the concept hierarchy tree.\textsuperscript{29} \subsection*{2.4.3 Attribute Value Matching} When tuples are read in from the database module, they are initially stored in a DBLEARN relation structure. The current version reads in the whole relation to be generalized and then begins generalization.\textsuperscript{30} This makes it necessary to store the attribute values in a space efficient way. When generalization begins, the attribute values must be matched against the concepts in the hierarchy tree so that more general concepts may be retrieved. Since the tree will need to be searched many times, it is necessary to perform this searching quickly. Both these requirements are fulfilled indirectly through the way in which the concept hierarchy information is stored and built. Since the leaf nodes of the concept hierarchy tree represent all values that may be found in the relation to be generalized, we know before any data is read from the database all possible values that might be encountered. For non-range values, therefore, a hash table can be constructed in which one copy of each hierarchy symbol is stored with its string representation. A pointer back to the concept hierarchy represented by this symbol can also be stored in this table. All attribute values read from the database, therefore, can also be hashed and stored as references to this table. In actuality, attribute values are hashed into the table, the matching concept is retrieved, and the attribute values are stored as pointers to the actual concepts they match. This gives instant access to generalization information when needed. For range type values, the conceptual storage of the actual value can be used, for example, storing integers as integers. The concept hierarchy tree can have extra fields defined to store the inherent types for the upper and lower bounds of the range values. When the first round of generalization is accomplished, the range values can be matched against these boundary values. On the first level of generalization, all values, range or non-range are replaced by concept symbols. Range values after generalization, therefore, can simply be replaced by a pointer to a concept, just as other values. Since attribute values are stored as pointers to concepts, when it comes time to generalize an attribute, all that is needed is to access the attribute’s concept and reset the attribute’s value to the concept’s parent in the hierarchy tree. No further searching of the tree is necessary after the first initial setting of the attribute’s value. This provides extremely fast generalization. In the duplicate removal stage, attribute values need to be compared against each other. Since they are stored as pointers into the concept hierarchy tree, all that is needed is a direct comparison of these pointers to ascertain whether two values are equal. Again this is a fast and efficient method of comparison allowing the duplicate removal process to proceed quickly. When the user interface is called upon to print any relation, the concept structure contains a reference into the hash table where its string representation is stored. This link can be easily followed to retrieve the needed string. 2.5 Learning Module The learning module contains the heart of the machine discovery process. Its primary inputs are the relation to be generalized, a set of concept hierarchy trees to guide the generalization and a structure detailing parameters that affect the generalization procedures. All of these elements have been described above. The primary steps in the learning process are initial generalization, duplicate removal, and further generalization. For characteristic learning tasks, the resultant generalized relation is the final product. For discriminate learning tasks, there will be two generalized relations which need to be compared to extract interesting differences. 2.5.1 Initial Generalization The initial generalization process simply involves iterating through each attribute of the input relation, replacing each attribute value with a more general concept and tracking the number of distinct values of attributes that remain after each iteration. When the number of distinct values of every attributes falls within the range of the attribute threshold, this stage of generalization ceases. As has been mentioned, the attributes are stored as pointers to concepts and so the actual replacement of a value with a more general concept is fast and easy. One issue that needs addressing, however, is how to handle unbalanced trees. A leaf node may not exist at the maximum depth of the tree when the tree is unbalanced. A measure of its distance from the maximum, distance_to_max, may be calculated by subtracting the node’s depth from the maximum depth of the tree. For example, in the tree shown in Figure 5, the distance to max of Alberta, Saskatchewan and Manitoba is 0, whereas B.C.’s is 1 and Ontario’s is 2. As generalization progresses, the level of generalization is tracked, with the first round being level 0. As attributes are accessed, if the generalization level is greater than or equal to the corresponding node’s distance to max, the node is generalized. Otherwise it is not. In the above tree, the three prairie provinces would be generalized in the first round, B.C. and the Prairies in the second round, and Western and Ontario on the third round. 2.5.2 Duplicate Removal When the attribute threshold has been reached for each attribute in the relation to be generalized, there will likely be many duplicate rows in the resulting relation. These are removed through a simple procedure. A new relation is created into which the first tuple of the generalized relation is copied. Then the rest of the tuples in the relation are compared to the elements of this new relation. As each of the original tuples is read, if it does not match any tuple in the new relation, it is added to it. If a tuple match is found, the vote count of the tuple in the new relation is increased by the vote amount of the duplicate. If any prop values have been defined for any attribute in the relation, these values are also accumulated in the new relation. The old tuple is then discarded. The result is the prime relation, a relation in which no attribute has more distinct values than are allowed by the attribute threshold. 2.5.3 Further Generalization If the number of tuples in the prime relation is less than the table threshold, the generalization process is complete. If not, further generalization must be accomplished. This generalization process proceeds by choosing for generalization the attribute with the most distinct values. Alternate selection criteria are discussed in Section 3. After each round of further generalization, duplicates are removed and another attribute is selected for generalization. When the total number of remaining tuples is less than or equal to the table threshold, automatic generalization ceases. If requested by the user, generalization is continued beyond the table threshold. 2.5.4 T-threshold Noise Reduction During this generalization of the prime relation to the final relation, noisy, exceptional cases may be removed from the generalized relation if a t-threshold has been specified by the user (see Section 2.2.3). In the current version, when the total number of tuples falls below twice the table threshold, all tuples with a proportion of votes less than the t-threshold are removed. 2.5.5 Discriminate Task Reduction For characteristic learning tasks, the process is complete at this point, but not for discrim- inate tasks. Two relations exist for discriminate tasks, the target and contrast relations. The purpose of the discriminate learning task is to find interesting distinctions between two sets of data. Any tuples, therefore, in the target and contrast relations that contain the same information will not contribute to this goal and must be noted. The two relations are therefore compared row for row and those which are the same are marked as non-distinct. These tuples will not be displayed in the final output. The only exception to this is if a d-threshold has been specified (see Section 2.2.3). If a d-threshold has been specified by the user, those marked tuples in the target relation that have a vote percentage higher than the threshold value are displayed with the unmarked tuples. The results of the learning procedure are stored as a pointer to the final generalized relation. This pointer may be accessed by the user through the command module for display. This concludes the overview of the architecture of DBLEARN and its methods of imple- menting the characteristic and discriminate learning algorithms. The following section will describe some possible changes to the system that might improve its design or add to its capabilities. 3 General Improvements to DBLEARN In this section, we present a set of planned improvements to DBLEARN. The improvements relate to four of the five modules. 3.1 Interface Development In general, the responsibility for display should be completely relegated to the interface modules. All output should be extracted from the other modules, and the structures built by these modules should be made available to the interfaces for specialized display. 3.1.1 Command Line Expansion As long as the command line interface remains a part of the program, some changes to the method of defining tasks should be made and some additional features should be added. The discrepancies between the discussion in the previous section and the actual implementation, which should all be updated, are not included below. Reuse of Task Results If a copy of the prime relation were kept from the completed learning task, the second stage of generalization could be repeated with different reduction strategies. Reuse of Tasks The ability to save a task definition during a session and later read that definition would be handy for repetitive activities. For example, from the command-line, one might enter: ``` save myfile ``` which would save the most recent task definition, including any applicable defaults, in the specified file. Entering ``` read myfile ``` would cause the stored task to be read from the file and executed. This would save on task entry time and would reduce the chance of error. At present, the best one can do is store the complete command-line input in a file and run DBLEARN with input from that file. 3.1.2 Graphical User Interface Development The initial needs of the graphical user interface are more tied to the structure of the command and learning modules. Currently, the learning module handles most of the individual tasks that should be handled by the command module, such as building the concept hierarchy trees and initializing the database and schemas. In addition, the learning module handles the transition from initial generalization to further generalization. These should be extracted to the command module level. This would solve the current problem of no intermediate communication between the learning module and the GUI. It would also make error correction easier for the command line interface. 3.2 Database Module The database module suffers primarily from inefficiency. Where DBMS’s automatically optimize queries, this may not be a major issue, but some DBMS’s do not do this and the results are blatantly noticeable. The primary problem is in the building of the database query. This is actually handled by the concept hierarchy module at the current time, but is included under this section since it is so database specific. 3.2.1 Better Extraction of Generalized Concepts When the user uses a high level concept to specify a subset of data to extract from the database, this is currently built into complex, inefficient queries. There should be better use of the IN function in a select statement. The high level predicate: ```sql where province = "Prairies" ``` is currently translated into something like: ```sql where province = 'Alberta' OR province = 'Saskatchewan' OR province = 'Manitoba' ``` It would be much more efficiently and easily translated into: ```sql where province in ('Alberta', 'Saskatchewan', 'Manitoba') ``` Similarly, the range value high level query: ```sql where discipline_code = "Computer" ``` is currently translated into something like: ```sql where (discipline_code >= 23000 AND discipline_code < 23500) OR (discipline_code >= 23500 AND discipline_code < 24000) OR (discipline_code >= 24000 AND discipline_code < 24500) OR (discipline_code >= 24500 AND discipline_code < 25000) ``` It would be much more efficiently translated as: ```sql where (discipline_code >= 23000 AND discipline_code < 25000) ``` Some additional information in the concept hierarchy trees would make this easier. If the lower and upper bound values of range values could be propagated up the tree as the tree is being built, then concept translation would be a simple matter. 3.2.2 Better Ordering of Joins Much more important than this though is the ordering of queries. Where multiple tables are being joined to perform a query, the tables need to be reduced in size as much as possible before the join. In one test query, reordering the table reduction before the join reduced the time necessary for the query from over 30 hours for an incomplete result to just a few minutes. The number of tuples in the query that DBLEARN built would have been over 45 million. The number in the better ordered query was about 150,000. The table reductions that can be performed before a join can be detected by the type of argument to the right side of a comparison operator. In DBLEARN syntax (and possibly in SQL), the left value of a comparison expression (such as “disc_code = computer”) is an attribute name. Where the right side are also attribute names, these expressions must be applied after a join of some sort. All other comparisons can be applied to a single table to reduce the size of that table before the join. 3.2.3 Earlier Deletion of Ungeneralizable Attributes In the current version, the initial relations are read in and then generalized. When attribute oriented generalization is being performed, if one attribute does not have a concept hierarchy defined for it, it is deleted from the tables. This involves a fair amount of computational time. This should be detected before the relations are even read in and the initial query adjusted even before the database is accessed to not even read the attribute in the first place. 3.3 Concept Hierarchy Module 3.3.1 More Conceptual Hierarchy Definition File Structure The structure of a concept hierarchy file that is similar to how we display the concept hierarchy files in text format would be powerful and easier to build. Multiple hierarchies could still be defined in the same file. The different levels of the tree could be defined by tabbing in one tab space for each level of the tree. A symbol found on a line with no tabbing would signal an attribute name and the beginning of a concept definition. Our file for province definition could look like: ``` province Western British Columbia Prairies Alberta Saskatchewan Manitoba Ontario Quebec Maritimes New Brunswick Nova Scotia Prince Edward Island Newfoundland ``` The ANY symbol is not required since every concept hierarchy has one. This would be much easier to define than the current style which is error prone and hard to understand. 3.3.2 Expansion of Range / Non-range Concepts The current definition of range values only includes numeric based attributes, but this is not conceptually as powerful as it could be. Dictionary entries and Dewey Decimal codes are examples of strings or alpha-numeric codes that have range properties. Similarly, university course numbers are numeric values but do not necessarily have the range property of inherent ordering. If this understanding is adopted, the range type concept hierarchy trees would need to be explicitly declared as such, not detected on the basis of attribute type. This would require an addition to the concept file definition structure. As mentioned above, where range values are defined for leaf nodes, it would be advantageous to propagate these values up the hierarchy tree so that every node has an upper and lower bound. This would make high level concept translation much easier. 3.4 Learning Module We have already mentioned the need to maintain a copy of the prime relation for reuse. This would allow for experimentation by the user of different further reduction strategies. The ability for the user to control the method of further generalization is also needed in the learning module. Currently the only strategy used to choose the attribute to generalize is the one with the most distinct values. Two alternate selection criteria are the highest reduction ratio and lowest reduction ratio. The attribute with the highest reduction ratio is that attribute which, when generalized one level, would cause the table to be maximally reduced in size. Conversely, the lowest reduction ratio corresponds to the least reduction in size. As well, the user should be allowed to explicitly choose an attribute for further generalization. In this case, the choices should be relayed to the user through the command module and the user’s choice returned. 4 Conclusion This paper has described DBLEARN and its architecture as it is and as it should be. The current version of DBLEARN is faster, easier to maintain, and easier to extend than the original prototype. The further reorganization of DBLEARN to match more closely the design given here should continue to increase the maintainability and extendibility of the software. As well, the suggested improvements to the implementation of DBLEARN that are given in Section 3 may further increase DBLEARN’s overall usefulness. References **Endnotes** 1. Currently, this modularity is not complete. Because DBLEARN was originally implemented for a command line interface with text screen output, much output to stdout and stderr remains scattered in the code. This needs to be extracted and handled by the user interface modules. All other modules should be rewritten to pass back data structures from their tasks. It will be the interface's responsibility to do all display in whatever form is available. This will make the task of updating the graphical user interface to handle dynamic exchange with the learning component much easier. 2. This is a documented feature of DBLEARN, but we have not verified whether or not it works in the current version. 3. A list box is a graphical box containing a list of entries, one of which may be selected by keyboard entry or a mouse click. The selected item is then entered into a special selection cell at the top of the box. A drop down list box appears at first to be just a single text cell with a down arrow to the right of it. When the arrow is clicked with a mouse, the box of entries drops down in a similar fashion to a drop down menu. When an item is selected, that item replaces the one in the selection cell and the drop down list disappears. 4. A standard list box may be single or multiple select. A single select list box allows only one entry to be selected at a time and is appropriate for a drop down style since the single selection may be displayed in the select cell that is left after the list box disappears. A multi-select list box allows as many entries to be selected as the user desires, displaying selected items in reverse video. It is more appropriate to have at least several lines of this type of list box displayed at all times, allowing the user to see which items are selected. If more items are anticipated than there is space for in the display structure, the list may be scrollable. Scrollable list boxes have a scroll bar to the right of the entries which allows the user to scroll up or down through the list in a similar fashion to scrolling through a word processing document. A pop-up version of this is a dynamically created list box which allows the selection of a number of items and then when an OK button is clicked, the list box disappears. 5. A correlation name is a short name or letter associated with a relation which replaces the name of the relation in a subsequent where clause. For example, a query might be constructed as follows: ```sql select amount, province from award, organization where award.org_code = organization.org_code ``` However, this involves more typing than the average user wants to do. Rather, correlation names 'a' and 'o' are added to the relation names award and organization and the query is rewritten: ```sql select amount, province from award a, organization o where a.org_code = o.org_code ``` which is much more efficient. 6. A push button is a simple button shaped object which initiates a single action when selected with a mouse. 7. A browsable file list is one where a lists of directories and files are separately displayed. When a directory is double clicked, its subdirectories are displayed in the directory list and the files in it are displayed in the file list. In this way the directory structure may be explored and files located easily. A multi-select version allows any number of files to be selected, though at the current time it is limited to files in the same directory. It would be useful for these files to be scanned for the individual concept hierarchies that they contain. If only one hierarchy for each target attribute that has been selected exists in the file list, then they can be automatically loaded. If there happens to be any duplicates, a choice should be given to the user of which is to be loaded. 8. Currently all attributes are presented, not just numeric ones. 9. A check box is a simple boolean selector presented as a small box in which a check appears when it is selected with a mouse. Subsequent selections toggle between checked and unchecked states. 10. A text entry box is a simple boxed area of the screen which when clicked allows editable text entry. 11. The concept hierarchies should be built and database query initialized as soon as the information for them is defined. This would allow for better error checking and correction. 12. The entry of the result into the text window is actually accomplished by a dirty patch. The window structures are not configurable to be able to receive input from stdout, but the DBLEARN currently sends all of its output to stdout. To get around this, stdout is redirected to a file and then when the learning task was finished, that file is read into the text window. 13. These features are not implemented yet, though the menu items for them are available. The methods available for the edit window object include saving and printing the contents of the text area, so the functions would be easily added. 14. Structure returns are not currently implemented. In the present version, the functions themselves are geared to the yacc interface and will simply print the information directly to the output stream. However, if the general concept is followed of requesting information and receiving back a structure that is then passed to whatever user interface is available, this will make dynamic exchanges between various interfaces much more distinct, and the user interfaces more modular. The individual user interfaces themselves would be fully responsible for all display and output issues. 15. The relations themselves are not retrieved at this point even though the current version retrieves the complete relation before generalization. Rather, the learning module is given the direct ability to retrieve the data one tuple at a time. This will facilitate the implementation of “on the fly” generalization at a later time. 16. The query building phase is currently handled by the learning module after the complete task has been defined. This needs to be extracted since the input to a learning task is not the information to build a relation for generalization, but the relation itself. This extraction would enable better error handling and less need for re-entry of information from the command line interface especially. When the query of the current yacc interface fails, the whole task must be retyped. 17. These functions are currently not handled by the command module, but by the learning module which directs all the loading of concept hierarchies and translation of high level concept to low level attribute values. These should be extracted from the learning module as they are not inherently part of the learning task, but one of the input elements to them. 18. We have not yet examined this function in adjust.c to determine how it works or what it really does. It is mentioned in [Huang and Cai, 1993]. 19. The current version also contains a function for controlling output level. The “set demo 1” command will cause the output of intermediate information in various stages of the generalization process. This is needed since different tasks handle their own output of information. With this more modular design, however, the user interface is responsible for all display of information and has access to all the intermediate information that is normally printed out as part of the expanded output function. The output of more information is therefore a unitary function of the interface and not DBLEARN as a whole. As such, the output level can be set and handled by the interface alone without the command module’s intervention. Similarly, two titles are assigned to the target and contrast relations. These are simply descriptive names to be used in the display of the results of generalization, and fall under the same type of category as the “demo” flag. These also can be handled by the interface module. 20. Currently the learning procedure takes the learning process from start to finish. We propose to divide this into two parts, the initial generalization to the prime relation where every attribute has been reduced to below the attribute threshold, and an iterative further generalization where the prime relation is reduced to more and more generalized states until the final generalized relation is obtained. This will allow the necessary communication between the learning module and the user interface, especially the graphical user interface which cannot (and should not) be accessed from any module except the command module. Since the present version assumes the availability of stdout, the learning module handles its own interaction with the user, but this violates the modularity that we are trying to build into the system. 21. Two variables in the current version, minor and major, correspond to the t-threshold and d-threshold described by Han et al. ([Han et al., 1993], p. 37). These, however, are not settable except by hard coding a value into them. The variable minor is used for pruning low vote tuples, but major is not used at all. 22. Currently no provision is included for d-thresholds. Only those tuples which represent 100% of examples are included in the final generalized relation for discriminate tasks. 23. In the current version, the prop votes amount is actually calculated dynamically when the relation is printed out by simply dividing the vote amount by the total number of original tuples in the relation. This is a function beyond the scope of just printing a relation and might conceptually perhaps be better left to the generalization process which could set a field in a tuple structure to a percentage value. 24. Errors might be defined as fatal occurrences that will not allow the generalization process to proceed. This could be like a loss of database connection. A warning would signal a non-fatal but unusual occurrence that the user should be aware of. This might be like a value being encountered in the initial relation for which there is no concept hierarchy defined. A strategy for responding to this condition must be devised. One possibility to signal these types of errors would be to build a linked list of return structures that note each exceptional non-fatal occurrence. The tuple that contained the condition could then just be ignored for the time being. 25. A variable could be set that specifies the further reduction to proceed immediately using a particular predefined reduction method. This would allow the whole task to be unitary instead of iteratively interactive. 26. A help command is documented in the yacc version, but it doesn’t do anything. 27. There are other more complex issues involved here concerning client / server connections and multiple DBMS access. The current version, however, has not addressed these issues. 28. This of course could be more efficiently be represented as: where discipline_code >= 23000 and discipline_code < 25000 but this is not done in the current version. Some database optimization ideas will be presented in Section 3. 29. Currently no error checking is done. 30. It would be much more efficient to perform generalization on the fly as tuples are read in. 31. D-thresholds are not implemented in the current version. 32. This code is actually commented out right now.
{"Source-Url": "http://www.cs.uregina.ca/Research/Techreports/9404.pdf", "len_cl100k_base": 13674, "olmocr-version": "0.1.50", "pdf-total-pages": 27, "total-fallback-pages": 0, "total-input-tokens": 61095, "total-output-tokens": 15341, "length": "2e13", "weborganizer": {"__label__adult": 0.00027680397033691406, "__label__art_design": 0.0003712177276611328, "__label__crime_law": 0.00026988983154296875, "__label__education_jobs": 0.006195068359375, "__label__entertainment": 7.486343383789062e-05, "__label__fashion_beauty": 0.00014853477478027344, "__label__finance_business": 0.00027680397033691406, "__label__food_dining": 0.0003044605255126953, "__label__games": 0.0006833076477050781, "__label__hardware": 0.0008950233459472656, "__label__health": 0.0002446174621582031, "__label__history": 0.0002498626708984375, "__label__home_hobbies": 0.00011414289474487303, "__label__industrial": 0.0003845691680908203, "__label__literature": 0.00028252601623535156, "__label__politics": 0.0001914501190185547, "__label__religion": 0.0003917217254638672, "__label__science_tech": 0.0185699462890625, "__label__social_life": 0.00011754035949707033, "__label__software": 0.0262298583984375, "__label__software_dev": 0.94287109375, "__label__sports_fitness": 0.00018453598022460935, "__label__transportation": 0.00037384033203125, "__label__travel": 0.00018799304962158203}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 71835, 0.01766]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 71835, 0.80027]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 71835, 0.91585]], "google_gemma-3-12b-it_contains_pii": [[0, 2119, false], [2119, 5934, null], [5934, 7118, null], [7118, 9443, null], [9443, 12822, null], [12822, 16146, null], [16146, 19589, null], [19589, 21885, null], [21885, 25176, null], [25176, 28673, null], [28673, 31189, null], [31189, 34783, null], [34783, 37091, null], [37091, 40417, null], [40417, 42993, null], [42993, 46195, null], [46195, 48241, null], [48241, 50693, null], [50693, 53015, null], [53015, 55426, null], [55426, 57611, null], [57611, 60149, null], [60149, 63110, null], [63110, 65769, null], [65769, 69038, null], [69038, 71723, null], [71723, 71835, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2119, true], [2119, 5934, null], [5934, 7118, null], [7118, 9443, null], [9443, 12822, null], [12822, 16146, null], [16146, 19589, null], [19589, 21885, null], [21885, 25176, null], [25176, 28673, null], [28673, 31189, null], [31189, 34783, null], [34783, 37091, null], [37091, 40417, null], [40417, 42993, null], [42993, 46195, null], [46195, 48241, null], [48241, 50693, null], [50693, 53015, null], [53015, 55426, null], [55426, 57611, null], [57611, 60149, null], [60149, 63110, null], [63110, 65769, null], [65769, 69038, null], [69038, 71723, null], [71723, 71835, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 71835, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 71835, null]], "pdf_page_numbers": [[0, 2119, 1], [2119, 5934, 2], [5934, 7118, 3], [7118, 9443, 4], [9443, 12822, 5], [12822, 16146, 6], [16146, 19589, 7], [19589, 21885, 8], [21885, 25176, 9], [25176, 28673, 10], [28673, 31189, 11], [31189, 34783, 12], [34783, 37091, 13], [37091, 40417, 14], [40417, 42993, 15], [42993, 46195, 16], [46195, 48241, 17], [48241, 50693, 18], [50693, 53015, 19], [53015, 55426, 20], [55426, 57611, 21], [57611, 60149, 22], [60149, 63110, 23], [63110, 65769, 24], [65769, 69038, 25], [69038, 71723, 26], [71723, 71835, 27]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 71835, 0.0]]}
olmocr_science_pdfs
2024-11-29
2024-11-29
fcc92eda54ba0c203ca17cfebaca1a1c0ae84f34
Web Services Make Connection (WS-MakeConnection) Version 1.1 Committee Specification 02 29 November 2008 Specification URIs: This Version: http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.1-spec-cs-02.html http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.1-spec-cs-02.doc (Authoritative) Previous Version: http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.1-spec-cd-02.html http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.1-spec-cd-02.doc (Authoritative) Latest Version: http://docs.oasis-open.org/ws-rx/wsmc/v1.1/wsmc.html http://docs.oasis-open.org/ws-rx/wsmc/v1.1/wsmc.doc Technical Committee: OASIS Web Services Reliable Exchange (WS-RX) TC Chairs: Paul Fremantle <paul@wso2.com> Sanjay Patil <sanjay.patil@sap.com> Editors: Doug Davis, IBM <dug@us.ibm.com> Anish Karmarkar, Oracle <Anish.Karmarkar@oracle.com> Gilbert Pilz, BEA <gpilz@bea.com> Steve Winkler, SAP <steve.winkler@sap.com> Ümit Yalçinalp, SAP <umit.yalcinalp@sap.com> Related Work: This specification replaces or supercedes: - WS-MakeConnection v1.0 Declared XML Namespaces: http://docs.oasis-open.org/ws-rx/wsmc/200702 Abstract: This specification (WS-MakeConnection) describes a protocol that allows messages to be transferred between nodes implementing this protocol by using a transport-specific back-channel. The protocol is described in this specification in a transport-independent manner allowing it to be implemented using different network technologies. To support interoperable Web services, a SOAP binding is defined within this specification. The protocol defined in this specification depends upon other Web services specifications for the detailed within those specifications and are out of scope for this document. By using the XML [XML], SOAP [SOAP 1.1], [SOAP 1.2] and WSDL [WSDL 1.1] extensibility model, SOAP-based and WSDL-based specifications are designed to be composed with each other to define a rich Web services environment. As such, WS-MakeConnection by itself does not define all the features required for a complete messaging solution. WS-MakeConnection is a building block that is used in conjunction with other specifications and application-specific protocols to accommodate a wide variety of requirements and scenarios related to the operation of distributed Web services. **Status:** This document was last revised or approved by the WS-RX Technical Committee on the above date. The level of approval is also listed above. Check the "Latest Version" or "Latest Approved Version" location noted above for possible later revisions of this document. Technical Committee members should send comments on this specification to the Technical Committee's email list. Others should send comments to the Technical Committee by using the "Send A Comment" button on the Technical Committee's web page at http://www.oasis- open.org/committees/ws-rx/. For information on whether any patents have been disclosed that may be essential to implementing this specification, and any offers of patent licensing terms, please refer to the Intellectual Property Rights section of the Technical Committee web page (http://www.oasis-open.org/committees/ws- rx/ipr.php). The non-normative errata page for this specification is located at http://www.oasis- open.org/committees/ws-rx/. Notices All capitalized terms in the following text have the meanings assigned to them in the OASIS Intellectual Property Rights Policy (the "OASIS IPR Policy"). The full Policy may be found at the OASIS website. This document and translations of it may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to OASIS, except as needed for the purpose of developing any document or deliverable produced by an OASIS Technical Committee (in which case the rules applicable to copyrights, as set forth in the OASIS IPR Policy, must be followed) or as required to translate it into languages other than English. The limited permissions granted above are perpetual and will not be revoked by OASIS or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and OASIS DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. OASIS requests that any OASIS Party or any other party that believes it has patent claims that would necessarily be infringed by implementations of this OASIS Committee Specification or OASIS Standard, to notify OASIS TC Administrator and provide an indication of its willingness to grant patent licenses to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this specification. OASIS invites any party to contact the OASIS TC Administrator if it is aware of a claim of ownership of any patent claims that would necessarily be infringed by implementations of this specification by a patent holder that is not willing to provide a license to such patent claims in a manner consistent with the IPR Mode of the OASIS Technical Committee that produced this specification. OASIS may include such claims on its website, but disclaims any obligation to do so. OASIS takes no position regarding the validity or scope of any intellectual property or other rights that might be claimed to pertain to the implementation or use of the technology described in this document or the extent to which any license under such rights might or might not be available; neither does it represent that it has made any effort to identify any such rights. Information on OASIS’ procedures with respect to rights in any document or deliverable produced by an OASIS Technical Committee can be found on the OASIS website. Copies of claims of rights made available for publication and any assurances of licenses to be made available, or the result of an attempt made to obtain a general license or permission for the use of such proprietary rights by implementers or users of this OASIS Committee Specification or OASIS Standard, can be obtained from the OASIS TC Administrator. OASIS makes no representation that any information or list of intellectual property rights will at any time be complete, or that any claims in such list are, in fact, Essential Claims. The name "OASIS", WS-MakeConnection, WSMC, WSRM, WS-RX are trademarks of OASIS, the owner and developer of this specification, and should be used only to refer to the organization and its official outputs. OASIS welcomes reference to, and implementation and use of, specifications, while reserving the right to enforce its marks against misleading uses. Please see http://www.oasis-open.org/who/trademark.php for above guidance. Table of Contents 110 1 Introduction ......................................................................................................................... 5 111 1.1 Terminology ...................................................................................................................... 5 112 1.2 Normative .......................................................................................................................... 6 113 1.3 Non-Normative .................................................................................................................. 6 114 1.4 Namespace ....................................................................................................................... 7 115 1.5 Conformance .................................................................................................................... 8 116 2 MakeConnection Model ....................................................................................................... 9 117 2.1 Glossary ........................................................................................................................... 10 118 2.2 Protocol Preconditions ..................................................................................................... 10 119 2.3 Example Message Exchange ............................................................................................ 10 120 3 MakeConnection .................................................................................................................. 13 121 3.1 MakeConnection Anonymous URI ..................................................................................... 13 122 3.2 MakeConnection Message ............................................................................................... 13 123 3.3 MessagePending ............................................................................................................... 15 124 3.4 MakeConnection Policy Assertion ..................................................................................... 15 125 4 Faults ................................................................................................................................... 17 126 4.1 Unsupported Selection ..................................................................................................... 18 127 4.2 Missing Selection ............................................................................................................. 18 128 5 Security Considerations ...................................................................................................... 20 129 Appendix A. Schema ........................................................................................................... 21 130 Appendix B. WSDL ................................................................................................................ 22 131 Appendix C. Message Examples ............................................................................................. 23 132 Appendix C.1 Example use of MakeConnection .................................................................... 23 133 Appendix D. Acknowledgments .............................................................................................. 27 1 Introduction The primary goal of this specification is to create a mechanism for the transfer of messages between two endpoints when the sending endpoint is unable to initiate a new connection to the receiving endpoint. It defines a mechanism to uniquely identify non-addressable endpoints, and a mechanism by which messages destined for those endpoints can be delivered. It also defines a SOAP binding that is required for interoperability. Additional bindings can be defined. This mechanism is extensible allowing additional functionality, such as security, to be tightly integrated. This specification integrates with and complements the WS-ReliableMessaging[WS-RM], WS-Security [WS-Security], WS-Policy [WS-Policy], and other Web services specifications. Combined, these allow for a broad range of reliable, secure messaging options. 1.1 Terminology The keywords "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [KEYWORDS]. This specification uses the following syntax to define normative outlines for messages: - The syntax appears as an XML instance, but values in italics indicate data types instead of values. - Characters are appended to elements and attributes to indicate cardinality: - "?" (0 or 1) - "*" (0 or more) - "+" (1 or more) - The character "]" is used to indicate a choice between alternatives. - The characters "[" and "]" are used to indicate that contained items are to be treated as a group with respect to cardinality or choice. - An ellipsis (i.e. "...") indicates a point of extensibility that allows other child or attribute content specified in this document. Additional children elements and/or attributes MAY be added at the indicated extension points but they MUST NOT contradict the semantics of the parent and/or owner, respectively. If an extension is not recognized it SHOULD be ignored. - XML namespace prefixes (see section 1.4) are used to indicate the namespace of the element being defined. Elements and Attributes defined by this specification are referred to in the text of this document using XPath 1.0 [XPATH 1.0] expressions. Extensibility points are referred to using an extended version of this syntax: - An element extensibility point is referred to using {any} in place of the element name. This indicates that any element name can be used, from any namespace other than the wsmc: namespace. - An attribute extensibility point is referred to using @{any} in place of the attribute name. This indicates that any attribute name can be used, from any namespace other than the wsmc: namespace. 1.2 Normative http://www.ietf.org/rfc/rfc2119.txt http://www.w3.org/TR/2000/NOTE-SOAP-20000508/ http://www.w3.org/TR/2003/REC-soap12-part1-20030624/ http://ietf.org/rfc/rfc3986 http://www.ietf.org/rfc/rfc4122.txt http://www.w3.org/TR/2001/NOTE-wsdl-20010315 http://www.w3.org/TR/2006/REC-ws-addr-core-20060509/ http://www.w3.org/TR/2006/REC-ws-addr-soap-20060509/ http://docs.oasis-open.org/ws-rx/wsrp/200702/wsrp-1.2-spec-cs-02.doc http://docs.oasis-open.org/ws-rx/wsrmp/200702/wsrmp-1.2-spec-cs-02.doc http://www.w3.org/TR/REC-xml/ http://www.w3.org/TR/1999/REC-xml-names-19990114/ http://www.w3.org/TR/xmlschema-1/ http://www.w3.org/TR/xmlschema-2/ http://www.w3.org/TR/xpath 1.3 Non-Normative http://www.openhealth.org/RDDL/20040118/rddl-20040118.html 1.4 Namespace The XML namespace [XML-ns] URI that MUST be used by implementations of this specification is: ``` http://docs.oasis-open.org/ws-rx/wsmc/200702 ``` Dereferencing the above URI will produce the Resource Directory Description Language [RDDL 2.0] document that describes this namespace. Table 1 lists the XML namespaces that are used in this specification. The choice of any namespace prefix is arbitrary and not semantically significant. <table> <thead> <tr> <th>Prefix</th> <th>Namespace</th> </tr> </thead> <tbody> <tr> <td>S</td> <td>(Either SOAP 1.1 or 1.2)</td> </tr> <tr> <td>S11</td> <td><a href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a></td> </tr> <tr> <td>S12</td> <td><a href="http://www.w3.org/2003/05/soap-envelope">http://www.w3.org/2003/05/soap-envelope</a></td> </tr> <tr> <td>wsmc</td> <td><a href="http://docs.oasis-open.org/ws-rx/wsmc/200702">http://docs.oasis-open.org/ws-rx/wsmc/200702</a></td> </tr> <tr> <td>wsrnm</td> <td><a href="http://docs.oasis-open.org/ws-rx/wsrnm/200702">http://docs.oasis-open.org/ws-rx/wsrnm/200702</a></td> </tr> <tr> <td>wsa</td> <td><a href="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing</a></td> </tr> <tr> <td>wsam</td> <td><a href="http://www.w3.org/2007/05/addressing/metadata">http://www.w3.org/2007/05/addressing/metadata</a></td> </tr> <tr> <td>wsp</td> <td><a href="http://www.w3.org/ns/ws-policy">http://www.w3.org/ns/ws-policy</a></td> </tr> </tbody> </table> The normative schema for WS-MakeConnection can be found linked from the namespace document that is located at the namespace URI specified above. All sections explicitly noted as examples are informational and are not to be considered normative. 1.5 Conformance An implementation is not conformant with this specification if it fails to satisfy one or more of the MUST or REQUIRED level requirements defined herein. A SOAP Node MUST NOT use the XML namespace identifier for this specification (listed in section 1.4) within SOAP Envelopes unless it is conformant with this specification. Normative text within this specification takes precedence over normative outlines, which in turn take precedence over the XML Schema [XML Schema Part 1, Part 2] descriptions. 2 MakeConnection Model The WS-Addressing [WS-Addressing] specification defines the anonymous URI to identify non-addressable endpoints and to indicate a protocol-specific back-channel is to be used for any messages destined for that endpoint. For example, when used in the WS-Addressing ReplyTo EPR, the use of this anonymous URI is meant to indicate that any response message is to be transmitted on the transport-specific back-channel. In the HTTP case this would mean that any response message is sent back on the HTTP response flow. In cases where the connection is still available the WS-Addressing URI is sufficient. However, in cases where the original connection is no longer available, additional mechanisms are needed. Take the situation where the original connection that carried a request message is broken and therefore is no longer available to carry a response back to the original sender. Traditionally, non-anonymous (addressable) EPRs would be used in these cases to allow for the sender of the response message to initiate new connections as needed. However, if the sender of the request message is unable (or unwilling) to accept new connections then the only option available is for it to establish a new connection for the purposes of allowing the response message to be sent. This specification defines a mechanism by which a new connection can be established. The MakeConnection model consists of two key aspects: - An optional anonymous-like URI template is defined that has similar semantics to WS-Addressing's anonymous, but also allows for each non-addressable endpoint to be uniquely identified - A new message is defined that establishes a connection that can then be used to transmit messages to these non-addressable endpoints Figure 1 below illustrates the overall flow involved in the use of MakeConnection: ``` Non-Addressable Endpoint (MC Initiator) Make Connection Protocol | | Addressable Endpoint | | (MC Receiver) Establish Protocol Preconditions Optional sharing of MC-Anonymous EPR MakeConnection( Connection Identifying Parameters ) Message destined for the Non-Addressable Endpoint ``` The MakeConnection message is used to establish a new connection between the two endpoints. Within the message is identifying information that is used to uniquely identify a message that is eligible for transmission. 2.1 Glossary The following definitions are used throughout this specification: **Back-channel:** When the underlying transport provides a mechanism to return a transport-protocol specific response, capable of carrying a SOAP message, without initiating a new connection, this specification refers to this mechanism as a back-channel. **Endpoint:** As defined in the WS-Addressing specification; a Web service Endpoint is a (referenceable) entity, processor, or resource to which Web service messages can be addressed. Endpoint references (EPRs) convey the information needed to address a Web service Endpoint. **MC Initiator** The endpoint that transmits the `MakeConnection` message – the destination endpoint for the messages being sent on the transport-specific back-channel. **MC Receiver:** The endpoint that receives the `MakeConnection` message – the source endpoint for the messages being sent on the transport-specific back-channel. **Receive:** The act of reading a message from a network connection. **Transmit:** The act of writing a message to a network connection. 2.2 Protocol Preconditions The correct operation of the protocol requires that a number of preconditions MUST be established prior to the processing of the initial sequenced message: - The MC Receiver MUST be capable of accepting new incoming connections. - The MC Initiator MUST be capable of creating new outgoing connections to the MC Receiver, and those connections MUST have a back-channel. - If a secure exchange of messages is REQUIRED, then the MC Initiator and MC Receiver MUST have a security context. 2.3 Example Message Exchange Figure 2 illustrates a message exchange in which the response message is delivered using `MakeConnection`. 1. The protocol preconditions are established. These include policy exchange, endpoint resolution, and establishing trust. 2. The client (MC Initiator) sends a GetQuote request message to the service (MC Receiver). The WS-Addressing wsa:ReplyTo EPR uses the MakeConnection Anonymous URI Template – indicating that if the GetQuoteResponse message is not sent back on this connection’s back-channel, then the client will use MakeConnection to retrieve it. 3. The service receives the request message and decides to close the connection by sending back an empty response (in the HTTP case an HTTP 202 Accept is sent). 4. The client sends a MakeConnection message to the service. Within the MakeConnection element is the wsmc:Address element containing the same MakeConnection Anonymous URI used in step 2. 5. The service has not completed executing the GetQuote operation and decides to close the connection by sending back an empty response (in the HTTP case an HTTP 202 Accept) indicating that no messages destined for this MC Initiator are available at this time. 6. The client sends a second MakeConnection message to the service. Within the MakeConnection element is the wsmc:Address element containing the same MakeConnection Anonymous URI used in step 2. 7. The service uses this new connection to transmit the GetQuoteResponse message. 348 dynamically adjust re-transmission time and the back-off intervals that are appropriate to the nature of the 349 transports and intermediaries envisioned. For the case of TCP/IP transports, a mechanism similar to that 350 described as RTTM in RFC 1323 [RTTM] SHOULD be considered. 351 Now that the basic model has been outlined, the details of this protocol are now provided in section 3. 3 MakeConnection The following sub-sections define the various MakeConnection features, and prescribe their usage by a conformant implementations. 3.1 MakeConnection Anonymous URI When an Endpoint is not directly addressable (e.g. behind a firewall or not able to allow incoming connections), an anonymous URI in the EPR address property can indicate such an Endpoint. The WS-Addressing anonymous URI is one such anonymous URI. This specification defines a URI template (the WS-MC anonymous URI) which may be used to uniquely identify anonymous Endpoints. http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id={unique-String} The appearance of an instance of this URI template in the wsa:Address value of an EPR indicates a protocol-specific back-channel will be established through a mechanism such as MakeConnection, defined below. When using this URI template, "{unique-String}" MUST be replaced by a globally unique string (e.g a UUID value as defined by RFC4122 [UUID]). This specification does not require the use of one particular string generation scheme. This string uniquely distinguishes the Endpoint. A sending Endpoint SHOULD Transmit messages at Endpoints identified with the URI template using a protocol-specific back-channel, including but not limited to those established with a MakeConnection message. Note, this URI template is semantically similar to the WS-Addressing anonymous URI if a protocol-specific back-channel is available. 3.2 MakeConnection Message The MakeConnection element is sent in the body of a one-way message that establishes a contextualized back-channel for the transmission of messages according to matching criteria (defined below). In the non-faulting case, if no matching message is available then no SOAP envelope will be returned on the back-channel. A common usage will be a client sending MakeConnection to a server for the purpose of receiving asynchronous response messages. When the MC protocol is composed with the WS-Addressing specification, the value of the wsa:Action header would be: http://docs.oasis-open.org/ws-rx/wsmc/200702/MakeConnection The following exemplar defines the MakeConnection syntax: <wsmc:MakeConnection ...> <wsmc:Address ...> xs:anyURI </wsmc:Address> ? <wsrm:Identifier ...> xs:anyURI </wsrm:Identifier> ? ... </wsmc:MakeConnection> The following describes the content model of the MakeConnection element. /wsmc:MakeConnection This element allows the sender to create a transport-specific back-channel that can be used to return a message that matches the selection criteria. Endpoints MUST NOT send this element as a header block. At least one selection criteria sub-element MUST be specified – if not a MissingSelection fault MUST be generated. This element specifies the URI (wsa:Address) of the initiating Endpoint. Endpoints MUST NOT return messages on the transport-specific back-channel unless they have been addressed to this URI. This Address property and a message’s WS-Addressing destination property are considered identical when they are exactly the same character-for-character. Note that URIs which are not identical in this sense may in fact be functionally equivalent. Examples include URI references which differ only in case, or which are in external entities which have different effective base URIs. /wsmc:MakeConnection/wsmc:Address/@{any} This is an extensibility mechanism to allow additional attributes, based on schemas, to be added to the element. /wsmc:MakeConnection/wsrm:Identifier This element specifies the WS-RM Sequence Identifier that establishes the context for the transport-specific back-channel. The Sequence Identifier should be compared with the Sequence Identifiers associated with the messages held by the sending Endpoint, and if there is a matching message it will be returned. /wsmc:MakeConnection/wsrm:Identifier/@{any} This is an extensibility mechanism to allow additional attributes, based on schemas, to be added to the element. /wsmc:MakeConnection/{any} This is an extensibility mechanism to allow different (extensible) types of information, based on a schema, to be passed. This allows fine-tuning of the messages to be returned, additional selection criteria included here are logically ANDed with the Address and/or wsrm:Identifier. If an extension is not supported by the Endpoint then it should generate an UnsupportedSelection fault. /wsmc:MakeConnection/@{any} This is an extensibility mechanism to allow additional attributes, based on schemas, to be added to the element. If more than one selection criteria element is present, then the MC Receiver processing the MakeConnection message MUST insure that any SOAP Envelope flowing on the back-channel satisfies all of those selection criteria. The management of messages that are awaiting the establishment of a back-channel to their receiving Endpoint is an implementation detail that is outside the scope of this specification. Note, however, that these messages form a class of asynchronous messages that is not dissimilar from “ordinary” asynchronous messages that are waiting for the establishment of a connection to their destinationEndpoints. This specification places no constraint on the types of messages that can be returned on the transport-specific back-channel. As in an asynchronous environment, it is up to the recipient of the MakeConnection message to decide which messages are appropriate for transmission to any particular Endpoint. However, the Endpoint processing the MakeConnection message MUST insure that the messages match the selection criteria as specified by the child elements of the MakeConnection element. Since the message exchange pattern use by MakeConnection is untraditional, the following points need to be reiterated for clarification: - The MakeConnection message is logically part of a one-way operation; there is no reply message to the MakeConnection itself, and any response flowing on the transport back-channel is a pending message. Since there is no reply message to MakeConnection, the WS-Addressing specific rules in section 3.4 "Formulating a Reply Message" are not used. Therefore, the value of any wsa:ReplyTo element in the MakeConnection message has no effective impact since the WS-Addressing [reply endpoint] property that is set by the presence of wsa:ReplyTo is not used. - In the absence of any pending message, there will be no message transmitted on the transport back-channel. E.g. in the HTTP case just an HTTP 202 Accepted will be returned without any SOAP envelope in the HTTP response message. - When there is a message pending, it is sent on the transport back-channel, using the connection that has been initiated by the MakeConnection request. ### 3.3 MessagePending When MakeConnection is used, and a message is returned on the transport-specific back-channel, the MessagePending header SHOULD be included on the returned message as an indicator whether there are additional messages waiting to be retrieved using the same selection criteria that was specified in the MakeConnection element. The following exemplar defines the MessagePending syntax: ```xml <wsmc:MessagePending pending="xs:boolean" ...> ... </wsmc:MessagePending> ``` The following describes the content model of the MessagePending header block. - This element indicates whether additional messages are waiting to be retrieved. - This attribute, when set to "true", indicates that there is at least one message waiting to be retrieved. When this attribute is set to "false" it indicates there are currently no messages waiting to be retrieved. - This is an extensibility mechanism to allow different (extensible) types of information, based on a schema, to be passed. - This is an extensibility mechanism to allow additional attributes, based on schemas, to be added to the element. The absence of the MessagePending header has no implication as to whether there are additional messages waiting to be retrieved. ### 3.4 MakeConnection Policy Assertion The MakeConnection policy assertion indicates that the MakeConnection protocol (operation and the use of the MakeConnection URI template in EndpointReferences) is required for messages sent from this endpoint. This assertion has Endpoint Policy Subject [WS-PolicyAttachment]. The normative outline for the MakeConnection assertion is: ```xml <wsmc:MCSupported ...> ... </wsmc:MCSupported> ``` The following describes the content model of the `MCSupported` element. ``` /wsmc:MCSupported A policy assertion that specifies that the MakeConnection protocol is required for messages sent from this endpoint. /wsmc:MCSupported/{any} This is an extensibility mechanism to allow different (extensible) types of information, based on a schema, to be passed. /wsmc:MCSupported/@{any} This is an extensibility mechanism to allow additional attributes, based on schemas, to be added to the element. ``` 4 Faults Entities that generate WS-MakeConnection faults MUST include as the [action] property the default fault action IRI defined below. The value from the W3C Recommendation is below for informational purposes: ``` http://docs.oasis-open.org/ws-rx/wsmc/200702/fault ``` The faults defined in this section are generated if the condition stated in the preamble is met. Fault handling rules are defined in section 6 of WS-Addressing SOAP Binding. The definitions of faults use the following properties: - [Code] The fault code. - [Subcode] The fault subcode. - [Detail] The detail element(s). If absent, no detail element is defined for the fault. If more than one detail element is defined for a fault, implementations MUST include the elements in the order that they are specified. Entities that generate WS-MakeConnection faults MUST set the [Code] property to either "Sender" or "Receiver". These properties are serialized into text XML as follows: <table> <thead> <tr> <th>SOAP Version</th> <th>Sender</th> <th>Receiver</th> </tr> </thead> <tbody> <tr> <td>SOAP 1.1</td> <td>S11:Client</td> <td>S11:Server</td> </tr> <tr> <td>SOAP 1.2</td> <td>S:Sender</td> <td>S:Receiver</td> </tr> </tbody> </table> The properties above bind to a SOAP 1.2 fault as follows: ``` <S:Envelope> <S:Header> <wsa:Action> http://docs.oasis-open.org/ws-rx/wsmc/200702/fault </wsa:Action> <!-- Headers elided for brevity. --> </S:Header> <S:Body> <S:Fault> <S:Code> <S:Value>[Code]</S:Value> <S:Subcode> <S:Value>[Subcode]</S:Value> </S:Subcode> </S:Code> <S:Reason> <S:Text xml:lang="en">[Reason]</S:Text> </S:Reason> <S:Detail> [Detail] </S:Detail> ... </S:Fault> </S:Body> </S:Envelope> ``` The properties bind to a SOAP 1.1 fault as follows when the fault is generated as a result of processing a MakeConnection message: ``` <S:Envelope> <S:Header> <wsa:Action> http://docs.oasis-open.org/ws-rx/wsmc/200702/fault </wsa:Action> ``` ```xml </S:Header> </S:Body> </S:Envelope> ``` 4.1 Unsupported Selection The QName of the unsupported element(s) are included in the detail. Properties: [Code] Receiver [Subcode] wsmc:UnsupportedSelection [Reason] The extension element used in the message selection is not supported by the MakeConnection receiver [Detail] 546 | wsmc UnsupportedSelection> xs:QName </wsmc:UnsupportedSelection>+ | <table> <thead> <tr> <th>Generated by</th> <th>Condition</th> <th>Action Upon Generation</th> <th>Action Upon Receipt</th> </tr> </thead> <tbody> <tr> <td>MakeConnection receiver</td> <td>In response to a MakeConnection message containing a selection criteria in the extensibility section of the message that is not supported</td> <td>Unspecified.</td> <td>Unspecified.</td> </tr> </tbody> </table> 4.2 Missing Selection The MakeConnection element did not contain any selection criteria. Properties: [Code] Receiver [Subcode] wsmc:MissingSelection [Reason] The MakeConnection element did not contain any selection criteria. [Detail] <table> <thead> <tr> <th>Generated by</th> <th>Condition</th> <th>Action Upon Generation</th> <th>Action Upon Receipt</th> </tr> </thead> <tbody> <tr> <td>MakeConnection receiver</td> <td>In response to a MakeConnection message containing a selection criteria in the extensibility section of the message that is not supported</td> <td>Unspecified.</td> <td>Unspecified.</td> </tr> <tr> <td>Generated by</td> <td>Condition</td> <td>Action Upon Generation</td> <td>Action Upon Receipt</td> </tr> <tr> <td>----------------------</td> <td>----------------------------------------------------------------------------</td> <td>------------------------</td> <td>---------------------</td> </tr> <tr> <td>MakeConnection</td> <td>In response to a MakeConnection message that does not contain any selection criteria</td> <td>Unspecified.</td> <td>Unspecified.</td> </tr> </tbody> </table> 5 Security Considerations It is strongly RECOMMENDED that the communication between Web services be secured using the mechanisms described in WS-Security. In order to properly secure messages, the body and all relevant headers need to be included in the signature. Specifically, any standard messaging headers, such as those from WS-Addressing, need to be signed with the body in order to "bind" the two together. Different security mechanisms may be desired depending on the frequency of messages. For example, for infrequent messages, public key technologies may be adequate for integrity and confidentiality. However, for high-frequency events, it may be more performant to establish a security context for the events using the mechanisms described in WS-Trust [Trust] and WS-SecureConversation [SecureConversation]. It should be noted that if a shared secret is used it is RECOMMENDED that derived keys be used to strengthen the secret as described in WS-SecureConversation. Requests for messages which are not available to anonymous parties are strongly RECOMMENDED to require usage of WS-Security so that the requestor can be authenticated and authorized to access the indicated messages. Similarly, integrity and confidentiality SHOULD be used whenever messages have restricted access. Recipients of messages are RECOMMENDED to validate the signature to authenticate and verify the integrity of the data. Specifically, recipients SHOULD verify that the sender has the right to "speak" for the message. The following list summarizes common classes of attacks that apply to this protocol and identifies the mechanism to prevent/mitigate the attacks: - Message alteration - Alteration is prevented by including signatures of the message information using WS-Security. - Message disclosure - Confidentiality is preserved by encrypting sensitive data using WS-Security. - Key integrity - Key integrity is maintained by using the strongest algorithms possible (by comparing secured policies - see WS-Policy and WS-SecurityPolicy [SecurityPolicy]). - Authentication - Authentication is established using the mechanisms described in WS-Security and WS-Trust. Each message is authenticated using the mechanisms described in WS-Security. - Accountability - Accountability is a function of the type of and strength of the key and algorithms being used. In many cases, a strong symmetric key provides sufficient accountability. However, in some environments, strong PKI signatures are required. - Availability - All reliable messaging services are subject to a variety of availability attacks. Replay detection is a common attack and it is RECOMMENDED that this be addressed by the mechanisms described in WS-Security. Other attacks, such as network-level denial of service attacks are harder to avoid and are outside the scope of this specification. That said, care should be taken to ensure that minimal state is saved prior to any authenticating sequences. - Replay - Messages may be replayed for a variety of reasons. To detect and eliminate this attack, mechanisms should be used to identify replayed messages such as the timestamp/nonce outlined in WS-Security. Alternatively, and optionally, other technologies, such as sequencing, can also be used to prevent replay of application messages. Service endpoints SHOULD scope its searching of messages to those that were processed under the same security context as the requesting MakeConnection message. Appendix A. Schema The normative schema that is defined for WS-MakeConnection using [XML-Schema Part1] and [XML- Schema Part2] is located at: http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.1-schema-200702.xsd The following copy is provided for reference. ```xml <?xml version="1.0" encoding="UTF-8"?> <!-- Copyright (C) OASIS (R) 1993-2007. All Rights Reserved. OASIS trademark, IPR and other policies apply. --> <!-- Protocol Elements --> <x:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" targetNamespace="http://docs.oasis-open.org/ws-rx/wsmc/200702" elementFormDefault="qualified" attributeFormDefault="unqualified"> <!-- Protocol Elements --> <xs:complexType name="MessagePendingType"> <xs:sequence> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:element name="MessagePending" type="wsmc:MessagePendingType"/> <xs:element name="Address"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:anyURI"> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> <xs:complexType name="MakeConnectionType"> <xs:sequence> <xs:element ref="wsmc:Address" minOccurs="0" maxOccurs="1"/> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:element name="MakeConnection" type="wsmc:MakeConnectionType"/> <xs:complexType name="MCSupportedType"> <xs:sequence> <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:element name="MCSupported" type="wsmc:MCSupportedType"/> <xs:element name="UnsupportedSelection"> <xs:simpleType> <xs:restriction base="xs:QName"/> </xs:simpleType> </xs:element> </xs:schema> ``` Appendix B. WSDL This WSDL describes the WS-MC protocol from the point of view of the endpoint that receives the MakeConnection message. Also note that this WSDL is intended to describe the internal structure of the WS-MC protocol, and will not generally appear in a description of a WS-MC-capable Web service. See section 3.4 Policy for a higher-level mechanism to indicate that WS-MC is supported. The normative WSDL 1.1 definition for WS-MakeConnection is located at: http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.0-wsdl-200702e1.wsdl The following non-normative copy is provided for reference. ```xml <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) OASIS (R) 1993-2007. All Rights Reserved. OASIS trademark, IPR and other policies apply. --> <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:tns="http://docs.oasis-open.org/ws-rx/wsmc/200702/wsdl" targetNamespace="http://docs.oasis-open.org/ws-rx/wsmc/200702/wsdl"> <wsdl:types> <xs:schema> <xs:import namespace="http://docs.oasis-open.org/ws-rx/wsmc/200702" schemaLocation="http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.0-schema-200702.xsd"/> </xs:schema> </wsdl:types> <wsdl:message name="MakeConnection"> <wsdl:part name="makeConnection" element="wsmc:MakeConnection"/> </wsdl:message> <wsdl:portType name="MCAbstractPortType"> <wsdl:operation name="MakeConnection"> <wsdl:input message="tns:MakeConnection" wsam:Action="http://docs.oasis-open.org/ws-rx/wsmc/200702/MakeConnection"/> </wsdl:operation> </wsdl:portType> </wsdl:definitions> ``` Appendix C. Message Examples Appendix C.1 Example use of MakeConnection To illustrate how a MakeConnection message exchange can be used to deliver messages to an Endpoint that is not addressable, consider the case of a pub/sub scenario in which the Endpoint to which notifications are to be delivered (the "event consumer") is not addressable by the notification sending Endpoint (the "event producer"). In this scenario the event consumer must initiate the connections in order for the notifications to be delivered. One possible set of message exchanges (using HTTP) that demonstrate how this can be achieved using MakeConnection is shown below. Step 1 – During a "subscribe" operation, the event consumer’s EPR specifies the MC anonymous URI and the WS-RM Policy Assertion [WS-RM Policy] to indicate whether or not RM is required: ``` <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:wsrmp="http://docs.oasis-open.org/ws-rx/wsrmp/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> <wsa:To> http://example.org/subscriptionService </wsa:To> <wsa:MessageID> http://client456.org/id-a6d8-a7c2eb546813 </wsa:MessageID> <wsa:ReplyTo> <wsa:To> http://client456.org/response </wsa:To> </wsa:ReplyTo> </S:Header> <S:Body> <sub:Subscribe xmlns:sub="http://example.org/subscriptionService"> <!-- subscription service specific data --> <targetEPR> <wsa:Address> http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=550e8400-e29b-11d4-a716-446655440000 </wsa:Address> <wsa:Metadata> <wsp:Policy wsu:Id="MyPolicy"> <wsrmp:RMAssertion/> </wsp:Policy> </wsa:Metadata> </targetEPR> </sub:Subscribe> </S:Body> </S:Envelope> ``` In this example the `subscribe` and `targetEPR` elements are simply examples of what a subscription request message might contain. Note: the `wsa:Address` element contains the MC anonymous URI indicating that the notification producer needs to queue the messages until they are requested using the MakeConnection message exchange. The EPR also contains the WS-RM Policy Assertion indicating the RM must be used when notifications related to this subscription are sent. Step 2 – Once the subscription is established, the event consumer checks for a pending message: ``` <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:wsrmp="http://docs.oasis-open.org/ws-rx/wsrmp/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> </S:Header> <S:To> http://example.org/subscriptionService </S:To> </S:Envelope> ``` Step 3 – If there are messages waiting to be delivered then a message will be returned back to the event consumer. However, because WS-RM is being used to deliver the messages, the first message returned is a CreateSequence: ```xml <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> <wsa:To>http://example.org/subscriptionService</wsa:To> <wsa:RelatesTo>http://example.org/id-123-456</wsa:RelatesTo> </S:Header> <S:Body> <wsmc:CreateSequence> <wsmc:AcksTo> <wsa:Address>http://example.org/subscriptionService</wsa:Address> </wsmc:AcksTo> </wsmc:CreateSequence> </S:Body> </S:Envelope> ``` Notice from the perspective of how the RM Source on the event producer interacts with the RM Destination of those messages, nothing new is introduced by the use of the MakeConnection, the use of RM protocol is the same as the case where the event consumer is addressable. Note the message contains a wsmc:MessagePending header indicating that additional message are waiting to be delivered. Step 4 – The event consumer will respond with a CreateSequenceResponse message per normal WS-Addressing rules: ```xml <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> <wsa:To>http://example.org/subscriptionService</wsa:To> <wsa:RelatesTo>http://example.org/id-123-456</wsa:RelatesTo> </S:Header> <S:Body> <wsrm:CreateSequenceResponse> <wsrm:Identifier>http://example.org/rmid-456</wsrm:Identifier> </wsrm:CreateSequenceResponse> </S:Body> </S:Envelope> ``` Note, this message is carried on an HTTP request directed to the `wsa:ReplyTo` EPR, and the HTTP response will be an HTTP 202. **Step 5 – The event consumer checks for another message pending:** ```xml <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> <wsa:To> http://example.org/subscriptionService </wsa:To> </S:Header> <S:Body> <wsmc:MakeConnection> <wsmc:Address>http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=550e8400-e29b-11d4-a716-446655440000</wsmc:Address> </wsmc:MakeConnection> </S:Body> </S:Envelope> ``` Notice this is the same message as the one sent in step 2. **Step 6 – Since there is a message pending for this destination then it is returned on the HTTP response:** ```xml <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:wsrm="http://docs.oasis-open.org/ws-rx/wsrm/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> <wsa:Action>http://example.org/eventType1</wsa:Action> <wsa:To>http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=550e8400-e29b-11d4-a716-446655440000</wsa:To> <wsmc:MessagePending pending="true"/> </S:Header> <S:Body> <!-- event specific data --> </S:Body> </S:Envelope> ``` As noted in step 3, the use of the RM protocol does not change when using `MakeConnection`. The format of the messages, the order of the messages sent and the timing of when to send it remains the same. **Step 7 – At some later interval, or immediately due to the `MessagePending` header's "pending" attribute being set to "true", the event consumer will poll again:** ```xml <S:Envelope xmlns:S="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702" xmlns:wsa="http://www.w3.org/2005/08/addressing"> <S:Header> <wsa:To> http://example.org/subscriptionService </wsa:To> </S:Header> ``` wsmc-1.1-spec-cs-02 Notice this is the same message as the one sent in steps 2 and 5. As in steps 3 and 6, the response to the `MakeConnection` can be any message destined to the specified Endpoint. This allows the event producer to send not only application messages (events) but RM protocol messages (e.g. `CloseSequence`, `TerminateSequence` or even additional `CreateSequence` messages) as needed. **Step 8** – If at any point in time there are no messages pending, in response to a `MakeConnection` the event producer returns an HTTP 202 back to the event consumer. The process then repeats (back to step 7) until the subscription ends. Appendix D. Acknowledgments The following individuals have provided invaluable input into the initial contribution: - Keith Ballinger, Microsoft - Stefan Batres, Microsoft - Rebecca Bergersen, Iona - Allen Brown, Microsoft - Kyle Brown, IBM - Michael Conner, IBM - George Copeland, Microsoft - Francisco Curbera, IBM - Paul Fremantle, IBM - Steve Graham, IBM - Pat Helland, Microsoft - Rick Hill, Microsoft - Scott Hinkelmann, IBM - Tim Holloway, IBM - Efim Hudis, Microsoft - David Ingham, Microsoft - Gopal Kakivaya, Microsoft - Johannes Klein, Microsoft - Frank Leymann, IBM - Martin Nally, IBM - Peter Niblett, IBM - Jeffrey Schlimmer, Microsoft - James Snell, IBM - Sanjiva Weerawarana, IBM - Roger Wolter, Microsoft The following individuals were members of the committee during the development of this specification: - Abbie Barbir, Nortel - Charlton Barreto, Adobe - Stefan Batres, Microsoft - Hamid Ben Malek, Fujitsu - Andreas Bjarestam, Ericsson - Toufic Boubez, Layer 7 - Doug Bunting, Sun - Lloyd Burch, Novell - Steve Carter, Novell - Martin Chapman, Oracle - Dave Chappell, Sonic - Paul Cotton, Microsoft - Glen Daniels, Sonic - Doug Davis, IBM - Blake Dournae, Intel - Jacques Durand, Fujitsu - Colleen Evans, Microsoft - Christopher Ferris, IBM - Paul Fremantle, WSO2 - Robert Freund, Hitachi - Peter Furniss, Erebor - Marc Goodner, Microsoft - Alastair Green, Choreology - Mike Grogan, Sun - Ondrej Hrebicek, Microsoft - Kazunori Iwasa, Fujitsu - Chamilaka Jayalath, WSO2 - Lei Jin, BEA - Ian Jones, BTplc - Anish Karmarkar, Oracle
{"Source-Url": "http://docs.oasis-open.org/ws-rx/wsmc/200702/wsmc-1.1-spec-cs-02.pdf", "len_cl100k_base": 11940, "olmocr-version": "0.1.53", "pdf-total-pages": 27, "total-fallback-pages": 0, "total-input-tokens": 90045, "total-output-tokens": 14322, "length": "2e13", "weborganizer": {"__label__adult": 0.00024259090423583984, "__label__art_design": 0.0003829002380371094, "__label__crime_law": 0.0003948211669921875, "__label__education_jobs": 0.0005826950073242188, "__label__entertainment": 7.355213165283203e-05, "__label__fashion_beauty": 0.00012421607971191406, "__label__finance_business": 0.0005478858947753906, "__label__food_dining": 0.0002104043960571289, "__label__games": 0.0004014968872070313, "__label__hardware": 0.0010585784912109375, "__label__health": 0.0002225637435913086, "__label__history": 0.00024628639221191406, "__label__home_hobbies": 5.632638931274414e-05, "__label__industrial": 0.0003147125244140625, "__label__literature": 0.00023066997528076172, "__label__politics": 0.0002551078796386719, "__label__religion": 0.0003440380096435547, "__label__science_tech": 0.0294036865234375, "__label__social_life": 5.745887756347656e-05, "__label__software": 0.0239105224609375, "__label__software_dev": 0.9404296875, "__label__sports_fitness": 0.00016772747039794922, "__label__transportation": 0.0003666877746582031, "__label__travel": 0.00016999244689941406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 53126, 0.02881]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 53126, 0.14353]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 53126, 0.76658]], "google_gemma-3-12b-it_contains_pii": [[0, 1738, false], [1738, 3480, null], [3480, 7382, null], [7382, 10658, null], [10658, 13347, null], [13347, 15802, null], [15802, 16847, null], [16847, 17613, null], [17613, 20115, null], [20115, 21855, null], [21855, 23202, null], [23202, 23596, null], [23596, 26348, null], [26348, 29602, null], [29602, 32023, null], [32023, 32528, null], [32528, 34603, null], [34603, 35903, null], [35903, 36360, null], [36360, 39821, null], [39821, 41826, null], [41826, 43657, null], [43657, 46626, null], [46626, 48647, null], [48647, 50950, null], [50950, 51573, null], [51573, 53126, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1738, true], [1738, 3480, null], [3480, 7382, null], [7382, 10658, null], [10658, 13347, null], [13347, 15802, null], [15802, 16847, null], [16847, 17613, null], [17613, 20115, null], [20115, 21855, null], [21855, 23202, null], [23202, 23596, null], [23596, 26348, null], [26348, 29602, null], [29602, 32023, null], [32023, 32528, null], [32528, 34603, null], [34603, 35903, null], [35903, 36360, null], [36360, 39821, null], [39821, 41826, null], [41826, 43657, null], [43657, 46626, null], [46626, 48647, null], [48647, 50950, null], [50950, 51573, null], [51573, 53126, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 53126, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 53126, null]], "pdf_page_numbers": [[0, 1738, 1], [1738, 3480, 2], [3480, 7382, 3], [7382, 10658, 4], [10658, 13347, 5], [13347, 15802, 6], [15802, 16847, 7], [16847, 17613, 8], [17613, 20115, 9], [20115, 21855, 10], [21855, 23202, 11], [23202, 23596, 12], [23596, 26348, 13], [26348, 29602, 14], [29602, 32023, 15], [32023, 32528, 16], [32528, 34603, 17], [34603, 35903, 18], [35903, 36360, 19], [36360, 39821, 20], [39821, 41826, 21], [41826, 43657, 22], [43657, 46626, 23], [46626, 48647, 24], [48647, 50950, 25], [50950, 51573, 26], [51573, 53126, 27]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 53126, 0.03588]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
115e3c5d6502c79a8bd60b6923fa5998d047c9b7
[REMOVED]
{"Source-Url": "https://hal.laas.fr/hal-01784210/document", "len_cl100k_base": 11058, "olmocr-version": "0.1.53", "pdf-total-pages": 17, "total-fallback-pages": 0, "total-input-tokens": 52958, "total-output-tokens": 13114, "length": "2e13", "weborganizer": {"__label__adult": 0.0004992485046386719, "__label__art_design": 0.0005125999450683594, "__label__crime_law": 0.0005421638488769531, "__label__education_jobs": 0.0010509490966796875, "__label__entertainment": 0.0001512765884399414, "__label__fashion_beauty": 0.00024890899658203125, "__label__finance_business": 0.0005025863647460938, "__label__food_dining": 0.0005865097045898438, "__label__games": 0.001007080078125, "__label__hardware": 0.003086090087890625, "__label__health": 0.0014438629150390625, "__label__history": 0.0005822181701660156, "__label__home_hobbies": 0.00017440319061279297, "__label__industrial": 0.0007448196411132812, "__label__literature": 0.0005860328674316406, "__label__politics": 0.0004570484161376953, "__label__religion": 0.0008234977722167969, "__label__science_tech": 0.323486328125, "__label__social_life": 0.00011259317398071288, "__label__software": 0.008209228515625, "__label__software_dev": 0.6533203125, "__label__sports_fitness": 0.00045371055603027344, "__label__transportation": 0.0010738372802734375, "__label__travel": 0.0002906322479248047}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 46984, 0.02603]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 46984, 0.38646]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 46984, 0.88847]], "google_gemma-3-12b-it_contains_pii": [[0, 1003, false], [1003, 2503, null], [2503, 6154, null], [6154, 9733, null], [9733, 12799, null], [12799, 15507, null], [15507, 18677, null], [18677, 20782, null], [20782, 24010, null], [24010, 27222, null], [27222, 30020, null], [30020, 32864, null], [32864, 36514, null], [36514, 39715, null], [39715, 42917, null], [42917, 45943, null], [45943, 46984, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1003, true], [1003, 2503, null], [2503, 6154, null], [6154, 9733, null], [9733, 12799, null], [12799, 15507, null], [15507, 18677, null], [18677, 20782, null], [20782, 24010, null], [24010, 27222, null], [27222, 30020, null], [30020, 32864, null], [32864, 36514, null], [36514, 39715, null], [39715, 42917, null], [42917, 45943, null], [45943, 46984, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 46984, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 46984, null]], "pdf_page_numbers": [[0, 1003, 1], [1003, 2503, 2], [2503, 6154, 3], [6154, 9733, 4], [9733, 12799, 5], [12799, 15507, 6], [15507, 18677, 7], [18677, 20782, 8], [20782, 24010, 9], [24010, 27222, 10], [27222, 30020, 11], [30020, 32864, 12], [32864, 36514, 13], [36514, 39715, 14], [39715, 42917, 15], [42917, 45943, 16], [45943, 46984, 17]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 46984, 0.02899]]}
olmocr_science_pdfs
2024-12-08
2024-12-08
c989ceb1fbc791d0e97d4471ffe451926a6b3be0
Collaborative Policy Administration Weili Han, Member, IEEE, Zheran Fang, Laurence T. Yang, Member, IEEE, Gang Pan, Member, IEEE, and Zhaohui Wu, Senior Member, IEEE Abstract—Policy based management is a very effective method to protect sensitive information. However, the overclaim of privileges is widespread in emerging applications, including mobile applications and social network services, because the applications’ users involved in policy administration have little knowledge of policy based management. The overclaim can be leveraged by malicious applications, then lead to serious privacy leakages and financial loss. To resolve this issue, this paper proposes a novel policy administration mechanism, referred to as Collaborative Policy Administration (CPA for short), to simplify the policy administration. In CPA, a policy administrator can refer to other similar policies to set up their own policies to protect privacy and other sensitive information. This paper formally defines CPA, and proposes its enforcement framework. Furthermore, in order to obtain similar policies more effectively, which is the key step of CPA, a text mining based similarity measure method is presented. We evaluate CPA with the data of Android applications, and demonstrate that the text mining based similarity measure method is more effective in obtaining similar policies than the previous category based method. Index Terms—Collaborative Policy Administration, Policy Based Management, Mobile Applications, Android, Social Network Services 1 INTRODUCTION The method of policy based management is widely used to manage complex and large scale network systems [1] [2] [3] [4]. The traditional framework of policy based management consists of four core components [5]: PDP (Policy Decision Point), PEP (Policy Enforcement Point), PAP (Policy Administration Point) and PR (Policy Repository). A well-trained policy administrator or group will specify, verify policies in PAP, and deploy the policies in PR. After a system runs, PDP will retrieve applicable policies from PR, and make decisions. PEP takes charge of the decision, such as satisfying the request where a subject wants to open a file (authorization action), or launching a logger to record system context (obligation action). The overclaim of privileges, where a not well-trained administrator assigns more privileges than those are required of a subject, is a increasingly serious problem, especially when the method of policy based management is applied to emerging application scenarios, such as mobile applications [6] [7] [8] [9] and social network services [10]. For instance, during the process of Android application development, three roles are usually involved in the policy administration: Application Developers declare which permissions the application will request; Application Marketers verify whether the application is legitimate or not by an automatic tool; Application Users decide whether to approve the permission requests. These three roles are usually performed by those who are not well-trained in policy based management. That is, the developers usually declare more permissions than necessary because they are inclined to make the development of applications easier, or even misunderstand technical documents [9] [11]; the marketers usually tend to allow more applications regardless of the malicious permission requests; and the application users may not know what the requested permissions mean, thus approving all requests because they are eager to use the application. The same issue exists in social network services, where a user is asked to grant access to private data to third-party applications [12]. This challenge to policy administration is increasing serious due to the explosion of these applications. Among all smart phones shipped during the second quarter of 2012, Android OS smart phones had the largest global market share (68.1%) [13]. Furthermore, social network services have become one of the most popular web applications in the world [10]. For example, in April 2012, Twitter, an online microblogging service created in March 2006, announced that it commanded more than 140 million active users, and saw 340 million Tweets a day [14]. Although IETF proposed the protocol of OAuth 2.0 [15], the policy administration is still a serious problem in the policy based management of these emerging applications [12]. As a result, we should strengthen the policy administration mechanism in these application scenarios. This paper proposes Collaborative Policy Administration (CPA for short). The essential idea of CPA is that applications with similar functionalities shall have similar policies which will be specified and deployed. Thus, to specify or verify policies, CPA will examine policies already specified by other similar applications and perform collaborative recommendation. The degree of similarity will be calculated by predefined - W. Han and Z. Fang are with Software School, Fudan University, Shanghai, P. R. China 201203. - L. Yang is with Department of Computer Science, St. Francis Xavier University. - G. Pan and Z. Wu are with School of Computer Science and Technology, Zhejiang University, Hangzhou, P. R. China 310007. algorithms, which could be a category based algorithm and a text mining based algorithm, etc. The main contributions of this paper are as follows: - We propose a novel method - collaborative policy administration, to help not well-trained users, even novices to specify and verify policies. We define the formal model of CPA. In this model, two main functions in policy administration are defined based on similarity measure methods, which will select similar policies as a refinement basis to assist administrators to design or verify their target policies. - We propose a text mining similarity measure method to help policy administrators to obtain similar policies. According to the evaluation, the proposed method is more effective than the category based similarity measure method, which is more widely used in other literatures [7] [12]. - We present an enforcement framework, and implement a prototype of CPA. The framework supports two types of user interfaces, and provides functions of collaborative policy design and collaborative policy verification. The rest of the paper is organized as follows: Section 2 analyzes the trust model in mobile applications and social network services, then presents them as typical scenarios; Section 3 formally defines CPA; Section 4 introduces an enforcement framework; Section 5 evaluates the effectiveness of CPA by experiments; Section 6 discusses the rest key issues in CPA; Section 7 investigates the related work; and Section 8 concludes the paper and introduces our future work. 2 BACKGROUND AND MOTIVATION 2.1 No Trusted Administration Point in Emerging Applications In the traditional administration model [3], a professional expert or group will take charge of the policy administration, whose functions include policy design, policy verification, and policy deployment. When a system is being deployed, the expert or group will analyze what are the critical resources, then model them, and specify the management and security policies. These policies could be from the routines of organization management, or from the result of face-to-face discussions or meetings. After the policy design, some formal analysis tools could be applied to verify the policies. Even after the policy deployment, log-based analysis tools can help the expert or group to verify the designed policies: explore vulnerabilities, fix policies, and redeploy them. However, the emerging applications, especially mobile applications and social network services, challenge the existing trust model in the policy administration. In these emerging applications, common users, including software developers and end users, who do not possess the professional knowledge of policy based management, must specify or verify policies. The developer of a third-party application must request the privileges to be used by the application. When the developer writes the manifest files, he or she might overclaim privileges [9] [11]. The developer may not know what is at risk in detail if an application requests such privileges. As an end user of the third-party application, he or she must determine whether the requests for the privileges are legitimate. The task is very tough because the majority of end users do not know the risk of the approval in detail. Usually, the end user will approve all requests from third-party applications, because he or she wants to run the applications, thus falling into the traps of malicious applications. As the second feature of the changing trust model, the involved parties in the policy administration could have the conflict of interest. A developer is inclined to request more privileges because this enables the developer to run his or her application with less privilege restrictions. However, an end user of the application is inclined to approve the fewest privileges possible to run the application, because more privileges expose more resources, thus lead to more risks, e.g., the leakage of privacy. The third feature of the changing trust model is that a supervisor could verify the policy requests. The strengths of different supervisors are totally different. It depends on the strategies of the applications' distribution. For example, because the strength of Google Play Store is relatively weak, Android developers can publish many applications rapidly and easily. But Apple App Store deploys a stricter reviewing strategy. Thus the speed of application publishing in App Store is usually slow [16]. As a result of the changing trust model, overclaim of privileges is widespread in these emerging applications. This breaks the basic security principle: Principle of Least Privilege [17]. Although IETF proposed the open authorization protocol [15], it does not provide a policy administration model under the changing trust model. Thus, the changing trust model calls for more novel mechanisms to strengthen the policy administration. 2.2 Motivated Scenarios 2.2.1 Android Applications In the Android security framework [6] [18] [19] [20] [21] [22], a developer rather than a professional policy administrator must set which permissions an application should request. And an end user of the application rather than a policy administrator must determine whether the requested permissions are legitimate for his or her mobile device. Due to the openness of the Android security framework, hundreds of millions of developers and users are involved. Without tools’ support, the developers could not fully understand, or might even misunderstand the description of the requested permissions. As a result, overclaimed permissions are widespread in Android applications [11]. On the other hand, the end users usually approve all requested permissions due to the lack of knowledge of policy administration. The supervisors, application marketers, usually spend little effort on checking the applications. Thus, many applications with malicious behaviors can be uploaded to markets, and spread to lots of Android devices. CPA will provide two functions to help application developers, marketers, and end users of Android: collaborative policy design and collaborative policy verification. Collaborative policy design assists the application developers in declaring permissions to achieve the applications’ functionalities, observing the Principle of Least Privilege while ensuring the normal functionalities of the applications. On the other hand, collaborative policy verification helps the end users identify malicious permission requests, thus keeps the users from privacy leakage or financial losses. Moreover, for the marketers, collaborative policy verification mitigates the difficulty of filtering malicious applications. 2.2.2 Social Network Services In social network services, third-party web-based applications could request sensitive information of end users. The problem is similar to the issue in the Android system. The differences between Android applications and social network services are as follows: First, the Android security framework only allows the end user to approve or deny all request permissions, but the social network services allow the end user to approve sensitive requests one by one. Second, the social network services can follow the protocol of OAuth (2.0), but the Android security framework is not standardized. Literature [12] proposed several recommendation models for OAuth. This mechanism is similar to CPA. However, by leveraging CPA, the developer as well as the end user can benefit. The developer can determine which sensitive requests can be set according to other similar policies. As a result, he or she can develop more secure and more acceptable applications for end users. 3 CPA: Definitions The proposed collaborative policy administration includes two main stages: collaborative policy design and collaborative policy verification. We, therefore, formally define the CPA model as follows: **DEFINITION 1: Collaborative Policy Administration Model:** $$CPA := \{Admins, CPDM, CPVM\}$$ Here, Admins refers to all involved policy administrators, including, e.g., developers, marketers, and end users in the Android framework. We define CPDM as follows: **DEFINITION 2: Collaborative Policy Design Model:** $$CPDM := \{PB_{\text{history}}, SimFunc, SUBJS, RefFunc, \Delta, PS_{\text{ref}}\}$$ A policy administrator $$\in Admins$$ can obtain a refined policy set $$\subseteq PS_{\text{ref}}$$ according to a refinement function $$\in RefFunc$$, which is a refinement [3] driven by history data. Thus, it is very different from the traditional policy refinement methods [3], which are driven by a set of refinement rules or templates. In DEFINITION 2, $$PB_{\text{history}}$$ refers to a policy base which contains a number of policies previously created both by administrator himself/herself and others. We abstractly define the content of $$PB_{\text{history}}$$ as follows: $$PB_{\text{history}} := 2^{\text{SUBJS} \times \text{PERMS}}$$ Here, SUBJS refers to the subjects in a system. E.g., in the Android system, all applications belong to SUBJS. PERMS refers to all available permissions. E.g., there are 130 permissions in the Android system now [23]. Next, in DEFINITION 2, SimFunc selects similar subjects, then output their policies according to the subject’s attributes as the similar policies. E.g., when a subject has a category attribute, all other subjects in the category can be viewed as similar applications, e.g., 90% of Minimal Acceptable Rate in Appendix A.1 in the supplemental material. Formally, $$SimFunc : \text{SUBJS} \times PB_{\text{history}} \rightarrow PS_{\text{similar}}$$ Here, $$PS_{\text{similar}}$$ refers to all policies of the similar subjects, as is described in the previous part. In DEFINITION 2, RefFunc refers to the refinement functions, each of which will output a policy set according to the attributes of a subject $$\in SUBJS$$, its similar policies $$\in PS_{\text{similar}}$$, and $$\delta, \Delta \in \Delta$$, which may be a number, is a parameter of the function. Formally, $$RefFunc : \text{SUBJS} \times PS_{\text{similar}} \times \Delta \rightarrow PS_{\text{ref}}$$ Here, $$PS_{\text{ref}}$$ is a subset of $$\text{SUBJS} \times \text{PERMS}$$. Note that, each subject in the output $$PS_{\text{ref}}$$ is equal to the input parameter of the subject $$\in \text{SUBJS}$$. And we define CPVM as follows: **DEFINITION 3: Collaborative Policy Verification Model:** $$CPVM := \{PB_{\text{history}}, SimFunc, SUBJS, VeriFunc, VeriResult\}$$ A policy administrator $$\in Admins$$ can obtain a verification result $$\in VeriResult$$ for a target policy set $$\in PS_{\text{target}}$$, which contains all polices assigned to a target subject $$\in SUBJS$$, according to a verification function $$\in VeriFunc$$. In DEFINITION 3, SUBJS refers to the target subjects which will be verified. According to a target subject, we can obtain a target policy set $$PS_{\text{target}}$$, which is also a subset of $$\text{SUBJS} \times \text{PERMS}$$. Note that, there is only one subject in $$PS_{\text{target}}$$. Finally, in DEFINITION 3, VeriFunc refers to the verification functions, each of which will verify the target policy set, and provide a verification result. The result includes a simple conclusion VeriResult, e.g., whether the target policy set is suitable or not, or a vector of percentages, where each value represents how much percentage a permission in the target policy set occupies in the similar policies. We define VeriFunc as follows: $$VeriFunc : \text{SUBJS} \times PS_{\text{similar}} \rightarrow VeriResult$$ 4 CPA: ENFORCEMENT FRAMEWORK 4.1 Overview As is shown in Figure 1, a policy administrator can leverage the framework to administrate policies via a phone, web browser, or development tool. In Figure 1, the direction of arrows is the direction of key data flows. The history policy base and similarity measure methods are two key components in the enforcement framework. To enforce CPA, the administrator should prepare a sufficient number of policies at first. Furthermore, collaborative policy design and collaborative policy verification are the two key functions provided by the framework, according to the definitions described in Section 3. These two functions depend on the history policy base and similarity measure methods. After obtaining the similar policies, the two functions call a refinement algorithm and a verification algorithm respectively. Finally, collaborative policy design and collaborative policy verification will display the results to the administrator on various user interfaces, e.g., a phone, web browser, or development tool. 4.2 Key Algorithms To enforce CPA, three key algorithms, similar policies algorithms, refinement algorithm, and verification algorithm, are proposed as follows: 4.2.1 Similar Policies Algorithms Each similar policies algorithm obtains a similar policy set according to an input subject. For each policy in the HPB, each similar policies algorithm determines whether its subject is similar to the required subject. If so, add it to the similar policy set. There are many functions to judge the similarity such as checking the category of a subject, as described in Algorithm 1, or even friends’ recommendation and manual selection. The time complexity of Algorithm 1 is $O(n)$, where $n$ refers to the number of policies in HPB. An index based on subjects in HPB can optimize the time complexity of Algorithm 1. Furthermore, we propose a new method based on the text mining technique to obtain similar policy sets of an application in the Android framework. This new method leverages the description of a target application to find similar applications, then adds the requested permissions of the similar applications to the similar policy set of the target application. A TF-IDF [24] method is employed to create key words of application description, and scores will be generated according to the key words. Finally, the new method selects a pre-defined number (threshold) of applications according to the scores, and adds the selected applications’ policy configurations to the similar policy set. Algorithm 2 shows our proposed similarity measure method in detail. In Algorithm 2, the initialize function involves declaring the simpolicies, assigning 0 to the score of every element in simpolicies and building the index for all application description from HPB if the index files are not available. The parse function tokenizes the description of the subject and returns a query object which is ready for searching. The statements inside the for loop are composed of a typical text mining procedure based on TF-IDF [24]. This procedure iterates on all subjects in the HPB. We execute the procedure with Apache Lucene [25]. a stands for corr(query, doc), which is the score factor based on how many of the query terms are found in the doc. b stands for queryNorm(query), which is the normalizing factor used to make scores between queries comparable. For each term in the query, c stands for tf(term, doc), which is the term’s frequency in doc. d stands for idf(term), which is the inverse document frequency of term. e stands for term.getBoost(), which is a search time boost of term in the query. f stands for norm(term, doc), which is a few (indexing time) boost and length factors. score is calculated based on a, b, c, d, e, and f, as is shown in Algorithm 2. simcountThreshold refers to the threshold of similar subjects. When the score is higher than the score of the simcountThreshold item in the similar subjects (simSubjs), the subject will be added into simSubjs in descending order by score. Finally, all policies of each subject in simSubjs will be added to simpolicies. The time complexity of Algorithm 2 might be $O(n)$, where $n$ refers to the number of subjects in HPB. However, each iteration of Algorithm 2 is heavy, because the algorithm leverages the algorithm of TF-IDF to generate the scores. ### 4.2.2 Refinement Algorithm **Algorithm 3 Collaborative Policy Refinement** **Input:** - $\text{subject} \in \text{SUBJS}$ - $\text{simpolicies} \in \text{PS}_{\text{sim}}$ - $\delta \in \Delta$, a number here, e.g., 0.9 **Output:** - $\text{refpolicies} \in \text{PS}_{\text{ref}}$ ```plaintext for all policy $\in$ simpolicies do count[policy.permission]++ end for for all permission $\in$ PERMS do if count[permission]/simpolicies.size $>$ $\delta$ then policy.subject $\leftarrow$ subject policy.permission $\leftarrow$ permission refpolicies.add(policy) end if end for ``` Algorithm 3 describes how to refine policies according to a parameter $\delta$, which is a number here. The time complexity of Algorithm 3 is $O(n)$, where $n$ refers to the number of policies in simpolicies. ### 4.2.3 Verification Algorithm **Algorithm 4 Collaborative Policy Verification** **Input:** - subject $\in$ SUBJS - simpolicies $\in$ PS$_{\text{sim}}$ **Output:** - veriResult $\in$ VeriResult ```plaintext for all policy $\in$ simpolicies do count[policy.permission]++ end for for targetpolicies $\in$ $\forall$p $\in$ HPB: p.subject $=$ subject do for all tpolicy $\in$ targetpolicies do veriResult[tpolicy.permission] $\leftarrow$ count[tpolicy.permission]/simpolicies.size end for end for ``` Algorithm 4 provides a quantified measure between the target policies and similar policies. Usually, the time complexity of Algorithm 4 is $O(n)$, where $n$ refers to the size of simpolicies, because the size of simpolicies is usually larger than the size of targetpolicies, and the step to fetch targetpolicies can be optimized by using an index of subjects in HPB. The final output is a vector of percentages, each of which means how much percentage the permission of target policy occupies in the similar policies. To simplify the final result, we can design an aggregation algorithm to obtain a single number rather than a vector. ### 5 CPA: Evaluation #### 5.1 Permission Configuration Risk Index To evaluate the effectiveness of CPA, we propose Permission Configuration Risk Index (PCRI), which can show how risky a measured application is. The essence of PCRI is that the more warning and dangerous highlighted permissions an application requests, the more risky the application is. The PCRI of an application is calculated based on the usage percentage and the critical level [7] of each permission the application requests. Here, only two levels, critical and non-critical, are used in PCRI. As a result, this proposed index can simplify the view of experiment results by integrating of the verification results. During the calculation of PCRI, we first classify the requested permissions of an application by using warning percentage ($P_w$) and dangerous percentage ($P_d$), e.g., 80% and 50% respectively in Appendix A.1 in the supplemental material, which are preset by the policy administrators. If the usage percentage of a requested permission ($P_p$) is higher than the warning percentage, the permission is a safe permission; if the percentage of a requested permission falls between the warning percentage and dangerous percentage, the permission is a warning permission; if the percentage of a permission falls below the dangerous percentage, the permission is a dangerous permission. TABLE 1 The calculation rules of PRI, \( \vec{A} \) is a parameter vector of the following formulas <table> <thead> <tr> <th>Critical Permission</th> <th>Non-critical Permission</th> </tr> </thead> <tbody> <tr> <td>Warning</td> <td>( a_1 \times \frac{T_w - T_p}{T_w - T_d} )</td> </tr> <tr> <td>Dangerous</td> <td>( a_3 \times \frac{T_d - T_p}{T_d - T_w} )</td> </tr> </tbody> </table> Second, different types of permissions will contribute differently to the calculation of PCRI. After investigating the 130 currently available permissions in the security framework of Android [23], we argue that the security impact of abusing each permission varies. For example, an application which requests a rarely used the READ_CONTACTS permission is likely to be more harmful than another one using the BATTERY_STATS permission. The former one can collect the contacts’ personal information which is very private, while the latter one is able to access only battery statistics. Sarma et al. identified 26 permissions as critical ones [7]. We, therefore, leverage them to calculate PCRI. Third, we define Permission Risk Index (PRI) of each warning or dangerous permission, before we calculate PCRI. Note that, safe permissions have no contribution to the application’s PCRI, because we use PCRI to help detect risky permission configurations. For each warning or dangerous permission, we calculate its PRI by rules shown in Table 1. For example, for the application whose policy verification report is shown in Figure 6 in Appendix A.2 in the supplemental material, the PRI of the WRITE_EXTERNAL_STORAGE permission should be \( a_1 \times \frac{0.60 - 0.50}{0.60 - 0.40} \), because it is a critical permission with a usage percentage lying in the range between the warning percentage and dangerous percentage. Finally, after calculating the PRI of each requested permission of an application (we assume that an application \( \text{app} \) requests \( n \) permissions \( \text{app.permissions} \)), its PCRI will be obtained by the following formula: \[ PCRI(\text{app}) = \sum_{p \in \text{app.permissions}}^{} PRI(p) \] Here, \( p, \text{percentage} \) refers to the usage percentage of a permission \( p \), and \( \text{warning} \) refers to the warning percentage defined by the policy administrator. 5.2 Effectiveness of Similarity Measure Methods We evaluate whether the category based similarity measure method or our proposed text mining based one is more effective in obtaining similar policy sets. The evaluation is based on the two datasets mentioned in Appendix B in the supplemental material: one dataset contains 21,492 records of paid applications downloaded from the US Google Play Store; and the other dataset consists of 288 malicious application samples. And the measure methods are described in Algorithm 1 and 2. We use PCRI to evaluate the risk of applications in two datasets and calculate each application’s PCRI according to the formula described in Section 5.1 with the two similarity measure methods and different parameters. 5.2.1 Similarity Measure Methods for Android Applications Obtaining similar policy sets is a critical step in the CPA framework. As for Android applications, if the target policy set in policy verification is the permission configuration of a standalone game application, the obtained similar policy set should contain the requested permissions of other similar standalone game applications. From the characteristics of standalone games, we know that they should not have the right to access the Internet or send short messages. So the ideal similar policy set should not contain the INTERNET or SEND_SMS permissions. However, if some SMS (Short Message Service) applications are mistakenly judged as similar to standalone games, perhaps by wrong categorization, we will obtain a similar policy set which contains the SEND_SMS permission from those SMS applications and the results can be misleading, especially when we are verifying the permission configuration of a malicious standalone game application which sends premium rate messages without the acknowledging the phone’s owner. When we verify the permission configuration of the aforementioned malicious application with similar policy set which contains the requested permissions of many SMS relevant applications, the verification result is bound to be very poor because we could see that the requested SEND_SMS permission is even marked in green rather than red. The poor result might mislead the application marketer into approving the sale of the malicious application. Several similarity measure methods, e.g., category based, can be applied to obtain similar policy sets for Android application. On Google Play Store, applications are divided into 34 categories, e.g., Books & Reference and Photography. If we argue that applications belonging to the same category share some features or provide similar functionalities, one feasible method to obtain similar policy sets, therefore, is selecting permission configurations of all applications belonging to the same category as the subject. This attribute was also used in the related work of Shehab et al. [12]. Besides, we also propose the text mining based similarity measure method, as is shown in Algorithm 2. The performance of similarity measure methods is the key factor of the two functions, collaborative policy design and collaborative policy verification, in CPA. We thus conduct the experiments to evaluate CPA according to the different similarity measure methods. 5.2.2 Choose Threshold in the Proposed Method We first conduct experiments applying the text mining based method with different thresholds, \( \vec{A} = (a_1, a_2, a_3, a_4) = (3, 1, 10, 5) \), warning percentage=80%, draw two conclusions from Figure 2 and 3: in Appendix B in the supplemental material. We can algorithms 2 for malicious applications (the second dataset PCRI the supplemental material). And Figure 3 shows the effects of the different thresholds in Algorithms 2 for normal applications (the first dataset in Appendix B in the supplemental material). And Figure 3 shows the PCRI distributions of the different thresholds in Algorithms 2 for malicious applications (the second dataset in Appendix B in the supplemental material). We can draw two conclusions from Figure 2 and 3: - PCRI can effectively figure out whether an application is normal or malicious. As is shown in Figure 2, 99.73%, 99.58%, 99.38% and 99.37% normal applications’ PCRI is lower than 30 for each threshold respectively. As is shown in Figure 3, many more malicious applications have PCRI belonging to a higher PCRI range. For example, each threshold has about 70 malicious applications whose PCRI falls between 110 and 140. And only 26.74%, 30.21%, 30.90% and 34.38% malicious applications fall below 30 of PCRI for each threshold respectively. - The threshold of 15 can be chosen as the suitable one in the text mining based similarity measure method. As is shown in Figure 2, the curves almost coincide with different thresholds. And in Figure 3, the curve of the threshold of 15 will provide more effective results than other thresholds (25, 35, 50), because the PCRI of malicious applications with threshold of 15 is the highest as a whole. 5.2.3 Choose Dangerous Percentage in CPA We conduct the experiments on different dangerous percentage ($P_d$) configurations. We employ two rates, warning rate and detection rate in the evaluation. The warning rate decides the critical PCRI value. After sorting the applications in the normal application dataset in descending order by PCRI, we view the top warning rate, e.g., 5%, of applications as potentially malicious. The critical PCRI value is the largest PCRI value of the rest of the applications in the normal application dataset. For example, for text mining based similarity measure method with $\bar{A} = (3, 1, 10, 5)$, warning percentage=80%, dangerous percentage=10%, threshold=15, if we set the warning rate as 5%, the critical PCRI value is 9.64, which is the largest PCRI value of the rest 95% normal applications. The detection rate refers to the proportion of applications in the malicious application dataset whose PCRI is larger than the detection value. Table 2 shows the detection rates of the text mining based similarity measure method at different warning rates, with $\bar{A} = (3, 1, 10, 5)$, warning percentage=80%, threshold=15, and different dangerous percentages. <table> <thead> <tr> <th>Warning Rate</th> <th>Dangerous Percentage</th> <th>Detected Malicious Count (288 in total)</th> <th>Detection Rate</th> </tr> </thead> <tbody> <tr> <td>5%</td> <td>10%</td> <td>249</td> <td>86.46%</td> </tr> <tr> <td></td> <td>20%</td> <td>238</td> <td>82.64%</td> </tr> <tr> <td></td> <td>50%</td> <td>230</td> <td>79.86%</td> </tr> <tr> <td>10%</td> <td>10%</td> <td>257</td> <td>89.24%</td> </tr> <tr> <td></td> <td>20%</td> <td>252</td> <td>87.50%</td> </tr> <tr> <td></td> <td>50%</td> <td>248</td> <td>86.11%</td> </tr> <tr> <td>20%</td> <td>10%</td> <td>270</td> <td>93.75%</td> </tr> <tr> <td></td> <td>20%</td> <td>269</td> <td>93.40%</td> </tr> <tr> <td></td> <td>50%</td> <td>265</td> <td>92.01%</td> </tr> </tbody> </table> 5.2.4 Compare the Proposed Method with the Category based Method Table 3 shows the warning rates and the corresponding detection rates using the text mining based similarity mea- TABLE 3 Detection rates of different similar measure methods at different warning rates, with $\vec{A} = (3, 1, 10, 5)$, warning percentage=80%, and dangerous percentage=10% <table> <thead> <tr> <th>Warning Rate</th> <th>Method</th> <th>Threshold</th> <th>Detected Malicious Count (288 in total)</th> <th>Detection Rate</th> </tr> </thead> <tbody> <tr> <td>5%</td> <td>Text Mining</td> <td>15</td> <td>249</td> <td>86.46%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>25</td> <td>236</td> <td>81.94%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>35</td> <td>234</td> <td>81.25%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>50</td> <td>231</td> <td>80.21%</td> </tr> <tr> <td></td> <td>Category based</td> <td>NA</td> <td>220</td> <td>76.39%</td> </tr> <tr> <td>10%</td> <td>Text Mining</td> <td>15</td> <td>257</td> <td>89.24%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>25</td> <td>253</td> <td>87.85%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>35</td> <td>250</td> <td>86.81%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>50</td> <td>247</td> <td>85.76%</td> </tr> <tr> <td></td> <td>Category based</td> <td>NA</td> <td>232</td> <td>80.56%</td> </tr> <tr> <td>20%</td> <td>Text Mining</td> <td>15</td> <td>270</td> <td>93.75%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>25</td> <td>265</td> <td>92.01%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>35</td> <td>263</td> <td>91.32%</td> </tr> <tr> <td></td> <td>Text Mining</td> <td>50</td> <td>259</td> <td>89.93%</td> </tr> <tr> <td></td> <td>Category based</td> <td>NA</td> <td>256</td> <td>88.89%</td> </tr> </tbody> </table> *NA: Not Applicable Figure 4. PCRI distributions of applications when we run the text mining based similarity measure method with different thresholds, different $\vec{A}$,s, warning percentage=80%, and dangerous percentage=10% 5.2.5 Evaluate Different $\vec{A}$ Finally, we conduct the experiments where $\vec{A}$ is set differently. The results of $\vec{A} = (1, 1, 1, 1)$ are shown in Figure 4a and 4b. And the results of $\vec{A} = (0, 0, 1, 1)$ are shown Figure 4c and 4d. According to Figure 4a, 4b, 4c, 4d, we can conclude that: - The trends of curves are similar for all $\vec{A} (3, 1, 10, 5), (1, 1, 1, 1), (0, 0, 1, 1)) for the normal applications. The difference is that the PCRI of $(3, 1, 10, 5)$ is the highest, and the $(0, 0, 1, 1)$ is the lowest. - The significant difference happens for $\vec{A} = (0, 0, 1, 1)$ with the malicious applications. The PCRI of more applications in Figure 4d fall in the area of small PCRI. This is bad for policy verification. Actually, the distributions of the malicious applications with $\vec{A} = (1, 1, 1, 1)$ are worse than the ones with $\vec{A} = (3, 1, 10, 5)$, if we compare Figure 4b with Figure 3. 6 Discussions 6.1 Further Work on Policy Sets Obtained from Collaborative Policy Design We can obtain a policy set from collaborative policy design. This policy set, however, may be an intermediate. result and can be adjusted to meet the requirements of system management or security management. E.g., a developer of an Android application usually adjusts the policy set due to the extension of applications’ functionalities. On the other hand, social network services might directly apply the policy set from the collaborative policy design, because users, especially who are friends involved in the services, tend to share more, and be less concerned with the security problem, thus the obtained similar policy set is very dense. As a result, the collaborative policy design should be accurate enough to be enforced. Thus, the refined policies can directly be used to determine whether the sharing operation should be allowed. 6.2 Vulnerabilities in CPA A vulnerability of collusion exists in HPB. An attacker can put their malicious policy configurations into the base. Generally, only one attacker cannot affect the results of collaborative policy design and collaborative policy verification. However, if lots of attackers collude to input a large volume of malicious policy configurations, the HPB will be polluted and the similarity measure function could return a false result. Then the collaborative policy design and collaborative policy verification will show a wrong result to a policy designer or verifier. This vulnerability might be defended, if we carefully prepare HPB. Furthermore, the algorithms can still be robust in situations where only a few malicious policy configurations exist in the HPB. The next vulnerability happens when an attacker maliciously abuse permissions with legitimate descriptions. For example, if the attacker releases a malicious application which sends premium rate SMSes without users’ knowledge, but masquerades as a benign SMS application. SMS applications are usually justified to use the SEND_SMS permission. Then CPA could return a wrong verification result. The choices of description for malicious applications are limited. That is, if the attacker wants to maliciously leverage the SEND_SMS permission, he or she should camouflage the application as an SMS application rather than a game application which is more popular on the Google Play Store. However, this vulnerability is more severe, due to the coarse-grained permission model in the Android framework. To counter this threat, a finer-grained permission model with an improved administration mechanism should be developed. The proposed model must consider such burden of users’ policy administration tasks. It is exactly an advantage of CPA to reduce the burden of policy administration. 7 Related Work Policy administration is the key to protecting or operating information systems [3]. Only after a legitimate policy set is designed, can the systems run correctly. As a result, many researchers [26] [27] [28] proposed their works on this topic. This paper proposes a policy mechanism CPA under the current trust model, where a professional policy administrator or group is absent. Recently, the security of the Android platform becomes a hotspot in the field of system security. Enck et al. [29] revealed that two-thirds of the 30 randomly-chosen popular third-party applications exhibited suspicious behaviors, such as disclosing sensitive information, and that half of the applications reported users’ locations to remote advertising servers. Grace et al.’s analysis tool showed that among the 13 privileged permissions examined, 11 were leaked, with individual phone leaking up to 8 permissions, which can be exploited to wipe out the user data, send premium rate messages, etc. [30]. Ongtang et al. [31] proposed a complex policy model, and Nauman et al. [8] proposed runtime security constraint components for the Android platform. However, their goal is not to reduce the burden of policy design or policy verification. In fact, these two mechanisms may impose a higher requirement of professional knowledge on the Android security than previous methods. To assist an application user in determining whether he or she should accept the permissions, Nauman et al. [8] proposed to provide additional information in the installation interface. This tool, however, only shows the static description of permission in more detail. Enck et al. [32] proposed a tool named Kirin to analyze the manifest of Android application package files to ensure that the permissions requested by the application satisfy a certain safety policy. To verify the overclaim of privileges among Android applications, Felt et al. [11] proposed a method where they detect API calls, then verify the policy configurations. However, their method cannot be effective in defending the threats from attackers who request a permission but implement a malicious relevant function. Sarma et al. [7] used the risk and benefit measures to verify the policy configurations. This paper, however, proposes two functions based on similar policies, collaborative policy design and collaborative policy verification. The proposed CPA and Sarma et al.’s method are different in mechanisms. Policy recommendation [12] was proposed to simplify the policy administration in social network services. A user, as a verifier, can view the verification result of permission requests based on the similar policy sets. This paper proposes a text mining based method, thus can provide a more independent method to obtain similar policies, then improve the effectiveness of the functions of collaborative policy design and collaborative policy verification. Furthermore, CPA proposed in this paper also supports both collaborative policy design and collaborative policy verification, while the policy recommendation proposed by Shehab et al. [12] is only used in policy verification. 8 Conclusion and Future Work This paper proposes a novel policy administration mechanism, CPA, to meet the requirements of the changing trust model, which has led to the widespread overclaim of privileges. CPA leverages the similar policies to design or verify a target policy set, then simplifies the policy administration for, especially, common users. This paper defines the formal model of CPA, and designs an enforcement framework. Furthermore, the paper proposes a text mining based similarity measure method to obtain similar policies. The evaluation by using a prototype and the data from Google Play Store shows the proposed text mining based measure method is more effective than the category based method which is usually used in previous related work. In the future work, we will investigate the safety definition in CPA with a quantified method. Furthermore, we will improve the permission model with finer-grained access control for Android, especially, for INTERNET permission. Last but not least, we will strengthen the mathematics depth of the definitions and analysis of CPA. Acknowledgments The paper is extended from “Poster: Collaborative policy administration” [33] present at ACM CCS 2011. And this paper is supported by the 863 project (Grant NO: 2011AA100701), the project of Natural Science Foundation of Shanghai (Grant NO: 12ZR1402600). Thank Professor Wenyuan Xu and Mr. Hossen Mustafa for their helps and comments. References Weili Han (M’08) is an associate professor at Fudan University. His research interests are mainly in the fields of policy based management, IoT security, information security, and distributed systems. He is now the members of the ACM, SIGSAC, IEEE, and CCF. He received his Ph.D. of Computer Science and Technology at Zhejiang University in 2003. Then, he joined the faculty of Software School at Fudan University. From 2008 to 2009, he visited Purdue University as a visiting professor funded by China Scholarship Council and Purdue. He serves in several leading conferences and journals as PC members, reviewers, and an associate editor. Zheran Fang is an undergraduate student in software school at Fudan University now. He is currently a member of the Laboratory of Cryptography and Information Security, Fudan University. His research interests mainly include information security, policy based management. Laurence Tianruo Yang is a professor in the Department of Computer Science at St. Francis Xavier University, Canada. His research interests include high-performance computing and networking, embedded systems, pervasive computing, and intelligent systems. Dr. Yang has a Ph.D. in computer science from the University of Victoria, Canada. Gang Pan (S’04-M’05) received the B.Sc. and Ph.D. degrees in computer science from Zhejiang University, Hangzhou, China, in 1998 and 2004, respectively. He is currently a Professor with the College of Computer Science and Technology, Zhejiang University. He has published more than 100 refereed papers. He visited the University of California, Los Angeles, during 2007-2008. His research interests include pervasive computing, computer vision, and pattern recognition. Dr. Pan has served as a Program Committee Member for more than ten prestigious international conferences, such as IEEE ICCV and CVPR, and as a reviewer for various leading journals. Zhaohui Wu (SM’05) received the Ph.D. degree in computer science from Zhejiang University, China, in 1993. From 1991 to 1993, he was a joint Ph.D. student with the German Research Center for Artificial Intelligence, Germany. He is currently a Professor with the Department of Computer Science, Zhejiang University. His research interests include distributed artificial intelligence, semantic grid, and ubiquitous computing. He is on the editorial boards of several journals and has served as chairs for various international conferences.
{"Source-Url": "http://www.leonsoftsolutions.com/ieeepapers/networking/Network12.pdf", "len_cl100k_base": 10197, "olmocr-version": "0.1.50", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 40047, "total-output-tokens": 12765, "length": "2e13", "weborganizer": {"__label__adult": 0.00042629241943359375, "__label__art_design": 0.0005731582641601562, "__label__crime_law": 0.0019388198852539065, "__label__education_jobs": 0.0029468536376953125, "__label__entertainment": 0.0001766681671142578, "__label__fashion_beauty": 0.0002758502960205078, "__label__finance_business": 0.0007886886596679688, "__label__food_dining": 0.0003046989440917969, "__label__games": 0.0011510848999023438, "__label__hardware": 0.0028133392333984375, "__label__health": 0.0008625984191894531, "__label__history": 0.0004329681396484375, "__label__home_hobbies": 0.0001513957977294922, "__label__industrial": 0.0005245208740234375, "__label__literature": 0.0004799365997314453, "__label__politics": 0.0006442070007324219, "__label__religion": 0.0004146099090576172, "__label__science_tech": 0.384521484375, "__label__social_life": 0.0002218484878540039, "__label__software": 0.0528564453125, "__label__software_dev": 0.54638671875, "__label__sports_fitness": 0.000255584716796875, "__label__transportation": 0.0004601478576660156, "__label__travel": 0.00016641616821289062}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 53308, 0.03327]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 53308, 0.19777]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 53308, 0.88857]], "google_gemma-3-12b-it_contains_pii": [[0, 5255, false], [5255, 11102, null], [11102, 16899, null], [16899, 19533, null], [19533, 24627, null], [24627, 30450, null], [30450, 34433, null], [34433, 37743, null], [37743, 43500, null], [43500, 50867, null], [50867, 53308, null]], "google_gemma-3-12b-it_is_public_document": [[0, 5255, true], [5255, 11102, null], [11102, 16899, null], [16899, 19533, null], [19533, 24627, null], [24627, 30450, null], [30450, 34433, null], [34433, 37743, null], [37743, 43500, null], [43500, 50867, null], [50867, 53308, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 53308, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 53308, null]], "pdf_page_numbers": [[0, 5255, 1], [5255, 11102, 2], [11102, 16899, 3], [16899, 19533, 4], [19533, 24627, 5], [24627, 30450, 6], [30450, 34433, 7], [34433, 37743, 8], [37743, 43500, 9], [43500, 50867, 10], [50867, 53308, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 53308, 0.13278]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
7c60cd699c657d94b42c8707f5cbde688fbcdcb0
The Speedup-Test: A Statistical Methodology for Program Speedup Analysis and Computation Sidi Touati, Julien Worms, Sébastien Briais May 2012 Abstract In the area of high performance computing and embedded systems, numerous code optimisation methods exist to accelerate the speed of the computation (or optimise another performance criteria). They are usually experimented by doing multiple observations of the initial and the optimised execution times of a program in order to declare a speedup. Even with fixed input and execution environment, program execution times vary in general. Hence different kinds of speedups may be reported: the speedup of the average execution time, the speedup of the minimal execution time, the speedup of the median, etc. Many published speedups in the literature are observations of a set of experiments. In order to improve the reproducibility of the experimental results, this article presents a rigorous statistical methodology regarding program performance analysis. We rely on well known statistical tests (Shapiro-wilk’s test, Fisher’s F-test, Student’s t-test, Kolmogorov-Smirnov’s test, Wilcoxon-Mann-Whitney’s test) to study if the observed speedups are statistically significant or not. By fixing $0 < \alpha < 1$ a desired risk level, we are able to analyse the statistical significance of the average execution time as well as the median. We can also check if $\Pr[X > Y] > \frac{1}{2}$, the probability that an individual execution of the optimised code is faster than the individual execution of the initial code. In addition, we can compute the confidence interval of the probability to get a speedup on a randomly selected benchmark that does not belong to the initial set of tested benchmarks. Our methodology defines a consistent improvement compared to the usual performance analysis method in high performance computing. We explain in each situation what are the hypothesis that must be checked to declare a correct risk level for the statistics. The Speedup-Test protocol certifying the observed speedups with rigorous statistics is implemented and distributed as an open source tool based on R software. keywords: Program performance evaluation and analysis, code optimisation, statistics. 1 Introduction The community of program optimisation, code performance evaluation, parallelisation and optimising compilation has published since many decades numerous research and engineering articles in major conferences and journals. These articles study efficient algorithms, strategies and techniques to accelerate program execution times, or optimise other performance metrics: Million Instructions Per Second (MIPS), code size, memory footprint, energy/power consumption, Giga Floating Point Operations Per Second (GFLOPS), etc. The efficiency of a code optimisation technique is generally published according to two principles, not necessarily disjoint. The first principle is to provide a mathematical proof given a theoretical model that the published code optimisation method is correct or/and efficient: this is the hardest part of research in computer science, since if the theoretical model is too simple, it would not represent real world, and if the model is too close to real world, mathematics become too complex to digest. A second principle for code optimisation in general is to propose and implement a code transformation technique and to practice it on a set of chosen benchmarks in order to evaluate its efficiency. This article concerns this last point: how can we use rigorous statistics to compare between the performances of two versions of the same program. What makes a binary program execution time vary on a modern multicore processor, even if we use the same data input, the same binary, the same execution environment? Here are some factors: 1. Intrinsic factors to the program itself: synchronisation functions, OS calls, etc. 2. Factors related to the execution environment: loaded machine, starting stack address in the memory, variable CPU frequency, dynamic voltage scaling, thread pinning on cores, etc. 3. Factors related to the processor micro-architecture: cache effects, out of order execution, automatic data prefetching, speculative execution, branch prediction, etc. 4. Factors related to the performance measurement: noise of measuring, imprecision of the measurement, etc. It is very difficult to control the complex combination of all the above influencing factors, especially on a supercomputer where the user is not allowed to have a root access to the machine. The community of high performance computing and simulation sometimes suffers from a difficulty in reproducing exactly the experimental scores. One of the multiple reasons is the variation of execution times of the same program given the same input and the same experimental environment. With the massive introduction of multicore architectures, we observe that the variations of execution times become exacerbated because of the complex dynamic features influencing the execution [1]. Consequently, if you execute a program (with a fixed input and experimental environment) n times, it is possible to obtain n distinct execution times. The mistake is to always assume that these variations are minor, and are stable in general. The variations of execution times is something that we observe everyday, we cannot neglect them, but we can analyse them statistically with rigorous methodologies. An usual behaviour in the community is to replace all the execution times by a single value, such as the minimum, the mean, the median or the maximum, losing important data on the variability and prohibiting to make statistics. This article presents a rigourous statistical protocol to compare between the performances of two code versions of the same application. While we consider in the article that a performance of a program is measured by its execution time, our methodology is general and can be applied to other metrics of performance (energy consumption for instance). It is important however to notice that our methodology applies for a continuous model of performance, not a discrete model. In a continuous model, we do not exclude integer values for measurements (that may be observed because of sampling), but we consider them as continuous data. We must also highlight that the name Speedup-Test does not rely on the usual meaning of statistical testing. Here, the term Test in the Speedup-Test title is employed because our methodology makes intensive usage of statistical testing. Here, the term Test in the Speedup-Test title is employed because our methodology makes intensive usage of proved statistical tests, we do not define a new one. Our article is organised as follows. Section 2 defines the background and notations needed in this document. Section 3 describes the core of our statistical methodology for the performance comparison between two code versions. Section 4 shows how we can estimate the chance that the code optimisation would provide a speedup on a program not belonging to the initial sample of benchmarks used for experiments. Section 5 gives a quick overview on the free software we released for this purpose, called SpeedupTest. Section 6 describes some test cases and experiments using SpeedupTest. Section 7 discusses some related work before we conclude. In order to improve the fluidity and the readability of the article, we detailed some notions in the appendix making the document self contained. 2 Background and notations Let $C$ be an initial code, let $C'$ be a transformed version after applying the program optimisation technique. Let $I$ be a fixed data input for the programs $C$ and $C'$. If we execute the program $C(I)$ $n$ times, it is possible that we obtain $n$ distinct execution times. Let $X$ be the random variable representing the execution time of $C(I)$. Let $X = \{x_1, \ldots, x_n\}$ be a sample of observations of $X$, i.e the set of the observed execution times when executing $C(I)$ $n$ times. The transformed code $C'$ can be executed $m$ times with the same data input $I$ producing $m$ execution times too. Similarly, let $Y$ be the random variable representing its execution time. Let $Y = \{y_1, \ldots, y_m\}$ be a sample of observations of $Y$, it contains the $m$ observed execution times of the code $C'(I)$. The theoretical mean of $X$ and $Y$ are noted $\mu_X$ and $\mu_Y$ respectively. The theoretical medians of $X$ and $Y$ are noted $\text{med}(X)$ and $\text{med}(Y)$. The theoretical variances are noted $\sigma_X^2$ and $\sigma_Y^2$. The cumulative distribution functions (CDF) are noted $F_X(a) = \mathbb{P}[X \leq a]$ and $F_Y(a) = \mathbb{P}[Y \leq a]$, where $\mathbb{P}[X \leq a]$ is the notation used for the probability that X ≤ a. The probability density functions are noted \( f_X(x) = \frac{dF_X(x)}{dx} \) and \( f_Y(y) = \frac{dF_Y(y)}{dy} \). Since \( X \) and \( Y \) are two samples, their sample means are noted \( \bar{X} = \frac{1}{n} \sum_{i=1}^{n} x_i \) and \( \bar{Y} = \frac{1}{m} \sum_{i=1}^{m} y_i \) respectively. The sample variances are noted \( s_X^2 \) and \( s_Y^2 \). The sample medians of \( X \) and \( Y \) are noted \( \text{med}(X) \) and \( \text{med}(Y) \). After collecting \( X \) and \( Y \) (the sets of execution times of the codes \( C(I) \) and \( C'(I) \) respectively for the same data input \( I \)), a simple definition of the speedup [2] sets it as \( \frac{X}{Y} \). In reality, since \( X \) and \( Y \) are random variables, the definition of a speedup becomes more complex. Ideally, we must analyse the probability density functions of \( X \) and \( Y \). Below our opinions on each of the above speedups: 1. The observed speedup of the minimal execution times: \[ \text{spmin}(C, I) = \frac{\min_i x_i}{\min_j y_j} \] 2. The observed speedup of the mean (average) execution times: \[ \text{spmean}(C, I) = \frac{\bar{X}}{\bar{Y}} = \frac{\sum_{1 \leq i \leq n} x_i}{\sum_{1 \leq j \leq m} y_j} \times \frac{m}{n} \] 3. The observed speedup of the median execution times: \[ \text{spmedian}(C, I) = \frac{\text{med}(X)}{\text{med}(Y)} \] Usually, the community publishes the best speedup among those observed, without any guarantee of reproducibility. Below our opinions on each of the above speedups: - Regarding the observed speedup of the minimal execution times, we do not advise to use it for many reasons. Appendix A of [3] explains why using the observed minimal execution time is not a fair choice regarding the chance of reproducing the result. - Regarding the observed speedup of the mean execution time, it is well understood in statistical analysis but remains sensitive to outliers. Consequently, if the program under optimisation study is executed few times by an external user, the latter may not able to observe the reported average. However, the average execution time is commonly accepted in practice. - Regarding the observed speedup of the median execution times, it is the one that is used by the SPEC organisation [4]. Indeed, the median is a better choice for reporting speedups, because the median is less sensitive to outliers. Furthermore, some practical cases show that the distribution of the execution times are skewed, making the median a better candidate for summarising the execution times into a single number. The previous speedups are defined for a single application with a fixed data input \( C(I) \). When multiple benchmarks are tested, we are sometimes faced to the need of reporting an overall speedup for the whole set of benchmarks. Since each benchmark may be very different from each other or may be of distinct importance, sometimes a weight \( W(C_j) \) is associated to a benchmark \( C_j \). After running and measuring the speed of every benchmark (with multiple runs of the same benchmark), we define \( \text{ExecutionTime}(C_j, I_j) \) as the considered execution time of the code \( C_j \) having \( I_j \) as data input. \( \text{ExecutionTime}(C_j, I_j) \) replaces all the observed execution times of \( C_j(I_j) \) with one of the usual functions (mean, median, min) i.e., the mean or the median or the min of the observed execution times of the code \( C_j \). The overall observed speedup of a set of \( b \) benchmarks is defined by the following equation: \[ S = \frac{\sum_{j=1}^{b} W(C_j) \times \text{ExecutionTime}(C_j, I_j)}{\sum_{j=1}^{b} W(C_j) \times \text{ExecutionTime}(C_j', I_j)} \] This speedup is a global measure of the acceleration of the execution time. Alternatively, some users prefer to consider \( G \) the overall gain, which is a global measure of how much (in percentage) the overall execution time has been reduced: \[ G = 1 - \frac{\sum_{j=1}^{b} W(C_j) \times \text{ExecutionTime}(C_j, I_j)}{\sum_{j=1}^{b} W(C_j) \times \text{ExecutionTime}(C_0, I_j)} = 1 - \frac{1}{S} \] (2) Depending on which function has been used to compute \( \text{ExecutionTime}(C_j, I_j) \), we speak about the overall speedup and gain of the average execution time, median execution time or minimal observed execution time. All the above speedups are observation metrics based on samples that do not guarantee their reproducibility since we are not sure about their statistical significance. The next section studies the question for the average and median execution times. Studying the statistical significance of the speedup of the minimal execution time remains a difficult open problem in nonparametric statistical theory (unless the probability density function is known, which is not the case in practice). 3 Analysing the statistical significance of the observed speedups The observed speedups are performance numbers observed once (or multiple times) on a sample of executions. Does this mean that other executions would conclude with similar speedups? How can we be sure about this question if no mathematical proof exists, and with which confidence level? This section answers this question and shows that we can test if \( \mu_X > \mu_Y \) and if \( \text{med}(X) > \text{med}(Y) \). For the rest of this section, we define \( 0 < \alpha < 1 \) as the risk (probability) of error, which is the probability of announcing a speedup that does not exist really (even if it is observed on a sample). Conversely, \( (1 - \alpha) \) is the usual confidence level. Usually, \( \alpha \) is a small value (for instance \( \alpha = 5\% \)). The reader must be aware that in statistics, the risk of error is included in the model, so we are not always able to decide between two contradictory situations (contrary to logic where a quantity cannot be true and false in the same time). Furthermore, the abuse of language defines \( (1 - \alpha) \) as a confidence level, while this is not exactly true in the mathematical sense. Indeed, there are two types of risks when we use statistical tests; Appendix A describes these two risks and discusses the notion of confidence level. Often, we say that a statistical test (normality test, Student’s test, etc.) concludes favourably by a confidence level \( (1 - \alpha) \) because it didn’t succeed to reject the tested hypothesis with a risk level equal to \( \alpha \). When a statistical test does not reject an hypothesis with a risk equal to \( \alpha \), there is usually no proof that the contrary is true with a confidence level of \( (1 - \alpha) \). This way of reasoning is admitted for all statistical tests since in practice it works well. 3.1 The speedup of the observed average execution time Having two samples \( X \) and \( Y \), deciding if \( \mu_X > \mu_Y \) the theoretical mean of \( X \) is higher than \( \mu_Y \) the theoretical mean of \( Y \) with a confidence level \( 1 - \alpha \) can be done thanks to the Student’s t-test [5]. In our situation, we use the one-sided version of the Student’s t-test and not the two sided version (since we want to check whether the mean of \( X \) is higher than the mean of \( Y \), not to test if they are simply distinct). Furthermore, the observation \( x_i \in X \) does not correspond to another observation \( y_j \in Y \), so we use the unpaired version of the Student’s t-test. 3.1.1 Remark on the normality of the distributions of \( X \) and \( Y \) The mathematical proof of the Student’s t-test is valid for Gaussian distributions only [6, 7]. If \( X \) and \( Y \) are not from Gaussian distributions (normal is synonymous to Gaussian), then the Student’s t-test is known to stay robust for large samples (thanks to the central limit theorem), but the computed risk \( \alpha \) is not exact [7, 6]. If \( X \) and \( Y \) are not normally distributed and are small samples, then we cannot conclude with the Student’s t-test. 3.1.2 Remark on the variances of the distributions of X and Y In addition to the Gaussian nature of X and Y, the original Student’s t-test was proved for populations with the same variance ($\sigma_X^2 \approx \sigma_Y^2$). Consequently, we also need to check whether the two populations X and Y have the same variance by using the Fisher’s F-test for instance. If the Fisher’s F-test concludes that $\sigma_X^2 \neq \sigma_Y^2$, then we must use a variant of Student’s t-test that considers Welch’s approximation of the degree of freedom. 3.1.3 The size needed for the samples X and Y The question now is to know what is a large sample. Indeed, this question is complex and cannot be answered easily. In [8, 5], a sample is said large when its size exceeds 30. However, that size is well known to be arbitrary, it is commonly used for a numerical simplification of the test of Student\(^1\). Note that $n > 30$ is not a size limit needed to guarantee the robustness of the Student’s t-test when the distribution of the population is not Gaussian, since the t-test remains sensitive to outliers in the sample. Appendix C in [3] gives a discussion on the notion of large sample. In order to set the ideas, let us consider that $n > 30$ defines the size of large samples: some books devoted to practice [8, 5] write a limit of 30 between small ($n \leq 30$) and large ($n > 30$) samples. 3.1.4 Using the Student’s t-test correctly $H_0$, the null hypothesis that we try to reject (in order to declare a Speedup) by using Student’s t-test, is that $\mu_X \leq \mu_Y$, with an error probability (of rejecting $H_0$ when $H_0$ is true, i.e. when there is no Speedup) equal to $\alpha$. If the test rejects this null hypothesis, then we can accept $H_a$, the alternative hypothesis $\mu_X > \mu_Y$ with a confidence level $1 - \alpha$ (Appendix A explains the exact meaning of the term confidence level used in this article). The Student’s t-test computes a $p$-value, which is the smallest probability of error to reject the null hypothesis. If $p$-value $\leq \alpha$, then the Student’s t-test rejects $H_0$ with a risk level lower than $\alpha$. Hence we can accept $H_a$ with a confidence level $(1 - \alpha)$. Appendix A gives more details on hypothesis testing in statistics, and on the exact meaning of the confidence level. As explained before, using correctly the Student’s t-test is conditioned by: 1. If the two samples are large enough (say $n > 30$ and $m > 30$), using the Student’s t-test is admitted but the computed risk level $\alpha$ may not be preserved if the underlying distributions of X and Y are too far from being normally distributed (page 71 of [9]). 2. If one of the two samples is small (say $n \leq 30$ or $m \leq 30$) (a) If $X$ or $Y$ does not follow Gaussian distribution with a risk level $\alpha$, then we cannot conclude about the statistical significance of the observed speedup of the average execution time. (b) If $X$ and $Y$ follow Gaussian distributions with a risk level $\alpha$ then: • If $X$ and $Y$ have the same variance with a risk level $\alpha$ (tested with Fisher’s F-test) then use the original procedure of the Student’s t-test. • If $X$ and $Y$ do not have the same variance with a risk level $\alpha$ then use the Welch’s version of the Student’s t-test procedure. The detailed description of the Speedup-Test protocol for the average execution time is illustrated in Figure 1. The problem with the average execution time is its sensibility to outliers. Furthermore, the average is not always a good indicator of the observed execution time felt by the user. In addition, the test of Student has been proved only for Gaussian distributions, while it is rare in practice to observe them for program execution times [1]: the usage of the Student’s t-test for non Gaussian distributions is admitted for large samples but the risk level is no longer guaranteed. The median is generally preferable to the average for summarising the data into a single number. The next section shows how to check if the speedup of the median is statistically significant. --- \(^1\)When $n > 30$, the Student distribution begins to be correctly approximated by the standard Gaussian distribution, allowing to consider $z$ values instead of $t$ values. This simplification is out of date, it has been made in the past when statistics used to use pre-computed printed tables. Nowadays, computers are used to numerically compute real values of all distributions, so we do no longer need to simplify the Student’s t-test for $n > 30$. For instance, the current implementation of the Student’s t-test in the statistical software R does not distinguish between small and large samples, contrary to what is explained in [5, 8]. 1) Two samples of execution times \( X = \{x_1, \ldots, x_n\} \) \( Y = \{y_1, \ldots, y_m\} \) 2) Risk level 0 < \( \alpha \) < 1 The variant here is to use the Welch's version of the Student's t-test procedure. ### Normality Check - Perform normality check for \( X \) and \( Y \) with the risk level \( \alpha \) - Not enough data to conclude. Perform more than 30 runs for \( X \) - Not enough data to conclude. Perform more than 30 runs for \( Y \) - \( X \) and \( Y \) are normal? - Perform a two-sided and unpaired Fisher's F-test with risk level \( \alpha \). - Null hypothesis \( H_0: \sigma_X^2 = \sigma_Y^2 \) - \( p\)-value \( \leq \alpha \)? - \( H_0 \) is rejected. Declare that the observed speedup of the average execution time is statistically significant - \( H_0 \) is accepted. Declare that the observed speedup of the average execution time is not statistically significant ### Additional Tests - \( n \leq 30 \) and \( X \) not normal? - Perform a one-sided and unpaired Student's t-test with risk level \( \alpha \). - Null hypothesis \( H_0: \mu_X \leq \mu_Y \) - Alternative hypothesis \( H_a: \mu_X > \mu_Y \) - \( p\)-value \( \leq \alpha \)? - \( H_0 \) is rejected. Declare that the observed speedup of the mean execution time is statistically significant ### Warning - \( 1 - \alpha \) may not be the correct confidence level Figure 1: The Speedup Test for the Average Execution Time 3.2 The speedup of the observed median execution time, as well as individual runs This section presents the Wilcoxon-Mann-Whitney [9] test, a robust statistical test to check if the median execution time has been reduced or not after a program transformation. In addition, the statistical test we are presenting checks also whether \( P[X > Y] > 1/2 \), as is proved in Appendix D of [3] (page 35): this is a very good information for the real speedup felt by the user (\( P[X > Y] > 1/2 \) means that there is more chance that a single random run of the optimised program will be faster than a single random run of the initial program). Contrary to the Student’s t-test, the Wilcoxon-Mann-Whitney test does not assume any specific distribution for \( X \) and \( Y \). The mathematical model (page 70 in [9]) imposes that the distributions of \( X \) and \( Y \) differ only by a location shift \( \Delta \), in other words that \[ F_Y(t) = P[Y \leq t] = F_X(t + \Delta) = P[X \leq t + \Delta] \quad (\forall t) \] Under this model (known as the location model), the location shift equals \( \Delta = \text{med}(X) - \text{med}(Y) \) (as well as \( \Delta = \mu_X - \mu_Y \) in fact) and \( X \) and \( Y \) consequently do not differ in dispersion. If this constraint is not satisfied, then as admitted for the Student’s t-test, the Wilcoxon-Mann-Whitney test can still be used for large samples in practice but the announced risk level may not be preserved. However, two advantages of this model is that the normality is not needed any more and that assumptions on the sign of \( \Delta \) can be readily interpreted in terms of \( P[X > Y] \). In order to check if \( X \) and \( Y \) satisfy the mathematical model of the Wilcoxon-Mann-Whitney test, a possibility is to use the Kolmogorov-Smirnov’s two sample test [10] as described below. 3.2.1 Using the test of Kolmogorov-Smirnov first The object is to test the null hypothesis \( H_0 \) of equality of the distributions of the variables \( X - \text{med}(X) \) and \( Y - \text{med}(Y) \), using the Kolmogorov-Smirnov two-sample test applied to the observations \( x_i - \text{med}(X) \) and \( y_j - \text{med}(Y) \). The Kolmogorov-Smirnov’s test computes a \( p \)-value: if \( p \)-value \( \leq \alpha \), then \( H_0 \) is rejected with a risk level \( \alpha \). That is, \( X \) and \( Y \) do not satisfy the mathematical model needed by the Wilcoxon-Mann-Whitney test. However, as said before, we can still use the test in practice for sufficiently large samples but the risk level may not be preserved [9]. 3.2.2 Using the test of Wilcoxon-Mann-Whitney As done previously with the Student’s t-test for comparing between two averages, we want here to check whether the median of \( X \) is greater than the median of \( Y \), and if \( P[X > Y] > \frac{1}{2} \). This amounts to use the one-sided variant of the test of Wilcoxon-Mann-Whitney. In addition, since the observation \( x_i \) from \( X \) does not correspond to an observation \( y_j \) from \( Y \), we use the unpaired version of the test. We set the null hypothesis \( H_0 \) of Wilcoxon-Mann-Whitney’s test as \( F_X \geq F_Y \), and the alternative hypothesis as \( H_a : F_X < F_Y \). As a matter of fact, the (functional) inequality \( F_X < F_Y \) means that \( X \) tends to be greater than \( Y \). Note in addition that, under the location shift model, \( H_0 \) is equivalent to the fact that the location shift \( \Delta \) is \( > 0 \). The Wilcoxon-Mann-Whitney test computes a \( p \)-value. If \( p \)-value \( \leq \alpha \), then \( H_0 \) is rejected. That is, we admit \( H_0 \) with a confidence level \( 1 - \alpha \): \( F_X > F_Y \). This amounts to declaring that the observed speedup of the median execution times is statistically significant, \( \text{med}(X) > \text{med}(Y) \) with a confidence level \( 1 - \alpha \), and \( P[X > Y] > \frac{1}{2} \). If the null hypothesis is not rejected, then the observed speedup of the median is not considered to be statistically significant. Figure 2 illustrates the Speedup-Test protocol for the median execution time. The next section studies the probability to get a statistical significant speedup on any program that does not necessarily belong to the initial set of tested benchmarks. Perform more than 30 runs for X and Y Not enough data to conclude. 1) Two samples of execution times \[ X = \{ x_1, \ldots, x_n \} \] \[ Y = \{ y_1, \ldots, y_m \} \] 2) Risk level \( 0 < \alpha < 1 \) Perform a two-sided and unpaired Kolmogorov-Smirnov test with risk level \( \alpha \) Null hypothesis \( H_0 \): \( X \) and \( Y \) are from the same distribution - \( p\)-value < \( \alpha \) - \( H_0 \) is rejected. - \( \text{correct model} \leftarrow \text{false} \) - \( \text{Not enough data to conclude. Perform more than 30 runs for X and Y} \) - \( \text{No} \) Null hypothesis \( H_0 \): \( X - \text{med}(X) \) and \( Y - \text{med}(Y) \) are from the same distribution - \( \alpha \leq 30 \) or \( m \leq 30 \)? - \( \text{Yes} \) - \( p\)-value < \( \alpha \) - \( H_0 \) is accepted. - \( \text{correct model} \leftarrow \text{true} \) - \( \text{No} \) Perform a one-sided and unpaired Wilcoxon-Mann-Whitney test with risk level \( \alpha \) Null hypothesis \( H_0 \): \( F_X \geq F_Y \) Alternative hypothesis \( H_a \): \( F_X < F_Y \) - \( p\)-value < \( \alpha \) - \( H_0 \) is rejected. Declare that the observed speedup of the median execution time is statistically significant. - \( P[X > Y] > 1/2 \) - \( H_0 \) is accepted. Declare that the speedup of the median execution time is not statistically significant. Declare the confidence level \( 1 - \alpha \) Warning: \( 1 - \alpha \) may not be the correct confidence level Declare the confidence level \( 1 - \alpha \) Figure 2: The Speedup Test for the Median Execution Time 4 Evaluating the proportion of accelerated benchmarks by a confidence interval Computing the overall performance gain or speedup for a sample of $b$ programs does not allow to estimate the quality nor the efficiency of the code optimisation technique. In fact, within the $b$ programs, only a fraction of $a$ benchmarks have got a speedup, and $b-a$ programs have got a slowdown. In this section, we want to analyse the probability $p$ to get a statistically significant speedup if we apply a code transformation. If we consider a sample of $b$ programs only, one could say that the chance to observe a speedup is $\frac{a}{b}$. But this computed chance is observed on a sample of $b$ programs only. So what is the confidence interval of $p$? The following paragraphs answers this question. In probability theory, we can study the random event \{The program is accelerated with the code optimisation under study\}. This event has two possible values, true or false. So it can be represented by a Bernoulli variable. In order to make correct statistics, it is very important that the initial set of $b$ benchmarks must be selected randomly from a huge database of representative benchmarks. If the set of $b$ benchmarks are selected manually and not randomly, then there is a bias in the sample and the statistics we compute in this section are wrong. For instance, if the set of $b$ programs are retrieved from a well known benchmarks (SPEC or others), then they cannot be considered as sufficiently random, because well known benchmarks have been selected manually by a group of people, not selected randomly from a huge database of programs. If we select randomly a sample of $b$ representative programs as a sample of benchmarks, we can measure the chance of getting the fraction of accelerated programs as $\frac{a}{b}$. The higher this proportion is, the better the quality of the code optimisation would be. In fact, we want to evaluate whether the code optimisation technique is beneficial for a large fraction of programs. The proportion $C = \frac{a}{b}$ has been observed on a sample of $b$ programs only. There are many techniques for estimating the confidence interval for $p$ (with a risk level $\alpha$). The simplest and most commonly used formula relies on approximating the binomial distribution with a normal distribution. In this situation, the confidence interval is given by the equation $C \pm r$, where $$ r = z_{1-\alpha/2} \times \sqrt{\frac{C(1-C)}{b}} $$ In other words, the confidence interval of the proportion is equal to $[C - r, C + r]$. Here, $z_{1-\alpha/2}$ represents the value of the quartile of order $1 - \alpha/2$ of the standard normal distribution ($\mathbb{P}[N(0,1) > z] = \frac{\alpha}{2}$). This value is available in a known precomputed table and in many softwares (Table A.2 in [5]). We should notice that the previous formula of the confidence interval of the proportion $C$ is accurate only when the value of $C$ are not too close from 0 or 1. A frequently cited rule of thumb is that the normal approximation works well as long as $a - \frac{a^2}{b} > 5$, as indicated for instance in [6] (Section 2.7.2). However, in a recent contribution [11], that condition was discussed and criticised. The general subject of choosing appropriate sample size which ensures an accurate normal approximation, was discussed in chapter VII 4, example (h) of the reference book [12]. When the approximation of the binomial distribution with a normal one is not accurate, other techniques may be used, that will not be presented here. The R software has an implemented function that computes the confidence interval of a proportion based on the normal approximation of a binomial distribution, see the example below. **Example (done with R)** Having $b = 30$ benchmarks selected randomly from a huge set of representative benchmarks, we obtained a speedup on only $a = 17$ cases. We want to compute the confidence interval for $p$ around the proportion $C=17/30=0.5666$ with a risk level equal to $\alpha = 0.1 = 10\%$. We easily estimate the confidence interval of $C$ using the R software as follows. ```r > prop.test(17, 30, conf.level=0.90) ``` 90 percent confidence interval: 0.4027157 0.7184049 Since \( a - \frac{a^2}{b} = 17 - \frac{17^2}{30} = 7.37 > 5 \), the computed confidence interval of the proportion is accurate. Note that this confidence interval is invalid if the initial set of \( b = 30 \) benchmarks was not randomly selected among a huge number of representative benchmarks. The above test allows us to say that we have 90% of chance that the proportion of accelerated programs is between 40.27% and 71.87%. If this interval is too wide for the purpose of the study, we can reduce the confidence level as a first straightforward solution. For instance, if I consider \( \alpha = 50\% \), the confidence interval of the proportion becomes [49.84%, 64.23%]. The next formula[5] gives the minimal number \( b \) of benchmarks to be selected randomly if we want to estimate the proportion confidence interval with a precision equal to \( r\% \) with a risk level \( \alpha \): \[ b \geq \left( z_{1-\alpha/2} \right)^2 \times \frac{C(1 - C)}{r^2} \] **Example (done with R) 2** In the previous example, we have got an initial proportion equal to \( C = 17/30 = 0.5666 \). If we want to estimate the confidence interval with a precision equal to 5% with a risk level of 5%, we put \( r = 0.05 \) and we read in the quartiles tables \( z_{1-0.05/2} = z_{0.975} = 1.960 \). The minimal number of benchmarks to observe is then equal to: \( b \geq 1.960^2 \times \frac{0.566 \times (1 - 0.566)}{0.05^2} = 377.46 \). We need to randomly select 378 benchmarks in order to assert that we have a chance of 95% that the proportions of accelerated programs are in the interval 0.566 ± 5%. ## 5 The Speedup-Test software The performance evaluation methodology described in this article has been implemented and automated in a software called SpeedupTest. It is a command line software that works on the shell: the user specifies a configuration file, then the software reads the data, checks if the observed speedups are statistically significant and prints full reports. SpeedupTest is based on \( \text{R} \) [13], it is available as a free software in [3]. The programming language is a script (\( \text{R} \) and \( \text{bash} \)), so the code itself is portable across multiple operating systems and hardware platforms. We have tested it successfully on linux, unix and mac OS environments (other platforms may be used). The input of the software is composed of: - A unique configuration file in CSV format: it contains a line per benchmark under study. For each benchmark, the user has to specify the file name of the initial set of performances observations (\( X \) sample) and the optimised performances (\( Y \) sample). Optionally, a weight (\( W(C) \)) and a confidence level can be defined individually per benchmark or globally for all benchmarks. It is possible to ask SpeedupTest to compute the highest confidence level per benchmark to declare statistical significance of speedups. - For each benchmark (two code versions), the collected observed performance data has to be saved in two distinct raw text files: a file for the \( X \) sample and another for the \( Y \) sample. The reason why we splitted the input into multiple files is to simplify the configuration of data analysis. Thanks to our choice, making multiple performance comparisons require modifications in the CSV configuration file only, the input data files remain unchanged. SpeedupTest accepts some optional parameters in the command line, such as a global confidence level (to be applied to all benchmarks), weights to be applied on benchmarks and required precision for confidence intervals (not detailed in this article but explained in [3]). The output of the software is composed of four distinct files: 1. A global report that prints the overall speedups and gains of all the benchmarks. 2. A file that details the individual speedup per benchmark, its confidence level and its statistical significance. 3. A warning file that explains for some benchmark why the observed speedup is not statistically significant. 4. An error file that prints any misbehaviour of the software (for debugging purpose). The user manual of the software, sample data and demos are present in [3]. The next section presents an experimental use of the software. The next section presents our implementation of the performance evaluation methodology. 6 Experiments and applications Let first describe the set of program benchmarks, their source codes are written in C and Fortran: 1. SPEC CPU 2006: a set of 17 sequential applications. They are executed using the standard ref data input. 2. SPEC OMP 2001: a set of 9 parallel OpenMP applications. Each application can be run in a sequential mode, or in a parallel mode with 1, 2, 4, 6 or 8 threads respectively. They are executed using the standard train data input. In our experiences, we consider that all the benchmarks have equal weight (\( \forall k, W(C_k) = 1 \)). The binaries of the above benchmarks have been generated using two distinct compilers of equivalent release date: gcc 4.1.3 and Intel icc 11.0. These compiler versions were the ones available when our experimental studies have been done. Newer compiler versions may be available currently and in the future. Other compilers may be used. For instance, a typical future work would be to make a fair performance comparison between multiple parallelising compilers. Please note that our experiments have no influence on the statistical methodology we describe, since we base our work on mathematics not on experimental performance data. Any performance data can be analysed, the versions of the tools that are used to log performance data have no incidence on the theory behind. We experimented multiple levels (compiler flags and options) of code optimisations done by both compilers. Our experiments have been conducted on a Linux workstation (Intel Core 2, two quad-core Xeon processors, 2.33 GHz.). For each binary version, we repeated the execution of the benchmark 31 times and recorded the measurement. For a complete description of the experimental setup and environment used to collect the performance data, please refer to [1]. The data are released publicly in [3]. This section is more related on analysing the data than on the way they have been collected. Next, we describe three possible applications of the SpeedupTest software. Note that applying the SpeedupTest in every section below requires less than 2 seconds of computation on a MacBook pro (2.53 GHz Intel Core 2 Duo). The next section provides an initial set of experiments that compare between the performance of different compiler flags. 6.1 Comparing between the performances of compiler optimisation levels We consider the set of SPEC CPU 2006 (17 programs). Every source code is compiled using gcc 4.1.3 with three compiler optimisation flags: -O0 (no optimisation), -O1 (basic optimisations) and -O3 (aggressive optimisations). That is, we generate three different binaries per benchmark. We want to test if the optimisation levels -O1 and -O3 are really efficient compared to -O0. This amount to consider 34 couples of comparisons: for every benchmark, we compare the performance of the binary generated by -O1 vs. -O0 and the one generated by -O3 vs. -O0. The observed performances of the benchmarks reported by the tool are: ``` Overall gain (ExecutionTime=mean) = 0.464 Overall speedup (ExecutionTime=mean) = 1.865 Overall gain (ExecutionTime=median) = 0.464 Overall speedup (ExecutionTime=median) = 1.865 ``` The overall observed gain and speedups are identical here because in this set of experiments, the observed median and mean execution times of every benchmark were almost identical (with three digits of precision). Such observations advocate that the binaries generated thanks to optimisation levels -O1 and -O3 are really efficient compared to -O0. In order to be confident for such conclusion, we need to rely on the statistical significance of the individual speedups per benchmarks (for both median and average execution times). They have all been accepted with a confidence level equal to 95%, i.e. with a risk level of 5%. Our conclusions remain the same even if reduce the confidence level to 1%, i.e; with a risk level of 99%. The tool also computes the following information: The observed proportion of accelerated benchmarks (speedup of the mean) $a/b = 34/34 = 1$ The confidence level for computing proportion confidence interval is 0.9. Proportion confidence interval (speedup of the mean) = $[0.901; 1]$. Warning: this confidence interval of the proportion may not be accurate because the validity condition $(a(1-a/b)>5)$ is not satisfied. Here the tool says that the probability that the compiler optimisation option `-O3` would produce a speedup (versus `-O1`) of the mean execution time belongs to the interval $[0.901; 1]$. However, as noted by the tool, this confidence interval may not be accurate because the validity condition $a - \frac{a^2}{b} > 5$ is not satisfied. Remind that the computed confidence interval of the proportion is invalid if $b$ the experimented set of benchmarks is not randomly selected among a huge number of representative benchmarks. Since we experimented selected benchmarks from SPEC CPU 2006, this condition is not satisfied so we cannot advocate for the precision of the confidence interval. Instead of analysing the speedups obtained by compiler flags, someone could obtain speedups by launching parallel threads. The next section studies this aspect. ### 6.2 Testing the performances of parallel executions of OpenMP applications In this section, we investigate the efficiency of a parallel execution against a sequential one. We consider the set of 9 SPEC OMP 2001 applications. Every application is executed with 1, 2, 4, 6 and 8 threads respectively. We compare every version to the sequential code (no threads). The binaries have been generated with the Intel icc 11.0 compiler using the flag `-O3`. So we have to conduct a comparison between 45 couples of benchmarks. The observed performances of the benchmarks reported by the tool are: - Overall gain (ExecutionTime=mean) = 0.441 - Overall speedup (ExecutionTime=mean) = 1.79 - Overall gain (ExecutionTime=median) = 0.443 - Overall speedup (ExecutionTime=median) = 1.797 These overall performance metrics clearly advocate that a parallel execution of the application is faster than a sequential execution. However, by analysing the statistical significance of the individual speedups with a risk level of 5%, we find that: - As expected, none of the single threaded versions of the code was faster than the sequential version: this is because a sequential version has no thread overhead, the compiler is able to better optimise the sequential code compared to the single threaded code. - Strange enough, the speedup of the average and median execution times has been rejected in 5 cases (with 2 threads or more). In other words, the parallel version of the code in 5 cases is not faster (in average and median) than the sequential code. Our conclusions remains the same if we increase the risk level to 20% or if we use the gcc 4.1.3 compiler instead of icc 11.0. The tool also computes the following information: The observed proportion of accelerated benchmarks (speedup of the mean) $a/b = 31/45 = 0.689$ The confidence level for computing proportion confidence interval is 0.95. Proportion confidence interval (speedup of the mean) = $[0.532; 0.814]$. The minimal needed number of randomly selected benchmarks is 330 (in order to have a precision r=0.05). Here the tool says that: 1. The probability that a parallel version of an OpenMP application would produce a speedup (of the average execution time) against the sequential version belongs to the interval $[0.532; 0.814]$. 2. If this probability confidence interval is not tight enough, and if the user requires a confidence interval with a precision of $r = 5\%$, then the user has to make experiments on a minimal number of randomly selected benchmarks $b = 330$. Let us now make a statistical comparison between the program performance obtained by two distinct compilers. That is, we want to check if ICC 11.0 produces more efficient codes compared to GCC 4.1.3. ### 6.3 Comparing between the efficiency of two compilers In this last section of performance evaluation, we want to answer the question: which compiler between GCC 4.1.3 and Intel ICC 11.0 is the best on an Intel Dell workstation? Both compilers have similar release date and are both tested with aggressive code optimisation level -O3. A compiler or a computer architecture expert would say, clearly, the Intel ICC 11.0 compiler would generate faster codes anyway. The reason is that GCC 4.1.3 is a free general purpose compiler that is designed for almost all processor architectures, while ICC 11.0 is a commercial compiler designed for intel processors only; the code optimisations of ICC 11.0 are specially focused for the workstation on which the experiments have been conducted, while GCC 4.1.3 has less focus on Intel processors. The experiments have been conducted using the set of 9 SPEC OMP 2001 applications. Every application is executed in a sequential mode (without thread), or in parallel mode (with 1, 2, 4, 6 and 8 threads respectively). We compare between the performances of the binaries generated by ICC 11.0 versus the ones generated by GCC 4.1.3. So we make a comparison between 54 couples. The observed performances of the benchmarks reported by the tool are: - Overall gain (ExecutionTime=mean) = 0.14 - Overall speedup (ExecutionTime=mean) = 1.162 - Overall gain (ExecutionTime=median) = 0.137 - Overall speedup (ExecutionTime=median) = 1.158 These overall performance metrics clearly advocate that ICC 11.0 generated faster codes than GCC 4.1.3. However, by analysing the statistical significance of the individual speedups, we find that: - With a risk level of 5%, the speedup of the average execution time is rejected in 14 cases among 54. If the risk is increased to 20%, the number of rejections decreases to 13 cases. With a risk of 99%, the number of rejections decreases to 11 cases. - With a risk level of 5%, the speedup of the median execution time is rejected in 13 cases among 54. If the risk is increased to 20%, the number of rejections decreases to 12 cases. With a risk of 99%, the number of rejections remains as 12 cases among 54. Here we can conclude that the efficiency of the GCC 4.1.3 compiler is not as bad as thought, but is still under the level of efficiency of a commercial compiler like ICC 11.0 compiler. The tool also computes the following information: - The observed proportion of accelerated benchmarks (speedup of the median) $a/b = 41/54 = 0.759$ - The confidence level for computing proportion confidence interval is 0.95. - Proportion confidence interval (speedup of the median) = [0.621; 0.861] - The minimal needed number of randomly selected benchmarks is 281 (in order to have a precision $r=0.05$). <table> <thead> <tr> <th>Benchmark family</th> <th>Average execution times</th> <th>Median execution times</th> </tr> </thead> <tbody> <tr> <td>SPEC CPU 2006 (icc, 34 pairs)</td> <td>0</td> <td>0</td> </tr> <tr> <td>SPEC OMP (icc, 45 pairs)</td> <td>14</td> <td>14</td> </tr> <tr> <td>SPEC OMP (gcc, 45 pairs)</td> <td>13</td> <td>14</td> </tr> </tbody> </table> Table 1: Number of non statistically significant speedups in the tested benchmarks Here the tool says that: 1. The probability that *icc* 11.0 beats *gcc* 4.1.3 (produces a speedup of the median execution time) on a randomly selected benchmark belongs to the interval [0.621; 0.861]; 2. If this probability confidence interval is not tight enough, and if the user requires a confidence interval with a precision of \( r = 5\% \), then the user has to make experiments on a minimal number of randomly selected benchmarks \( b = 281 \)! ### 6.4 The impact of the SpeedupTest protocol over some observed speedups In this section, we give a synthesis of our experimental data to show that some observed speedups (that we call "hand made") are not statistically significant. In each benchmark family, we counted the number of non statistically significant speedups among those that are "hand made". Table 1 gives a synthesis. The first column describes the benchmarks family, with the used compiler and the number of observed speedups (pairs of samples). The second column provides the number of non statistically significant speedups of the average execution times. The last column provides the number of non statistically significant speedups of the median execution times. As observed in the table, we analysed 34 pairs of samples for the SPEC CPU 2006 applications compiled with *icc*. All the observed speedups are statistically significant. When the program execution times are less stable, such as in the case of SPEC OMP 2006 (as highlighted in [1]), some observed speedups are not statistically significant. For instance, 14 speedups of the average execution times (among 45 observed ones) are not statistically significant (see the third line of Table 1). Also, 13 observed speedups of the median execution times (among 45 observed ones) are not statistically significant (see the last line of Table 1). ### 7 Related work and discussion #### 7.1 Observing execution times variability The literature contains some experimental research highlighting that program execution times are sometimes increasingly variable or unstable. In the article of *raced profiles* [14], the performance optimisation system is based on observing the execution times of code fractions (functions, and so on). The mean execution time of such code fraction is analysed thanks to the Student’s t-test, aiming to compute a confidence interval for the mean. This previous article does not fix the data input of each code fraction: indeed, the variability of execution times when the data input varies cannot be analysed with the Student’s t-test. Simply because when data input varies, the execution time varies inherently based on the algorithmic complexity, and not on the structural hazards. Program execution times variability has been shown to lead to wrong conclusions if some execution environment parameters are not kept under control [15]. For instance, the experiments on sequential applications reported in [15] show that the size of Unix shell variables and the linking order of object codes both may influence the execution times. Recently, we published in [1] an empirical study of performance variation in real world benchmarks with fixed data input. Our study concludes three points: 1) The variability of execution times of long running sequential applications (SPEC CPU 2000 and 2006) is marginal. 2) The variability of execution times of long running parallel applications such as SPEC OMP 2001 is important on multicore processors, such variability cannot be neglected. 3) Almost all the samples of execution times do not follow a Gaussian distribution, which means that the Student’s t-test, as well as mean confidence intervals, cannot be applied on small samples. ### 7.2 Program performance evaluation in presence of variability In the field of code optimisation and high performance computing, most of the published articles declare observed speedups as defined in Sect. 2. Unfortunately, few studies based on rigorous statistics are really conducted to check if the observations of the code performance improvements are statistically significant or not. Program performance analysis and optimisation may rely on two well known books that explain digest statistics to our community [5, 8] in an accessible way. These two books are good introductions for doing fair statistics for analysing performance data. Based on these two books, previous work on statistical program performance evaluation have been published [16]. In the later article, the authors rely on the Student’s t-test to compare between two average execution times (the two sided version of the student t-test) in order to check if \( \mu_X \neq \mu_Y \). In our methodology, we improve the previous work in two directions. First, we conduct a one-sided Student’s t-test to validate that \( \mu_X > \mu_Y \). Second, we check the normality if small samples and the equivalence of their variances (using the Fisher’s F-test) in order to use the classical Student’s t-test instead of the Welch’s variant. In addition, we must note that [5, 8, 16] focus on comparing between the mean execution times only. When the program performances have some extrema values (outliers), the mean is not a good performance measure (since the mean is sensitive to outliers). Consequently the median is usually advised for reporting performance numbers (such as for SPEC scores). Consequently, we rely on more academic books on statistics [6, 7, 9] for comparing between two medians. Furthermore, these fundamental books help us to understand mathematically some common mistakes and misunderstanding of statistics that we report in [3]. A limitation of our methodology is that we do not study the variations of the execution times due to changing the program’s input. The reason is that the variability of execution times when the data input varies cannot be analysed with the statistical tests as we did. Simply because when the data input varies, the execution time varies inherently based on the algorithmic complexity (intrinsic characteristic of the code), and not based on the structural hazards of the underlying machine. In other words, observing distinct execution times when varying data input of the program cannot be considered as hazard, but as an inherent reaction of the program under analysis. ### 8 Conclusion The community of program performance evaluation and their optimisation techniques suffer from a lack of rigorous statistical evaluation methodology. This article treats the problem by defining a rigorous statistical protocol allowing to consider the variations of program execution times. The variation of program execution times is not a chaotic phenomena to neglect or to smooth; we should keep it under control and incorporate it inside the statistics. Compared to [5, 8], the Speedup-Test methodology analyses the median execution time in addition to the average. Contrary to the average, the median is a better performance metric because it is less sensitive to outliers and is more appropriate for skewed distributions: this explains why the SPEC benchmark organisation advocates for it [4]. Summarising the observed execution times of a program with their median also allows to evaluate the chance to have a faster execution time if we do a single run of the application. Such performance metric is closer to the feeling of the users in general. Additionally, the Speedup-Test protocol is more cautious than [5, 8] because it checks the hypothesis on the data distributions before applying statistical tests. The Speedup-Test methodology analyses the distribution of the observed execution times. For declaring a speedup for the average execution time, we rely on the Student’s t-test under the condition that \( X \) and \( Y \) follow a Gaussian distribution (tested with Shapiro-Wilk’s test). If not, using the Student’s t-test is admitted but the computed risk level \( \alpha \) may still be inaccurate if the underlying distributions of \( X \) and \( Y \) are too far from being normally distributed. For declaring a speedup for the median execution time, we rely on the Wilcoxon-Mann-Whitney’s test. Contrary to the Student’s t-test, the Wilcoxon-Mann-Whitney’s test does not assume any specific distribution of the data, except that it requires that \( X \) and \( Y \) differ only by a shift location (that can be tested with the Kolmogorov-Smirnov’s test). We conclude with a short discussion about the appropriate risk level we should use in practice. Indeed, there is not a unique answer to this crucial question. In each context of code optimisation we may be asked to be more or less confident in the statistics. In the case of hard real time applications, the risk level must be low enough (less than 5% for instance). In the case of soft real time applications (multimedia, mobile phone, GPS, etc.), the risk level can be less than 10%. In the case of desktop applications, the risk level may not be necessarily too low. In any situation, the used risk level must be declared publicly in conjunction with the statistical significance. References Table 2: The two risk levels for hypothesis testing in statistical and probability theory. The primary risk level (0 < \( \alpha < 1 \)) is generally the guaranteed level of confidence, while the secondary risk level (0 < \( \beta < 1 \)) is not always guaranteed. <table> <thead> <tr> <th>Decision of the statistical test</th> <th>Truth</th> <th>( H_0 )</th> <th>( H_a )</th> </tr> </thead> <tbody> <tr> <td>( H_0 )</td> <td>( 1 - \alpha )</td> <td>( \beta )</td> <td></td> </tr> <tr> <td>( H_a )</td> <td>( \alpha )</td> <td></td> <td>( 1 - \beta )</td> </tr> </tbody> </table> A Hypothesis testing in statistical and probability theory Statistical testing is a classical mechanism to decide between two hypothesis based on samples or observations. Here, we should notice that almost all statistical tests have proved \( \alpha \) risk level for rejecting an hypothesis only (called the null hypothesis \( H_0 \)). The probability \( 1 - \alpha \) is the confidence level of not rejecting the null hypothesis. It is not a proved probability that the alternative hypothesis \( H_a \) is true with a confidence level \( 1 - \alpha \). By abuse of language, we say in practice that if a test rejects \( H_0 \) a null hypothesis with a risk level \( \alpha \), then we admit \( H_a \) the alternative hypothesis with a confidence level \( 1 - \alpha \). But this confidence level is not a mathematical one, except in rare cases. To have more hints on hypothesis testing, we invite the reader to study section 14.2 from [6] or section B.4 from [7]. We can for instance understand that statistical tests have in reality two kinds of risks: a primary \( \alpha \) risk, which is the probability to reject \( H_0 \) while it is true, and a secondary \( \beta \) risk which is the probability to accept \( H_0 \) while \( H_a \) is true, see Tab. 2. So, intuitively, the confidence level, sometimes known as the strength or power of the test, could be defined as \( 1 - \beta \). All the statistical tests we use (normality test, Fisher’s F-test, Student’s t-test, Kolmogorov-Smirnov’s test, Wilcoxon-Mann-Whitney’s test) have only proved \( \alpha \) risks levels under some hypothesis. We must say that hypothesis testing in statistics does not usually confirm a hypothesis with a confidence level \( 1 - \beta \), but in reality it rejects a hypothesis with a risk of error \( \alpha \). By abuse of language, if a null hypothesis \( H_0 \) is not rejected with a risk \( \alpha \), we say that we admit the alternative hypothesis \( H_a \) with a confidence level \( 1 - \alpha \). This is not mathematically true, because the confidence level of accepting \( H_a \) is \( 1 - \beta \), which cannot be computed easily. In this article, we use the abusive term confidence level for \( 1 - \alpha \) because it is the definition used in the \( \mathbb{R} \) software to perform numerous statistical tests.
{"Source-Url": "https://inria.hal.science/hal-00764454/document", "len_cl100k_base": 14340, "olmocr-version": "0.1.53", "pdf-total-pages": 17, "total-fallback-pages": 0, "total-input-tokens": 54082, "total-output-tokens": 16352, "length": "2e13", "weborganizer": {"__label__adult": 0.0003788471221923828, "__label__art_design": 0.0004341602325439453, "__label__crime_law": 0.0003685951232910156, "__label__education_jobs": 0.0009984970092773438, "__label__entertainment": 9.429454803466796e-05, "__label__fashion_beauty": 0.0001875162124633789, "__label__finance_business": 0.00034046173095703125, "__label__food_dining": 0.00041604042053222656, "__label__games": 0.000812530517578125, "__label__hardware": 0.0023975372314453125, "__label__health": 0.0006570816040039062, "__label__history": 0.00042319297790527344, "__label__home_hobbies": 0.0001556873321533203, "__label__industrial": 0.0006723403930664062, "__label__literature": 0.0003380775451660156, "__label__politics": 0.000301361083984375, "__label__religion": 0.0005512237548828125, "__label__science_tech": 0.14990234375, "__label__social_life": 0.00010377168655395508, "__label__software": 0.00946807861328125, "__label__software_dev": 0.82958984375, "__label__sports_fitness": 0.00042557716369628906, "__label__transportation": 0.0007700920104980469, "__label__travel": 0.00025081634521484375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 62848, 0.03181]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 62848, 0.60229]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 62848, 0.88774]], "google_gemma-3-12b-it_contains_pii": [[0, 3918, false], [3918, 8796, null], [8796, 12515, null], [12515, 16788, null], [16788, 21591, null], [21591, 23063, null], [23063, 27371, null], [27371, 28965, null], [28965, 33210, null], [33210, 37551, null], [37551, 41510, null], [41510, 44840, null], [44840, 48263, null], [48263, 52299, null], [52299, 56679, null], [56679, 59931, null], [59931, 62848, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3918, true], [3918, 8796, null], [8796, 12515, null], [12515, 16788, null], [16788, 21591, null], [21591, 23063, null], [23063, 27371, null], [27371, 28965, null], [28965, 33210, null], [33210, 37551, null], [37551, 41510, null], [41510, 44840, null], [44840, 48263, null], [48263, 52299, null], [52299, 56679, null], [56679, 59931, null], [59931, 62848, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 62848, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 62848, null]], "pdf_page_numbers": [[0, 3918, 1], [3918, 8796, 2], [8796, 12515, 3], [12515, 16788, 4], [16788, 21591, 5], [21591, 23063, 6], [23063, 27371, 7], [27371, 28965, 8], [28965, 33210, 9], [33210, 37551, 10], [37551, 41510, 11], [41510, 44840, 12], [44840, 48263, 13], [48263, 52299, 14], [52299, 56679, 15], [56679, 59931, 16], [59931, 62848, 17]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 62848, 0.0303]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
e46bc565d58b7a7b516563768a623c15fa456d45
Integrating Software Engineering and Usability Engineering Karsten Nebe\textsuperscript{1}, Dirk Zimmermann and Volker Paelke\textsuperscript{2} \textsuperscript{1}University of Paderborn (C-LAB), \textsuperscript{2}Leibniz University of Hannover (IGK) Germany 1. Introduction The usability of products gains in importance not only for the users of a system but also for manufacturing organizations. According to Jokela, the advantages for users are far-reaching and include increased productivity, improved quality of work, and increased user satisfaction. Manufacturers also profit significantly through a reduction of support and training costs (Jokela, 2001). The quality of products ranks among the most important aspects for manufacturers in competitive markets and the software industry is no exception to this. One of the central quality attributes for interactive systems is their usability (Bevan, 1999) and the main standardization organizations (IEEE 98, ISO 91) have addressed this parameter for a long time (Granollers, 2002). In recent years more and more software manufacturer consider the usability of their products as a strategic goal due to market pressures. Consequently, an increasing number of software manufacturer are pursuing the goal of integrating usability practices into their software engineering processes (Juristo et al., 2001). While usability is already regarded as an essential part of software quality (Juristo et al., 2001) the practical implementation often turns out to be a challenge. One key difficulty is usually the integration of methods, activities and artefacts from usability engineering into the existing structures of an organization, which typically already embody an established process model for product development and implementation. Uncoordinated usability activities that arise frequently in practice have only a small influence on the usability of a product. In practice the activities, processes and models applied during development are usually those proposed by software engineering (Granollers et al., 2002). A systematic and sustainable approach for the integration of usability activities into existing processes is required. In order to align the activities from both software engineering (SE) and usability engineering (UE) it is necessary to identify appropriate interfaces by which the activities and artefacts can be integrated smoothly into a coherent development process. The central goal of such integration is to combine the quality benefits of usability engineering with the systematic and planable proceedings of software engineering. This chapter provides a starting point for such integration. We begin with a discussion of the similarities and differences between both disciplines and review the connection between models, standards and the operational processes. We then introduce integration strategies at three levels of abstractions: the level of... standards in SE and UE, the level of process models, as well as the level of operational processes. On the most abstract level of standards we have analyzed and compared the software engineering standard ISO/IEC 12207 with the usability engineering standard DIN EN ISO 13407 and identified ‘common activities’. These define the overarching framework for the next level of process models. Based on this, we have analyzed different SE process models at the next level of abstraction. In order to quantify the ability of SE process models to create usable products, a criteria catalogue with demands from usability engineering was defined and used to assess common SE models. The results provide an overview about the degree of compliance of existing SE models with UE demands. This overview not only highlights weaknesses of SE process models with regards to usability engineering, but also serves to identify opportunities for improved integration between SE and UE activities. These opportunities can form the foundation for the most concrete implementation of an integrated development approach at the operational process level. We present recommendations based on the results of the analysis. 2. Software Engineering Software engineering (SE) is a discipline that adopts various engineering approaches to address all phases of software production, from the early stages of system specification up to the maintenance phase after the release of the system (Patel & Wang, 2000; Sommerville, 2004). SE tries to provide a systematic and planable approach for software development. To achieve this, it provides comprehensive, systematic and manageable procedures, in terms of SE process models (SE models). SE models usually define detailed activities, the sequence in which these activities have to be performed and the resulting deliverables. The goal in using SE models is a controlled, solid and repeatable process in which the project results do not depend on individual efforts of particular people or fortunate circumstances (Glinz, 1999). Hence, SE models partially map to process properties and process elements, adding concrete procedures. Existing SE models vary with regards to specific properties (such as type and number of iterations, level of detail in the description or definition of procedures or activities, etc.) and each model has specific advantages and disadvantages, concerning predictability, risk management, coverage of complexity, generation of fast deliverables and outcomes, etc. Examples of such SE models are the Linear Sequential Model (also called Classic Life Cycle Model or Waterfall Model) (Royce, 1970), Evolutionary Software Development (McCracken, & Jackson, 1982), the Spiral Model by Boehm (Boehm, 1988), or the V-Model (KBST, 1997). SE standards define a framework for SE models on a higher abstraction level. They define rules and guidelines as well as properties of process elements as recommendations for the development of software. Thereby, standards support consistency, compatibility and exchangeability, and cover the improvement of quality and communication. The ISO/IEC 12207 provides such a general process framework for the development and management of software. ‘The framework covers the life cycle of software from the conceptualization of ideas through retirement and consists of processes for acquiring and supplying software products and services.’ (ISO/IEC, 2002). It defines processes, activities and tasks and provides descriptions about how to perform these items on an abstract level. www.intechopen.com In order to fulfil the conditions of SE standards (and the associated claim of ensuring quality) SE models should comply with these conditions. In general, standards as well as SE models cannot be directly applied. They have to be adapted and/or tailored to the specific organizational conditions. The resulting instantiation of a SE model, fitted to the organizational aspects, is called software development process, which can then be used and put to practice. Thus, the resulting operational process is an instance of the underlying SE model and the implementation of activities within the organization. This creates a hierarchy of different levels of abstractions for SE: standards that define the overarching framework, process models that describe systematic and traceable approaches and the operational level in which the models are tailored to fit the specifics of an organization (Figure 1). Figure 1. Hierarchy of standards, process models and operational processes in SE ### 3. Usability Engineering Usability Engineering (UE) is a discipline that is concerned with the question of how to design software that is easy to use (usable). UE is ‘an approach to the development of software and systems which involves user participation from the outset and guarantees the efficacy of the product through the use of a usability specification and metrics.’ (Faulkner, 2002a) UE provides a wide range of methods and systematic approaches for the support of development. These approaches are called Usability Engineering Models (UE Models) or Usability Lifecycles. Examples include Goal-Directed-Design (Cooper & Reimann, 2003), the UE Lifecycle (Mayhew, 1999) or the User-Centred Design-Process Model of IBM (IBM, 1996). All of them have much in common since they describe an idealized approach that ensures the development of usable software, but they differ in their specifics, in the applied methods and the general description of the procedure (e.g. phases, dependencies, goals, responsibilities, etc.) (Woletz, 2006). UE Models usually define activities and their resulting deliverables as well as the order in which specific tasks or activities have to be performed. The goal of UE models is to provide tools and methods for the implementation of the user’s needs and to guarantee the efficiency, effectiveness and users’ satisfaction of the solution. Thus, UE and SE address different needs in the development of software. SE aims at systematic, controllable and manageable approaches to software development, whereas UE focuses on the realization of usable and user-friendly solutions. The consequence is that there are different views between the two disciplines during system development, which sometimes can lead to conflicts, e.g. when SE focuses on system requirements and the implementation of system concepts and designs, whereas UE focuses on the implementation of user requirements, interaction concepts and designs. For successful designs both views need to be considered and careful trade-offs are required. UE provides standards similar to the way SE does. These are also intended to serve as frameworks to ensure consistency, compatibility, exchangeability, and quality, which is in line with the idea of SE standards. However, UE standards focus on the users and the construction of usable solutions. Examples for such standards are the DIN EN ISO 13407 (1999) and the ISO/PAS 18152 (2003). The DIN EN ISO 13407 introduces a process framework for the human-centred design of interactive systems. Its overarching aim is to support the definition and management of human-centred design activities, which share the following characteristics: - The active involvement of users and a clear understanding of user and task requirements (‘context of use’) - An appropriate allocation of function between users and technology (‘user requirements’) - The iteration of design solutions (‘produce design solutions’) - Multi-disciplinary design (‘evaluation of use’) These characteristics are reflected by the activities (named in brackets), which define the process framework of the human-centred design process, and have to be performed iteratively. The ISO/PAS 18152 is partly based on the DIN EN ISO 13407, and describes a reference model to measure the maturity of an organization in performing processes that make usable, healthy and safe systems. It describes processes and activities that address human-system issues and the outcomes of these processes. It provides details on the tasks and artefacts associated with the outcomes of each process and activity. There is a sub-process called human-centred design that describes the activities that are commonly associated with a user centred design process. These activities are ‘context of use’, ‘user requirements’, ‘produce design solutions’ and ‘evaluation of use’, which are in line with the DIN EN ISO 13407. They are, however, more specific in terms of defining lists of activities (so called base practices) that describe how the purpose of each activity can be achieved (e.g. what needs to be done to gather the user requirements in the right way). Thus, the ISO/PAS 18152 enhances the DIN EN ISO 13407 in terms of the level of detail and contains more precise guidelines. In order to ensure the claims of the overarching standards, UE models need to adhere to the demands of the corresponding framework. Thus, a connection between the standards and the UE models exists, which is similar to the one identified for SE above. Similar to SE, there is also a hierarchy of standards and subsequent process models. Additionally, there are similarities on the level of operational processes. The selected UE model needs to be adjusted to the organizational guidelines. Therefore, a similar hierarchy of the different abstraction levels exists for SE and for UE (Figure 2). Standards define the overarching framework, models describe systematic and traceable approaches and on the operational level, the SE models are adjusted and put into practice. 4. State of the Art: Integration of Standards, Models and Operational Processes In general, standards and models are seldom applied directly, neither in SE nor in UE. Standards merely define a framework to ensure compatibility and consistency and to set quality standards. For practical usage, models are being adapted and tailored to organizational conditions and constraints, such as existing processes, organizational or project goals, legal policies, etc. Thus models are refined by the selection and definition of activities, tasks, methods, roles, deliverables, etc. as well as the responsibilities and relationships in between. The derived instantiation of a model, fitted to the organizational aspects, is called software development process (for SE models) or usability lifecycle (for UE models). The resulting operational processes can be viewed as instances of the underlying model. This applies to both SE and UE. In order to achieve sufficient alignment between the two disciplines, all three levels of abstraction must be considered to ensure that the integration points and suggestions for collaboration meet the objectives of both sides and the intentions behind a standard, model or operational implementation is not lost. The integration of SE and UE leads to structural, organisational and implementation challenges, caused by ‘differences relating to historical evolution, training, professional orientation, and technical focus, as well as in methods, tools, models, and techniques’ (Constantine et al., 2003). As discussed in sections 2 and 3, SE and UE have evolved with different objectives. SE’s main goal is the design of software, covering the process of construction, architecture, reliable functioning and design for utility (Sutcliffe, 2005). Historically, UE has been considered in contrast to this system-driven philosophy of SE (Norman & Draper, 1986) and focuses on social, cognitive and interactive phenomena (Sutcliffe, 2005). This conceptual difference between the two disciplines highlights the challenges for integration in practice. A lack of mutual understanding between practitioners of both disciplines is common. As reported by Jerome and Kazmann (2005) there is substantial incomprehension of the other field between software engineers and usability specialists. Apparently, scientific insights on design processes have had little impact on the exchange and communication so far. Practitioners from both disciplines commonly hold widely disparate views of their respective roles in development processes. This leads to a lack of communication and collaboration. Often cooperation is deferred to late stages of the development lifecycle where it is usually too late to address fundamental usability problems. Hakiel (1997) identifies additional areas where understanding is lacking. A central problem is the perception of many project managers that the activities and results of UE are irreproducible and result from unstructured activities. This perception is in part caused by the missing interrelation/links between activities of SE and UE and indicates the need for the education of project management about UE goals and practices (Faulkner & Culwin, 2000b; Venturi & Troost, 2004). This is a prerequisite to achieve adequate executive and managerial support and to consider UE in the project planning from the outset (staffing, organisational structure, scheduling of activities) (Radle & Young 2001). Many of the mentioned problems are caused by the act of changing established processes by adding and adapting UE activities. Particularly there, where formal SE process models are applied UE activities are rarely considered as a priority. Granollers et al. (2002) summarize this in their study: „the development models used by the software industry in the production of solutions are still those proposed by SE. SE is the driving force and the UE needs to adapt to this in order to survive‘. While so called UE models, which address the complete development from the usability perspective, have been proposed (e.g. Mayhew, 1999, Cooper & Reimann 2001), a complete replacement of SE engineering processes by these is often infeasible. Rather, it seems necessary to gather knowledge about the fundamental concepts, the methodologies and techniques of UE in a form that is accessible to all stakeholders in a development process and to incorporate this knowledge and the corresponding activities into existing software development processes (Aikio, 2006). Early on Rideout (1989) have identified the use of effective interdisciplinary design teams, the creation and dissemination of company and industry standards and guidelines, and the extension of existing processes to encompass UE concerns as keys to the acceptance and success of UE. Most existing approaches have tried to achieve unification at specific levels of abstraction. While this can lead to successful results, it fails to provide a continuous strategy for integration that considers the structural, organizational and operational aspects on equal footing and is adaptable to a variety of established and evolving SE practices. This has been illustrated by the advent of so called agile development approaches that have become popular in recent years, resulting in the need for newly adapted strategies for UE integration. In the following sections we introduce a systematic approach that covers the three levels of abstraction from standards over process models to operational processes to address this challenge in a systematic way. 5. Integration on three Levels of Abstraction In order to identify integration points between the two disciplines examination and analysis has to be performed on each level of the abstraction hierarchy: On the most abstract level of standards it has to be shown that the central aspects of SE and UE can coexist and can be integrated. On the level of process models it has to be analyzed how UE aspects can be incorporated into SE models. And on the operational level concrete recommendations for activities have to be formulated to enable effective collaboration with reasonable organizational and operational efforts. In previous work the authors have addressed individual aspects of this integration approach (Nebe & Zimmermann, 2007a; Nebe & Zimmermann, 2007b; Nebe et al., 2007c), which are now composed into a coherent system. 5.1 Common Framework on the Level of Standards To figure out whether SE and UE have similarities on the level of standards, the standards’ detailed descriptions of processes, activities and tasks, output artefacts, etc. have been analyzed and compared. For this the SE standard ISO/IEC 12207 was chosen for comparison with the UE standard DIN EN ISO 13407. The ISO/IEC 12207 defines the process of software development as a set of 11 activities: Requirements Elicitation, System Requirements Analysis, Software Requirements Analysis, System Architecture Design, Software Design, Software Construction, Software Integration, Software Testing, System Integration, System Testing and Software Installation. It also defines specific development tasks and details on the generated output to provide guidance for the implementation of the process. The DIN EN ISO 13407 defines four activities of human-centred design that should take place during system development. These activities are labelled ‘context of use’, ‘user requirements’, ‘produce design solutions’ and ‘evaluation of use’. DIN EN ISO 13407 also describes in detail the kind of output to be generated and how to achieve it. On a high level, when examining the descriptions of each activity, by relating tasks and outputs with each other, similarities can be identified in terms of the characteristics, objectives and proceedings of activities. Based on these similarities single activities were consolidated as groups of activities (so called, ‘common activities’). These ‘common activities’ are part of both disciplines SE and UE on the highest level of standards. An example of such a common activity is the Requirement Analysis. From a SE point of view (represented by the ISO/IEC 12207) the underlying activity is the Requirement Elicitation. From the UE standpoint, specifically the DIN EN ISO 13407, the underlying activities are the ‘context of use’ and ‘user requirements’, which are grouped together. Another example is the Software Specification, which is represented by the two SE activities System Requirements Analysis and Software Requirements Analysis, as well as by ‘produce design solutions’ from a UE perspective. The result is a compilation of five ‘common activities’: Requirement Analysis, Software Specification, Software Design and Implementation, Software Validation, Evaluation that represent the process of development from both, a SE and a UE point of view (Table 1). These initial similarities between the two disciplines lead to the assumption of existing integration points on this overarching level of standards. Based on this, the authors used these five ‘common activities’ as a general framework for the next level in the hierarchy, the level of process models. However, the identification of these similar activities does not mean that one activity is performed in similar ways in SE and UE practice. They may have similar goals on the abstract level of standards but typically differ significantly in the execution, at least on the operational level. Thus, Requirement Analysis in SE focuses mainly on system-based requirements whereas UE requirements describe the users’ needs and workflows. The activity of gathering requirements is identical but the view on the results is different. Another example is the Evaluation. SE evaluation aims at functional correctness and correctness of code whereas UE focuses on the completeness of users’ workflows and the fulfilment of users’ needs. <table> <thead> <tr> <th>ISO/IEC 12207</th> </tr> </thead> <tbody> <tr> <td>Sub- Process: Development</td> </tr> </tbody> </table> <table> <thead> <tr> <th>Common Activities</th> </tr> </thead> <tbody> <tr> <td>Requirement Analysis</td> </tr> <tr> <td>Software Specification</td> </tr> <tr> <td>System Architecture Design</td> </tr> <tr> <td>Software Design</td> </tr> <tr> <td>Software Construction</td> </tr> <tr> <td>Software Integration</td> </tr> <tr> <td>Software Testing</td> </tr> <tr> <td>System Integration</td> </tr> <tr> <td>System Testing</td> </tr> <tr> <td>Software Installation</td> </tr> </tbody> </table> <table> <thead> <tr> <th>DIN EN ISO 13407</th> </tr> </thead> <tbody> <tr> <td>Context of Use</td> </tr> <tr> <td>User Requirements</td> </tr> <tr> <td>Produce Design Solutions</td> </tr> <tr> <td>Software Design and Implementation</td> </tr> <tr> <td>n/a</td> </tr> <tr> <td>Evaluation of Use</td> </tr> <tr> <td>Evaluation of Use</td> </tr> </tbody> </table> Table 1. Comparison of SE and UE activities on the level of standards and the identified similarities (Common Activities) Consequently, it is important to consider these different facets of SE and UE likewise. And as usability becomes an important quality aspect in SE, the ‘common activities’ not only have to be incorporated in SE models from a SE point of view, but also from the UE point of view. Some SE models already adhere to this, but obviously not all of them. To identify whether UE aspects of the ‘common activities’ are already implemented in SE models, the authors performed a gap-analysis with selected SE models. The overall goal of this study was to identify integration points on the level of process models. Therefore a deep understanding about the selected SE models and an accurate specification of the requirements that specify demands from an UE perspective was required. 5.2 Ability of SE models to Create Usable Products In order to assess the ability of SE models to create usable products, criteria are needed to define the degree of UE coverage in SE models. These criteria must contain the UE demands and should be used for evaluation later on. To obtain detailed knowledge about UE activities, methods, deliverables and their regarding quality aspects, the authors analyzed the DIN EN ISO 13407 and the ISO/PAS 18152. As mentioned above the DIN EN ISO 13407 defines a process framework with the four activities ‘context of use’, ‘user requirements’, ‘produce design solutions’ and ‘evaluation of use’. The reference model of the ISO/PAS 18152 represents an extension to parts of the DIN EN ISO 13407. Particularly the module Human-centred design of the ISO/PAS 18152 defines base practices for the four activities of the framework. These base practices describe in detail how the purpose of each activity is achieved. Thus, it is an extension on the operational process level. Since the ISO/PAS 18152 is aimed at process assessments, its base practices describe the established steps. Therefore they can be used as UE requirements that need to be applied by the SE models to ensure to create usable products. For the following analysis they form the basic requirements against which each activity is evaluated. As an example table 2 shows the base practices of the activity ‘user requirements’. <table> <thead> <tr> <th>HS.3.2 User Requirements</th> </tr> </thead> <tbody> <tr> <td>BP1</td> </tr> <tr> <td>BP2</td> </tr> <tr> <td>BP3</td> </tr> <tr> <td>BP4</td> </tr> <tr> <td>BP5</td> </tr> </tbody> </table> Table 2. Base practices of the module HS.3.2 User Requirements given in the ISO/PAS 18152. Based on these requirements (base practices) the authors evaluated the selected SE models. The comparison was based on the description of the SE models in the standard documents and official documentation. For each requirement the authors determined whether the model complied with it or not. An overview of the results for each model is shown in table 3. The quantity of fulfilled requirements for each activity of the framework provides some indication of the level of compliance of the SE model with the UE requirements. According to the results, statements about the ability of SE models to create usable products were made. Table 4 shows the condensed result of the gap-analysis. The compilation of findings shows, that for none of the SE models all base practices of ISO/PAS 18152 can be seen as fulfilled. However, there is also a large variability in the coverage rate between the SE models. For example, the V-Model shows a very good coverage for all modules except for smaller fulfilment of ‘produce design solutions’ HS 3.3 criteria, whereas the Linear Sequential Model only fulfils a few of the ‘evaluation of use’ (HS 3.4) criteria and none of the other modules. Evolutionary Design and the Spiral Model share a similar pattern, where they show only little coverage for ‘context of use’, medium to good coverage of ‘user requirements’, limited coverage for Produce Design Solution and good support for ‘evaluation of use’ activities. <table> <thead> <tr> <th>Modul</th> <th>Activity</th> <th>LSM</th> <th>ED</th> <th>SM</th> <th>VM</th> </tr> </thead> <tbody> <tr> <td>HS 3.1</td> <td>Context of use</td> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td>1</td> <td>Define the scope of the context of use for the system.</td> <td>-</td> <td>-</td> <td>+</td> <td>+</td> </tr> <tr> <td>2</td> <td>Analyse the tasks and worksystem.</td> <td>-</td> <td>-</td> <td>-</td> <td>+</td> </tr> <tr> <td>3</td> <td>Describe the characteristics of the users.</td> <td>-</td> <td>-</td> <td>-</td> <td>+</td> </tr> <tr> <td>4</td> <td>Describe the cultural environment/organizational/management regime.</td> <td>-</td> <td>-</td> <td>-</td> <td>+</td> </tr> </tbody> </table> 5 Describe the characteristics of any equipment external to the system and the working environment. - - - + 6 Describe the location, workplace equipment and ambient conditions. - - - + 7 Analyse the implications of the context of use. - - - + 8 Present these issues to project stakeholders for use in the development or operation of the system. - + - - ### HS 3.2 User Requirements 1 Set and agree the expected behaviour and performance of the system with respect to the user. - - + + 2 Develop an explicit statement of the user requirements for the system. - + + + 3 Analyse the user requirements. - + + + 4 Generate and agree on measurable criteria for the system in its intended context of use. - - + + 5 Present these requirements to project stakeholders for use in the development and operation of the system. - - - - ### HS 3.3 Produce design solutions 1 Distribute functions between the human, machine and organizational elements of the system best able to fulfil each function. - - - - 2 Develop a practical model of the user's work from the requirements, context of use, allocation of function and design constraints for the system. - - - - 3 Produce designs for the user-related elements of the system that take account of the user requirements, context of use and HF data. - - - - 4 Produce a description of how the system will be used. - + + + 5 Revise design and safety features using feedback from evaluations. - + + + ### HS 3.4 Evaluation of use 1 Plan the evaluation. - + + + 2 Identify and analyse the conditions under which a system is to be tested or otherwise evaluated. - - + + 3 Check that the system is fit for evaluation. + + + + 4 Carry out and analyse the evaluation according to the evaluation plan. + + + + 5 Understand and act on the results of the evaluation. + + + + Table 3. Results of the gap-analysis: Coverage of the base practices for the Linear Sequential Model (LSM), Evolutionary Development (ED), Spiral Model (SM) and V-Model (VM) Integrating Software Engineering and Usability Engineering Table 4. Results of the gap-analysis, showing the level of sufficiency of SE models covering the requirements of UE <table> <thead> <tr> <th>Model</th> <th>Context of Use</th> <th>User Requirements</th> <th>Produce Design Solutions</th> <th>Evaluation of Use</th> <th>Across Activities</th> </tr> </thead> <tbody> <tr> <td>Linear Sequential Model</td> <td>0 %</td> <td>0 %</td> <td>0 %</td> <td>60 %</td> <td>13 %</td> </tr> <tr> <td>Evolutionary Development</td> <td>13 %</td> <td>40 %</td> <td>40 %</td> <td>80 %</td> <td>39 %</td> </tr> <tr> <td>Spiral Model</td> <td>13 %</td> <td>80 %</td> <td>40 %</td> <td>100 %</td> <td>52 %</td> </tr> <tr> <td>V-Modell</td> <td>88 %</td> <td>80 %</td> <td>40 %</td> <td>100 %</td> <td>78 %</td> </tr> <tr> <td>Across Models</td> <td>28 %</td> <td>50 %</td> <td>30 %</td> <td>85 %</td> <td></td> </tr> </tbody> </table> The summary of results (Table 4) and a comparison of the percentage of fulfilled requirements for each SE model, shows that the V-Model performs better than the other models and can be regarded as basically being able to produce usable products. With a percentage of 78% it is far ahead of the remaining three SE models. In the comparison, the Linear Sequential Model falls short at only 13%, followed by Evolutionary Development (39%) and the Spiral Model (52%). If one takes both the average values of fulfilled requirements and the specific base practices for each UE activity into account, this analysis shows that the emphasis for all SE models is laid on evaluation ('evaluation of use'), especially comparing the remaining activities. The lowest overall coverage could be found in the 'context of use' and Produce Design Solution, indicating that three of the four SE models don’t consider the relevant contextual factors of system usage sufficiently, and also don’t include (user focused) concept and prototype work to an extent that can be deemed appropriate from a UCD perspective. The relatively small compliance values for the 'context of use' (28%), ‘user requirements’ (50%) and ‘produce design solutions’ (30%) activities across all SE models, can be interpreted as an indicator that there is only a loose integration between UE and SE. There are few overlaps between the disciplines regarding these activities and therefore it is necessary to provide suitable interfaces to create a foundation for integration. This approach does not only highlight weaknesses of SE models regarding the UE requirements and corresponding activities, it also pinpoints the potential for integration between SE and UE: Where requirements are currently considered as not fulfilled, recommendations for better integration can be derived. The underlying base practices and the corresponding detailed descriptions provide indicatory on what needs to be considered on the level of process models. As an example, initial high-level recommendations e.g. for the Linear Sequential Model could be as followed: In addition to phases like System Requirements and Software Requirements there needs to be a separate phase for gathering user requirements and analysis of the context of use. As the model is document driven and completed documents... are post-conditions for the next phase it has to be ensured that usability results are part of this documentation. The approach can be applied in a similar way to any SE model, to establish the current level of integration and to identify areas for improved integration. This can be used a foundation for implementing the operational process level and will improve the interplay of SE and UE in practice. The results confirmed the expectations of the authors, indicating deficiencies in the level of integration between both disciplines on the level of the overarching process models. Thus, there is a clear need to compile more specific and detailed criteria for the assessment of the SE models. The analysis also showed that the base practices currently leave too much leeway for interpretations. In addition, it turned out that a dichotomous assessment scale (in terms of ‘not fulfilled’ or ‘fulfilled’) is not sufficient. A finer rating is necessary to evaluate process models adequately. Thus, the documentation analysis of the SE models produced first insights but it turned out that the documentation is not comprehensive enough to ensure the validity of recommendations derived from this analysis alone. 6. Detailed Criteria of Usability: Quality aspects in UE In order to gather more specific and detailed criteria for the assessment of SE models and the derivation of recommendations a further analysis had to be performed. The authors believe that there is such thing as a ‘common understanding’ in terms of what experts think of when they talk about UE and this is certainly represented by the definition of the human-centred-design process in the DIN EN ISO 13407. Although the definitions of base practices defined in the ISO/PAS 18152 are not considered as invalid they leave leeway for interpretation as shown in section 5. However, while this ‘common understanding’ seems true on a very abstract level, strong differences in how to implement these in practice can be expected. The key question therefore is not only what should be done, but rather how it can be assured that everything needed is being performed (or guaranteed) in order to gain a certain quality of a result, an activity or the process itself. In addition, the completeness and correctness of the base practices and human-centred design activities as defined in the ISO/PAS 18152 itself needs to be verified. For a more detailed analysis, based on current real-world work practices, the authors performed semi-structured interviews and questionnaires with six experts in the field of UE. These experts are well grounded in theoretical terms, i.e. standards and process models, as well as in usability practice. As a result, overarching process- and quality characteristics were derived that led to statements about the relevance, the application and need of usability activities, methods and artefacts to be implemented in SE. The following results highlight initial insights, especially with regards to the quality characteristics/aspects of UE activities. A substantial part of the interviews referred explicitly to quality characteristics/aspects of the four human-centred design activities of the DIN EN ISO 13407: ‘context of use’, ‘user requirements’, ‘produce design solutions’ and ‘evaluation of use’. The goal was to identify what constitutes the quality of a certain activity from the experts’ point of view and what kind of success and quality criteria exist that are relevant on a process level and subsequently for the implementation in practice. In summary, it can be said that the quality of the four activities essentially depends on the production and subsequent treatment of the result generated by each activity. From the quality perspective it is less important how something is accomplished, but rather to guarantee the quality of the results. In order to answer the question what constitutes this quality, the analyzed statements of the experts regarding each activity are discussed in the following paragraphs. The core characteristic (essence) of each activity is described, followed by requirements regarding the generation and treatment of content, a summary of (measurable) quality criteria and success characteristics, as well as a list of operational measures that can be used for the implementation in practice. 6.1 Context of Use There is a common agreement of all experts involved in the study in that the fundamental goal of the activity is the formation of a deep understanding of the users, their goals, needs and the actual work context. This then forms the base for the derivation of requirements as well as for validating user requirements of the solution. The focus of the context analysis should therefore be on the original tasks and workflows, independent of concrete solutions and/or any supporting systems. Apart from a documentation or rather communication of the analyzed knowledge it is crucial to anchor the activity within the overall process model. The context analysis provides a base for the entire process of development, in particular for deriving requirements, which provide the link to the next process step/sub-process. It generally applies that an output is only as valuable as it serves as input for a following sub-process. Thus, the context analysis must start at an early stage, preferably before any comprehensive specification is being created. This could be in a pre-study phase of the project, where neither technical platform nor details about the implementation have been determined. The quality of the context analysis and its results also depends on organisational conditions. A sufficient time schedule and the allocation of adequate resources is required in order to be able to accomplish the context analysis in an appropriate way. The support by the management and the organization is crucial in this case. As mentioned before, the results are the most significant factor for the quality. In their comments, most experts focused on the documentation of the results, but it turned out that this is not a necessity. The important aspect is not the documentation itself. Rather, the results must exist in an adequate form so that all people involved can access or read it, and that it is comprehensible for anyone involved. With regard to the description (respectively the communication) of context information two major points have been identified that need to be considered and distinguished: First, the context information must be formulated in an appropriate way so that even people who were not involved in the process of analysis can comprehensibly understand its content. And second, the information must be unambiguous, consistent and complete. That is, only reasonable and context-relevant data is gathered and completeness (pertaining to the systems that are essential for the accomplishment of the tasks) is assured. One major quality aspect of a successful context analysis is the ability to identify so called ‘implied needs’ based on the context information. Implied needs are ‘those needs, which are often hidden or implied in circumstances in which requirements engineers must sharpen their understanding of the customer's preferred behavior’ (ProContext, 2008). Hence, the context information must contain all details needed to derive the user requirements. All experts agreed on the fact that the quality of the results strongly depends on the experience and qualification of the analysts. The abilities to focus on the substantial and to focus on facts (rather than interpretation) are crucial for this activity. Additionally, the experiences of the users are important as well. Their representativeness, ability to express themselves and the validity of their statements are a prerequisite for good results. A measureable quality criterion is the amount of predictable user requirements derived based on the context information. One example: If five comparable skilled experts are asked to derive all user requirements based on the given context information independently, and if all experts finally compile a similar set of requirements in terms of quantity and meaning, then the context information could be rated as high quality. This implies that the entire user requirements could be derived based on the context information. A success criterion for the analysis and its context information is the ability to identify coherent patterns, e.g. similar workflows, similar habits, the usage of similar tools, etc. Accordingly, the identification of non-similar workflows might imply the need for further analysis. Another success factor is the feedback obtained from presenting the results not only to the users of the system but also to the customers. Good feedback from the users implies a good solution and in combination with good customer feedback it indicates a good balance between user and business goals. The success of a context analysis activity itself can often only be estimated/evaluated afterwards, then when the users have not found any major gaps or critical errors in the concept of the solution. Summative evaluation is a suitable method to measure this. An additional, but difficult to quantify, quality criterion is the acceptance and the utility of the results (context information) for the process and for the organization. If the context information enables the derivation of user requirements and if it is useful to create concepts and designs out of it than it has been obviously good. A central characteristic of good context information is that all questions that appear during the design process can be answered from it. An important measure for ensuring the quality is the training of the analysts in applying the methodologies and methods. The qualification of the analysts determines the result’s quality. Qualification means not only to know (theoretically learned), but rather to perform (practically experienced). The context analysis is the cornerstone for the user-centred development and it is crucial for the success of a solution. In order to ensure its quality, it requires the integration of the activities and regarding results (deliverables) into the overall process, the supply of sufficient and qualified resources as well as appropriate time for the execution of an entire analysis within the project plan. Therefore, the support by the management and the organization is necessary. 6.2 User Requirements The main goal of the activity ‘user requirements’ is to work out a deep understanding about the organisational and technical requirements, the users’ workflows and the users’ needs and goals of the future system. This results in a valid basis for system specifications. From the UE perspective it is crucial that this is not purely technically driven perception (as often in SE processes) but extents to a utilization- and situational-view. The majority of the experts described the core of this activity as the specification and documentation of requirements in coordination with development, users and customers. However, the result does not always have to be defined in the way of fine-granular requirements and extensive specifications. More important is to transfer this knowledge successfully into the development process. Similar to the activity of context analysis, both the experience and skills of the analysts are essential for the success and for the quality of the results, as well as the users’ representativeness, ability to express themselves and the validity of their statements. According to statements of the experts, a set of quality criteria can be defined, both at the execution of the activity, and at the result. User requirements should have a certain formulation quality (legibility, comprehensibility, consistency, etc.) and should be formulated system-neutrally. Requirements should be based on demands (prerequisite for something that should be accomplished), which guaranteed the validity. This can be important for the argumentation when trade-offs in the development process are required. User requirements must be adequate and precisely formulated on level of the tasks. A negative example would be: „The system must be usable‘ - this requirement is not embodied at a task level, it is just an abstract goal. Good user requirements are not interpretable per se. The solution itself derived from the requirements is interpretable of course, but the requirements are not. In particular the consideration of user goals and requirements and the trade-off with business goals is seen as an important success criterion. Further success criteria are the comprehensibility and utility of the results (requirements) in the further process. In order to achieve this quality the experts recommended several measures, such as an iterative procedure during the collection and derivation of requirements. The involvement of all stakeholders (users, customer, management, development, etc.) at all stages of the process is inevitable. In particular the presentation of user requirements to the management is considered as an important means for arising awareness. Dedicated and qualified roles are also crucial for the success of the entire process (e.g. no developer should write the specification – this should be done by someone qualified and skilled). 6.3 Produce Design Solution The design activity Produce Solution covers the creative process of transferring user requirements and knowledge about the user domain and the business perspective into design concepts for new solutions. For this, different ideas have to be produced, investigated and critiqued. As most design activities, this is an open-ended problem solving process without a unique solution, especially regarding the user interface. The main goal is to provide a functional system with a user interface that allows satisfactory interaction and efficient use (all information, no errors, no unnecessary steps, etc.), as described in the seven ISO dialogue design principles (DIN EN ISO 9241-Part 110, 2006). Essential for a good design solution is that it handles all requirements collected in the specification (validity) but also (increasingly) that the user feels safe and confident in the use of the designed system and feels satisfied with the results. The form in which the design is created, communicated and documented is not the decisive factor. Representations can range from sketches over formal specifications to working prototypes. What is central is that the representation provides information at a level of detail that is deemed useful for implementation and can be successfully communicated. As in most design disciplines it is considered good practice to consider design alternatives that are critiqued by experts and evaluated with users to guide the design process. Process support for such exploratory activities is considered useful and important. If questions from the users - but also from the development team - arise during these reviews it is often a strong indication that further analysis and review are required. The quality of the proposed solutions depends critically on the experience and knowledge of the persons involved in the design work. The experts consider a multidisciplinary qualification, but with a clear account of the assigned roles and competencies (developer, analyst, designer, etc.) as the key to the production of successful high quality design. With regards to design, criteria for success and measurable quality criteria can be difficult to define. What can, however, be checked and measured are for example, the implementation of user requirements through the design, the design accordance with the principles of dialogue design (DIN EN ISO 9241-110, 2006) and information presentation standards (DIN EN ISO 9241-Part 12, 1998). Comparative studies of alternative designs and performance measurements can provide further information on design quality to guide further refinement or to identify problematic design choices. Appropriate measures for quality assurance are to strengthen the links with the related process activities of ‘user requirements’ and the ‘evaluation of use’. An established best practice is the use of iterative approaches in which alternative design proposals are examined and refined to evolve a suitable solution. To ensure a wide creative potential and a correspondingly large solution space the integration of a variety of roles and experts from different backgrounds into this activity is advisable. It is, however, vital that the leadership of this activity is assigned to a qualified user interface designer, whose role is explicitly communicated and who has the final decision power in this activity. This must be communicated to the complete team and adequately supported by the management. 6.4 Evaluation of Use The central aim of the ‘evaluation of use’ activity is to collect feedback on the practical use of a system design in order to refine the design and the system. Problems in use are to be identified and subsequently corrected. The key to a successful integration of evaluation into a development process is to consider it as a continuous ongoing activity throughout the process. Of course, the methodology and applied techniques have to be adapted to the maturity of the design representations/implementation at different stages of development. Evaluation is most useful in the larger process context, as many evaluation methods identify problems, but provide no solution for the problems found. It is therefore important to not only identify problems but to feed this information back into the design process to resolve the identified issues. This should be reflected in the process. It is critical that the results of this activity are used in the ongoing process. Therefore the information must be available in a form that is understandable to the stakeholders in the development process. The quality of the activity ‘evaluation of use’ is primarily defined by the results. In this activity what was previously designed (based on the preceding analysis) and implemented is now evaluated. It is crucial that major usability problems are identified at this stage, especially issues that are seen as disruptive from the user’s perspective. Second categories of problems cover issues that are valid but do not necessarily disturb users, which are less critical. The activity can be considered completed, once no new significant problems are found. The commitment of all stakeholders, the expertise of usability experts and the ability of stakeholders to accept criticism and to act constructively on it are of central importance for the success of the evaluation activity. Measurable quality criteria can be derived from the selection and use of established evaluation methods (Freymann, M. 2007). Decisive measures for quality assurance include the qualification of key stakeholders in evaluation techniques and process, the explication of the evaluation as an essential activity in the process and the allocation of sufficient time for multiple iterations of design-evaluation cycles in the process plan. 7. Summary & Outlook Today, the usability of a software product is no longer only a crucial quality criterion for the users but also for the organizations. It can be seen as unique selling point in the competitive market. However, the various differences in each organisation’s structure, its process model, development process and the organizational conditions makes it difficult to transfer the knowledge about usability methodologies, methods and techniques into practice. There are many different approaches to integrate usability engineering and software engineering but each focuses on different measures. Some are very specific, e.g. to an organization or to a development process, while others are very abstract, e.g. to process models. However, each of them has its authority and each leads to the regarding results in detail on a specific level of abstraction. However, there are fewer approaches that combine approaches on all levels of abstractions. The presented approach identifies integration points between software engineering and usability engineering on three different levels of abstractions. The authors showed that standards define an overarching framework for both disciplines. Process models describe systematic and planable approaches for the implementation and the operational process in which the process models are tailored to fit the specifics of an organization. On the first level (‘level of standards’) the authors analyzed, compared and contrasted the software engineering standard ISO/IEC 12207 with the usability engineering standard DIN EN ISO 13407 and identified a set of ‘common activities’ as part of both disciplines. These activities define the overarching framework for the next level, the ‘level of process models’. In order to identify the maturity of software engineering process models’ ability to create usable products, the authors used a two-step approach to synthesize the demands of usability engineering and performed an assessment of selected software engineering models. To obtain detailed knowledge about usability engineering activities, methods, deliverables and their regarding quality aspects, the authors analyzed the two usability engineering standards DIN EN ISO 13407 and the ISO/PAS 18152. The ISO/PAS 18152 defines detailed base practices that specify the tasks for creating usable products. These base practices have been used as a foundation to derive requirements that represent the ‘common activities’ usability engineering perspective. The quantity of fulfilled requirements for each activity of the framework informs about the level of compliance of the software engineering model satisfying the base practices and therewith the usability perspective of activities. The results of the assessment provide an overview about the degree of compliance of the selected models with usability engineering demands. It turned out that there is a relatively small compliance to the usability engineering activities across all selected software engineering models. This is an indicator that only little integration between usability engineering and software engineering exists. There are less overlaps between the disciplines regarding these activities and therefore it is necessary to provide suitable interfaces to create a foundation for the integration. The analysis of software engineering models also showed that more detailed and adequate criteria for the assessment are necessary by which objective and reliable statements about process models and their ability to create usable software could be made. Therefore the authors performed a second analysis and conducted expert interviews and questionnaires to elicit appropriate criteria for the evaluation of software engineering models. A substantial part of the questions referred explicitly to quality characteristics/aspects of the four human-centred design activities of the DIN EN ISO 13407: ‘context of use’, ‘user requirements’, ‘produce design solutions’ and ‘evaluation of use’. The goal was to identify, what constitutes the quality of a certain activity from the experts’ point of view and what kind of success and quality criteria exist that are relevant on a process level and subsequently for the implementation in practice. The results highlight first insights especially regarding quality aspects of usability engineering activities. Even if these could not be generalized, the results reflect the experts’ fundamental tendencies and opinions. Beyond this, it could have been proved that there is such thing as ‘common mind’ in terms of what experts think of when they talk about user centred design and this is certainly represented by the definition of the human-centred-design process in the DIN EN ISO 13407. However, even if the experts’ opinions sometimes differ on how to implement these activities (e.g. in using methodologies, methods, tools, etc.), they follow the same goal: to ensure a specific quality of these activities. Thus, there is no generic answer of how an activity has to be performed in detail – the question is how to assure that everything needed is being performed in order to gain a certain quality of a result, an activity or the process itself. This article shows first results on this important question. The presented approach does not only highlight weaknesses of software engineering process models, it additionally identifies opportunities for the integration between software engineering and usability engineering. These can be used as a foundation to implement the operational process level and will help to guarantee the interplay of software engineering and usability engineering in practice, which is part of the authors’ future work. The gathered knowledge about the quality aspects of usability engineering can serve as a basis for a successful integration with software engineering and leads to high quality results and activities. In the future, the authors expect to derive specific recommendations to enrich software engineering models by adding or adapting usability engineering activities, phases, artefacts, etc. By doing this, the development of usable software on the level of process models will be guaranteed. Furthermore, the authors will present further results based on the questionnaires and will work out a guideline/checklist of usability engineering demands that account for the integration of usability engineering into software engineering models. 8. Acknowledgement We would like to express our sincere appreciation to all those who have contributed, directly or indirectly, to this work in form of technical or other support. In particular we would like to thank Markus Düchting for his assistance. A special thank to Lennart Grötzbach always helping us to find the right words. We would like to thank Thomas Geis and Jan Gulliksen for the fruitful and intensive discussions and the helpful input. We also like to thank the remaining interview partners for their help and efforts. 9. References DIN EN ISO 13407 (1999). Human-centered design processes for interactive systems, CEN - European Committee for Standardization, Brussels DIN EN ISO 9241-12 (1998) Ergonomic requirements for office work with visual display terminals (VDTs) - Part 12: Presentation of information, ISO Copyright Office, Geneva, Switzerland Mayhew, D. J. (1999). *The Usability Engineering Lifecycle*, Morgan Kaufmann, San Francisco In these 34 chapters, we survey the broad disciplines that loosely inhabit the study and practice of human-computer interaction. Our authors are passionate advocates of innovative applications, novel approaches, and modern advances in this exciting and developing field. It is our wish that the reader consider not only what our authors have written and the experimentation they have described, but also the examples they have set. How to reference In order to correctly reference this scholarly work, feel free to copy and paste the following: http://www.intechopen.com/books/advances_in_human_computer_interaction/integrating_software_engineering_and_usability_engineering
{"Source-Url": "http://cdn.intechopen.com/pdfs-wm/5451.pdf", "len_cl100k_base": 11853, "olmocr-version": "0.1.49", "pdf-total-pages": 22, "total-fallback-pages": 0, "total-input-tokens": 54441, "total-output-tokens": 14439, "length": "2e13", "weborganizer": {"__label__adult": 0.00037598609924316406, "__label__art_design": 0.0009551048278808594, "__label__crime_law": 0.000293731689453125, "__label__education_jobs": 0.0040740966796875, "__label__entertainment": 7.086992263793945e-05, "__label__fashion_beauty": 0.00017821788787841797, "__label__finance_business": 0.00036454200744628906, "__label__food_dining": 0.00037980079650878906, "__label__games": 0.0007638931274414062, "__label__hardware": 0.0006623268127441406, "__label__health": 0.0003857612609863281, "__label__history": 0.0003578662872314453, "__label__home_hobbies": 8.273124694824219e-05, "__label__industrial": 0.0004317760467529297, "__label__literature": 0.00046181678771972656, "__label__politics": 0.00022423267364501953, "__label__religion": 0.0004982948303222656, "__label__science_tech": 0.017486572265625, "__label__social_life": 8.678436279296875e-05, "__label__software": 0.0070648193359375, "__label__software_dev": 0.9638671875, "__label__sports_fitness": 0.00029158592224121094, "__label__transportation": 0.00041556358337402344, "__label__travel": 0.00019347667694091797}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 66032, 0.02542]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 66032, 0.37786]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 66032, 0.92132]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 2937, false], [2937, 6515, null], [6515, 9117, null], [9117, 12548, null], [12548, 14625, null], [14625, 18515, null], [18515, 22225, null], [22225, 25053, null], [25053, 27763, null], [27763, 29743, null], [29743, 33164, null], [33164, 36717, null], [36717, 40507, null], [40507, 44311, null], [44311, 48096, null], [48096, 52008, null], [52008, 55639, null], [55639, 59306, null], [59306, 62514, null], [62514, 65131, null], [65131, 66032, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 2937, true], [2937, 6515, null], [6515, 9117, null], [9117, 12548, null], [12548, 14625, null], [14625, 18515, null], [18515, 22225, null], [22225, 25053, null], [25053, 27763, null], [27763, 29743, null], [29743, 33164, null], [33164, 36717, null], [36717, 40507, null], [40507, 44311, null], [44311, 48096, null], [48096, 52008, null], [52008, 55639, null], [55639, 59306, null], [59306, 62514, null], [62514, 65131, null], [65131, 66032, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 66032, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 66032, null]], "pdf_page_numbers": [[0, 0, 1], [0, 2937, 2], [2937, 6515, 3], [6515, 9117, 4], [9117, 12548, 5], [12548, 14625, 6], [14625, 18515, 7], [18515, 22225, 8], [22225, 25053, 9], [25053, 27763, 10], [27763, 29743, 11], [29743, 33164, 12], [33164, 36717, 13], [36717, 40507, 14], [40507, 44311, 15], [44311, 48096, 16], [48096, 52008, 17], [52008, 55639, 18], [55639, 59306, 19], [59306, 62514, 20], [62514, 65131, 21], [65131, 66032, 22]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 66032, 0.19149]]}
olmocr_science_pdfs
2024-11-26
2024-11-26
1832525f2b87e3102ded648059e583ee37e18a01
KDE Fundamentals T.C. Hollingsworth ## Contents 1 Introduction 7 2 Installing KDE Plasma Desktop and KDE Applications 8 2.1 Installing Packages ................................................. 8 2.1.1 Linux® .............................................................. 8 2.1.2 Microsoft® Windows® ........................................... 8 2.1.3 Mac®OS ............................................................ 9 2.1.4 BSD™ .............................................................. 9 2.1.5 Mobile Devices .................................................... 9 2.1.6 Live Media ........................................................ 9 2.1.7 Building from Source Code .................................... 9 3 Finding Your Way Around 10 3.1 A Visual Dictionary .................................................. 10 3.1.1 The Big Picture ................................................ 10 3.1.1.1 Windows ...................................................... 10 3.1.1.2 Elements of Graphical User Interface (GUI) .......... 12 3.1.2 The Widgets ...................................................... 14 3.2 Common Menus ....................................................... 19 3.2.1 The File Menu ................................................... 20 3.2.2 The Edit Menu .................................................. 20 3.2.3 The View Menu .................................................. 21 3.2.4 The Tools Menu .................................................. 21 3.2.5 The Settings Menu .............................................. 22 3.2.6 The Help Menu .................................................. 22 3.2.7 Thanks and Acknowledgments .................................. 23 3.3 Common Keyboard Shortcuts ........................................ 23 3.3.1 Working with Windows ......................................... 23 3.3.1.1 Starting and Stopping Applications .................. 23 3.3.1.2 Moving Around ........................................... 24 3.3.1.3 Panning and Zooming ................................... 24 3.3.2 Working with Activities and Virtual Desktops ............. 25 <table> <thead> <tr> <th>Section</th> <th>Title</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>3.3.3</td> <td>Working with the Desktop</td> <td>25</td> </tr> <tr> <td>3.3.4</td> <td>Getting Help</td> <td>25</td> </tr> <tr> <td>3.3.5</td> <td>Working with Documents</td> <td>25</td> </tr> <tr> <td>3.3.6</td> <td>Working with Files</td> <td>26</td> </tr> <tr> <td>3.3.7</td> <td>Changing Volume and Brightness</td> <td>26</td> </tr> <tr> <td>3.3.8</td> <td>Leaving Your Computer</td> <td>26</td> </tr> <tr> <td>3.3.9</td> <td>Modifying Shortcuts</td> <td>27</td> </tr> <tr> <td>4</td> <td>Common Tasks</td> <td>28</td> </tr> <tr> <td>4.1</td> <td>Navigating Documents</td> <td>28</td> </tr> <tr> <td>4.1.1</td> <td>Scrolling</td> <td>28</td> </tr> <tr> <td>4.1.2</td> <td>Zooming</td> <td>29</td> </tr> <tr> <td>4.2</td> <td>Opening and Saving Files</td> <td>29</td> </tr> <tr> <td>4.2.1</td> <td>Introduction</td> <td>29</td> </tr> <tr> <td>4.2.2</td> <td>The File Selection Window</td> <td>29</td> </tr> <tr> <td>4.2.3</td> <td>Thanks and Acknowledgments</td> <td>33</td> </tr> <tr> <td>4.3</td> <td>Check Spelling</td> <td>34</td> </tr> <tr> <td>4.3.1</td> <td>Check Spelling</td> <td>34</td> </tr> <tr> <td>4.3.2</td> <td>Automatic Spell Checking</td> <td>34</td> </tr> <tr> <td>4.3.3</td> <td>Configuring Sonnet</td> <td>35</td> </tr> <tr> <td>4.3.4</td> <td>Thanks and Acknowledgments</td> <td>35</td> </tr> <tr> <td>4.4</td> <td>Find and Replace</td> <td>35</td> </tr> <tr> <td>4.4.1</td> <td>The Find Function</td> <td>35</td> </tr> <tr> <td>4.4.2</td> <td>The Replace Function</td> <td>37</td> </tr> <tr> <td>4.4.3</td> <td>Thanks and Acknowledgments</td> <td>38</td> </tr> <tr> <td>4.5</td> <td>Choosing Fonts</td> <td>38</td> </tr> <tr> <td>4.6</td> <td>Choosing Colors</td> <td>39</td> </tr> <tr> <td>4.6.1</td> <td>Using Basic Colors</td> <td>39</td> </tr> <tr> <td>4.6.2</td> <td>Mixing Colors</td> <td>40</td> </tr> <tr> <td>4.6.2.1</td> <td>Using the Grid</td> <td>40</td> </tr> <tr> <td>4.6.2.2</td> <td>Using the Screen Colors</td> <td>40</td> </tr> <tr> <td>4.6.2.3</td> <td>Hue/Saturation/Value</td> <td>40</td> </tr> <tr> <td>4.6.2.4</td> <td>Red/Green/Blue</td> <td>40</td> </tr> <tr> <td>4.6.2.5</td> <td>HTML Hexadecimal Code</td> <td>40</td> </tr> <tr> <td>4.6.3</td> <td>Custom Colors</td> <td>40</td> </tr> </tbody> </table> 5 Customizing KDE software 5.1 Customizing Toolbars 5.1.1 Modifying Toolbar Items 5.1.1.1 Adding an Item 5.1.1.2 Removing an Item 5.1.1.3 Changing the Position of Items 5.1.1.4 Adding a Separator 5.1.1.5 Restoring Defaults 5.1.1.6 Changing Text and Icons 5.1.2 Customizing Toolbar Appearance 5.1.2.1 Text Position 5.1.2.2 Icon Size 5.1.2.3 Moving Toolbars 5.1.2.4 Show/Hide Toolbars 5.1.3 Thanks and Acknowledgments 5.2 Using and Customizing Shortcuts 5.2.1 Introduction 5.2.2 Changing a Shortcut 5.2.3 Resetting Shortcuts 5.2.4 Removing a Shortcut 5.2.5 Working with Schemes 5.2.6 Printing Shortcuts 5.2.7 Thanks and Acknowledgments 6 Credits and License Abstract This guide provides an introduction to the Plasma workspace and applications and describes many common tasks that can be performed. Chapter 1 Introduction Welcome to KDE! This guide will introduce you to the many features of the Plasma workspace and applications and describe many common tasks you can perform. For more information on KDE, visit the KDE website. Chapter 2 Installing KDE Plasma Desktop and KDE Applications You can install KDE applications, including KDE Plasma Desktop, on a variety of different platforms, ranging from smartphones and tablets to computers running Microsoft® Windows®, Mac®, OS, UNIX®, BSD™ or Linux®. Binary packages are available for many different platforms and distributions, or advanced users may build the source code. 2.1 Installing Packages Hundreds of developers worldwide have done a lot of work to make it easy to install KDE onto a variety of different devices and platforms. 2.1.1 Linux® Nearly every Linux® distribution provides binary packages for individual applications and the KDE Plasma Desktop as a whole. To install an individual application, look for its name in your distribution’s package collection. To install one of the KDE Plasma Workspaces, like KDE Plasma Desktop, look for a metapackage or package group, typically plasma-desktop. **NOTE** Some applications may be installed together with other applications in a combined package named after the KDE package they are provided in. For instance, Konqueror might be found in the kde-base apps package. If you have trouble locating KDE packages for your distribution, please contact their support resources. Many distributions also have a team dedicated to packaging applications by KDE that can provide assistance specific to them. 2.1.2 Microsoft® Windows® The KDE on Windows Initiative provides binary packages of KDE applications for Microsoft® Windows®. They also provide a special installer application that permits you to install individual applications or groups and all necessary dependencies easily. For more information on the initiative and to download the installer, visit the KDE on Windows Initiative. ### 2.1.3 Mac® OS Individual KDE applications can be installed through several different ‘ports’ systems available for Mac® OS. Several different KDE applications also provide their own binary builds for Mac® OS. For more information, visit KDE on Mac OSX. ### 2.1.4 BSD™ Most BSD™ distributions allows you to install KDE applications and the KDE Plasma Desktop through their ‘ports’ system. For more information on installing ports, see your BSD™ distribution’s documentation. ### 2.1.5 Mobile Devices Plasma Mobile is an exciting initiative to bring a new KDE experience to mobile devices like smartphones or tablets. Binary releases are provided for several different devices. For more information, visit Plasma Mobile. ### 2.1.6 Live Media Several Linux® and BSD™ distributions offer live media. This permits you to try out the KDE Plasma Desktop without installing anything to your system. All you have to do insert a CD or connect a USB drive and boot from it. If you like what you see, most offer an option to install it to your hard drive. There is a list of distributions that offer the KDE workspace and applications on live media on the KDE website. ### 2.1.7 Building from Source Code For detailed information on how to compile and install KDE Plasma Desktop and applications see Build from source. Since KDE software uses cmake you should have no trouble compiling it. Should you run into problems please report them to the KDE mailing lists. The recommended tool to build Frameworks, KDE Plasma Desktop and all the other applications is kdesrc-build 3.1 A Visual Dictionary The KDE Plasma Workspaces feature many different graphical user interface elements, commonly known as ‘widgets’. This guide will introduce you to their names and functions. 3.1.1 The Big Picture 3.1.1.1 Windows This is the window of the KWrite, a text editor. Click on part of the window to learn more about it. 1. The **Window Menu** 2. The **Titlebar** KDE Fundamentals 3. Buttons to *minimize, maximize, or close the window* 4. The **Menubar** 5. The **Toolbar** 6. A very large **Text Area** that acts as this program’s **Central Widget** 7. A vertical **Scrollbar** (there is also a horizontal scrollbar below the text box) 8. The **Statusbar** This is the another window, that of the Dolphin file manager. Click on part of the window to learn more about it. 1. A **panel** that contains a list of Places on the computer system 2. A **Breadcrumb** of the path of the displayed folder 3. A folder **Icon** 4. A file **Icon** 5. A highlighted **Icon** 6. A **Context Menu** listing actions that can be performed on a file 7. A **Slider** that changes the size of the Icons displayed 8. More **Panels** 3.1.1.2 Elements of Graphical User Interface (GUI) This screenshot, from the System Settings Formats panel, shows some GUI elements. Click on part of the window to learn more about it. 1. An **Icon List** (the second item is selected) 2. An open **Drop Down Box** 3. An item in the **Drop Down Box** that has been selected 4. Some more **Buttons** KDE Fundamentals This screenshot, from the System Settings Custom Shortcuts panel, shows some more GUI elements. 1. A Tree View 2. A Check Box that has been selected 3. A pair of Spin Boxes 4. A Menu Button This screenshot, from the System Settings Default Applications panel, shows even more GUI elements. Click on part of the window to learn more about it. 1. A List Box 2. A pair of Radio Buttons 3. A Text Box Finally, this screenshot, from the System Settings Colors panel, shows five Tabs ### 3.1.2 The Widgets <table> <thead> <tr> <th>Name</th> <th>Description</th> <th>Screenshot</th> </tr> </thead> <tbody> <tr> <td>Central Widget</td> <td>The main area of the running application. This might be the document you are editing in a word processor or the board of a game like Chess.</td> <td><img src="image.png" alt="Central Widget" /></td> </tr> <tr> <td>Button</td> <td>These can be clicked with the left mouse button to perform an action.</td> <td><img src="image.png" alt="OK Button" /></td> </tr> <tr> <td>Breadcrumb</td> <td>Shows the path in a hierarchical system, such as a filesystem. Click on any part of the path to go up in the tree to that location. Click on the arrow to the right of part of the path to go to another child element of that path.</td> <td><img src="image.png" alt="Breadcrumb" /></td> </tr> <tr> <td><strong>KDE Fundamentals</strong></td> <td></td> <td></td> </tr> <tr> <td>----------------------</td> <td></td> <td></td> </tr> <tr> <td><strong>Check Box</strong></td> <td>These can be clicked to select and unselect items. They are typically used in a list of several selections. Selected items typically display a check mark, whereas unselected items will have an empty box.</td> <td></td> </tr> <tr> <td><strong>Color Selector</strong></td> <td>This allows a color to be selected for various purposes, such as changing the color of text. For more information, see Section 4.6</td> <td></td> </tr> <tr> <td><strong>Combo Box</strong></td> <td>A combination of a Drop Down Box and a Text Box. You can select an option from the list, or type in the text box. Some combo boxes may automatically complete entries for you, or open the list with a list of choices that match what you have typed.</td> <td></td> </tr> <tr> <td><strong>Context Menu</strong></td> <td>Many user interface elements in the Plasma Workspace and in Applications contain a context menu, which can be opened by clicking on something with the right mouse button. This menu contains options and actions that usually affect the user interface element that was right-clicked.</td> <td></td> </tr> <tr> <td><strong>Dialog Box</strong></td> <td>A small window that appears above a larger application window. It may contain a message, warning, or configuration panel, among others.</td> <td></td> </tr> <tr> <td><strong>Drop Down Box</strong></td> <td>This provides a list of items, from which you may select one.</td> <td></td> </tr> <tr> <td>Icon</td> <td>A graphical representation of something, such as a file or action. They typically, but not always, also contain a text description, either beneath or to the right of the icon.</td> <td></td> </tr> <tr> <td>---</td> <td>---</td> <td></td> </tr> </tbody> </table> <table> <thead> <tr> <th>Icon List</th> <th>This provides a list of items represented by an Icon and a description. It is typically used in the left panel of configuration panels to allow selection from various types of configuration categories.</th> </tr> </thead> </table> <table> <thead> <tr> <th>List Box</th> <th>This is a list of items that typically allows multiple items to be selected. To select a group of contiguous items, press the Shift key and click the first and last items. To select multiple items that are not contiguous, press the Ctrl key and select the desired items.</th> </tr> </thead> </table> | Menu | A list of selections, that usually perform an action, set an option, or opens a window. These can be opened from menubars or menu buttons. | ### KDE Fundamentals <table> <thead> <tr> <th><strong>Menubar</strong></th> <th>These are located at the top of nearly every window and provide access to all the functions of the running application. For more information, see Section 3.2.</th> </tr> </thead> <tbody> <tr> <td><strong>Menu Button</strong></td> <td>A special type of button that opens a menu.</td> </tr> <tr> <td><strong>Panel or Sidebar or Tool View</strong></td> <td>These are located on the sides or bottom of the central widget and allow you to perform many different tasks in an application. A text editor might provide a list of open documents in one, while a word processor might allow you to select a clip art image.</td> </tr> <tr> <td><strong>Progress Bar</strong></td> <td>A small bar that indicates that a long-running operation is being performed. The bar may indicate how much of the operation has completed, or it may simply bounce back and forth to indicate that the operation is in progress.</td> </tr> <tr> <td><strong>Radio Button</strong></td> <td>These are used in a list of options, and only permit one of the options in the list to be selected.</td> </tr> <tr> <td><strong>Scrollbar</strong></td> <td>Allows you to navigate a document.</td> </tr> <tr> <td><strong>Slider</strong></td> <td>Allows a numeric value to be selected by moving a small bar either horizontally or vertically across a line.</td> </tr> <tr> <td>-----------</td> <td>-------------------------------------------------------------------------------------------------</td> </tr> <tr> <td><strong>Spin Box</strong></td> <td>This permits a numerical value to be selected, either by using the up and down arrows to the right of the box to raise or lower the value, respectively, or by typing the value into the text box.</td> </tr> <tr> <td><strong>Status Bar</strong></td> <td>These are located at the bottom of many applications and display information about what the application is currently doing. For instance, a web browser might indicate the progress of loading a web page, while a word processor might display the current word count.</td> </tr> <tr> <td><strong>Tab</strong></td> <td>These appear at the top of an area of a window, and permit that area of the window to be changed to a variety of different selections.</td> </tr> <tr> <td><strong>Text Area</strong></td> <td>Allows a large amount of text to be typed in, typically multiple lines or paragraphs. Unlike a Text Box, pressing Enter will usually result in a line break.</td> </tr> <tr> <td><strong>Text Box</strong></td> <td>A single-line text entry that allows a small amount of text to be typed in. Typically, pressing Enter will perform the same action as clicking the OK button.</td> </tr> <tr> <td><strong>Titlebar</strong></td> <td>This is located at the top of every window. It contains the name of the application and usually information about what the application is doing, like the title of the web page being viewed in a web browser or the filename of a document open in a word processor.</td> </tr> </tbody> </table> ### Toolbar These are located near the top of many applications, typically directly underneath the **menu bar**. They provide access to many common functions of the running application, like *Save* or *Print*. ### Tree View A Tree View allows you to select from a hierarchical list of options. A section, or category, of the Tree View may be unexpanded, in which case no options will appear beneath it and the arrow to the left of the title will be pointing right, toward the title. It may also be expanded, in which case several options will be listed below it, and the arrow to the left of the title will be pointing down, toward the options. To expand a portion of the tree view, click the arrow to the left of the title of the section you wish to expand, double-click on the title, or select the title using your keyboard's arrow keys and press the **Enter** or + key. To minimize a portion of the tree view, you may also click the arrow, double-click on the title, or press the **Enter** or - key. ### 3.2 Common Menus Many KDE applications contain these menus. However, most applications will have more menu entries than those listed here, and others may be missing some of the entries listed here. *The menubar in Gwenview.* Some applications, like Dolphin, do not show a menubar by default. You can show it by pressing \texttt{Ctrl-M}. You can also use this to hide the menubar in applications that support doing so. ### 3.2.1 The File Menu The \texttt{File} menu allows you to perform operations on the currently open file and access common tasks in applications. Common menu items include: - \texttt{File $\rightarrow$ New (Ctrl+N)} - Creates a new file. - \texttt{File $\rightarrow$ New Window} - Opens a new window. - \texttt{File $\rightarrow$ Open... (Ctrl+O)} - Opens an already existing file. - \texttt{File $\rightarrow$ Save (Ctrl+S)} - Saves the file. If the file already exists it will be overwritten. - \texttt{File $\rightarrow$ Save As...} - Saves the file with a new filename. - \texttt{File $\rightarrow$ Save All} - Saves all open files. - \texttt{File $\rightarrow$ Reload (F5)} - Reloads the current file. - \texttt{File $\rightarrow$ Reload All} - Reloads all open files. - \texttt{File $\rightarrow$ Print... (Ctrl+P)} - Prints the file. Use \texttt{Print to File (PDF)} to generate a PDF file or select a range of pages to print only these pages to a new PDF file. - \texttt{File $\rightarrow$ Close (Ctrl+W)} - Closes the current file. - \texttt{File $\rightarrow$ Close All} - Closes all open files. - \texttt{File $\rightarrow$ Quit (Ctrl+Q)} - Exits the program. ### 3.2.2 The Edit Menu The \texttt{Edit} menu allows you to modify the currently open file. - \texttt{Edit $\rightarrow$ Undo (Ctrl+Z)} - Undo the last action you performed in the file. - \texttt{Edit $\rightarrow$ Redo (Ctrl+Shift+Z)} - Redo the last action you performed in the file. Edit → Cut (Ctrl+X) Removes the currently selected portion of the file, if any, and places a copy of it in the clipboard buffer. Edit → Copy (Ctrl+C) Places a copy of the currently selected portion of the file, if any, in the clipboard buffer. Edit → Paste (Ctrl+V) Copies the first item in the clipboard buffer to the current location in the file, if any. Edit → Select All (Ctrl+A) Selects the entire contents of the currently open file. Edit → Find... (Ctrl+F) Allows you to search for text in the currently open file. Edit → Replace... (Ctrl+R) Allows you to search for text in the currently open file and replace it with something else. Edit → Find Next (F3) Go to the next match of the last Find operation. Edit → Find Previous (Shift+F3) Go to the previous match of the last Find operation. 3.2.3 The View Menu The View menu allows you to change the layout of the currently open file and/or the running application. This menu has different options depending on the application you are using. 3.2.4 The Tools Menu The Tools menu allows you to perform certain actions on the currently open file. Tools → Automatic Spell Checking (Ctrl+Shift+O) Check for spelling errors as you type. For more information, see Section 4.3.2. Tools → Spelling... This initiates the spellchecking program - a program designed to help the user catch and correct any spelling errors. For more information, see Section 4.3.1. Tools → Spelling (from cursor)... This initiates the spellchecking program, but only checks the portion of the document from the current location of the cursor to the end. For more information, see Section 4.3.1. Tools → Spellcheck Selection... This initiates the spellchecking program, but only checks the currently selected text in the document. For more information, see Section 4.3.1. Tools → Change Dictionary... This allows you to change the dictionary used to check spellings. For more information, see Section 4.3.3. 3.2.5 The Settings Menu The Settings allows you to customize the application. This menu typically contains the following items: **Settings → Show Menubar (Ctrl+M)** Toggle the Menubar display on and off. Once hidden it can be made visible using the shortcut Ctrl+M again. If the menubar is hidden, the context menu opened with a right mouse button click anywhere in the view area has an extra entry Show Menubar. **Settings → Show Statusbar** Toggles the display of the statusbar on and off. Some KDE applications use statusbar at the bottom of their screen to display useful information. **Settings → Toolbars Shown** Allows you to show and hide the various toolbars supported by the application. **Settings → Show Statusbar** When checked, this displays a small bar at the bottom of the application containing information about the status. When unchecked the status bar is hidden. **Settings → Configure Shortcuts...** Allows you to enable, disable, and modify keyboard shortcuts. For more information, see Section 5.2. **Settings → Configure Toolbars...** Allows you to customize the contents, layout, text, and icons of toolbars. For more information, see Section 5.1. **Settings → Configure Notifications...** This item displays a standard KDE notifications configuration dialog, where you can change the notifications (sounds, visible messages, etc.) used by the application. For more information how to configure notifications please read the documentation for the System Settings module Manage Notifications. **Settings → Configure Application...** Opens the configuration panel for the currently running application. 3.2.6 The Help Menu The Help menu gives you access to the application’s documentation and other useful resources. **Help → Application Handbook (F1)** Invokes the KDE Help system starting at the running application’s handbook. **Help → What’s This? (Shift+F1)** Changes the mouse cursor to a combination arrow and question mark. Clicking on items within the application; will open a help window (if one exists for the particular item) explaining the item’s function. **Help → Tip of the Day** This command opens the Tip of the Day dialog. You can page through all the tips by using the buttons on the dialog and select to show the tips at startup. Note: Not all applications provide these tips. Help → Report Bug... Opens the Bug report dialog where you can report a bug or request a ‘wishlist’ feature. Help → Donate Opens the Donations page where you can support KDE and its projects. Help → Switch Application Language... Opens a dialog where you can edit the Primary language and Fallback language for this application. Help → About Application This will display version and author information for the running application. Help → About KDE This displays the KDE Development Platform version and other basic information. 3.2.7 Thanks and Acknowledgments Special thanks to an anonymous Google Code-In 2011 participant for writing much of this documentation. 3.3 Common Keyboard Shortcuts The KDE Plasma Workspaces provide keyboard shortcuts that allow you to perform many tasks without touching your mouse. If you use your keyboard frequently, using these can save you lots of time. This list contains the most common shortcuts supported by the workspace itself and many applications available within. Every application also provides its own shortcuts, so be sure to check their manuals for a comprehensive listing. NOTE The Meta key described below is a generic name for the custom key found on many different keyboards. On keyboards designed for Microsoft® Windows®, this key is usually called the Windows key, and will have a picture of the Windows® logo. On keyboards designed for Mac® computers, this key is known as the Command key and will have a picture of the Apple® logo and/or the ⌘ symbol. On keyboards designed for UNIX® systems, this key is really known as the Meta key and is typically labeled with a diamond: ◆ 3.3.1 Working with Windows These shortcuts allow you to perform all kinds of operations with windows, whether it be opening, closing, moving, or switching between them. 3.3.1.1 Starting and Stopping Applications These shortcuts make it easy to start and stop programs. 3.3.1.2 Moving Around These shortcuts allow you to navigate between windows, activities, and desktops efficiently. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Meta</td> <td>Open the Application Launcher</td> </tr> <tr> <td>Alt+Space / Alt+F2</td> <td>Run Command Interface</td> </tr> <tr> <td>Ctrl+Esc</td> <td>System Activity</td> </tr> <tr> <td>Alt+F4</td> <td>Close</td> </tr> <tr> <td>Ctrl+Q</td> <td>Quit</td> </tr> <tr> <td>Ctrl+Alt+Esc</td> <td>Force Quit</td> </tr> </tbody> </table> 3.3.1.3 Panning and Zooming Need to get a closer look? The KDE Plasma Workspaces allow you to zoom in and out and move your entire desktop around, so you can zoom in even when the application you are using doesn’t support it. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Meta+=</td> <td>Zoom In</td> </tr> <tr> <td>Meta+-</td> <td>Zoom Out</td> </tr> <tr> <td>Meta+0</td> <td>Zoom Normal</td> </tr> <tr> <td>Meta+Up</td> <td>Pan Up</td> </tr> <tr> <td>Meta+Down</td> <td>Pan Down</td> </tr> <tr> <td>Meta+Left</td> <td>Pan left</td> </tr> <tr> <td>Meta+Right</td> <td>Pan Right</td> </tr> </tbody> </table> 3.3.2 Working with Activities and Virtual Desktops These shortcuts allow you to switch between and manage Activities and virtual desktops. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Meta+Q / Alt+D,Alt+A</td> <td>Manage Activities</td> </tr> <tr> <td>Meta+Tab</td> <td>Next Activity</td> </tr> <tr> <td>Meta+Shift+Tab</td> <td>Previous Activity</td> </tr> <tr> <td>Ctrl+F1</td> <td>Switch to Desktop 1</td> </tr> <tr> <td>Ctrl+F2</td> <td>Switch to Desktop 2</td> </tr> <tr> <td>Ctrl+F3</td> <td>Switch to Desktop 3</td> </tr> <tr> <td>Ctrl+F4</td> <td>Switch to Desktop 4</td> </tr> </tbody> </table> 3.3.3 Working with the Desktop These shortcuts allow you to work with the KDE Plasma Desktop and panels. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>AltD A</td> <td>Add Widgets</td> </tr> <tr> <td>AltD R</td> <td>Remove this Widget</td> </tr> <tr> <td>AltD L</td> <td>Lock/Unlock Widgets</td> </tr> <tr> <td>AltD S</td> <td>Widget Settings</td> </tr> <tr> <td>Ctrl+F12</td> <td>Show Desktop</td> </tr> <tr> <td>AltD T</td> <td>Run the Associated Application</td> </tr> <tr> <td>Alt+D,Alt+S</td> <td>Desktop Settings</td> </tr> </tbody> </table> 3.3.4 Getting Help Need some help? The manual for the current application is only a keypress away, and some programs even have additional help that explains the element in focus. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>F1</td> <td>Help</td> </tr> <tr> <td>Shift+F1</td> <td>What’s This?</td> </tr> </tbody> </table> 3.3.5 Working with Documents Whether it’s a text document, spreadsheet, or web site, these shortcuts make performing many kinds of tasks with them easy. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>F5</td> <td>Refresh</td> </tr> <tr> <td>Ctrl+A</td> <td>Select All</td> </tr> </tbody> </table> 3.3.6 Working with Files Whether you are in an Open/Save dialog or the Dolphin file manager, these shortcuts save you time when performing operations on files. Note that some of the concepts used with files are the same as with documents, so several of the shortcuts are identical to their counterparts listed above. <table> <thead> <tr> <th>Shortcut</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Ctrl+Z</td> <td>Undo</td> </tr> <tr> <td>Ctrl+Shift+Z</td> <td>Redo</td> </tr> <tr> <td>Ctrl+X</td> <td>Cut</td> </tr> <tr> <td>Ctrl+C</td> <td>Copy</td> </tr> <tr> <td>Ctrl+V</td> <td>Paste</td> </tr> <tr> <td>Ctrl+N</td> <td>New</td> </tr> <tr> <td>Ctrl+P</td> <td>Print</td> </tr> <tr> <td>Ctrl+S</td> <td>Save</td> </tr> <tr> <td>Ctrl+F</td> <td>Find</td> </tr> <tr> <td>Ctrl+W</td> <td>Close Document/Tab</td> </tr> <tr> <td>Ctrl+A</td> <td>Select All</td> </tr> <tr> <td>Ctrl+L</td> <td>Replace Location</td> </tr> <tr> <td>Ctrl+Shift+A</td> <td>Invert Selection</td> </tr> <tr> <td>Alt+Left</td> <td>Back</td> </tr> <tr> <td>Alt+Right</td> <td>Forward</td> </tr> <tr> <td>Alt+Up</td> <td>Up (to folder that contains this one)</td> </tr> <tr> <td>Alt+Home</td> <td>Home Folder</td> </tr> <tr> <td>Delete</td> <td>Move to Trash</td> </tr> <tr> <td>Shift+Delete</td> <td>Delete Permanently</td> </tr> </tbody> </table> 3.3.7 Changing Volume and Brightness In addition to the standard keys, many computer keyboards and laptops nowadays have special keys or buttons to change the speaker volume, as well as the brightness of your monitor if applicable. If present, you can use these keys in the KDE Plasma Workspaces to perform those tasks. If you do not have such keys, see Section 3.3.9 for information on how to assign keys for these tasks. 3.3.8 Leaving Your Computer All done? Use these shortcuts and put your computer away! 3.3.9 Modifying Shortcuts The shortcuts described in Working With Windows, Leaving Your Computer, Changing Volume and Brightness and Working with Activities and Virtual Desktops are called *global shortcuts*, since they work regardless of which window you have open on your screen. These can be modified in the Global Shortcuts panel of System Settings, where they are separated by KDE component. The shortcuts described Working with the Desktop are immutable and cannot be modified. The shortcuts described in Working with Documents and Getting Help are set by individual programs. Most KDE programs allow you to use the common shortcut editing dialog to modify these. The shortcuts described in Working With Files can be edited in the same manner when used inside a file manager like Dolphin or Konqueror, but cannot be modified in the case of Open/Save dialogs, etc. Chapter 4 Common Tasks 4.1 Navigating Documents 4.1.1 Scrolling You’re probably familiar with the scrollbar that appears on the right side (and sometimes the bottom) of documents, allowing you to move within documents. However, there are several other ways you can navigate documents, some of which are faster and easier. Several mice have a wheel in the middle. You can move it up and down to scroll within a document. If you press the `Shift` key while using the mouse wheel, the document will scroll faster. If you’re using a portable computer like a laptop, you might also be able to scroll using the touchpad. Some computers allow you to scroll vertically by moving your finger up and down the rightmost side of the touchpad, and allow you to scroll horizontally by moving your finger across the bottommost side of the touchpad. Others let you scroll using two fingers: move both fingers up and down anywhere on the touchpad to scroll vertically, and move them left and right to scroll horizontally. Since this functionality emulates the mouse wheel functionality described above, you can also press the `Shift` key while you do this to scroll faster. If you use the KDE Plasma Workspaces, you can control mouse wheel behavior in the Mouse module in System Settings, and you can control touchpad scrolling behavior in the Touchpad module in System Settings. Otherwise, look in the configuration area of your operating system or desktop environment. Additionally, the scrollbar has several options in its context menu. You can access these by right-clicking anywhere on the scrollbar. The following options are available: **Scroll here** Scroll directly to the location represented by where you right-clicked on the scrollbar. This is the equivalent of simply clicking on that location on the scrollbar. **Top (Ctrl+Home)** Go to the beginning of the document. **Bottom (Ctrl+End)** Go to the end of the document. **Page up (PgUp)** Navigate to the previous page in a document that represents a printed document, or one screen up in other types of documents. Page down (PgDn) Navigate to the next page in a document that represents a printed document, or one screen down in other types of documents. Scroll up Scroll up one unit (usually a line) in the document. This is the equivalent of clicking the up arrow at the top of the scrollbar. Scroll down Scroll down one unit (usually a line) in the document. This is the equivalent of clicking the down arrow at the bottom of the scrollbar. 4.1.2 Zooming Many applications permit you to zoom. This makes the text or image you are viewing larger or smaller. You can generally find the zoom function in the View menu, and sometimes in the status bar of the application. You can also zoom using the keyboard by pressing Ctrl++ to zoom in, or Ctrl+- to zoom out. If you can scroll with the mouse wheel or touchpad as described in Section 4.1.1, you can also zoom by pressing Ctrl and scrolling that way. 4.2 Opening and Saving Files 4.2.1 Introduction Many KDE applications work with files. Most applications have a File menu with options that allow you to open and save files. For more information on that, see Section 3.2.1. However, there are lots of different operations that require selecting a file. Regardless of the method, all KDE applications generally use the same file selection window. Opening a file in Konqueror. 4.2.2 The File Selection Window The Toolbar This contains standard navigation tool buttons: KDE Fundamentals Back Causes the folder view to change to the previously displayed folder in its history. This button is disabled, if there is no previous item. Forward Causes the folder view to change to the next folder in its history. This button is disabled, if there is no next folder. Parent Folder This will cause the folder view to change to the immediate parent of the currently displayed folder, if possible. Reload (F5) Reloads the folder view, displaying any changes that have been made since it was first loaded or last reloaded. Show Preview Displays a preview of each file inside the folder view. Zoom Slider This allows you to change the size of the icon or preview shown in the folder view. Options Options → Sorting Options → Sorting → By Name Sort files listed in the folder view alphabetically by name. Options → Sorting → By Size Sort files listed in the folder view in order of their file size. Options → Sorting → By Date Sort files listed in the folder view by the date they were last modified. Options → Sorting → By Type Sort files listed in the folder view alphabetically by their file type. Options → Sorting → Descending When unchecked (the default), files in the folder view will be sorted in ascending order. (For instance, files sorted alphabetically will be sorted from A to Z, while files sorted numerically will be sorted from smallest to largest.) When checked, files in the folder view will be sorted in descending order (in reverse). Options → Sorting → Folders First When enabled (the default), folders will appear before regular files. Options → View Options → View → Short View Displays only the filenames. Options → View → Detailed View Displays Name, Date and Size of the files. Options → View → Tree View Like Short View, but folders can be expanded to view their contents. Options → View → Detailed Tree View This also allows folders to be expanded, but displays the additional columns available in Detailed View. Options → Show Hidden Files (Alt+.) Displays files or folders normally hidden by your operating system. The alternate shortcut for this action is F8. Options → Show Places Navigation Panel (F9) Displays the places panel which provides quick access to bookmarked locations and disks or other media. Options → Show Bookmarks Displays an additional icon on the toolbar that provides access to ‘bookmarks’, a list of saved locations. KDE Fundamentals Options → Show Aside Preview Displays a preview of the currently highlighted file to the right of the folder view. Bookmarks Opens a submenu to edit or add bookmarks and to add a new bookmark folder. Location Bar The location bar, which can be found on top of the folder view, displays the path to the current folder. The location bar has two modes: Bread Crumb Mode In the ‘bread crumb’ mode, which is the default, each folder name in the path to the current folder is a button which can be clicked to quickly open that folder. Moreover, clicking the ‘>’ sign to the right of a folder opens a menu which permits to quickly open a subfolder of that folder. Location bar in bread crumb mode. Editable Mode When in bread crumb mode, clicking in the gray area to the right of the path with the left mouse button switches the location bar to the ‘editable’ mode, in which the path can be edited using the keyboard. To switch back to bread crumb mode, click the check mark at the right of the location bar with the left mouse button. Location bar in editable mode. The context menu of the location bar offers action to switch between the modes and to copy and paste the path using the clipboard. Check the last option in this context menu to display either the full path starting with the root folder of the file system or to display the path starting with the current places entry. The Places List This provides the standard KDE list of Places, shared with Dolphin and other file management tools. The Folder View The largest part of the file selection window is the area that lists all items in the current directory. To select a file, you can double-click on it, or choose one and hit Open or Save. You can also select multiple files at once. To select specific files, or to unselect specific files that are already selected, press and hold Ctrl, click on each file, then release Ctrl. To select a contiguous group of files, click the first file, press and hold Shift, click on the last file in the group, and release Shift. The Folder View supports a limited set of file operations, which can be accessed by right-clicking on a file to access its context menu, or using keyboard shortcuts. The following items are available in the context menu: Create New... Create a new file or folder. Move to Trash... (Del) Move the currently selected item to the trash. Sorting This submenu can also be accessed from the toolbar, and is described in Options → Sorting. View This submenu can also be accessed from the toolbar, and is described in Options → View. Open File Manager Opens the current folder in your default file manager application. Properties (Alt+Enter) Open the Properties window that allows you to view and modify various types of metadata related to the currently selected file. The Preview Pane If enabled, this displays a preview of the currently highlighted file. The Name Entry When a file is selected, a name will appear in this text box. You may also manually enter a file name or path in this text box. The Filter Entry When opening a file, the Filter entry allows you to enter a filter for the files displayed in the folder view. The filter uses standard globs; patterns must be separated by white space. For instance, you can enter *.cpp *.h *.moc to display several different common Qt™ programming files. To display all files, enter a single asterisk (*). The filter entry saves the last 10 filters entered between sessions. To use one, press the arrow button on the right of the entry and select the desired filter string. You can disable the filter by pressing the Clear text button to the left of the autocompletion arrow button. When saving a file, the Filter entry will instead display a drop down box that allows you to select from all the file types the application supports. Select one to save a file in that format. Automatically select filename extension When saving a file, this check box will appear. When selected (the default), the application will automatically append the default file extension for the selected file type to the end of the file name, if it does not already appear in the Name entry. The file extension that will be used is listed in parenthesis at the end of the check box label. The Open or Save Button Depending on the action being performed, an Open or Save button will be displayed. Clicking on this button will close the file selection window and perform the requested action. The Cancel Button Clicking Cancel will close the file dialog without performing any action. 4.2.3 Thanks and Acknowledgments Special thanks to Google Code-In 2011 participant Alexey Subach for writing parts of this section. 4.3 Check Spelling Sonnet is the spelling checker used by KDE applications such as Kate, KMail, and KWord. It is a GUI frontend to various free spell checkers. To use Sonnet you need to install a spell checker like GNU Aspell, Enchant, Hspell, ISpell or Hunspell and additionally the corresponding dictionaries for the languages that you wish to use. 4.3.1 Check Spelling Correcting a misspelling. To check spelling, go to Tools → Spelling.... If a word is possibly misspelled in your document, it is displayed in the top line in the dialog. Sonnet tries to appropriate word(s) for replacement. The best guess is displayed to the right of Replace with. To accept this replacement, click on Replace. Sonnet also allows you to select a word from the list of suggestions and replace the misspelled word with that selected word. With the help of the Suggest button, you can add more suggestions from the dictionary to the suggestions list. Click on Ignore to keep your original spelling, Click on Finished to stop spellchecking and keep the changes made. Click on Cancel to stop spellchecking and cancel the changes already made. Click on Replace All to automatically replace the misspelled word(s) with the chosen replacement word, if they appear again in your document later. Click on Ignore All to ignore the spelling at that point and all the future occurrences of the word misspelled. Click on Add to Dictionary to add the misspelled word to your personal dictionary. The Personal Dictionary is a distinct dictionary from the system dictionary and the additions made by you will not be seen by others. The drop down box Language at the bottom of this dialog allows you to switch to another dictionary temporarily. 4.3.2 Automatic Spell Checking In many applications, you can automatically check spelling as you type. To enable this feature, select Tools → Automatic Spell Checking. Potentially misspelled words will be underlined in red. To select a suggestion, right click on the word, select the Spelling submenu, and select the suggestion. You may also instruct Sonnet to ignore this spelling for this document by selecting Ignore Word, or you may select Add to Dictionary to save it in your personal dictionary. 4.3.3 Configuring Sonnet To change your dictionary, go to Tools → Change Dictionary... A small window will appear at the bottom of the current document that will allow you to change your dictionary. For more information on configuring Sonnet, see the Spell Checker System Settings module documentation. 4.3.4 Thanks and Acknowledgments Special thanks to Google Code-In 2011 Participant Salma Sultana for writing much of this section. 4.4 Find and Replace The Find function of many KDE applications lets you find specific text in a document, while the Replace function allows you to replace text that is found with different text you provide. You can find both these functions in the Edit menu of many KDE applications. For more information on this menu, see Section 3.2.2. 4.4.1 The Find Function The Find function searches for text in a document and selects it. Searching for income in Calligra Sheets. To use Find in many applications, go to Edit → Find... or press Ctrl+F. Then, in the Text to find: text box, enter the text that you want to find. If Regular expression is checked you will be able to search using regular expressions. Click on Edit to select from and enter commonly used regular expression characters, like White Space or Start of Line. If Kate is installed, you can find more information on writing regular expressions in its documentation. You can limit the found results by configuring these options: Case sensitive Capital and lowercase characters are considered different. For example, if you search for ‘This’, results that contain ‘this’ will not be returned. Whole words only By default, when the application searches for text, it will return results even in the middle of other text. For instance, if you search for ‘is’ it will stop on every word that contains that, like ‘this’ or ‘history’. If you check this option, the application will only return results when the search text is a word by itself, that is, surrounded by whitespace. From cursor The search will start from the location of the cursor and stop at the end of the text. Find backwards By default, the application searches for the text starting at the beginning of the document, and move through it to the end. If you check this option, it will instead start at the end and work its way to the beginning. Selected text Select this option to search only in the text that is currently selected, not the entire document. It is disabled when no text is selected. Many applications show a search bar instead of the Find window. See KatePart documentation for additional information on the search bar. Searching for software in Kate’s search bar. The Find function only selects the first match that it finds. You can continue searching by selecting Edit → Find Next or by pressing F3. Kate displays a match for KDE. 4.4.2 The Replace Function The Replace function searches for text in a document and replaces it with other text. You can find it in many applications at Edit → Replace... or by pressing Ctrl+R. Replacing income with expense in Calligra Sheets The window of the Replace function is separated into 3 sections: **Find** Here you may enter the text you wish to search for. See Section 4.4.1 for more information on the options provided here. **Replace** Here you may enter the text you wish to replace the found text with. You can reuse the found text in the replacement text by selecting the Use placeholders checkbox. Placeholders, sometimes known as backreferences, are a special character sequence that will be replaced with all or part of the found text. For instance, '0' represents the entire found string. You may insert placeholders into the text box by clicking the Insert Placeholder button, then selecting an option from the menu like Complete Match. For example, if you are searching for ‘message’, and you want to replace it with messages insert the Complete Match placeholder and add an ‘s’. The replace field will then contain ‘0s’. If Kate is installed, you can learn more about placeholders in the Regular Expressions appendix of its documentation. **Options** This contains all the same options that the Find function does, with one addition: If the Prompt on replace option is checked a window will appear on every found word, allowing you to confirm whether you would like to replace the found text. KDE Fundamentals Many Applications show a search and replace bar instead of the Replace window. See KatePart documentation for additional information on the search and replace bar. Replacing `kmail` with `kate` in Kate’s search and replace bar 4.4.3 Thanks and Acknowledgments Thanks to an anonymous Google Code-In 2011 participant for writing much of this section. 4.5 Choosing Fonts The font selector appears in many different KDE applications. It lets you select the font face, font style, and font size of the text that appears in your application. Font This is the leftmost selection box, and lets you choose the font face from a list of fonts on your system. Font style This is the center selection box, and lets you choose the font style from the following choices: Selecting a font in System Settings. KDE Fundamentals - **Italic** - this displays text in a cursive, or slanted fashion, and is commonly used for citations or to emphasize text. - **Regular** - the default. Text is displayed without any special appearance. - **Bold Italic** - a combination of both **Bold** and **Italic** - **Bold** - this displays text in a darker, thicker fashion, and is commonly used for titles of documents or to emphasize text. **Size** This is the rightmost selection box, and lets you select the size of your text. Font size is measured in **points**, a standard unit of measure in typography. For more information on this, see the [Point (typography) article on Wikipedia](#). **Preview** The bottom of the font selector displays a preview of text using the font settings that are currently selected. You may change this text if you wish. ### 4.6 Choosing Colors The color chooser appears in many KDE applications, whenever you need to select a color. It lets you pick from a **Basic colors** consisting of many predefined colors or mix your own when you want a specific color. ![Select Color — System Settings](#) _ Selecting a color in **System Settings**. ### 4.6.1 Using Basic Colors The basic colors group is a set of predefined colors. You can find it on the top side of the color chooser window. To select a color from the basic colors, simply click on it. The color will be displayed at the right of the palette, along with its HTML hexadecimal code 4.6.2 Mixing Colors The color chooser also lets you mix your own colors. There are several ways to do this: 4.6.2.1 Using the Grid The right side of the color chooser contains a large box, and a thinner box immediately to its right. You can use the left box to select the Hue and Saturation of the desired color based on the visual guide provided in the box. The right bar adjusts the Value. Adjust these to select the desired color, which is displayed in the middle of the window. For more information on Hue, Saturation, and Value, see Section 4.6.2.3 4.6.2.2 Using the Screen Colors The eyedropper tool allows you to select a color from your screen. To use it, select the Pick Screen Color button below the basic colors, and then click anywhere on your screen to select that color. 4.6.2.3 Hue/Saturation/Value The lower-right corner of the screen allows you to manually enter the coordinates of the desired color in the Hue/Saturation/Value (HSV) color space. For more information on this, see the HSL and HSV article on Wikipedia. These values are also updated when selecting a color by other methods, so they always accurately represent the currently selected color. 4.6.2.4 Red/Green/Blue The lower-right corner of the screen also allows you to manually enter the coordinates of the desired color in the Red/Green/Blue (RGB) color model. For more information on this, see the RGB color model article on Wikipedia. These values are also updated when selecting a color by other methods, so they always accurately represent the currently selected color. 4.6.2.5 HTML Hexadecimal Code You may enter the HTML hexadecimal code representing the color in the lower-right corner of the screen. For more information on this, see the Web colors article on Wikipedia. This value is also updated when selecting a color by other methods, so it always accurately represents the currently selected color. 4.6.3 Custom Colors After selecting a color, you may add it to the Custom Colors group so you can use it later. To do so, click the Add to Custom Colors button. Chapter 5 Customizing KDE software 5.1 Customizing Toolbars The toolbar in Gwenview. 5.1.1 Modifying Toolbar Items To customize an application’s toolbars, go to Settings → Configure Toolbars... or right-click on a toolbar and select Configure Toolbars.... On the left side of the toolbar configuration panel, the available items that you can put in your toolbar are shown. On the right, the ones that already appear on the toolbar are shown. At the top, you can select the toolbar you wish to modify or view. Above each side of the panel there is a Filter text box you can use to easily find items in the list. The Customize Toolbars window in Gwenview with the Previous button selected. 5.1.1.1 Adding an Item You can add an item to your toolbar by selecting it from the left side and clicking on the right arrow button. 5.1.1.2 Removing an Item You can remove an item by selecting it and clicking the left arrow button. 5.1.1.3 Changing the Position of Items You can change the position of the items by moving them lower or higher in the list. To move items lower, press the down arrow button, while to move items higher press the up arrow button. You can also change items’ position by dragging and dropping them. On horizontal toolbars, the item that’s on top will be the one on the left. On vertical toolbars, items are arranged as they appear in the toolbar. 5.1.1.4 Adding a Separator You can add separator lines between items by adding a --- separator --- item to the toolbar. 5.1.1.5 Restoring Defaults You can restore your toolbar to the way it was when you installed the application by pressing the Defaults button at the bottom of the window and then confirming your decision. 5.1.1.6 Changing Text and Icons You can change the icon and text of individual toolbar items by selecting an item and clicking either the Change Icon... or Change Text... button. 5.1.2 Customizing Toolbar Appearance You can change the appearance of toolbars by right-clicking on a toolbar to access its context menu. 5.1.2.1 Text Position You can change the appearance of text on toolbars in the Text Position submenu of a toolbar’s context menu. You can choose from: - Icons - only the icon for each toolbar item will appear. - Text - only the text label for each toolbar item will appear. - Text Alongside Icons - the text label will appear to the right of each toolbar item’s icon - Text Under Icons - the text label will appear underneath each toolbar item’s icon You can also show or hide text for individual toolbar items by right-clicking on an item and checking or unchecking the item under Show Text. 5.1.2.2 Icon Size You can change the size of toolbar items’ icons by selecting Icon Size from the toolbar’s context menu. You can choose from the following options: (each lists the icon size in pixels) - Small (16x16) - Medium (22x22) [the default value] - Large (32x32) - Huge (48x48) 5.1.2.3 Moving Toolbars In order to move toolbars, you must ‘unlock’ them. To do so, uncheck Lock Toolbar Positions from a toolbar’s context menu. To restore the lock, simply recheck this menu item. You can change a toolbar’s position from the Orientation submenu of its context menu. You can choose from: - Top [the default in many applications] - Left - Right - Bottom You can also move a toolbar by clicking and holding onto the dotted line at the left of horizontal toolbars or the top of vertical toolbars and dragging it to your desired location. 5.1.2.4 Show/Hide Toolbars If your application has only one toolbar, you can hide a toolbar by deselecting Show Toolbar from either the toolbar’s context menu or the Settings menu. To restore the toolbar, select Show Toolbar from the Settings menu. Note that toolbars must be ‘unlocked’ to hide them from their context menu; see Section 5.1.2.3 for more information. If your application has more than one toolbar, a submenu called Toolbars Shown will appear in the context menu and Settings menu instead of the above menu entry. From that menu you may select individual toolbars to hide and show. 5.1.3 Thanks and Acknowledgments Thanks to an anonymous Google Code-In 2011 participant for writing much of this section. 5.2 Using and Customizing Shortcuts 5.2.1 Introduction Many KDE applications allow you to configure keyboard shortcuts. To open the standard keyboard shortcuts configuration panel, go to Settings → Configure Shortcuts.... In the Configure Shortcuts window, you will see a list of all the shortcuts available in the current application. You can use the search box at the top to search for the shortcut you want. <table> <thead> <tr> <th>Action</th> <th>Shortcut</th> <th>Alternate</th> <th>Global</th> </tr> </thead> <tbody> <tr> <td>Dolphin</td> <td></td> <td></td> <td></td> </tr> <tr> <td>☑ Compare Files</td> <td>▼</td> <td></td> <td></td> </tr> <tr> <td>Show Hidden Files</td> <td>Alt+.</td> <td>F8</td> <td></td> </tr> </tbody> </table> Searching for shortcuts with file in Dolphin. 5.2.2 Changing a Shortcut To change a shortcut, first click on the name of a shortcut you want to change. You will see a radio group where you can choose whether to set the shortcut to its default value, or select a new shortcut for the selected action. To set a new shortcut, choose Custom and click on the button next to it. Then just type the shortcut you would like to use, and your changes will be saved. 5.2.3 Resetting Shortcuts There is a button at the bottom of the window, called **Defaults**. Clicking on this button will reset all your custom shortcuts to their default values. You can also reset an individual shortcut to its default value by selecting it, and choosing the **Default** radio button. 5.2.4 Removing a Shortcut To remove a shortcut, select it from the list, then click the remove icon (a black arrow with a cross) to the right of the button that allows you to select a shortcut. 5.2.5 Working with Schemes Schemes are keyboard shortcuts configuration profiles, so you can create several profiles with different shortcuts and switch between these profiles easily. KDE Fundamentals To see a menu allowing you to edit schemes, click on the Manage Schemes button at the bottom of the form. The following options will appear: Current Scheme Allows you to switch between your schemes. New... Creates a new scheme. This opens a window that lets you select a name for your new scheme. Delete Deletes the current scheme. More Actions Opens the following menu: Save Shortcuts to scheme Save the current shortcuts to the current scheme. Export Scheme... Exports the current scheme to a file. Import Scheme... Imports a scheme from a file. 5.2.6 Printing Shortcuts You can print out a list of shortcuts for easy reference by clicking the Print button at the bottom of the window. 5.2.7 Thanks and Acknowledgments Special thanks to Google Code-In 2011 participant Alexey Subach for writing much of this section. Chapter 6 Credits and License The original idea for this guide was proposed by Chusslove Illich and brought to fruition with input from Burkhard Lück, Yuri Chornoivan, and T.C. Hollingsworth. Much of it was written by participants of Google Code-In 2011. Thanks to Google for sponsoring their excellent work! This documentation is licensed under the terms of the GNU Free Documentation License. This program is licensed under the terms of the GNU General Public License.
{"Source-Url": "https://docs.kde.org/trunk5/en/khelpcenter/fundamentals/fundamentals.pdf", "len_cl100k_base": 14873, "olmocr-version": "0.1.53", "pdf-total-pages": 47, "total-fallback-pages": 0, "total-input-tokens": 88023, "total-output-tokens": 15606, "length": "2e13", "weborganizer": {"__label__adult": 0.00038242340087890625, "__label__art_design": 0.0023860931396484375, "__label__crime_law": 0.00019431114196777344, "__label__education_jobs": 0.0022373199462890625, "__label__entertainment": 0.0004374980926513672, "__label__fashion_beauty": 0.00017571449279785156, "__label__finance_business": 0.0002655982971191406, "__label__food_dining": 0.0002086162567138672, "__label__games": 0.0025463104248046875, "__label__hardware": 0.0016317367553710938, "__label__health": 0.00012600421905517578, "__label__history": 0.00029540061950683594, "__label__home_hobbies": 0.0002282857894897461, "__label__industrial": 0.00013256072998046875, "__label__literature": 0.00047850608825683594, "__label__politics": 0.00016176700592041016, "__label__religion": 0.0006170272827148438, "__label__science_tech": 0.002475738525390625, "__label__social_life": 0.0002703666687011719, "__label__software": 0.4921875, "__label__software_dev": 0.4921875, "__label__sports_fitness": 0.00017333030700683594, "__label__transportation": 0.00016224384307861328, "__label__travel": 0.00024306774139404297}, "weborganizer_max": "__label__software", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 60128, 0.03159]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 60128, 0.16957]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 60128, 0.83385]], "google_gemma-3-12b-it_contains_pii": [[0, 37, false], [37, 37, null], [37, 2294, null], [2294, 3717, null], [3717, 4396, null], [4396, 4538, null], [4538, 4772, null], [4772, 6443, null], [6443, 8130, null], [8130, 8514, null], [8514, 9267, null], [9267, 9617, null], [9617, 10035, null], [10035, 11402, null], [11402, 12646, null], [12646, 13532, null], [13532, 14633, null], [14633, 16154, null], [16154, 17392, null], [17392, 19080, null], [19080, 21028, null], [21028, 23364, null], [23364, 25276, null], [25276, 26496, null], [26496, 28406, null], [28406, 30376, null], [30376, 31249, null], [31249, 33328, null], [33328, 34741, null], [34741, 37151, null], [37151, 38554, null], [38554, 40057, null], [40057, 41854, null], [41854, 44089, null], [44089, 45343, null], [45343, 46914, null], [46914, 48444, null], [48444, 49265, null], [49265, 50727, null], [50727, 52801, null], [52801, 53419, null], [53419, 54508, null], [54508, 56275, null], [56275, 58118, null], [58118, 58805, null], [58805, 59653, null], [59653, 60128, null]], "google_gemma-3-12b-it_is_public_document": [[0, 37, true], [37, 37, null], [37, 2294, null], [2294, 3717, null], [3717, 4396, null], [4396, 4538, null], [4538, 4772, null], [4772, 6443, null], [6443, 8130, null], [8130, 8514, null], [8514, 9267, null], [9267, 9617, null], [9617, 10035, null], [10035, 11402, null], [11402, 12646, null], [12646, 13532, null], [13532, 14633, null], [14633, 16154, null], [16154, 17392, null], [17392, 19080, null], [19080, 21028, null], [21028, 23364, null], [23364, 25276, null], [25276, 26496, null], [26496, 28406, null], [28406, 30376, null], [30376, 31249, null], [31249, 33328, null], [33328, 34741, null], [34741, 37151, null], [37151, 38554, null], [38554, 40057, null], [40057, 41854, null], [41854, 44089, null], [44089, 45343, null], [45343, 46914, null], [46914, 48444, null], [48444, 49265, null], [49265, 50727, null], [50727, 52801, null], [52801, 53419, null], [53419, 54508, null], [54508, 56275, null], [56275, 58118, null], [58118, 58805, null], [58805, 59653, null], [59653, 60128, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 60128, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 60128, null]], "pdf_page_numbers": [[0, 37, 1], [37, 37, 2], [37, 2294, 3], [2294, 3717, 4], [3717, 4396, 5], [4396, 4538, 6], [4538, 4772, 7], [4772, 6443, 8], [6443, 8130, 9], [8130, 8514, 10], [8514, 9267, 11], [9267, 9617, 12], [9617, 10035, 13], [10035, 11402, 14], [11402, 12646, 15], [12646, 13532, 16], [13532, 14633, 17], [14633, 16154, 18], [16154, 17392, 19], [17392, 19080, 20], [19080, 21028, 21], [21028, 23364, 22], [23364, 25276, 23], [25276, 26496, 24], [26496, 28406, 25], [28406, 30376, 26], [30376, 31249, 27], [31249, 33328, 28], [33328, 34741, 29], [34741, 37151, 30], [37151, 38554, 31], [38554, 40057, 32], [40057, 41854, 33], [41854, 44089, 34], [44089, 45343, 35], [45343, 46914, 36], [46914, 48444, 37], [48444, 49265, 38], [49265, 50727, 39], [50727, 52801, 40], [52801, 53419, 41], [53419, 54508, 42], [54508, 56275, 43], [56275, 58118, 44], [58118, 58805, 45], [58805, 59653, 46], [59653, 60128, 47]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 60128, 0.18519]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
1626f7fdaf2b5e2deb7d14cd6615eb43fd13a778
This is the unspecified version of the paper. This version of the publication may differ from the final published version. Permanent repository link: http://openaccess.city.ac.uk/1922/ Link to published version: Copyright and reuse: City Research Online aims to make research outputs of City, University of London available to a wider audience. Copyright and Moral Rights remain with the author(s) and/or copyright holders. URLs from City Research Online may be freely distributed and linked to. Towards Security Monitoring Patterns George Spanoudakis Department of Computing, City University, Northampton Square, London, EC1V 0HB, U.K. gespan@soi.city.ac.uk Christos Kloukinas Department of Computing, City University, Northampton Square, London, EC1V 0HB, U.K. C.Kloukinas@soi.city.ac.uk Kelly Androutsopoulos Department of Computing, City University, Northampton Square, London, EC1V 0HB, U.K. sbb530@sso.city.ac.uk ABSTRACT Runtime monitoring is performed during system execution to detect whether the system’s behaviour deviates from that described by requirements. To support this activity we have developed a monitoring framework that expresses the requirements to be monitored in event calculus – a formal temporal first order language. Following an investigation of how this framework could be used to monitor security requirements, in this paper we propose patterns for expressing three basic types of such requirements, namely confidentiality, integrity and availability. These patterns aim to ease the task of specifying confidentiality, integrity and availability requirements in monitorable forms by non-expert users. The paper illustrates the use of these patterns using examples of an industrial case study. Categories and Subject Descriptors D.2.4 [Software/Program Verification]: assertion checkers. Keywords Runtime monitoring, security patterns, event calculus 1. INTRODUCTION Researchers and organizations are constantly developing new security mechanisms for deterring attackers, such as firewalls, virus detection systems and cryptographic protocols for secure communication. When developing a system with security mechanisms, they usually apply static analysis techniques in order to verify that the system behaviour respects certain security properties and detect flaws. Static analysis techniques range from static verification (e.g. model checking) to techniques measuring the efficiency of algorithms (e.g. encryption). However, attackers are also constantly working on attack methods and hence a system can never be considered to be completely secure. Furthermore, static analysis techniques typically verify properties based on assumptions about the behaviour of a system that may turn out to be incorrect at runtime or models which may be incomplete. Thus, no matter how rigorous static analysis might have been, there is no guarantee that the final implementation will not be vulnerable to attack. To alleviate this problem, monitoring of security requirements can be applied to a system to detect at runtime whether its behaviour deviates from that described by its security requirements and the assumptions under which it was shown to be secure. Runtime monitoring can be used as a replacement of static verification or in addition to it. Runtime monitoring takes as input security requirements and checks whether they are consistent with traces of events that are produced during system execution. In this paper, we introduce patterns for expressing basic security monitoring properties that can be checked at runtime using a general runtime requirements monitoring framework that is discussed in [26]. In this framework, requirements are expressed in event calculus (i.e., a first-order temporal formal language [24] shortly referred to as "EC" henceforth) in terms of events which signify the emission/reception of messages by different components of a system, and fluents that represent changes in the state of a system which are triggered by events. As correct EC formulas, however, can be difficult to write, non expert users could benefit from having abstract EC formulas (patterns) expressing generic security properties that could be instantiated to specify the exact security requirements that need to be monitored in specific systems. To enable this, we introduce patterns which cover the three main security properties as defined in [3], namely: (i) Confidentiality – the absence of unauthorised disclosure of information; (ii) Integrity – the absence of unauthorised transformations of the state of a system; and (iii) Availability – the readiness of a system to provide a correct service. Our work was initially motivated by the work on specification patterns [10] [1] defined to assist users in expressing requirements in formal languages, such as LTL [20] and CTL [6]. However, these specification patterns have not been defined for event calculus nor do they focus on security requirements. Using the patterns that we introduce in this paper, someone can implement basic security requirements of a system separately from the system functionality by creating security-related rules and verifying and controlling these requirements using the EC monitoring framework discussed in [26]. In this way it is possible to separate the treatment of the security requirements from the application logic. If the system already has built-in security mechanisms, then the external monitoring of security requirements adds yet another layer of security checking which is independent from the system and therefore makes it more fault tolerant [5], especially if it is possible to control the system when violations are detected. However, even in cases where control cannot be applied, our approach can help by providing the basis for detecting more violations than the system itself, logging violations, and using the sophisticated reasoning capabilities of the monitor to analyse specific dynamic event patterns, e.g., for cases like denial of service attacks. The rest of this paper is structured as follows. In Section 2, we describe the general framework that we use for monitoring and in Section 3 we overview event calculus. In Section 4, we define the monitoring patterns and present examples of using them to express security requirements drawn from an industrial scenario. In Section 5, we discuss related work and in Section 6 we give conclusions and present plans for future work. 2. MONITORING FRAMEWORK The general architecture of the monitoring framework that we use to monitor the patterns introduced in this paper is shown in Figure 1. This framework consists of a monitoring manager that accepts a set of (security) requirements to be monitored and based on them it identifies the event types that need to be observed and sends them to an event catcher. It also forwards the requirements to be monitored to the monitoring engine of the framework. The event catcher observes events from one or more of the agents that constitute the system being monitored, captures those that correspond to the event types given by the monitoring manager and sends them to the monitoring engine of the framework. The monitoring engine checks whether the event trace that is reported and sends them to the monitoring engine of the framework. The event catcher observes events from one or more of the agents that constitute the system being monitored, captures those that correspond to the event types given by the monitoring manager and sends them to an event catcher. It also forwards the requirements to be monitored to the monitoring engine of the framework. The event catcher observes events from one or more of the agents that constitute the system being monitored, captures those that correspond to the event types given by the monitoring manager and sends them to the monitoring engine of the framework. The monitoring engine checks whether the event trace that is reported and sends them to the monitoring engine of the framework. The event catcher observes events from one or more of the agents that constitute the system being monitored, captures those that correspond to the event types given by the monitoring manager and sends them to an event catcher. It also forwards the requirements to be monitored to the monitoring engine of the framework. 3. SPECIFICATION OF PROPERTIES I Event calculus (EC) is a first-order temporal formal language that can be used to specify properties of dynamic systems which change over time. Such properties are specified in terms of events and fluents. An event in EC is something that occurs at a specific instance of time (e.g., invocation of an operation) and may change the state of a system. Fluents are conditions regarding the state of a system which are initiated and terminated by events. A fluent may, for example, signify that a specific system variable has a particular value at a specific instance of time or that a specific relation between two objects holds. The occurrence of an event in EC is represented by the predicate \( \text{Happens}(e, t, R(t_1, t_2)) \). This predicate signifies that an instantaneous event \( e \) occurs at some time \( t \) within the time range \( R(t_1, t_2) \). The boundaries of \( R(t_1, t_2) \) can be specified by using either time constants or arithmetic expressions over the time variables of other predicates in an EC formula. The initiation of a fluent is signified by the EC predicate \( \text{Initiates}(e, f, t) \) whose meaning is that a fluent \( f \) starts to hold after the event \( e \) at time \( t \). The termination of a fluent is signified by the EC predicate \( \text{Terminates}(e, f, t) \) whose meaning is that a fluent \( f \) ceases to hold after the event \( e \) occurs at time \( t \). An EC formula may also use the predicates \( \text{Initially}(f) \) and \( \text{HoldsAt}(f, t) \) to signify that a fluent \( f \) holds at the start of the operation of a system and that \( f \) holds at time \( t \), respectively. Our EC based language uses special types of events and fluents to specify monitorable properties of systems. More specifically, fluents can be defined by the user as relations between objects of the following general form: \[ \text{relation}(\text{Object}_1, \ldots, \text{Object}_n) \tag{I} \] In (I), \( \text{relation} \) is the name of the relation that takes as arguments \( n \) objects \( (\text{Object}_1, \ldots, \text{Object}_n) \) that can be fluents or terms. A predefined relation for fluents that is commonly used is: \[ \text{valueOf}(\text{variable}, \text{value}_{\text{exp}}) \tag{II} \] whose meaning is that \( \text{variable} \) has the value \( \text{value}_{\text{exp}} \). In (II), - \( \text{variable} \) denotes a typed variable which can be: (i) a system variable – A system variable is a variable of the system that is being monitored whose value can be captured at any time during the monitoring process, or (ii) a monitoring variable – A monitoring variable is introduced by the users of the monitoring framework to represent the deduced states of the system at runtime (i.e. states which the system itself might not be aware of but its monitor can use in order to reason about it). - \( \text{value}_{\text{exp}} \) is a term that either represents an EC variable/value or signifies a call to an operation that returns an object of the same type as the variable. This operation may be a built-in operation of the monitoring engine (e.g. an operation that computes the average of a set of values) or an operation that is invoked in an external party. When \( \text{value}_{\text{exp}} \) is an operation call, then effectively the return value of the operation becomes the value of \( \text{variable} \). Events in our framework represent exchanges of messages between the agents that constitute a system. A message can invoke an operation in an agent or return results following the execution of an operation. In our EC-based language, events are described by terms that have the following generic form: \[ \text{event}_{\text{id}_1, \_\text{sender}, \_\text{receiver}, \_\text{status}, \_\text{oper}, \_\text{source}} \] (III) In (III): - \( \_\text{id} \) is a unique identifier of the event - \( \_\text{sender} \) is the identifier of the agent that sends the message. - \( \_\text{receiver} \) is the identifier of the agent that receives the message. - \( \_\text{status} \) represents the processing status of an event. The status of the event can be: (i) REQ-B, that is a request for the invocation of an operation that has been received but whose processing has not started yet; (ii) REQ-A, that is a request for the invocation of an operation that has been received and whose processing has started; (iii) RES-B, that is a response generated upon the completion of an operation that has not been dispatched yet; or (iv) RES-A, that is a response generated upon the completion of an operation that has been dispatched. - \( \_\text{oper} \) is the signature of operation that the event invokes or reports the results of. - \( \_\text{source} \) is the name of the agent that provided information about the event. As an example of a monitoring property expressed in our EC-based language consider the formula below: \[ \forall \_\text{id}_1, \_\text{id}_2, \_\text{s}, \_\text{r}: \text{String}; \_\text{v}: \text{ObjType} \ t: \text{Time} \text{Happens}(e(\_\text{id}_1, \_\text{s}, \_\text{r}, \text{REQ-B}, \_\text{v}, \_\text{r}), \_\text{v}, \_\text{r}) \Rightarrow \text{Happens}(e(\_\text{id}_2, \_\text{s}, \_\text{r}, \text{RES-A}, \_\text{v}, \_\text{r}), \_\text{v}, \_\text{r}) \] According to this formula, an agent \( _r \) which receives an event invoking the operation \( o(_v) \) in it (i.e. \( e(\_\text{id}_1, \_\text{s}, \_\text{r}, \text{REQ-B}, \_\text{v}, \_\text{r}) \)) should complete the execution of \( o(_v) \) and respond to the caller \( (_s) \) within \( t_1 \) time units following the request (i.e., an availability requirement as we discuss in Section 4.4). 4. SECURITY MONITORING PATTERNS The monitoring patterns that we have defined to enable the specification of monitoring rules focus on common security properties, namely confidentiality, integrity and availability. These patterns are introduced in the following after an overview of the monitoring pattern language that we use to express them. 4.1 Monitoring Pattern Language A monitoring pattern is composed of: (i) a monitoring rule which defines in a parameterised form the event calculus formulas that will need to be monitored at runtime, and (ii) a set of assumptions which define in parameterised forms the event calculus formulas that can be used at runtime to deduce information about the state of the monitored systems that affects the satisfiability of the monitoring rules based on captured runtime events. Patterns may define different monitoring rules and assumptions for different types of monitoring (e.g. single and multi-party monitoring) if these types can be applied for the property of the pattern. The first order language that is used to define the pattern formulas is based on EC. The variables of this language are typed and might or might not be replaced depending on their specification in the pattern. More specifically a variable \( _x \) which appears in “\(<x>\)” (i.e. \(<_x>\)” must be replaced by another compatible variable, that is a variable whose type is compatible with the type of \( _x \) when the pattern is instantiated. Variables which do not appear in “\(<x>\)” should not be replaced. The type of a pattern variable may be one of the following predefined set of meta-types: Term, Event, Fluent, Agent, and InformationTerm. Term is the most general of these meta-types and represents any type of term that can appear in an EC formula. The meta-types Event and Fluent represent events and fluents respectively as defined in Section 3. The meta-type Agent represents an entity with a computational capacity that can send, receive and process messages. Finally, the meta-type InformationTerm represents some primitive data type (String, Integer, Real, Boolean) or object type. In addition to the generic fluents introduced in Section 3, our pattern language uses the following predefined fluents, (i) \( \text{authorised(authorisingAgent,authorisedAgent,e)} \) – This fluent denotes that the agent \( \text{authorisedAgent} \) has been authorised to receive and process the event \( e \) or to send an event \( e \) by the agent \( \text{authorisingAgent} \). (ii) \( \text{exposes(o, owner)} \) – This fluent denotes that the response generated from the execution of an operation \( o \) will disclose an information term \( i \) which belongs to the agent \( \text{owner} \). (iii) \( \text{transforms(o, agent)} \) – This fluent denotes that the execution of the operation \( o \) may transform the state of the agent \( \text{agent} \). 4.2 Pattern for Confidentiality Confidentiality is defined in [3] as “absence of unauthorised disclosure of information”. This property means that an agent who possesses some information should not allow unauthorised disclosure of it. Disclosure may occur either through direct access of the stored information at the side of the agent which possesses it or through the dispatch of the information. Information dispatch can happen through directed communications of the form \( \text{source} \rightarrow \text{dest} \) in which the agent \( \text{source} \) who possesses the information sends it over to \( \text{dest} \). In communication chains of the form \( \text{source} \rightarrow \text{dest}_1 \rightarrow \ldots \rightarrow \text{dest}_n \), there is the possibility of unauthorised disclosure of information not only at the source or during the transmission of information over a channel but also at some destination agent \( \text{dest}_i \) which despite being authorised to receive the information itself fails after receiving it to prevent unauthorised access to it by a third party. The term “unauthorised” in the above definition assumes an authentication and an authorisation process. Consequently, the knowledge of the authentication and authorisation status of agents is a necessary, albeit not sufficient condition, for monitoring confidentiality. 4.2.1 Pattern for source-party monitoring The pattern for source-party confidentiality monitoring is shown in Figure 2. The rule CSR1 in this pattern is monitored at the source of an information disclosure message (i.e. the agent _sender in the pattern) and states that if an information disclosure event \( E_1 \) happens in this agent that allows another agent (receiver) to obtain information \( i \) which is confidential to an agent _owner, the _receiver should be authorised by the _owner to obtain _f at the time of the disclosure. In the pattern, the authorisation of the _receiver is performed by an operation _authorO which tests whether the _receiver is authorised to receive the event \( E_1 \) and thus obtain the information _i of _owner at time _t. During monitoring, authorisation can be obtained by deduction from the assumption CSA2 of the pattern. and the axioms of EC. According to CSA2, the fluent authorised (<_owner>, <_receiver>, E1) which indicates the authorisation of _receiver to receive the event E1 that exposes _i is initiated only if an event E2 that indicates the receipt of a response from the execution of the operation _authorO has occurred and the result of this operation (result _authorO) signifies the authorisation (i.e., it is equal to authorisedValue). Following the initialisation of the authorisation fluent authorised(<_owner>, <_receiver>, E1) at some time to the predicate HoldsA authorised(<_owner>, <_receiver>, E1), t1) can be shown to hold at any time t after to by the following axiom of EC [24] (assuming that no other event that could have clipped authorised(<_owner>, <_receiver>, E1) occurred between to and t1): \[ \text{HoldAt}(f, t) \iff (\exists t, \exists t \in \mathbb{R}_+ \text{Happens}(e, t, \mathbb{R}(t_a, t_b)) \land \\ \text{Initiates}(e, f) \land \neg \text{Clipped}(f, t, t_b)) \] In cases where the status of E1 is REQ-B or RES-B, CSR1 provides scope for pre-emptive control as the relevant requests or responses can be blocked if the rule is not satisfied. In cases where the status of E1 is REQ-A or RES-A, the rule provides scope only for reactive control as the relevant dispatched would have occurred when the rule is checked. The pattern in Figure 2 covers also destination-party monitoring since CSR1 can monitor invocations of an operation in an agent by observing the responses (RES-* To ensure that a piece of confidential information _i which an agent (agent2) has received from another agent (agent1) will not be disclosed to an unauthorised third party (agent3), it is necessary to apply CSR1 to agent2. This is possible, however, only if agent2 agrees to provide information about the exchange of all the events between it and third parties that would disclose _i. In this case, to enable the monitoring of agent2, the variable _i owner in CSR1 should be agent1, _sender should be agent2, and _receiver should be agent3. With these variable settings, CSR1 would check if agent3 is authorized by agent1 to receive an event from agent2 that discloses _i. Furthermore, separate instances of CSR1 and CSA1 should be created for all the operations which agent1 can invoke in a third party or execute after an invocation from a third party and would disclose _i. 4.2.2 Pattern for multi-party monitoring To illustrate the use of the confidentiality pattern, we use a case study based on an e-healthcare system supporting monitoring, assistance and provision of medication to patients with critical medical conditions that is described in [4]. In this case study, patients who have been discharged from hospitals with potentially threatening medical conditions can use an e-health terminal (EHT) – that is an e-health application installed on their PDAs – to contact an emergency response centre (ERC) for assistance and fast ordering of medication. In one scenario of this case study, a patient who had suffered from a cardiac arrest, feels unwell and sends through his EHT a request for assistance to ERC. To establish the cause of the problem, ERC retrieves the patient’s medical record through the EHT. From this record, ERC establishes that the patient’s doctor is on vacation and broadcasts a message to a group of doctors known to be able to substitute the patient’s doctor. A doctor D receives this message on his own EHT and replies immediately. ERC verifies D’s ability to substitute for the patient’s doctor for the specific assistance request. Following this, D’s EHT interrogates ERC to receive the patient’s medical data. D analyses all these data, identifies the most appropriate treatment, and writes the electronic prescription on his/her EHT which subsequently sends the prescription to ERC which forwards it to the patient’s EHT after registering it. In this scenario, Campadello et al. [4] have identified the following confidentiality requirement: “A patient’s substitute doctor can access the patient’s medical data if and only if he is the selected doctor” (i.e., Req. 2.2.1.7 in [4]) Assuming the following operations of ERC, (a) fetchPatientData(docID:String, request:String, patientInfo:MedicalRecord) – This operation retrieves the medical record of a Figure 2. Pattern for confidentiality monitoring As indicated by the event E2, the operation _authorO in the pattern is executed in some agent _agent1 following a request by the _sender. Thus, CSR1 is satisfied only if prior to its checking, an event E2 has occurred and by virtue of CSA2 the authorisation fluent authorised(<_owner>, <_receiver>, E1) has been initiated. The effect of events on the disclosure of information in the pattern is specified by the assumptions CSA1 that specify which operations can expose confidential information. Note that the event E1 in the pattern can be either a request for the execution of an information disclosure operation <_o> (i.e., REQ-* events) or a response generated by executing <_o> in the sender following an invocation sent earlier by the receiver (i.e., RES-* events). Also, CSR1 can refer to requests and responses that are to be dispatched (i.e., when the event status is REQ-B and RES-B, respectively) or that have already been dispatched (i.e., when the event status is REQ-A and RES-A, respectively). 1 The variables indicating the identifiers of events in all the formulas in the paper are assumed to be of type String and universally quantified. patient (\textit{patInfo}) given (as input) a medical assistance request associated with the patient (\textit{request}) and the identifier of a requesting doctor (\textit{docID}). (b) \texttt{verifyDoctor(docID:String, request:String, verified:Boolean)} - This operation verifies if a doctor (\textit{docID}) can deal with a given request (\textit{request}) the above requirement can be monitored by an instantiation of the confidentiality pattern in Figure 2 covering the interaction between ERC and the EHT of doctor D. Table 1. Mapping of variables of confidentiality pattern <table> <thead> <tr> <th>Pattern Term/Variable</th> <th>System Operation or Parameter</th> </tr> </thead> <tbody> <tr> <td>\textless{}_sender\textgreater{}</td> <td>\textit{ercID}</td> </tr> <tr> <td>\textless{}_receiver\textgreater{}</td> <td>\textit{docEhtID}</td> </tr> <tr> <td>\textless{}_agent\textgreater{}</td> <td>\textit{ercID}</td> </tr> <tr> <td>\textless{}_owner\textgreater{}</td> <td>\textit{ercID}</td> </tr> <tr> <td>\textless{}_i\textgreater{}</td> <td>\textit{fetchPatientData}</td> </tr> <tr> <td>\textless{}_o\textgreater{}</td> <td>\textit{patInfo}</td> </tr> <tr> <td>\textless{}_result\textgreater{}</td> <td>\textit{verifyDoctor}</td> </tr> <tr> <td>\textless{}_authorisedValue\textgreater{}</td> <td>True</td> </tr> </tbody> </table> To instantiate the pattern and specify the specific confidentiality properties of the system, system providers need first to identify the different agents and interactions in the system, and subsequently establish the sender and receiver for each interaction as well as the agents that can accept an event catcher. In the above example, we focus on the interaction from the doctor’s EHT to the ERC and assume that an event catcher can be inserted at ERC’s side. Note that here we consider ERC to be the sender since we are interested in ERC’s reply to the doctor’s EHT request for a patient’s record. Having identified the specific pattern rule that will be used, system providers need to identify the system variables/operations which will substitute for the pattern terms. To do so, they must define a mapping from pattern variables onto system operations and variables. An example of this mapping for the variables of the pattern of Figure 2 is shown in Table 1. Once this mapping is identified, system providers need to indicate the variables of the formula that will substitute for the parameters of the system operations. If such variables are not identified, formula variables with the same names and types as operation parameters will be automatically generated to substitute for these parameters. In our example, as Table 1 does not define a mapping of operation parameters, such default variables will be generated automatically for these parameters. Thus, given the mapping of Table 1, the following rule and assumptions can be generated automatically from the pattern of Figure 2: \textbf{Rule CR1:} \begin{align*} \forall \_eID1, \_eID2, \_ercID, \_docEhtID, \_request:String; \\ patInfo: MedicalRecord; t1:Time \\ \text{Happens}(e(\_eID1, \_ercID), \_docEhtID, RES-B, \\ \text{fetchPatientData}(\_docID, \_request, \_patInfo), \\ \_ercID), t1, \text{\_verified}(t1)) \\ \text{HoldsAt}(\text{\_verified}(t1), t1) \\ \text{HoldsAt}(\text{\_verified}(t1, t)) \\ \text{HoldsAt}(\text{\_verified}(t1), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \end{align*} \textbf{Assumption CA1:} \begin{align*} \text{Initially}(\text{\_verified}(t), t) \\ \text{Happens}(e(\_eID2, \_ercID), \_docEhtID, RES-A, \\ \text{verifyDoctor}(\_docEhtID, \_request), \_ercID), t1, \text{\_verified}(t1)) \\ \text{HoldsAt}(\text{\_verified}(t1), t1) \\ \text{HoldsAt}(\text{\_verified}(t1), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \\ \text{HoldsAt}(\text{\_verified}(t), t) \end{align*} According to rule CR1, following a request for the execution of the operation \textit{fetchPatientData} by a doctor’s EHT to the ERC it should be checked if the requesting doctor’s EHT has been authorised to receive the information that is to be disclosed to him/her. Also, according to CA2 this authorisation can be obtained through the execution of the operation \textit{verifyDoctor}. Finally, \textit{CA1} specifies that the operation \textit{fetchPatientData} discloses \textit{patInfo}. Note also that since the mapping of Table 1 does not define a mapping for the parameters \textit{docID} of the operations \textit{fetchPatientData} and \textit{verifyDoctor}, a default rule variable called \textit{docID} has been generated for both these operations in the formulas and, as a result, the doctor’s \textit{ID} (\textit{docID}) to be used in the \textit{verifyDoctor} operation will be the same as the one used in the \textit{fetchPatientData} operation. 4.3 Pattern for Integrity Integrity has been defined in [3] as “absence of unauthorised system state transformations”. This definition implies that: (a) no unauthenticated and unauthorised agent should be allowed to request the execution of an operation that would change the state of another agent. Such unauthorised changes can be checked by destination-party monitoring as we assume that changes of system states may occur only at specific local agents and an external agent can only change the state of a system by calling operations at a destination agent. 4.3.1 Pattern for destination-party integrity monitoring The pattern for destination-party integrity monitoring is specified in Figure 3. The monitoring rule of this pattern (IDRI) specifies that upon the receipt of a request from a \textit{sender} for the execution of an operation \textit{o} which may transform the state of a \textit{receiver}, the \textit{sender} must be authorised by the \textit{receiver} to execute \textit{o}. The possibility of the execution of \textit{o} causing a transformation in the state of the \textit{receiver} is indicated by the fluent \textit{transforms(E1, \_receiver)} which the rule requires to hold when the \textit{receiver} gets the request. Note that the pattern for integrity monitoring is similar to the one for confidentiality monitoring but differ in two points. The first difference is that the confidentiality pattern is monitored at the sender side, since it is the sender which may expose some information. The integrity pattern, on the other hand, needs to be monitored at the receiver side, since it is the receiver which may eventually transform the system state (at the request of the sender). This is shown by the different source terms of the events of the two patterns. The second difference between these two patterns is that the confidentiality pattern uses the exposes fluent to specify information disclosure while the integrity pattern uses the transforms fluent to specify system state transformations. Monitoring rules: \[ \forall \_o:Operation; \_sender, \_receiver: Agent; t:Time Happens(E1, t, \\exists(t,t)) \land \text{HoldsAt}(transforms(<\_o>, <\_receiver>), t) \Rightarrow \text{HoldsAt}(authorised(<\_receiver>, <\_sender>, E1), t) \] where: \( E1 = e(_eID1,<_o>,<_receiver>,\text{REQ-A},<\_o>,<_receiver>) \) Assumptions: Initially(transforms(<_o>, <_receiver>)) \[\forall \_authorO: Operation; agent1: Agent; t:Time \text{Happens}(E2, t, \exists(t,t)) \land \text{HoldsAt}(equalTo(<\_result_authorO>, \langle<\_authorisedValue>,\rangle), t) \Rightarrow \text{Initiates}(E2, authorised(<\_receiver>, <\_sender>, E1)), t) \] where: \( E2 = e(_eID2,<_agent1>,<_receiver>,\text{RES-A}, \langle<\_authorO>,<_receiver>\rangle) \) Table 2. Mapping of variables of integrity pattern <table> <thead> <tr> <th>Pattern Term/Variable</th> <th>System Operation or Parameter</th> </tr> </thead> <tbody> <tr> <td>_sender</td> <td>docEhtID</td> </tr> <tr> <td>_receiver</td> <td>ercID</td> </tr> <tr> <td>_o</td> <td>createPrescription</td> </tr> <tr> <td>_author</td> <td>verifyDoctor</td> </tr> <tr> <td>_result_authorO</td> <td>verifyDoctor:verified</td> </tr> <tr> <td>_authorisedValue</td> <td>True</td> </tr> <tr> <td>_agent1</td> <td>ercID</td> </tr> </tbody> </table> Following the procedure for instantiating a pattern that we described in Section 4.2.3, we can define the mapping between the variables of the pattern of Figure 3, and the operations of the e-healthcare system and their parameters. This mapping is shown in Table 2. From this mapping we can generate the following rule as an instance of the rule IDR1 in order to check the requirement Req. 2.2.1.15 at runtime: Rule IDR1: \[\forall \_eID1, _ercID, _docEhtID: \text{String}; t: \text{Time} \text{Happens}(e(_eID1, _docEhtID, _ercID, REQ-B), createPrescription(_docID, _request, _presc), _ercID), t, \\exists(t,t)) \land \text{HoldsAt}(transforms(createPrescription(_docID, _request, _presc), _ercID), t) \] We can also generate the assumptions IA1 and IA2 below as instances of the formulas IDA1 and IDA2, respectively: Assumption IA1: Initially(transforms(createPrescription(_docID, _request, _presc), _ercID)) Assumption IA2: \[\forall \_eID2, _ercID, _docEhtID: \text{String}; t: \text{Time} \text{Happens}(e(_eID2, _ercID, REQ-B), createPrescription(_docID, _request, _presc), _ercID), t, \\exists(t,t)) \land \text{HoldsAt(equalTo(verified, True), t))} \] The rule IR1 above checks whether the doctor (_docID) who invokes the operation createPrescription in ERC (_ercID) is authorised to do so. Note that, due to the mapping of the pattern variables of Table 2, IR1 effectively describes a delegation of the doctor’s right to create prescriptions to his/her EHT, since it is the EHT which is the sender in this interaction (_docEhtID), while it is the doctor who is being authorised (_docID) for the action in reality. The assumption IA2 above states that a doctor is authorised to call the operation createPrescription in ERC only if this is verified by the operation verifyDoctor. In this case, an appropriate authorisation fluent will be generated by IA2 and by virtue of the EC axiom discussed in Section 4.3.2 we can derive that the HoldsAt predicate in the head of the rule IR1 is satisfied. 4.3.2 Example In the scenario outlined in Section 4.2.3, the following integrity requirement has been identified: “Electronic prescriptions shall be issued only by doctors by means of an e-health terminal.” (i.e., Req. 2.2.1.15 in [4]) This requirement can be monitored by a rule stating that if an ERC receives an electronic prescription by a doctor then this doctor must be authorised to issue the prescription. The rule can be created by instantiating the destination party integrity monitoring pattern assuming that: (i) ERC provides the operation createPrescription(docID:String, request:String, presc:Prescription) to create new electronic prescriptions (presc) for a medical assistance request (request), and (ii) doctors are authorised through the execution of the operation verifyDoctor as discussed in Section 4.2.3. 4.4 Pattern for Availability According to [3], availability is defined as “readiness for correct system service”. In [3], a service is deemed to be correct if it implements the specified system function. Readiness of a system in this definition means that if some agent invokes an operation to access some information or use a resource, it will eventually receive a correct response to the request. In some cases, the property may be strengthened to require that a response will be received within a fixed time period following the invocation. These cases can be effectively monitored by our framework as indicated below. 4.4.1 Pattern for source-party availability monitoring The pattern for source party availability monitoring specifies a monitoring rule that checks whether, following the dispatch of an event by a source agent (_sender) requesting the execution of an operation _o in a destination agent (_receiver), the source agent receives a response from the destination agent for the request within tu time units after the dispatch (see rule ASR1 in Figure 4). Note that, as it is based on events captured at the source of a request, ASR1 checks the availability of both the receiver of the request and the communication channel between it and the sender. Also the use of a bounded range for the time variable $t_2$ in ASR1 (i.e., $R(t_1, t_1 + t_u)$) is necessary since if the variable was unbounded, the rule would not be decidable (only cases where the rule is satisfied would be detectable). <table> <thead> <tr> <th>Monitoring rules:</th> </tr> </thead> </table> | $\forall o: Operation, _\_sender, _\_receiver: Agent; t_1, t_2: Time;$ | $\text{Happens}(e(_eID, _\_sender, _\_receiver, REQ-A, _\_o, _\_receiver), t_1, R(t_1, t_1 + t_u))$ | ASR1 | **Figure 4. Pattern for source-party availability monitoring** ### 4.4.2 Patterns for destination-party availability monitoring For destination-party availability monitoring, we introduce two patterns that specify different monitoring rules. These patterns are shown in Figure 5. The rule of the first pattern (ADR1) states that an agent (_receiver) which receives a request for the execution of an operation from another agent (_sender) should respond to the sender within $t_u$ time units after the receipt of the request. The rule of the second pattern (ADR2) is used to check the availability of an agent (_sender) which is known to operate correctly only if it requests the execution of an operation $o$ (or a set of such operations) in another agent (_receiver) at regular time intervals. <table> <thead> <tr> <th>Pattern 1</th> </tr> </thead> <tbody> <tr> <td>Monitoring rules:</td> </tr> </tbody> </table> | $\forall o: Operation, _\_sender, _\_receiver: Agent; t_1, t_2: Time;$ | $\text{Happens}(e(_eID, _\_sender, _\_receiver, REQ-B, _\_o, _\_receiver), t_1, R(t_1, t_1 + t_u))$ | ADR1 | <table> <thead> <tr> <th>Pattern 2</th> </tr> </thead> <tbody> <tr> <td>Monitoring rules:</td> </tr> </tbody> </table> | $\forall o: Operation, _\_sender, _\_receiver: Agent; t_1, t_2: Time;$ | $\text{Happens}(e(_eID1, _\_sender, _\_receiver, REQ-A, _\_o, _\_receiver), t_1, R(t_1, t_1 + t_u))$ | ADR2 | **Figure 5. Patterns for destination-party availability monitoring** Note that, in the case of availability there is no need for an additional multi-party monitoring pattern since if both source and destination party monitoring can be applied, the monitoring of ADR1 checks the availability of the service at the destination side and the monitoring of rule ASR1 checks the availability of both the destination side and the communication channel between the two agents. It should also be noted that the patterns for availability do not address the correctness of system functions. This is because system correctness must be assessed against some additional model of the intended behaviour of a system which can not be specified in a generic form as part of the pattern. ### 4.4.3 Example In the e-healthcare system scenario introduced in Section 4.2.3, the following availability requirement has been identified: > “The patient’s e-health terminal shall continuously... emit an OK status to the ERC.” (i.e., Req. 2.2.1.11 in [4]) Assuming that the status of an EHT to ERC is notified by calling the operation `reportStatus(ehtID: String)` and that the abstract _sender and _receiver terms in the pattern are mapped onto the id of an EHT (`ehtID`) and the id of the ERC (`ercID`) respectively, the above requirement can be monitored using the following rule: **AR3:** $\forall eID1, eID2, ehtID, ercID: String; t_1, t_2: Time$ $\text{Happens}(e(eID1, ehtID, ercID, REQ-A, reportStatus(ehtID)), ercID, t_1, R(t_1, t_1 + t_u)) \Rightarrow \text{Happens}(e(eID2, ehtID, ercID, REQ-A, reportStatus(ehtID)), ercID, t_2, R(t_1, t_1 + t_u))$ AR3 is created by instantiating the rule ADR2 of the availability pattern and checks if an EHT invokes the operation `reportStatus` in intervals of no more than $t_u$ time units. # 5. RELATED WORK Konrad and Cheng [17] define specification patterns expressed in the real-time temporal logics MTL [18], TCTL [2], and RTGIL [21]. Their work extends the Dwyer et al. pattern system [10] with a taxonomy of (i) duration properties that describe a bounded duration of an occurrence, (ii) periodic properties that describe periodic occurrences, and (iii) real-time order properties that place time bounds on the order of occurrences. Our patterns differ in that we specifically consider monitorable security properties and not general liveness/safety properties as [17]. Propel [25] is also an extension of [10] that helps specifiers identify the subtleties and alternative options associated with the intended behaviour of systems (see the Response pattern of [10] for example). Propel allows specifiers examine all the options explicitly and decide on the final instantiation of the property (where all the options have been resolved). Unlike our approach, Propel does not support the expression of real-time information. Bandra [7] is another extension of [10] that deals with events in a state-based formalism but with no real-time information. Bandera supports user defined patterns and provides a structured-English front end for the patterns, which are then translated into the formalism of the chosen model checker. Security patterns have also been introduced to aid the development of secure software systems but not for verification or monitoring. Such patterns have been proposed as part of UMLsec [15] and SecureUML [19]. In UMLsec, Jürjens proposes some transformation patterns between UML models that are used to introduce patterns by refinement [14]. These patterns are for security solutions rather than for formulating security properties. SecureUML [19] is another extension of UML which provides syntax for expressing access control policies directly in UML. Other recent work has also focused on specifying security patterns [23] that describe solutions to particular recurring security problems. Security patterns that can be applied at different architectural levels of software systems are also described in [12]. These patterns however are not expressed in a formal language and thus are not always clear to developers. Finally, apart from [8] which describes authorisation policies for determining access rights of processes to objects (without being able to express time constraints), no other work in the area of intrusion detection and dynamic monitoring of security (e.g. [11][8][16][22][9]) has used property specification patterns to express monitoring rules, to the best of our knowledge. ### 6. CONCLUSION AND FUTURE WORK In this paper, we have presented patterns for expressing three basic security properties, namely confidentiality, integrity and availability, in a way which permits their monitoring at runtime. These patterns are expressed in Event Calculus and can be used with a generic framework for monitoring functional and non functional requirements at runtime with sophisticated reasoning capabilities [26]. The creation of these patterns aims at making it easier for system providers to specify basic security requirements for their systems and monitor them using this framework. By doing so, system providers can outsource security requirements to the monitoring infrastructure and use monitoring as an additional layer of security checking which is independent from checks performed by the system that is being monitored, thus, making it more fault tolerant. Furthermore, monitoring enables the identification, diagnosis and future prevention of attacks, even for dynamic and difficult to describe attack scenarios. Our current work focuses on the development of a tool to support the instantiation of the patterns presented in this paper and the validation of the generated security requirements. This tool will generate pattern instances automatically based on mappings between the pattern variables and system operations/variables as discussed in this paper. Our aim is to use this tool to support the instantiation of patterns for real-world applications and investigate if our approach is expressive enough for these. Finally, we are also working on the development of template formulas as part of the confidentiality patterns to assist system providers express theories for confidential information leaks that can result from disclosing non confidential pieces of information independently. ### ACKNOWLEDGEMENTS The work reported in this paper has been funded by the European Commission under the Information Society Technologies Programme as part of the integrated project SERENITY (contract IST-027587). ### REFERENCES
{"Source-Url": "http://openaccess.city.ac.uk/1922/1/Towards_Security_Monitoring_Patterns.pdf", "len_cl100k_base": 10543, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 30966, "total-output-tokens": 12589, "length": "2e13", "weborganizer": {"__label__adult": 0.0004014968872070313, "__label__art_design": 0.00044918060302734375, "__label__crime_law": 0.0008740425109863281, "__label__education_jobs": 0.0011148452758789062, "__label__entertainment": 9.500980377197266e-05, "__label__fashion_beauty": 0.00017726421356201172, "__label__finance_business": 0.0004544258117675781, "__label__food_dining": 0.00036525726318359375, "__label__games": 0.0006785392761230469, "__label__hardware": 0.0011548995971679688, "__label__health": 0.0010194778442382812, "__label__history": 0.00029969215393066406, "__label__home_hobbies": 0.00010627508163452148, "__label__industrial": 0.0005717277526855469, "__label__literature": 0.0004267692565917969, "__label__politics": 0.0003478527069091797, "__label__religion": 0.00043320655822753906, "__label__science_tech": 0.11993408203125, "__label__social_life": 0.0001074075698852539, "__label__software": 0.01468658447265625, "__label__software_dev": 0.85546875, "__label__sports_fitness": 0.00024378299713134768, "__label__transportation": 0.000492095947265625, "__label__travel": 0.0001882314682006836}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 49657, 0.02124]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 49657, 0.35975]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 49657, 0.87666]], "google_gemma-3-12b-it_contains_pii": [[0, 717, false], [717, 6228, null], [6228, 12153, null], [12153, 19401, null], [19401, 24913, null], [24913, 31462, null], [31462, 36960, null], [36960, 43112, null], [43112, 49657, null]], "google_gemma-3-12b-it_is_public_document": [[0, 717, true], [717, 6228, null], [6228, 12153, null], [12153, 19401, null], [19401, 24913, null], [24913, 31462, null], [31462, 36960, null], [36960, 43112, null], [43112, 49657, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 49657, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 49657, null]], "pdf_page_numbers": [[0, 717, 1], [717, 6228, 2], [6228, 12153, 3], [12153, 19401, 4], [19401, 24913, 5], [24913, 31462, 6], [31462, 36960, 7], [36960, 43112, 8], [43112, 49657, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 49657, 0.1087]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
0e5629baf6c97496cc769a165cf41a84bae81dc2
On the Complexity of Buffer Allocation in Message Passing Systems Alex BRODSKY, Jan Bækgaard PEDERSEN & Alan WAGNER Department of Computer Science University of British Columbia Vancouver, BC, Canada, V6T 1Z4 {abrodsky,matt,wagner}@cs.ubc.ca Abstract. In modern cluster systems message passing functionality is often off-loaded to the network interface card for efficiency reasons. However, this limits the amount of memory available for message buffers. Unfortunately, buffer insufficiency can cause an otherwise correct program to deadlock, or at least slow down. Hence, given a program trace from an execution in an unrestricted environment, determining the minimum number of buffers needed for a safe execution is an important problem. We present three related problems, all concerned with buffer allocation for safe and efficient execution. We prove intractability results for the first two problems and present a polynomial time algorithm for the third. 1 Introduction For efficiency reasons, most modern clusters off-load message passing functionality to the network interface card (NIC) [1] to facilitate a greater overlap of computation and communication. Unfortunately, most NICs have two orders of magnitude less memory than the average host, which makes message buffers a limited resource. Thus, programs that use asynchronous message passing and execute correctly otherwise, might dead-lock when executing on a system where parts of the message passing system have been off-loaded to the NIC; such issues have been investigated in [2, 3, 4]. Ideally, we want to detect the possibility of dead-lock and prevent it from happening. The MPI message passing standard [4] defines a “safe” program as one that requires no buffering and uses synchronous communication. Since better performance can be obtained by taking advantage of system or network buffers to reduce unnecessary synchronizations—asynchronous communication—the notion of a “k-safe” (asynchronous) program arises. A “k-safe” program requires $k$ buffers to guarantee completion [1, 5, 6]. Unfortunately the value of $k$ is usually not known a priori. In this paper we investigate the complexity of determining a minimum value of $k$ for programs that use asynchronous buffer communication and have static communication patterns. Under these assumptions we show that the problem of determining $k$, the minimum number of buffers for deadlock free execution, is NP-hard. Furthermore, we show that the simpler task of verifying whether a buffer assignment is sufficient to avoid deadlock is coNP-complete. Finally, we give a polynomial time algorithm for determining... the exact number of buffers needed to ensure nonblocking sends, achieving efficient program execution. Interestingly, the nonblocking requirement makes the problem tractable! Motivations and precise definitions of the system and the problems considered are given in the following sections. 2 Background Determining the k-safety of a program is important for several reasons. First, the semantics of asynchronous communication depend on the availability of buffers, and change—in an implementation dependent fashion—when buffer space becomes exhausted. Since buffer space is typically limited, or pre-allocated during application initialization, a priori knowledge of the application’s buffer requirements ensures that communication semantics do not change part way through the execution. Second, to improve performance, many systems use zero-copy techniques: messages are transferred directly from the NIC to application buffers. Since these buffers must be pre-allocated by the application, the application must know the number required. Third, one of the most common purposes of parallelization is to enable the solutions of bigger problems on larger data sets. Typically, host memory is the limiting resource and, if the number of buffers needed is known, memory utilization can be improved. Finally, communication libraries like MPI allow the application to manage the buffer space; this can be optimized if the number required is known in advance. The most natural primitives for asynchronous buffered communication are “nonblocking sends” and “blocking receives”; these are also the standard communication primitives in MPI [4] and PVM [7]. Cypher and Leu formally define the former as a POST-SEND immediately followed by a WAIT-FOR-BUFFER-RELEASE and the latter as a POST-RECEIVE immediately followed by a WAIT-FOR-RECEIVE-TO-BE-MATCHED [8, 9]. Informally, the send blocks until the message is copied out of the send buffer and the receive blocks until the message has been copied into the receive buffer. We only consider point-to-point communication similar to the model used in [10], since multicast and broadcast communication can be simulated with point-to-point communication. A multiprocess system $S$ is a set of simultaneously executing independent asynchronous processes that perform a computation by interspersing local computation and point-to-point message passing between processes; these are referred to as $A$-computations in [10]. Such a system is equivalent to the system with three different events like the one defined by Lamport [11]: send events, receive events and internal events. Send events cause messages to be sent, receive events causes messages to be received and internal events represent computation on internal state. The system uses nonblocking sends and blocking receives; processes synchronize by communicating and no assumptions can be made about the computation time of any process. When a process performs a send, the message may either be sent to the receiving process where it is either received or buffered, or the sending process blocks. If the receiving process is ready to receive (i.e., has issued a receive request for the incoming message), or the message passing system has free buffers available, the sending process does not block. If no buffers are available and the receiving process is not ready to receive, the sending process blocks until one of the conditions changes. These communication primitives are comparable to the default send/receive primitives found in PVM and MPI: blocking receives and nonblocking sends when buffers are available and blocking when not. In such a model each process has a pool of buffers for incoming messages used on a first come first served basis; we call these receive buffers. Buffers are used when a message is not ready to be received by the receiving process. Buffers are returned to the receiving process’s buffer pool when the message has been received (i.e., the corresponding receive request has completed). Other models that use only send buffers, a combination of send and receive buffers, or buffers that are allocated on a per channel basis, are possible. While the focus of this paper is on the receive buffer model, our results are applicable to other models as well. In this paper we consider programs that are repeatable [8, 9] when executed in an unrestricted environment, i.e., programs with static communication patterns. While this narrows the class of programs we consider, the class of applications with static communication patterns is still considerable, including: grid computations, linear system computations, and pipe line computations. Since the communication pattern must be static we do not consider the case where a receive can specify a wild card, i.e., a receive specifies exactly one sender; regardless of this restriction the problems we consider remain intractable. A message history $M$ for the execution of a system $S$ is a set of messages of the form $m = (i, s_i, j, s_j)$ where $i$ and $j$ are process identifiers; $i$ represents the sender and $j$ represents the receiver. The sequence numbers $s_i$ and $s_j$ are local to the sending and receiving processes, respectively. For process $i$ the first send or receive has sequence number 1, the second has number 2, and so forth. We use a communication graph $G(S)$, described in the next section, to encode the message history; sends and receives are encoded as vertices, and the sequence numbers are represented by the topological order of the vertices in $G(S)$. Even though the communication pattern is static, the arrival time of messages varies from execution to execution. The following example shows this effect and how the allocation of buffers can result in deadlock. Consider the three process system depicted in Figure 1 where $p_1$ and $p_3$ each have zero buffers available and process $p_2$ has one buffer available. Two different scenarios exist. In the first scenario, message 1 arrives before message 3 and takes up the buffer. Now processes $p_2$ and $p_3$ can never progress as one additional buffer is needed to break the deadlock between them. In the second scenario, message 3 arrives first and takes up the buffer. Process $p_3$ can proceed to its receive call and block until message 2 arrives. Consequently, process $p_2$ will send message 2, receive message 1 followed by message 3. Thus, all processes finish and no deadlock occurs. For example, if process $p_3$ had one buffer rather than process $p_2$, the system depicted in Figure 1 is guaranteed to complete for all executions. As demonstrated, the order in which messages arrive at a process determines whether a system deadlocks. We call a system that exhibits such behaviours unsafe. This situation can be rectified by an appropriate allocation of buffers to processes. To conserve memory, we want to allocate only as many buffers as needed. For programs with static communication patterns, we would like to determine a minimum buffer assignment or to determine whether a given buffer assignment prevents deadlock. As we will show, both of these problems are intractable. If system \( S \) is to execute efficiently, ideally, no send operation blocks. In addition to safety, we like to determine the minimum buffer assignment necessary to prevent blocking sends. Interest- ingly, the stricter constraint makes the corresponding buffer allocation problem tractable. Determining whether a system is buffer independent—the system is 0-safe—was investigated in [8, 9]. In our model the interesting systems are buffer-dependent, and require an unknown number of buffers to avoid deadlock. To determine the minimum number of buffers, the execution of a system can be modeled using a (coloured) Petri net [12]. In order to determine if the system can reach a state of deadlock, the Petri net occurrence graph [13] is constructed, and a search for dead markings is performed. However, the size of the occurrence graph is exponential in the size of the original Petri net. A variation of this problem has been investigated by the operations research community [14, 15, 16]. In these models, events or products are buffered between various stations in the production process, however, the arrival of these events is governed by probability distributions, which are specified a priori. In our model, since processes are asynchronous, the time for a message to arrive is non-deterministic, i.e., a message may take an arbitrarily long time to arrive and a process may take an arbitrarily long time to perform a send or a receive. 3 Definitions Let \( S \) be a multiprocess system with \( n \) processes and \( E_i \) communication events occurring in process \( i \); a communication event is either a send or a receive. A communication graph of \( S \) is a directed acyclic graph \( G(S) = (V, A) \) where the set of vertices \( V = \{v_{i,c} \mid 1 \leq i \leq n, 0 \leq c \leq (E_i + 1)\} \) corresponds to the communication events and the arc set \( A \) consists of two disjoint arc sets, the computation arc set \( P \) and the communication arc set \( C \). Each vertex represents an event in the system: vertex \( v_{i,0} \) represents the start of process \( i \), vertex \( v_{i,c} \), \( 1 \leq c \leq E_i \), represents either a send or a receive event, and vertex \( v_{i,(E_i+1)} \) represents the end of a process. An arc \( (v_{i,c}, v_{i,c+1}) \in P, 0 \leq c \leq E_i \), represents a computation within process \( i \) and an arc \( (v_{i,s}, v_{j,t}) \in C \) represents a communication between different processes, \( i \) and \( j \), where \( v_{i,s} \) is a send vertex, and \( v_{j,t} \) is a receive vertex (e.g. Figure 2). Note, the process arcs are drawn without orientation for clarity; they are always oriented downwards. In general vertices are labelled with double indices, representing the process label and the sequence number of the corresponding event. The former is dropped when the process label is given by the context. Communication graphs are comparable to the time-space diagrams—without internal events—noted in [11]. A multiprocess system \( S \) is unsafe if a deadlock can occur due to an insufficient number of available buffers; if \( S \) is not unsafe, then \( S \) is said to be safe. Figures 1 and 3 are examples of unsafe systems. Note: the numbers above the graph in Figure 3 represents the buffer assignment. A buffer assignment is an \( n \)-tuple \( B = (b_1, b_2, ..., b_n) \) of non-negative integers that represent the number of buffers that can be allocated by each process. Since buffers use up memory, which may be needed by the application, ideally, as few buffers as possible should be allocated. However, allocating too few buffers can result in an unsafe system. Two natural decision problems arise from this optimization problem. Given a communication graph \( G(S) \) and a non-negative integer \( k \), the Buffer Allocation Problem (BAP) is to decide if there exists a buffer assignment $B = (b_1, b_2, ..., b_n)$ such that $S$ is safe and $\sum_{i=1}^{n} b_i \leq k$. In order to solve this problem we need to solve a simpler one. Suppose we are given a buffer assignment $B = (b_1, b_2, ..., b_n)$ and a communication graph $G(S)$, the **Buffer Sufficiency Problem** (BSP) is to decide if the assignment is sufficient to make $S$ safe. Additionally, we can require that no process in system $S$ should ever block on a send. Given a communication graph $G(S)$ and a non-negative integer $k$, the **Nonblocking Buffer Allocation Problem** (NBAP) is to decide if there exists a buffer assignment $B = (b_1, b_2, ..., b_n)$, such that no send in $S$ ever blocks, and $\sum_{i=1}^{n} b_i \leq k$. Next, we introduce the terminology used throughout the paper. ### 3.1 Terminology The $i$th **process component** $G_i(S)$ of $G(S)$ is the subgraph $G_i(S) = (V_i, A_i)$ where $V_i = \{v_{i,c} \in V \mid 0 \leq c \leq (E_i + 1) \}$ and $A_i = \{(v_{i,c}, v_{i,c+1}) \in A \mid 0 \leq c \leq E_i \}$. The process component corresponds to a process in $S$. We construct communication graphs by connecting process components with arcs. Hence, it is more intuitive to treat a process component as a chain of send and receive vertices bound by a start and an end vertex. A **t-ring** is a subgraph of a communication graph $G(S)$, consisting of $t > 1$ process components such that in each of the $t$ process components there is a send vertex $s_{ij,c}$ and a receive vertex $r_{ij,d}$, $c < d$, $1 \leq j \leq t$ such that the arcs $(s_{ij,c}, r_{ij,d})$ and $(s_{ij+1,c+1}, r_{ij,d})$, $1 \leq j < t$, are in $A$. This definition is equivalent to the definition of a “crown” in [10]. A t-ring is a circular dependence of alternating send and receive events; an example of a t-ring is illustrated in Figure 4. As the shaded arcs in Figure 4 show, each receive event depends on the preceding send event and each send event depends on the corresponding receive event. Thus, without an available buffer, there is a circular dependency that results in the system deadlocking. Therefore, a system $S$ whose communication graph $G(S)$ contains a t-ring will deadlock unless one of the processes in the t-ring has an available buffer. Since $G(S)$ must be a DAG, no cycle will never occur in $G(S)$. Figure 2 shows an example of a 2-ring. If $G(S)$ contains a t-ring, then we say that system $S$ also contains a t-ring. In this paper we use $G(S)$ rather than the dependency graph because the order in which received messages are allocated to buffers depends on the execution history. In order to model the execution of a system we define a colouring game that simulates the execution of the system with respect to $G(S)$. ### 3.2 Colouring the Communication Graph Given a communication graph $G(S)$, an execution of a corresponding system $S$ is represented by a colouring game where the goal is to colour all vertices green; a green vertex corresponds to the completion of an event. We use three colours to denote the state of each event in the system: a red vertex indicates that the corresponding event has not started, a yellow vertex indicates that the corresponding event has started but not completed, and a green vertex indicates that the corresponding event has completed. Hence, a red vertex must first be coloured yellow before it can be coloured green; this corresponds to a traffic lights changing from red, to yellow, to green. To represent buffer allocations we use tokens. For each process with a number of allocated buffers, we associate an equal size pool of tokens with the corresponding process component. To represent a buffer allocation, tokens are removed from the process component’s token pool and placed on the receive vertices. The colouring game represents an execution via the following rules. Initially, the start vertices of $G(S)$ are coloured green and all remaining vertices are coloured red; this is called the initial colouring. 1. A red send vertex may be coloured yellow if the preceding vertex is green (i.e., the send is ready). 2. A red receive vertex may be coloured yellow if the corresponding send vertex is yellow, and (a) the preceding vertex (in the same process component) is green (i.e., both the send and the receive are ready), or (b) a token from the corresponding buffer pool is moved on to the vertex (i.e., the send is ready and a buffer is available). 3. A yellow send vertex may be coloured green if the corresponding receive vertex is coloured yellow (i.e., the communication has completed from the senders perspective). 1Naturally, we refer to a European traffic light. 4. A yellow receive vertex may be coloured green if both of its preceding vertices are green. If the vertex has a token, the token is returned to the process component’s pool (i.e., a receive completes once the send completes and the preceding computation completes). 5. A red end vertex may be coloured yellow if the preceding vertex is green. 6. A yellow end vertex may be coloured green if the preceding vertex is green. Buffer utilization is represented by placing a token from the token pool of the process component on the selected vertex, and colouring it yellow. If no tokens are available, the rule cannot be invoked. A valid colouring of $G$, denoted $\chi_G$, is a colour assignment to all vertices that can be obtained by repeatedly applying the colouring rules, starting from the initial colouring. A colouring sequence $\Sigma = (\chi^1, \chi^2, \ldots)$ is a sequence of valid colourings such that each colouring is derived from the preceding one by a single application of one of the colouring rules. An execution of a multiprocess system $S$ with buffer assignment $B$ is represented by a colouring sequence on $G(S)$. We say that a colouring sequence completes if and only if the last colouring in the sequence comprises only green vertices. A colouring sequence deadlocks if and only if the last colouring in the sequence has one or more non-green vertices and the sequence cannot be extended via the application of the colouring rules. Furthermore, each transition, from one colouring to the next, within a colouring sequence, corresponds to a change of state of an event in the corresponding execution. Assuming that all events in the system are ordered, there is a correspondence between the colouring sequences on $G(S)$ and the executions of system $S$. A system $S$ is safe if and only if every colouring sequence on the graph $G(S)$ completes. Furthermore, sends in $S$ never block if and only if every partial colouring sequence on $G(S)$ that ends with a colouring containing a yellow send vertex and a corresponding red receive vertex can be extended by applying rule 2 to the red receive vertex. The choice of when to apply rule 2 affects future choices. For example, in Figure 3, applying the rule to the receive vertex corresponding to the send from process $p_1$, before the send vertex in process $p_3$ is coloured green, results in a deadlocked colouring sequence. 4 The Buffer Allocation Problem In order to prevent deadlock in distributed applications the underlying system needs to allocate a sufficient number of buffers. Ideally, it should be the minimum number required. Unfortunately, the corresponding decision problem, BAP is intractable: given a communication graph $G(S)$ and a positive integer $k$, determine whether there exists a buffer assignment of at most $k$ buffers such that $S$ is safe. We show that BAP is NP-hard by a reduction of the well known 3-SAT problem[17] to BAP. Recall the definition of 3-SAT: determine if there exists a satisfying assignment to $\bigwedge_{i=1}^n (a_i \lor b_i \lor c_i)$, where $a_i$, $b_i$, and $c_i$ are boolean literals in $\{x_1, \bar{x}_1, x_2, \bar{x}_2, \ldots, x_n, \bar{x}_n\}$. We first need the following lemma. Lemma 4.1 (The t-Ring Lemma) Let $G$ be a communication graph comprising a single t-ring. No colouring sequence on $G$ can complete without invoking rule 2b at least once. Proof: Assume by contradiction that there exists a complete colouring sequence $\Sigma$ that does not make use of rule 2b. Consider the first colouring in $\Sigma$ where one of the sending vertices is green; call the vertex $s_i$. Let $r_j$ be the corresponding receive vertex. By rule 3, the vertex $r_j$ must be yellow. Since rule 2b has not been applied, rule 2a must have been invoked earlier in the sequence. By the definition of a t-ring, the send vertex $s_j$ must be the predecessor of $r_j$. Since the rule 2a was applied to $r_j$, $s_j$ must be green. Hence, there is an earlier colouring in $\Sigma$ with a green send vertex. This is a contradiction. **Theorem 4.2** The Buffer Allocation Problem (BAP) is NP-hard. **Proof:** We prove this by reduction of 3-SAT to BAP. For any 3-SAT instance $F$ we construct a corresponding system $S$ and the corresponding communication graph $G(S)$, both which are polynomial in the size of $F$. The system has $2n + 1$ processes, where $n$ is the number of variables. Each process contains $c + 1$ epochs where $c$ is the number of clauses in $F$. An epoch is a consecutive sequence of one or more events in a process. An epoch terminates on a send to a barrier process, or when the process terminates. An epoch begins on a receive from a barrier process or when the process starts. A barrier process is used to synchronize all processes at the end of its epoch. Each process performs a send to the barrier process at the end of their epoch, and waits for a response from the barrier process. The barrier process sends the response to every process only after it has received a message from each process. An epoch of a process component is correspondingly defined. Epochs are used to prevent unwanted interaction between processes. For each literal $x_i$ and $\bar{x}_i$, let the system $S$ contain processes $p_{x_i}$ and $p_{\bar{x}_i}$. In addition, let $p_{\text{barrier}}$ denote the barrier process in $S$. Epoch 0 is used to fix a buffer assignment corresponding to a variable assignment in 3-SAT. In epoch 0 add a 2-ring between processes $p_{x_i}$ and $p_{\bar{x}_i}$. This corresponds to fixing an assignment, because by Lemma 4.1, to colour vertices $s_{x_i}$ and $s_{\bar{x}_i}$ green, a free token must be available at either process component $p_{x_i}$ or $p_{\bar{x}_i}$. Hence, we need at least $n$ tokens. Note, at the end of each epoch, each token is released back into its token pool. The $j$th epoch of each process corresponds to the $j$th clause of $F$ and is a 3-ring on the processes $p_{a_j}$, $p_{b_j}$, and $p_{c_j}$ that correspond to the literals $a_j$, $b_j$, and $c_j$ (see Figure 6). By Lemma 4.1, in order to avoid deadlock, at least one of the three processes, $p_{a_j}$, $p_{b_j}$, or $p_{c_j}$, must have a buffer. Finally, at the end of the epoch, all processes perform a send to the process $p_{\text{barrier}}$ and wait for a reply. This is formalized in the following Lemma. **Lemma 4.3** There exists a token assignment of size $n$ such that all colouring sequences on $G(S)$ complete if and only if formula $F$ is satisfiable. **Proof:** Let $s_{x_i,0}$, $s_{\bar{x}_i,0}$, $r_{x_i,0}$, and $r_{\bar{x}_i,0}$ be the send and receive vertices in epoch 0. By Lemma 4.1, to colour vertices $s_{x_i,0}$ and $s_{\bar{x}_i,0}$ green, a free token must be available at either process component $p_{x_i}$ or $p_{\bar{x}_i}$. Hence, we need at least $n$ tokens. Note, at the end of each epoch, each token is released back into its token pool. As long as all vertices in each epoch of each process component can be coloured green, the barrier component can also be coloured green. A colouring sequence will only deadlock in the barrier if the corresponding send vertex in one of the process components can not be coloured yellow. If $F$ has a satisfying assignment, then at least one literal in every clause will be true. A corresponding token assignment will ensure that each 3-ring has at least one process component with a token (one corresponding to a true literal). Hence, by Lemma 4.1 none of colouring sequences will deadlock on any of the the 3-rings. Hence, any colouring sequence on $G(S)$ will complete. If $F$ does not have a satisfying assignment, then for any assignment there exists at least one clause comprising false literals. The corresponding token assignment will not assign any tokens to the process components in the corresponding 3-ring. Thus, by Lemma 4.1 all colouring sequences will deadlock in that 3-ring. Further, none of the colouring sequences on $G(S)$ will complete. Hence, any colouring sequence on $G(S)$ will complete if and only if the corresponding assignment satisfies $F$. ■ Hence, there exists a buffer assignment of size $n$ such that $S$ is safe if and only if $F$ is satisfiable. Thus, BAP is NP-hard. ■ **Theorem 4.4** The Buffer Allocation Problem (BAP) is in $\Sigma_2P$. **Proof:** By Theorem 5.1, verifying that a token assignment is sufficient to prevent deadlock (BSP) is coNP-complete. Since we can non-deterministically guess a sufficient token assignment, the result follows. ■ The Buffer Allocation Problem remains intractable for systems with send buffers only, and for systems with a combination of both send and receive buffers. In the latter case, the problem remains in $\Sigma_2P$ because the class of systems with receive buffers only is a subclass of systems with both receive and send buffers. In the former case, we conjecture that the problem is NP-complete. The NP-hardness follows from the observation that each t-ring in the system has to have a buffer assigned to one of its processes in order for the system to progress. It does not matter if it is a send or a receive buffer. Hence, the reduction used in Theorem 4.2 can be applied with no modification. ### 5 The Buffer Sufficiency Problem We now turn our attention to the possibly simpler problem of verifying whether a given buffer assignment is sufficient to prevent deadlock. However, this turns out to be an intractable problem as well; we show that BSP is coNP-complete by a reduction from the TAUTOLOGY problem [18, Page 261] to BSP. Given an instance of a formula in disjunctive normal form (DNF), \( \bigvee_{i=0}^{n} \bigwedge_{j=0}^{L_{i,j}} L_{i,j} \) where \( L_{i,j} \in \{ x_1, \bar{x}_1, \ldots, x_n, \bar{x}_n \} \), the formula is a tautology if it is true on all assignments. An assignment for which the formula is not true is a concise proof that the formula is not a tautology. **Theorem 5.1** The Buffer Sufficiency Problem (BSP) is coNP-complete. **Proof:** We first observe that if \( S \) is unsafe, then there exists a concise certificate of this fact comprising a colouring sequence on \( G(S) \) that does not complete. Since the size of a colouring sequence is at most twice the number of vertices in \( G(S) \), the certificate is polynomial in size and hence, BSP is in coNP. Let \( F \) be a DNF formula with \( t \) terms where the \( i \)th term has \( l_i \) literals. For any formula \( F \), we construct a system \( S \) and show that there exists a deadlocking colouring sequence on \( G(S) \) if and only if the formula is not a tautology. We represent the disjunction of \( t \) terms by a subsystem containing a t-ring on \( t \) processes where each term is a subsystem consisting of a single process, called a ‘term’ process. The communication graphs corresponding to the term and the disjunction are illustrated in Figures 7 and 8 respectively. Following the t-ring, one ‘term’ process performs a send – called a ‘done’ send – to signal that the t-ring did not deadlock. Finally, the \( i \)th ‘term’ process performs \( l_i \) receives, corresponding to the literals of the \( i \)th term; the latter we call ‘literal’ receives. The first receive in the ‘term’ process is called a ‘t-ring’ receive. ![Figure 7: Disjunction subsystem.](image) When a message to a ‘term’ process arrives before any send within the t-ring begins, the message is buffered, using up the one available buffer and preventing the process from buffering any additional messages until it leaves the t-ring. This corresponds to the falsification of the corresponding literal and term. To represent a variable assignment, we use a select subsystem consisting of three processes \( p_x, p_{\bar{x}}, \) and \( q_i \); the first two processes correspond to the truth values of \( x_i \) and are called ‘select’ processes. The third process, called the ‘arbiter’, fixes the truth value of \( x_i \). Processes \( p_x \) and \( p_{\bar{x}} \) each perform a send to the third ‘arbiter’ process, but the ‘arbiter’ process can receive neither message until it receives a ‘done’ message. Since the ‘arbiter’ has only one buffer, only one of the sends from the processes \( p_x \) and \( p_{\bar{x}} \) will be buffered; the other send will cause the sending process to block until the ‘done’ message arrives. The process that did not block performs a nonblocking send, via a disperser (described below), to each ‘term’ process whose corresponding term contains the complement of the fixed variable. A disperser is a nonblocking subsystem that upon receipt of a ‘disperse’ message performs a nonblocking broadcast by using additional processes as buffers (see Figure 10). To construct a multiprocess system $S$ that corresponds to formula $F$, instantiate a select subsystem for each variable and a disjunction subsystem corresponding to $F$. The disjunction subsystem performs the ‘done’ send to a disperser, which broadcasts it to the select subsystems. Finally, each select subsystem broadcasts its selection, via a disperser, to the corresponding ‘literal’ re- ceives of the ‘term’ processes; Figure 11 depicts the corresponding communication graph $G(S)$ of a composition. ![Figure 11: The composite widget for the formula $(x_1 \land x_2 \land \bar{x}_3) \lor (\bar{x}_1 \land \bar{x}_3) \lor (x_1 \land \bar{x}_2)$.](image) Intuitively, if each of the ‘term’ processes receive a message from a select subsystem – sent via a disperser – before any of the ‘term’ processes initiate a send event, the buffers on each of the ‘term’ processes will be used up. By Lemma 4.1 this will prevent the disjunction subsystem from advancing past the t-ring. If the formula cannot be falsified, then at least one ‘term’ process will not receive any messages before the disjunction subsystem advances past the t-ring. This is formalized in the following lemma. **Lemma 5.2** There exists a deadlocking colouring sequence on the communication graph $G(S)$ if and only if the formula $F$ is not a tautology. **Proof:** If $F$ is not a tautology, then there exists an assignment for which every term in the disjunction is false. In this case we show that a deadlocking colouring sequence exists. Let $v_{x_i,0}$ and $v_{\bar{x}_i,0}$ be the start vertices of process components $p_{x_i}$ and $p_{\bar{x}_i}$ respectively. Similarly, let the send vertices $s_{x_i,1}$ and $s_{\bar{x}_i,1}$ be adjacent to the receive vertices $r_{q_i,x_i}$ and $r_{q_i,\bar{x}_i}$ in the process component $q_i$, and let $s_{x_i,2}$ and $s_{\bar{x}_i,2}$ be the send vertices of the arcs that are incident on the disperser components. Let $Z \subseteq V$ be the set of start vertices corresponding to the falsifying assignment of $F$; $Z$ will contain one of $v_{x_i,0}$ or $v_{\bar{x}_i,0}$ for each $i$. First, let $\Sigma_Z$ be the longest colouring sequence constructed by applying the colouring rules only to vertices that have ancestors in $Z$. Since each $q_i$ has one free token, for every $v_{q_i,0} \in Z$ or $v_{\bar{q}_i,0} \in Z$, vertex $r_{q_i,x_i}$ (respectively $r_{q_i,\bar{x}_i}$), will be assigned a token and coloured yellow via rule 2b; later in the sequence the vertices $s_{x_i,2}$ (respectively $s_{\bar{x}_i,2}$) can be coloured yellow and then green. The corresponding receive vertex in the disperser component can thus be coloured green. Since the dispersers are adjacent to the ‘literal’ receive vertices in the term process components, the corresponding send vertex of each of the receive vertices can be coloured yellow, implying that rule 2b can be applied to the ‘literal’ receive vertices. Thus, if $Z$ contains $v_{x_i,0}$ or $v_{\bar{x}_i,0}$, and a term process component contains a ‘literal’ receive vertex corresponding to $\bar{x}_i$ (respectively $x_i$), then the token in the corresponding process component will be used up. Second, extend $\Sigma_Z$ by allowing all valid colourings. To avoid deadlock, Lemma 4.1 requires at least one of the term process components in the disjunction to have a free token. Since $F$ is not a tautology and we used a falsifying assignment, none of the process components has a free token, and the colouring sequence will deadlock. If $F$ is a tautology, then regardless of the assignment, one of the terms will be true (i.e., all the literals in the term will be true). Hence, at least one term process component will have no ‘literal’ receive vertices that are descendants of $Z$, and will have a token available to prevent the colouring sequence from deadlocking on the t-ring. Observe that the selection component allows at most one of $r_{q_i,x_i}$ or $r_{q_i,\bar{x}_i}$ to be coloured yellow, via rule 2b. Provided that the ‘done’ receive vertex of process component $q_i$ is not coloured green, at least one term component will not have any ‘literal’ receive vertices to which rule 2b can be applied. Thus, the token belonging to that process component will be available to prevent the colouring sequence from deadlocking on the t-ring. On the other hand, if the ‘done’ receive vertex is coloured green, then the ‘done’ send vertex in the term component is coloured green. This means that at least one ‘t-ring’ receive vertex is coloured green, and hence the colouring sequence will not deadlock in the t-ring. Once the ‘done’ send vertex is coloured green, the colouring sequence can always complete. Hence, the system $S$ is safe. Hence, system $S$ is unsafe if and only if the formula is not a tautology. Since BSP is in $\text{coNP}$ and is $\text{coNP}$-hard via a reduction from $\text{TAUTOLOGY}$, BSP is $\text{coNP}$-complete. This result also holds for systems that use a combination of both send and receive buffers. The $\text{coNP}$-hardness follows from the fact that systems with receive buffers only are also systems that use combinations of send and receive buffers. Since a colouring sequence also serves as a deadlock certificate for combination systems, the $\text{coNP}$-completeness result follows. In the case of systems with send buffers, we conjecture that the corresponding BSP is in $\text{P}$. Unlike communication in systems with receive buffers only, the order of the sends implies an order on the allocation of buffers. Hence, we believe that the computation of sufficiency is similar to the nonblocking buffer allocation problem and hence is in $\text{P}$. 6 The Nonblocking Buffer Allocation Problem We now turn to the last of the three problems we consider in this paper. In addition to the system being safe, we can require that no sending process ever blocks due to insufficient buffers on the receiving process. The Nonblocking Buffer Allocation Problem (NBAP) is to determine the minimum number of buffers needed to achieve nonblocking sends. Given $G(S)$, the following algorithm computes the number of buffers needed to assure that none of the sends will ever block. Given two vertices, $v_{i,c+k}$ and $v_{i,c}$, in $G(S)$, $k > 0$, vertex $v_{i,c+k}$ is **communication dependent** on vertex $v_{i,c}$ if $v_{i,c}$ is the start vertex or if there exist a vertex $v_{j,d}$, $j \neq i$, such that there exists a path from $v_{i,c}$ to $v_{j,d}$ and the arc $(v_{j,d}, v_{i,c})$ is in $A$ (see Figure 12). Vertex $v_{i,c+k}$ is **terminally communication dependent** on vertex $v_{i,c}$ if $v_{i,c+k}$ is communication dependent on $v_{i,c}$ and is not communication dependent on the vertices $v_{i,c+l}$, $0 < l < k$. The algorithm is depicted in Figure 13. 1. For each receive vertex $v_{i,c}$ determine its terminal communication dependency, vertex $v_{i,t}$, where $t < c$. 2. Set $I_{i,c} = [t, c]$ to be the interval between vertex $v_{i,t}$ and vertex $v_{i,c}$. 3. For each process component $G_i(S)$, compute $b_i$, the maximum overlap over all intervals $I_{i,c}$. 4. $B = \{b_1, b_2, \ldots, b_n\}$ is the optimal nonblocking buffer assignment. The time between when a message can arrive and when it is received at receive vertex $v_{i,c}$ is represented by the interval $I_{i,c}$. Each interval must have a buffer to ensure nonblocking sends. Hence, the minimum number of buffers, $b_i$, is the maximum overlap over all intervals of a process component $G_i(S)$. Computing the terminal communication dependencies for $G(S)$ can be done via dynamic programming in $O(|V|n)$ time, where $V$ is the vertex set of $G(S)$ and $n$ is the number of processes. If there exists a path from vertex $v_{i,c}$ to $v_{j,d}$, then there exists a path from $v_{i,c}$ to all vertices $v_{j,d+k}$, $k > 0$. Associate with each vertex $v_{i,c}$ an integer vector $a_{i,c}$ of size $n$; $a_{i,c}[j] = d$ means that there exists a path from $v_{i,c}$ to $v_{j,d}$, and thus to $v_{j,d+k}$, $k > 0$. The vector $a_{i,c}$ is computed by taking the elementwise minimums over the vectors of the adjacent vertices $v_{i,c}$; this is simply a depth first traversal of $G(S)$. Since the number of arcs is at most $3|V|/2$ and the pairwise comparison takes $n$ steps, the traversal takes $O(|V|n)$ time. Next, computing the $O(|V|)$ intervals, $I_{i,c}$, requires one table lookup per interval. To compute the maximum overlap we sort the intervals and perform a sweep, keeping track of the current and maximum overlap; this takes $O(|V| \log |V|)$ time. Thus, the total complexity is $O(|V|n + |V| \log |V|)$. time. In the worst case where \( p \approx |V| \), this algorithm is quadratic. However, in practice \( n \) is usually fixed, in which case the \( |V| \log |V| \) term dominates. ### 6.1 Proof of Correctness of the Nonblocking Buffer Allocation Algorithm In terms of the colouring game, a system \( S \) will not block on any send if for any valid colouring on \( G(S) \) containing a yellow send vertex \( s \) and a corresponding red receive vertex \( r \), vertex \( r \) can be coloured yellow by applying rule 2b. This corresponds to guaranteeing buffer availability for every send in the system. **Lemma 6.1** Given a multiprocess system \( S \), let \( G(S) \) be the corresponding communication graph. For all vertices \( v_{i,s}, v_{j,t} \in G(S) \), if \( v_{j,t} \) is a send vertex and there exists a path from the vertex \( v_{i,s} \) to vertex \( v_{j,t} \), then vertex \( v_{j,t} \) cannot be coloured yellow until vertex \( v_{i,s} \) is coloured green. **Proof:** By rule 1, the predecessor of \( v_{j,t} \) must first be coloured green before \( v_{j,t} \) can be coloured yellow. Since rules 3 and 4 imply that the predecessors of a green vertex must be green, the result follows. **Corollary 6.2** Let \( S, G(S), v_{i,s}, v_{j,t} \) be as in Lemma 6.1 and let \( v_{i,r} \) be the receive vertex corresponding to the send vertex \( v_{j,t} \). Rule 2b will never be applied to vertex \( v_{i,r} \) before vertex \( v_{i,s} \) is coloured green. The preceding corollary implies that a buffer for the receive event corresponding to vertex \( v_{i,r} \) need not be available until the completion of the send event corresponding to the vertex, on which \( v_{i,r} \) is terminally communication dependent. Hence, it is sufficient to allocate the buffer just before the completion of the respective send event. Finally, we argue that this is also necessary. **Theorem 6.3** Given \( S \) and \( G(S) \), let \( v_{i,s} \) be a send vertex and \( v_{i,r} \) be a receive vertex that is terminally communication dependent on vertex \( v_{i,s} \). A token for the application of Rule 2b on vertex \( v_{i,r} \) must be available before vertex \( v_{i,s} \) is coloured green. **Proof:** Let \( v_{j,t} \) be the send vertex corresponding to the receive vertex \( v_{i,r} \) and let \( Q = \{ v_{i,q} \mid s < q < r \} \) be the set of vertices that are predecessors of \( v_{i,r} \), but on which \( v_{i,r} \) is not communication dependent. Since \( v_{i,r} \) is not communication dependent on the vertices in \( Q \), we can construct a colouring sequence on \( G(S) \) that fixes the vertices in \( Q \) to be red, and colours vertex \( v_{j,t} \) yellow, making the application of rule 2b possible in the next step. Since no progress is made in the \( i \)th process component after colouring vertex \( v_{i,s} \) green, the state of the associated token pool does not change until the application of rule 2b to vertex \( v_{i,r} \). Hence, when vertex \( v_{i,s} \) is coloured green, the token pool must have a token destined for vertex \( v_{i,r} \). Thus, if receive event \( r \) is terminally communication dependent on send event \( s \), then it is necessary and sufficient that a buffer to be used for receive event \( r \) must be allocated before the send event \( s \) completes. The start event may be thought of as a special send event. Since a buffer is required for each receive over a corresponding interval, computing the maximum overlap of intervals yields the number of buffers required. 6.2 Other Models For systems with only send buffers the problem remains in P. The problem can be solved by first reversing all arcs in the communication graph, swapping the start and end vertices, and then running the algorithm described above. For systems with both send and receive buffers, we conjecture that the nonblocking buffer allocation problem is NP-hard. This follows from the observation that we have a choice of either allocating a buffer on the sending or the receiving side, each time a buffer is needed. 6.3 Approximating BAP with NBAP The NBAP algorithm may be useful for determining a buffer assignment that prevents deadlock (BAP). Since a non-blocking execution is guaranteed not to deadlock, any buffer assignment determined by the NBAP algorithm ensures a safe execution. However, the buffer assignment may be far from optimal. A simple example of this phenomena is a two process producer-consumer system comprising of n messages sent by the producer and received by the consumer in the respective order. Such a system requires zero buffers to execute safely, but requires n buffers to execute without blocking. Thus, the aforementioned buffer assignment may entail infinitely more buffers than required. 6.4 Implementation of the NBAP algorithm in Millipede We implemented the NBAP algorithm and added it to the Millipede parallel debugging system, which is a a multi level parallel debugger for message passing programs [19, 20, 21]. Millipede logs all messages between processes in a parallel system; these message histories are then used to analyze program execution and locate bugs. Determining the number of buffers required for block free execution is one such analysis. To demonstrate the NBAP algorithm we ran Millipede on a program that implements the pipe-and-roll parallel matrix multiplication algorithm [22]. The program has one control process and a number of worker processes arranged in a 2 dimensional mesh. We ran the NBAP algorithm on meshes of size 2 \times 2, 3 \times 3 and 4 \times 4. The communication graph for the smallest example, comprising four workers ordered in a 2 \times 2 mesh is depicted in Figure 14. The corresponding optimal buffer assignment is, listed in the second column of table 1. <table> <thead> <tr> <th>Proc.</th> <th>Max overlap</th> <th>Overlap for intervals I_j</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td>I_1</td> </tr> <tr> <td>0</td> <td>4</td> <td>0</td> </tr> <tr> <td>1</td> <td>3</td> <td>2</td> </tr> <tr> <td>2</td> <td>3</td> <td>3</td> </tr> <tr> <td>3</td> <td>3</td> <td>3</td> </tr> <tr> <td>4</td> <td>3</td> <td>2</td> </tr> </tbody> </table> Table 1: The result of NBAP algorithm on the 2 \times 2 example. In this example process 0 is the control process and processes 1 through 4 are the workers. The control process needs 4 buffers and the workers each need 3 to execute without blocking. The results obtained when executing the NBAP algorithm on a $3 \times 3$ worker system is 9 buffers for the control process and between 4 and 5 buffers for the worker processes. For the $4 \times 4$ system the numbers are 16 for the control process and between 5 and 7 buffers for the workers. 7 Conclusion As more and more functionality of message passing systems is off-loaded to the network interface card, limited buffer space becomes an increasingly important issue. Hence, the problem of determining $k$-safety plays an increasingly important role. Unfortunately this problem is intractable. We have shown that in the receive buffer model, determining the number of buffers needed to assure safe execution of a program is NP-hard, and that even verifying whether a number of assigned buffers is sufficient is coNP-complete. On the positive side, if we require that no send blocks, we provide a polynomial time algorithm for computing the minimal number of buffers. By allocating this number of buffers, safe execution is guaranteed! There are several strategies that a programmer can use to reduce the likelihood of deadlock when only a few buffers are available. To decrease the risk of deadlock the programmer can introduce epochs that are separated by barrier synchronizations. If each epoch only needs a small number of buffers, the risk of deadlock due to buffer insufficiency is reduced. For systems with only send buffers we conjecture that the Buffer Sufficiency Problem can be solved in polynomial time because the order of the sends in each process is fixed. This would imply that the buffer allocation problem for systems with only send buffers is \textbf{NP}-complete. For systems with both send and receive buffers we conjecture that the nonblocking buffer allocation problem is \textbf{NP}-hard. Unlike in the other two models, a buffer can be assigned either on the send side or on the receive side, dramatically increasing the size of the search space. The results (conjectures) are summarized below. <table> <thead> <tr> <th>Problem</th> <th>Receive Buffers</th> <th>Send Buffers</th> <th>Send/Receive Buffers</th> </tr> </thead> <tbody> <tr> <td>BAP</td> <td>\textbf{NP}-hard</td> <td>\textbf{NP}-hard</td> <td>\textbf{NP}-hard</td> </tr> <tr> <td>BSP</td> <td>co\textbf{NP}-complete</td> <td>(P)</td> <td>co\textbf{NP}-complete</td> </tr> <tr> <td>NBAP</td> <td>P</td> <td>P</td> <td>(\textbf{NP}-hard)</td> </tr> </tbody> </table> References
{"Source-Url": "http://www.egr.unlv.edu/~matt/publications/pdf/CPA-2002-A4.pdf", "len_cl100k_base": 11754, "olmocr-version": "0.1.53", "pdf-total-pages": 19, "total-fallback-pages": 0, "total-input-tokens": 58105, "total-output-tokens": 13948, "length": "2e13", "weborganizer": {"__label__adult": 0.00031757354736328125, "__label__art_design": 0.00035953521728515625, "__label__crime_law": 0.0003924369812011719, "__label__education_jobs": 0.0011386871337890625, "__label__entertainment": 0.00011157989501953124, "__label__fashion_beauty": 0.00015914440155029297, "__label__finance_business": 0.0003485679626464844, "__label__food_dining": 0.0004274845123291016, "__label__games": 0.0008897781372070312, "__label__hardware": 0.0027179718017578125, "__label__health": 0.0006861686706542969, "__label__history": 0.0004117488861083984, "__label__home_hobbies": 0.0001556873321533203, "__label__industrial": 0.0006990432739257812, "__label__literature": 0.0002951622009277344, "__label__politics": 0.00030493736267089844, "__label__religion": 0.0005016326904296875, "__label__science_tech": 0.2188720703125, "__label__social_life": 9.065866470336914e-05, "__label__software": 0.01477813720703125, "__label__software_dev": 0.7548828125, "__label__sports_fitness": 0.00037550926208496094, "__label__transportation": 0.0009055137634277344, "__label__travel": 0.0002522468566894531}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 52466, 0.0209]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 52466, 0.48227]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 52466, 0.89464]], "google_gemma-3-12b-it_contains_pii": [[0, 2646, false], [2646, 6475, null], [6475, 9593, null], [9593, 13656, null], [13656, 15969, null], [15969, 18335, null], [18335, 22139, null], [22139, 25258, null], [25258, 27869, null], [27869, 30862, null], [30862, 31428, null], [31428, 33145, null], [33145, 37046, null], [37046, 39666, null], [39666, 43206, null], [43206, 46237, null], [46237, 47830, null], [47830, 50501, null], [50501, 52466, null]], "google_gemma-3-12b-it_is_public_document": [[0, 2646, true], [2646, 6475, null], [6475, 9593, null], [9593, 13656, null], [13656, 15969, null], [15969, 18335, null], [18335, 22139, null], [22139, 25258, null], [25258, 27869, null], [27869, 30862, null], [30862, 31428, null], [31428, 33145, null], [33145, 37046, null], [37046, 39666, null], [39666, 43206, null], [43206, 46237, null], [46237, 47830, null], [47830, 50501, null], [50501, 52466, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 52466, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 52466, null]], "pdf_page_numbers": [[0, 2646, 1], [2646, 6475, 2], [6475, 9593, 3], [9593, 13656, 4], [13656, 15969, 5], [15969, 18335, 6], [18335, 22139, 7], [22139, 25258, 8], [25258, 27869, 9], [27869, 30862, 10], [30862, 31428, 11], [31428, 33145, 12], [33145, 37046, 13], [37046, 39666, 14], [39666, 43206, 15], [43206, 46237, 16], [46237, 47830, 17], [47830, 50501, 18], [50501, 52466, 19]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 52466, 0.0619]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
1748dc51404897bc7195f9044b8d1b834c9559c6
Automated generation of formal safety conditions from railway interlocking tables Haxthausen, Anne Elisabeth Published in: International Journal on Software Tools for Technology Transfer Link to article, DOI: 10.1007/s10009-013-0295-9 Publication date: 2014 Document Version Peer reviewed version Citation (APA): General rights Copyright and moral rights for the publications made accessible in the public portal are retained by the authors and/or other copyright owners and it is a condition of accessing publications that users recognise and abide by the legal requirements associated with these rights. - Users may download and print one copy of any publication from the public portal for the purpose of private study or research. - You may not further distribute the material or use it for any profit-making activity or commercial gain - You may freely distribute the URL identifying the publication in the public portal If you believe that this document breaches copyright please contact us providing details, and we will remove access to the work immediately and investigate your claim. Automated Generation of Formal Safety Conditions from Railway Interlocking Tables Anne E. Haxthausen DTU Compute, Technical University of Denmark, DK-2800 Lyngby, Denmark e-mail: aeha@dtu.dk 1.2 Solution Our solution has been to develop a set of tools [13] supporting automated formal verification of relay interlocking systems. We decided that the verification method should be formal as formal verification has been recognised as one of the best ways of avoiding errors and is for that reason strongly recommended by the CENELEC standard EN50128 [10] for software for railway control and protection systems. Furthermore we decided that the method should be automated as much as possible to reduce the time consumption. We chose the model checking approach [7] to formal verification as this allows for full automation. However, the model checking approach requires as input a formal model of the system behaviour and a formal specification of the required properties, and it is not a trivial task to create this input. To overcome this problem, we decided also to create tools for generating verifiable formal models and for generating formal requirements, respectively. The tools are centred around a domain-specific language (DSL) for digitised representations of track layout diagrams, interlocking tables, and circuit diagrams used for documenting a relay interlocking system. We chose to centre the tools around a domain-specific language rather than a general purpose modelling language, as it is easier for railway engineers to use a language that facilitates concepts already known and used in the railway domain. The tools comprise: - data validators for checking that the documentation (in DSL) follows certain general wellformedness rules, - generators that from a DSL description produce input to the SAL model checker[1]: - a formal, behavioural model (state transition system) of the described interlocking system and its environment and - required properties expressed as formulae in the temporal logic LTL [17]. Fig. 1 shows an overview of the generator tools. As it can be seen the model is generated from the circuit diagrams and... Fig. 1. Overview of generator tools. The tool described in this paper is shown by a solid arrow. the track layout diagram. Additional generators can be used to derive required properties from the circuit diagrams, the track layout diagram, and the interlocking table, respectively. The generated properties include the following: 1. **High-level safety conditions** expressing that there are no derailments and no collisions. These are generated from the track layout. 2. **Low-level safety conditions** (also called signalling conditions) expressing that general signalling rules of Railnet Denmark are obeyed. These are generated from the interlocking table. 3. **Circuit confidence conditions** expressing that the circuits are well-designed in a general sense (e.g. not giving rise to race conditions). These are generated from the circuit diagrams. 4. **Model consistency conditions** expressing consistency between related state variables of the model (used for model validation). These are generated from the track layout. Prototypes of the generator tools have been developed using the RAISE formal method [21, 22] due to previous good experience in using that method. Details on these tools and their development can be found in [2, 5, 15]. The whole collection of tools can be used to verify an interlocking system in the following number of steps: - Write a DSL description of the interlocking system. - Validate the description using the data validators. - Apply the generators to generate input to a model checker. - Apply the model checker to that input to investigate whether the model satisfies the required properties. 1.3 Focus of this Paper and Relation to Past Papers In a series of papers and technical reports our approach and tools have been described: - The article [14] *Modelling and Verification of Relay Interlocking Systems* has main focus on describing how a behavioural model of a relay interlocking system can be extracted from the circuit diagrams describing the system. - The article [15] *Formal Development of a Tool for Automated Modelling and Verification of Relay Interlocking Systems* explains how the model generator tool (making the extraction described in [14]) was formally developed using the RAISE formal method. - The development of a domain model for circuit diagrams, the interlocking system model generator and the circuit confidence conditions generator was done in a sub-project described very detailed in the technical project report [5]. This report also gives a first suggestion for how the environment can be modelled and which other conditions to consider. - Another sub-project, described in the technical report [2], continued the first sub-project by developing a domain model for railway networks and interlocking tables, and generators for extracting behavioural environment models, and three property generators for extracting high-level safety conditions, low-level safety conditions, and model consistency conditions, respectively. The current paper describes how one of the property generators takes interlocking tables as input and generates low-level safety conditions expressing that the signalling rules of Railnet Denmark are obeyed. This generator utilises the fact that interlocking tables serve as design specifications and contain data that can be used to instantiate generic signalling rules to concrete instances that can serve as safety requirements. More details on this tool and its development can be found in the technical report [2], except for a description of the conditions of Principle 7 in Section 6.5 as these were not yet included in the tool when the report was written. 1.4 Related Work The railway domain has been identified as a grand challenge for computer science, and the modelling, development and verification of interlocking systems has been investigated by many researchers. Different types of interlocking systems (for instance relay based versus computer based, functional versus geographical, etcetera) have been modelled using different modelling formalisms and verified using different verification techniques (e.g. theorem proving and model checking). An overview of results and trends in 2003 can be found in [4], and more recent results can be found in proceedings like [20] and book chapters like [11, 24]. Several other research groups [3, 25, 18, 12, 16, 6, 19] have also investigated interlocking systems having interlocking tables as design specifications. One of their goals is to verify interlocking tables. Their approach for verification is to translate the tables into execution/design models for interlocking systems (typically by instantiating generic models with data from the tables) and verify by model checking that these models satisfy high-level safety requirements such as no collisions and no derailments. Hence, our goal of model checking is different from that of the above mentioned research groups: their goal is to verify the interlocking tables, while our goal is to verify circuit diagrams. Consequently, a main difference between their and our verification approach is that their interlocking models are derived from the interlocking tables (i.e. from the design specification) while our models are derived from the relay circuit diagrams for the implementation. Instead of using interlocking tables for generating interlocking models, we use them for generating requirements (LTL formulas) in terms of signalling. Like the others, we also check for no collisions and no derailments. Eriksson [9] has also formally verified relay based interlocking systems by deriving a model from the relay circuits, but he used theorem proving and not model checking for the verification. 1.5 Paper Overview First, in Section 2, an informal introduction to the domain of the considered interlocking systems is given. Then, in Section 3 the notions of Kripke structures (used as behavioural models) and LTL formulas (used to express safety conditions) are introduced for the convenience of readers who are not familiar with these notions. In Section 4 the state space of models and conditions is introduced, in Section 5 it is shortly explained how the models are created, and in Section 6 it is explained how the considered conditions generator extracts safety conditions from relay interlocking tables. Section 7 reports on how the tool has been applied in the verification of the interlocking system for Stenstrup station in Denmark, and finally, in Section 8 some conclusions are drawn. 2 Train Route Based Interlocking Systems In this paper we consider a class of interlocking systems (DSB type 1954) used for many Danish stations. These systems are based on a concept of train routes and implemented by relay based electrical circuits. In this section a short introduction to these systems and their documentation is given. 2.1 The Physical Domain of a Station The physical domain under control consists of the railway tracks, points and signals. The tracks are divided into sections, each having a track circuit for detecting whether or not it is occupied by a train. The points can be switched between two positions: plus (i.e. straight) and minus (i.e. branching), and the signals can give proceed and stop indications by lights in coloured lamps. Fig. 2 shows a (simplified) track layout diagram for a typical station (Stenstrup station in Denmark). The track layout diagram outlines the geographical arrangement of the tracks and track-side equipment such as track circuits, points, and signals. From the diagram it can be seen that Stenstrup has six track circuits (named A12, 01, 02, 03, 04, and B12), two points (named 01 and 02), and six signals (named A, B, E, F, G, and H). 2.2 Train Route Based Interlocking The task of an interlocking system is to control points and signals such that train collisions and derailments are avoided. The interlocking systems we are considering use a train route based approach to achieve that. The basic ideas of this approach are: − Trains should drive on predefined routes through the network. − Each route is covered by an entry signal that indicates whether it is allowed for a train to enter the route or not. Trains are assumed to respect the signals. − Two trains must never be allowed to drive on conflicting (e.g. overlapping) routes at the same time. (To prevent collisions.) − Before a train is allowed to enter a route, the points in the route must be locked in positions making the route connected (i.e. it is physically possible to go from one end of the route to the other end without derailing), and the route must be empty (i.e. there are no trains on the route). (To prevent derailments and collisions, respectively.) − The points of a route must not be switched while a train is driving on the route. (To prevent derailments.) 2.3 Relay Circuit Implementations and Diagrams The interlocking systems we are considering are implemented by electrical relay circuits. The circuits are made up of components such as power supplies (each having a positive and a negative pole), relays, contacts, lamps inside signals, and operator buttons, connected by wires. A relay is an electrical switch operated by an electromagnet to connect or disconnect a number of contacts in a circuit. When current flows through the relay, the magnet is drawn and some of the associated contacts are connected (these contacts are said to be upper contacts) while others (the lower contacts) are disconnected. When no current flows through the relay, the magnet is dropped and the associated upper and lower contacts will be disconnected and connected, respectively. When contacts are connected/disconnected this may imply that sub-circuits containing these contacts become live/dead. This again may imply that relays of these sub-circuits are drawn or dropped, and so on. An interlocking system can get input from the environment: buttons in the circuits can be pushed by an operator and some of the relays (called the external relays) change state (are drawn or dropped) when points change positions or trains enter or leave track sections. The external relays are hence controlled by the environment. All other relays are said to be internal and are controlled by the circuits. 2.3.1 Relay Circuit Diagrams The electrical circuits implementing a relay interlocking system are documented by relay circuit diagrams. For each internal relay one of the diagrams shows the sub-circuit that controls that relay. Fig. 3 shows an example of a (simplified) relay circuit diagram. This diagram shows the sub-circuit controlling a relay named $RR_1$. The circuit consists of a number of components connected by wires. The wires are depicted as black lines. At the top is the positive pole and at the bottom is the negative pole of the power supply. Relay $RR_1$ is shown using this signature: \[ \begin{array}{c} \text{RR1} \\ \end{array} \] The downwards arrow informs that in the initial state this relay is dropped. (If it had been drawn the arrow would have been upwards.) A number of contacts belonging to other relays occur in this circuit. E.g. a contact belonging to a relay named $A_1$ is shown using this signature: \[ \begin{array}{c} \text{A1} \\ \end{array} \] The downwards arrow informs that in the initial state relay $A_1$ is dropped. The horizontal bar breaks the wire – this indicates that the contact is disconnected in the initial state (and in all states where $A_1$ is dropped). If the bar had not been breaking the wire it would have indicated that the contact had been connected in the initial state, as it is the case for the contact of $A_2$ (which is connected in all states where relay $A_2$ is dropped). Also a button $B_1$ is shown in the diagram using this signature: \[ \begin{array}{c} \text{B1} \\ \end{array} \] In the initial state the button is not pushed. Current will flow through a relay if there is a path from the positive pole to the negative pole that goes through the relay and all contacts within this path are connected and all buttons are pushed. Therefore, from the diagram in Fig. 3 it can be deduced that for current to flow through relay $RR_1$, button $B_1$ must be pushed and relay $A_2$ must be dropped, or relay $A_1$ must be drawn and relay $A_2$ must be dropped. When that condition becomes fulfilled, relay $RR_1$ will be drawn, and when it is not anymore fulfilled, it will be dropped. 2.4 Interlocking Tables For each station an interlocking table specifies the train routes of the station and for each of these routes - the conditions for when the train route can be locked (reserved), - the conditions for when the entry signal of the route is set to show a proceed aspect, - the conditions for when the entry signal of the route is set back to show a stop aspect, and - the conditions for releasing the train route again. The interlocking table serves as a design specification of the interlocking system. Hence, it is used by the engineers who design the electrical circuits of the interlocking system, and it is used by the test team who tests that the implicit requirements of the table hold for the implemented interlocking system. The aim of the generator tool we describe in this paper is to derive explicit, formal requirements from an interlocking table such that they can be formally verified to hold for a formal model of the behaviour of the implemented interlocking system. The formal model is generated from the circuit diagrams and track layout diagram by other generators of our tool set. Table 1 shows a (simplified) interlocking table for Stenstrup station. The interlocking table has one row for each train route. For each route - the Route sub-columns contain basic information about the train route such as its identification number, - the Signals sub-columns state (1) which signals (the entry signal and any distant signal for this) should be set to a proceed aspect when the conditions for entering the route are met, and (2) which signals must be set to a stop aspect. Fig. 3. A simple circuit diagram. <table> <thead> <tr> <th>Id</th> <th>From</th> <th>To</th> <th>A</th> <th>B</th> <th>E</th> <th>F</th> <th>G</th> <th>H</th> <th>A12</th> <th>01</th> <th>02</th> <th>03</th> <th>B12</th> <th>01</th> <th>02</th> <th>Init</th> <th>Final</th> </tr> </thead> <tbody> <tr> <td>2</td> <td>A</td> <td>G</td> <td>g</td> <td>r</td> <td>r</td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td>↑</td> <td>↑</td> <td></td> <td>↑</td> <td>↑</td> <td>+</td> <td>+</td> </tr> <tr> <td>3</td> <td>A</td> <td>H</td> <td>g</td> <td>r</td> <td>r</td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td>↑</td> <td>↑</td> <td></td> <td>↑</td> <td>↑</td> <td>-</td> <td>-</td> </tr> <tr> <td>5</td> <td>B</td> <td>E</td> <td>g</td> <td>r</td> <td>r</td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td>↑</td> <td>↑</td> <td></td> <td>↑</td> <td>↑</td> <td>+</td> <td>+</td> </tr> <tr> <td>6</td> <td>B</td> <td>F</td> <td>g</td> <td>r</td> <td>r</td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td>↑</td> <td>↑</td> <td></td> <td>↑</td> <td>↑</td> <td>-</td> <td>-</td> </tr> <tr> <td>7</td> <td>E</td> <td>A</td> <td>g</td> <td>r</td> <td></td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td></td> <td></td> <td>+</td> <td></td> <td>E:01</td> <td></td> <td></td> </tr> <tr> <td>8</td> <td>F</td> <td>A</td> <td>g</td> <td>r</td> <td></td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td></td> <td></td> <td>-</td> <td></td> <td>F:01</td> <td></td> <td></td> </tr> <tr> <td>9</td> <td>G</td> <td>B</td> <td>g</td> <td>r</td> <td></td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td></td> <td></td> <td>+</td> <td>G:03</td> <td></td> <td></td> <td></td> </tr> <tr> <td>10</td> <td>H</td> <td>B</td> <td>g</td> <td>r</td> <td></td> <td></td> <td></td> <td></td> <td>↑</td> <td>↑</td> <td></td> <td></td> <td>-</td> <td>H:03</td> <td></td> <td></td> <td></td> </tr> </tbody> </table> Table 1. Interlocking table (divided in two parts) for Stenstrup station. (to provide flank or front protection) before the entry signal can be set to proceed (g means green light (indicating proceed) and r means red light (indicating stop)), - the **Points** sub-columns state required positions of points (+/- means straight/branching position) for the route to be connected (and possibly also flank protected), - the **Track sections** columns state with an ↑ which track sections must be unoccupied for the route and its safety distance to be empty, - the **Stop** column specifies that a certain signal (the entry signal of the route) should be switched to a stop aspect when a certain track section (the first section of the route) becomes occupied, - the **Route release** columns define conditions for when the train route can be released (to be explained in Section 6), and - the **Route conflicts** marks with the symbol ◦ which routes are conflicting. 2.4.1 Data Validation One of our data validator tools can be used to check that such an interlocking table contains suitable data with right to a given track layout diagram, e.g. that the track sections of a route constitute a connected path in the track layout, that the signal in the Stop column is an entry signal for that path and the section in the Stop column is the first section of the route. 3 Background on Models and Assertions According to our method, to verify an interlocking system, the generator tools should be applied to the documentation of the system (expressed in the domain-specific language) in order to derive (1) a behavioural model \( M \) of the system and its environment, and (2) formal safety conditions \( \phi \) that the system must fulfil. The verification problem is then to check that each condition \( \phi \) is satisfied by the model \( M \). This is written \( M \models \phi \). In order to use the SAL model checker [1] to perform this check, we have chosen the conditions \( \phi \) to be LTL formulas and the models \( M \) to be Kripke structures represented in the input language [8] of the SAL model checker. This section gives a short introduction to LTL and Kripke structures, and it defines the satisfaction relation \( \models \). More details on these topics can for instance be found in [7,17]. The section also shortly explains how the Kripke structures are represented in SAL. 3.1 LTL Formulas The generated conditions are LTL formulas built over a finite set of propositional state variables \( V \) that characterises the state of the system. The set of LTL formulas over \( V \) is the least set satisfying the following rules: - If \( v \in V \), then \( v \) is an LTL formula. - If \( \phi, \psi \) are LTL formulas, then \( \neg \phi, \phi \land \psi, \phi \lor \psi, \phi \Rightarrow \psi, X(\phi), G(\phi), F(\phi), U(\phi, \psi) \), and \( W(\phi, \psi) \) are LTL formulas. 3.2 State Transition System Models As models we use Kripke structures that describe how the state of a system can evolve over time. A Kripke structure over a finite set of propositional variables \( V \) is a four tuple \( (S, s_0, R, L) \), where - \( S \) is a finite set of states, - \( s_0 \in S \) is an initial state\(^3\), - \( R \subseteq S \times S \) is a total\(^4\), binary relation on the state space describing possible state changes, and - \( L: S \to 2^V \), where \( 2^V \) denotes the power set of \( V \), is a function that labels each state with variables that are true in that state. \(^2\) More general Kripke models allow non-propositional variables provided these have finite domains. However, for the models presented in this article, propositional variables are sufficient. \(^3\) In the models we are considering, there is only one possible initial state. More general Kripke structures allow for a set of initial states. \(^4\) \( R \) is total means that for all \( s \in S \) there is a state \( s' \in S \) such that \( (s, s') \in R \). 3.3 Satisfaction Relation between Models and LTL Formulas An (execution) path in a Kripke structure \( (S, s_0, R, L) \) is an infinite sequence \( p \) of states \( p(1), p(2), \ldots \) such that for each \( i \geq 1 \), \( p(i), p(i + 1) \in R \). In the following, we use the notation \( p^i \) for the suffix of \( p \) starting at \( p(i) \), i.e. \( p^i = p(i), p(i + 1), \ldots \). The satisfaction relation \( \models \) between paths \( p \) in a Kripke structure \( (S, s_0, R, L) \) and LTL formulas \( \phi \) over the same set of variables \( V \) is the least relation satisfying: - \( p \models v \), if \( v \in L(p(1)) \) - \( p \models \neg \phi \), if it is not the case that \( p \models \phi \) - \( p \models \phi \land \psi \), if \( p \models \phi \) and \( p \models \psi \) - \( p \models \phi \lor \psi \), if \( p \models \phi \) or \( p \models \psi \) - \( p \models \phi \Rightarrow \psi \), if \( p \models \psi \) whenever \( p \models \phi \) - \( p \models X(\phi) \), if \( p^2 \models \phi \) (from the next time step \( \phi \) must be true) - \( p \models G(\phi) \), if for all \( i \geq 1 \), \( p^i \models \phi \) (\( \phi \) must hold on the entire path) - \( p \models F(\phi) \), if there is some \( i \geq 1 \) such that \( p^i \models \phi \) (\( \phi \) eventually holds, i.e. holds somewhere on the path) - \( p \models U(\phi, \psi) \), if there exists \( i \geq 1 \) such that \( p^i \models \psi \) and for all \( 1 \leq k < i \), \( p^k \models \phi \) (\( \phi \) must remain true until \( \psi becomes true) - \( p \models W(\phi, \psi) \) iff \( p \models U(\phi, \psi) \lor G(\phi) \) (\( \phi \) must remain true forever or until \( \psi \) becomes true) The satisfaction relation \( \models \) between Kripke structures \( M = (S, s_0, R, L) \) and LTL formulas \( \phi \) over the same set of variables \( V \) is defined as follows: \( M \models \phi \), iff for all paths \( p \) starting in the initial state \( s_0 \) of \( M \) (i.e. for which \( p(1) = s_0 \)), \( p \models \phi \) holds. 3.4 SAL Representations of Kripke Structures This subsection shortly explains how Kripke models are rep- resented in SAL. A generated SAL specification consists of the following elements: - a declaration of a finite set \( V \) of propositional (Boolean) state variables, - an initialisation assigning initial values (true or false) to the variables in \( V \), - a set of transition rules of the form \( \text{cond} \rightarrow \text{update} \) where \( \text{cond} \) (called the enabling condition) is a propositional formula over the variables in \( V \) using the connectives \( \land, \lor, \Rightarrow \) and \( \neg \), and - \( \text{update} \) is a multiple assignment of Boolean values (true and false) to the primed versions \( v' \) of some of the variables \( v \) in \( V \). Intuitively, the rule states that for states in which the en- abling condition is true, the system can change state to a new state that is obtained from the current state by per- forming the assignments in the \( \text{update} \). Such a specification represents the following Kripke structure $(S, s_0, R, L)$ over $V$: - $S = V \rightarrow \{true, false\}$ is the finite set of states, where a state is a truth valuation of the variables in $V$, - $s_0 \in S$ is an initial state deduced from the initialisation, - $R \subseteq S \times S$ is a binary relation on the state space induced by the transition rules: $(s, s') \in R$ if there is a transition rule $cond \rightarrow update$ such that (i) the enabling condition $cond$ is true when evaluated in $s$, (ii) for each assignment $v' = e$ in $update, s'(v) = e$, and (iii) for all variables $v$ in $V$ not having an assignment in $update, s'(v) = s(v)$, - $L : S \rightarrow 2^V$ is defined by: $L(s) = \{v | v \in V \land s(v) = true\}$ for $s \in S$. 4 State Space For a given interlocking system, our tools can be used to generate a model and safety conditions for the system. The model and the safety conditions are defined over a common set of variables describing the state space. This section first describes informally the common state space and then it defines the set $V$ of variables capturing the possible states of the system. In sections 5 and 6, it is described how models and conditions, respectively, are generated by the generator tools. 4.1 State Space The relays and buttons in the circuits implementing an interlocking system change state over time as reaction to input from the environment as described in Section 2.3. In the relay circuits of an interlocking system there are relays monitoring the states of the track side equipment: - For each point $P$, there are two relays $plusP$ and $minusP$ that are drawn when and only when $P$ is in the plus and the minus position, respectively. - For each track section $t$, there is a relay $t$ that is drawn when and only when the track section is unoccupied. - For each signal $S$, there are two relays $RedS$ and $GreenS$ that are drawn when and only when there is a red light and a green light in $S$, respectively. The two first classes of relays are said to be external as they are controlled by the environment. All other relays, including the last class of relays, are controlled by the circuits and are said to be internal. The remaining internal relays store the internal state of the interlocking system. For instance, there are relays keeping track of which routes are locked. For some interlocking systems, there is one locking relay for each route, however, for systems of DSB type 1954, some routes share a relay. We will use the notation $l(x)$ to denote the locking relay associated with a route $x$. A locking relay $r$ is dropped, when and only when one of the train routes $x$ associated with $r$ is locked. Which of the routes is locked is determined by the point settings: Route $x$ is locked, when $l(x)$ is dropped and the points settings are as required for route $x$ according to the interlocking table.\(^6\) As an example, for Stenstrup station there are four locking relays, $ia$ (for routes 2 and 3), $ib$ (for routes 5 and 6), $ua$ (for routes 7 and 8), and $ub$ (for routes 9 and 10). The safety requirements that will be formalised in Section 6 can be expressed in terms of the states of the relays mentioned above. 4.2 State Variables and Initial States The set $V$ of variables, over which the models and the conditions are defined, includes: - A Boolean variable $r$ for each relay $r$ in the circuit diagrams. When a relay variable $r$ is true/false, it models that the associated relay is drawn/dropped. - A Boolean variable $b$ for each button in the circuit diagrams. When a button variable $b$ is true/false, it models that the associated button is pushed/released. - A Boolean auxiliary variable $idle$. When it is true, it models that the interlocking system is in an idle state waiting for new input. The initial state of buttons is false, the initial state of track section relay variables is true (modelling that the track sections are initially unoccupied), the initial states of point relay variables $plusP$ and $minusP$ are true and false, respectively, and the initial states of internal relays are derived from the circuit diagrams. 5 Behavioural Models Our framework provides tool components that from the circuit diagrams and the track layout diagram of an interlocking system can be used to create a behavioural model $M$ of the interlocking system and its interface to the environment. In Section 4 we described the state variables of $M$ and stated the initial values of these variables. In this section we will shortly outline which transition rules are generated. The transition rules describe how the internal relays, the external relays, and the buttons can change state over time. 5.1 State Transition Rules for Internal Relays and Buttons The state transition rules for internal relays and buttons are generated from the circuit diagrams. For each internal relay $r$ in the circuit diagrams two rules are generated: \[ \neg r \land isConducting_r \rightarrow r' = true \] \(^5\) Note that we only consider SAL specifications for which the relation defined in this way is total (as required for Kripke structures). We use the SAL deadlock checker to check that. \(^6\) Note: two routes can only share a locking relay when at least one point is required to be set in different positions for the two routes. for drawing $r$ and \[ r \land \neg \text{isConducting}_r \rightarrow r' = \text{false} \] for dropping $r$. Here $\text{isConducting}_r$ is a condition for current to flow through the relay. It expresses that there is a path from the positive pole to the negative pole that goes through the relay and all contacts within this path are connected and all buttons are pushed. As an example, from the diagram in Fig. 3 in Section 2.3.1 it is deduced that for current to flow through relay $RR1$, button $B1$ must be pushed and relay $A2$ must be dropped, or relay $A1$ must be drawn and relay $A2$ must be dropped. Therefore, the following two rules for relay $RR1$ are generated: \[ \neg RR1 \land ((A1 \land \neg A2) \lor (B1 \land \neg A2)) \rightarrow RR1' = \text{true} \] \[ RR1 \land \neg ((A1 \land \neg A2) \lor (B1 \land \neg A2)) \rightarrow RR1' = \text{false} \] Similarly, for each button in the relay circuit diagrams a rule for pressing it is generated, and a rule for releasing buttons is also generated. More details on these transition rules can be found in [5, 15]. 5.2 State Transition Rules for External Relays The state transition rules for external relays are generated from the track layout diagram. A point $P$ can be switched between three positions: the plus position, the minus position, and the intermediate position between the plus position and the minus position. For each point $P$ in the track layout diagram, four transition rules are generated describing how the relays plus$P$ and minus$P$ associated with $P$, change state when the point is switched between its three possible positions. For each track section $t$ in the track layout diagram, transition rules for drawing and dropping the corresponding track relay are generated. The rules reflect the possible train movements and therefore depend on the track layout. More details on these transition rules can be found in [2]. 6 Safety Requirements This section first describes which formal requirements the generator tool derives from an interlocking table (that has been checked by the data validator tool) and then it informs how the tool was formally specified. The formal requirements are formulas in LTL, expressed as conditions on the relay variables keeping the state of points, track sections, signals, and route lockings. They express safety conditions at the design level (i.e. concrete instances of the general signalling principles) that an interlocking system must satisfy. In each of the subsections 6.1–6.6 below, first a general signalling principle is stated informally, then it is explained how formal, concrete instances of this can be generated by instantiating a formal condition pattern with data from a given interlocking table, and finally an example of this is given for the interlocking table for Stenstrup in Table 1. In the formal condition patterns the following notation will be used for a route $x$: - $L_x$: the locking relay $l(x)$ of $x$. - $\text{RouteLocked}_x$: the condition $\neg L_x \land \text{PointsSet}_x$ expressing that route $x$ is locked. - $\text{PointsSet}_x$: a condition expressing that the points of $x$ are set as required according to the “Points” fields for $x$ in the interlocking table. - $\text{TracksFree}_x$: a condition expressing that the track sections of $x$ are unoccupied as required according to the “Track sections” fields for $x$ in the interlocking table. - $\text{SignalsSet}_x$: a condition expressing that the signals of $x$ are set to a stop aspect as required according to the “Signals” fields for $x$ in the interlocking table. - $\text{StopSection}_x$: the track section (relay) specified in the “Stop field” for $x$ in the interlocking table. - $\text{Init}_x$: a condition expressing that the second last track section of $x$ is occupied and the last track section of $x$ is unoccupied as specified in the “Init” field for $x$ in the “Route release” columns in the interlocking table. - $\text{End}_x$: a condition expressing that the second last track section of $x$ is unoccupied and the last track section of $x$ is occupied as specified in the “Final” field for $x$ in the “Route release” columns in the interlocking table. 6.1 No Locking of Conflicting Routes **Principle 1.** When a train route $x$ is locked, none of its conflicting routes $y$ must be locked. For each route $x$, this is expressed by a condition of the following form: \[ G(\text{RouteLocked}_x \Rightarrow \bigwedge_{y \in \text{ConflictingRoutes}(x)} \neg \text{RouteLocked}_y) \quad (1) \] where ConflictingRoutes$(x)$ is the set of routes that are in conflict with $x$ according to the interlocking table. **Example 1.** Applying this principle to train route 2 for Stenstrup, the generated condition will be in the following form as the route is in conflict with train routes 3, 5, 6, 7, 8 and 10 according to the interlocking table for Stenstrup: \[ G(\text{RouteLocked}_2 \Rightarrow \neg \text{RouteLocked}_3 \land \neg \text{RouteLocked}_5 \land \neg \text{RouteLocked}_6 \land \neg \text{RouteLocked}_7 \land \neg \text{RouteLocked}_8 \land \neg \text{RouteLocked}_{10}) \] Expanding each of the expressions RouteLocked$_y$ using the data in the interlocking table, this gives For each signal light at the same time. A signal must never display a red light and green light. Principle 3. A signal must never display a red light and green light at the same time. For each signal S, this is expressed by a condition of the following form: \[ G(idle \land \neg GreenS \Rightarrow RedS) \] (4) Example 4. Applying this principle to signal A for Stenstrup, the following condition is generated: \[ G(idle \land \neg GreenA \Rightarrow RedA) \] 6.4 Proceed Signal Principle 5. When a signal S shows a proceed aspect, one of the routes x, starting from S, must be ready for use, i.e. (1) the route x must be locked, (2) all the track sections of the route must be unoccupied as stated in the interlocking table, and (3) all covering signals of the route must show a stop aspect as stated in the interlocking table. 6.2 Locking and Points Positions Principle 2. When a locking relay r is dropped, one of the routes x, which is controlled by r, must have the points of that route set as required for route x according to the interlocking table. (This implies that a route can’t be locked before its points are set.) For each locking relay r, this is expressed by a condition of the following form: \[ G(\neg r \Rightarrow \bigvee_{x \in Routes(r)} PointsSet_x) \] (2) where \( Routes(r) \) is the set of routes x controlled by r, i.e. for which \( l(x) = r \). Example 2. Applying this principle to locking relay ia for Stenstrup, the following condition is generated as routes 2 and 3 are the routes controlled by ia: \[ G(\neg ia \Rightarrow (plus01 \land plus02) \lor (minus01 \land minus02)) \] The condition expresses that when ia is dropped, points 01 and 02 are either both set in the plus position or both set in the minus position as required by the interlocking table for routes 2 and 3, respectively. 6.3 Signal Aspects Only certain combinations of lights are allowed aspects of the signals. Principle 3. A signal must never display a red light and green light at the same time. For each signal S, this is expressed by a condition of the following form: \[ G(idle \Rightarrow \neg(\text{Red}S \land \text{Green}S)) \] (3) Example 3. Applying this principle to signal A for Stenstrup, the following condition is generated: \[ G(idle \Rightarrow \neg(\text{Red}A \land \text{Green}A)) \] Principle 4. When the green light is turned off in a signal S, the red light must be turned on. 6.5 Stop Signal **Principle 6.** When track section, StopSection$_x$, specified in the "Stop" field for route $x$ in the interlocking table, is occupied in an idle state, the signal $S_x$ in the same field must show a stop aspect (i.e. the red light must be on). For each route $x$, this is expressed by a condition of the following form: $$G(idle \land \neg StopSection_x \Rightarrow RedS_x)$$ \hspace{1cm} (6) In the condition it is necessary to include idle on the left-hand side of the implication in order to give the system time to change the setting of the signal as a reaction on the occupation of StopSection$_x$. Note that condition (6) is a consequence of conditions (5) and (4) if it has been generated from a well-formed interlocking table as $\neg StopSection_x$ implies $\neg TracksFree_y$ for all routes $y$ starting from $S_x$ (due to the fact that for a well-formed interlocking table StopSection$_x$ is included in the track sections of any route starting from $S_x$), and this implies $\neg GreenS_x$ (due to (5)), which implies $RedS_x$ (due to (4)). **Example 6.** Applying this principle to route 2 for Stenstrup, the following condition is generated: $$G(idle \land \neg A12 \Rightarrow RedA)$$ It expresses that when track section A12 (the first section of the route) is occupied by a train (or another object), then the entry signal, A, must show a stop aspect (i.e. the red light must be on). **Principle 7.** When the setting of the entry signal $S$ of a locked route $x$ is changed to stop (i.e. the red light is turned on), it must keep this setting as long as the route is still locked. This principle prohibits that the signal is changed to proceed in the case where a train that has entered the route, reverses direction and leaves the route before the route has been released. For each signal $S$ and each route $x \in Routes(S)$, this principle is expressed by a condition of the following form: $$G(\neg L_x \land \neg RedS \land X(RedS) \Rightarrow X(W(RedS, L_x)))$$ \hspace{1cm} (7) where $L_x = l(x)$ is the locking relay of $x$, and $W$ is the LTL weak until operator and $X$ is the next state operator. **Example 7.** Applying this principle to signal A and route 2 (or route 3) for Stenstrup, the following condition is generated: $$G(\neg ia \land \neg aRed \land X(aRed) \Rightarrow X(W(aRed, ia)))$$ It expresses that if the red light in signal A is off (i.e. $\neg aRed$ is true) while route 2 (or route 3) is locked (i.e. $\neg ia$ is true) and if the red light is turned on in the next state (i.e. $X(aRed)$ is true), then the red light must be kept as long as the route is still locked, i.e. the red light can’t be turned off before a release (where $ia$ becomes true). Next subsection states the conditions for when a release can happen. 6.6 Train Route Release Before a locked train route can be released, the two last sections $t1$ and $t2$ of the route must have been in a state (called the release start state) where $t1$ is occupied and $t2$ is unoccupied, and then in a state (called the release end state) where $t1$ is unoccupied and $t2$ is occupied. This sequence of states is called the release sequence. This sequence will happen when a train passes the second last track section and ends on the last track section of the route. The “Route release” columns of the interlocking table state the release start and end states for each train route. **Principle 8.** When a train route has been locked, the route must not be released before the release sequence for the route has taken place. For each route $x$, this is expressed by a condition of the following form: $$G(L_x \land X(RouteLocked_x \land F(L_x)) \Rightarrow X(\neg L_x \land Init_x \land \neg L_x \land U(\neg L_x, \neg L_x \land End_x)))$$ where $L_x$ is the locking relay of $x$, $Init_x$ is a condition expressing the release start state for $x$, $End_x$ is a condition expressing the release end state for $x$, $U$ is the LTL until operator, $X$ is the next state operator and $F$ is the eventually operator. If condition $L_x$ is true, it implies that $RouteLocked_x$ is false, as $RouteLocked_x = \neg L_x \land PointsSet_x$. Therefore, the left-hand side of the implication is true if route $x$ is not locked in the current state, it becomes locked in next state and later it becomes released (unlocked) again. The right-hand side of the implication expresses the condition that from the next state (i.e. the state in which the route became locked according to the left-hand side condition), the route will not be released, i.e. $L_x$ will not become true, until after the release sequence. **Example 8.** Applying this principle to train route 2 for Stenstrup Station, the following condition is generated: The left-hand side of the implication says that route 2 is not locked (i.e. ia is true) in the current state, it becomes locked (i.e. ia ∧ plus01 ∧ plus02) in the next state and later on it becomes released (unlocked) again (i.e. F(ia)). The right-hand side says that in the next state the route will stay locked at least until the release start state (where track section 01 is occupied and track section 02 is unoccupied) and in the state after this release start state, the route will continue being locked until the release end state where track section 01 is again unoccupied and track section 02 has been occupied. 6.7 Development of the Tool A prototype of the generator tool was developed by creating an executable specification in the RAISE specification language RSL [21]. In this section the overall structure of the specification is outlined. The main components of the specification are: - a specification of a data type Table for representing interlocking tables, - a specification of a data type Assertion for representing conditions, i.e. LTL assertions (formulas), and - a function gen for generating conditions from interlocking tables. The generator function gen is specified to take a Table value as input and to return an Assertion — set value, i.e. a set of Assertion values (representations of LTL formulas). For each signalling principle i stated above, gen instantiates the formal condition pattern of principle i with data from the interlocking table obtaining a set seti of assertions, and then it returns the union of all these sets. More details about the tool and its development can be found in [2]. 7 Experiments We applied the developed signalling conditions generator to the interlocking table (shown in Table 1) for Stenstrup station in Denmark. In this way 52 conditions were generated. Table 2 shows for each signalling principle stated in Section 6, the number of conditions generated from the interlocking table. We also applied other conditions generators from our tool set to generate 152 other desired properties from the station documentation. Furthermore, we applied yet other generator tools from our tool set to generate a state transition system model for the behaviour of the implemented relay interlocking system (described by 18 circuit diagrams) and its environment (allowing operator input and an arbitrary number of trains driving according to the traffic rules). This state transition system model had 71 Boolean variables (i.e. $2^{71}$ states) and 141 transition rules. We then used the SAL symbolic model checker [1] to verify that the generated model satisfied the 204 generated conditions. All conditions turned out to be valid. The SAL symbolic model checker is a BDD-based model checker for finite state systems. Details on the elapsed execution time for checking the 52 signalling conditions (generated from the interlocking table) and the 152 other conditions can be found in Table 3. Each class of conditions were verified separately and without utilising intermediate results among queries. The elapsed time was measured with the LinuxMint12 time command on a Lenovo T420. According to the signalling engineers it would last about a month to validate the circuit diagrams for Stenstrup station by their traditional manual inspection, and they would only check a small part of our 204 conditions. So it is really much faster to use our tools. We also tried to introduce some design flaws in the relay circuits to demonstrate that these can be found by using our tools. E.g. we introduced flaws such that a signal could reach a state where both the red light and the green light were turned on at the same time. In this case the model checker detected that the signal aspect condition in formula (3) was broken for that signal. Furthermore, we made some validation of the model. For instance, we model checked that the behavioural model allows trains to move through the network. The safety conditions all take the form $G(a \Rightarrow b)$. If for such a condition, a is always false, the condition is trivially true. For a given condition and model, one can check that this is not the case by checking that $G(\neg a)$ is violated. If it turns out that a is always false, it can be an indication that there may an error in the model or that the condition a has been formulated wrongly. By making such checks, we actually found a flaw in an earlier formulation of the left-hand side condition of Principle 7. 8 Conclusions Summary. This paper has described a tool component of a tool set that supports formal verification of relay interlocking systems. Given the interlocking table of a relay interlocking system, the tool can automatically generate formal safety requirements for the implementation of the relay interlocking system. The requirements express that the signalling rules are followed. Other tool components of the tool set can be used to generate a formal model of an interlocking system and its environment. Having generated the requirements and Table 2. For each signalling principle stated in Section 6, the number of signalling conditions generated from the interlocking table for Stenstrup station. <table> <thead> <tr> <th>signalling principle</th> <th>number of generated conditions</th> </tr> </thead> <tbody> <tr> <td>1 (no locking of conflicting routes)</td> <td>8</td> </tr> <tr> <td>2 (points set correctly while locked)</td> <td>4</td> </tr> <tr> <td>3 (not read and green signal)</td> <td>6</td> </tr> <tr> <td>4 (red signal when not green)</td> <td>6</td> </tr> <tr> <td>5 (only green signal when allowed)</td> <td>6</td> </tr> <tr> <td>6 (red signal when required)</td> <td>8</td> </tr> <tr> <td>7 (keep red signal until release)</td> <td>6</td> </tr> <tr> <td>8 (only allowed train route release)</td> <td>8</td> </tr> <tr> <td>total</td> <td>52</td> </tr> </tbody> </table> Table 3. For each of the four classes of conditions introduced in Section 1: (1) the number of conditions generated from the documentation of Stenstrup station and (2) elapsed execution time in seconds for checking these conditions. <table> <thead> <tr> <th>kind of conditions</th> <th>number of generated conditions</th> <th>execution time</th> </tr> </thead> <tbody> <tr> <td>signalling</td> <td>52</td> <td>409</td> </tr> <tr> <td>no collisions, no derailments</td> <td>12</td> <td>20</td> </tr> <tr> <td>circuit confidence</td> <td>102</td> <td>5139</td> </tr> <tr> <td>model consistency</td> <td>38</td> <td>20</td> </tr> </tbody> </table> the model, a model checker can be used to verify that these requirements always hold for the formal model. To use such an automated, formal verification approach is a great improvement compared to manual inspections of interlocking tables, track layout diagrams and circuit diagrams: It is much faster and less error prone, it is much more complete with right to what is being checked, and the checking itself is exhaustive considering all possible scenarios. The approach has successfully been applied to the relay interlocking system for Stenstrup station. Although the signalling conditions generator tool has been developed for a certain type of interlocking systems (the relay based DSB type 1954), it is expected that it can easily be adapted to other DSB types of interlocking systems that are based on similar interlocking tables, as the safety conditions for these systems are basically the same. With respect to the input of the generator (i.e. the interlocking tables), there may be small variations in the concrete syntax, but at least for the Danish systems, the content is basically the same. For other systems there may, apart from variations in the concrete syntax of the tables, also be minor variations in the signalling principles and therefore in the actual content of the tables. For instance, if the signalling principle for releasing a train route does not require the same release sequence of track sections as in the Danish systems, the release conditions in the tables will be different and the same holds for the formal release conditions that should be generated. In such a case the generator tool should be changed accordingly. Future work. The current tool set has been used for a proof-of-concept. To be used in industry, further development needs to be done, e.g. a better user interface should be provided. We plan to apply the tools to larger stations to test to which extent the method is scalable without state space explosion problems. Experience by other research groups shows that the use of standard model checking techniques for verifying similar systems is only feasible for small railway stations. For instance, in [12] a systematic study of applicability bounds of the symbolic model-checker NuSMV and the explicit model checker SPIN showed that these popular model checkers could only verify small railway stations. So it is likely that the application of our method to larger stations would also lead to state space explosion. If this happens, more advanced verification techniques must be investigated. Our safety conditions are independent of the model checking technique so the conditions generator tool described in this paper can be used in connection with more advanced model checking techniques. Several domain-specific techniques to push the applicability bounds for model checking interlocking systems have been suggested. For instance, one could combine bounded model checking with inductive reasoning, as done in [16]. In [23] Winter pushes the applicability bounds of symbolic model checking (NuSMV) by optimising the ordering strategies for variables and transitions using domain knowledge about the track layout. In [19], it is suggested to reduce the state space using several abstraction techniques: reduction of the number of track sections and the number of trains, and compositional reasoning by decomposition of the railway network into several smaller networks. We also plan to make a similar tool set for the new ERTMS based signalling systems that are going to be implemented in Denmark over the next decade. Acknowledgements. I would like to thank Kirsten Mark Hansen for providing the initial idea for this project and for many valuable discussions when she was employed at Railnet Denmark. Special thanks go to my former students Morten Aanæs and Hoang Phuong Thai who developed the first version of the generator tool described in this paper in their master thesis project supervised by me. The functionality of the tool... was inspired by another master thesis made by my former students Marie Le Bliguet and Andreas A. Kjær. Finally, I would like to thank the reviewers for comments to a previous version of this paper. The work has been partially supported by the RobustRailS project granted by the Danish Council for Strategic Research. References
{"Source-Url": "http://orbit.dtu.dk/files/102239832/STTThaxthausen.pdf", "len_cl100k_base": 13245, "olmocr-version": "0.1.53", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 52590, "total-output-tokens": 15473, "length": "2e13", "weborganizer": {"__label__adult": 0.0013284683227539062, "__label__art_design": 0.0011138916015625, "__label__crime_law": 0.001155853271484375, "__label__education_jobs": 0.005878448486328125, "__label__entertainment": 0.00036263465881347656, "__label__fashion_beauty": 0.00044608116149902344, "__label__finance_business": 0.0012102127075195312, "__label__food_dining": 0.0009870529174804688, "__label__games": 0.004367828369140625, "__label__hardware": 0.00995635986328125, "__label__health": 0.0010824203491210938, "__label__history": 0.0013399124145507812, "__label__home_hobbies": 0.0007205009460449219, "__label__industrial": 0.007518768310546875, "__label__literature": 0.0012903213500976562, "__label__politics": 0.0007872581481933594, "__label__religion": 0.001171112060546875, "__label__science_tech": 0.357177734375, "__label__social_life": 0.00035834312438964844, "__label__software": 0.025970458984375, "__label__software_dev": 0.462158203125, "__label__sports_fitness": 0.0014019012451171875, "__label__transportation": 0.11151123046875, "__label__travel": 0.0007295608520507812}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 59645, 0.02224]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 59645, 0.52805]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 59645, 0.89264]], "google_gemma-3-12b-it_contains_pii": [[0, 1323, false], [1323, 3487, null], [3487, 7418, null], [7418, 13096, null], [13096, 17542, null], [17542, 19681, null], [19681, 25590, null], [25590, 30976, null], [30976, 36231, null], [36231, 38661, null], [38661, 43425, null], [43425, 48468, null], [48468, 53738, null], [53738, 59645, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1323, true], [1323, 3487, null], [3487, 7418, null], [7418, 13096, null], [13096, 17542, null], [17542, 19681, null], [19681, 25590, null], [25590, 30976, null], [30976, 36231, null], [36231, 38661, null], [38661, 43425, null], [43425, 48468, null], [48468, 53738, null], [53738, 59645, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 59645, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 59645, null]], "pdf_page_numbers": [[0, 1323, 1], [1323, 3487, 2], [3487, 7418, 3], [7418, 13096, 4], [13096, 17542, 5], [17542, 19681, 6], [19681, 25590, 7], [25590, 30976, 8], [30976, 36231, 9], [36231, 38661, 10], [38661, 43425, 11], [43425, 48468, 12], [48468, 53738, 13], [53738, 59645, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 59645, 0.06538]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
4692ce8120bc3171357d57e2962838bbc6c0e78f
<table> <thead> <tr> <th>Title</th> <th>Taking advantage of service selection: A study on the testing of location-based web services through test case prioritization</th> </tr> </thead> <tbody> <tr> <td>Author(s)</td> <td>Zhai, K; Jiang, B; Chan, WK; Tse, TH</td> </tr> <tr> <td>Citation</td> <td>The IEEE International Conference on Web Services (ICWS 2010), Miami, FL., 5-10 July 2010. In Proceedings of ICWS 2010, p. 211-218</td> </tr> <tr> <td>Issued Date</td> <td>2010</td> </tr> <tr> <td>URL</td> <td><a href="http://hdl.handle.net/10722/125683">http://hdl.handle.net/10722/125683</a></td> </tr> <tr> <td>Rights</td> <td>IEEE International Conference on Web Services (ICWS). Copyright © IEEE Computer Society.; This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.; ©2010 IEEE. Personal use of this material is permitted. However, permission to reprint/republish this material for advertising or promotional purposes or for creating new collective works for resale or redistribution to servers or lists, or to reuse any copyrighted component of this work in other works must be obtained from the IEEE.</td> </tr> </tbody> </table> Taking Advantage of Service Selection: A Study on the Testing of Location-Based Web Services through Test Case Prioritization Ke Zhai, Bo Jiang The University of Hong Kong Pokfulam, Hong Kong {kzhai, bjiang}@cs.hku.hk W. K. Chan† City University of Hong Kong Tat Chee Avenue, Hong Kong wkchan@cs.cityu.edu.hk T. H. Tse The University of Hong Kong Pokfulam, Hong Kong thtse@cs.hku.hk Abstract—Dynamic service compositions pose new verification and validation challenges such as uncertainty in service membership. Moreover, applying an entire test suite to loosely coupled services one after another in the same composition can be too rigid and restrictive. In this paper, we investigate the impact of service selection on service-centric testing techniques. Specifically, we propose to incorporate service selection in executing a test suite and develop a suite of metrics and test case prioritization techniques for the testing of location-aware services. A case study shows that a test case prioritization technique that incorporates service selection can outperform their traditional counterpart — the impact of service selection is noticeable on software engineering techniques in general and on test case prioritization techniques in particular. Furthermore, we find that points-of-interest-aware techniques can be significantly more effective than input-guided techniques in terms of the number of invocations required to expose the first failure of a service composition. Keywords—test case prioritization, location-based web service, service-centric testing, service selection I. INTRODUCTION Location-based service (LBS) is indispensable in our digital life [20]. According to a keynote speech presented at ICWS 2008 [7], many interesting mobile web-based services can be developed on top of LBS [7]. In the social network application Loopt [8], for instance, we receive notifications whenever our friends are nearby, where each “friend” found is known as a point of interest (POI) [9][18], a specific location that users may find useful or interesting. A faulty location-based service composition may annoy us if it erroneously notifies us the presence of a stranger in another city, or fails to notify us even if a friend is just in front of us. In this paper, we use the terms “composite service” and “service composition” interchangeably. After fixing a fault or modifying a service composition, it is necessary to conduct regression testing (i.e., retesting software following the modification) to assure that such fixing or modifications do not unintentionally change the service composition. Test case prioritization permutes a set of test cases (known as a test suite) with the aim of maximizing a testing goal [17][24]. One popular goal used by researchers is the fault detection rate, which indicates how early the execution of a permuted test suite can expose regression faults [5][6][17][23]. Prioritization does not discard any test case, and hence does not compromise the fault detection capability of the test suite as a whole. Existing work [5][6][11][23] has studied code-coverage-based techniques for test case prioritization. Such techniques use the heuristics that faster code coverage of the application under test may lead to a faster fault detection rate. However, coverage information is not available until the corresponding test cases have been executed on the application. These techniques may approximate the required information using the coverage information achieved by the same test case on a preceding version of the application. However, such an approximation may be ineffective when the amount of code modification is large, which is the case for dynamic service composition. Furthermore, these techniques require instrumentation to collect the code coverage information. Nonetheless, such instrumentation often incurs significant execution overhead, which may prevent an LBS service from responding in a timely manner. When performing test case prioritization on cooperative services, many researchers assume that a service composition has already been formed. In the other words, cooperative services form a service composition through static binding rather than dynamic service selection. To perform regression testing on such statically bound composite services, existing techniques [13][14] usually execute all test cases on every possible service composition, which can be costly when the pool of candidate services is large. We observe at least two technical challenges for a technique to support the testing of dynamic service compositions: First, the exact service composition cannot be known until a dynamic service selection has been made. There is no guarantee that members in a previous service composition that executed a test case can be discovered and selected to form a service composition again for regression testing of the same test case. Second, the number of possible service compositions can be huge. Testing all combinations maximizes the fault detection capability but makes testing expensive. We argue that the testing of dynamic service compositions requires a low-cost and yet highly effective testing strategy. To address the first challenge, we bring in service selection into a test case prioritization technique. To address the second challenge, we optimize the technique by not selecting/binding a web service that has already been found to be faulty. The main contribution of the paper is threefold: (i) We propose a novel approach to integrating service selection and test case prioritization and formulate a family of black-box test case prioritization techniques. (ii) We empirically study the impact of service selection on the effectiveness of software engineering techniques in general and test case prioritization techniques in particular. (iii) We propose a suite of location-based metrics and evaluation metrics to measure the proximity/diversity between points of interests and locations in the test cases. We organize the rest of the paper as follows: We first highlight a case study in Section II that has motivated us to propose our prioritization techniques. Then, we discuss our service-selection-aware test case prioritization techniques in Section III. We present our case study on a location-based web service in Section IV. Finally, we review related work in Section V, and conclude the paper in Section VI. II. MOTIVATING STUDY We motivate our work via an adapted location-based service composition City Guide as shown in Figure 1. It consists of a set of main web services (denoted by \( WS_i \), \( i = 1, 2, ..., n \)), each binding to a map service and a Case-Based Reasoning (CBR) service, which in turns binds to a data service. The main web services are registered in a UDDI registry. Each client of City Guide is written in Android running on a smart phone. Our example adapts the application to let the service-selection service receive a blacklist of service URLs. The service filters out these blacklisted services and selects a remaining \( WS_i \) using its original approach. For instance, to select a web service, it applies GPS data to every discovered service and selects the one that produces the largest number of POIs. In this scenario, services of each type may have multiple implementations. Moreover, each use of the City Guide application triggers a dynamic selection of concrete services of any kind followed by a dynamic formation of a service composition. However, a software service can be faulty. Our verification objective is to assure dynamically any service composition by using test cases that may dynamically be dispatched to verify the service composition. One may invoke all possible service compositions for all possible test cases, but such a simple approach incurs significant overheads. A. Service Selection Table I shows a test suite containing six ordered test cases \( \langle t_1, t_2, t_3, t_4, t_5, t_6 \rangle \) and their fault detection capability on four faulty web services \( \{ WS_1, WS_2, WS_3, WS_4 \} \) in City Guide. A cell marked as “failed” means that the execution of the service (row) over the test case (column) produces a failure; otherwise, the test case is deemed as successful. We are going to use the example to illustrate a problem of existing techniques in testing dynamic service compositions. ![Figure 1. Architecture of City Guide.](image) Traditional Regression Testing Techniques [17] can be ineffective in revealing faults in web services. For instance, test case prioritization techniques [24] require each test case to be executed on every web service. To do so, a technique may, in the worst case, construct \( 24 (= 6 \times 4) \) service compositions. However, as we have mentioned above, there is no guarantee that a given service is re-discoverable and bound to form a required service composition so as to apply the same test case again. Indeed, in City Guide, service discovery and selection are performed by the application. It is hard to apply traditional testing techniques to assure City Guide. Even if service compositions could be constructed, traditional techniques can still be ineffective. Let us consider a scenario: Initially, all four web services run \( t_1 \) in turn and \( WS_2 \) is detected to be faulty. Since \( WS_2 \) has been shown to be faulty, it is undesirable to select it for follow-up service compositions. Subsequently, if \( t_2 \) is run, only 3 services (\( WS_1, WS_3, \) and \( WS_4 \)) need to be invoked in turn. Following the same scheme, one may easily count that the numbers of service invocations for \( t_3, t_4, t_5, \) and \( t_6 \) are 2, 2, 1, and 0, respectively, and the total number of service invocations is therefore 12. We observe that for all 12 invocations in the above scenario, only four (33%) reveal any fault. Hence, two third of the service invocations are wasted. **New Idea.** We illustrate our new idea with a testing strategy that potentially reduces the number of service invocations. Let us revisit the test case execution scenario in the last paragraph. For each test case, we invoke only one service, chosen by the selection service that maintains a blacklist of services shown to be faulty. The list is initially empty. A technique passes the blacklist to the service-selection service, which discovers all four web services and picks $W_{S_1}$ to be invoked because it is not blacklisted. Unfortunately, the first test case $t_1$ does not reveal any fault in $W_{S_1}$. The technique then applies the second test case. It passes the latest blacklist to the service-selection service, which also discovers all four web services (i.e., all services that have not been shown to be faulty) and resolves to choose $W_{S_2}$ for $t_2$. This invocation for test case $t_2$ reveals that $W_{S_2}$ is faulty. Hence, the technique adds $W_{S_3}$ to the blacklist. The technique repeats the above procedure with $W_{S_4}$ for $t_3$, $W_{S_2}$ for $t_4$, $W_{S_3}$ for $t_5$, and $W_{S_4}$ for $t_6$ in turn. Noticeably, the total number of service invocations drops to 6. Our insight is that service selection has an impact on the effective application of a testing and analysis technique. B. POI Proximity The effectiveness of a test suite in detecting the presence of a fault in web services can be further improved by using test case prioritization [13][14]. Figure 2 shows a fault in the computation of location proximity in City Guide, in which a multiplication operator is mistakenly replaced by a division operator [12]. Two test cases are shown in Figure 3. Each time when the web services recommend three hotels, the client chooses the closest one as the best hotel, which, together with user’s GPS location, will be added as a new case in the case base for future reasoning and query. ```java public class GpsLocationProximity { public double compute(Gps loc1, Gps loc2) { double t = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1) * Math.cos(lat2); // Bug, should be: // + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLong/2) * Math.sin(dLong/2); } } ``` Figure 2. Faulty code with wrong operator Consider test case #1, where the user’s locations are close to the POIs. The correct distances of POIs #7 and #9 from the third GPS location (114.1867, 22.2812) are 0.2569 km and 0.2545 km, respectively, and POI #8 is the closest. However, the distances computed by the faulty code are 0.2570 km and 0.2704 km, respectively, and POI #7 becomes the closest POI. Although the fault only incurs a marginal error in the distance calculation, the small difference seriously affects future POI results because the user will mistakenly confirm a POI that is not optimal. As a result, test case #1 exposes a failure. On the contrary, test case #2 does not reveal any failure. Although the distance is wrongly computed whenever the function is called, it leads only to a small error because the locations are always far away from any POIs, which does not affect the POI ranking. As a result, POIs #1, #2, and #3 are always ranked as closest. The above example shows that the closer a GPS location sequence is in relation to the POIs, the more effective can be the sequence for detecting faults in location-based web services. To achieve better regression testing effect, we propose several POI-aware test case prioritization techniques in Section III. III. SERVICE-CENTRIC TESTING TECHNIQUE Based on Section II, we now present how we address the technical challenges. The first challenge is addressed by incorporating service selection into test case prioritization. For our service-centric testing technique, a test suite is executed only once. During the execution, the binding between the client and the other web services is dynamic. In particular, for each round of execution, the client program passes a blacklist to a service-selection service, which returns a selected service for the former service to construct a service composition (see Figure 4). Hence, test cases in the test suite will not necessarily be bound to the same web service, and more than one web service can be tested by each run of the same test suite. Our service-centric testing technique is formulated as follows. Suppose that $(t_1, t_2, \ldots, t_f, \ldots, t_n)$ is an ordered test set provided by a non-service-centric test case prioritization technique (such as in [10][14][17]), and $\Gamma(A, B)$ is a service selection function, which accepts a blacklist $B$ of services and a set of candidate services $A$, and returns a service from the set $A - B$. Let $B_i$ be the blacklist obtained before executing the test case $t_i$ and let $A_0$ be an empty set. A service-centric testing technique will set $B_{i+1} = B_i$ if the test case $t_i$ does not reveal a failure and set $B_{i+1} = B_i \cup \{\Gamma(B_i, A)\}$ if $t_i$ reveals a failure from executing the service composition constructed from using $\Gamma(B_i, A)$ over the test case $t_i$. ![Figure 4. Our service-centric testing technique.](image) We next present how we address the second technical challenge for testing location-aware service compositions. In the rest of this section, we will introduce five proposed techniques using five different metrics: sequence variance, public class GpsLocationProximity { public double compute(Gps loc1, Gps loc2) { double t = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(lat1) * Math.cos(lat2); // Bug, should be: // + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLong/2) * Math.sin(dLong/2); } } Figure 2. Faulty code with wrong operator Consider test case #1, where the user’s locations are close to the POIs. The correct distances of POIs #7 and #9 from the third GPS location (114.1867, 22.2812) are 0.2569 km and 0.2545 km, respectively, and POI #8 is the closest. However, the distances computed by the faulty code are 0.2570 km and 0.2704 km, respectively, and POI #7 becomes the closest POI. Although the fault only incurs a marginal error in the distance calculation, the small difference seriously affects future POI results because the user will mistakenly confirm a POI that is not optimal. As a result, test case #1 exposes a failure. On the contrary, test case #2 does not reveal any failure. Although the distance is wrongly computed whenever the function is called, it leads only to a small error because the locations are always far away from any POIs, which does not affect the POI ranking. As a result, POIs #1, #2, and #3 are always ranked as closest. The above example shows that the closer a GPS location sequence is in relation to the POIs, the more effective can be the sequence for detecting faults in location-based web services. To achieve better regression testing effect, we propose several POI-aware test case prioritization techniques in Section III. III. SERVICE-CENTRIC TESTING TECHNIQUE Based on Section II, we now present how we address the technical challenges. The first challenge is addressed by incorporating service selection into test case prioritization. For our service-centric testing technique, a test suite is executed only once. During the execution, the binding between the client and the other web services is dynamic. In particular, for each round of execution, the client program passes a blacklist to a service-selection service, which returns a selected service for the former service to construct a service composition (see Figure 4). Hence, test cases in the test suite will not necessarily be bound to the same web service, and more than one web service can be tested by each run of the same test suite. Our service-centric testing technique is formulated as follows. Suppose that $(t_1, t_2, \ldots, t_f, \ldots, t_n)$ is an ordered test set provided by a non-service-centric test case prioritization technique (such as in [10][14][17]), and $\Gamma(A, B)$ is a service selection function, which accepts a blacklist $B$ of services and a set of candidate services $A$, and returns a service from the set $A - B$. Let $B_i$ be the blacklist obtained before executing the test case $t_i$ and let $A_0$ be an empty set. A service-centric testing technique will set $B_{i+1} = B_i$ if the test case $t_i$ does not reveal a failure and set $B_{i+1} = B_i \cup \{\Gamma(B_i, A)\}$ if $t_i$ reveals a failure from executing the service composition constructed from using $\Gamma(B_i, A)$ over the test case $t_i$. ![Figure 4. Our service-centric testing technique.](image) We next present how we address the second technical challenge for testing location-aware service compositions. In the rest of this section, we will introduce five proposed techniques using five different metrics: sequence variance, We categorize our proposed techniques as either input-guided or POI-aware. For the former category, we apply the concept of test case diversity as discussed in [2]. Indeed, our previous work [22] has demonstrated that the more diverse a context sequence is, the more effective they will be in fault detection. For location-based services, the input-guided techniques prioritize a test suite in descending order of the diversity of locations in test cases. For the latter category, following our observation in Section II, POI-aware techniques prioritize test cases that are closer to POIs or cover more POIs. We first formulate some concepts for ease of discussion. Let \( T = \{ t_1, t_2, ..., t_n \} \) be a test suite with \( n \) test cases. Each test case \( t = (l_1, l_2, ..., l_{|t|}) \) is a sequence of GPS locations. Every GPS location \( l_{ij} = (\text{long}_{ij}, \text{lat}_{ij}) \) is an ordered couple of real numbers representing the longitude and latitude of a location. POIs are a set \( P = \{ p_1, p_2, ..., p_m \} \) of \( m \) GPS locations. Each POI is also denoted by an ordered couple \( p_k = (\text{long}_{k}, \text{lat}_{k}) \). The objective is to prioritize \( T \) into an ordered test sequence \( S = (t_1, t_2, ..., t_n) \), where \( (t_1, t_2, ..., t_n) \) is a permutation of \((1, 2, ..., n)\). In our proposed techniques, the test sequence \( S \) is determined by sorting the test cases \( t_i \) in \( T \) according to the value of the quantitative metric \( M \) over \( t_i \). This can be described as a sorting function \( S = \text{sort}(T, M) \). Typically, a sorting function is defined either in ascending order (sort_asc) or descending order (sort_desc). Moreover, our proposed techniques use different quantitative metrics to guide the sorting progress to obtain a desirable value of a goal function \( g(G, \text{sort}(T, M)) \), which indicates how well \( S \) scores with respect to \( G \). Without loss of generality, let us assume that a larger value of \( g \) indicates a better satisfaction of \( G \) by \( S \). \( M \) is either a POI-aware metric \( M_p(t, P) \) or an input-guided metric \( M_f(t) \). The following subsections describe our proposed techniques in more detail. A. Sequence Variance (Var) Sequence variance is an input-guided metric to measure the variations in a sequence. It is defined as the second-order central moment of the sequence: \[ \text{Var}(t) = \frac{1}{|t|} \sum_{i=1,2,...,|t|} \| l_i - \bar{l} \|^2 \] where \( t = (l_1, l_2, ..., l_{|t|}) \) denotes a test case and \( \bar{l} = (\sum l_i)/|t| \) is the centroid of all GPS locations in the sequence. Intuitively, a larger variance indicates more diversity, and hence the sorting function \( \text{sort}_{\text{desc}}(T, \text{Var}(t)) \) is used for this technique. B. Polyline Entropy (Entropy) A test case \( t = (l_1, l_2, ..., l_{|t|}) \) consists of a sequence of GPS locations. If we plot these locations in a two-dimensional coordinate system and connect every two consecutive locations with a line segment, we obtain a polyline with \(|t| \) vertices and \(|t| - 1 \) segments. Polyline entropy is a metric gauging the complexity of such a polyline. We adapt this metric from the concept of entropy of a curve. The entropy of a curve comes from the thermodynamics of curves developed by Mendès France [15] and Dupain [4]. Consider a finite planar curve \( \Gamma \) of length \( L_\Gamma \). Let \( C_r \) be the convex hull of \( \Gamma \), and \( C_r' \) be the length of \( C_r \)'s boundary. Let \( D \) be a random line, and \( P_h \) be the probability that \( D \) intersects with \( \Gamma \) at \( n \) points, as illustrated in Figure 5. According to [15], the entropy of the curve is given by \[ H(\Gamma) = -\sum_{n=1}^{\infty} P_n \log P_n \] By the classical computation in [15], one can easily obtain (see refs. [4][15]) the function \( H(\Gamma) \) that computes the entropy of a planar curve \( \Gamma \) as \[ H(\Gamma) = \log \left( \frac{2L_\Gamma}{C_r} \right) \] We follow the concept of entropy of a curve in [4][15] and compute the entropy of a test case using the function \[ \text{Entropy}(t) = \log \left( \frac{2L_t}{C_t} \right) \] where \( L_t \) is the length of the polyline represented by \( t \), and \( C_t \) is the boundary length of the convex hull of the polyline. A test case with higher entropy contains a more complex polyline. We sort the test cases in descending order of their entropies, that is, we use \( \text{sort}_{\text{desc}}(T, \text{Entropy}(t)) \). C. Centroid Distance (CDist) Centroid distance represents the distance from the centroid of a GPS location sequence to the centroid of the POIs. Because POI information is used in the computation, centroid distance is a POI-aware metric. It directly measures how far a test case is from the centroid of the POIs. We formulate this metric as \[ \text{CDist}(t, P) = \| \bar{l} - \bar{p} \| \] where \( \bar{p} = (\sum p_i)/m \) is the centroid of all POIs. The sorting function used with \( \text{CDist} \) is \( \text{sort}_{\text{asc}}(T, \text{CDist}(t, P)) \). D. Polyline Distance (PDist) Similar to Entropy, we may regard each test case as a polyline whose vertices are GPS locations. The polyline distance measures the mean distance from all POIs to this polyline. Let \( \text{dist}(p, t) \) denote the distance from a POI \( p = (\text{long}, \text{lat}) \) to a polyline \( t = (l_1, l_2, ..., l_{|t|}) \). The polyline distance \( \text{PDist}(t, P) \) of a test case \( t \) is given by \[ \text{PDist}(t, P) = \frac{\sum_{i=1,2,...,|P|} \text{dist}(p_i, t)}{|P|} \] Similar to \( \text{CDist} \), we use \( \text{sort}_{\text{asc}}(T, \text{PDist}(t, P)) \) as the sorting function for \( \text{PDist} \). E. POI Coverage (PCov) POI coverage evaluates the impact of POIs on each test case. To compute the PCov value of a test case \( t \), we first compute the distance \( \text{dist}(p_i, t) \) from each POI \( p_i \) to the polyline represented by \( t \). Then, we use a threshold value \( \alpha \) to classify whether a POI is covered by the polyline, by checking whether the distance \( \text{dist}(p_i, t) \) is no greater than \( \alpha \). Hence, the PCov metric is given by \[ \text{PCov}(t, P) = \sum_{i=1}^{\text{|P|}} f(\text{dist}(p_i, t)) \] where \[ f(\text{dist}) = \begin{cases} 1 & \text{if dist} \leq \alpha \\ 0 & \text{otherwise} \end{cases} \] Here, we use the sorting function \( \text{sort}_{\text{desc}}(T, \text{PCov}(t, P)) \). We summarize all the proposed techniques in Table II. <table> <thead> <tr> <th>Acronym</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Var</td> <td>Input-guided</td> <td>Sort in descending order of the variance of the GPS location sequence</td> </tr> <tr> <td>Entropy</td> <td>Input-guided</td> <td>Sort in descending order of the entropy of the polyline represented by each test case</td> </tr> <tr> <td>CDist</td> <td>POI-aware</td> <td>Sort in ascending order of the distance between the centroid of the GPS locations and the centroid of the POIs</td> </tr> <tr> <td>PDist</td> <td>POI-aware</td> <td>Sort in ascending order of the mean distance from the POIs to the polyline</td> </tr> <tr> <td>PCov</td> <td>POI-aware</td> <td>Sort in descending order of the number of POIs covered by each test case</td> </tr> </tbody> </table> IV. CASE STUDY In this section, we evaluate the effectiveness of our black-box testing prioritization techniques for location-based web services through a case study. A. Research Questions In this section, we present our research questions. \textbf{RQ1:} Is the proposed service-centric testing technique significantly more cost-effective than traditional non-service-centric techniques? The answer to this question will tell us whether incorporating services selection will have an impact on the effectiveness of software engineering techniques in general and test case prioritization techniques in particular. \textbf{RQ2:} Is the diversity of locations in test cases a good indicator for early detection of failures? The answer to this question will tell us whether prioritization techniques based on the diversity of locations in test cases can be promising. \textbf{RQ3:} Is the proximity of locations in test cases in relation to POIs a good indicator for early detection of failures? The answer to this question will tell us whether test case prioritization techniques based on such proximity is heading towards a right direction. B. Subject Pool of Web Services In the experiment, we used a realistic location-based service composition \textit{City Guide}, which contains 3289 lines of code. (This will be the only subject used in our empirical study, as the implemented codes of other backend services are not available to us.) We treat the given \textit{City Guide} as a “golden version”. We used MuClipse [12] to generate a pool of faulty web services and followed the procedure in [12] to eliminate mutants that are unsuitable for testing experiments. All the remaining 35 faulty web services constituted our subject pool. We applied our test pool (see Section IV.E) to these faulty web services. Their average failure rate is 0.0625. C. Experimental Environment We conduct the experiment on a Dell PowerEdge 1950 server running Solaris UNIX and equipped with 2 Xeon X5355 (2.66Hz, 4 core) processors and 8GB memory. D. Effectiveness Metrics Some previous work uses the average percentage of fault detection (APFD) [6] as the metric to evaluate the effectiveness of a test case prioritization technique. However, the APFD value depends on test suite size. For example, appending more test cases to an ordered test suite will jack up the probability to a value quite close to 1. Hence, it is undesirable to use APFD when test suites are large, but regression test suites in many industrial settings are usually large in size. We propose to use another metric, the Harmonic Mean (HM), which is independent of the test suite size. HM is a standard mathematical average that combines different rates (which, in our case, is the rate of detecting individual faults) into one value. Let \( T \) be a test suite consisting of \( n \) test cases and \( F \) be a set of \( m \) faults revealed by \( T \). Let \( T_{Fi} \) be the first test case in the reordered test suite \( S \) of \( T \) that reveals fault \( i \). Then, the harmonic mean of \( TF \) is given by \[ HM_{TF} = \frac{1}{\frac{1}{TF_1} + \frac{1}{TF_2} + \cdots + \frac{1}{TF_m}} \] We also propose to use another measure to evaluate the cost of detecting each fault. As service invocations can be expensive, a technique should aim at lowering the number of service invocations for failure detection. Suppose the number of service invocations for detecting fault \( i \) is \( S_{li} \). We propose the use the harmonic mean of \( S_{li} \), given by \[ HM_{SI} = \frac{m}{\frac{1}{S_{l1}} + \frac{1}{S_{l2}} + \cdots + \frac{1}{S_{lm}}} \] Although both \( HM_{TF} \) and \( HM_{SI} \) measure the fault detection rate, \( HM_{SI} \) is arguably more accurate than \( HM_{TF} \) because \( HM_{SI} \) reflects the actual number of service execution needed to reveal an average fault, whereas \( HM_{TF} \) reflects the number of test cases executed to reveal a fault. The latter ignores the possible dynamic binding of services and is an indirect measure of the testing effort. E. Experiment and Discussions As introduced in Section II, our subject program \textit{City Guide} is a location-based service composition. We used a regression test pool containing 2000 test cases, each of which was a GPS location sequence. For each test case, we used the POIs returned by the golden version over the last location in a test case as the test oracle. We used the POIs extracted from the test oracles to populate the case base. We proposed five prioritization metrics: Var, Entropy, CDist, PDist, and PCov. Together with random ordering, therefore, there are six techniques, each of which can be combined with service selection (denoted by service-centric) or be used alone (denoted by non-service-centric). Thus, there are twelve techniques in total. To show the average performance of our techniques on different test suites, we randomly constructed 50 test suites from the test pool. Each test suite contained 1024 test cases. Each technique was evaluated on all test suites to obtain an average. In the experiment, each service-centric technique used the adapted service-selection service of City Guide to implement $\Gamma$ (see Section III for details). We compute the $HM_{TF}$ distribution for all techniques, and group the results into two box-and-whisker plots (Figures 6 (a) and (c)) depending on whether a technique is service-centric. For each plot, the x-axis represents the prioritization metric used (or random ordering) and the y-axis represents the $HM_{TF}$ distributions for all test suites. The horizontal lines in the boxes indicate the lower quartile, median, and upper quartile values. If the notches of two boxes do not overlap, then the median values of the two groups differ at a significance level of 5%. Similarly, we calculate the $HM_{S1}$ distribution and draw two plots as shown in Figures 6 (b) and (d), where the y-axis represents the $HM_{S1}$ distribution for all test suites. For service-centric techniques, we also conduct multiple comparison analysis [11] to find those techniques whose means differ significantly from others. The distributions of $HM_{TF}$ and $HM_{S1}$ values for each technique are shown in Figures (e) and (f), respectively, as a horizontal line with a dot in the center, which denotes the mean value. If the lines corresponding to two techniques do not overlap, then their mean values are different at a significance level of 5%. 1) Answering RQ1. By comparing Figures 6 (b) and (d), we observe that service selection remarkably reduces the number of service invocations. Take the metric Var as an example. The service-centric technique that incorporates service selection achieves 126.88 in terms of the median $HM_{S1}$. However, the median $HM_{S1}$ for the non-service-centric counterpart is 270.97. Thus, service selection leads to a 53.18% reduction of service invocations, which is an encouraging improvement. Similarly, the reductions for random ordering, Entropy, CDist, PDist, and PCov are 24.24%, 0.51%, 29.69%, 40.61%, and 23.88%, respectively. The average improvement is 28.69%, which is significant. On the other hand, the variance is large. Comparing Figures 6 (a) and (c), we observe that the number of test cases that exposes a fault increases from using a non-service-centric version to a service-centric version of the same technique. However, as discussed in the last subsection, $HM_{S1}$ is more accurate and the improvement of $HM_{S1}$ through service selection is large. It further indicates that the use of traditional idea to count test cases as an effectiveness metric for service-oriented testing may not be helpful. Hence, we can answer RQ1 that the proposed service-centric techniques are, on average, significantly more cost-effective in detecting faults than the non-service-centric counterparts. 2) Answering RQ2. We observe from Figures 6 (a), (b), (e), and (f) that, in general, the two input-guided techniques are significantly more effective than random ordering. In particular, we see from Figure 6 (b) that the median $HM_{S1}$ values of Var and Entropy are 126.88 and 149.58, respectively, and the median $HM_{S1}$ value of random ordering is 176.83. From Figure 6 (f), the mean $HM_{S1}$ values of random ordering, Var, and Entropy are 182.24, 141.79, and 144.54, respectively. These figures indicate that, compared with random ordering, Var or Entropy has the potential to reduce the average number of service invocations. Moreover, Var outperforms Entropy in that Var leads to fewer service invocations than Entropy. Hence, we can answer RQ2 that the diversity of locations in test cases can be a good indicator to guide test case prioritization to detect failures earlier than random ordering. 3) Answering RQ3. We observe from the box-and-whisker plots in Figures 6 (a) and (b) that the three POI-aware techniques (CDist, PDist, and PCov) are significantly better than random ordering and the two input-guided techniques (Var and Entropy) at a significance level of 5%. If we further examine the results of multiple comparisons [11] in Figures 6 (e) and (f), there is no overlap of POI-aware techniques with Var, Entropy, or random ordering in the respective notches. It indicates that the POI-aware techniques can be more effective than Var, Entropy, and random ordering in terms of mean values at a significance level of 5%. Among all techniques, CDist is the most effective metric to guide test case prioritization and the difference between CDist and each of other techniques is statistically significant. Moreover, based on Figure 6 (d), CDist achieves 78.4 in terms of the mean $HM_{S1}$, which is substantially smaller than that of random ordering (176.83). Based on the analysis, the proximity of locations in test cases in relation to POIs can be promising in guiding the detection of failures in location-based web services. F. Summary Our empirical results provide a piece of evidence that service selection does carry impacts on the effectiveness of software engineering techniques. According to the case study, on average, it helps improve the effectiveness of test case prioritization to assure web services remarkably. We also observe that use of the proximity/diversity of locations is promising in guiding a testing technique to detect failures in location-based web services notably and is significantly more cost-effective than random ordering. Furthermore, the use of the locations of POIs captured by test cases can be more effective than using test inputs only. On average, POI-aware techniques detects the first failure of each fault in a location-based web service by invoking web services much fewer number of times than random ordering of test cases. Owing to the probabilistic nature of service selection in City Guide, some faults may fail to be exposed. Encouragingly, we observe empirically that a fault is missed by random ordering in just one test suite out of 50, and none of the other techniques fail to expose any fault using any test suite. We have repeated our experiment on smaller test suites and found that, although the use of a smaller test suite tends to miss more faults, the total number of missed faults is still small. For example, for test suites of size 256, on average, our proposed techniques detect at least 80% of all faults. Owing to the page limit, we do not include the detailed results on smaller test suites in this paper. V. RELATED WORK Many existing test case prioritization techniques are coverage-based. For instance, Wong et al. [23] propose to combine test suite minimization and test case prioritization to select test cases based on the additional cost per additional coverage requirement. Srivastava et al. [19] propose to compare different program versions at machine code level and then prioritize test cases to cover the modified parts of the program maximally. Walcott et al. [21] propose a time-aware prioritization technique based on a generic technique to permute test cases under given time constraints. Li et al. [11] propose to apply evolutionary algorithms for test case prioritization with the goal of increasing the coverage rate. Researchers have also investigated the challenges in regression testing of service-oriented applications. Mei et al. [14] propose a hierarchy of test case prioritization techniques for service-oriented applications by considering different levels of services including business process, XPath, and WSDL specifications. In [13][14], they also study the problem of black-box test case prioritization of service-oriented applications based on the coverage information of WSDL tags. Different from their work that explore XML message structure exchanged between services to guide prioritization, we utilize the distributions of location and POI information to guide prioritization and do not need to analyze communication messages, which are linked to location-based software cohesively. Adaptive random testing [2][3] improves the performance of random test case generation by evenly spreading test cases across the input domain. Jiang et al. [10] proposed a family of adaptive random test case prioritization techniques that spread the coverage achieved by any prefix of a prioritized sequence of test cases as evenly as possible to increase the fault detection rate. Locations-based web service is a popular application that can benefit both mobile network operators and end users [16]. There are many standards [1] and techniques for location-based web services. In future work, one may generalize our techniques so that they will be applicable to a broader range of location-based web services. VI. CONCLUSION The testing of dynamic service compositions must solve the problem that a dynamically selected service may not be selected and bound in another execution of the same test case. Moreover, the number of possible service compositions can be huge. Both problems need to be addressed by non-traditional testing ideas and the understanding of the impact of service selection on software engineering techniques is vital. To tackle these two issues, we have proposed to integrate service selection in test case prioritization to support regression testing. Furthermore, we have also proposed a family of black-box service-centric test case prioritization techniques that guide the prioritization based on Point of Interest (POI) information. Our case study on a medium-sized location-based web service City Guide has shown that service selection significantly improves the effectiveness of regression testing. The result demonstrates that service selection has a large impact on the effectiveness of software engineering techniques in general and test case prioritization techniques in particular. Moreover, POI-aware prioritization techniques are much more effective than random ordering. The experiment has also shown that the use of proximity or diversity of locations, particularly the POI-aware properties, can be promising in cost-effectively detecting failures in location-based web services. Our future work includes incorporating advanced service selection strategies to a wider class of software engineering techniques. REFERENCES
{"Source-Url": "http://hub.hku.hk/bitstream/10722/125683/1/Content.pdf", "len_cl100k_base": 9926, "olmocr-version": "0.1.53", "pdf-total-pages": 9, "total-fallback-pages": 0, "total-input-tokens": 34575, "total-output-tokens": 12216, "length": "2e13", "weborganizer": {"__label__adult": 0.0003161430358886719, "__label__art_design": 0.0003268718719482422, "__label__crime_law": 0.0002799034118652344, "__label__education_jobs": 0.0008831024169921875, "__label__entertainment": 6.282329559326172e-05, "__label__fashion_beauty": 0.00016129016876220703, "__label__finance_business": 0.00019693374633789065, "__label__food_dining": 0.0002849102020263672, "__label__games": 0.0006084442138671875, "__label__hardware": 0.0007376670837402344, "__label__health": 0.0004220008850097656, "__label__history": 0.00023186206817626953, "__label__home_hobbies": 5.9723854064941406e-05, "__label__industrial": 0.00022542476654052737, "__label__literature": 0.0003323554992675781, "__label__politics": 0.00020945072174072263, "__label__religion": 0.00032401084899902344, "__label__science_tech": 0.0175323486328125, "__label__social_life": 8.189678192138672e-05, "__label__software": 0.00785064697265625, "__label__software_dev": 0.96826171875, "__label__sports_fitness": 0.00022733211517333984, "__label__transportation": 0.000347137451171875, "__label__travel": 0.00018203258514404297}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 47560, 0.01964]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 47560, 0.33429]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 47560, 0.87767]], "google_gemma-3-12b-it_contains_pii": [[0, 1081, false], [1081, 6639, null], [6639, 11253, null], [11253, 19931, null], [19931, 25735, null], [25735, 31780, null], [31780, 38219, null], [38219, 40824, null], [40824, 47560, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1081, true], [1081, 6639, null], [6639, 11253, null], [11253, 19931, null], [19931, 25735, null], [25735, 31780, null], [31780, 38219, null], [38219, 40824, null], [40824, 47560, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 47560, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 47560, null]], "pdf_page_numbers": [[0, 1081, 1], [1081, 6639, 2], [6639, 11253, 3], [11253, 19931, 4], [19931, 25735, 5], [25735, 31780, 6], [31780, 38219, 7], [38219, 40824, 8], [40824, 47560, 9]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 47560, 0.06635]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
8c5fedb28c30da72fff37522ab306f2431ecebad
This document describes the implementation process and the basic use of peripheral simulation model in TRACE32. ### Overview PSM - Peripheral Simulation Model contains functions and registers of corresponding physical modules supported by MCU. It is additional program (overlay) for simulated core. To complete the tasks, core operates on registers located in physical memory of MCU. PSM is a software overlay for memory area occupied by peripheral module. For an accurate simulation of microprocessor's unit, interaction between a core and peripherals module is required. PSM provides functions responsible for interaction between core and other modules. PSM is able to simulate any module which significantly increases functionality of the entire simulation environment. The processor retrieves and sends data from/to memory shared with other MCU modules, hence the need to simulate not only the processor core, but also cooperative modules. Simulation of microprocessor's system without the module requires manual setting of the appropriate bits in registers of peripheral module (important for proper software operation). For proper registers' configuration to which a processor sends/receives data, user have to perform time-consuming work with a documentation. Bits in a registers are frequently modified with an each clock cycle. By Peripheral Simulation Models complicated settings are done automatically. Software takes over the role of an interaction between model and simulator and between other modules. Using PSM increases possibility of checking a software functionality in implemented microprocessor’s system. An important feature of this solution is to eliminate a **human error factor** in process of modifying registers contents while working with documentation. Simulation **without** Peripheral Simulation Models. Simulation **with** Peripheral Simulation Models. Ports are used for communication between models, processor simulator and user. Currently there are over 512 ports. Ports are the primary communication interface provided by TRACE32. PSM is stored in a DLL. The functions and resources of the DLL can be used directly by TRACE32. The DLL is not an independent program. Libraries are dynamically imported into the memory at the time specified by a programmer (mostly when actually needed), hence a definition of dynamically linked library. DLL files are often used in programs as plug-ins. The module contained in a DLL can be loaded using the appropriate command in TRACE32. Simulation process: Microprocessor's system is often simulated by executing sequence of steps and observing the program's response. In simulated system are some operations CPU performs itself, such as arithmetic-logic operations, copying, etc. Those operations do not need to cooperate with other modules and program may be continued. Nevertheless when it comes to cooperation between CPU and other modules (most cases) it is necessary to ensure adequate interaction in a simulator. PSM performs its functions (data change in registers, interruption send, decrementation, etc.) and after those functions are completed, program is continued until the very end. For better understanding of simulation operating rules it is advised to remember that the simulation is a virtual representation of real processes and takes place in computer memory. TRACE32 simulation environment allows to simulate any system. TRACE32 reserves area of memory for a simulated system and in this area simulator performs operations. All performed operations and created variables are stored in TRACE32 memory. This section describes: functions frequently used in the model, operations on the registers, communication in the simulation, I/O operations and the basic commands in a initialization script. **Standard function** Callback functions are used to handle events such as reset, exit from TRACE32, GO,BREAK, timers, changes on ports lines and changes of the registers’ contents in model memory (see the file simul.h). These functions are called when registered events are performed, so it is required to initialize them in a `SIMUL_Init` function. The memory allocation for our variables should be done inside `SIMUL_Init` function (do not use global variables). Allocation is done with `SIMUL_Alloc` function. Event handler functions: 1. Event reset callback function. ```c SIMUL_RegisterResetCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private); ``` Register callback function to handle simulation model reset. 2. Event read callback function. ```c SIMUL_RegisterBusReadCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private, int bustype, simulWord * paddressFrom, simulWord * paddressTo); ``` Register callback function to handle register events in simulation model. Function responsible for reading register (separately for each of registers). 3. Event write callback function. ```c SIMUL_RegisterBusWriteCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private, int bustype, simulWord * paddressFrom, simulWord * paddressTo); ``` Register callback function to handle register events in simulation model. Function responsible for writing to register (separately for each of registers). 4. Event port change callback function. ``` SIMUL_RegisterPortChangeCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private, int offset, int width); ``` Register callback function to handle port changes in simulation model. 5. Event command callback function. ``` SIMUL_RegisterCommandCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private); ``` Register callback function to handle a commands in TRACE32 environment. This function returns SIMUL_COMMAND_OK or SIMUL_COMMAND_FAIL. 6. Event exit from TRACE32 callback function. ``` SIMULAPI SIMUL_RegisterExitCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private); ``` Register callback function to handle exit from a model in TRACE32 environment. This function returns SIMUL_EXIT_OK. 7. Event GO callback function. ``` SIMULAPI SIMUL_RegisterGoCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private); ``` Register callback function to handle GO command in TRACE32 environment. This function returns SIMUL_GO_OK. 8. Event Terminal callback function. ``` SIMUL_RegisterTerminalCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private, int id); ``` Register callback function to handle terminal in TRACE32 environment. ```c SIMULAPI SIMUL_RegisterBreakCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private); ``` Register callback function to handle BREAK command in TRACE32 environment. This function returns SIMUL_BREAK_OK. 10. Reallocation (changes) register address function. ```c SIMUL_RelocateBusCallback(simulProcessor processor, void * callbackid, int bustype, simulWord * paddressFrom, simulWord * paddressTo); ``` Register callback function to handle addresses changes in simulation model registers in TRACE32 environment. 11. Register timer function. ```c SIMUL_RegisterTimerCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private); ``` Register callback function to handle timers in a simulation model in TRACE32 environment. Explanation of terms appearing in the functions: <table> <thead> <tr> <th>term</th> <th>description</th> </tr> </thead> <tbody> <tr> <td>func</td> <td>Function that supports an event</td> </tr> <tr> <td>private</td> <td>Global variable of our model</td> </tr> <tr> <td>bustype</td> <td>Variable of the structure of CBS</td> </tr> <tr> <td>offset</td> <td>Port from which the start</td> </tr> <tr> <td>width</td> <td>Amount of ports</td> </tr> <tr> <td>paddressFrom</td> <td>Start address of register</td> </tr> <tr> <td>paddressTo</td> <td>End address (paddressFrom + regsize)</td> </tr> </tbody> </table> Please note that the maximum number of ports (width) for a single registration is 32, to declare other ports offset variable have to be changed. The model can be loaded with parameters (types and kinds of parameters can be defined by the user), e.g. base module address, number of interrupts in INTC etc. Access to this data can be obtained through the structure `simulCallbackStruct*cbs` in an initialization function. <table> <thead> <tr> <th>cbs-&gt; x.init.argc</th> <th>Indicated the number of parameters (value “1” means no parameters)</th> </tr> </thead> <tbody> <tr> <td>cbs-&gt; x.init.argpbustype[1]</td> <td>Indicates the type of bus. Value of that variable should stored in the main structure as a bustype variable (for future use)</td> </tr> <tr> <td>cbs-&gt; x.init.argpport [x]</td> <td>stores parameters of int type</td> </tr> <tr> <td>cbs-&gt; x.init.argp [x]</td> <td>stores parameters of char* type</td> </tr> </tbody> </table> The exact description of structure is in ‘simul.h’ file. There are so called standard functions which are designed to handle the model. For example, display of warning messages, memory allocation, etc. Standard functions: 1. Formated displaying. ```c SIMUL_Printf(simulProcessor processor, const char *format, ...); ``` Function used to display text message in TRACE32 environment. 2. Displaying warnings in TRACE32 command line. ```c SIMUL_Warning(simulProcessor processor, const char *format, ...); ``` Function used to display warnings in TRACE32 environment. 3. Stopping simulation in TRACE32. ```c SIMUL_Stop(simulProcessor processor); ``` Function used to stop simulation in TRACE32 environment. 4. Updated data TRACE32. ```c SIMUL_Update(simulProcessor processor, int flags); ``` Function used to update data in TRACE32 environment. 5. Allocation of memory for variables. ```c SIMUL_Alloc(simulProcessor processor, int size); ``` Function used to allocate memory in TRACE32, for variables used in a simulation model. 6. Deallocate memory for variables. ```c SIMUL_Free(simulProcessor processor, void * ptr); ``` Function used to free memory in TRACE32 environment. 7. Get current endian (Little = 0). ```c SIMUL_GetEndianess(simulProcessor processor); ``` Function used to get a current endian settings used in a simulation model. --- ## Registers Model should simulate all types of registers: <table> <thead> <tr> <th>RO</th> <th>read only register</th> </tr> </thead> <tbody> <tr> <td>R/W</td> <td>read write register</td> </tr> <tr> <td>W</td> <td>write register</td> </tr> <tr> <td>RC</td> <td>read clear by 0 register</td> </tr> <tr> <td>R1C</td> <td>read clear by 1 register</td> </tr> <tr> <td>R/W</td> <td>read write register</td> </tr> </tbody> </table> For each register, there should be two functions (depending on register access type). One responsible for reading and one for writing a certain area of memory (register). These functions should be in `Simul_Init` function in `model_name`.c file (these are callback functions). For each function that supports register (memory) designer can determine what kind of access type is being executed by TRACE32, whether it is being read by peripheral file or being accessed by CPU. According to values in the variable `cbs->x.bus.cycletype`: <table> <thead> <tr> <th>SIMUL_MEMORY_HIDDEN</th> <th>Access peripheral file or simulation bus</th> </tr> </thead> <tbody> <tr> <td>SIMUL_MEMORY_DATA</td> <td>CPU access through instructions such as load</td> </tr> <tr> <td>SIMUL_MEMORY_FETCH</td> <td>CPU load opcode</td> </tr> <tr> <td>SIMUL_MEMORY_DMA</td> <td>DMA</td> </tr> </tbody> </table> Register type 'RO' is simulated by not executing callback function responsible for writing. The register type 'W' is simulated by not executing callback function responsible for reading, while other registers are simulated in similar way according to privileges. Functions operating on registers in model: 1. Read memory function. ```c SIMUL_ReadMemory(simulProcessor processor, int bustype, simulWord * paddress, int width, int cycletype, simulWord * pdata); ``` Function used to read memory from specified area in TRACE32 environment. 2. Write memory function. ```c SIMUL_WriteMemory(simulProcessor processor, int bustype, simulWord * paddress, int width, int cycletype, simulWord * pdata); ``` Function used to write memory to specified area in TRACE32 environment. 3. Insert function (smaller word to a greater word). Such as 8-bit to 32-bit. ```c SIMUL_InsertWord(simulProcessor processor, simulWord * ptarget, int wordwidth, simulWord * paddress, int width, simulWord * pdata); ``` Function used to insert a smaller word in the greater word. 4. Extract function (smaller word from a greater word). Such as 8-bit from 32-bit. ```c SIMUL_ExtractWord(simulProcessor processor, simulWord * psource, int wordwidth, simulWord * paddress, int width, simulWord * pdata); ``` Function used to extract a smaller width word from a greater width word. 5. Data save function. ``` SIMUL_SaveWord(simulProcessor processor, void * ptarget, int width, simulWord * pdata); ``` Function used to save a value of specified word. 6. Data load function. ``` SIMUL_LoadWord(simulProcessor processor, void * psource, int width, simulWord * pdata); ``` Function used to load a value from specified word. Explanation of terms appearing in the functions: <table> <thead> <tr> <th>bustype</th> <th>type of bus</th> </tr> </thead> <tbody> <tr> <td>paddress</td> <td>address</td> </tr> <tr> <td>width</td> <td>width in bytes</td> </tr> <tr> <td>wordwidth</td> <td>width of the object on which operations are executed</td> </tr> <tr> <td>cycletype</td> <td>access type, eg hidden</td> </tr> <tr> <td>pdata</td> <td>data to write / read</td> </tr> <tr> <td>ptarget</td> <td>target to save</td> </tr> <tr> <td>psource</td> <td>source to load</td> </tr> </tbody> </table> In supported registers functions it is required to set a `cbs->x.bus.clocks` variable which is responsible for number of cycles of access to these functions. The `cbs.x.bus->address` variable stores address of read or write. The access type is stored in `cbs.x.bus->width` variable - it is possible to write an 8, 16-bit or 32-bit register. To avoid misunderstandings it is recommended to write a functions to handle hazardous situations, or use `SIMUL_InsertWord` / `SIMUL_ExtractWord` when these registers are supported. Write / read data are transmitted in `cbs.x.bus->data` variable. At the end function returns `SIMUL_MEMORY_OK`. ©1989-2015 Lauterbach GmbH Timers are used to measure time and are calculated relative to TRACE32. Each timer used in a model have to be registered in the initialization function (Simul_Init). Timer needs to be started using SIMUL_StartTimer function and can be stopped using SIMUL_StopTimer function. It is also possible to retrieve a current simulation time etc. Functions operating on timers: 1. Start timer function. ```c SIMUL_StartTimer(simulProcessor processor, void * timerid, int mode, simulTime * ptime); ``` Function used to start selected timer in a simulation model. 2. Stop timer function. ```c SIMUL_StopTimer(simulProcessor processor, void * timerid); ``` Function used to stop selected timer in a simulation model. 3. Stop all timers function. ```c SIMUL_StopAllTimer(simulProcessor processor); ``` Function used to stop all timers in a simulation model. 4. Returns time since the beginning of simulation function. ```c SIMUL_GetTime(simulProcessor processor, simulTime * ptime); ``` 5. Returns number of clock cycles since the beginning of simulation function. ```c SIMUL_GetClock(simulProcessor processor, int clockid, simulTime * ptime); ``` 6. Returns clock frequency function. ```c SIMUL_GetClockFrequency(simulProcessor processor, int clockid, simulWord64 * pfrequency); ``` 7. Set clock frequency function ```c SIMUL_SetClockFrequency(simulProcessor processor, int clockid, simulWord64 * pfrequency); ``` 8. Returns number of clock cycles for one clock function. ```c SIMUL_GetClockCycle(simulProcessor processor, int clockid, simulTime * ptime); ``` 9. Sets number of clock cycles for one clock function. ```c SIMUL_SetClockCycle(simulProcessor processor, int clockid, simulTime * ptime); ``` Explanation of terms appearing in the functions: <table> <thead> <tr> <th>term</th> <th>description</th> </tr> </thead> <tbody> <tr> <td>timerid</td> <td>timer identifier</td> </tr> <tr> <td>mode</td> <td>timer mode</td> </tr> <tr> <td>ptime</td> <td>defines set / returns value</td> </tr> <tr> <td>func</td> <td>function responsible for timer operation</td> </tr> <tr> <td>clockid</td> <td>clock identifier</td> </tr> <tr> <td>pfrequency</td> <td>defines set / returns frequency</td> </tr> </tbody> </table> Timer mode depending on `mode` variable: <table> <thead> <tr> <th>SIMUL_TIMER_ABS</th> <th>ptime specifies absolute time calculated from the beginning of simulation</th> </tr> </thead> <tbody> <tr> <td>SIMUL_TIMER_REL</td> <td>ptime specifies the number of clock cycles from now</td> </tr> </tbody> </table> For example, if a mode is set on (SIMUL_TIMER_REPEAT | SIMUL_TIMER_CLOCKS) then simulator calls a timer with each step (depends on how many cycles equal one step on simulator such as ARM = 3). ## Ports The ports serve as communication between different models and also between models and a simulator. To set port value in TRACE32: <table> <thead> <tr> <th>port.set p.0 high</th> <th>sets value ‘1’ on port 0.</th> </tr> </thead> <tbody> <tr> <td>port.set p.0 low</td> <td>sets value ‘0’ on port 0.</td> </tr> </tbody> </table> Currently, there are 512 general-purpose ports and 8 (-1 to -8) special ports dedicated for communication with simulator. To use ports in model designer has to register callback functions in Simul_Init in ‘model_name’.c file. Number of ports used in specific function is defined by setting width variable. By using two variables from cbs structure (cbs->x.port.newdata and cbs->x.port.olddata) we can find out whether there is change and on which port. For more than one port, use function to determine which port has changed its value. Functions operating on ports: 1. Set value port function. ``` SIMUL_SetPort(simulProcessor processor, int offset, int width, simulWord *pdata); ``` 2. Get value port function. ```c SIMUL_GetPort(simulProcessor processor, int offset, int width, simulWord * pdata); ``` 3. Port change function. ```c SIMUL_RegisterPortChangeCallback(simulProcessor processor, simulCallbackFunctionPtr func, simulPtr private, int offset, int width); ``` Explanation of terms appearing in the functions: <table> <thead> <tr> <th>Term</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>offset</td> <td>port number</td> </tr> <tr> <td>width</td> <td>number of ports</td> </tr> <tr> <td>pdata</td> <td>set /get value</td> </tr> <tr> <td>func</td> <td>function that supports an event</td> </tr> <tr> <td>private</td> <td>variable output model</td> </tr> </tbody> </table> At the end function returns `SIMUL_PORT_OK`. Terminals Terminal is used to display data, thus it is possible to simulate the graphic driver or similar device displaying informations in a dedicated window. Functions operating on terminal: SIMUL_StateTerminal(simulProcessor processor, int id); 2. Read data function. SIMUL_ReadTerminal(simulProcessor processor, int id); 3. Write characters function. SIMUL_WriteTerminal(simulProcessor processor, int id, int ch); Explanation of terms appearing in the functions: <table> <thead> <tr> <th>id</th> <th>terminal ID</th> </tr> </thead> <tbody> <tr> <td>private</td> <td>model variable</td> </tr> <tr> <td>ch</td> <td>character to write on terminal</td> </tr> </tbody> </table> Terminal state is returned by following value. <table> <thead> <tr> <th>SIMUL_STATE_RXREADY</th> <th>Terminal ready to read</th> </tr> </thead> <tbody> <tr> <td>SIMUL_STATE_TXREADY</td> <td>Terminal ready to write</td> </tr> <tr> <td>SIMUL_STATE_NOTEXISTING</td> <td>There is no terminal</td> </tr> </tbody> </table> Basic interface used for communication consists of general-purpose ports (0 to 511), dedicated ports lines -1 (reset), -2 (interruption), -3 (NMI) [exact names can be found in Ports section in simul.h file] and registered callback functions. Model should report an interrupt event to simulator using a dedicated port. For interrupt handling in a simulator (only for Interrupt Controller), please write appropriate functions. (if does not exist). Interrupt processing should be confirmed by clearing a dedicated line. All accesses to memory (peripherals, registers) have to be made through access type SIMUL_MEMORY_DATA, unless they are special sequence of read / write, implemented in the target system through bus. In that case SIMUL_MEMORY_HIDDEN access type should be used. Functions operating on normal type of access is already written in a simulator. However for special type of access new function have to be written, bearing in mind here that there are no variables associated with CTS. Files In PSM it is possible to operate on files, without using functions provided by standard header files. It is important because TRACE32 acts on many platforms and operating systems. Therefore, functions defined in simul.h file are used to let TRACE32 support various platforms and systems. Functions operating on files: 1. Open file function. SIMUL_OpenFile(simulProcessor processor, const char * filename, int mode); 2. Close file function. SIMUL_CloseFile(simulProcessor processor, void * file); 3. Read file function. SIMUL_ReadFile(simulProcessor processor, void * file, void * pdata, int length); 4. Write file function. ``` SIMUL_WriteFile(simulProcessor processor, void * file, void * pdata, int length); ``` 5. Read line from file function. ``` SIMUL_ReadlineFile(simulProcessor processor, void * file, void * pdata, int length); ``` 6. Write line to file function. ``` SIMUL_WritelineFile(simulProcessor processor, void * file, void * pdata); ``` 7. Set file position (returns position after operation). ``` SIMUL_SeekFile(simulProcessor processor, void * file, long pos, int mode); ``` Explanation of terms appearing in the functions: <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>filename</strong></td> <td>Name of file</td> </tr> <tr> <td><strong>file</strong></td> <td>File ID</td> </tr> <tr> <td><strong>mode</strong></td> <td>Access mode</td> </tr> <tr> <td><strong>length</strong></td> <td>Length of write / read data</td> </tr> <tr> <td><strong>pdata</strong></td> <td>Data pointer</td> </tr> <tr> <td><strong>pos</strong></td> <td>Position to set</td> </tr> </tbody> </table> Mode variable has following values for **OpenFile**: <p>| | |</p> <table> <thead> <tr> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td><strong>SIMUL_FILE_READ</strong></td> <td>Read a file</td> </tr> <tr> <td><strong>SIMUL_FILE_WRITE</strong></td> <td>Write a file</td> </tr> <tr> <td>Mode Variable</td> <td>Description</td> </tr> <tr> <td>---------------</td> <td>-------------</td> </tr> <tr> <td>SIMUL_FILE_CREATE</td> <td>Create a file</td> </tr> <tr> <td>SIMUL_FILE_APPEND</td> <td>Adding to a file</td> </tr> <tr> <td>SIMUL_FILE_BINARY</td> <td>Binary file</td> </tr> <tr> <td>SIMUL_FILE_ASCII</td> <td>ASCII file</td> </tr> <tr> <td>SIMUL_FILE_SEEKABS</td> <td>Setting position in relation to the beginning of file</td> </tr> <tr> <td>SIMUL_FILE_SEEKREL</td> <td>Setting position in relation to the current position in file</td> </tr> <tr> <td>SIMUL_FILE_SEEKEND</td> <td>Setting position in relation to the end of file</td> </tr> </tbody> </table> To properly support the model in TRACE32 and easier usage model by other people, initscript should be created. Task of initialization scripts is prepare model to work with a simulator as if the initialization has been performed by MCU procedure in TRACE32. Initscripts are created in files with the extension *.CMM. Commands used in initialization script for Peripheral simulation model (more details see General Commands Reference Guide): 1. Start command and End command. ``` DO Start script ENDDO End of script ``` Command "DO" begin the script, and command "ENDDO" inform of the completion. 2. CPU select command. Format: `SYSTEM.CPU <cpu>` `<cpu>`: `C64X, ARM7TDMI, ARM9E, C6455, ...` Specify the exact CPU type used on your target. This is required to get the matching PER file and other CPU specific settings (e.g. predefined settings for on-chip FLASH). 3. Port name set command. Format: `NAME.SET port.<number> <port_name>` `<number>`: `-8,-7,...511,512.` `<port_name>`: `interrupt, timer, model,...` Gives name of selected port. All ports used in system have to be listed. 4. Deletes the specified model from TRACE32 memory command. Format: SIM.UNLOAD <path to model_name.dll> <path to model_name.dll>: arm_timer.dll, vic_lpc.dll,... Selected simulation model is removed from TRACE32 memory. Command without specified model, clears all simulation models from TRACE32 memory. 5. Loads the specified model to TRACE32 memory command. Format: SIM.LOAD <model_name.dll> [parameters] <path to dll>: ../model/arm_timer.dll, c:/vic_lpc.dll,... [parameters]: "timer" "cpu" Selected simulation model is loaded into TRACE32 memory. If the model has parameters, then have to be provided. In other action model can be unpredictable. 6. System up command. Format: SYSTEM.UP After this command all libraries are initialized. 7. Performs an operation on the address command. Format: DATA.ASSEMBLE [<address>] <mnemonic> <address>: 0xff000000, 0xbc80a000,... <mnemonic>: nop, subs, str, move,... Data.Assemble is used to replace the code at memory <address> with the assembler instruction specified by <mnemonic>; <mnemonic> describes the instruction with respect to the CPU-mnemonic. 8. Displaying instruction window command. <table> <thead> <tr> <th>Format: DATA.LIST</th> </tr> </thead> </table> Display format (in assembler, mixed or HLL) is selected dynamically, depending on the current debug mode. If no address is specified, the window tracks to the value of the program counter. The window is only scrolled, if the bar moves outside of a predefined subwindow. 9. Displays memory area in a window command. <table> <thead> <tr> <th>Format: DATA.DUMP &lt;range&gt;</th> </tr> </thead> <tbody> <tr> <td>&lt;range&gt;: 0x0--0xff, 0xffff8000--0xffffff90a0,...</td> </tr> </tbody> </table> If a single address is selected this address will define the windows' initial position only. Scrolling makes other memory contents visible. When selecting an address range only the defined data range can be dumped. Range definition is useful whenever the addresses following are read protected (e.g., in the case of I/O) or more than one page will be printed. This command allows to preview the memory area. The area is updated every step. When a window is displayed reading is made with each step. 10. Sets a value in the specified register command. <table> <thead> <tr> <th>Format: REGISTER.SET &lt;register&gt; &lt;value&gt;</th> </tr> </thead> <tbody> <tr> <td>&lt;register&gt;: r0, r1, pc,...</td> </tr> <tr> <td>&lt;value&gt;: 0x4, 20, 1, 0xf, 0,...</td> </tr> </tbody> </table> This command set a given value into the selected register. The register names different for each processor architecture. 11. Set a breakpoint at address command. <table> <thead> <tr> <th>Format: BREAK.SET &lt;address&gt;</th> </tr> </thead> <tbody> <tr> <td>&lt;address&gt;: 0xff000000, 0xbc80a000,...</td> </tr> </tbody> </table> Command useful for observing system behavior in certain program spots. Without parameters the command opens a dialog window for setting breakpoints. 12. Sets a value with a specified width, at the selected address command. Format: **DATA.SET** <address> <width> <value> <address>: 0xff000000, 0xbc80a000,... <width>: %byte,%word,%long,... :value>: 0x4,20,1,0xf,0,... This command allows to set the memory area value. For example, registers are reset from selected area simultaneously or overwritten any other value. 13. Opens the specified PER file command. Format: **PER** <path to per file> <path to per file>: ../per/c64.per, C:/arm/per/ARM9.per,... Command opens PER file under the specified location. The peripherals of integrated microcontrollers can be displayed and manipulated with the command **PER**. The command offers a free configurable window for displaying memory or i/o structures. So it is possible to display the state of peripheral chips or memory based structures very comfortably. 14. Introduce program code into the simulator command. Format: **DATA.PROGRAM** <address> <path to asm file> <address>: 0xff000000, 0xbc80a000,... <path to per file>: ../program.asm, C:/code/program.asm,... This command creates a window for editing and assembling a short assembler program. Without a specified filename the file T32.ASM is generated. If the Compile button is used, syntax errors and undefined labels will be detected. The resulting program will be assembled for the specified address and saved to memory. The labels entered will be added to the symbol list. Peripheral model example Practical example of timer simulating model is designed to show the whole process of programming, implementation and maintenance. Environment Follow these steps: In Visual Studio create ‘New Project’ by choosing File -> New -> Project.... In a “New Project” window, select Win32 -> Win32 Console Application In ‘Name’ field, enter the name of new model (in this case is a “timer”). In ‘Location’ field, enter model location (in this case is a “C:\timer”). Click Ok button to proceed. In “Win32 Application Wizard” window, click on ‘Application Settings’ then select DLL as ‘Application type’ and click Finish button. Once our programming environment is ready, we need to create a files structure of our model. The project consists of 4 source files: simul.h, simul.c and created by us files “model_name”.c and “model_name”.def To 'Source Files' add: simul.c, 'model_name'.c and 'model_name'.def (Module Definition File). To Header files add: simul.h. Content 'model_name'.def file should look like this: ``` LIBRARY simple_port DESCRIPTION 'TRACE32 Hardware Simulation Model' EXPORTS SIMUL_Interface ``` After adding all required files structure should look like this: ![Microsoft Development Environment](image) Source code listing First what designer need to do, is to include a “simul.h” library, which contains all necessary functions. For better readability of the code, registers offsets should be defined as “short_name”_OFFSET. Base address should be also defined as “module_name”_BASE. “NUM_OF_REGS” definition specifies a number of registers in the module. Example: ``` #include "simul.h" #define NUM_OF_REGS 5 #define COUNT_OFFSET 0x0000 #define CTR_OFFSET 0x0004 #define SVAL_OFFSET 0x0008 #define EVAL_OFFSET 0x000c #define IR_OFFSET 0x0010 #define TIMER0_BASE 0xFF000000 ``` Type definition of 32 bits width register ```c typedef struct { simulWord32 count, ctr, sval, eval, ir; } Regs; ``` ```c typedef struct { simulWord32 startaddress; int bustype, reset, work, intport, chport; Regs regs; simulTime ctimestamp; void * ptimer; } Timer; ``` Function declaration used to link registers offsets with module base address. Inside there are previously defined registries offsets. **SimulWord32** specifies variables type. ```c static simulWord32 regs_offset[NUM_OF_REGS] = { COUNT_OFFSET, CTR_OFFSET, SVAL_OFFSET, EVAL_OFFSET, IR_OFFSET }; ``` Function declaration used to write values in selected register. Variables have to be related to the module registers. ```c void * regwrite_func[NUM_OF_REGS] = { COUNT_Write, CTR_Write, SVAL_Write, EVAL_Write, IR_Write }; ``` Function declaration used to read values from selected register. Variables have to be related to the module registers. ```c void * regread_func[NUM_OF_REGS] = { COUNT_Read, CTR_Read, SVAL_Read, EVAL_Read, IR_Read }; ``` Registers initialization function. Each register is linked to module base address by "for" loop and calls two callback functions. First one is responsible for writing and second one is responsible for reading registers values. ```c static void Regs_Init(simulProcessor processor, Timer * timer) { simulWord from, to; int i; for (i = 0; i < NUM_OF_REGS; i++) { from = timer->startaddress + regs_offset[i]; to = from + 3; SIMUL_RegisterBusWriteCallback(processor, regwrite_func[i], (simulPtr) timer, timer->bustype, &from, &to); SIMUL_RegisterBusReadCallback(processor, regread_func[i], (simulPtr) timer, timer->bustype, &from, &to); } } ``` Write function for a particular register. This function have to be attributed to each register of access type as WRITE or READ/WRITE. ```c static int SIMULAPI COUNT_Write(simulProcessor processor, simulCallbackStruct * cbs, simulPtr private) { Timer * timer = (Timer*) private; SIMUL_InsertWord(processor, &timer->regs.count, 32, &cbs->x.bus.address, cbs->x.bus.width, &cbs->x.bus.data); return SIMUL_MEMORY_OK; } ``` Read function for a particular registry. This function have to be attributed to each register of access type as READ or READ/WRITE. Note: If register is visible in TRACE32 window, then function is called with each step. ```c static int SIMULAPI COUNT_Read(simulProcessor processor, simulCallbackStruct * cbs, simulPtr private) { Timer * timer = (Timer*) private; SIMUL_ExtractWord(processor, &timer->regs.count, 32, &cbs->x.bus.address, cbs->x.bus.width, &cbs->x.bus.data); return SIMUL_MEMORY_OK; } ``` In write function, you can place a direct function of the register handle i.e. operations on the register are performed at the same cycle as at write to it. All operations are performed on variable such as “reg” and a result is assigned to the register. ```c /* CTR (Control Register) */ static int SIMULAPI CTR_Write(simulProcessor processor, simulCallbackStruct * cbs, simulPtr private) { Timer * timer = (Timer*) private; simulWord32 reg; SIMUL_InsertWord(processor, &reg, 32, &cbs->x.bus.address, cbs->x.bus.width, &cbs->x.bus.data); if (reg & 0x2) /* Timer reset */ { timer->regs.count = 0x0; reg = 0x0; timer->regs.sval = 0x0; timer->regs.eval = 0x0; } if (((reg & 0x70)==0x20)||((reg & 0x70)==0x60)) { timer->work=1; } timer->regs.ctr = reg & 0xffffffff; return SIMUL_MEMORY_OK; } ``` Function returns "SIMUL_MEMORY_OK". Timer handle function. The operations are executed with each step. Inside this function is implemented: increment / decrement value of the register, bit masks, etc. For example, in place of stars may be located functions corresponding to the various modes of timer. By setting the corresponding bits in Control register, different operating modes are selected. ```c /* --- IntReq timer --- */ int SIMULAPI IntReqTimer(simulProcessor processor, simulCallbackStruct * cbs, simulPtr private) { Timer * timer = (Timer*) private; simulWord data; if (timer->regs.ctr & 0x1) /* Timer enabled */ { timer->regs.count++; } switch ((timer->regs.ctr >> 4) & 0x7) { case 0x0: * * * * break; * * * * } return SIMUL_TIMER_OK; } ``` Function returns "SIMUL_TIMER_OK". Ports are used for communication between models. Each port has its own number and may take a state of 0 or 1. Port -2 enables interruption of processor. To enable interruption, set ‘1’ on port, so then after a fulfillment of a condition, port will be on ‘1’. In `Intport` variable stores interruption port number. ```c if ((timer->regs.ir)) { data = 1; SIMUL_SetPort(processor, timer->intport, 1, &data); } ``` After interrupt handling is completed, exit from interrupt have to be done by clearing a state of port responsible for it. ```c /* IR (IR Register) */ timer->regs.ir &= ~(reg & 0xff); if (!timer->regs.ir) /* deassert interrupt */ { simulWord data = 0; SIMUL_SetPort(processor, timer->intport, 1, &data); } ``` Function responsible for a timer reset is called after model initialized. Because `TIMER_Reset` function is called after initialization, simulation timer (not timer PSM) can be started by `SIMUL_StartTimer` function. Depending on module needs, different controls flags can be used. Presented timer model uses two flags `SIMUL_TIMER_REPEAT` and `SIMUL_TIMER_CLOCKS`. `SIMUL_GetClock` function returns number of clock cycles since the beginning of the simulation, increasing on each step. ```c static int SIMULAPI TIMER_Reset(simulProcessor processor, simulCallbackStruct * cbs, simulPtr private) { Timer * timer = (Timer*) private; simulTime time, nowtime; memset(&timer->regs, 0x00, sizeof(timer->regs)); timer->reset = 0; SIMUL_GetClock(processor, 0, &nowtime); time = 1; SIMUL_StartTimer(processor, timer->ptimer, SIMUL_TIMER_REPEAT | SIMUL_TIMER_CLOCKS, &time); return SIMUL_RESET_OK; } ``` Function returns "SIMUL_RESET_OK". The most important in simulation module is initialization function. Is called only once at the very beginning. All callback function here are placed. In presented timer model, `SIMUL_RegisterResetCallback` function responsible for a timer reset and `Regs_Init` function responsible for events handling in the registers, have been called. There are also declarations of variables. Because there are no global variables in a model, function `SIMUL_Alloc` is used. ```c int SIMULAPI SIMUL_Init(simulProcessor processor, simulCallbackStruct * cbs) { Timer * timer; int i; strcpy(cbs->x.init.modelname, __DATE__ " Timer Model"); timer = (Timer*) SIMUL_Alloc(processor, sizeof(Timer)); timer->bustype = 0; timer->intport = -2; timer->startaddress = TIMER0_BASE; Regs_Init(processor, timer); SIMUL_RegisterResetCallback(processor, TIMER_Reset, (simulPtr) timer); timer->ptimer = SIMUL_RegisterTimerCallback(processor, IntReqTimer, (simulPtr) timer); TIMER_Reset(processor, cbs, timer); return SIMUL_INIT_OK; } ``` Function returns "SIMUL_INIT_OK". Each model can be called with parameters. Correct handling of model parameters must be ensured. The "i" variable specifies the number of checked parameters (depending on needs of simulation model). Presented timer is set (by default) to base address stored in \texttt{TIMER0\_BASE} variable (under condition that as a first parameter is "timer" string), but if necessary it can be overwritten with any other value. Second parameter is the number of port (responsible for interrupt). By default value is stored in variable and is equal "-2" but if necessary it can be overwritten with any other value. Function at the end calls warning function, which is designed to notify module parameters. ```c for (i = 1; i <= cbs->x.init.argc - 1; i++) { if (i == 1) { if (strstr(cbs->x.init.argp[1], "timer") != NULL) timer->startaddress = TIMER0_BASE; else timer->startaddress = cbs->x.init.argppport[1]; continue; } else if (i == 2) { if (strstr(cbs->x.init.argp[2], "cpu") != NULL) timer->intport = SIMUL\_PORT\_INTERRUPT; else if (strstr(cbs->x.init.argp[2], "noport") == NULL) timer->intport = cbs->x.init.argppport[2]; continue; } SIMUL\_Warning(processor, "usage parameters: [<base address|name> <interrupt port>]"); return SIMUL\_INIT\_FAIL; } ``` Initialization scripts Following script provides settings for TRACE32 environment. The script contains a set of commands to run timer with initial settings such as work mode, initial and final value of incremented register, interrupt options, etc. The script also contains commands for opening and distribution of appropriate windows in TRACE32. The script should look like this: Header of script contains such data as module name, developer, major functions, etc. ```plaintext ; 'TIMER' Model Initialization Script ; DATA (NICK) ; ; A brief comment on the specific characteristics (ports) [not required] ; Sim.unload command is used to clean the memory configuration for a simulation model. After sim.load command should be a path to dll library that contains implemented module. ```plaintext ; --- Timer initialization script --- sim.unload sim.load ../timer/Debug/timer.dll "timer" "cpu" per ../per/timer.per sys.up d.l ``` This sequence allows to set model in infinite loop, after 3 steps. ```plaintext ; --- processor infinite loop --- d.a 0x0 nop d.a 0x4 nop d.a 0x8 b $ - 8; infinite loop ``` When interrupt event occurred, interrupt have to be handled and exit. At the time of interrupt event, program jumps to 0x18 address where is procedure to clear interrupt. In next step program return to an infinite loop. ``` ; --- interrupt service routine --- d.a 0x18 str r0, [r1, #0x10]; clear interrupt flag d.a 0x1c subs pc, r14, #4; return from interrupt ``` Configuration for ARM core. Set program counter to 0x0 value. The register r0 holds value to be entered in the “interrupt register”. The register r1 holds timer base address. ``` ; --- ARM core configuration --- r.s pc 0x0; set program counter to 0x0 r.s r0 0x1; value to write to register r.s r1 0xff000000; base address of Timer ``` Configure timer registers. Set timer to appropriate operating mode determines the initial and final value (depending on the mode) and begins counting. ``` ; --- Timer configuration --- d.s d:0xff000004 %l 0x59; timer enable,loop,from sval to eval d.s d:0xff000008 %l 0x00; start value d.s d:0xff00000c %l 0x20; end value r.s I 0; enable interrupts b.s 0x18; set breakpoint on beginning of interrupt ``` For better visibility, set windows position in TRACE32. The easiest way to do it is deploy windows as intended and then save the settings by clicking on the bookmark Window / Store Windows to.... Initialized model has a preview of all functions. Windows position settings can be copied to the initialization script. ``` B:: TOOLBAR ON STATUSBAR ON WINPAGE.RESET WINCLEAR WINPOS 0.0 19.154 70. 4. 15. 1. W001 d.dump 0xff000000--0xff00000f WINPOS 0.0 0.0 56. 14. 15. 1. W002 WINTABS 10. 10. 25. 62. d.l WINPOS 58.857 12.077 47. 13. 0. 0. W000 per ../per/timer.per WINPOS 60.143 0.23077 46. 9. 0. 0. W003 r WINPAGE.SELECT P000 enddo ```
{"Source-Url": "http://www2.lauterbach.com/pdf/simulator_api.pdf", "len_cl100k_base": 10721, "olmocr-version": "0.1.53", "pdf-total-pages": 39, "total-fallback-pages": 0, "total-input-tokens": 61340, "total-output-tokens": 11903, "length": "2e13", "weborganizer": {"__label__adult": 0.0006070137023925781, "__label__art_design": 0.0006780624389648438, "__label__crime_law": 0.00028967857360839844, "__label__education_jobs": 0.00044655799865722656, "__label__entertainment": 0.0001266002655029297, "__label__fashion_beauty": 0.0002624988555908203, "__label__finance_business": 0.0002684593200683594, "__label__food_dining": 0.0005545616149902344, "__label__games": 0.0022430419921875, "__label__hardware": 0.036834716796875, "__label__health": 0.0003647804260253906, "__label__history": 0.00033664703369140625, "__label__home_hobbies": 0.00025963783264160156, "__label__industrial": 0.00197601318359375, "__label__literature": 0.00022530555725097656, "__label__politics": 0.0002384185791015625, "__label__religion": 0.0007405281066894531, "__label__science_tech": 0.049774169921875, "__label__social_life": 5.2928924560546875e-05, "__label__software": 0.0167694091796875, "__label__software_dev": 0.88525390625, "__label__sports_fitness": 0.0004544258117675781, "__label__transportation": 0.0008192062377929688, "__label__travel": 0.0002338886260986328}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 41854, 0.01995]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 41854, 0.73994]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 41854, 0.73492]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 1341, false], [1341, 2518, null], [2518, 3179, null], [3179, 3604, null], [3604, 5322, null], [5322, 6644, null], [6644, 8317, null], [8317, 9876, null], [9876, 11198, null], [11198, 13127, null], [13127, 14730, null], [14730, 16017, null], [16017, 17347, null], [17347, 18527, null], [18527, 19205, null], [19205, 20120, null], [20120, 21731, null], [21731, 22642, null], [22642, 23093, null], [23093, 24190, null], [24190, 25306, null], [25306, 26953, null], [26953, 28411, null], [28411, 29062, null], [29062, 29272, null], [29272, 29550, null], [29550, 30241, null], [30241, 31070, null], [31070, 32447, null], [32447, 34040, null], [34040, 34746, null], [34746, 35507, null], [35507, 36473, null], [36473, 37571, null], [37571, 38949, null], [38949, 40060, null], [40060, 41414, null], [41414, 41854, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 1341, true], [1341, 2518, null], [2518, 3179, null], [3179, 3604, null], [3604, 5322, null], [5322, 6644, null], [6644, 8317, null], [8317, 9876, null], [9876, 11198, null], [11198, 13127, null], [13127, 14730, null], [14730, 16017, null], [16017, 17347, null], [17347, 18527, null], [18527, 19205, null], [19205, 20120, null], [20120, 21731, null], [21731, 22642, null], [22642, 23093, null], [23093, 24190, null], [24190, 25306, null], [25306, 26953, null], [26953, 28411, null], [28411, 29062, null], [29062, 29272, null], [29272, 29550, null], [29550, 30241, null], [30241, 31070, null], [31070, 32447, null], [32447, 34040, null], [34040, 34746, null], [34746, 35507, null], [35507, 36473, null], [36473, 37571, null], [37571, 38949, null], [38949, 40060, null], [40060, 41414, null], [41414, 41854, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 41854, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 41854, null]], "pdf_page_numbers": [[0, 0, 1], [0, 1341, 2], [1341, 2518, 3], [2518, 3179, 4], [3179, 3604, 5], [3604, 5322, 6], [5322, 6644, 7], [6644, 8317, 8], [8317, 9876, 9], [9876, 11198, 10], [11198, 13127, 11], [13127, 14730, 12], [14730, 16017, 13], [16017, 17347, 14], [17347, 18527, 15], [18527, 19205, 16], [19205, 20120, 17], [20120, 21731, 18], [21731, 22642, 19], [22642, 23093, 20], [23093, 24190, 21], [24190, 25306, 22], [25306, 26953, 23], [26953, 28411, 24], [28411, 29062, 25], [29062, 29272, 26], [29272, 29550, 27], [29550, 30241, 28], [30241, 31070, 29], [31070, 32447, 30], [32447, 34040, 31], [34040, 34746, 32], [34746, 35507, 33], [35507, 36473, 34], [36473, 37571, 35], [37571, 38949, 36], [38949, 40060, 37], [40060, 41414, 38], [41414, 41854, 39]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 41854, 0.13398]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
b1e59e3d50fa6fdfae1adae3005d42f0a6e079e1
Package ‘ivreg’ October 13, 2022 Title Instrumental-Variables Regression by ‘2SLS’, ‘2SM’, or ‘2SMM’, with Diagnostics Version 0.6-1 Description Instrumental variable estimation for linear models by two-stage least-squares (2SLS) regression or by robust-regression via M-estimation (2SM) or MM-estimation (2SMM). The main ivreg() model-fitting function is designed to provide a workflow as similar as possible to standard lm() regression. A wide range of methods is provided for fitted ivreg model objects, including extensive functionality for computing and graphing regression diagnostics in addition to other standard model tools. License GPL (>= 2) Depends R (>= 3.6.0) Imports car (>= 3.0-9), Formula, lmtest, MASS, stats Suggests AER, effects (>= 4.2.0), knitr, insight, parallel, rmarkdown, sandwich, testthat, modelsummary, ggplot2 Encoding UTF-8 LazyData true VignetteBuilder knitr BugReports https://github.com/john-d-fox/ivreg/issues/ URL https://john-d-fox.github.io/ivreg/ RoxygenNote 7.1.2 NeedsCompilation no Author John Fox [aut, cre] (<https://orcid.org/0000-0002-1196-8012>), Christian Kleiber [aut] (<https://orcid.org/0000-0002-6781-4733>), Achim Zeileis [aut] (<https://orcid.org/0000-0003-0918-3766>), Nikolas Kuschnig [ctb] (<https://orcid.org/0000-0002-6642-2543>) Maintainer John Fox <jfox@mcmaster.ca> Repository CRAN Date/Publication 2021-10-15 09:10:05 UTC R topics documented: CigaretteDemand ......................................................... 2 coef.ivreg ............................................................. 4 influence.ivreg ......................................................... 7 ivreg ................................................................. 12 ivreg.fit ............................................................ 15 Kmenta ................................................................. 18 SchoolingReturns ....................................................... 19 Index ........................................................................... 22 CigaretteDemand U.S. Cigarette Demand Data Description Usage data("CigaretteDemand", package = "ivreg") Format A data frame with 48 rows and 10 columns. packs Number of cigarette packs per capita sold in 1995. rprice Real price in 1995 (including sales tax). rincome Real per capita income in 1995. salestax Sales tax in 1995. cigtax Cigarette-specific taxes (federal and average local excise taxes) in 1995. salestaxdiff Difference in salestax (between 1995 and 1985). cigtaxdiff Difference in cigtax (between 1995 and 1985). Details The data are taken from the online complements to Stock and Watson (2007) and had been prepared as panel data (in long form) in CigarettesSW from the AER package (Kleiber and Zeileis 2008). Here, the data are provided by state (in wide form), readily preprocessed to contain all variables needed for illustrations of OLS and IV regressions. More related examples from Stock and Watson (2007) are provided in the AER package in StockWatson2007. A detailed discussion of the various cigarette demand examples with R code is provided by Hanck et al. (2020, Chapter 12). CigaretteDemand Source Online complements to Stock and Watson (2007). References See Also CigarettesSW. Examples ```r ## load data data("CigaretteDemand", package = "ivreg") ## basic price elasticity: OLS vs. IV cig_ols <- lm(log(packs) ~ log(rprice), data = CigaretteDemand) cig_iv <- ivreg(log(packs) ~ log(rprice) | salestax, data = CigaretteDemand) cbind(OLS = coef(cig_ols), IV = coef(cig_iv)) ## adjusting for income differences (exogenous) cig_iv2 <- ivreg(log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome), data = CigaretteDemand) ## adding a second instrument for log(rprice) cig_iv3 <- update(cig_iv2, . ~ . | . + cigtax) ## comparison using heteroscedasticity-consistent standard errors library("lmtest") library("sandwich") coeftest(cig_iv2, vcov = vcovHC, type = "HC1") coeftest(cig_iv3, vcov = vcovHC, type = "HC1") ## long-run price elasticity using differences between 1995 and 1985 cig_ivdiff1 <- ivreg(packsdiff ~ pricediff + incomediff + salestaxdiff, data = CigaretteDemand) cig_ivdiff2 <- update(cig_ivdiff1, . ~ . | . - salestaxdiff + cigtaxdiff) cig_ivdiff3 <- update(cig_ivdiff1, . ~ . | . + cigtaxdiff) coeftest(cig_ivdiff1, vcov = vcovHC, type = "HC1") coeftest(cig_ivdiff2, vcov = vcovHC, type = "HC1") coeftest(cig_ivdiff3, vcov = vcovHC, type = "HC1") ``` Description Various methods for processing "ivreg" objects; for diagnostic methods, see ivregDiagnostics. Usage ## S3 method for class 'ivreg' coef(object, component = c("stage2", "stage1"), complete = TRUE, ...) ## S3 method for class 'ivreg' vcov(object, component = c("stage2", "stage1"), complete = TRUE, ...) ## S3 method for class 'ivreg' confint( object, parm, level = 0.95, component = c("stage2", "stage1"), complete = TRUE, vcov. = NULL, df = NULL, ...) ## S3 method for class 'ivreg' bread(x, ...) ## S3 method for class 'ivreg' estfun(x, ...) ## S3 method for class 'ivreg' vcovHC(x, ...) ## S3 method for class 'ivreg' terms(x, component = c("regressors", "instruments", "full"), ...) ## S3 method for class 'ivreg' model.matrix( object, component = c("regressors", "projected", "instruments"), ...) ## S3 method for class 'ivreg_projected' model.matrix(object, ...) ## S3 method for class 'ivreg' predict( object, newdata, type = c("response", "terms"), na.action = na.pass, ...) ## S3 method for class 'ivreg' print(x, digits = max(3, getOption("digits") - 3), ...) ## S3 method for class 'ivreg' summary(object, vcov. = NULL, df = NULL, diagnostics = NULL, ...) ## S3 method for class 'summary.ivreg' print(x, digits = max(3, getOption("digits") - 3), signif.stars = getOption("show.signif.stars"), ... ) ## S3 method for class 'ivreg' anova(object, object2, test = "F", vcov. = NULL, ...) ## S3 method for class 'ivreg' update(object, formula., ..., evaluate = TRUE) ## S3 method for class 'ivreg' residuals( object, type = c("response", "projected", "regressors", "working", "deviance", "pearson", "partial", "stage1"), ... ) ## S3 method for class 'ivreg' Effect(focal.predictors, mod, ...) ## S3 method for class 'ivreg' formula(x, component = c("complete", "regressors", "instruments"), ...) ## S3 method for class 'ivreg' find_formula(x, ...) Arguments object, object2, model, mod An object of class "ivreg". component For terms, "regressors", "instruments", or "full"; for model.matrix, "projected", "regressors", or "instruments"; for formula, "regressors", "instruments", or "complete"; for coef and vcov, "stage2" or "stage1". complete If TRUE, the default, the returned coefficient vector (for coef()) or coefficient-covariance matrix (for vcov) includes elements for aliased regressors. ... arguments to pass down. parm parameters for which confidence intervals are to be computed; a vector or numbers or names; the default is all parameters. level confidence level; the default is 0.95. vcov. Optional coefficient covariance matrix, or a function to compute the covariance matrix, to use in computing the model summary. df Optional residual degrees of freedom to use in computing model summary. x An object of class "ivreg" or "summary.ivreg". newdata Values of predictors for which to obtain predicted values. type For predict, one of "response" (the default) or "terms"; for residuals, one of "response" (the default), "projected", "regressors", "working", "deviance", "pearson", or "partial"; type = "working" and "response" are equivalent, as are type = "deviance" and "pearson"; for weights, "variance" (the default) for invariance-variance weights (which is NULL for an unweighted fit) or "robustness" for robustness weights (available for M or MM estimation). Methods for computing deletion and other regression diagnostics for 2SLS regression. It's generally more efficient to compute the deletion diagnostics via the influence method and then to extract the various specific diagnostics with the methods for "influence.ivreg" objects. Other diagnostics for linear models, such as added-variable plots (avPlots) and component-plus-residual plots (crPlots), also work, as do effect plots (e.g., predictorEffects) with residuals (see the examples below). The pointwise confidence envelope for the qqPlot method assumes an independent random sample from the t distribution with degrees of freedom equal to the residual degrees of freedom for the model and so are approximate, because the studentized residuals aren't independent. For additional information, see the vignette Diagnostics for 2SLS Regression. Usage ```r ## S3 method for class 'ivreg' influence( model, sigma. = n <= 1000, )``` ```r influence.ivreg type = c("stage2", "both", "maximum"), applyfun = NULL, ncores = NULL, ... ## S3 method for class 'ivreg' rstudent(model, ...) ## S3 method for class 'ivreg' cooks.distance(model, ...) ## S3 method for class 'influence.ivreg' dfbeta(model, ...) ## S3 method for class 'ivreg' dfbeta(model, ...) ## S3 method for class 'ivreg' hatvalues(model, type = c("stage2", "both", "maximum", "stage1"), ...) ## S3 method for class 'influence.ivreg' rstudent(model, ...) ## S3 method for class 'influence.ivreg' hatvalues(model, ...) ## S3 method for class 'influence.ivreg' cooks.distance(model, ...) ## S3 method for class 'influence.ivreg' qqPlot( x, ylab = paste("Studentized Residuals(" , deparse(substitute(x)), ")", sep = ""), distribution = c("t", "norm"), ... ) ## S3 method for class 'ivreg' influencePlot(x, ...) ## S3 method for class 'influence.ivreg' influencePlot(model, ...) ## S3 method for class 'ivreg' infIndexPlot(model, ...) ## S3 method for class 'influence.ivreg' ``` infIndexPlot(model, ...) ## S3 method for class 'influence.ivreg' model.matrix(object, ...) ## S3 method for class 'ivreg' avPlots(model, terms, ...) ## S3 method for class 'ivreg' avPlot(model, ...) ## S3 method for class 'ivreg' mcPlots(model, terms, ...) ## S3 method for class 'ivreg' mcPlot(model, ...) ## S3 method for class 'ivreg' Boot( object, f = coef, labels = names(f(object)), R = 999, method = "case", ncores = 1, ... ) ## S3 method for class 'ivreg' crPlots(model, terms, ...) ## S3 method for class 'ivreg' crPlot(model, ...) ## S3 method for class 'ivreg' ceresPlots(model, terms, ...) ## S3 method for class 'ivreg' ceresPlot(model, ...) ## S3 method for class 'ivreg' plot(x, ...) ## S3 method for class 'ivreg' qqPlot(x, distribution = c("t", "norm"), ...) ## S3 method for class 'ivreg' outlierTest(x, ...) ## S3 method for class 'ivreg' influencePlot(x, ...) ## S3 method for class 'ivreg' spreadLevelPlot(x, main = "Spread-Level Plot", ...) ## S3 method for class 'ivreg' ncvTest(model, ...) ## S3 method for class 'ivreg' deviance(object, ...) ## S3 method for class 'rivreg' influence(model, ...) ### Arguments `model`, `x`, `object` A "ivreg" or "influence.ivreg" object. `sigma` If TRUE (the default for 1000 or fewer cases), the deleted value of the residual standard deviation is computed for each case; if FALSE, the overall residual standard deviation is used to compute other deletion diagnostics. `type` If "stage2" (the default), hatvalues are for the second stage regression; if "both", the hatvalues are the geometric mean of the casewise hatvalues for the two stages; if "maximum", the hatvalues are the larger of the casewise hatvalues for the two stages. In computing the geometric mean or casewise maximum hatvalues, the hatvalues for each stage are first divided by their average (number of coefficients in stage regression/number of cases); the geometric mean or casewise maximum values are then multiplied by the average hatvalue from the second stage. `applyfun` Optional loop replacement function that should work like `lapply` with arguments `function(X, FUN, ...)`. The default is to use a loop unless the `ncores` argument is specified (see below). `ncores` Numeric, number of cores to be used in parallel computations. If set to an integer the applyfun is set to use either `parLapply` (on Windows) or `mclapply` (otherwise) with the desired number of cores. `...` Arguments to be passed down. `ylab` The vertical axis label. `distribution` "t" (the default) or "norm". `terms` Terms for which added-variable plots are to be constructed; the default, if the argument isn’t specified, is the "regressors" component of the model formula. `f, labels, R` see `Boot`. `method` only "case" (case resampling) is supported: see `Boot`. `main` Main title for the graph. **influence.ivreg** **Value** In the case of `influence.ivreg`, an object of class "influence.ivreg" with the following components: - **coefficients** the estimated regression coefficients - **model** the model matrix - **dfbeta** influence on coefficients - **sigma** deleted values of the residual standard deviation - **dffits** overall influence on the regression coefficients - **cookd** Cook's distances - **hatvalues** hatvalues - **rstudent** Studentized residuals - **df.residual** residual degrees of freedom In the case of other methods, such as `rstudent.ivreg` or `rstudent.influence.ivreg`, the corresponding diagnostic statistics. Many other methods (e.g., `crPlot.ivreg`, `avPlot.ivreg`, `Effect.ivreg`) draw graphs. **See Also** - `ivreg`, `avPlots`, `crPlots`, `predictorEffects`, `qqPlot`, `influencePlot`, `infIndexPlot`, `Boot`, `outlierTest`, `spreadLevelPlot`, `ncvTest`. **Examples** ```r kmenta.eq1 <- ivreg(Q ~ P + D | D + F + A, data = Kmenta) summary(kmenta.eq1) car::avPlots(kmenta.eq1) car::mcPlots(kmenta.eq1) car::crPlots(kmenta.eq1) car::ceresPlots(kmenta.eq1) car::influencePlot(kmenta.eq1) car::influenceIndexPlot(kmenta.eq1) car::qqPlot(kmenta.eq1) car::spreadLevelPlot(kmenta.eq1) plot(effects::predictorEffects(kmenta.eq1, residuals = TRUE)) set.seed <- 12321 # for reproducibility confint(car::Boot(kmenta.eq1, R = 250)) # 250 reps for brevity car::outlierTest(kmenta.eq1) car::ncvTest(kmenta.eq1) ``` **Description** Fit instrumental-variable regression by two-stage least squares (2SLS). This is equivalent to direct instrumental-variables estimation when the number of instruments is equal to the number of regressors. Alternative robust-regression estimators are also provided, based on M-estimation (2SM) and MM-estimation (2SMM). **Usage** ```r ivreg( formula, instruments, data, subset, na.action, weights, offset, contrasts = NULL, model = TRUE, y = TRUE, x = FALSE, method = c("OLS", "M", "MM"), ... ) ``` **Arguments** - `formula, instruments` formula specification(s) of the regression relationship and the instruments. Either `instruments` is missing and `formula` has three parts as in `y ~ x1 + x2 | z1 + z2 + z3` (recommended) or `formula` is `y ~ x1 + x2` and `instruments` is a one-sided formula `~ z1 + z2 + z3` (only for backward compatibility). - `data` an optional data frame containing the variables in the model. By default the variables are taken from the environment of the `formula`. - `subset` an optional vector specifying a subset of observations to be used in fitting the model. - `na.action` a function that indicates what should happen when the data contain NAs. The default is set by the `na.action` option. - `weights` an optional vector of weights to be used in the fitting process. - `offset` an optional offset that can be used to specify an a priori known component to be included during fitting. - `contrasts` an optional list. See the `contrasts.arg` of `model.matrix.default`. model, x, y logicals. If TRUE the corresponding components of the fit (the model frame, the model matrices, the response) are returned. These components are necessary for computing regression diagnostics. method the method used to fit the stage 1 and 2 regression: "OLS" for traditional 2SLS regression (the default), "M" for M-estimation, or "MM" for MM-estimation, with the latter two robust-regression methods implemented via the rlm function in the MASS package. ... further arguments passed to ivreg.fit. Details ivreg is the high-level interface to the work-horse function ivreg.fit. A set of standard methods (including print, summary, vcov, anova, predict, residuals, terms, model.matrix, bread, estfun) is available and described in ivregMethods. For methods related to regression diagnostics, see ivregDiagnostics. Regressors and instruments for ivreg are most easily specified in a formula with two parts on the right-hand side, e.g., y ~ x1 + x2 | z1 + z2 + z3, where x1 and x2 are the explanatory variables and z1, z2, and z3 are the instrumental variables. Note that exogenous regressors have to be included as instruments for themselves. For example, if there is one exogenous regressor ex and one endogenous regressor en with instru- ment in, the appropriate formula would be y ~ en + ex | in + ex. Alternatively, a formula with three parts on the right-hand side can also be used: y ~ ex | en | in. The latter is typically more convenient, if there is a large number of exogenous regressors. Moreover, two further equivalent specification strategies are possible that are typically less con- venient compared to the strategies above. One option is to use an update formula with a . in the second part of the formula is used: y ~ en + ex | . - en + in. Another option is to use a separate formula for the instruments (only for backward compatibility with earlier versions): formula = y ~ en + ex, instruments = ~ in + ex. Internally, all specifications are converted to the version with two parts on the right-hand side. Value ivreg returns an object of class "ivreg" that inherits from class "lm", with the following compo- nents: coefficients parameter estimates, from the stage-2 regression. residuals vector of model residuals. residuals1 matrix of residuals from the stage-1 regression. residuals2 vector of residuals from the stage-2 regression. fitted.values vector of predicted means for the response. weights either the vector of weights used (if any) or NULL (if none). offset either the offset used (if any) or NULL (if none). estfun a matrix containing the empirical estimating functions. n number of observations. nobs number of observations with non-zero weights. number of columns in the model matrix $x$ of regressors. $q$ number of columns in the instrumental variables model matrix $z$ $\text{rank}$ numeric rank of the model matrix for the stage-2 regression. $\text{df.residual}$ residual degrees of freedom for fitted model. $\text{cov.unscaled}$ unscaled covariance matrix for the coefficients. $\text{sigma}$ residual standard deviation. $\text{qr}$ QR decomposition for the stage-2 regression. $\text{qr1}$ QR decomposition for the stage-1 regression. $\text{rank1}$ numeric rank of the model matrix for the stage-1 regression. $\text{coefficients1}$ matrix of coefficients from the stage-1 regression. $\text{df.residual1}$ residual degrees of freedom for the stage-1 regression. $\text{exogenous}$ columns of the "regressors" matrix that are exogenous. $\text{endogenous}$ columns of the "regressors" matrix that are endogenous. $\text{instruments}$ columns of the "instruments" matrix that are instruments for the endogenous variables. $\text{method}$ the method used for the stage 1 and 2 regressions, one of "OLS", "M", or "MM". $\text{rweights}$ a matrix of robustness weights with columns for each of the stage-1 regressions and for the stage-2 regression (in the last column) if the fitting method is "M" or "MM", NULL if the fitting method is "OLS". $\text{hatvalues}$ a matrix of hatvalues. For method = "OLS", the matrix consists of two columns, for each of the stage-1 and stage-2 regression; for method = "M" or "MM", there is one column for each stage=1 regression and for the stage-2 regression. $\text{df.residual}$ residual degrees of freedom for fitted model. $\text{call}$ the original function call. $\text{formula}$ the model formula. $\text{na.action}$ function applied to missing values in the model fit. $\text{terms}$ a list with elements "regressors" and "instruments" containing the terms objects for the respective components. $\text{levels}$ levels of the categorical regressors. $\text{contrasts}$ the contrasts used for categorical regressors. $\text{model}$ the full model frame (if $\text{model} = \text{TRUE}$). $y$ the response vector (if $y = \text{TRUE}$). $x$ a list with elements "regressors", "instruments", "projected", containing the model matrices from the respective components (if $x = \text{TRUE}$). "projected" is the matrix of regressors projected on the image of the instruments. References See Also ivreg.fit, ivregDiagnostics, ivregMethods, lm, lm.fit Examples ``` ## data data("CigaretteDemand", package = "ivreg") ## model m <- ivreg(log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome), data = CigaretteDemand) summary(m) summary(m, vcov = sandwich::sandwich, df = Inf) ## ANOVA m2 <- update(m, . ~ . - log(rincome) | . - log(rincome)) anova(m, m2) car::Anova(m) ## same model specified by formula with three-part right-hand side ivreg(log(packs) ~ log(rincome) | log(rprice) | salestax, data = CigaretteDemand) # Robust 2SLS regression data("Kmenta", package = "ivreg") Kmenta1 <- Kmenta Kmenta1[20, "Q"] <- 95 # corrupted data deq <- ivreg(Q ~ P + D | D + F + A, data=Kmenta) # demand equation, uncorrupted data deq1 <- ivreg(Q ~ P + D | D + F + A, data=Kmenta1) # standard 2SLS, corrupted data deq2 <- ivreg(Q ~ P + D | D + F + A, data=Kmenta1, subset=-20) # standard 2SLS, removing bad case deq3 <- ivreg(Q ~ P + D | D + F + A, data=Kmenta1, method="MM") # 2SLS MM estimation car::compareCoefs(deq, deq1, deq2, deq3) round(d eq3$rweights, 2) # robustness weights ``` ivreg.fit Fitting Instrumental-Variable Regressions by 2SLS, 2SM, or 2SMM Estimation Description Fit instrumental-variable regression by two-stage least squares (2SLS). This is equivalent to direct instrumental-variables estimation when the number of instruments is equal to the number of predictors. Alternative robust-regression estimation is also supported, based on M-estimation (22M) or MM-estimation (2SMM). Usage ivreg.fit( x, ivreg.fit ```r ivreg.fit = function(y, z, weights, offset, method = c("OLS", "M", "MM"), rlm.args = list(), ...) ``` ### Arguments - **x**: regressor matrix. - **y**: vector for the response variable. - **z**: instruments matrix. - **weights**: an optional vector of weights to be used in the fitting process. - **offset**: an optional offset that can be used to specify an a priori known component to be included during fitting. - **method**: the method used to fit the stage 1 and 2 regression: "OLS" for traditional 2SLS regression (the default), "M" for M-estimation, or "MM" for MM-estimation, with the latter two robust-regression methods implemented via the `rlm` function in the `MASS` package. - **rlm.args**: a list of optional arguments to be passed to the `rlm` function in the `MASS` package if robust regression is used for the stage 1 and 2 regressions. - **...**: further arguments passed to `lm.fit` or `lm.wfit`, respectively. ### Details `ivreg` is the high-level interface to the work-horse function `ivreg.fit`. `ivreg.fit` is essentially a convenience interface to `lm.fit` (or `lm.wfit`) for first projecting `x` onto the image of `z`, then running a regression of `y` on the projected `x`, and computing the residual standard deviation. ### Value `ivreg.fit` returns an unclassed list with the following components: - **coefficients**: parameter estimates, from the stage-2 regression. - **residuals**: vector of model residuals. - **residuals1**: matrix of residuals from the stage-1 regression. - **residuals2**: vector of residuals from the stage-2 regression. - **fitted.values**: vector of predicted means for the response. - **weights**: either the vector of weights used (if any) or `NULL` (if none). - **offset**: either the offset used (if any) or `NULL` (if none). - **estfun**: a matrix containing the empirical estimating functions. - **n**: number of observations. - **nobs**: number of observations with non-zero weights. p number of columns in the model matrix \( x \) of regressors. q number of columns in the instrumental variables model matrix \( z \) rank numeric rank of the model matrix for the stage-2 regression. df.residual residual degrees of freedom for fitted model. cov.unscaled unscaled covariance matrix for the coefficients. sigma residual standard error; when method is "M" or "MM", this is based on the MAD of the residuals (around 0) — see \texttt{mad}. x projection of \( x \) matrix onto span of \( z \). qr QR decomposition for the stage-2 regression. qr1 QR decomposition for the stage-1 regression. rank1 numeric rank of the model matrix for the stage-1 regression. coefficients1 matrix of coefficients from the stage-1 regression. df.residual1 residual degrees of freedom for the stage-1 regression. exogenous columns of the "regressors" matrix that are exogenous. endogenous columns of the "regressors" matrix that are endogenous. instruments columns of the "instruments" matrix that are instruments for the endogenous variables. method the method used for the stage 1 and 2 regressions, one of "OLS", "M", or "MM". rweights a matrix of robustness weights with columns for each of the stage-1 regressions and for the stage-2 regression (in the last column) if the fitting method is "M" or "MM", NULL if the fitting method is "OLS". hatvalues a matrix of hatvalues. For \texttt{method} = "OLS", the matrix consists of two columns, for each of the stage-1 and stage-2 regression; for \texttt{method} = "M" or "MM", there is one column for \texttt{each} stage-1 regression and for the stage-2 regression. See Also \texttt{ivreg}, \texttt{lm.fit}, \texttt{lm.wfit}, \texttt{rlm}, \texttt{mad} Examples ```r ## data data("CigaretteDemand", package = "ivreg") ## high-level interface m <- ivreg(log(packs) ~ log(rprice) + log(rincome) | salestax + log(rincome), data = CigaretteDemand) ## low-level interface y <- m$y x <- model.matrix(m, component = "regressors") z <- model.matrix(m, component = "instruments") ivreg.fit(x, y, z)$coefficients ``` Description These are partly contrived data from Kmenta (1986), constructed to illustrate estimation of a simultaneous-equation econometric model. The data are an annual time-series for the U.S. economy from 1922 to 1941. The values of the exogenous variables D, and F, and A are real, while those of the endogenous variables Q and P are simulated according to the linear simultaneous equation model fit in the examples. Usage data("Kmenta", package = "ivreg") Format A data frame with 20 rows and 5 columns. Q food consumption per capita. P ratio of food prices to general consumer prices. D disposable income in constant dollars. F ratio of preceding year’s prices received by farmers to general consumer prices. A time in years. Source See Also ivreg. Examples data("Kmenta", package = "ivreg") deq <- ivreg(Q ~ P + D | D + F + A, data = Kmenta) # demand equation seq <- ivreg(Q ~ P + F + A | D + F + A, data = Kmenta) # supply equation summary(d eq, tests = TRUE) summary(seq, tests = TRUE) Description Data from the U.S. National Longitudinal Survey of Young Men (NLSYM) in 1976 but using some variables dating back to earlier years. Usage data("SchoolingReturns", package = "ivreg") Format A data frame with 3010 rows and 22 columns. - **wage**: Raw wages in 1976 (in cents per hour). - **education**: Education in 1976 (in years). - **experience**: Years of labor market experience, computed as age - education - 6. - **ethnicity**: Factor indicating ethnicity. Is the individual African-American ("afam") or not ("other")? - **smsa**: Factor. Does the individual reside in a SMSA (standard metropolitan statistical area) in 1976? - **south**: Factor. Does the individual reside in the South in 1976? - **age**: Age in 1976 (in years). - **nearcollege**: Factor. Did the individual grow up near a 4-year college? - **nearcollege2**: Factor. Did the individual grow up near a 2-year college? - **nearcollege4**: Factor. Did the individual grow up near a 4-year public or private college? - **enrolled**: Factor. Is the individual enrolled in college in 1976? - **married**: Factor. Is the individual married in 1976? - **education66**: Education in 1966 (in years). - **smsa66**: Factor. Does the individual reside in a SMSA in 1966? - **south66**: Factor. Does the individual reside in the South in 1966? - **feducation**: Father’s educational attainment (in years). Imputed with average if missing. - **meducation**: Mother’s educational attainment (in years). Imputed with average if missing. - **fameducation**: Ordered factor coding family education class (from 1 to 9). - **kww**: Knowledge world of work (KWW) score. - **iq**: Normed intelligence quotient (IQ) score. - **parents14**: Factor coding living with parents at age 14: both parents, single mother, step parent, other. - **library14**: Factor. Was there a library card in home at age 14? Details Investigating the causal link of schooling on earnings in a classical model for wage determinants is problematic because it can be argued that schooling is endogenous. Hence, one possible strategy is to use an exogenous variable as an instrument for the years of education. In his well-known study, Card (1995) uses geographical proximity to a college when growing up as such an instrument, showing that this significantly increases both the years of education and the wage level obtained on the labor market. Using instrumental variables regression Card (1995) shows that the estimated returns to schooling are much higher than when simply using ordinary least squares. The data are taken from the supplementary material for Verbeek (2004) and are based on the work of Card (1995). The U.S. National Longitudinal Survey of Young Men (NLSYM) began in 1966 and included 5525 men, then aged between 14 and 24. Card (1995) employs labor market information from the 1976 NLSYM interview which also included information about educational attainment. Out of the 3694 men still included in that wave of NLSYM, 3010 provided information on both wages and education yielding the subset of observations provided in SchoolingReturns. The examples replicate the results from Verbeek (2004) who used the simplest specifications from Card (1995). Including further region or family background characteristics improves the model significantly but does not affect much the main coefficients of interest, namely that of years of education. Source Supplementary material for Verbeek (2004). References Examples ```r ## load data data("SchoolingReturns", package = "ivreg") ## Table 5.1 in Verbeek (2004) / Table 2(1) in Card (1995) ## Returns to education: 7.4% m_ols <- lm(log(wage) ~ education + poly(experience, 2, raw = TRUE) + ethnicity + smsa + south, data = SchoolingReturns) summary(m_ols) ## Table 5.2 in Verbeek (2004) / similar to Table 3(1) in Card (1995) m_red <- lm(education ~ poly(age, 2, raw = TRUE) + ethnicity + smsa + south + nearcollege, data = SchoolingReturns) summary(m_red) ## Table 5.3 in Verbeek (2004) / similar to Table 3(5) in Card (1995) ## Returns to education: 13.3% m_iv <- ivreg(log(wage) ~ education + poly(experience, 2, raw = TRUE) + ethnicity + smsa + south | nearcollege + poly(age, 2, raw = TRUE) + ethnicity + sma + south, data = SchoolingReturns summary(m_iv) Index * datasets CigaretteDemand, 2 Kmenta, 18 SchoolingReturns, 19 * regression ivreg, 12 ivreg.fit, 15 alias.ivreg (coef.ivreg), 4 Anova.ivreg (coef.ivreg), 4 anova.ivreg (coef.ivreg), 4 avPlot.ivreg (influence.ivreg), 7 avPlots, 7, 11 avPlots.ivreg (influence.ivreg), 7 Boot, 10, 11 Boot.ivreg (influence.ivreg), 7 bread.ivreg (coef.ivreg), 4 ceresPlot.ivreg (influence.ivreg), 7 ceresPlots.ivreg (influence.ivreg), 7 CigaretteDemand, 2 CigarettesSW, 2, 3 coef, 6 coef.ivreg, 4 confint.ivreg (coef.ivreg), 4 cooks.distance.influence.ivreg (influence.ivreg), 7 cooks.distance.ivreg (influence.ivreg), 7 crPlot.ivreg (influence.ivreg), 7 crPlots, 7, 11 crPlots.ivreg (influence.ivreg), 7 deviance.ivreg (influence.ivreg), 7 dfbeta.influence.ivreg (influence.ivreg), 7 dfbeta.ivreg (influence.ivreg), 7 Effect, 7 Effect(ivreg(coef.ivreg), 4 estfun(ivreg(coef.ivreg), 4 find_formula.ivreg (coef.ivreg), 4 formula, 6 formula(ivreg(coef.ivreg), 4 hatvalues.influence.ivreg (influence.ivreg), 7 hatvalues.ivreg (influence(ivreg), 7 infIndexPlot, 11 infIndexPlot.influence(ivreg (influence.ivreg), 7 infIndexPlot.ivreg (influence(ivreg), 7 influence(ivreg, 7 influence.rivreg(influence(ivreg), 7 influencePlot, 11 influencePlot.influence.ivreg (influence(ivreg), 7 influencePlot.ivreg(influence(ivreg), 7 ivreg, 7, 11, 12, 16–18 ivreg.fit, 7, 13, 15, 15 ivregDiagnostics, 4, 7, 13, 15 ivregDiagnostics(influence.ivreg), 7 ivregMethods, 13, 15 ivregMethods(coef.ivreg), 4 Kmenta, 18 lapply, 10 linearHypothesis, 7 linearHypothesis(ivreg(coef.ivreg), 4 lm, 15 lm.fit, 15–17 lm.wfit, 16, 17 mad, 17 mclapply, 10 mcPlot.ivreg(influence.ivreg), 7 mcPlots.ivreg(influence(ivreg), 7 model.matrix, 6 INDEX model.matrix.default, 12 model.matrix.influence.ivreg (influence.ivreg), 7 model.matrix.ivreg(coef.ivreg), 4 model.matrix.ivreg_projected (coef.ivreg), 4 na.pass, 7 ncvTest, 11 ncvTest.ivreg(influence.ivreg), 7 outlierTest, 11 outlierTest.ivreg(influence.ivreg), 7 parLapply, 10 plot.ivreg(influence.ivreg), 7 predict.ivreg(coef.ivreg), 4 predictorEffects, 7, 11 print.ivreg(coef.ivreg), 4 print.summary.ivreg(coef.ivreg), 4 qqPlot, 7, 11 qqPlot.influence.ivreg (influence.ivreg), 7 qqPlot.ivreg(influence.ivreg), 7 qr.ivreg(coef.ivreg), 4 residuals.ivreg(coef.ivreg), 4 rlm, 13, 16, 17 rstudent.influence.ivreg (influence.ivreg), 7 rstudent.ivreg(influence.ivreg), 7 SchoolingReturns, 19 spreadLevelPlot, 11 spreadLevelPlot.ivreg (influence.ivreg), 7 StockWatson2007, 2 summary.ivreg(coef.ivreg), 4 terms, 6 terms.ivreg(coef.ivreg), 4 update.ivreg(coef.ivreg), 4 vcov, 6 vcov.ivreg(coef.ivreg), 4 vcovHC.ivreg(coef.ivreg), 4 weights.ivreg(coef.ivreg), 4
{"Source-Url": "https://cran.r-project.org/web/packages/ivreg/ivreg.pdf", "len_cl100k_base": 9648, "olmocr-version": "0.1.53", "pdf-total-pages": 23, "total-fallback-pages": 0, "total-input-tokens": 55172, "total-output-tokens": 11684, "length": "2e13", "weborganizer": {"__label__adult": 0.0004241466522216797, "__label__art_design": 0.0010728836059570312, "__label__crime_law": 0.0006136894226074219, "__label__education_jobs": 0.007266998291015625, "__label__entertainment": 0.0002110004425048828, "__label__fashion_beauty": 0.00030803680419921875, "__label__finance_business": 0.0032520294189453125, "__label__food_dining": 0.0004355907440185547, "__label__games": 0.0009317398071289062, "__label__hardware": 0.0009169578552246094, "__label__health": 0.0005035400390625, "__label__history": 0.0007157325744628906, "__label__home_hobbies": 0.0002963542938232422, "__label__industrial": 0.001255035400390625, "__label__literature": 0.0004963874816894531, "__label__politics": 0.0007696151733398438, "__label__religion": 0.0005097389221191406, "__label__science_tech": 0.2012939453125, "__label__social_life": 0.00031065940856933594, "__label__software": 0.05511474609375, "__label__software_dev": 0.7216796875, "__label__sports_fitness": 0.0003650188446044922, "__label__transportation": 0.0007348060607910156, "__label__travel": 0.00034046173095703125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 35613, 0.029]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 35613, 0.72902]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 35613, 0.68]], "google_gemma-3-12b-it_contains_pii": [[0, 1404, false], [1404, 3447, null], [3447, 5077, null], [5077, 5964, null], [5964, 7004, null], [7004, 8446, null], [8446, 9384, null], [9384, 10449, null], [10449, 11291, null], [11291, 13314, null], [13314, 14763, null], [14763, 16296, null], [16296, 19001, null], [19001, 21479, null], [21479, 23028, null], [23028, 24996, null], [24996, 27103, null], [27103, 28179, null], [28179, 30051, null], [30051, 32712, null], [32712, 32816, null], [32816, 34632, null], [34632, 35613, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1404, true], [1404, 3447, null], [3447, 5077, null], [5077, 5964, null], [5964, 7004, null], [7004, 8446, null], [8446, 9384, null], [9384, 10449, null], [10449, 11291, null], [11291, 13314, null], [13314, 14763, null], [14763, 16296, null], [16296, 19001, null], [19001, 21479, null], [21479, 23028, null], [23028, 24996, null], [24996, 27103, null], [27103, 28179, null], [28179, 30051, null], [30051, 32712, null], [32712, 32816, null], [32816, 34632, null], [34632, 35613, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 35613, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 35613, null]], "pdf_page_numbers": [[0, 1404, 1], [1404, 3447, 2], [3447, 5077, 3], [5077, 5964, 4], [5964, 7004, 5], [7004, 8446, 6], [8446, 9384, 7], [9384, 10449, 8], [10449, 11291, 9], [11291, 13314, 10], [13314, 14763, 11], [14763, 16296, 12], [16296, 19001, 13], [19001, 21479, 14], [21479, 23028, 15], [23028, 24996, 16], [24996, 27103, 17], [27103, 28179, 18], [28179, 30051, 19], [30051, 32712, 20], [32712, 32816, 21], [32816, 34632, 22], [34632, 35613, 23]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 35613, 0.0]]}
olmocr_science_pdfs
2024-12-07
2024-12-07
075e8051c5f741a66aef902722644d3fcd24ffa0
Installation Overview This document is intended for system administrators of self-hosted installations of CircleCI Server. The following sections provide planning information, system requirements and step-by-step instructions for installing CircleCI Server on Amazon Web Services (AWS) with Terraform. Refer to the What’s New page for full details of what’s new and fixed in this release. If you are looking to update an existing installation, see our guide to Upgrading a Server Installation. Support Packages CircleCI 2.0 may be installed without a support package, on AWS, using the examples and instructions in this document. Alternatively, if you do decide to go ahead with a support package, there are a number of benefits, as detailed below: Non-AWS Platform Support With a Platinum CircleCI support package it is possible to install and configure CircleCI on Azure or any other platform used in your organization. Contact CircleCI support or your account representative to get started. Externalization With a Platinum support agreement, it is possible to improve performance and resilience by configuring the following services to run externally to the Services machine: - PostgreSQL - MongoDB - Vault - Rabbitmq - Redis - Nomad Contact CircleCI support or your account representative to evaluate your installation against the current requirements for running external services. System Requirements This document is intended for system administrators of self-hosted installations of CircleCI Server. This section defines the system and port access requirements for installing CircleCI v2.18.3. Services Machine The Services machine hosts the core of our Server product, including the user-facing website, API engine, datastores, and Nomad job scheduler. It is best practice to use an isolated machine. The following table defines the Services machine CPU, RAM, and disk space requirements: <table> <thead> <tr> <th>Number of daily active CircleCI users</th> <th>CPU</th> <th>RAM</th> <th>Disk space</th> <th>NIC speed</th> </tr> </thead> <tbody> <tr> <td>&lt;50</td> <td>8 cores</td> <td>32GB</td> <td>100GB</td> <td>1Gbps</td> </tr> <tr> <td>50-250</td> <td>12 cores</td> <td>64GB</td> <td>200GB</td> <td>1Gbps</td> </tr> <tr> <td>251-1000</td> <td>16 cores</td> <td>128GB</td> <td>500GB</td> <td>10Gbps</td> </tr> <tr> <td>1001-5000</td> <td>20 cores</td> <td>256GB</td> <td>1TB</td> <td>10Gbps</td> </tr> <tr> <td>5000+</td> <td>24 cores</td> <td>512GB</td> <td>2TB</td> <td>10Gbps</td> </tr> </tbody> </table> Nomad Clients Nomad client machines run the CircleCI jobs that are scheduled by the Nomad Server on the Services machine. Following are the Minimum CPU, RAM, and disk space requirements per client: - CPU: 4 cores - RAM: 32GB - Disk space: 100GB - NIC speed: 1Gbps The following table defines the number of Nomad clients to make available as a best practice. Scale up and down according to demand on your system: <table> <thead> <tr> <th>Number of daily active CircleCI users</th> <th>Number of Nomad client machines</th> </tr> </thead> <tbody> <tr> <td>&lt;50</td> <td>1-5</td> </tr> <tr> <td>50-250</td> <td>5-10</td> </tr> <tr> <td>250-1000</td> <td>10-15</td> </tr> <tr> <td>5000+</td> <td>15+</td> </tr> </tbody> </table> Server Ports Below all ports required by a CircleCI 2.0 installation are listed for each machine type. ## Services Machine <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>80</td> <td>TCP</td> <td>Inbound</td> <td>End users</td> <td>HTTP web app traffic</td> <td></td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Inbound</td> <td>End users</td> <td>HTTPS web app traffic</td> <td></td> </tr> <tr> <td>7171</td> <td>TCP</td> <td>Inbound</td> <td>End users</td> <td>Artifacts access</td> <td></td> </tr> <tr> <td>8081</td> <td>TCP</td> <td>Inbound</td> <td>End users</td> <td>Artifacts access</td> <td></td> </tr> <tr> <td>22</td> <td>TCP</td> <td>Inbound</td> <td>Administrators</td> <td>SSH</td> <td></td> </tr> <tr> <td>8800</td> <td>TCP</td> <td>Inbound</td> <td>Administrators</td> <td>Admin console</td> <td></td> </tr> <tr> <td>8125</td> <td>UDP</td> <td>Inbound</td> <td>Nomad Clients</td> <td>Metrics</td> <td></td> </tr> <tr> <td>8125</td> <td>UDP</td> <td>Inbound</td> <td>Nomad Servers</td> <td>Metrics</td> <td>Only if using externalized Nomad Servers</td> </tr> <tr> <td>8125</td> <td>UDP</td> <td>Inbound</td> <td>All Database Servers</td> <td>Metrics</td> <td>Only if using externalised databases</td> </tr> <tr> <td>4647</td> <td>TCP</td> <td>Bi-directional</td> <td>Nomad Clients</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>8585</td> <td>TCP</td> <td>Bi-directional</td> <td>Nomad Clients</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>7171</td> <td>TCP</td> <td>Bi-directional</td> <td>Nomad Clients</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>3001</td> <td>TCP</td> <td>Bi-directional</td> <td>Nomad Clients</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>80</td> <td>TCP</td> <td>Bi-directional</td> <td>GitHub Enterprise / GitHub.com (whichever applies)</td> <td>Webhooks / API access</td> <td>Only if running on AWS</td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Bi-directional</td> <td>GitHub Enterprise / GitHub.com (whichever applies)</td> <td>Webhooks / API access</td> <td></td> </tr> <tr> <td>80</td> <td>TCP</td> <td>Outbound</td> <td>AWS API endpoints</td> <td>API access</td> <td>Only if running on AWS</td> </tr> <tr> <td>Port number</td> <td>Protocol</td> <td>Direction</td> <td>Source / destination</td> <td>Use</td> <td>Notes</td> </tr> <tr> <td>-------------</td> <td>----------</td> <td>-----------</td> <td>----------------------</td> <td>-----</td> <td>-------</td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Outbound</td> <td>AWS API endpoints</td> <td>API access</td> <td>Only if running on AWS</td> </tr> <tr> <td>5432</td> <td>TCP</td> <td>Outbound</td> <td>PostgreSQL Servers</td> <td>PostgreSQL database connection</td> <td>Only if using externalised databases. Port is user-defined, assuming the default PostgreSQL port.</td> </tr> <tr> <td>27017</td> <td>TCP</td> <td>Outbound</td> <td>MongoDB Servers</td> <td>MongoDB database connection</td> <td>Only if using externalized databases. Port is user-defined, assuming the default MongoDB port.</td> </tr> <tr> <td>5672</td> <td>TCP</td> <td>Outbound</td> <td>RabbitMQ Servers</td> <td>RabbitMQ connection</td> <td>Only if using externalized RabbitMQ</td> </tr> <tr> <td>6379</td> <td>TCP</td> <td>Outbound</td> <td>Redis Servers</td> <td>Redis connection</td> <td>Only if using externalized Redis</td> </tr> <tr> <td>4647</td> <td>TCP</td> <td>Outbound</td> <td>Nomad Servers</td> <td>Nomad Server connection</td> <td>Only if using externalized Nomad Servers</td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Outbound</td> <td>CloudWatch Endpoints</td> <td>Metrics</td> <td>Only if using AWS CloudWatch</td> </tr> </tbody> </table> ## Nomad Clients <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>64535-65535</td> <td>TCP</td> <td>Inbound</td> <td>End users</td> <td>SSH into builds feature</td> <td></td> </tr> <tr> <td>80</td> <td>TCP</td> <td>Inbound</td> <td>Administrators</td> <td>CircleCI Admin API access</td> <td></td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Inbound</td> <td>Administrators</td> <td>CircleCI Admin API access</td> <td></td> </tr> <tr> <td>22</td> <td>TCP</td> <td>Inbound</td> <td>Administrators</td> <td>SSH</td> <td></td> </tr> <tr> <td>22</td> <td>TCP</td> <td>Outbound</td> <td>GitHub Enterprise / GitHub.com (whichever applies)</td> <td>Download Code From GitHub.</td> <td></td> </tr> <tr> <td>4647</td> <td>TCP</td> <td>Bi-directional</td> <td>Services Machine</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>8585</td> <td>TCP</td> <td>Bi-directional</td> <td>Services Machine</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>7171</td> <td>TCP</td> <td>Bi-directional</td> <td>Services Machine</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>3001</td> <td>TCP</td> <td>Bi-directional</td> <td>Services Machine</td> <td>Internal communication</td> <td></td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Outbound</td> <td>Cloud Storage Provider</td> <td>Artifacts storage</td> <td>Only if using external artifacts storage</td> </tr> <tr> <td>53</td> <td>UDP</td> <td>Outbound</td> <td>Internal DNS Server</td> <td>DNS resolution</td> <td>This is to make sure that your jobs can resolve all DNS names that are needed for their correct operation.</td> </tr> </tbody> </table> ## GitHub Enterprise / GitHub.com <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>22</td> <td>TCP</td> <td>Inbound</td> <td>Services Machine</td> <td>Git access</td> <td></td> </tr> <tr> <td>22</td> <td>TCP</td> <td>Inbound</td> <td>Nomad Clients</td> <td>Git access</td> <td></td> </tr> <tr> <td>80</td> <td>TCP</td> <td>Inbound</td> <td>Nomad Clients</td> <td>API access</td> <td></td> </tr> <tr> <td>443</td> <td>TCP</td> <td>Inbound</td> <td>Nomad Clients</td> <td>API access</td> <td></td> </tr> <tr> <td>80</td> <td>TCP</td> <td>Bi-directional</td> <td>Services Machine</td> <td>Webhooks / API access</td> <td></td> </tr> </tbody> </table> ## PostgreSQL Servers <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>5432</td> <td>TCP</td> <td>Bi-directional</td> <td>PostgreSQL Servers</td> <td>PostgreSQL replication</td> <td>Only if using externalized databases. Port is user-defined, assuming the default PostgreSQL port.</td> </tr> </tbody> </table> ## MongoDB Servers <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>27017</td> <td>TCP</td> <td>Bi-directional</td> <td>MongoDB Servers</td> <td>MongoDB replication</td> <td>Only if using externalized databases. Port is user-defined, assuming the default MongoDB port.</td> </tr> </tbody> </table> ### RabbitMQ Servers <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>5672</td> <td>TCP</td> <td>Inbound</td> <td>Services Machine</td> <td>RabbitMQ connection</td> <td>Only if using externalized RabbitMQ</td> </tr> <tr> <td>5672</td> <td>TCP</td> <td>Bi-directional</td> <td>RabbitMQ Servers</td> <td>RabbitMQ mirroring</td> <td>Only if using externalized RabbitMQ</td> </tr> </tbody> </table> ### Redis Servers <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>6379</td> <td>TCP</td> <td>Inbound</td> <td>Services Machine</td> <td>Redis connection</td> <td>Only if using externalized Redis</td> </tr> <tr> <td>6379</td> <td>TCP</td> <td>Bi-directional</td> <td>Redis Servers</td> <td>Redis replication</td> <td>Only if using externalized Redis, and using Redis replication (optional)</td> </tr> </tbody> </table> ### Nomad Servers <table> <thead> <tr> <th>Port number</th> <th>Protocol</th> <th>Direction</th> <th>Source / destination</th> <th>Use</th> <th>Notes</th> </tr> </thead> <tbody> <tr> <td>4646</td> <td>TCP</td> <td>Inbound</td> <td>Services Machine</td> <td>Nomad Server connection</td> <td>Only if using externalized Nomad Servers</td> </tr> <tr> <td>4647</td> <td>TCP</td> <td>Inbound</td> <td>Services Machine</td> <td>Nomad Server connection</td> <td>Only if using externalized Nomad Servers</td> </tr> <tr> <td>4648</td> <td>TCP</td> <td>Bi-directional</td> <td>Nomad Servers</td> <td>Nomad Servers internal communication</td> <td>Only if using externalized Nomad Servers</td> </tr> </tbody> </table> Installation Prerequisites This document is intended for system administrators of self-hosted installations of CircleCI Server. CircleCI uses Terraform to automate parts of the infrastructure for your CircleCI Server install, so you will need to install this first: - Visit Download Terraform and choose the correct package for your architecture. Ensure you have the following information available before beginning the installation procedure: - A CircleCI License file (.rli). Contact CircleCI support for a license and request a cluster-enabled license to run jobs on dedicated instances for best performance. - Your AWS Access Key ID and Secret Access Key. - Name of your AWS EC2 key pair. - AWS Region, for example us-west-2. - AWS Virtual Private Cloud (VPC) ID and AWS Subnet ID. If your account is configured to use a default VPC, your default VPC ID is listed under Account Attributes, which you will find from the AWS management console on the EC2 dashboard page. - Set your VPC (enableDnsSupport) setting to true to ensure that queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address at the base of the VPC IPv4 network range plus two will succeed. See the Using DNS with Your VPC Amazon Web Services documentation for additional details. Private Subnet Requirements The following additional settings are required to support using private subnets on AWS with CircleCI: - The private subnet for builder boxes must be configured with a NAT gateway or an internet gateway configured for the outbound traffic to the internet via attached route tables. The subnet should be large enough to never exhaust the addresses. - The VPC Endpoint for S3 should be enabled. Enabling the VPC endpoint for S3 should significantly improve S3 operations for CircleCI and other nodes within your subnet. - Adequately power the NAT instance for heavy network operations. Depending on the specifics of your deployment, it is possible for NAT instances to become constrained by highly parallel builds using Docker and external network resources. A NAT that is inadequate could cause slowness in network and cache operations. - If you are integrating with github.com, ensure that your network access control list (ACL) whitelists ports 80 and 443 for GitHub webhooks. When integrating with GitHub, either set up CircleCI in a public subnet, or set up a public load balancer to forward github.com traffic. - See the Services Machine section of our overview for more information on the specific ports that need to be accessible to instances in your CircleCI installation. Planning Have available the following information and policies before starting the installation: - If you use network proxies, contact your Account team before beginning your install. - Plan to provision at least two AWS instances, one for Services and one for your first set of Nomad Clients. Best practice is to use an `m4.2xlarge` instance with 8 vCPUs and 32GB RAM for both the Services and Nomad Clients instances. - AWS instances must have outbound access to pull Docker containers and to verify your license. If you don't want to give open outbound access, see our list of ports that will need access. - In order to provision required AWS entities with Terraform you will require an IAM User with the following permissions (See the AWS guidance on creating IAM users): ```json { "Version": "2012-10-17", "Statement": [ { "Action": [ "s3:* ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::circleci-*", "arn:aws:s3:::circleci-/*/", "arn:aws:s3:::*" ] }, { "Action": [ "autoscaling:*", "sqs:*", "iam:*", "ec2:StartInstances", "ec2:RunInstances", "ec2:TerminateInstances", "ec2:Describe*", "ec2:CreateTags", "ec2:AuthorizeSecurityGroupEgress", "ec2:AuthorizeSecurityGroupIngress", "ec2:CreateSecurityGroup", "ec2:DeleteSecurityGroup", "ec2:DescribeInstanceAttribute" ] } ] } ``` "ec2:DescribeInstanceStatus", "ec2:DescribeInstances", "ec2:DescribeNetworkAcls", "ec2:DescribeSecurityGroups", "ec2:RevokeSecurityGroupEgress", "ec2:RevokeSecurityGroupIngress", "ec2:ModifyInstanceAttribute", "ec2:ModifyNetworkInterfaceAttribute", "cloudwatch:*", "autoscaling:DescribeAutoScalingGroups", "iam:GetUser" ], "Resource": [ "* ], "Effect": "Allow"} Installation on AWS with Terraform This document is intended for system administrators of self-hosted installations of CircleCI Server. Following is a step by step guide to installing CircleCI Server v2.18.3 with Terraform. Define Variables for Terraform 1. Clone the Setup repository. If you already have it cloned, make sure it is up-to-date and you are on the master branch by running: ``` git checkout master && git pull ``` 2. Go to the top directory of the enterprise-setup repo on your local machine. 3. Run `terraform init` to initialize your working directory. 4. Run `make init` to initialize a `terraform.tfvars` file (your previous `terraform.tfvars` if any, will be backed up in the same directory). 5. Open `terraform.tfvars` in an editor and fill in appropriate AWS values for section 1. 6. If you plan to use 1.0 builders, specify a `circle_secret_passphrase` in section 2, replacing `_` with alpha numeric characters, if not, leave it as is. 1.0 builders are disabled by default in section 3. 7. Specify the instance type to use for your Nomad clients. By default, the value specified in the `terraform.tfvars` file for Nomad Clients is `m4.2xlarge` (8 vCPUs, 32GB RAM). To increase the number of concurrent CircleCI jobs that each Nomad Client can run, modify section 2 of the `terraform.tfvars` file to specify a larger `nomad_client_instance_type`. Refer to the AWS Amazon EC2 Instance Types guide for details. The `builder_instance_type` is only used for CircleCI 1.0 and is disabled by default in section 3. 8. In section 3 you can: a. choose to use 1.0 Builders if your project requires it (by changing the count to 1) b. enter proxy details, and enter a prefix if there will be multiple installations within your AWS region – the Services and Nomad client instances will be displayed with this prefix in the AWS console. A full list of define_variables_for_terraform | INSTALLATION GUIDE | 12 --- ``` # 1. Required Cloud Configuration aws_access_key = "..." aws_secret_key = "..." aws_region = "eu-central-1" aws_vpc_id = "..." aws_subnet_id = "..." aws_ssh_key_name = "..." # 2. Required CircleCI Configuration circle_secret_passphrase = "..." services_instance_type = "m4.2xlarge" builder_instance_type = "r3.4xlarge" nomad_client_instance_type = "m4.2xlarge" # 3. Optional Cloud Configuration # Set this to `1` or higher to enable CircleCI 1.0 builders desired_builders_count = "0" # Provide proxy address if your network configuration requires it http_proxy = "" https_proxy = "" no_proxy = "" # Use this var if you have multiple installation within one AWS region prefix = "..." services_disable_api_termination = "false" force_destroy_s3_bucket = "true" ``` Figure 1. Example tfvars Above is an example of the `terraform.tfvars` file you will be editing. The table below shows some of the default settings, and some optional variables that can be used to further customize your cluster. variables and defaults can be found in the `variables.tf` file in the root of the `enterprise-setup` directory. Optional vars: <table> <thead> <tr> <th>Var</th> <th>Description</th> <th>Default</th> </tr> </thead> <tbody> <tr> <td>services_instance_type</td> <td>Instance type for the centralized services box. We recommend a m4 instance</td> <td>m4.2xlarge</td> </tr> <tr> <td>builder_instance_type</td> <td>Instance type for the 1.0 builder machines. We recommend a r3 instance</td> <td>r3.2xlarge</td> </tr> <tr> <td>max_builders_count</td> <td>Max number of 1.0 builders</td> <td>2</td> </tr> <tr> <td>nomad_client_instance_type</td> <td>Instance type for the nomad clients (2.0 builders). We recommend a XYZ instance</td> <td>m4.xlarge</td> </tr> <tr> <td>max_clients_count</td> <td>Max number of nomad clients</td> <td>2</td> </tr> <tr> <td>prefix</td> <td>Prefix for resource names</td> <td>circleci</td> </tr> <tr> <td>enable_nomad</td> <td>Provisions a nomad cluster for CircleCI Server v2.x</td> <td>1</td> </tr> <tr> <td>enable_route</td> <td>Enable creating a Route53 route for the Services box</td> <td>0</td> </tr> <tr> <td>services_user_data_enabled</td> <td>Set to 0 to disable automated installation on Services Box</td> <td>1</td> </tr> <tr> <td>force_destroy_s3_bucket</td> <td>Add/Remove ability to forcefully destroy S3 bucket when your installation is shut down</td> <td>false</td> </tr> <tr> <td>services_disable_api_termination</td> <td>Protect the services instance from API termination. Set to false if you would like to terminate the Services box automatically when your installation is shut down</td> <td>true</td> </tr> </tbody> </table> **Provision Instances** 1. Save your changes to the `tfvars` file and run the following: ```bash terraform plan ``` 2. To provision your instances, run the following: ```bash terraform apply ``` You will be asked to confirm if you wish to go ahead by typing *yes*. 3. An IP address will be provided at the end of the Terraform output. Visit this IP to carry on the install process. **Access Your Installation** 1. You will see a browser-specific SSL/TLS info box. This is just to inform you that on the next screen your browser might tell you the connection to the admin console is unsafe, but you can be confident it is secure. Click Continue to Setup and proceed to your installation IP. ![Bypass Browser TLS Warning](image) *Figure 2. SSL Security* 2. Enter your hostname – this can be your domain name or public IP of the Services Machine instance. At this time you can also upload your SSL public key and certificate if you have them. To proceed without providing these click Use Self-Signed Cert – choosing this option will mean you will see security warnings each time you visit the Management Console. 3. Upload your license. 4. Decide how to secure the Management Console. You have three options: a. Anonymous admin access to the console, anyone on port 8800 can access (not recommended) b. Set a password that can be used to securely access the Management Console (recommended) c. Use your existing directory-based authentication system (for example, LDAP) 5. Your CircleCI installation will be put through a set of preflight checks, once they have completed, scroll down and click Continue. Installation Setup You should now be on the Management Console settings page (your-circleci-hostname.com:8800). ⚠️ You can make changes to the settings on this page at any time but changes here will require **downtime** while the service is restarted. Some settings are covered in more detail in our Operations Guide. 1. The Hostname field should be pre-populated from earlier in the install process, but if you skipped that step, enter your domain or public IP of the Services machine instance. You can check this has been entered correctly by clicking Test Hostname Resolution. 2. The Services section is only used when externalizing services. Externalization is available with a Platinum service contract. Contact support@circleci.com if you would like to find out more. 3. Under Execution Engines, only select 1.0 Builders if you require them for a legacy project – most users will leave this unchecked. 4. Select Cluster in the 2.0 Builders Configuration section. The Single box option will run jobs on the Services machine, rather than a dedicated instance, so is only suitable for trialling the system, or for some small teams. 5. Register CircleCI as a new OAuth application in GitHub.com or GitHub Enterprise by following the instructions provided onscreen. If you get an "Unknown error authenticating via GitHub. Try again, or contact us." message, try using http: instead of https: for the Homepage URL and callback URL. 6. Copy the Client ID and Secret from GitHub and paste it into the relevant fields, then click Test Authentication. 7. If you are using GitHub.com, move on to the next step. If using Github Enterprise, you will also need to supply an API Token so we can verify your organization. To provide this, complete the following from your GitHub Enterprise dashboard: a. Navigate to Personal Settings (top right) > Developer Settings > Personal Access Tokens. b. Click "generate new token". Name the token appropriately to prevent accidental deletion. Do not tick any of the checkboxes, we only require the default public read-level access so no extra permissions are required. We recommend this token should be shared across your organization rather than being owned by a single user. c. Copy the new token and paste it into the GitHub Enterprise Default API Token field. 8. If you wish to use LDAP authentication for your installation, enter the required details in the LDAP section. For a detailed runthrough of LDAP settings, see our LDAP authentication guide. 9. We recommend using an SSL certificate and key for your install. You can submit these in the Privacy section if this step was missed during the installation. 10. We recommend using S3 for storage and all required fields for Storage are pre-populated. The IAM user, as referred to in the planning section of this document, is used here. 11. Complete enhanced AWS Integration options. 12. Complete the Email section if you wish to configure your own email server for sending build update emails. Leave this section if you wish to use our default email server. Due to an issue with our third party tooling, Replicated, the Test SMTP Authentication button is not currently working 13. Configure VM service if you plan to use Remote Docker or machine executor (Linux/Windows) features. We recommend using an IAM instance profile for authentication, as described in the planning section of this document. With this section completed, instances will automatically be provisioned to execute jobs in Remote Docker or use the machine executor. To use the Windows machine executor you will need to build an image. For more information on VM Service and creating custom AMIs for remote Docker and machine executor jobs, see our VM service guide. You can preallocate instances to always be up and running, reducing the time taken for Remote Docker and machine executor jobs to start. If preallocation is set, a cron job will cycle through your preallocated instances once per day to prevent them getting into a bad/dead state. If Docker Layer Caching (DLC) is to be used, VM preallocation should be set to 0, forcing containers to be spun up on-demand for both machine and Remote Docker. It is worth noting here that if these fields are not set to 0 but all preallocated instances are in use, DLC will work correctly, as if preallocation was set to 0. 14. If you wish to use AWS Cloudwatch or Datadog for collating metrics for your installation, set this up here. For more information see our Monitoring guidance: You can also customize the metrics received through Telegraf. For more on this see our Custom Metrics guide. 15. Artifacts persist data after a job is completed, and may be used for longer-term storage of your build process outputs. By default, CircleCI Server only allows approved types to be served. This is to protect users from uploading, and potentially executing malicious content. The Artifacts setting allows you to override this protection. For more information on safe/unsafe types see our Build Artifacts guidance. 16. After agreeing to the License Agreement and saving your settings, select Restart Now from the popup. You will then be redirected to start CircleCI and view the Management Console Dashboard. It will take a few minutes to download all of the necessary Docker containers. If the Management Console reports Failure reported from operator: no such image click Start again and it should continue. Validate Your Installation 1. When the application is started, select Open to launch CircleCI in your browser, and sign up/log in to your CircleCI installation and start running 2.0 builds! You will become the Administrator at this point as you are the first person to sign in. Have a look at our Getting Started guide to start adding projects. 2. After build containers have started and images have been downloaded, the first build should begin immediately. If there are no updates after around **15 minutes**, and you have clicked the Refresh button, contact CircleCI support for assistance. 3. Next, use our realitycheck repo to check basic CircleCI functionality. 4. If you're unable to run your first builds successfully please start with our Troubleshooting guide for general troubleshooting topics, and our Introduction to Nomad Cluster Operation for information about how to check the status of Builders in your installation. Teardown This document is intended for system administrators of self-hosted installations of CircleCI Server. If you wish to delete your installation of CircleCI Server, please let us know first in case there are any specific, supplementary steps required for your installation. Below is our basic step by step guide to tearing down an installation of CircleCI Server that was made with Terraform: 1. First you need to manually disable the termination protection on the Services machine from the AWS Management Console (If you set services_disable_api_termination = "false" in your terraform.tfvars file, skip this step). To do this: a. Navigate to the EC2 Dashboard and locate the Services machine instance b. Click to select it 2. Click Actions > Instance Settings > Change Termination Protection 3. Navigate to the S3 dashboard, locate the S3 bucket associated with your CircleCI cluster and delete the bucket and its contents (If you set force_destroy_s3_bucket = "true" in your terraform.tfvars file, skip this step). 4. From a terminal, navigate to your clone of our enterprise-setup repo and run terraform destroy to destroy all EC2 instances, IAM roles, ASGs and Launch configurations created by terraform apply. Upgrading a Server Installation This document is intended for system administrators of self-hosted installations of CircleCI Server. This section describes the process for upgrading your CircleCI Server installation from v2.17.x to v2.18.3. If you have already upgraded to v2.18 and would like steps to upgrade to patch release v2.18.3, first take a snapshot and then follow the application upgrade steps. Org Rename Script Before upgrading please read and follow the steps below if you have ever had issues with renaming an organization within CircleCI or you suspect that an organization rename might have happened at any point. 1. SSH into your Services machine 2. REPL into workflows-conductor by running the following: `sudo docker exec -it workflows-conductor lein repl :connect 6005` 3. Go to this link for the org rename script. Copy/paste this script into the REPL session. It will run migration and output current progress. 4. If any ERROR messages are present in the output please report back to your CSM or reach out to support. Upgrade Steps Overview Following is an overview of the CircleCI Server upgrade steps. Each stage is described in detail below. - Take a snapshot of your installation so you can rollback later if necessary (optional but recommended) - Update Replicated and check you are running Docker v17.12.1, update if necessary - Install the latest version of CircleCI Server 1. **Snapshot for Rollback** To take a snapshot of your installation: 1. Go to the Management Console (e.g. `your-circleci-hostname.com:8888`) and click Stop Now to stop the CircleCI service. 2. Ensure no jobs are running on the nomad clients – you can check this by running `nomad status` 3. Navigate to the AWS EC2 management console and select your Services machine instance 4. Select Actions > Image > Create Image – Select the No Reboot option if you want to avoid downtime at this point. This image creation step creates an AMI that can be readily launched as a new EC2 instance to restore your installation. It is also possible to automate this process with the AWS API. Subsequent AMIs/snapshots are only as large as the difference (changed blocks) since the last snapshot, such that storage costs are not necessarily larger for more frequent snapshots, see Amazon's EBS snapshot billing document for details. Once you have the snapshot you are free to make changes on the Services machine. If you do need to rollback at any point, see our guide to restoring from a backup. 2. Updating Replicated a. Prerequisites - Your installation is Ubuntu 14.04 or 16.04 based. - Your installation is not airgapped and you can access the internet from it. - We will be updating to Replicated v2.38, but first we need to check you are running at least v2.10.3 on your Services machine. To check this, SSH into the Services machine and run the following: ``` replicated --version ``` If you are running a version of Replicated pre v2.10.3 please reach out to support@circleci.com. If you are already on v2.38 you can skip the next step and move to upgrade the CircleCI application. b. Preparations Remember to take a snapshot (described above) before starting the Replicated update process. 1. Stop the CircleCI application by clicking the Stop Now button on the Dashboard. Application shutdown takes a few minutes. Wait for the status to become “Stopped” before continuing. Alternatively you can SSH into the Services machine and stop the CircleCI application from the command line: ```bash replicatedctl app stop ``` You can check the status using the following: ```bash replicatedctl app status inspect ``` Example Output: 2. For the replicated update to succeed, it is necessary to update docker to the recommended version, 17.12.1. Check which version you are running with `docker version` and if you need to update, follow these steps: ``` sudo apt-get install docker-ce=17.12.1~ce-0~ubuntu ``` 3. Pin the Docker version using the following command: ``` sudo apt-mark hold docker-ce ``` c. Perform Update 1. Perform the Replicated update by executing the update script as follows: ``` curl -sSL "https://get.replicated.com/docker?replicated_tag=2.38.0" | sudo bash ``` Double-check your replicated and docker versions: ``` replicatedctl version # 2.38.0 docker -v # 17.12.1 ``` 2. Restart the app with ``` replicatedctl app start ``` The application will take a few minutes to spin up. You can check the progress in the administration dashboard or by executing: ``` replicatedctl app status inspect ``` Example output: ``` [ { "AppID": "edd9471be0bc4ea04dfca94718ddf621", "Sequence": 2439, "State": "started", "DesiredState": "started", "Error": "", "IsCancellable": true, "IsTransitioning": true, "LastModifiedAt": "2018-10-23T22:04:05.00374451Z" } ] ``` 3. Upgrade CircleCI Server 1. Once you are running the latest version of Replicated, click the View Update button in the Management Console dashboard. 2. Click Install next to the version you wish to install. Please refresh your screen intermittently during the install process to avoid unnecessary waiting. The install process may take several minutes and the install status will be displayed both on the Releases. 3. Once the installation is finished, navigate to the Dashboard to start your installation - Note the middle box on the Dashboard will read "CircleCI is up to date" when you are running the latest version.
{"Source-Url": "https://circleci.com/docs/2.0/CircleCI-Server-AWS-Installation-Guide-v2-18-3.pdf", "len_cl100k_base": 9257, "olmocr-version": "0.1.53", "pdf-total-pages": 33, "total-fallback-pages": 0, "total-input-tokens": 57374, "total-output-tokens": 9355, "length": "2e13", "weborganizer": {"__label__adult": 0.0002613067626953125, "__label__art_design": 0.00034737586975097656, "__label__crime_law": 0.0002624988555908203, "__label__education_jobs": 0.0013761520385742188, "__label__entertainment": 9.381771087646484e-05, "__label__fashion_beauty": 0.0001367330551147461, "__label__finance_business": 0.0018301010131835935, "__label__food_dining": 0.00020897388458251953, "__label__games": 0.0008215904235839844, "__label__hardware": 0.0031986236572265625, "__label__health": 0.0002319812774658203, "__label__history": 0.00024211406707763672, "__label__home_hobbies": 0.0002460479736328125, "__label__industrial": 0.0006093978881835938, "__label__literature": 0.0001766681671142578, "__label__politics": 0.00021648406982421875, "__label__religion": 0.0003333091735839844, "__label__science_tech": 0.031158447265625, "__label__social_life": 0.00014066696166992188, "__label__software": 0.2271728515625, "__label__software_dev": 0.73046875, "__label__sports_fitness": 0.00015592575073242188, "__label__transportation": 0.0002391338348388672, "__label__travel": 0.0002129077911376953}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 37036, 0.01884]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 37036, 0.02376]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 37036, 0.80055]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 0, null], [0, 1399, false], [1399, 3483, null], [3483, 6423, null], [6423, 7531, null], [7531, 8896, null], [8896, 10658, null], [10658, 12860, null], [12860, 15474, null], [15474, 17160, null], [17160, 17524, null], [17524, 19402, null], [19402, 20487, null], [20487, 22522, null], [22522, 23449, null], [23449, 23816, null], [23816, 23951, null], [23951, 25092, null], [25092, 26268, null], [26268, 26800, null], [26800, 28471, null], [28471, 29742, null], [29742, 30333, null], [30333, 31563, null], [31563, 33170, null], [33170, 33595, null], [33595, 34662, null], [34662, 35213, null], [35213, 35950, null], [35950, 36564, null], [36564, 36831, null], [36831, 37036, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 0, null], [0, 1399, true], [1399, 3483, null], [3483, 6423, null], [6423, 7531, null], [7531, 8896, null], [8896, 10658, null], [10658, 12860, null], [12860, 15474, null], [15474, 17160, null], [17160, 17524, null], [17524, 19402, null], [19402, 20487, null], [20487, 22522, null], [22522, 23449, null], [23449, 23816, null], [23816, 23951, null], [23951, 25092, null], [25092, 26268, null], [26268, 26800, null], [26800, 28471, null], [28471, 29742, null], [29742, 30333, null], [30333, 31563, null], [31563, 33170, null], [33170, 33595, null], [33595, 34662, null], [34662, 35213, null], [35213, 35950, null], [35950, 36564, null], [36564, 36831, null], [36831, 37036, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 37036, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 37036, null]], "pdf_page_numbers": [[0, 0, 1], [0, 0, 2], [0, 1399, 3], [1399, 3483, 4], [3483, 6423, 5], [6423, 7531, 6], [7531, 8896, 7], [8896, 10658, 8], [10658, 12860, 9], [12860, 15474, 10], [15474, 17160, 11], [17160, 17524, 12], [17524, 19402, 13], [19402, 20487, 14], [20487, 22522, 15], [22522, 23449, 16], [23449, 23816, 17], [23816, 23951, 18], [23951, 25092, 19], [25092, 26268, 20], [26268, 26800, 21], [26800, 28471, 22], [28471, 29742, 23], [29742, 30333, 24], [30333, 31563, 25], [31563, 33170, 26], [33170, 33595, 27], [33595, 34662, 28], [34662, 35213, 29], [35213, 35950, 30], [35950, 36564, 31], [36564, 36831, 32], [36831, 37036, 33]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 37036, 0.22276]]}
olmocr_science_pdfs
2024-12-11
2024-12-11
94b9e338aa72e246403481bdf8162c2a0404d700
Technical Whitepaper Columnar Database and Query Optimization Author: Ciarán Gorman is a Financial Engineer who has designed and developed data management systems across a wide range of asset classes for top tier investment banks. TABLE OF CONTENTS 1 Introduction .................................................................................................................... 3 2 Overview of Test Data...................................................................................................... 4 3 Query Structure ............................................................................................................... 5 3.1 Query Structure Example .......................................................................................... 5 4 Precalculation .................................................................................................................. 8 4.1 Precalculation As Query Grows ............................................................................... 8 5 Take Advantage of the Built-in Map-reduce Capabilities of kdb+ Partitioned Databases . 10 5.1 Map-reduce As Table Grows ................................................................................. 10 6 Use of Attributes ........................................................................................................... 12 6.1 Parted Attribute: `p# ............................................................................................... 12 6.2 Parted Attribute As Table Grows ........................................................................... 12 6.3 Sorted Attribute: `s# .............................................................................................. 14 6.3.1 Sorted Attribute As Table Grows ...................................................................... 14 6.4 Unique Attribute: `u# .......................................................................................... 17 6.4.1 Unique Attribute As Table Grows .................................................................... 17 6.4.2 Unique Attribute as Query Grows .................................................................... 19 6.5 Grouped Attribute: `g# .......................................................................................... 20 6.5.1 Grouped Attribute As Table Grows ................................................................ 20 6.5.2 Grouped Attribute to Retrieve Daily Last ....................................................... 23 6.5.3 Grouped Attribute as Query Grows ................................................................ 23 7 Conclusion ..................................................................................................................... 26 1 INTRODUCTION The purpose of this whitepaper is to give an overview of some of the methods that are available to a kdb+ developer when trying to optimize the performance of a kdb+ database when queried. kdb+ has a well deserved reputation as a high performance database, appropriate for capturing, storing and analyzing massive amounts of data. Developers using kdb+ can use some of the techniques outlined in this whitepaper to optimize the performance of their installations. These techniques encompass variations in the structure of queries, how data is stored, and approaches to aggregation. Adjustments to column attributes are made using the dbmaint.q library, which was written by First Derivatives consultants and is available from the Kx wiki (http://code.kx.com/wsvn/code/contrib/fdsupport/database%20maintenance/dbmaint.q). Where appropriate, OS disk cache has been flushed using Simon Garland’s io.q script, which is available at the Kx wiki (http://code.kx.com/wsvn/code/contrib/simon/io/io.q). Tests performed using kdb+ version 2.8 (2012.05.29) 2 OVERVIEW OF TEST DATA The data used for the majority of the examples within this whitepaper is simulated NYSE TaQ data, with a minimal schema and stored in a date partitioned db. The data consists of the constituents of the S&P 500 index over a 1-month period, which has in the region of 10,000 trades and 50,000 quotes per security per day. Initially, no attributes are applied, although the data is sorted by sym, and within sym on time. Where an example requires a larger dataset, we will combine multiple partitions or create a new example dataset. <table> <thead> <tr> <th>trade</th> <th>c t f a</th> </tr> </thead> <tbody> <tr> <td>date</td> <td>d</td> </tr> <tr> <td>time</td> <td>t</td> </tr> <tr> <td>sym</td> <td>s</td> </tr> <tr> <td>price</td> <td>f</td> </tr> <tr> <td>size</td> <td>i</td> </tr> <tr> <td>stop</td> <td>b</td> </tr> <tr> <td>cond</td> <td>c</td> </tr> <tr> <td>ex</td> <td>c</td> </tr> </tbody> </table> <table> <thead> <tr> <th>quote</th> <th>c t f a</th> </tr> </thead> <tbody> <tr> <td>date</td> <td>d</td> </tr> <tr> <td>time</td> <td>t</td> </tr> <tr> <td>sym</td> <td>s</td> </tr> <tr> <td>bid</td> <td>f</td> </tr> <tr> <td>ask</td> <td>f</td> </tr> <tr> <td>bsize</td> <td>i</td> </tr> <tr> <td>asize</td> <td>i</td> </tr> <tr> <td>mode</td> <td>c</td> </tr> <tr> <td>ex</td> <td>c</td> </tr> </tbody> </table> (q) (select tradecount:count i by date from trade) lj (select quotecount:count i by date from quote) <table> <thead> <tr> <th>date</th> <th>tradecount</th> <th>quotecount</th> </tr> </thead> <tbody> <tr> <td>2010.12.01</td> <td>4940021</td> <td>24713334</td> </tr> <tr> <td>2010.12.02</td> <td>4940300</td> <td>24714460</td> </tr> <tr> <td>2010.12.03</td> <td>4940482</td> <td>24708283</td> </tr> <tr> <td>2010.12.30</td> <td>4982917</td> <td>24933374</td> </tr> <tr> <td>2010.12.31</td> <td>4994626</td> <td>25000981</td> </tr> </tbody> </table> ... 3 QUERY STRUCTURE Before considering optimizations that can be achieved through amendments to data structures, etc, it is important to approach query construction correctly. This is important in all types of databases, but especially when dealing with on-disk data where the database is partitioned, as poorly structured queries can cause the entire database to be scanned to find the data needed to satisfy the query. While kdb+ generally evaluates left-of-right, the constraints on select statements are applied from left to right following the where statement. It is important to make sure that the first constraint in a request against a partitioned table is against the partition column (typically this will be date). For partitioned and non-partitioned tables, one should aim to reduce the amount of data that needs to be scanned/mapped as early as possible through efficient ordering of constraints. 3.1 Query Structure Example The purpose of this example is to examine the performance of queries with differently-ordered constraints as the database grows. In order to vary the size of the database, we will use .Q.view. To measure performance, we will use \ts to measure the execution time in ms and space used in bytes. Note that while the non-optimal requests complete successfully in our relatively small test database, these queries run much slower on a larger database. These queries should be executed with caution. The following queries will be performed, with OS disk cache flushed between requests by restarting the process and using the flush functionality in io.q. ```q //set the date to be requested q)d:first date //sym before date (non-optimal order) q)select from trade where sym=`IBM, date=d //date before sym (optimal order) q)select from trade where date=d, sym=`IBM ``` The results show that with non-optimal constraint order, the elapsed time for queries increases with the size of the db, while the request times for optimal constraint order is constant. The reason for the increase is that kdb+ has to inspect a much larger range of data in order to find the calculation components. One result of interest is the performance for the non-optimal request in a db containing 1 date; we are only looking at 1 date, therefore one might expect that the performance would be similar. In order to explain the difference here we have to recall that date is a virtual column in the database – inferred by kdb+ by inspecting the folder names in the partitioned db. When the partition column is a constraint, but not the first constraint, kdb+ creates this data for comparison. What we are observing is the cost of this promotion and comparison. Table 1 - Results from queries as database grows <table> <thead> <tr> <th>dates in db</th> <th>sym before date</th> <th>time (ms)</th> <th>size (b)</th> <th>date before sym</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td>1</td> <td></td> <td>470</td> <td>75,499,920</td> <td></td> <td>78</td> <td>75,499,984</td> </tr> <tr> <td>5</td> <td></td> <td>487</td> <td>75,878,400</td> <td></td> <td>78</td> <td>75,499,984</td> </tr> <tr> <td>10</td> <td></td> <td>931</td> <td>75,880,624</td> <td></td> <td>78</td> <td>75,499,984</td> </tr> <tr> <td>15</td> <td></td> <td>1,209</td> <td>75,882,912</td> <td></td> <td>78</td> <td>75,499,984</td> </tr> <tr> <td>20</td> <td></td> <td>1,438</td> <td>75,885,072</td> <td></td> <td>78</td> <td>75,499,984</td> </tr> </tbody> </table> Figure 1: Effect of constraint order on execution times The scale of the chart above has been adjusted to show that there is a slight difference in space used as reported by \texttt{ts} for each request. This is because the virtual column is promoted to an in-memory vector of date values for comparison if it is used as a constraint other than the first constraint. It should be noted that even for optimal constraint order, this is a high amount of space to use, given the size of the result set. We will address this when we look at attributes later. 4 PRECALCULATION For any system, it is advisable to pay particular attention to the queries that are commonly performed and analyse them for optimisations that can be made by precalculating components of the overall calculation. For example, if the db is regularly servicing requests for minute-interval aggregated data, then it probably makes sense to precalculate and store this data. Similarly, daily aggregations can be precalculated and stored for retrieval. 4.1 Precalculation As Query Grows The aim of this example is to show the impact on request times of precalculation and storage of intermediate/final calculation results. We will make baseline requests against our example date-partitioned trade table. For the precalculated data, we will create a new table (ohlc) with daily aggregated data, and save this as a date-partitioned table in the same database. Between each test, kdb+ will be restarted and the os cache will be flushed. ```k //make dictionary containing groups of distinct syms drawn from our sym universe q)syms:n!{(neg x)?sym}each n: 1 10 100 500 //make call for open prices for ranges of security drawn from the dictionary q)select open:first price by sym from trade where date=first date, sym in syms 1 ... q)select open:first price by sym from trade where date=first date, sym in syms 500 ``` Now we have a baseline for values drawn from the quote table, save a table with daily aggregates for each security ```k //create ohlc table with a number of different day-level aggregations, and save to disk using dpft function. q){ohlc::0!select open:first price, high:max price, low:min price, close: last price, vwap: size wavg price by sym from trade where date= x; .Q.dpft[`.;x;`sym;`ohlc];}each date //This will create one row per security/date pair. q)select count i by date from ohlc date | x --------| --- 2010.12.01| 500 2010.12.02| 500 ... 2010.12.30| 500 2010.12.31| 500 ``` //reload db q)\l . //repeat the same requests, but target our new aggregation table. q)select open by sym from ohlc where date=first date, sym in syms 1 ... q)select open by sym from ohlc where date=first date, sym in syms 500 Table 2 - Results from queries as more securities are requested <table> <thead> <tr> <th>sym values</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>265,056</td> <td>0</td> <td>2,896</td> </tr> <tr> <td>10</td> <td>13</td> <td>2,100,224</td> <td>0</td> <td>3,504</td> </tr> <tr> <td>100</td> <td>53</td> <td>16,781,680</td> <td>0</td> <td>12,400</td> </tr> <tr> <td>500</td> <td>125</td> <td>134,228,736</td> <td>0</td> <td>48,752</td> </tr> </tbody> </table> Figure 3: Effect of using precalculated data on execution times We can see that for a relatively low expenditure on storage, there are significant performance gains by pre-calculating commonly requested data or components of common calculations. 5 TAKE ADVANTAGE OF THE BUILT-IN MAP-REDUCE CAPABILITIES OF kdb+ PARTITIONED DATABASES For certain aggregation functions, kdb+ has built-in map-reduce capabilities. When a query crosses partitions - for example a multi-day volume weighted average price (VWAP), kdb+ identifies whether the aggregation can be map-reduced. If so, it will perform the map operation across each of the partitions. Some aggregations that support map-reduce are \textit{avg, count, max, min, sum, wavg}. Map-reduce implementation is transparent to the user. For requests that do not involve aggregation, the map component is simply a retrieval of the required rows, and the reduce combines to form the result table. 5.1 Map-reduce As Table Grows In this example, we will look at the impact of increasing the amount of data being aggregated. We will perform the same query over widening time periods. \begin{verbatim} //perform the same query over widening date windows //restart kdb+ and flush os cache between each request q)select size wavg price by sym from trade where date in 5#date ... q)select size wavg price by sym from trade where date in 20#date \end{verbatim} \begin{table}[h] \centering \begin{tabular}{|c|c|} \hline \textbf{dates in query} & \textbf{time (ms)} \\ \hline 5 & 1,863 \\ 10 & 3,152 \\ 15 & 4,596 \\ 20 & 7,597 \\ \hline \end{tabular} \caption{Results from queries using map-reduce} \end{table} When we look at the performance of the requests, we can see that due to map-reduce, the time for the calculation is scaling near-linearly as the number of dates increases. If there were no map-reduce implementation for this aggregation, the cost of mapping in all data then calculating over this dataset would lead to performance worse than linear scaling. It is possible to take advantage of this behavior with kdb+’s slaves, where the map calculation components are distributed to slaves in parallel, which can lead to very fast performance. The use of slaves is outside the scope of this paper. 6 USE OF ATTRIBUTES Attributes can be applied to a vector, table, or dictionary to inform kdb+ that the data has certain properties that allow different treatments to be applied when dealing with that data. 6.1 Parted Attribute: `p#` The parted index is typically used to provide fast access to sorted data in splayed on-disk tables, where the most commonly filtered and/or grouped field (often the instrument) has a sort applied prior to saving. It indicates that a vector is organized into contiguous (but not necessarily sorted) chunks. Applying `p#` allows kdb+ to identify the unique values within a vector quickly, and where in the vector the segments begin. The result of this is an improvement in the time required to perform a request, and also a reduction in the amount of data required to perform some calculations. The performance improvement will be most noticeable where the values in the vector are sufficiently repetitive. There is a memory overhead to set `p#` attribute on a vector, and kdb+ will verify that the data is actually parted as described. 6.2 Parted Attribute As Table Grows If we apply the `p#` attribute to the sym columns in the on-disk database we have created for testing and retry the example from the Query Structure example in section 3.1, one can see the benefits of the reduced work that kdb+ has to carry out to find the data it is looking for. We will then be able to compare the results and examine the impact from applying attributes. In this test, we want to examine the performance of queries applied against data partitioned by date and parted on sym, with the `p#` attribute applied to the sym column. The database will be varied in size using `.Q.view`, and between each test we will restart kdb+ and flush the os cache. ```k //add `p attribute using setattrcol from dbmaint.q //NOTE: setattrcol does not adjust the order of the data. Our data is already segmented by sym. qu)setattrcol[`:.;`trade;`sym;`p] qu) //set the date to be requested q)d:first date //sym before date (non-optimal order) qu)select from trade where sym=`IBM, date=d //date before sym (optimal order) qu)select from trade where date=d, sym=`IBM ``` Table 4 - Results from queries on data with `p`# attribute <table> <thead> <tr> <th>dates in db</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td>no attribute(from 3.1)</td> <td></td> <td></td> <td><code>p</code># set</td> <td></td> </tr> <tr> <td></td> <td>sym before date</td> <td>date before sym</td> <td></td> <td>sym before date</td> <td>date before sym</td> <td></td> </tr> <tr> <td>1</td> <td>470</td> <td>75,499,920</td> <td>78</td> <td>75,499,984</td> <td>3</td> <td>445,024</td> </tr> <tr> <td>5</td> <td>487</td> <td>75,878,400</td> <td>78</td> <td>75,499,984</td> <td>24</td> <td>889,936</td> </tr> <tr> <td>10</td> <td>931</td> <td>75,880,624</td> <td>78</td> <td>75,499,984</td> <td>26</td> <td>892,816</td> </tr> <tr> <td>15</td> <td>1,209</td> <td>75,882,912</td> <td>78</td> <td>75,499,984</td> <td>64</td> <td>896,336</td> </tr> <tr> <td>20</td> <td>1,438</td> <td>75,885,072</td> <td>78</td> <td>75,499,984</td> <td>177</td> <td>898,576</td> </tr> </tbody> </table> As we can see in the table above, when we compare optimal to non-optimal query construction there is still a significant increase in timings and space required when a non-optimal constraint order is used. However, in general the time and space required is much lower than the corresponding examples without `p`# applied. Figure 5: Effect of `p`# on execution times When we look at the results of the `p`# and non-optimal constraint order examples, we can see the benefits of both applying `p`# and using an optimal constraint order in the query. Initially, both optimal and non-optimal requests against the db with `p`# set are faster than their counterparts without attributes. As the database grows, we can see that the optimally ordered request without `p`# starts to outperform the non-optimal request with `p`# set. The reason for this is that requests with optimal constraint order only have to search within the data for one date. While `p`# has optimized the search within each date for the non-optimal request, the data it has to search through is growing as the db grows, and before long the work being done surpasses the work being done in the non `p# database. As the db grows it becomes clear that the best-performing version is with `p# applied and optimal constraint order. **Figure 6: Effect of `p# on workspace used** ![Graph showing effect of `p# on workspace used](image) The queries where `p# is set also require significantly less space for calculation than those without `p#. This is because kdb+ is able to move directly to the location in the sym vector that is of interest, rather than scanning sym to find values that match the constraint. ### 6.3 Sorted Attribute: `s# The sorted attribute indicates that the vector is sorted in ascending order. It is typically applied to temporal columns, where the data is naturally in ascending order as it arrives in real time. When kdb+ encounters a vector with `s# attribute applied, it will use a binary search instead of the usual linear search. Operations such as asof and within are much faster using the binary search. Requests for min and max can be fulfilled by inspecting the start and end of the vector, and other comparison operations are optimized. Setting `s# attribute on a vector has no overhead in terms of memory required, and kdb+ will verify that the data is sorted ascending before applying the attribute. #### 6.3.1 Sorted Attribute As Table Grows Let’s look at the impact on query performance of applying `s# as the dataset grows. We will be applying the `s# attribute to the time column by sorting the data on time as we select it from the on- disc data. As we are not interested in the contents of the calculation results, we can combine data from multiple dates in the database and sort on time to simulate growing realtime tables. Between each request, we will restart kdb+. ```kdb+ //create time we will use for test requests t:first 09:30:00.000+1?07:00:00.000 //create temporary table using one or more days of saved data - vary from 1 through 10 on each iteration rtquote:{`time xasc select from quote where date in x#date}1... rtquote:{`time xasc select from quote where date in x#date}10 //make requests against rtquote for IBM data. Repeat as the rtquote table grows select from rtquote where time=t, sym=`IBM //repeat process with `s removed from time vector rtquote:update `#time from{`time xasc select from quote where date in x#date}1... rtquote:update `#time from{`time xasc select from quote where date in x#date}10 ``` <table> <thead> <tr> <th>rows in table</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td>25,000,000</td> <td>49</td> <td>33,554,944</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>50,000,000</td> <td>102</td> <td>67,109,392</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>75,000,000</td> <td>154</td> <td>134,218,288</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>100,000,000</td> <td>213</td> <td>134,218,288</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>125,000,000</td> <td>247</td> <td>134,218,288</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>150,000,000</td> <td>299</td> <td>268,436,016</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>175,000,000</td> <td>368</td> <td>268,436,016</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>200,000,000</td> <td>406</td> <td>268,436,016</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>225,000,000</td> <td>523</td> <td>268,436,016</td> <td>0</td> <td>1,248</td> </tr> <tr> <td>250,000,000</td> <td>568</td> <td>268,436,016</td> <td>0</td> <td>1,248</td> </tr> </tbody> </table> ``` Table 5 - Results from queries on data with `s# attribute Figure 7: Effect of `s# on execution times We can see in the chart above the benefits from setting `s# on the time column. While the request times without the attribute grow linearly with the increase in data, the times for the requests against the data with the attribute set are uniform – in this case returning instantly. Figure 8: Effect of `s# on workspace used We observe similar results here for the amount of space used for the request. kdb+ is able to perform the calculation with a much smaller subset of the data. We can see that the curve representing space used for requests without an attribute set has a series of steps. These steps reflect the fact that kdb+’s buddy memory algorithm allocates according to powers of 2. 6.4 Unique Attribute: `u# The unique attribute is a hash map used to speed up searches on primary key columns, or keys of simple dictionary maps, where the list of uniques is large and/or lookups are very frequent. There is a memory overhead for applying `u# to a vector, and kdb+ will verify that the data is unique before applying the attribute. 6.4.1 Unique Attribute As Table Grows This example will examine the performance of the `u# attribute as the dataset being queried grows. The example data we’ve used for the previous examples does not contain values with a high enough degree of uniqueness to be used here. We will create some new data for this example using the q rand function. The table that we will use for this example will be similar to a last value cache, although to observe the behaviour, we will probably grow it beyond a reasonable size for tables of this form. ```q //function to create example last value cache keyed table with x rows //also creates global s to retrieve query value later q)mktbl:{([sym:s::(neg x)?`7];lprice:0.01*x?10000)} //make example table, vary through the values on each iteration q)tbl:mktbl 100 ... q)tbl:mktbl 10000000 //create test value q)req:first 1?s //directly index to retrieve value and create table q)enlist tbl[req] //repeat with `u# applied to sym column q)tbl:update `u#sym from mktbl 100 ... q)tbl:update `u#sym from mktbl 10000000 ``` ### Table 6 - Results from queries on data with `u#` attribute as table grows <table> <thead> <tr> <th>rows in table</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td>100</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> <tr> <td>1,000</td> <td>0</td> <td>1,536</td> <td>0</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> <tr> <td>10,000</td> <td>0</td> <td>16,896</td> <td>0</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> <tr> <td>100,000</td> <td>0</td> <td>131,584</td> <td>0</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> <tr> <td>1,000,000</td> <td>2</td> <td>1,049,088</td> <td>0</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> <tr> <td>10,000,000</td> <td>23</td> <td>16,777,728</td> <td>7</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> <tr> <td>100,000,000</td> <td>233</td> <td>134,218,240</td> <td>96</td> <td>528</td> <td>0</td> <td>1,040</td> <td>0</td> <td>528</td> </tr> </tbody> </table> ### Figure 9: Effect of `u#` on execution times as table grows The chart above shows that as the table size crosses 1m data points, the time taken for requests against non-attributed data starts to grow. Requests against attributed data remain uniform in response time, in this case returning instantly. In addition, it can be observed that directly indexing into the keyed table with no attributes applied is faster and uses less data than performing a `select` against it. ### 6.4.2 Unique Attribute as Query Grows For this example, we’ll create a static last value cache table and grow the number of sym values being requested. ```kx //function to create example last value cache keyed table with x rows //create global s to retrieve query value later q)mktbl:{{[sym:s::(neg x)?`7];lprice:0.01*x?10000}} //create fixed size example table q)tbl:mktbl 10000000 //make dictionary containing groups of distinct syms drawn from our sym universe q)syms:as!{(neg x)?s}each as:1 10 100 1000 10000 100000 //select value q)select lprice from tbl where sym in syms 1 ... q)select lprice from tbl where sym in syms 100000 //directly index to retrieve value and create table q)tbl each syms[1] ... q)tbl each syms[100000] //repeat with `u# applied to sym q)tbl:mktbl 10000000 q)update `u#sym from `tbl <table> <thead> <tr> <th>sym values</th> <th>select</th> <th>index</th> <th>`u# set</th> <th>select</th> <th>index</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>22</td> <td>16,777,776</td> <td>0</td> <td>608</td> <td>0</td> </tr> <tr> <td>10</td> <td>77</td> <td>83,886,624</td> <td>60</td> <td>1,392</td> <td>0</td> </tr> <tr> <td>100</td> <td>77</td> <td>83,886,624</td> <td>462</td> <td>9,872</td> <td>0</td> </tr> <tr> <td>1,000</td> <td>77</td> <td>83,886,624</td> <td>7,454</td> <td>88,976</td> <td>0</td> </tr> <tr> <td>10,000</td> <td>78</td> <td>83,886,624</td> <td>48,822</td> <td>1,033,616</td> <td>7</td> </tr> <tr> <td>100,000</td> <td>85</td> <td>83,886,624</td> <td>484,486</td> <td>9,546,128</td> <td>90</td> </tr> </tbody> </table> ``` Table 7 - Results from queries on data with `u# as query grows As we can see, selects against vectors with `u# applied significantly outperform those without an attribute applied. As the queries grow, we can see that there can be limitations to the performance gains with large queries. For the index syntax, the reason for this is that our example code is written in such a way that we are operating in a scalar fashion across the requested sym vector. This example is provided as commentary, not as an example of recommended design. As mentioned previously, `u# is typically applied to aggregation tables or dictionary keys, so it is unlikely to be required to service requests of the size we reach in this example. In a scenario where there is a large query domain, it may be faster to break up into smaller queries and combine the results. ### 6.5 Grouped Attribute: `g#` The grouped attribute is a conventional database 'index' of all instances of a particular value. The ability of kdb+ to maintain this in real time as data is inserted allows fast searching, grouping and filtering on important fields. Applying the grouped attribute to a column causes the regular search algorithm to be substituted for a hash based search. This allows developers to identify the unique values within a vector quickly, and to quickly retrieve the values required. There is a significant memory/disk cost for applying `g# to a vector. #### 6.5.1 Grouped Attribute As Table Grows This example is concerned with observing the performance of setting `g# on the sym column of a realtime quote table, which is typically ordered by time. We will observe the performance of locating matched through an unordered sym vector. As we are not interested in the contents of the calculation results, we can combine data from multiple dates in the database and sort on time to simulate growing realtime tables. We will not set any attribute on the time column, and will restart kdb+ between queries. //create rt quote table with `g#sym. Vary through 1-10 dates q)rtquote:update `g#sym, `#time from `time xasc select from quote where date in 1#date ... q)rtquote:update `g#sym, `#time from `time xasc select from quote where date in 10#date //select all IBM data from throughout the table q)select from rtquote where sym=`IBM //repeat the process for data without `g#sym q)rtquote:update `#time from `time xasc select from quote where date in 1#date ... q)rtquote:update `#time from `time xasc select from quote where date in 10#date <table> <thead> <tr> <th>rows in table</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td>25,000,000</td> <td>119</td> <td>301,990,304</td> <td>8</td> <td>2,228,848</td> </tr> <tr> <td>50,000,000</td> <td>243</td> <td>603,980,192</td> <td>10</td> <td>4,457,072</td> </tr> <tr> <td>75,000,000</td> <td>326</td> <td>1,207,959,968</td> <td>14</td> <td>8,913,520</td> </tr> <tr> <td>100,000,000</td> <td>472</td> <td>1,207,959,968</td> <td>20</td> <td>8,913,520</td> </tr> <tr> <td>125,000,000</td> <td>582</td> <td>1,207,959,968</td> <td>26</td> <td>8,913,520</td> </tr> <tr> <td>150,000,000</td> <td>711</td> <td>2,415,919,520</td> <td>30</td> <td>17,826,416</td> </tr> <tr> <td>175,000,000</td> <td>834</td> <td>2,415,919,520</td> <td>36</td> <td>17,826,416</td> </tr> <tr> <td>200,000,000</td> <td>931</td> <td>2,415,919,520</td> <td>40</td> <td>17,826,416</td> </tr> <tr> <td>225,000,000</td> <td>1,049</td> <td>2,415,919,520</td> <td>46</td> <td>17,826,416</td> </tr> <tr> <td>250,000,000</td> <td>1,167</td> <td>2,415,919,520</td> <td>50</td> <td>17,826,416</td> </tr> </tbody> </table> Table 8 – Results from queries on data with `g# attribute as table grows We can see from this example that even when sym values are distributed across the table, having `g# applied to the sym vector allows for a significant speedup. The chart showing space used shows a similar pattern to the timing curve. The slight increase in space used is because the result set is growing as the size of the table increases. 6.5.2 Grouped Attribute to Retrieve Daily Last As discussed, setting `g#` causes the regular search algorithm to be replaced with a hash-based search. We can make use of this hash directly using the group function with the column that has `g#` applied. To illustrate this, consider the following methods for calculating the last price for each symbol for a day of simulated real-time trade data. We will restart between examples: ```kdb //create simulated realtime trade table sorted on time q) rttrade: update `#time from `time xasc select from trade where date=first date q) ts select last price by sym from rttrade 24 33561280j //create simulated realtime trade table sorted on time q) rttrade: update `g#sym, `#time from `time xasc select from trade where date=first date q) ts select last price by sym from rttrade 15 33559232j //create simulated realtime trade table sorted on time q) rttrade: update `g#sym, `#time from `time xasc select from trade //use group on the sym column to get the indices for each sym and find //last value in each vector. Use these index values to directly index //into the price vector, then create a table with the results q) ts {1!([]sym:key x;price::value x)} rttrade`price last each group[rttrade`sym] 0 15072j ``` As we can see in the results above, using the same form of query with the attribute applied results in a significant speedup. However, using an alternative approach in which we retrieve the individual indices for each security, then find the last, results in a much faster calculation, and usage of much less data. 6.5.3 Grouped Attribute as Query Grows This example will examine the behaviour of `g#` as the requested universe grows. We will use more than one query format, and observe whether the format of the request impacts performance. The data used for the example is quote data drawn from our example database, and sorted on time to simulate realtime data. kdb+ will be restarted between tests. //make dictionary containing groups of distinct syms drawn from our sym universe q) syms: n!{(neg x)?sym} each n: 1 10 100 500 //create rt quote table with `g#sym q) rtQuote: update `g#sym, `#time from `time xasc select from quote where date=first date //comparing the performance of different query forms as we increase the number of securities requested q) select first bid by sym from rtQuote where sym in syms 1 ... q) select first bid by sym from rtQuote where sym in syms 500 q) raze{select first bid by sym from rtQuote where sym=x} each syms 1 ... q) raze{select first bid by sym from rtQuote where sym=x} each syms 500 <table> <thead> <tr> <th>sym values</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> <th>time (ms)</th> <th>size (b)</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>132</td> <td>301,990,624</td> <td>133</td> <td>301,991,104</td> <td>1</td> <td>787,408</td> <td>1</td> <td>787,904</td> </tr> <tr> <td>10</td> <td>197</td> <td>402,653,920</td> <td>1,319</td> <td>301,993,792</td> <td>29</td> <td>12,583,696</td> <td>13</td> <td>790,592</td> </tr> <tr> <td>100</td> <td>309</td> <td>402,653,920</td> <td>13,204</td> <td>302,020,608</td> <td>417</td> <td>201,327,824</td> <td>125</td> <td>817,408</td> </tr> <tr> <td>500</td> <td>444</td> <td>536,879,984</td> <td>27,484</td> <td>33,965,504</td> <td>3,634</td> <td>536,879,984</td> <td>616</td> <td>935,680</td> </tr> </tbody> </table> Table 9 - Results from queries on data with `g# attribute as query grows Figure 13: Comparison of query times with `g# attribute as query size grows NB: omitted curve for ‘using = and each’ without attributes in order to examine more closely the faster-returning examples. As we can see from the chart above, there are points at which it has been more performant to use = for comparison and loop over the universe of securities being requested, then join the result sets using raze. This is because select preserves the order of records in the table, so has to coalesce the indices from the `g# hash records for each security into a single ascending index when using in and a list, but this step is not necessary when using a function over a list of securities. Note: If an aggregation on sym is being performed, using a function and operating over the list of values will result in the same data set, but if an aggregation is not being performed (e.g. select from rtquote where sym = x), then the result sets will differ – the result set for the function format will have data grouped into contiguous sym groups. 7 CONCLUSION This paper has described a number of different techniques that are available to kdb+ developers when trying to optimise the performance of a kdb+ database when queried. We have looked at query structure, precalculation, map-reduce, and various effects from applying attributes to data. With each of these topics, we have attempted to provide an indication of the reasons for variations in the performance of kdb+, and identify some limits and edge cases associated with these techniques. It is important to point out that the use of these techniques should be married to an appropriate overall system design – taking into account the data structures they are being applied to, the type of access required, and any outside factors (hardware constraints, etc.). They should not be considered magic bullets that can be used to rescue an inefficient design – doing this will likely lead to larger problems in the longer term. It is recommended that developers experiment with the techniques outlined above - and additional performance techniques that we have not explored in this paper - to find the approach that best fits the use case being handled. Tests performed using kdb+ version 2.8 (2012.05.29)
{"Source-Url": "https://kx.com/media/2017/11/Columnar_database_and_query_optimization.pdf", "len_cl100k_base": 10525, "olmocr-version": "0.1.42", "pdf-total-pages": 26, "total-fallback-pages": 0, "total-input-tokens": 53467, "total-output-tokens": 11338, "length": "2e13", "weborganizer": {"__label__adult": 0.0004982948303222656, "__label__art_design": 0.00061798095703125, "__label__crime_law": 0.0005736351013183594, "__label__education_jobs": 0.0018110275268554688, "__label__entertainment": 0.00017714500427246094, "__label__fashion_beauty": 0.0002417564392089844, "__label__finance_business": 0.01788330078125, "__label__food_dining": 0.0006260871887207031, "__label__games": 0.0008282661437988281, "__label__hardware": 0.0012578964233398438, "__label__health": 0.0005121231079101562, "__label__history": 0.00039768218994140625, "__label__home_hobbies": 0.00018477439880371096, "__label__industrial": 0.0013360977172851562, "__label__literature": 0.00029158592224121094, "__label__politics": 0.0004494190216064453, "__label__religion": 0.00043129920959472656, "__label__science_tech": 0.06390380859375, "__label__social_life": 0.0001214146614074707, "__label__software": 0.0712890625, "__label__software_dev": 0.8349609375, "__label__sports_fitness": 0.0003192424774169922, "__label__transportation": 0.000888824462890625, "__label__travel": 0.0004038810729980469}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 35980, 0.09138]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 35980, 0.16463]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 35980, 0.8348]], "google_gemma-3-12b-it_contains_pii": [[0, 233, false], [233, 2806, null], [2806, 3872, null], [3872, 5195, null], [5195, 7002, null], [7002, 8682, null], [8682, 9181, null], [9181, 11102, null], [11102, 12013, null], [12013, 13776, null], [13776, 14017, null], [14017, 16198, null], [16198, 18092, null], [18092, 19760, null], [19760, 21492, null], [21492, 21861, null], [21861, 23640, null], [23640, 25187, null], [25187, 26647, null], [26647, 28297, null], [28297, 30013, null], [30013, 30355, null], [30355, 32321, null], [32321, 33721, null], [33721, 34765, null], [34765, 35980, null]], "google_gemma-3-12b-it_is_public_document": [[0, 233, true], [233, 2806, null], [2806, 3872, null], [3872, 5195, null], [5195, 7002, null], [7002, 8682, null], [8682, 9181, null], [9181, 11102, null], [11102, 12013, null], [12013, 13776, null], [13776, 14017, null], [14017, 16198, null], [16198, 18092, null], [18092, 19760, null], [19760, 21492, null], [21492, 21861, null], [21861, 23640, null], [23640, 25187, null], [25187, 26647, null], [26647, 28297, null], [28297, 30013, null], [30013, 30355, null], [30355, 32321, null], [32321, 33721, null], [33721, 34765, null], [34765, 35980, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 35980, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 35980, null]], "pdf_page_numbers": [[0, 233, 1], [233, 2806, 2], [2806, 3872, 3], [3872, 5195, 4], [5195, 7002, 5], [7002, 8682, 6], [8682, 9181, 7], [9181, 11102, 8], [11102, 12013, 9], [12013, 13776, 10], [13776, 14017, 11], [14017, 16198, 12], [16198, 18092, 13], [18092, 19760, 14], [19760, 21492, 15], [21492, 21861, 16], [21861, 23640, 17], [23640, 25187, 18], [25187, 26647, 19], [26647, 28297, 20], [28297, 30013, 21], [30013, 30355, 22], [30355, 32321, 23], [32321, 33721, 24], [33721, 34765, 25], [34765, 35980, 26]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 35980, 0.24872]]}
olmocr_science_pdfs
2024-11-22
2024-11-22
061bc70d24179a4450b44af3f31a1f08a8821c18
Modular Systems with Preferences Alireza Ensan and Eugenia Ternovska Simon Fraser University Canada {aensan,ter}@sfu.ca Abstract We propose a versatile framework for combining knowledge bases in modular systems with preferences. In our formalism, each module (knowledge base) can be specified in a different language. We define the notion of a preference-based modular system that includes a formalization of meta-preferences. We prove that our formalism is robust in the sense that the operations for combining modules preserve the notion of a preference-based modular system. Finally, we formally demonstrate correspondences between our framework and the related preference formalisms of cp-nets and preference-based planning. Our framework allows one to use these preference formalisms (and others) in combination, in the same modular system. 1 Introduction Combining knowledge bases (KBs) is very important when common sense reasoning is involved. For example, in planning, we may want to combine temporal and spatial reasoning, or reasoning from the point of view of several agents. Here, we focus on search problems, i.e., the problems where some input is given, and we are looking for a solution (e.g. a schedule, a trajectory, a business plan) according to a KB or a combination of KBs. Search problems are formalized as the task of Model Expansion (MX) [Mitchell and Ternovska, 2005], which is the task of expanding a given structure\(^1\) (that represents an instance of the problem) with interpretations of new relations and functions (that represent solutions) to satisfy a specification in some logic, e.g. first-order logic, Answer Set Programming, etc. For example, consider the problem of constructing a trajectory of a falling ball. The input structure represents the initial conditions, and it is expanded with interpretation of a function (or a predicate) that represents spatial coordinates of the ball over a time interval, to satisfy an axiomatization of the trajectory. Another example is, given initial situation on the input, construct a plan of actions for an agent to satisfy a certain goal, by taking into account action preconditions and effects. Modular Systems (MS) [Tasharrofi and Ternovska, 2011] is an extension to the MX framework. Each module (and a combination of them) is an MX task. Modules are combined through the operators of composition, union, projection, complementation and feedback. The framework is able to specify multi-component problems where their constituents are characterized in different languages. An algorithm for solving MSs was proposed in [Tasharrofi et al., 2011]. An improvement of the algorithm, in the same paper, uses approximations to reduce the search space. Connections to Satisfiability Modulo Theory and other systems were discussed in [Tasharrofi et al., 2011]. An important aspect of knowledge representation systems is the capability to represent preferences. The literature presents a variety of approaches to formalize preferences, e.g. [Brafman and Domshlak, 2009], [Santhanam et al., 2011], [Delgrande et al., 2003], [Brewka et al., 2010], [Sohrabi et al., 2008], [Boutilier et al., 2004a], [Delgrande et al., 2007], [Wilson, 2004], and [Faber et al., 2013]. Several surveys have appeared in recent years categorizing preference formalisms from various perspectives. For example, in [Baier and McIlraith, 2008], a set of preference formalisms for planning have been introduced. The authors of [Delgrande et al., 2004] classified preference frameworks in non-monotonic reasoning. Preferences in database systems have been broadly investigated by different researchers such as [Kiessling, 2002], [Borzsony et al., 2001] and [Stefanidis et al., 2011]. A primary well-known preference language in database systems was proposed in [Kiessling, 2002]. In this language, some preference constructors were introduced to express basic preference terms. For example, POS is a constructor that gives two n-arity tuples \( A = (a_1, \ldots, a_n) \) and \( B = (b_1, \ldots, b_n) \) and a set called POS. \( A \) is preferred to \( B \) (notation \( A >_P B \)) with respect to \( i^{th} \) attribute (column) in the database table if and only if \( A[i] \in \text{POS} \) and \( B[i] \notin \text{POS} \). Logical connectives can be also applied on basic preferences. This language offers operators for combining preferences to construct complex preference terms. Pareto and prioritized accumulation are two operators broadly used in several frameworks. Prioritized accumulation (notation \( \& \)) gives priority to a preference. Let \( A \) and \( B \) be tuples of the same relational schema \( R \). \( A \) is preferred to \( B \) (notation \( A >_{P_1 \& P_2} B \)) if and only if --- \(^1\)A structure, e.g. \( A = (A, R_1^A, \ldots, R_m^A, f_1^A, \ldots, f_k^A, c_1^A, \ldots, c_l^A) \) is a domain \( A \) together with an interpretation function \( I \) of relations \( R \) such that \( R^A = I(R) \subseteq A^n \), function symbols \( f \) where \( f^A = I(f) : A^m \to A \), and constants \( c \) where \( c^A = I(c) \in A \). A > _P_1 B \lor (A > _P_1 B \land B > _P_2 A \land A < _P_2 B).\) Pareto operator combines two preferences such that \(A\) is preferred to \(B\) with respect to composition of \(_P_1\) and \(_P_2\) \((P = P_1 \odot P_2)\) if and only if \((A > _P_1 B \land \neg(B > _P_2 A) \lor (A > _P_2 B \land \neg B > _P_1 A)).\) However, the main principles behind combinations of preference formalisms (possibly written in different languages) have not been fully formalized yet. Here are some key challenges of current formalisms: First, they cannot combine preferences in systems consisting of intricate interconnected parts (see feedback connection in Example 1 below). Second, preference terms are written in the same language such as [Ross, 2007] or [Kiessling, 2002] that use first-order logic to express preferences. They are not able to formalize preference composition in heterogeneous data systems. The following example clarifies the complexity of formalizing a modular system with preferences. **Example 1.** A Logistic Service Provider (LSP) is a modular system that can be used by a company such as Oracle. It decides how to pack goods and deliver them. It solves two NP-complete tasks interactively, – Multiple Knapsack module \(M_K\) and Travelling Salesman Problem (module \(M_{TSP}\)). The system takes orders from customers (items \(Items(i)\) to deliver, their profits \(p(i)\), weights \(w(i)\), and the capacity of trucks available \(c(t)\), decides how to pack Pack\((i, t)\) items in trucks, and for each truck, solves a TSP problem. The feedback about solvability of TSP is sent back to \(M_K\). Module \(M_{TSP}\) takes a candidate solution from \(M_K\), together with the graph of cities and routes with distances, allowable distance limit and destinations for each product. The output of this module is the route, for each truck Route\((t, n, c)\), where \(t\) is a truck, \(n\) is the number in the sequence, and \(c\) is a city. The Knapsack problem is written, in, e.g. Integer Linear Programming (ILP), and TSP in Answer Set Programming (ASP). The modules \(M_K\) and \(M_{TSP}\) are composed in sequence, with a feedback going from an output of \(M_{TSP}\) to an input of \(M_K\). A solution to the compound module, \(M_{LSP}\), to be acceptable, must satisfy both sub-systems. The company may have preferences for packing and delivery of products. E.g. if a fragile item is packed in a truck, it may be preferred to exclude heavy items. Among certain routes with equal costs, some of them may be preferred to others. It is possible that preferences in the Knapsack problem are formalized by cp-nets [Boutilier et al., 2004a] and the TSP’s preferences are represented in preference-based Answer Set Programming framework [Brewka et al., 2003]. In Figure 1, \(P_k\) denotes the preferences of the knapsack module and \(P_{TSP}\) denotes the TSP module’s preferences. Formulating this modular problem with preferences is not easy because: 1) the Knapsack and the TSP are axiomatized in different languages, 2) preferences of each module are represented by a different formalism, 3) preference formalisms use different languages than the axiomatizations of the modules themselves, 4) two modules communicate in a complex way that includes a feedback loop from \(M_{TSP}\) to \(M_K\). **Contributions** We propose model-theoretic foundations for combining KBs with preferences in modular systems. On the logic level, each module is represented by a KB in some logic \(L^2\), and its preferences (and meta-preferences) are represented by (strict) partial orders on partial structures in a preference formalism named \(P\) - \(MS\). Different logics and preference formalisms can be used for modules in the same system. Operations for combining modules are generalized to combine preferences of each module. We prove that our formalism is robust in the sense that the operations for combining modules preserve the notion of a preference-based modular system. Our formalism is consistent with (and extends) the model-theoretic semantics of modular systems [Tasharrofi and Ternovska, 2011]. In model theoretic semantics, an MX task is viewed as a set of structures, where each input is expanded with solutions. We also prove that our formalism represent cp-nets and preference-based planning. Thus we can combine them in one modular system. **Novelty** With our formalism, each module can be formalized in a different framework. To our knowledge, this is the first multi-language preference formalism. This generality is achieved through the model-theoretic semantics of modular systems. Another novelty is the ability of handling preferences in complexly structured systems. For instance, in Example 1, there is a complex combination of Knapsack and TSP problems (feedback from TSP to Knapsack). In contrast, these complex systems were not representable in previous work. E.g., in [Kiessling, 2002]. **2 Preliminaries** A vocabulary (denoted, e.g. \(\tau, \sigma, \varepsilon\)) is a set of non-logical (predicate and function) symbols. A \(\tau\)-structure is a domain (a set), and interpretation of vocabulary symbols in \(\tau\). In [Tasharrofi and Ternovska, 2011], the authors formalize combinatorial search problems as the task of model expansion (MX), the logical task of expanding a given structure with new relations. Formally, the user axiomatizes the problem in some logic \(L\). This axiomatization relates an instance of the problem (a finite structure), and its solutions (expansions of that structure with new relations or functions). Logic \(L\) corresponds to a specification/modeling language. It could be an ASP program, or a specification in a language from the CP community, or even a Java program, as long as model-theoretic semantics can be provided. \(^2\)Any logic with model-theoretic semantics can be used, including logic programs. Definition 1 (Model Expansion task). Given: a formula $\phi$ in logic $\mathcal{L}$ with a vocabulary $\sigma \cup \varepsilon$, such that $\sigma \cap \varepsilon = \emptyset$ and $\sigma$-structure $\mathcal{A}$. Find: structure $\mathcal{B}$ that expands $\mathcal{A}$ to $\sigma \cup \varepsilon$ and satisfies $\phi$. We call $\sigma$ instance and $\varepsilon$ expansion vocabularies. Definition 2 (Module). A module is a set (class) of $\sigma \cup \varepsilon$-structures, where $\sigma \cap \varepsilon = \emptyset$. A module can be given by any decision procedure, be a set of models of a KB, be given by an inductive definition, a C or an ASP program, or by an agent making decisions. Modules of [Tasharrofi et al., 2011] were introduced as model expansion tasks. The view of Definition 2 is equivalent. In modular systems, information propagation happens through vocabulary symbols that are equal. Modules are combined using the following algebraic operations. Projection ($\pi_i(M)$) hides some vocabulary of a module. Composition ($M_1 \triangleright M_2$) connects outputs of $M_1$ to inputs of $M_2$. Union ($M_1 \cup M_2$) models choice. Complementation ($\bar{M}$) does "the opposite" of what $M$ does. Feedback ($M[R=S]$) connects output $S$ of $M$ to its input $R$ and was inspired by feedbacks in logical circuits. Intuitively, the operations correspond to conjunction, disjunction, negation and existential quantifier. Feedback represents fixpoints (not necessarily minimal) of modules viewed as operators. One can introduce other operations, e.g. least fixpoints or combinations of the operations above. We now define the syntax of the algebra of modular systems. Following [Järvisalo et al., 2009], we say modules $M_1$ and $M_2$ are composable if $\varepsilon_{M_1} \cap \varepsilon_{M_2} = \emptyset$ (no output interference). Module $M_2$ is independent from $M_1$ if $\varepsilon_{M_2} \cap \varepsilon_{M_1} = \emptyset$ (no cyclic dependencies). A module is primitive if the only sub-module (algebraic sub-formula) of it is itself. Well-formed modular systems $MS(\sigma, \varepsilon)$, with instance ($\sigma$) and expansion ($\varepsilon$) vocabularies, are defined recursively. - If $M$ is a primitive module with instance (input) vocabulary $\sigma$ and expansion (output) vocabulary $\varepsilon$, then $M \in MS(\sigma, \varepsilon)$. - If $M \in MS(\sigma, \varepsilon)$, $\tau \subseteq \sigma \cup \varepsilon$, then $\pi_\tau(M) \in MS(\sigma \cap \tau, \varepsilon \cap \tau)$. - If $M \in MS(\sigma, \varepsilon)$, $M' \in MS(\sigma', \varepsilon')$, $M$ is composable with and independent from $M'$, then $(M \triangleright M') \in MS(\sigma \cup (\sigma' \setminus \varepsilon), \varepsilon \cup \varepsilon')$. - If $M \in MS(\sigma, \varepsilon)$, $M' \in MS(\sigma', \varepsilon')$, and they are independent, then $(M \cup M') \in MS(\sigma \cup \sigma', \varepsilon \cup \varepsilon')$. - If $M \in MS(\sigma, \varepsilon)$, $R \subseteq \sigma$, $S \subseteq \varepsilon$, and $R$ and $S$ are of the same type and arity, then $M[R=S] \in MS(\sigma \setminus \{R\}, \varepsilon \cup \{R\})$. - If $M \in MS(\sigma, \varepsilon)$, $\mathcal{A} \subseteq MS(\sigma, \varepsilon)$. A modular system is given by an algebraic formula, with input-output vocabulary specified for each primitive module. Subsystems correspond to sub-formulas and are modules themselves. Model-theoretic semantics associates, with each modular system, a set of structures. Each such structure is called a model of the modular system. The semantics does not put any finiteness restriction on the domains. Thus, the framework works for modules with infinite structures. We assume that the domains of all structures are included in a (potentially infinite) universal domain $U$. Definition 3 (Models of a Modular System). Let $M \in MS(\sigma, \varepsilon)$ be a modular system and $\mathcal{B}$ be a $(\sigma \cup \varepsilon)$-structure. We construct the set $M^{\text{out}}$ of models of module $M$ by structural induction on the structure of a module. **Primitive Module:** $\mathcal{B}$ is a model of $M$ if $\mathcal{B} \in M$. **Projection:** $B$ is a model of $M := \pi_{i \cup \varepsilon}(M')$ (with $M' \in MS'(\sigma', \varepsilon')$) if a $(\sigma' \cup \varepsilon')$-structure $B'$ exists such that $B'$ is a model of $M'$ and $B'$ expands $\mathcal{B}$. **Composition:** $B$ is a model of $M := M_1 \triangleright M_2$ (with $M_1 \in MS(\sigma_1, \varepsilon_1)$ and $M_2 \in MS(\sigma_2, \varepsilon_2)$) if $\mathcal{B}|(\sigma_1 \cup \varepsilon_1)$ is a model of $M_1$ and $\mathcal{B}|(\sigma_2 \cup \varepsilon_2)$ is a model of $M_2$. **Feedback:** $B$ is a model of $M := M[R=S] = MS(\sigma', \varepsilon')$ if $R^B = S^B$ and $\mathcal{B}$ is model of $M'$. To save space, we skip union and complementation. E.g. the Knapsack-TSP system in Example 1 is formalized as $MS_{LSP} = [M_K \triangleright M_T]_{SP} \triangleright B = B'$. Partial structures allow interpretation of some vocabulary symbols to be partially specified. The algorithm for solving modular systems [Tasharrofi et al., 2011] constructs expansions incrementally, by adding information to partial structures. Definition 4. $B$ is a $\tau_p$-partial structure over vocabulary $\tau$ if: (1) $\tau_p \subseteq \tau$, (2) $B$ gives a total interpretation to symbols in $\tau \setminus \tau_p$, and (3) for each $n$-ary symbol $R$ in $\tau_p$, $B$ interprets $R$ using two sets $R^+$ and $R^-$ such that $R^+ \cap R^- = \emptyset$, and $R^+ \cup R^- \neq \text{dom}(B)^n$. Definition 5. For two partial structures $B$ and $B'$ over the same vocabulary and domain, we say that $B$ extends $B'$ if all undefined symbols in $B$ are also undefined in $B'$. Notation 1. Let $V = \{a_1, a_2, ..., a_n\}$ be a set of vocabulary symbols. Let $A$ be a partial structure that interprets a subset $X \subseteq V$ such that $V \setminus X$ is undefined. Each $a_i \in X$ can be interpreted as false, represented by $a_i^-$, or as true, represented by $a_i^+$. Suppose $Y$ is a set of the form $\{a_i^+, a_i^-, a_i^0\}$ where $a_i^0 = a_i^+ \lor a_i^-$. We assume that set $Y$ is representation of partial structure $A$. 3. $\mathcal{P}$-MS: Preference-based Modular Systems In this section we introduce Preference-based Modular Systems ($\mathcal{P}$-MS). To have a formalism compatible with model theoretic semantics of modular systems, we define preference statements based on the concept of structures. However, using structures to model preferences is not always practical. Formally speaking, some interpreted symbols may be preferred to others, and there could not be enough information to decide about the rest. Unlike structures, partial structures interpret a subset of vocabulary symbols, while interpretation of other symbols is unknown. The idea of partial structures originates from the notion of three-valued logic that a truth value of a statement can be true, false, or unknown [Kleene, 1952]. In our formalism, a preference statement can be represented by a partial order over a set of partial structures when certain conditions hold. First, we explain the meaning of strict partial order. Definition 6. A strict partial order $\mathcal{O}$ over a set $S$ is a pair $\mathcal{O} = (S, \prec)$ such that $\prec$ is a binary relation over elements of $S$ that is anti-reflexive, asymmetric and transitive. Now, we define one preference statement for a primitive module (single model expansion task). Definition 7. Let \( M \) be a primitive module and \( \text{vocab}(M) = \tau \). A \( \tau \)-preference (or simply called preference) \( \mathcal{P} = (O, \Gamma) \) in \( M \) is a pair where \( O = (S, \prec) \) is a strict partial order over \( S \) that is the set of all \( \tau \)-partial structures in \( M \) where \( \tau \subseteq \tau \). As well, \( \Gamma = \{\Gamma_1, \Gamma_2, ..., \Gamma_m\} \) is a set of \( \tau \)-partial structures, \( 1 \leq i \leq m \), in \( M \) that \( \tau \subseteq \tau \). In practical domains, preferences are usually represented by conditional statements. In the above definition, we utilize a set of partial structures \( \Gamma \) to express the premises of a preference statement, and \( O \) represents the conclusion. Once the preference has been defined, a preferred structure is introduced as follows: Definition 8. Let \( M \) be a primitive module, and \( B, B' \) be two structures in \( M \). Given preference \( \mathcal{P} = (O, \Gamma) \) in \( M \), let \( \Delta \) be a set of all structures in \( M \) that extend at least one member of \( \Gamma \). We say structure \( B \) is preferred to \( B' \) with respect to \( \mathcal{P} \) (denoted by \( B \succ \mathcal{P} B' \)) if 1) \( B, B' \in \Delta \), 2) there are partial structures \( B_i, B_j \) over \( \text{vocab}(M) \) that can be extended to structures in \( M \) such that \( B_i \succ B_j \), and \( B \) is an extension of \( B_i \), where \( B' \) extends \( B_j \), and 3) there are no partial structures \( B_k \) and \( B_m \) such that \( B \) and \( B' \) extend them respectively and \( B_m \succ B_k \). This definition states that when a part of \( B \) is preferred to \( B' \), if a condition specified by \( \Gamma \) is satisfied by both structures, we can conclude that \( B \) is preferred to \( B' \). It makes no difference how the rest of the vocabulary is interpreted because it is irrelevant to \( \mathcal{P} \). Example 2. In Example 1, consider that safety of delivering items is an important preference for the company. So, it is preferred to avoid packing heavy and light items together to reduce the risk of damage to the light items. Let \( \mathcal{P}_{\text{safe}} = (O_{\text{safe}}, \Gamma_{\text{safe}}) \) be the safety preference where \( O_{\text{safe}} = (S, \prec) \) is a partial order over \( S \) that is the set of all items. Relation \( \prec \) is defined as \{pack\( ^- (i) \prec \text{pack}(i))[w(i) \leq W]\}; it means that for each item \( i \) that is lighter than a constant weight \( W \), it is preferred to not put \( i \) in the pack. According to Notation 1, pack\( ^- \) is a representation of a partial structure that interprets ground atom pack\( (i) \) as false. The premise of the conditional statement is formalized by \( \Gamma_{\text{safe}} = \{\Gamma_1, \Gamma_2, ..., \Gamma_m\} \) where \( \Gamma_i = \{\text{item}(i), w(i)\} \) such that \( w(i) \geq W \). This states when there is an item with weight not less than \( W \), it is preferred to not include items lighter than \( W \) in the pack. Definition 9. For two structures \( B, B' \in M \), if a) neither \( B \succ \mathcal{P} B' \) nor \( B' \succ \mathcal{P} B \), b) for any \( B'' \in M \), if \( B'' \succ \mathcal{P} B \) then \( B'' \succ \mathcal{P} B' \), and c) if \( B \succ \mathcal{P} B' \) then \( B \succ \mathcal{P} B'' \), they are called equally preferred with respect to \( \mathcal{P} \) and are represented by \( B \equiv \mathcal{P} \). If one of the conditions (b) or (c) do not hold, then \( B \) and \( B' \) are incomparable and are represented by \( B \equiv \mathcal{P} B' \). Also, \( B \equiv \mathcal{P} B' \) means that \( B \succ \mathcal{P} B' \) or \( B \equiv \mathcal{P} B' \). Considering that a module is defined as a set of structures, we can conclude the following: Proposition 1. Given a preference \( \mathcal{P} = (O, \Gamma) \) in module \( M \), the pair \( (\pi, \preceq_\pi) \) is a strict partial order, \( \approx_\pi \) is an equivalence relation over structures of \( M \), and \( \geq_\pi \) is a transitive and reflexive binary relation over structures of \( M \). Meta-Preferences In practice, each module may have more than one preference. Some of them may be preferred to others. The question then arises how a preferred structure is defined in this case. The notion of meta-preference addresses this question. Definition 10. Given a module \( M \) and a set of preferences \( \Pi = \{P_1, P_2, ..., P_n\} \), let \( \Omega_i = \{P_j \in \Pi | (P_j \succ P_i) \lor (P_j \preceq P_i)\} \) be a subset of \( \Pi \) such that its elements have order relation with \( P_i \). Assume \( O_{\mathcal{M}} = (\Pi, \prec) \) is a strict partial order over elements of \( \Pi \). Binary relation \( \succ \mathcal{M} \succ \mathcal{P} \) over structures of \( M \) is defined as: \[ B \succ \mathcal{M} \succ \mathcal{P} B' \text{ if there is a preference } P_j \in \Omega_i \text{ such that } B \succ \mathcal{P} P_j \text{ and } \] - there does not exist \( P_j \in \Omega_i \) that \( P_j \succ \mathcal{P} \) with respect to \( O_{\mathcal{M}} \) and \( B' \succ \mathcal{M} \succ \mathcal{P} \), and - there is no a preference \( P_k \in \Pi \backslash \Omega_i \) that \( B' \succ \mathcal{P} \). Meta-preference \( \mathcal{M} \) is characterized as \( \mathcal{M} = (O_{\mathcal{M}}, \prec) \). We say structure \( B \) is preferred to \( B' \) with respect to binary relation \( \succ \mathcal{M} \subseteq M \times M \) (notation \( \succ \mathcal{M} B' \)) whenever if \( \exists B'' \in M \mid B' \succ \mathcal{M} B'' \), then \( B' \not\succ \mathcal{M} B'' \). This definition states that structure \( B \) is preferred to \( B' \) with respect to \( \mathcal{M} \) if we can find a preference such as \( P \), that \( B \succ \mathcal{P} \), and there is no preference that makes \( B' \) preferred to \( B \). If there is a preference \( P \), such that \( B \succ \mathcal{P} B \) then \( B \) is not preferred to \( B' \) with respect to the meta-preference unless \( P \) is preferred to \( P \). Also, the definition prevents conflicts may happen between a mix of preferences, though it does not guarantee transitivity of \( \succ \mathcal{M} \). If \( B \) is preferred to \( B' \) with respect to \( \mathcal{M} \), and if \( B' \) is preferred to \( B'' \), then \( B'' \) cannot be preferred to \( B \) with respect to \( \mathcal{M} \). Example 3. In Example 1, assume that the company has more than one preference. If an expensive item is selected for delivery, it is not secure to have another precious item in the pack that is specified by \( \mathcal{P}_{\text{security}} \). Assume we have a meta-preference \( \mathcal{M} \) such that \( \Pi_{\text{K}} = (\mathcal{P}_{\text{safe}}, \mathcal{P}_{\text{security}}) \) and \( \mathcal{M} = (\mathcal{P}_{\text{safe}} < \mathcal{P}_{\text{security}}) \). To have a preferred packing for the Knapasack module, when there is a heavy and expensive item in the pack, it is preferred to not include another heavy item, but it is fine to have two expensive items in the pack. Preference-based Modular Systems Up to now, we defined a preference \( \mathcal{P} \) in a single primitive module. In what follows, we study how a preference in a modular system is modelled when preferences of its components are given. Definition 11. Let \( M = M_1 \succ M_2 \) be a modular system, \( \text{vocab}(M_1) = \tau_1 \), and \( \text{vocab}(M_2) = \tau_2 \). Given \( \mathcal{P}_1 = (O_1, \Gamma_1) \) in \( M_1 \) and \( \mathcal{P}_2 = (O_2, \Gamma_2) \) in \( M_2 \), for \( B, B' \in M \), \( B \) is preferred to \( B' \) with respect to \( \mathcal{P}_1 \) and \( \mathcal{P}_2 \), and is represented by \( B \succ \mathcal{P}_1 \succ \mathcal{P}_2 B' \) when \( B|\tau_1 \succ \mathcal{P}_1 B'|\tau_1 \) and \( B|\tau_2 \succ \mathcal{P}_2 B'|\tau_2 \), where \( B|\tau \) is restriction of \( B \) to \( \tau \). Informally, \( B \) is preferred to \( B' \) with respect to \( \mathcal{P} = \mathcal{P}_1 \succ \mathcal{P}_2 \), if \( B \) is preferred to \( B' \) with respect to \( \mathcal{P}_1 \) when they are restricted to the vocabulary of \( M_1 \) and with respect to \( \mathcal{P}_2 \) when they are restricted to the vocabulary of \( M_2 \). Example 4. In Example 1, for module \( M_{\text{isp}} \), suppose that if cities \( c_1, c_2, c_3, c_4 \) are in the set of destinations, there is a path from $c_1$ to $c_4$ through $c_2$ that is preferred to the path from $c_1$ to $c_4$ through $c_3$. This can be formalized by preference $P_{\text{LP}} = (O_{\text{LP}}, \Gamma_{\text{LP}})$ where $O_{\text{LP}} = (S_{\text{LP}}, \prec)$ is a partial order over $S_{\text{LP}}$, that is the set of all possible routes. For a positive integer $k$ and truck $t$, \[ \{ \text{Route}(k, c_1, t), \text{Route}(k + 1, c_2, t), \text{Route}(k + 2, c_4, t) \} = \text{Route}(k, c_1, t), \text{Route}(k + 1, c_3, t), \text{Route}(k + 2, c_4, t) \} \] and $\Gamma_{\text{LP}} = \{ \text{Dest}(1, c_1), \text{Dest}(2, c_2), \text{Dest}(3, c_3), \text{Dest}(4, c_4) \}$. A preferred plan of packing and delivery with respect to $P_{\text{LP}}$ depends on whether heavy and light items are not in the same pack and if the truck is supposed to visit cities $c_1, c_2, c_3, c_4$, then taking road $(c_1, c_2)$ is preferred to $(c_1, c_3)$. We now extend this notion to meta-preferences. **Definition 12.** Let $M = M_1 \uplus M_2$ and let’s assume $\text{vocab}(M_1) = \tau_1$ and $\text{vocab}(M_2) = \tau_2$. Assume that $\Pi_1$ is a set of preferences in $M_1$ and $\Pi_1$ is a meta-preference over $\Pi_1$. Similarly, $\Pi_2$ and $\Pi_2$ are a set of preferences and a meta-preference respectively in $M_2$. For $B, B' \in M$, $B$ is preferred to $B'$ with respect to $\Pi$ and $\Pi_2$, and is represented by $B \succ_{\Pi} B'$ or $B \succ_{\Pi_2} B'$. We proceed to the union operator. **Definition 13.** Let $M = M_1 \uplus M_2$ be a modular system. Suppose $\text{vocab}(M_1) = \tau_1$ and $\text{vocab}(M_2) = \tau_2$. Assume $\Pi_1$ and $\Pi_2$ are preferences in $M_1$ and $M_2$ respectively. For $B, B' \in M$. If $B \succ_{\Pi} B'$ or $B \succ_{\Pi_2} B'$ then $B$ is preferred to $B'$ with respect to $\Pi_1 \cup \Pi_2$ and is denoted by $B \succ_{\Pi \cup \Pi_2} B'$. For meta-preferences we have: **Definition 14.** Let $M = M_1 \uplus M_2$ be a modular system. Suppose $\text{vocab}(M_1) = \tau_1$ and $\text{vocab}(M_2) = \tau_2$. Let $\Pi_1$ be a set of preferences in $M_1$ and $\Pi_1$ is a meta-preference over $\Pi_1$, and let $\Pi_2$ be a set of preferences in $M_2$ and $\Pi_2$ is a meta-preference over $\Pi_2$. For $B, B' \in M$. $B \succ_{\Pi} B'$ if $B \succ_{\Pi_1} B'$ or $B \succ_{\Pi_2} B'$. Let us comment briefly on the feedback operator. Let $M$ be a $\sigma \uplus \varepsilon$ modular system, $R \in \sigma$, and $S \in \varepsilon$. If $R$ and $S$ are two vocabulary symbols of the same type and arity, then $M[R = S]$ is a $(\sigma \setminus \{ R \}) \uplus (\varepsilon \cup \{ R \})$ modular system. The feedback operator does not change the vocabulary of a module. Hence, definition of a preference remains unchanged. When $B \succ \triangleright B'$ holds in $M$, if $B$ and $B'$ are also structures of $M'$, we conclude that $B$ is preferred to $B'$ in $M'$. **Definition 15.** Let’s assume $M' = M[R = S]$ and $P = (^{\sigma}, ^{\varepsilon}, \Gamma)$ are preferences in $M$. For $B, B' \in M$, whenever $R^B = S^B$ and $R^{B'} = S^{B'}$, then $B \succ \triangleright B'$, where $B \succ \triangleright B'$. This definition says that if two structures $B$ and $B'$ are in $M$, and $B$ is preferred to $B'$ with respect to $P$ then $B$ remains preferred to $B'$ in module $M'$ that is module $M$ with feedback. The following definition introduces meta-preferences in a module with feedback operator. **Definition 16.** Assume $M' = M[R = S]$, $P$ is a set of preferences in $M$, and $MP$ is a meta-preference over $P$. Assume that $B, B' \in M$, and $B, B' \in M$. If $B \succ \triangleright B'$ in $M$, then $B \succ \triangleright MP B'$ in $M'$. In the model expansion task, in a general sense, there are vocabulary symbols (notation $\pi$) that are hidden from outer observers while they are interpreted by the structures of the module. By considering the fact that projection operator hides some visible vocabulary symbols of the module, we present the following definition. **Definition 17.** Let’s assume $M' = \pi(M)$, where $\text{vocab}(M) = \tau$ and $\text{vocab}(M') = \tau'$ ($\tau$ and $\tau'$ are visible vocabularies). For $B_\pi, B'_\pi \in M'$, if there are structures $B$ and $B'$ in $M$ such that $B \succ \pi B_\pi$ and $B' \succ \pi B'_\pi$ and $B \succ \pi B'$, then we say $B \succ \pi B'_\pi$ on the condition that for all vocabulary symbols $R \in (\tau \setminus \tau') \subseteq \varepsilon_1$ the following holds: $L_B = L_{B'}$ and $L_B' = L_{B'}$. Intuitively, given two structures $B_\pi$ and $B'_\pi$ in $M'$, if we can find two structures $B$ and $B'$ in $M$ such that they expand $B_\pi$ and $B'_\pi$, if $B$ is preferred to $B'$ with respect to $\Pi$, we can conclude that $B_\pi$ is also preferred to $B'_\pi$. We proceed to meta-preferences. **Definition 18.** $M' = \pi(M)$, $\text{vocab}(M) = \tau$, and $\text{vocab}(M') = \tau'$ ($\tau$ and $\tau'$ are visible vocabularies). Assume $B_\pi, B'_\pi \in M'$, if there are structures $B$ and $B'$ in $M$ such that $B \succ \pi B_\pi$ and $B' \succ \pi B'_\pi$ and $B \succ \pi B'$, then we say $B \succ \pi B'_\pi$ on the condition that for all vocabulary symbols $R \in (\tau \setminus \tau') \subseteq \varepsilon_1$ the following holds: $L_B = L_{B'}$ and $L_B' = L_{B'}$. A preferred modular system $\mathcal{P}$-$MS$ is a modular system with a partial order over its preferences. **Definition 19.** A modular system $MS$ with a set of preferences $\Pi$ is a preferred modular system, notation $\mathcal{P}$-$MS$, if it is specified by a pair $(\Pi, MS)$ where $MP$ is a meta-preference in $MS$. The following statement shows the robustness of our notions and is proven by structural induction. **Theorem 1.** Assume for some $n$, a modular system $MS$ is obtained from $M_1, M_2, ..., M_n$, where $MS_i, 1 \leq i \leq n$ are modular systems, by using operations in modular systems including composition, union, feedback, and projection. For all $1 \leq i \leq n$, if $M_i$ is $\mathcal{P}$-$MS$ then $M$ is also $\mathcal{P}$-$MS$. 4 Relation with Two Preference Formalisms We now describe two preference formalisms and show how they can be related to our formalism. **CP-Nets** *Ceteris paribus* (cp) network is a graphical representation of conditional preferences with reasoning capability [Boutilier et al., 2004b]. The idea underlying cp-nets is to compare different assignments to a set of variables as some of these variables are conditionally dependent on each other. Each node represents an attribute (variable) connected to its parents through directed edges. A preference over domain values of a variable is dependent on all of its parents value. The dependency is shown by a Conditional Preference Table (CPT) represented as an annotation for each node. There exists an induced graph derived from each cp-net that shows ordering relation between a subset of outcomes. Each node in the induced graph represents an outcome and each directed edge exhibits ordering relation between nodes. An outcome \( o_1 \) is preferred to \( o_2 \) if in the induced graph, there is a path from \( o_1 \) to \( o_2 \). An induced graph comprises all information about preferences over outcomes that can be derived from a cp-net. From the syntactic point of view, \( \mathcal{P}\)-\( MS \) is able to capture the notion of attributes in cp-nets. Each attribute can be viewed as an interpreted predicate symbol in the context of \( \mathcal{P}\)-\( MS \). Therefore, an outcome in a cp-net can be represented by a structure that interprets vocabulary symbols. The relation between cp-nets and \( \mathcal{P}\)-\( MS \) in this way implies that the space of all outcomes in a cp-net can be modelled by a set of structures interpreting vocabulary symbols in \( \mathcal{P}\)-\( MS \). A preference statement visualized by a cp-net over a set of variables \( V = \{V_1, ..., V_n\} \) is an ordering over domain values of a variable that may or may not be dependent on some other variables, and a preference in \( \mathcal{P}\)-\( MS \) is defined as \( \mathcal{P} = (\mathcal{O}, \Gamma) \) where \( \mathcal{O} \) is a partial order given a set of partial structures \( \Gamma \). In a sense, a partial structure in \( \mathcal{P}\)-\( MS \) is a combination of some interpreted vocabulary symbols. Thus, a partial structure can stipulate a value assigned to an attribute. Orderings over partial structures in our formalism are in fact orderings over attribute values in cp-nets when partial structures in \( \mathcal{O} \) are assumed to interpret only one vocabulary symbol. Transforming the condition part of the preference statement in a cp-net is straightforward. Order relation holds for partial structures which extend \( \Gamma \). Therefore, parents of each cp-net attribute can be represented by \( \Gamma \). In order to establish the correspondence between the semantic of cp-nets and \( \mathcal{P}\)-\( MS \), first we explain the concept of flip-over in cp-nets. In an induced graph derived from a cp-net, each outcome node has one attribute value preferred to its child’s while other attributes are assumed to be fixed. Therefore, by moving from a node to its children one attribute value is changed that is called a flip-over. A path in an induced graph is a chain of flip-overs between two outcomes. Hence, an outcome is preferred to another when single or multiple flip-over(s) exist between them. Now, we show how a flip-over can be represented in \( \mathcal{P}\)-\( MS \). Consider two structures \( B \) and \( B' \): if \( B \geq_{MP} B' \) (\( \geq_{MP} \) means that \( \geq_{MP} \) or \( \simeq_{MP} \) that is an equivalence relation), we have enough information to know that \( B \) is preferred to \( B' \) at least at one vocabulary symbol interpretation or they are equally preferred. The concept of a single flip-over can be specified by \( \geq_{MP} \) when \( \mathcal{O}_{MP} = \emptyset \) (there is no meta-preference in cp-nets). In this case, \( \geq_{MP} \) has the transitivity property and a chain of flip-overs can be modelled by \( \mathcal{P}\)-\( MS \) as well. If \( \mathcal{O}_{MP} \) is not empty, \( MP \) of a structure represents the notion of relative importance (meta-preference) in TCP-net [Brafman et al., 2006] that is an extension of cp-nets to model meta-preferences. This reasoning leads us to the following theorem, relating cp-nets and the \( \mathcal{P}\)-\( MS \) formalism. **Theorem 2.** Let \( G \) be a cp-net and \( MP \) be the representation of \( G \) in the context of \( \mathcal{P}\)-\( MS \). If an outcome \( o_1 \) is preferred to outcome \( o_2 \) in the induced graph of \( G \), then, for \( o_1 \) and \( o_2 \) that are transformed into the \( \mathcal{P}\)-\( MS \), we have \( o_1 \geq_{MP} o_2 \). **Preference-based Planning** In what follows, we show how \( \mathcal{P}\)-\( MS \) is able to assert preference statements expressed in \( PP \) [Son and Pontelli, 2004] that is a preference language for planning problems. While we do not discuss the full details of \( PP \) here, we recall the main definitions found in [Son and Pontelli, 2004]. Given a set of fluent symbols \( \mathcal{F} \) and a set of actions \( \mathcal{A} \), a state is defined as a subset of \( \mathcal{F} \). A planning problem is a triple \( (D, I, G) \) where \( D \) indicates pre-conditions and effects of actions, \( I \) is the initial state, and \( G \) stands for the goal state. A solution to a planning problem, that is called a plan, is a chain of actions and states \( I, \alpha_1, ... \alpha_n, G \) that starts from \( I \) and ends to \( G \). A basic desire \( \phi \) is identified as one of the following: 1) a certain action occurs in the plan denoted by \( \phi = \text{occ}(a) \). 2) a set of certain fluents is satisfied that is denoted by \( \phi = (f_1 \land ... \land f_{i+n}) \), 3) any combination of basic desires by using classical logic connectives (e.g. \( \land, \lor, \lor \)) or temporal connective stemmed from temporal logic such as \( \text{Next}(\phi_1), \text{Until}(\phi_1, \phi_2) \), \( \text{Always}(\phi) \), and \( \text{Eventually}(\phi) \). [Son and Pontelli, 2004] state that a planning problem \( (D, I, G) \) can be reduced to an Answer Set Programming (ASP) problem \( \Pi(D, I, G) \) such that for a feasible plan \( p_M \) there is an answer set \( M \) in program \( \Pi \). In the context of answer set programming, a formula \( \phi \) is satisfied in \( M \) if it is a subset of vocabulary symbols that \( M \) makes true. For two plans \( p_1 \) and \( p_2 \), we say \( p_1 \) is preferred to \( p_2 \) with respect to a basic desire \( \phi \) if \( \phi \) is satisfied in \( p_1 \) but not in \( p_2 \). In the context of ASP, if \( M_1 \) and \( M_2 \) are two answer sets of \( p_1 \) and \( p_2 \) respectively, \( M_1 \) satisfies \( \phi \) but \( M_2 \) does not. To express basic desires in \( \mathcal{P}\)-\( MS \), it suffices to show that answer sets can be translated to structures in the context of modular systems. Consider a vocabulary \( \{a_1, ..., a_k\} \) and an answer set \( M = \{a_1, ..., a_k\} \) \( (k \leq n) \). As it can be observed from the notion of answer sets, \( M \) can be viewed as a structure that interprets each atom \( a_i \), \( i \leq k \), as true and for all \( a_j \), \( k < j \leq n \), as false. Having the same argument, a basic desire \( \phi \) is a partial structure in modular systems such that a subset of atoms in \( M \) is true. As a result, a planning problem \( (D, I, G) \) with preferences can be translated to answer sets and then to modular systems. Assume that structure \( B \) represents plan \( p_1 \), structure \( B' \) is translation of \( p_2 \), and formula \( \phi \) is translated to partial structure \( B_\phi \). A plan \( p_1 \) is preferred to \( p_2 \) with respect to \( \phi \) when \( B \) is preferred to \( B' \) with respect to \( B_\phi \). This completely coincides with our definition of preferences in modular systems. The following result follows from what we discussed. **Theorem 3.** Let \( p_1 \) and \( p_2 \) be two feasible plans of a planning problem \( \Pi(D, I, G) \) that can be translated to ASP program \( \Pi(D, I, G) \). Let \( M_{p_1} \) and \( M_{p_2} \) be ASP translation of \( p_1 \) and \( p_2 \) respectively. Suppose that \( M_{p_1} \) is translated to structure \( B \) and \( M_{p_2} \) to structure \( B' \) in the context of \( \mathcal{P}\)-\( MS \). Given a basic desire \( \phi \) if \( p_1 \) is preferred to \( p_2 \) with respect to \( \phi \) in language \( PP \), then \( B \geq_{MP} B' \) in \( \mathcal{P}\)-\( MS \) where \( MP_\phi \) is translation of \( \phi \) into \( \mathcal{P}\)-\( MS \). 5 Conclusion and Future Work We proposed an abstract framework for unifying preference languages in modular systems. We introduced the notion of preference-based modular systems ($\mathcal{P}$-$\mathcal{MS}$). We demonstrated that a system obtained through combination of some $\mathcal{P}$-$\mathcal{MS}$ is also a $\mathcal{P}$-$\mathcal{MS}$. We studied how preferences expressed in other languages (two languages as examples) can be translated to our framework. Examples included two common preference languages: cp-nets and planning with preferences (PP). Our future work will address expressivity and computational issues of the framework. We will continue our study of practical aspects of our framework in AI applications, in particular, Business Processes that have complex modular structures and different users may communicate through different formal languages. References
{"Source-Url": "http://www.ijcai.org/Proceedings/15/Papers/416.pdf", "len_cl100k_base": 12264, "olmocr-version": "0.1.49", "pdf-total-pages": 8, "total-fallback-pages": 0, "total-input-tokens": 32817, "total-output-tokens": 14910, "length": "2e13", "weborganizer": {"__label__adult": 0.000408172607421875, "__label__art_design": 0.0005855560302734375, "__label__crime_law": 0.0005860328674316406, "__label__education_jobs": 0.003284454345703125, "__label__entertainment": 0.00014781951904296875, "__label__fashion_beauty": 0.0002522468566894531, "__label__finance_business": 0.0007834434509277344, "__label__food_dining": 0.0006089210510253906, "__label__games": 0.0011339187622070312, "__label__hardware": 0.0008568763732910156, "__label__health": 0.0011081695556640625, "__label__history": 0.0005211830139160156, "__label__home_hobbies": 0.0002636909484863281, "__label__industrial": 0.0010919570922851562, "__label__literature": 0.0010242462158203125, "__label__politics": 0.0004553794860839844, "__label__religion": 0.0006928443908691406, "__label__science_tech": 0.32568359375, "__label__social_life": 0.00021851062774658203, "__label__software": 0.016204833984375, "__label__software_dev": 0.642578125, "__label__sports_fitness": 0.0003333091735839844, "__label__transportation": 0.0010175704956054688, "__label__travel": 0.0002543926239013672}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 47612, 0.0204]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 47612, 0.65145]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 47612, 0.81072]], "google_gemma-3-12b-it_contains_pii": [[0, 5115, false], [5115, 11001, null], [11001, 18533, null], [18533, 27029, null], [27029, 33927, null], [33927, 41990, null], [41990, 47392, null], [47392, 47612, null]], "google_gemma-3-12b-it_is_public_document": [[0, 5115, true], [5115, 11001, null], [11001, 18533, null], [18533, 27029, null], [27029, 33927, null], [33927, 41990, null], [41990, 47392, null], [47392, 47612, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 47612, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 47612, null]], "pdf_page_numbers": [[0, 5115, 1], [5115, 11001, 2], [11001, 18533, 3], [18533, 27029, 4], [27029, 33927, 5], [33927, 41990, 6], [41990, 47392, 7], [47392, 47612, 8]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 47612, 0.0]]}
olmocr_science_pdfs
2024-11-27
2024-11-27
9605795853049aedd49b6f3beab52d734a800ce1
Interpretability Illusions in the Generalization of Simplified Models Dan Friedman 1 * Andrew Lampinen 2 Lucas Dixon 3 Danqi Chen 1 2 Asma Ghandeharioun 3 Abstract A common method to study deep learning systems is to use simplified model representations—for example, using singular value decomposition to visualize the model’s hidden states in a lower dimensional space. This approach assumes that the results of these simplifications are faithful to the original model. Here, we illustrate an important caveat to this assumption: even if the simplified representations can accurately approximate the full model on the training set, they may fail to accurately capture the model’s behavior out of distribution. We illustrate this by training Transformer models on controlled datasets with systematic generalization splits, including the Dyck balanced-parenthesis languages and a code completion task. We simplify these models using tools like dimensionality reduction and clustering, and then explicitly test how these simplified proxies match the behavior of the original model. We find consistent generalization gaps: cases in which the simplified proxies are more faithful to the original model on the in-distribution evaluations and less faithful on various tests of systematic generalization. This includes cases where the original model generalizes systematically but the simplified proxies fail, and cases where the simplified proxies generalize better. Together, our results raise questions about the extent to which mechanistic interpretations derived using tools like SVD can reliably predict what a model will do in novel situations. 1. Introduction How can we understand deep learning models? Often, we begin by simplifying the model, or its representations, using tools like dimensionality reduction, clustering, and discretization. We then interpret the results of these simplifications—for example finding dimensions in the principal components that encode a task-relevant feature (e.g. Liu et al., 2022; Power et al., 2022; Zhong et al., 2023; Chughtai et al., 2023; Lieberum et al., 2023). In other words, we are essentially replacing the original model with a simplified proxy that uses a more limited—and thus easier to interpret—set of features. By analyzing these simplified proxies, we hope to understand at an abstract level how the system solves a task. Ideally, this understanding helps us predict model behavior in unfamiliar situations, and thereby anticipate failure cases or potentially unsafe behavior. However, in order to arrive at understanding by simplifying a model, we have to assume that the result of the simplification is a relatively faithful proxy for the original model. For example, we need to assume that the principal components of the model representations, by capturing most of the variance, are thereby capturing the important details of the model’s representations for its computations. In this work, we question whether this assumption is valid. First, some model simplifications, like PCA, are not computed solely from the model itself; they are calculated with respect to the model’s representations for a particular collection of inputs, and therefore depend on the input data distribution. Second, even if a simplification does not explicitly depend on the training distribution, it might appear faithful on in-distribution evaluations, but fail to capture the model’s behavior over other distributions. Thus, it is important to understand the extent to which simplified proxy models characterize the behavior of the underlying model beyond this restricted data distribution. We therefore study how models, and their simplified proxies, generalize out-of-distribution. We focus on small-scale Transformer (Vaswani et al., 2017) language models trained on controlled datasets with systematic generalization splits. We first consider models trained on the Dyck balanced-parenthesis languages. These languages have been studied in prior work on characterizing the computational expressivity of Transformers (e.g., Hewitt et al., 2020; Ebrahimi et al., 2020; Yao et al., 2021; Weiss et al., 2021; Murty et al., 2023; Wen et al., 2023), and admit a variety of sys- --- * Work done while the author was a Student Researcher at Google Research. 1Department of Computer Science, Princeton University 2Google DeepMind 3Google Research. Correspondence to: Dan Friedman <dfriedman@cs.princeton.edu>. Proceedings of the 41st International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s). tematic generalization splits, including generalization to unseen structures, different sequence lengths, and deeper hierarchical nesting depths. First, we simplify and analyze the model’s representations, e.g. by visualizing their first few singular vectors. Next, for each simplification, we explicitly construct the corresponding simplified proxy models—for example, replacing the model’s key and query representations with their projection onto the top-k singular vectors—and evaluate how the original models, and their simpler proxies, generalize to out-of-distribution test sets. We find that the simplified proxy models are not as faithful to the original models out of distribution. While the proxies behave similarly to the original model on in-distribution evaluations, they reveal unexpected generalization gaps on out-of-distribution tests—the simplified model often under-estimates the generalization performance of the original model, contrary to intuitions from classic generalization theory (Valiant, 1984; Bartlett & Mendelson, 2002), and recent explanations of grokking (Merrill et al., 2023). However, under certain data-independent simplifications the simpler model actually outperforms the original model; once again, this indicates a mismatch between the original model and its simplification. We elucidate these results by identifying some features of the model’s representations that the simplified proxies are capturing and missing, and how these relate to human-written Transformer algorithms for this task (Yao et al., 2021). We show that different simplifications produce different kinds of divergences from the original model. We finally test whether these findings extend to larger models trained on a more naturalistic setting: predicting the next character in a dataset of computer code. We test how models generalize to unseen programming languages and find generalization gaps in this setting as well, with the simplified models proving less faithful to the original model on out-of-domain examples. We also find that the results vary on different subsets of the code completion task, with larger generalization gaps on some types of predictions than others. These experiments offer some additional insight into how these gaps are related to different properties of sequence modeling tasks. Specifically, generalization gaps might be more pronounced on more “algorithmic” tasks, where the model must use a particular feature in a precise, context-dependent way. The effect is diminished in settings where various local features contribute to the model’s prediction. Our results raise a key question for understanding deep learning models: If we simplify a model in order to interpret it, will we still accurately capture model computations and behaviors out of distribution? We reflect on this issue; the related challenges in fields like neuroscience; and the relationship between complexity and generalization. 2. Setting Transformer language models The Transformer (Vaswani et al., 2017) is a neural network architecture for processing sequence data. The input is a sequence of tokens $w_1, \ldots, w_N \in \mathcal{V}$ in a discrete vocabulary $\mathcal{V}$. At the input layer, the model maps the tokens to a sequence of $d$-dimensional embeddings $X^{(0)} \in \mathbb{R}^{N \times d}$, which is the sum of a learned token embedding and a positional embedding. Each subsequent layer $i$ consists of a multi-head attention layer (MHA) followed by a multilayer perceptron layer (MLP): $X^{(i)} = X^{(i-1)} + \text{MHA}^{(i)}(X^{(i-1)}) + \text{MLP}^{(i)}(X^{(i-1)})$. Following Elhage et al. (2021), multi-head attention (with $H$ heads) can be written as $$\text{MHA}(X) = \sum_{h=1}^{H} \text{softmax}(XW^h_Q(XW^h_K)^\top)XW^h_VW^h_O,$$ where $W^h_Q, W^h_K, W^h_V, W^h_O \in \mathbb{R}^{d \times d_h}$ are referred to as the query, key, and value projections respectively, and $W^h_O \in \mathbb{R}^{d_h \times d}$ projects the output value back to the model dimension. The MLP layer operates at each position independently; we use a two-layer feedforward network: $\text{MLP}(X) = \sigma(XW_1)W_2$, where $W_1 \in \mathbb{R}^{d \times d_m}$, $W_2 \in \mathbb{R}^{d_m \times d}$, and $\sigma$ is the ReLU function. The output of the model is a sequence of token embeddings, $X^{(L)} \in \mathbb{R}^{N \times d}$. We focus on autoregressive Transformer language models, which define a distribution over next words, given a prefix $w_1, \ldots, w_{i-1} \in \mathcal{V}$: $p(w_i | w_1, \ldots, w_{i-1}) \propto \exp(\theta^L_{w_i} X^{(L)}_{i-1})$, where $\theta_{w_i} \in \mathbb{R}^d$ is a vector of output weights for word $w_i$. Dyck languages Dyck-$k$ is the family of balanced parenthesis languages with up to $k$ bracket types. Following the notation of Wen et al. (2023), the vocabulary of Dyck-$k$ is the words $\{1, \ldots, 2k\}$, where, for any $t \in [k]$, the words $2t-1$ and $2t$ are the opening and closing brackets of type $t$, respectively. Given a sentence $w_1, \ldots, w_n$, the nesting depth at any position $i$ is defined as the difference between the number of opening brackets in $w_{1:i}$ and the number of closing brackets in $w_{1:i}$. As in prior work (Yao et al., 2021; Murty et al., 2023; Wen et al., 2023), we focus on bounded-depth Dyck languages (Hewitt et al., 2020), denoted Dyck-$(k,m)$, where $m$ is the maximum nesting depth. We focus on Dyck for two main reasons. On one hand, the Dyck languages exhibit several fundamental properties of both natural and programming languages—namely, recursive, hierarchical structure, which gives rise to long-distance dependencies. For this reason, Dyck languages have been widely studied in prior work on the expressivity of Transformer language models (Hewitt et al., 2020; Yao et al., 2021), and in interpretability (Wen et al., 2023). On the Table 1: Illustration of Dyck generalization splits. For simplicity, examples are drawn from Dyck-(3, 2). Three sample sentences for each set, their respective sentence structure, and nesting depth are shown below. O and C refer to open and closed brackets in the sentence structure. <table> <thead> <tr> <th>Subset</th> <th>Illustrative Samples</th> </tr> </thead> <tbody> <tr> <td>Train</td> <td>Random samples from Dyck-(3,2) with three different bracket types of ( ( ) { }. All sentences have the maximum nesting depth of two.</td> </tr> <tr> <td>Seen Struct</td> <td>Random samples with bracket structures that appeared in the Train set, but with different bracket types.</td> </tr> <tr> <td>Unseen Struct</td> <td>Random samples with bracket structures that have not appeared in the Train set, but have the same maximum nesting depth of two.</td> </tr> <tr> <td>Unseen Depth</td> <td>Examples with maximum nesting depth strictly greater than two.</td> </tr> </tbody> </table> <table> <thead> <tr> <th>Split</th> <th>Accuracy Split</th> </tr> </thead> <tbody> <tr> <td>Seen struct</td> <td><img src="image_url" alt="Accuracy Graph" /></td> </tr> <tr> <td>Unseen struct (len ≤ 32)</td> <td><img src="image_url" alt="Accuracy Graph" /></td> </tr> <tr> <td>Unseen struct (len &gt; 32)</td> <td><img src="image_url" alt="Accuracy Graph" /></td> </tr> <tr> <td>Unseen depth</td> <td><img src="image_url" alt="Accuracy Graph" /></td> </tr> </tbody> </table> For our main analysis, we train models on Dyck-(20, 10), the language with 20 bracket types and a maximum depth of 10, following (Murty et al., 2023). To create generalization splits, we follow Murty et al. (2023) and start by sampling a training set with 200k training sentences—using the distribution described by Hewitt et al. (2020)—and then generate test sets with respect to this training set. Next, we recreate the structural generalization split described by Murty et al. (2023) by sampling sentences and discarding seen sentences and sentences with unseen bracket structures (Seen struct). The bracket structure of a sentence is defined as the sequence of opening and closing brackets (e.g., the structure of \( ( \) \{ \) is \texttt{OOCCOC}). The above sampling procedure results in a shift in the distribution of sentence lengths, with the Seen struct set containing much shorter sentences than the training set.\(^3\) Therefore, we create two equal-sized structural generalization splits, Unseen struct (len ≤ 32) and Unseen struct (len > 32), by sampling sentences, discarding sentences with seen structures, and partitioning by length. Finally, we create a Unseen depth generalization set by sampling sentences from Dyck-(20, 20) and only keeping those sentences with a maximum nesting depth of at least 10. All generalization sets have 20k sentences. The different generalization splits are illustrated in Table 1 and more details are provided in Appendix A.1. Following Murty et al. (2023), we evaluate models’ accuracy at predicting closing brackets that are at least 10 positions away from the corresponding opening bracket, and score the prediction by the closing bracket to which the model assigns the highest likelihood. **Code completion** We also experiment with larger models trained on a more practical task: predicting the next character in a dataset of computer code. Code completion has become a common use case for large language models, with applications in developer tools, personal programming assistants, and automated agents (e.g. Anil et al., 2023; OpenAI, 2023). This task is a natural transition point from the Dyck setting, requiring both “algorithmic” reasoning (including bracket matching) and more naturalistic language modeling (e.g. predicting names of new variables). We train character-level language models on the CodeSearchNet dataset (Husain et al., 2019), which is made up of functions in a variety of programming languages. As in the Dyck languages, we define the bracket nesting depth as difference between the number of opening and closing brackets at each position, treating three pairs of characters as brackets (\( (\), \{\}, \[\]). We train models on Java functions with a maximum nesting depth of three and construct two kinds of generalization split: Java functions with deeper nesting depths (Java, unseen depth); and functions with a seen depth but written in an unseen language (JavaScript, PHP, Go). See Appendix B.6 for more details. We evaluate the \(^3\)The longest sentence in our Seen struct set has a length of 30. Interpretability Illusions in the Generalization of Simplified Models Figure 2: Second-layer attention embeddings for Dyck sequences, projected onto the first and third singular vectors and colored by bracket depth. The maximum depth during training is 10. At each position, the model can find the most recent unmatched bracket by finding the most recent bracket at the current nesting depth. 3. Approach Scope of our analysis For Transformer LMs, mechanistic interpretations can be divided into two stages: circuit identification and explaining circuit components. The first stage involves identifying the subgraph of model components that are involved in some behavior. The second stage involves characterizing the computations of each component. Various automated circuit identification methods have been developed (e.g. Vig et al., 2020; Meng et al., 2022; Conmy et al., 2023), but relatively less work has focused on the second stage of interpretation, which we focus on here. In particular, we focus on characterizing the algorithmic role of individual attention heads. Interpretation by model simplification Our main focus is on understanding individual attention heads, aiming to explain which features are encoded in the key and query representations and therefore determine the attention pattern. We evaluate two data-dependent methods of simplifying keys and queries, and a third data-agnostic method that simplifies the resulting attention pattern: Simplifying key and query embeddings. Our first two approaches aim to characterize the attention mechanism by examining simpler representations of the key and query embeddings. To do this, we collect the embeddings for a sample of 1,000 training sequences. Dimensionality reduction: We calculate the singular value decomposition of the concatenation of key and query embeddings. For evaluation, we project all key and query embeddings onto the first $k$ singular vectors before calculating the attention pattern. This approach is common in prior work in mechanistic interpretability (e.g. Lieberum et al., 2023). Clustering: We run k-means on the embeddings, clustering keys and queries separately. For evaluation, we replace each key and query with the closest cluster center prior to calculating the attention pattern. This approach has precedent in a long line of existing work on extracting discrete rules from RNNs (e.g. Omlin & Giles, 1996; Jacobsson, 2005; Weiss et al., 2018; Merrill & Tsilivis, 2022), and can allow us to characterize attention using discrete case analysis. 4. Case Study: Dyck Language Modeling In this section, we train two-layer Transformer language models on Dyck languages. In Appendix B.2, we illustrate how we can attempt to reverse-engineer the algorithms these model learn by inspecting simplified model representations, using visualization methods that are common in prior work (e.g. Liu et al., 2022; Power et al., 2022; Zhong et al., 2023; Chughtai et al., 2023; Lieberum et al., 2023). In this section, we quantify how well these simplified proxy models predict the behavior of the underlying model. First, we plot approximation quality metrics for different model simplifications and generalization splits, finding a consistent generalization gap. Then we try to explain why this generalization gap occurs by analyzing the approximation errors. We include additional results in Appendix B. the in-domain held-out set early in training, and reach near-perfect accuracy on the structural generalization set later. On the depth generalization split, the models achieve approximately 75% accuracy. In Fig. 2 and Appendix B.3, we provide some qualitative analysis of the resulting models by examining low-dimensional representations of the attention embeddings. We find that the learned solutions resemble a human-written Transformer algorithm for Dyck (Yao et al., 2021), with the first attention layer using a broad attention pattern to calculate the bracket depth at each position, and the second layer using the depth to attend to the most recent unmatched bracket at each position. In the remainder of this section, we focus on the second attention layer, measuring the extent to which simplified representations approximate the original model on different generalization splits. Generalization gaps We evaluate approximation quality using two metrics: the Jensen-Shannon Divergence (JSD), a measure of how much the attention pattern diverges from the attention pattern of the original model; and whether or not the two models make the Same Prediction at the final layer. Fig. 3 shows these metrics after simplifying the second-layer key and query representations. The simplified models correspond fairly well to the original model on the in-domain evaluation set (Seen struct), but there are consistent performance gaps on the generalization splits. For example, Fig. 3b shows that we can reduce the key and query embeddings to as few as four dimensions and still achieve nearly 100% prediction similarity on the Seen struct evaluation set. However, whereas the original model generalizes almost perfectly to Unseen structures, the simplified model deviates considerably in these settings, suggesting that these simplification methods underestimate generalization. Fig. 4 shows the effect of replacing the attention pattern with one-hot attention. One-hot attention is a faithful approximation on all generalization splits except for the depth generalization split (Fig. 4a). In this setting, the one-hot attention model slightly out-performs the original model (Fig. 4b), in a sense over-estimating how well the model will generalize. Comparing error patterns What do the simplified models miss? Figures 5a and 5b plot the errors made by the original model and a rank-8 SVD approximation, broken down by query depth and the maximum depth in the sequence. While both models have a similar overall error pattern, the rank-8 model somewhat underestimates generalization, performing poorly on certain out-of-domain cases where the original model successfully generalizes (i.e., depths 11 and 12). Figures 5c and 5d plot the errors made by the attention mechanism, showing the depth of the keys receiving the highest attention scores in cases where the final prediction of the original model is incorrect. In this case, both models have similar error patterns on shallower depths, attending to depths either two higher or two lower than the target depth. This error is in line with our visual analysis in the Appendix: in Appendix Fig. 9c, we can see that the attention embeddings encode the parity of the depth, with tokens at odd- and even-numbered depths having opposite signs in the third component. However, the error patterns diverge on depths greater than ten, suggesting that the lower-dimension model can explain why the original model makes mistakes in some in-domain cases, but not out-of-domain. 5. Case Study: Code Completion Now we investigate whether our findings extend to larger models trained on a more practical task: predicting the next character in a dataset of computer code. This task is a natural transition point from the Dyck setting, requiring both “algorithmic” reasoning (including bracket matching) and more Interpretability Illusions in the Generalization of Simplified Models naturalistic language modeling. We train character-level language models on the CodeSearchNet dataset (Husain et al., 2019), training on Java functions with a maximum bracket nesting depth of three, and evaluating generalization to functions with deeper nesting depths (Java, unseen depth) and functions with seen depths but written in an unseen languages (Javascript, PHP, Go). We train Transformer LMs with four layers, four attention heads per-layer, and an attention embedding size of 64, and train models with three random initializations. Unlike Dyck, this task does not admit a deterministic solution; however, we find that there are enough regularities in the data to allow the models to achieve high accuracy at predicting the next token (Fig. 14). See Appendix B.6 for more training details. Generalization gaps We measure the effect of simplifying each attention head independently: for each head, we reduce the dimension of the key and query embeddings using SVD and calculate the percentage of instances in which the original and simplified model make the same prediction. Figure 6a plots the average prediction similarity, filtering to cases where the original model is correct. The prediction similarity is consistently higher on Java examples and lower on unseen programming languages, suggesting that this task also gives rise to a generalization gap. On the other hand, there is no discernible generalization gap on the Java depth generalization split; this could be because in human-written code, unlike in Dyck, bracket types are correlated with other contextual features, and so local model simplifications may have less of an effect on prediction similarity. Comparing subtasks Which aspects of the code completion task give rise to bigger or smaller generalization gaps? In Figure 6b, we break down the results by the type of character the model is predicting: whether it is a Whitespace character; part of a reserved word in Java (Keyword); part of a new identifier (New word); part of an identifier that appeared earlier in the function (Repeated word); a Close bracket; or any Other character, including opening brackets, semicolons, and operators. We plot the results for each attention head in a single model after projecting the key and query embeddings to the first 16 SVD components and include results for other models and dimensions in Appendix B.6. The results vary depending on the prediction 4To verify the statistical significance of this result, we conducted a paired sample t-test, which indicated that the difference between ID and OOD approximation scores is statistically significant with \( p \leq 0.005 \). See Appendix B.6 for more details. Figure 5: Errors of the original model and a rank-8 SVD simplification on the depth generalization test set. Figures 5a and 5b plot the prediction accuracy, broken down by the depth of the query and the maximum depth among the keys. Figures 5c and 5d plot the depth of the token with the highest attention score, broken down by the true target depth, considering only incorrect predictions. The models have similar error patterns on shallower depths, attending to depths two higher or two lower than the target depth, but the simplified model diverges on depths greater than ten. Comparing attention heads In Figure 6b, we can observe that some prediction types are characterized by outlier attention heads: simplifying these attention heads leads to much lower approximation quality, and larger gaps in approximation quality between in-distribution and out-of-distribution samples. This phenomenon is most pronounced in the Repeated word category, where simplifying a single attention head reduces the prediction similarity score to 75% on in-domain samples and as low as 61% on samples from unseen languages. In the appendix (B.6), we find evidence that this head implements the “induction head” pattern, which has been found to play a role in the emergence of in-context learning in Transformer language models (Elhage et al., 2021; Olsson et al., 2022). This finding suggests that the low-dimensional approximation underestimates the extent to which the induction head mechanism will generalize to unseen distributions. 6. Discussion In this section, we summarize our main experimental findings, discuss possible explanations for this phenomenon, and reflect on the broader implications. Main findings Our experiments illustrated generalization gaps, cases where simplified proxy models are faithful to the original model on in-domain evaluations but fail to capture the model’s behavior on tests of systematic generalization. On the Dyck languages (§4), simplifying attention embeddings (using clustering or PCA) resulted in models that generalized worse than the original model. Our analysis suggested that simplified embeddings capture coarse-grained features—for example, whether a bracket appears at an odd- or even-numbered nesting depth While this might be sufficient to explain model behavior in simpler in-domain settings, it fails to capture the finer-grained structure the model relies on to generalize. We observed similar generalization gaps on a code completion task (§2), with larger gaps on some subtasks than others. In particular, the largest gaps occur when the model must complete a word that appeared earlier in the sequence. We found evidence connecting this gap to an “induction head” mechanism; simplifying this attention head leads to a larger generalization gap on repeated words, indicating that the model relies on higher dimensional embeddings to implement this copying mechanism in out-of-distribution settings. Why might such phenomena occur? One possible explanation for our results is that the gaps arise due to the data we use for simplifying the representations (to identify clusters or PCA components), and the gaps might disappear if we fit the approximations using OOD data as well. Our results suggest that such an approach might reduce generalization gaps in some cases. For example, from visualizing the Dyck embeddings in Figure 2, we might expect the clustering simplification to be more faithful if the data used for clustering included examples with unseen depths. On the other hand, even if the data used for simplification includes all relevant features, some features might be represented less strongly than others (in the sense of accounting for less variance between embeddings), despite being impor- Figure 6: Prediction similarity on CodeSearchNet after reducing the dimension of the key and query embeddings using SVD, filtered to the subset of tokens that the original model predicts correctly. We apply dimensionality reduction to each attention head independently and aggregate the results over attention heads and over models trained with three random seeds. Each model has four layers, four attention heads per-layer, and a head dimension of 64. The prediction similarity between the original and simplified models is consistently higher on in-distribution examples (Java) relative to examples in unseen languages (Fig. 6a). Fig. 6b breaks down the results by prediction type, using 16 SVD components. Each point on the plot shows the prediction similarity after simplifying one attention head, and we plot all attention heads from all three random seeds. The gap between in-distribution and out-of-distribution approximation scores is greater on some types of predictions than others (e.g., Repeated word), perhaps because these predictions depend more on precise, context-dependent attention. **Compression & simplification** Hooker et al. (2019) observed that compressing vision models (via pruning) selectively reduces performance on a subset of examples; intriguingly, these examples also tend to be more challenging to classify, even for humans. Our results showing that simplified transformer models do worse on (more challenging) generalization splits may be an analogous phenomenon, but at the dataset rather than exemplar level (and for sequence data rather than images). From this perspective, our results may have implications for the common practice of compressing language models for more efficient serving, e.g. by quantization (e.g. Bhandare et al., 2019; Yao et al., 2023). **Related challenges in neuroscience** Neuroscience also relies on stimuli to drive neural responses, and thus similarly risks interpretations that may not generalize to new data distributions. For example, historical research on retinal coding using simple bars or grids as visual stimuli. However, testing naturalistic stimuli produced many new findings (Karamanlis et al., 2022)—e.g., some retinal neurons respond only to an object moving differently than its background (Ölveczky et al., 2003), so their function could never be determined from simple stimuli. Thus, interpretations of retinal computation drawn from simpler stimuli did not fully capture its computations over all possible test distributions. Neuroscience and model interpretability face common challenges from interactions between different levels of analysis (Churchland & Sejnowski, 1988): we wish to understand a system at an abstract algorithmic level, but its actual behavior may depend on low-level details of its implementation. **The relationship between complexity and generalization** Classical generalization theory suggests that simpler models generalize better (Valiant, 1984; Bartlett & Mendelson, 2002), unless datasets are massive; however, in practice overparameterized deep learning models generalize well (Nakkiran et al., 2021; Dar et al., 2021). Recent theory has explained this via implicit regularization effectively simplifying the models (Neyshubar, 2017; Arora et al., 2019), e.g. making them more compressible (Zhou et al., 2018). Our results reflect this complex relationship between model simplicity and generalization. We find that data-dependent approaches to simplifying the models’ representations impairs generalization. However, a data-independent simplification (hard attention) allows the simplified model to generalize better to high depths. This result reflects the match between the Transformer algorithm for Dyck and the inductive bias of hard attention, and therefore echoes some of the classical understanding about model complexity and the bias-variance tradeoff. 7. Related Work Circuit analysis Research on reverse-engineering neural networks comes in different flavors, each focusing on varying levels of granularity. A growing body of literature aims to identify Transformer circuits (Olsson et al., 2022). Circuits refer to components and corresponding information flow patterns that implement specific functions, such as indirect object identification (Wang et al., 2023), variable binding (Davies et al., 2023), arithmetic operations (e.g., Stolfo et al., 2023; Hanna et al., 2023), or factual recall (e.g., Meng et al., 2022; Geva et al., 2023). More recently, there have been attempts to scale up this process by automating circuit discovery (Conmy et al., 2023; Davies et al., 2023) and establishing hypothesis testing pipelines (Chan et al., 2022; Goldowsky-Dill et al., 2023). In addition to the progress made in circuit discovery, prior research has highlighted some challenges. For example, contrary to earlier findings (Nanda et al., 2022), small models trained on prototypical tasks, such as modular addition, exhibit a variety of qualitatively different algorithms (Zhong et al., 2023; Pearce et al., 2023). Even in setups with strong evidence in favor of particular circuits, such as factual associations, modules that exhibit the highest causal effect in storing knowledge may not necessarily be the most effective choice for editing the same knowledge (Hase et al., 2023). Our results highlight an additional challenge: circuits identified with one dataset may behave differently out of distribution. Analyzing attention heads Because attention is a key component of the Transformer architecture (Vaswani et al., 2017), it has been a prime focus for analysis. Various interesting patterns have been reported, such as attention heads that particularly attend to separators, syntax, position, or rare words (e.g., Clark et al., 2019; Vig, 2019; Guan et al., 2020). The extent to which attention can explain the model’s predictions is a subject of debate. Some argue against using attention as an explanation for the model’s behavior, as attention weights can be manipulated in a way that does not affect the model’s predictions but can yield significantly different interpretations (e.g., Pruthi et al., 2020; Jain & Wallace, 2019). Others have proposed tests for scenarios where attention can serve as a valid explanation (Wiegrefe & Pinter, 2019). It is interesting to consider our results on one-hot attention simplification and depth generalization through the lens of this debate. Top-1 attention accuracy is highly predictive of model success in most cases; however, on deeper structures top-1 attention and accuracy dissociate. Thus, while top attention could be an explanation in most cases, it fails in others. However, our further analyses suggest that this is due to increased attention to other elements, even if the top-1 is correct—thus, attention patterns may still explain these errors, as long as we do not oversimplify attention before interpreting it. Neuron-level interpretability A more granular approach to interpretability involves examining models at the neuron level to identify the concepts encoded by individual neurons. By finding examples that maximally activate specific “neurons”—a hidden dimension in a particular module like an MLP or in the Transformer’s residual stream—one can deduce their functionality. These examples can be sourced from a dataset or generated automatically (Belinkov & Glass, 2019). It has been observed that a single neuron sometimes represents high-level concepts consistently and even responds to interventions accordingly. For example, (Bau et al., 2020) demonstrated that by activating or deactivating the neuron encoding the “tree” concept in an image generation model, one can respectively add or remove a tree from an image. Neurons can also work as n-gram detectors or encode position information (Voita et al., 2023). However, it is essential to note that such example-dependent methods could potentially lead to illusory conclusions (Bolukbasi et al., 2021). Robustness of interpretability methods Our findings join a broader line of work in machine learning on the robustness of interpretability methods. For example, prior work in computer vision has found that explanation methods for computer vision can be both sensitive to perceptually indistinguishable perturbations of the data (Ghorbani et al., 2019), and insensitive to semantically meaningful changes (Adebayo et al., 2018), highlighting the importance of rigorous evaluation for interpretability methods. 8. Conclusion In this work, we simplified Transformer language models using tools like dimensionality reduction, in order to investigate their computations. We then compared how the original models and their simplified proxies generalized out-of-distribution. We found consistent generalization gaps: cases in which the simplified proxy model is more faithful to original model on in-distribution evaluations and less faithful on various systematic distribution shifts. Overall, these results highlight the limitations of interpretability methods that depend upon simplifying a model, and the importance of evaluating model interpretations out of distribution. Limitations This study focused on small-scale models trained on a limited range of tasks. Future work should study how these findings apply to larger-scale models trained on other families of tasks, such as large (natural) language models. Likewise, we only explored simplifying one component of a model at a time—such as a single attention head. However, model interpretations often involve larger circuits, and simplifying an entire circuit simultaneously might yield more dramatic distribution shifts; future work should explore this possibility. Interpretability Illusions in the Generalization of Simplified Models Impact Statement Methods for interpreting neural networks are important if we hope to deploy these systems safely and reliably. This work draws attention to a setting in which common approaches to interpretability can lead to misleading conclusions. These findings can caution against the pitfalls of these approaches and motivate the development of more faithful interpretability methods in the future. Acknowledgments We thank Adam Pearce, Adithya Bhaskar, and Mitchell Gordon for helpful discussions and feedback on writing and presentation of results. References A. Implementation Details: A.1. Dyck Dataset Details As described in Section 2, we sample sentences from Dyck-(10, 20), the language of balanced brackets with 20 bracket types and a maximum nesting depth of 10. We use the sampling distribution described and implemented by Hewitt et al. (2020), following existing work (Yao et al., 2021; Murty et al., 2023). We insert a special beginning-of-sequence token to the begin of each sequence, and append an end-of-sequence token to the end, and these tokens are included in all calculations of sentence length. Note that we discard sentences with lengths greater than 512. The training set contains 200k sentences and all the generalization sets contain 20k sentences. In all cases, we sample sentences, discarding sentences according to the rules described in Section 2, until the dataset has the desired size. See Table 1 for illustration of different generalization sets. Figure 7 plots the distribution of sentence lengths. For reference, we also include an IID split, which is created by sampling sentences from the same distribution used to construct the training set but rejecting any strings that appeared in the training set. It turns out that almost all sequences in this subset have unseen structures. (The number of bracket structures at length $n$ is given by the $n^{th}$ Catalan number, so the chance of sampling the same bracket structure twice is very low.) For all of the experiments described in Section 4, results on this subset are nearly identical to results on the Unseen structure (len > 32) subset. A.2. Model Details For our Dyck experiments, we use a two-layer Transformer, with each layer consisting of one attention head, one MLP, and one layer normalization layer. The model has a hidden dimension of 32, and the attention key and query embeddings have the same dimension. This dimension is chosen based on a preliminary hyperparameter search over dimensions in {2, 4, 8, 16, 32, 64} because it was the smallest dimension to consistently achieve greater than 99% accuracy on the IID evaluation split. Each MLP has one hidden layer with a dimension of 128, followed by a ReLU activation. The input token embeddings are tied to the output token embeddings (Press & Wolf, 2017), and we use absolute, learned position embeddings. The model is implemented in JAX (Bradbury et al., 2018) and adapted from the Haiku Transformer (Hennigan et al., 2020). A.3. Training Details We train the models to minimize the cross entropy loss: $$\mathcal{L} = \frac{1}{|\mathcal{D}|} \sum_{w_1 \in \mathcal{D}} \frac{1}{n} \sum_{i=2}^{n} p(w_i | w_{1:i-1}),$$ where $\mathcal{D}$ is the training set, $p(w_i | w_{1:i-1})$ is defined according to Section 2, and $w_1$ is always a special beginning-of-sequence token. We train the model for 100,000 steps with a batch size of 128 and use the final model for further analysis. We use the AdamW optimizer (Loshchilov & Hutter, 2019) with $\beta_1 = 0.9$, $\beta_2 = 0.999$, $\epsilon = 1e-7$, and a weight decay factor of $1e-4$. We set the learning rate to follow a linear warmup for the first 10,000 steps followed by a square root decay, with a maximum learning rate of $5e-3$. We do not use dropout. B. Additional Results B.1. Transformer Algorithms for Dyck Our investigations will be guided by a human-written algorithm for modeling Dyck languages with Transformers (Yao et al., 2021), which we review here. The construction uses a two-layer autoregressive Transformer with positional encodings and one attention head per layer. First attention layer: Calculate bracket depth. The first attention layer calculates the bracket depth at each position, defined as the number of opening brackets minus the number of closing brackets. One way to accomplish this is using an attention head that attends uniformly to all tokens and uses one-dimensional value embeddings, with opening brackets having a positive value and closing brackets having a negative value. At position $t$, the attention output will be $\text{depth}(w_{1:t})/t$. First MLP: Embed depths. The output of the first attention layer is a scalar value encoding depth. The first-layer MLP maps these values to orthogonal depth embeddings, which can be used as keys and queries in the next attention layer. Second attention layer: Bracket matching. The second attention layer uses depth embeddings to find the most recent unmatched opening bracket. At position $i$, the most recent unmatched opening bracket is the bracket at position $j$, where $j \leq i$ is the highest value such that $w_j$ is an opening bracket and $\text{depth}(w_{1:j}) = \text{depth}(w_{1:i})$. B.2. Case Study: Analyzing a Dyck Language Model In this section, we attempt to reverse-engineer the algorithm learned by a two-layer Dyck LM by analyzing simplified model representations, using visualization methods that are common in prior work (e.g. Liu et al., 2022; Power et al.,... First layer: Calculating bracket depth We start by examining the first attention layer. In Fig. 8, we plot an example attention pattern (Fig. 8a), along with the value embeddings plotted on the first two singular vectors (Fig. 8c). As in the human-written algorithm (§B.1), this attention head also appears to (1) attend broadly to all positions, and (2) associate opening and closing brackets with value embeddings with opposite sides. On the other hand, the attention pattern also deviates from the human construction in some respects. First, instead of using uniform attention, the model assigns more attention to the first position, possibly mirroring a construction from Liu et al. (2023). (In preliminary experiments, we found that the model learned a similar attention pattern even when we did not prepend a START token to the input sequences—that is, the first layer attention head attended uniformly to all positions but placed higher attention on the first token in the sequence.) Second, the value embeddings encode more information than is strictly needed to compute depth. Specifically, Figure 8c shows that the first components of the value embeddings encode position. Coloring this plot by bracket type reveals that the embeddings encode bracket type as well—each cluster of value embeddings corresponds to either opening or closing brackets for a single bracket type. In contrast, in the human-written Transformer algorithm, the value embeddings only encode whether the bracket is an opening or closing bracket and are invariant to position and bracket type. This might suggest that the model is using some other algorithm, perhaps in addition to our reference algorithm. Despite these differences, these simplified representations of the model suggest that this model is indeed implementing some form of depth calculation. Second layer: Bracket matching Now we move on to the second attention head. Behaviorally, this attention head appears to implement the bracket-matching function described in §B.1, and which has been observed in prior work (Ebrahimi et al., 2020); an example attention pattern is shown in Fig. 8b. Our goal in this section is to explain how this attention head implements this function in terms of the underlying key and query representations. Fig. 9 shows... Interpretability Illusions in the Generalization of Simplified Models Figure 8: Left: An example attention pattern from the first-layer attention head. Each position attends broadly to the full input sequence, but with more attention concentrated on the beginning of sequence token. Center: An example attention pattern from the second-layer attention head. Each query assigns the most attention to the most recent unmatched opening bracket. Right: The first two singular vectors of the value embeddings. Each point represents the sum of a token embedding and a position embedding (for all token embeddings and positions up to 64). PCA plots of the key and query embeddings from a sample of 1,000 training sequences. Again, these representations resemble the construction from Yao et al. (2021): the direction of the embeddings encodes depth (Fig. 9a), and the magnitude in each direction encodes the position, with later positions having higher magnitudes (Fig. 9b). On the other hand, the next two components (Fig. 9c) illustrate that the model also encodes the parity of the depth, with tokens at odd- and even-numbered depths having opposite signs in the third component. This reflects the fact that matching brackets are always separated by an even number of positions, so each query must attend to a position with the same parity. Overall, this investigation illustrates how simple representations of the model can suggest an understanding of the algorithm implemented by the underlying model—in this case, that the model implements a (possibly imperfect) version of the depth-matching mechanism described in Section B.1. B.3. Interpretation by Clustering In Figure 10, we plot the distribution of depths associated with each cluster, after applying k-means separately to a sample of key and query embeddings, with k set to 16. Beneath each query cluster, we plot the depth distribution of the nearest key cluster, where distance is defined as the Euclidean distance between cluster centers. This figure illustrates how clustering allows us to interpret the model by means of a discrete case analysis: we can see that the queries are largely clustered by depth, and the nearest key cluster typically consists of keys with the same depth, suggesting that the model implements a (possibly imperfect) version of the depth-matching mechanism described in Section B.1. B.4. Analysis: Structural Generalization In Figure 11, we look at the approximation errors on the structural generalization test set (looking at the subset of examples with length ≤ 32). The figure plots the difference between the position with the highest attention score in the original model and simplified model. In both figures, the simplified version of the model generally attends to an earlier position than the true depth, and that differs from the target depth by an even number of positions. This suggests that these approximations “oversimplify” the model: they capture the coarse grained structure—namely, that positions always attend to positions with the same parity—but underestimate the fidelity with which the model encodes depth. B.5. Depth Generalization Figure 12 plots key and query embeddings for out-of-distribution data points on the depth generalization split (Section 4). The success of the Transformer depends on the model’s mechanism for representing nesting depth. To succeed on the depth generalization split, this mechanism must also extrapolate to unseen depths. Figure 5 indicates that the model does extrapolate to some extent, but the simplified models fail to fully capture this behavior. Figure 12 offers some hints about why this might be the case. These plots suggest that there is some systematic generalization (deeper depths are embedded where we might expect). However, we can also visually observe that the deeper depths... Interpretability Illusions in the Generalization of Simplified Models Figure 9: Key and query embeddings from the second-layer attention head, projected onto the first four singular vectors and colored by either bracket depth or position. are less separated, perhaps indicating that the model uses additional directions for encoding deeper depths, but these directions are dropped when we fit SVD on data containing only lower depths. On the other hand, we did not have a precise prediction about where the deeper depths would be embedded, which is a limitation of our black box analysis: without reverse-engineering the lower layers, we cannot make strong predictions beyond the training data. Are these findings consistent across training runs? In Figure 13, we train a Dyck model with a different random initialization and plot the prediction errors on the depth generalization, recreating Figure 5. The overall pattern is similar in this training run, with the simplified model diverging more from the original model on predictions at deeper query depths. B.6. Additional Results: Computer Code Dataset details We train character-level language models on functions from the CodeSearchNet dataset (Husain et al., 2019) with a maximum length of 512 characters. The vocabulary is defined as the ASCII printable characters; all other characters are replaced with a special Unknown token. The training data consists of Java functions with a maximum bracket nesting depth of three, where the bracket nesting depth is defined as the difference between the number of opening and closing brackets at each position and we treat three pairs of characters as brackets ( (), {}, []). The training examples are drawn from the original training split. We evaluate the models on: unseen Java functions with maximum depth of three (Java); unseen Java functions with maximum depth strictly greater than three (Java, unseen depth); and functions in unseen programming languages, with a maximum depth of three (JavaScript, Go, PHP). We draw the training examples from the original training split and the evaluation examples from the validation split. Table 2 reports the number of functions in each subset, and the average length in characters. To break down the results by prediction type, we categorize each character as follows. First, we define a character as Whitespace if it is a whitespace character (according to the Python isspace method) and a Close bracket if it is one of ), }, or ]. Next, we split each function by whitespace and non-alphanumeric characters to obtain sequences of contiguous alphanumeric characters (words). We categorize a word as a Keyword if it is a Java reserved word,6 or the word true, false, or null; a Repeated word if the word appeared earlier in the sequence; and a New word otherwise. Each character is assigned to the same category of the word it is a part of. Characters that are not part of a word—i.e., non-alphanumeric characters—are categorized as Other. Model and training details We trained decoder-only Transformer language models with four layers and four attention heads per layer. The embedding size was 256, the attention embedding size was 64, and the MLP hidden layer was 512. We used a dropout rate of 0.1 and a batch size of 6 https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html Interpretability Illusions in the Generalization of Simplified Models Figure 10: Interpreting the attention mechanism via clustering. The top row plots the depth distribution in each query cluster, and the bottom row plots the depth distribution in the key cluster closest to that query cluster (so some key clusters appear twice). As an interpretation of the model, this figure suggests that the key and query embeddings are reasonably well clustered by depth, and queries generally attend to clusters of the same depth, but the mechanism seems somewhat more effective for some depths (see clusters 1, 3, 8) than others, and in some cases the model might confuse a depth for another depth +/- 2 (clusters 5 and 10). The figure does not capture the mechanism for attending to the most recent token at a matching depth. Table 2: The number of functions and the average length (in characters) of the training and evaluation subsets of CodeSearchNet. See Appendix B.6 for more details. <table> <thead> <tr> <th></th> <th>Java (train)</th> <th>Java (eval)</th> <th>Java, unseen depth</th> <th>JavaScript</th> <th>Go</th> <th>PHP</th> </tr> </thead> <tbody> <tr> <td>Num. examples</td> <td>202,395</td> <td>7,589</td> <td>2,817</td> <td>2,317</td> <td>9,402</td> <td>9,338</td> </tr> <tr> <td>Avg. length</td> <td>257</td> <td>240</td> <td>356</td> <td>257</td> <td>179</td> <td>271</td> </tr> </tbody> </table> 32 and trained for 100,000 steps. We set the learning rate to follow a linear warmup for the first 10,000 steps followed by a square root decay, with a maximum learning rate of 5e-3, and trained three models with different random initializations. Other model and training details are the same as described in Appendix A.3. Figure 14 plots the accuracy of the (original) models at predicting the next character at the end of training, broken down by the prediction type. The accuracy is relatively high, in part because many characters are whitespace, part of common keywords, or part of variable names that appeared earlier in the sequence. Significance test Figure 6a depicts the generalization gap on the code completion task aggregated across attention heads as well as model initialization. To verify that the gap is statistically significant, we conducted a paired sample t-test\(^7\) as follows. For every choice of model initialization, we measured the average approximation quality score (averaging over attention heads) on in-domain data (Java), and on out-of-domain data (aggregating the OOD splits). The null hypothesis for this test is that the expected difference between in-domain and OOD approximation scores is zero. We ran this analysis separately for each simplification level (number of SVD components). At each simplification level, this test finds that the expected difference between ID and OOD approximation scores is positive and the result is statistically significant with \(p \leq 0.005\). Additional approximation results We provide some additional results from the experiments described in Section 5. Figure 15 plots the prediction similarity on CodeSearchNet broken down by whether the underlying model’s prediction is correct or incorrect. Prediction similarity is lower overall when the model is incorrect, although the gap between in-domain and out-of-domain approximation scores is generally smaller. Figure 16 breaks down the results by prediction type, showing the effect of simplifying each attention head, aggregated across models trained with three random initializations, each with four layers and four attention heads. --- \(7\)https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.ttest_rel.html Interpretability Illusions in the Generalization of Simplified Models (a) SVD (b) Clustering Figure 11: These figures illustrate the kinds of errors in attention patterns that the approximations introduce on Unseen structure (length ≤ 32) evaluation split. They plot the distribution of distances between the position to which the original model assigns the most attention, and the position attended to by the simplified model. Both plots have a periodic structure, where the simplified model attends to a position that differs from the correct position by a multiple of two. This error pattern can be understood by noting that the parity of the nesting depth (which is equivalent to the parity of the position) is a prominent feature in the key and query embeddings (Figure 9c). The findings observed in Figure 6b are generally consistent across training results, with the gap between in-distribution and out-of-distribution approximation scores varying depending on the prediction type, although using lower dimensions leads to more consistent generalization gaps across categories. Which attention head is associated with the biggest generalization gap? In Figure 17, we plot the generalization gap for each attention head in a code completion model, comparing the difference in the Same Prediction approximation score between Java examples and non-Java examples, using a rank-16 SVD approximation for the given key and query embeddings. Simplifying the fourth head in the fourth layer leads to a generalization gap for most prediction types, with the biggest gap on predicting words that appeared earlier in the sequence. In Figure 18, we plot two example attention patterns from this head. From the attention pattern, this attention head appears to implement part of an “induction head” circuit (Elhage et al., 2021). The fact that the low-rank approximation has worse prediction similarity on examples from unseen programming languages suggests that the higher dimensions of the attention embeddings play a larger role in determining the behavior of this mechanism in these out-of-domain settings. The attention head associated with the largest gap on New word predictions is the third head in the first layer. Two example attention patterns are illustrated in Figure 19. This attention head generally attends to the previous token, perhaps indicating that these predictions depend more on local context. B.7. Additional Dataset: SCAN To assess whether our findings generalize to other settings, we also train models on the SCAN dataset (Lake & Baroni, 2018). SCAN is a synthetic, sequence-to-sequence semantic parsing dataset designed to test systematic generalization. The input to the model is an instruction in semi-natural language, such as “turn thrice”, and the target is to generate a sequence of executable commands (“TURN TURN TURN”). Data We consider two generalization settings. First, we test models on the Add jump generalization split, in which the test examples are compositions using a verb (jump) that appears in the training set only as an isolated word. We train this model on the training set introduced by Patel et al. (2022), which augments the original training data with more verbs, as this was shown to enable Transformers to generalize to the Add jump set. Second, we test models on Length generalization. We use the length generalization splits from Newman et al. (2020), The examples in the --- Footnotes: 8 https://github.com/arkilpatel/Compositional-Generalization-Seq2Seq 9 https://github.com/bnewm0609/eos-decision training set are no longer than 26 tokens long, and generalization splits have examples with lengths spanning from 26 tokens to 40 tokens. Model and training As in our Dyck experiments, we use a decoder-only Transformer. In the Add jump setting, we modify the attention mask to allow the model to use bi-directional attention for the input sequence, and we train the model to generate the target tokens. In the Length generalization setting, we use an autoregressive attention mask at all positions, and no position embeddings, because this has been shown to improve the abilities of Transformers to generalize to unseen lengths (Kazemnejad et al., 2023). We conduct a hyper-parameter search over number of layers (in \{2, 3, 4, 6\}) and number of attention heads (in \{1, 2, 4\}) and select the model with the highest accuracy on the generalization split, as our main goal is to evaluate simplified model representations in settings where the underlying model exhibits some degree of systematic generalization. The hidden dimension is 32, and the dimension of the attention embeddings is 32 divided by the number of attention heads. For Add jump, this is a three layer model with two attention heads, which achieves an OOD accuracy of around 99%. For Length, this is a six layer model with four attention heads, achieving an OOD accuracy of around 60%. We use a batch size of 128, a maximum learning rate of 5e-4, and a dropout rate of 0.1, and train for 100,000 steps. All other model and training details are the same as in Appendix A.2 and A.3. Results After training the models, we evaluate the effect of dimension-reduction and clustering, applied to the key and query embeddings. We apply this simplification independently to each head in the model and report the average results in Figure 20. On the Add jump generalization set, there is no discernible generalization gap. This result is in line with a finding of Patel et al. (2022), who found that, in models that generalize well, the embedding for the jump token is clustered with the embeddings for the other verbs, which would suggest that simplifications calculated from training data would also characterize the model behavior on the Add jump data. On the Length generalization set, there is a small but consistent generalization gap for both dimension reduction and clustering. These results suggest that generalization gaps can also appear in other settings, and underscore the value of evaluating simplifications on a variety of distribution shifts. On the other hand, we do not attempt to conduct a mechanistic interpretation of these larger models; further investigations are needed to understand the implications of these (small) generalization gaps for model interpretation. Figure 13: We trained a model on the Dyck dataset with a different random initialization and recreate the plots from Figure 5c. The figure plots the errors of the original model and a rank-8 SVD simplification on the depth generalization test set. Figures 13a and 13b plot the prediction accuracy, broken down by the depth of the query and the maximum depth among the keys. Figures 13c and 13d plot the depth of the token with the highest attention score, broken down by the true target depth, considering only incorrect predictions. The results are similar to the results in Figure 5c, with the simplified model diverging more on predictions with deeper query depths. For example, when the query depth is greater than 15, the lower-dimension model is more likely to attend to keys with a depth four less than the target depth. Interpretability Illusions in the Generalization of Simplified Models Figure 14: Accuracy at predicting the next character in CodeSearchNet, broken down by prediction type and evaluated on different generalization splits, averaged over three training runs. The models achieve relatively high accuracy, performing especially well at predicting whitespace characters and characters appearing in keywords or words that appeared earlier in the sequence. See Section B.6 for more details. Figure 15: Predicting closing brackets in different versions of CodeSearchNet after reducing the dimension of the key and query embeddings using SVD. We apply dimensionality reduction to each attention head independently and aggregate the results over attention heads and over models trained with three random seeds. The results are partitioned according to whether the original model makes the correct (top) or incorrect (bottom) prediction. The prediction similarity between the original and simplified models is consistently higher on in-distribution examples (Java, seen depth) relative to examples with deeper nesting depths or unseen languages. The gap is somewhat larger when we resample the bracket types and increase the number of bracket types. Interpretability Illusions in the Generalization of Simplified Models Figure 16: Prediction similarity on CodeSearchNet after reducing the dimension of the key and query embeddings using SVD, filtered to the subset of tokens that the original model predicts correctly. We train models with three random initializations. Each model has four layers, four attention heads per layer, and an attention embedding size of 64, and we apply dimensionality reduction to each attention head independently. This figure depicts the results from all three models using different numbers of SVD components, broken down by prediction type. Each point on the plot shows the prediction similarity after simplifying one attention head. The findings in 6b are generally consistent across training results, with the gap between in-distribution and out-of-distribution approximation scores varying depending on the prediction type, although using lower dimensions leads to more consistent generalization gaps across categories. Figure 17: The generalization gap for each attention head in a model for CodeSearchNet, defined as the difference between the Same Prediction score measured on in-domain examples (Java) compared to samples in unseen languages, using a rank-16 SVD approximation for the key and query embeddings. Simplifying the fourth head in the fourth layer leads to a generalization gap for most prediction types, with the biggest gap on predicting words that appeared earlier in the sequence. This head seems to form part of an “induction head” mechanism (see Fig. 18) Simplifying the third head in the first layer leads to the largest gap on New word predictions; this head generally attends to token at the previous position (Fig. 19), perhaps to gather local bigram statistics. Figure 18: Two example attention patterns from the attention head associated with the largest generalization gap on *Repeated word* predictions in a code completion task (see Fig. 17). Each row represents a query and each column represents a key, and we show the first 50 characters of two Java examples. This attention head appears to implement the “induction head” pattern, which increases the likelihood of generating a word that appeared earlier in the sequence. Figure 19: Two example attention patterns from the attention head associated with the largest generalization gap on *New word* predictions in a code completion task (see Fig. 17). Each row represents a query and each column represents a key, and we show the first 50 characters of two Java examples. This attention head appears to generally attend to the previous position, perhaps indicating that these predictions depend more on local context. Figure 20: Attention approximation metrics for models trained on the SCAN dataset, evaluated on two systematic generalization splits: the Add jump evaluation set, and the Length generalization set, which contains examples with unseen lengths. We apply these approximations to each attention head individually, and plot the results and 95% confidence interval averaged over the heads. See Appendix B.7.
{"Source-Url": "https://openreview.net/pdf?id=YJWlUMW6YP", "len_cl100k_base": 14331, "olmocr-version": "0.1.50", "pdf-total-pages": 25, "total-fallback-pages": 0, "total-input-tokens": 74522, "total-output-tokens": 19176, "length": "2e13", "weborganizer": {"__label__adult": 0.000652313232421875, "__label__art_design": 0.0009031295776367188, "__label__crime_law": 0.0004591941833496094, "__label__education_jobs": 0.001926422119140625, "__label__entertainment": 0.00035858154296875, "__label__fashion_beauty": 0.0003628730773925781, "__label__finance_business": 0.0004074573516845703, "__label__food_dining": 0.0005092620849609375, "__label__games": 0.0014190673828125, "__label__hardware": 0.0013551712036132812, "__label__health": 0.0009765625, "__label__history": 0.0006260871887207031, "__label__home_hobbies": 0.00016987323760986328, "__label__industrial": 0.0007104873657226562, "__label__literature": 0.0019989013671875, "__label__politics": 0.0004756450653076172, "__label__religion": 0.0008902549743652344, "__label__science_tech": 0.36376953125, "__label__social_life": 0.00020706653594970703, "__label__software": 0.01358795166015625, "__label__software_dev": 0.6064453125, "__label__sports_fitness": 0.0004892349243164062, "__label__transportation": 0.0008788108825683594, "__label__travel": 0.0002963542938232422}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 79335, 0.03189]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 79335, 0.37354]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 79335, 0.87062]], "google_gemma-3-12b-it_contains_pii": [[0, 4589, false], [4589, 10454, null], [10454, 15157, null], [15157, 18555, null], [18555, 22404, null], [22404, 25164, null], [25164, 28925, null], [28925, 32805, null], [32805, 38611, null], [38611, 40861, null], [40861, 45459, null], [45459, 49793, null], [49793, 54731, null], [54731, 57033, null], [57033, 60881, null], [60881, 64231, null], [64231, 67861, null], [67861, 71426, null], [71426, 73676, null], [73676, 74175, null], [74175, 75003, null], [75003, 76244, null], [76244, 78020, null], [78020, 78934, null], [78934, 79335, null]], "google_gemma-3-12b-it_is_public_document": [[0, 4589, true], [4589, 10454, null], [10454, 15157, null], [15157, 18555, null], [18555, 22404, null], [22404, 25164, null], [25164, 28925, null], [28925, 32805, null], [32805, 38611, null], [38611, 40861, null], [40861, 45459, null], [45459, 49793, null], [49793, 54731, null], [54731, 57033, null], [57033, 60881, null], [60881, 64231, null], [64231, 67861, null], [67861, 71426, null], [71426, 73676, null], [73676, 74175, null], [74175, 75003, null], [75003, 76244, null], [76244, 78020, null], [78020, 78934, null], [78934, 79335, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 79335, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 79335, null]], "pdf_page_numbers": [[0, 4589, 1], [4589, 10454, 2], [10454, 15157, 3], [15157, 18555, 4], [18555, 22404, 5], [22404, 25164, 6], [25164, 28925, 7], [28925, 32805, 8], [32805, 38611, 9], [38611, 40861, 10], [40861, 45459, 11], [45459, 49793, 12], [49793, 54731, 13], [54731, 57033, 14], [57033, 60881, 15], [60881, 64231, 16], [64231, 67861, 17], [67861, 71426, 18], [71426, 73676, 19], [73676, 74175, 20], [74175, 75003, 21], [75003, 76244, 22], [76244, 78020, 23], [78020, 78934, 24], [78934, 79335, 25]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 79335, 0.07442]]}
olmocr_science_pdfs
2024-11-30
2024-11-30
a33ec399fc5bc3de22a92c509779aec9d024e6ab
Proving the Temporal Properties of the Unique World * Zoltán Horváth¹, Peter Achten², Tamás Kozsik¹, and Rinus Plasmeijer² ¹ Department of General Computer Science University Eötvös Loránd, Budapest, Hungary hz@ludens.elte.hu, tamas.kozsik@elte.hu ² Faculty of Mathematics and Computer Science University Nijmegen, The Netherlands peter@cs.kun.nl, rinus@cs.kun.nl Abstract. The behavior of concurrent and parallel programs can be specified in a functional style. We introduced a relational model for synthesizing abstract parallel imperative programs earlier. In this paper we investigate the applicability of the specification and verification tools of the model for proving temporal properties of concrete programs written in a pure functional language, in Concurrent Clean. Destructive updates preserving referential transparency are possible by using so called unique types. Clean programs perform I/O by accessing their unique environment. We present a methodology for proving safety and liveness properties of concurrent, interleaved Clean Object I/O processes and show examples for verification of simple Clean programs. 1 Introduction The behavior of concurrent and parallel programs can be specified in a functional style. We introduced a relational model for synthesizing abstract parallel imperative programs earlier [7, 6]. We use the methodology and the abstract, programming language independent specifications presented in [3, 7, 8]. In this paper we investigate the applicability of the specification and verification tools of the model for proving temporal properties of reactive programs written in a pure functional language, in Concurrent Clean [12]. Verification of reactive ERLANG programs are investigated in [5, 4]. We use our UNITY like [3], temporal logic based reasoning instead of the first-order fixed-point calculus applied there. Automatic verification of Clean programs may be possible also by integrating temporal reasoning with CPS [11]. 2 Abstract specifications of reactive systems Reactive systems may be formulated in Clean as part of a unique environment [13, 1]. To specify the behavior of a reactive system we need temporal logic based notation [3, 6, 8] referring to program state and local state [1]. * Supported by the Hungarian State Eötvös Fellowship and by the Hungarian Ministry of Education, Grant Nr. FKFP 0206/97 A specification of a reactive system may be given as a set of properties of its unique environment (for full and detailed description of the model see [6]). Every property is a relation over the powerset of the state space\(^1\). Let \(P, Q, R, U : A \rightarrow L\) be logical functions. We define \(\rightarrow\), \(\leftarrow\), \(\Leftarrow\) \(\subseteq \mathcal{P}(A) \times \mathcal{P}(A)\), and \(FP, \text{INIT}, \text{inv}, \text{TERM} \subseteq \mathcal{P}(A)\). A program satisfies the safety property \(P \rightarrow Q\), if and only if there is no direct state-transition from \(P \land \neg Q\) to \(\neg P \land \neg Q\) only through \(Q\) if any. A program satisfies the progress properties \(P \rightarrow Q\) or \(P \leftarrow Q\) if the program starting from \(P\) inevitably reaches a state, in which \(Q\) holds. \(P \rightarrow Q\) defines further restriction for the direction of progress. The fixed point property \(FP \Rightarrow R\) defines necessary conditions for the case when the program is in one of its fixed point. The \(Q \in \text{INIT}\) property defines sufficient condition for the initial states of the program. \(Q \leftarrow FP\) expresses that the program starting from \(Q\) inevitably reaches one of its fixed points. \(P\) is said to be stable if and only if \(P \rightarrow \downarrow\), where \(\downarrow\) denotes the constant function \(False\). If \(P\) holds initially and \(P\) is stable, then \(P\) is an invariant, denoted by \(\text{inv}P\). 3 Clean constructs and libraries The scope of the present paper is restricted to interactive programs written in standard Clean 1.3, using the Object I/O library 1.0.2 [1, 2]. Experimental Concurrent Clean systems supporting true concurrency and parallelism [9, 13] are not investigated. In [9] concurrent and parallel evaluation of Clean expressions are controlled by program annotations. Message passing needed for the communication of arguments and results is implicit. An explicit version is proposed in [13]. Here, functions are provided to create threads and channels, and also for message passing and receiving. Clean is a strongly typed language based on term graph rewriting. Destructive updates preserving referential transparency are possible by using so called uniqueness types [12, 14]. I/O in Clean uses the world as value paradigm. In this paradigm, external resources such as the file system and event stream are passed explicitly as a value to functions. These values are also called environments. The external world is of type \(\text{World}\). I/O programs are functions of type \(\text{World} \rightarrow \text{World}\). The \(\ast\) in front of \(\text{World}\) means that the \(\text{World}\) argument is unique: when the function is evaluated it is guaranteed that this function has the only reference to the world. In addition, it must yield a world with one reference. Uniqueness is a function property. The type system derives the uniqueness properties of all functions. Many functions do not change the uniqueness of their arguments. The simplest example is the identity function \(\text{id}\) defined as: \(\text{id} a = a\). Its derived type is: \(\text{id} : \ast x \rightarrow \ast x\). This type indicates that \(\text{id}\) can both be applied to a unique value and a non-unique (or shared) value. \(^1\) Logical functions are characterised by their truth set, so truth sets are used in the notations at place of logical functions and vice versa if it is not confusing. Using uniqueness information the Clean compiler is able to generate better code by letting functions reuse unique argument components instead of rebuilding them. An example is the use of unique arrays. Clean programs using the Object I/O library create their own unique state space and define initialisation and state-transition functions. The library supports interactive processes, which can be created and closed dynamically. Each interactive process may consist of an arbitrary number of interactive objects. These are: windows, dialogues, menus, timers, and receivers. Again, these objects can be created and closed dynamically. An interactive process is a state transition system. Its state is a value of type \( \text{PSt} \ l \ p \), defined as: \[ \text{:: PSt} \ l \ p = \{ \text{ls}::1, \ \text{ps}::p, \ \text{io}::*\text{ISt} \ l \ p \}. \] The \( \text{ls} \) and \( \text{ps} \) components constitute the ‘logical’ state of the interactive process which must be defined by the programmer. The \( \text{io} \) component is managed entirely by the Object I/O system. It contains, amongst others, the current state of all interactive objects of the interactive process. So the IO state represents the external environment of the interactive process and it is therefore uniquely attributed. Interactive objects are created by passing an abstract description to the proper creation function. Such an abstract description is usually an algebraic data type value. One can find examples in the Clean programs in Section 5.2, line 10-11 (a timer), and Section 6.2, line 18-22 (a dialogue). The important point of such abstract descriptions is that they contain the state transitions of the interactive process. These state transitions are higher order function arguments of the algebraic data types. They are usually of type: \( (\text{PSt} \ l \ p) \rightarrow (\text{PSt} \ l \ p) \). Event handlers of I/O processes on the same processor are interleaved. Atomic actions correspond to handling of one event.\(^2\) The Object I/O system keeps evaluating all interactive processes until each of them has terminated. An interactive process terminates by applying the library function \text{closeProcess} to its process state. This function will close all current interactive objects from the IO state component and turn it into the empty IO state, which is its final state. 4 A calculus of verification We use a two phase model. In the first phase the abstract model of the Clean program is constructed. We give a formal specification and model the behaviour of the concrete program by an abstract program. The program text is analyzed and the state transition functions are extracted. The relatively well defined structure of the Object I/O processes makes this possible. A tool, which assists this first phase is needed in the future to ensure the correctness of the abstract model in respect of the main semantical properties of the concrete Clean program. --- \(^2\) The current implementation supports only processes on a single processor. However, using the Object I/O TCP/IP library (developed by Martin Wierich) allows one to create distributed communicating programs. We prove the correctness of the abstract program in respect of the specification in the second phase. This phase has a well-developed mathematical basis [3, 6]. In the following we give a short description of the main concepts. A problem is defined as a set of specification relations, more precisely a problem \( F \) is a relation over the parameter space \( B \) and ordered tuples of specification relations. The appropriate choice of the parameter space reduces the size of the problem and the number of verification steps. Every specification relation is defined over the powerset of the state space (section 2). The abstract program is regarded as a relation generated by a set of nondeterministic (simultaneous) conditional assignments [7] similar to the concept of abstract program in UNITY [3] and to the concept of parallel program given by van Lamsweerde and Sintzoff [10]. By virtue of its definition the effect relation of a conditional assignment is total, i.e., its domain is equal with the whole state space. This means that a conditional assignment always terminates [6]. Some assignments are selected nondeterministically and executed in each step of the execution of the abstract program. Every statement is executed infinitely often, i.e., an unconditionally fair scheduling is postulated. If more than one processor selects statements for execution, then the executions of different processors are fairly interleaved. A fixed point is said to be reached in a state, if none of the statements changes that state [3]. We denote the conditional assignment \( s_j \in S \) the following way: \( \parallel s_{i_j} \in [1..n] \{ v_i \in F_j_i(v_1, ..., v_n), \text{if } \pi_{j_i} \} \). The program properties with respect of an abstract parallel program are characterized as relations over the powerset of the state space. They are defined in terms of the weakest precondition \( \text{(wp)} \) of the element statements of the abstract program. We use the dual concept of strongest postcondition \( \text{(sp)} \) too. We generalize the concept of weakest precondition for abstract parallel programs [7] \( \text{wp}(S,R):=\forall s \in S : \text{wp}(s,R) \). Let us denote by \( \text{inv}_S(Q) \) the set of logical functions of which truth are preserved by the elements of \( S \) if the program is started from a state satisfying \( Q \). That is: \( \text{inv}_S(Q) \subseteq P(A) \). \( \text{inv}_S(Q) := \{ P \mid s \text{p}(s_0, Q) \Rightarrow P \text{ and } P \Rightarrow \text{wp}(S,P) \} \). Let us denote by \( \triangleright_S \) the set of ordered pairs \( (P,Q) \) of logical functions for which holds that \( P \) is stable while \( \neg Q \) during the execution of \( S \). \( \triangleright_S \subseteq P(A) \times P(A) \). \( \triangleright_S := \{ (\{P\}, \{Q\}) \mid (P \land \neg Q) \Rightarrow \text{wp}(S, (P \lor Q)) \} \). Let us denote by \( \Rightarrow_S \) the set of ordered pairs \( (P,Q) \) of logical functions for which holds that \( P \) is stable while \( \neg Q \) during the execution of \( S \) and there is a conditional assignment \( s_j \) which ensures the transition from \( P \) to \( Q \). Let be \( \Rightarrow_S \subseteq P(A) \times P(A) \) the transitive disjunctive closure (denoted by \( \text{tdc} \)) of \( \Rightarrow_S \). A fixed point is said to be reached in a state of the state space \( A \), if none of the statements changes the state. \( \varphi_S \) characterizes the set of fixed points, \( \varphi_S := \{ v_j \in [1..n] (\neg \pi_{j_i} \lor \pi_{j_i} \land v_i = F_j_i(v_1, ..., v_n)) \} \), where \( \pi_{j_i} \) denotes the logical function, which characterize the set of states over which the relation \( F_j \) is deterministic. Let us denote by \( \text{TERM}_S \) the set \( \{ [Q] : (Q, \varphi_S) \in \Rightarrow_S \} \). The abstract parallel program \( S \subseteq A \times A \) is a solution of the problem \( F \), if \( \forall b \in B : \exists h \in F(b) \), such that the program \( S \) satisfies all the specification properties given in the \( \text{inv}_h, \triangleright_h, \Rightarrow_h, \neg_h, \text{wp}_h, \text{TERM}_h \) components of the element of the parameter space $h$ assuming that the program starts from a state satisfying all the elements of INIT$_h$. The program $S$ satisfies a specification property, if and only if there exists an invariant property $K$ such that the program satisfies the specification property with respect to $K$. This means that a program is said to satisfy a specification property, even if the program fails to satisfy it over a subset of the unreachable states [3, 7]. The presented model has a temporal logic background but the verification steps are based on simple weakest precondition calculations. 5 Sorting a list stored in the unique process state In this section we show our first simple example, in which we sort a list stored in the local process state component of an Object I/O process by bubble sort. We prove an invariant, a fixed point property and termination (progress). 5.1 Formal specification of the problem The state space of the program is the $PSt$ process state of the Object I/O process. $A = \text{pst} : PSt$. The process state consists of three components, the local state, the public state and the IO state. The list of elements to be sorted is stored in the local state. Type $V$ is list of integers. $PSt = (\text{ls} : V, \text{ps} : \text{NoState}, \text{io} : \text{IOSt}), V = \mathbb{[Int]}$. We specify that the program inevitably reaches a fixed point and the list stored in the local process state is a sorted permutation of the initial unsorted list. \[ \uparrow \mapsto \text{FP} \quad (1) \] \[ \text{FP} \Rightarrow (\text{pst.ls} \in \text{perms}(\text{unsortedlist}) \land \text{sorted}(\text{pst.ls})) \quad (2) \] The specification property (2) is allowed to be refined (substituted) by an invariant and a weaker fixed point property [6]. It is easy to show that from (3) and (4) follows (2). \[ \text{inv(} \text{pst.ls} \in \text{perms}(\text{unsortedlist})\text{)} \quad (3) \] \[ \text{FP} \Rightarrow \text{sorted}(\text{pst.ls}) \quad (4) \] 5.2 Clean program The Clean program below starts an Object I/O process and initialises the three components of the process state by calling the $\text{startNDI}$ function. Local state is set to $\text{unsortedlist}$, public state is set to $\text{NoState}$, the IO state is initialised to be empty and subsequently modified by $\text{initialise}$ to include a $\text{Timer}$. The $\text{TimerFunction}$ is set to $\text{bubble}$, i.e. the timer handled by the I/O process calls function $\text{bubble}$ repeatedly again and again after 0 seconds delays. module bubblesort import StdEnv, StdIO, StdDebug :: NoState = NoState Start :: *World -> *World Start world = startNDI unsortedlist NoState initialise [] world where unsortedlist = [100,99..0] initialise :: (PSt [a] .p) -> PSt [a] .p | Ord, toString a initialise pst = snd (openTimer undef (Timer 0 NilLS [TimerFunction (noLS1 bubble)]) pst) bubble :: NrOfIntervals (PSt [a] .p) -> PSt [a] .p | Ord, toString a bubble _ pst=: {ls=list} | not sorted = trace_n (show list) (closeProcess pst) | otherwise = (pst & ls=updateAt i (list!!j)) (updateAt j (list!!i) list)} where (sorted,i,j) = sweep_is_sorted 0 list // sweep_is_sorted :: Int [a] -> (Bool,Int,Int) | Ord a // sweep_is_sorted answers the question whether the list is // sorted and finds the indices (i,j) of two elements in the list // l such that i<j and (l!!i)>(l!!j), if the list is not sorted. 5.3 An abstract model of the program The \( s_0 \) initialisation assignment is a composition of the initialisation of the components and the subsequent set of the IO state to include the timer. The program has an iterative structure, the state transforming step \( pst := \text{bubble}(pst) \) is repeated until the fixed point is reached. A possible abstract model of the concrete Clean program is given below. \[ s_0 : \text{pst} := \text{InitProc}(\text{Timer(bubble)},(\text{unssortedlist},\text{NoState},\text{empty})) \] \[ S : \{ \text{pst} := \text{bubble}(\text{pst}) \} \] where \[ \text{bubble}(\text{pst}) = \begin{cases} (pst.ls, pst.ps, closed) & \text{if } \text{sorted}(\text{pst.ls}) \land (\text{pst.io} \neq \text{closed}) \\ (newlist(pst.ls), pst.ps, pst.io) & \text{if } \neg \text{sorted}(\text{pst.ls}) \land (\text{pst.io} \neq \text{closed}) \end{cases} \] and \( \text{newlist}(\text{list}) = [\text{list}(0), \ldots, \text{list}(i-1), \text{list}(j), \text{list}(i+1), \ldots, \text{list}(j-1), \text{list}(i), \text{list}(j+1), \ldots, \text{list}((\text{list.length} - 1))] \), where \((i,j) = \text{sweep'}(\text{list})\), the first \(i\) and \(j\), for which \(\text{list}(i) > \text{list}(j)\) 5.4 Formal proof We prove invariant (3) first. Let us denote \((\text{pst.ls} \in \text{perms(unsrtlist)})\) by \(P\). \(\text{wp}(\text{pst} := \text{InitProc(\text{Timer(bubble)}), (unsrtlist, NoState, empty), True}) = (\text{pst.ls} = \text{unsrtlist} \land \text{pst.ps} = \text{NoState} \land \text{pst.io} = [\text{Timer(bubble)}]) \Rightarrow (\text{pst.ls} \in \text{perms(unsrtlist)}) = P\). \(\text{wp}(\text{pst} := \text{bubble(pst)}, P) = (\text{sorted(pst.ls)} \land (\text{pst.io} \neq \text{closed}) \rightarrow \text{pst.ls} \in \text{perms(unsrtlist)}) \land (\lnot\text{sorted(pst.ls)} \land (\text{pst.io} \neq \text{closed}) \rightarrow \text{newlist(pst.ls)} \in \text{perms(unsrtlist)})\). Since \(\text{newlist(pst.ls)} \in \text{perms(pst.ls)}\) by definition of \(\text{newlist}\) if \(\lnot\text{sorted(pst.ls)}\) and \(\text{pst.ls} \in \text{perms(unsrtlist)}\), so both the first implication and the second implication follows from \(P\). Let us denote \((\lnot\text{sorted(pst.ls)} \rightarrow \text{pst.io} \neq \text{closed})\) by \(K\). Using the same kind of calculation it is easy to show that \(K\) is an invariant of the program. If we want to prove (4) we have to calculate the fixed point of the program. \[\varphi_S = (\lnot\text{sorted(pst.ls)} \land (\text{pst.io} \neq \text{closed})) \rightarrow \text{pst.ls} = \text{newlist(pst.ls)} \land \text{pst.ps} = \text{pst.ps} \land \text{pst.io} = \text{pst.io}) \land (\text{sorted(pst.ls)} \land (\text{pst.io} \neq \text{closed}) \rightarrow \text{pst.ls} = \text{pst.ls} \land \text{pst.ps} = \text{pst.ps} \land \text{pst.io} = \text{closed}).\] If the condition of the first implication holds, then the consequence is false by definition of \(\text{newlist}\). We get \(\varphi_S = ((\text{sorted(pst.ls)} \lor \text{pst.io} = \text{closed}) \land (\lnot\text{sorted(pst.ls)} \lor (\text{pst.io} = \text{closed})), \) so \(\varphi_S = (\text{pst.io} = \text{closed})\) and \(\varphi_S \land K \Rightarrow \text{sorted(pst.ls)}\). We proved (4). We introduce the variant function \(v = \text{inversion(pst.ls)} - \chi(\text{pst.io} = \text{closed}) + 2\), where \(\chi(\text{true}) = 1\) and \(\chi(\text{false}) = 0\). We apply the theorem of variant function [6] to prove (1). Since \(\forall l : \text{inversion}(l) \geq 0\) and \(\forall b : \chi(b) \leq 1, v \geq 0\). It is easy to see that for invariant \(K\): \(K \Rightarrow v > 0\), i.e. the variant function is positive in any reachable state. We have to show that the variant function inevitably decreases until the program reaches its fixed point, i.e. \(\lnot\varphi_S \land v = t' \land K \Rightarrow v \leq t' - 1\). Using the fact \(\varphi_S \land v = t' \land K \rightarrow \varphi_S \land v \leq t' - 1\). \(\text{wp}(\text{pst} := \text{bubble(pst)}, (\varphi_S \land v \leq t' - 1) \land K) = (\lnot\text{sorted(pst.ls)} \land (\text{pst.io} \neq \text{closed}) \rightarrow (\text{sorted(newlist(pst.ls)}) \lor (\text{inversion(newlist(pst.ls)}) - \chi(\text{closed} = \text{closed}) + 2 \leq t' - 1) \land K)).\) It is easy to show, that from \((\lnot\varphi_S \land v = t' \land K) = (\text{pst.io} \neq \text{closed}) \land \text{inversion(pst.ls)} - \chi(\text{pst.io} = \text{closed}) + 2 = t') \land K\) follows the calculated weakest precondition, hence we proved the \(\Rightarrow\) relation. 6 Properties of communicating I/O processes In this section we prove the correctness of a program which consists of two simple communicating Object I/O processes. We present two processes, which send messages to each other, when the user presses a button. The processes are running in an interleaved way and are interactive. The overall system includes the user as a third component, who interacts with the processes by pressing buttons. 6.1 Formal specification of the problem The overall state space of the program is the smallest common superspace of the subspaces of the three components. Process $A$ is running over the subspace $\text{pst}_A : \text{PSt}_A \times \text{ch}_{ab} : \text{Ch}_1 \times \text{ch}_ba : \text{Ch}_2 \times \text{button}_A : \text{Button}_A$, where $\text{PSt}_A = (ls : \text{Int}, ps : \text{NoState}, io : \text{IOSt}), \text{Ch}_1 = \text{Ch}_2 = \text{Channel}(\text{Int}), \text{Button}_A = \{\text{pressed}, \text{released}\}$. Similarly process $B$ is running over the subspace $\text{pst}_B : \text{PSt}_B \times \text{ch}_{ab} : \text{Ch}_1 \times \text{ch}_ba : \text{Ch}_2 \times \text{button}_B : \text{Button}_B$, where $\text{Button}_B = \{\text{pressed}, \text{released}\}$. The user is acting over the subspace $\text{button}_A : \text{Button}_A \times \text{button}_B : \text{Button}_B$. The overall state space of the system is: $A = \text{pst}_A : \text{PSt}_A \times \text{ch}_{ab} : \text{Ch}_1 \times \text{ch}_ba : \text{Ch}_2 \times \text{button}_A : \text{Button}_A \times \text{button}_B : \text{Button}_B$. We use the concept of history of channels in our specification and verification. The history of a channel is the list of elements communicated on it ever. The history of channel $c$ is denoted by $\text{hc}_c$. We specify that the system reaches one of its fixed points (6) after sending $mc$ messages (7), which messages are initiated by pressing the buttons (8),(9). We assume that channels are initially empty and buttons are released (5). The parameter space is $B = mc : \text{Int}$. \[ \begin{align*} \text{ch}_ba &= \text{ch}_{ab} = \overline{\text{ch}_{ab}} = \overline{\text{ch}_{ab}} = <\not\triangleright \text{button}_A = \text{button}_B = \text{released} \in \text{INIT}_{mc} (5) \\ \uparrow \text{FP} &\quad \text{FP}_{mc} \Rightarrow |\text{ch}_{ab}| + |\text{ch}_{ba}| = mc \\ \text{button}_A &= \text{pressed} \land |\text{ch}_{ab}| = t' \triangleright mc \text{ button}_A = \text{released} \land |\text{ch}_{ab}| = t' + 1 (8) \\ \text{button}_B &= \text{pressed} \land |\text{ch}_{ba}| = t' \triangleright mc \text{ button}_B = \text{released} \land |\text{ch}_{ba}| = t' + 1 (9) \end{align*} \] 6.2 Clean program The two processes behave in the same way. The function process is the functional abstraction of the common behaviour. The first parameter of the process is its name, the second parameter is an ordered pair of two identifiers, which are used to identify the process itself and the other process. The \textit{NDIProcess}-es are declared to belong to a \textit{ProcessGroup} with shared state initialised to \text{NoState}, i.e. no useful shared public state exists. Communication channels are implemented implicitly. The local part of the process state \text{PSt} is initialised by the \textit{NDIProcess} to 0. The \textit{initialise} functions initialises the IO state. There are two state transition functions defined. Function \texttt{pressed} may cause a state transition by sending data and incrementing the counter stored in the local state when the corresponding button is pressed. Function \texttt{received} is activated to receive data and to increment the counter stored in the local state when a message is arrived to the process. If the counter reaches the value $mc$, then the IO state is closed. module processes import StdEnv, StdIO :: NoState = NoState Start :: *World -> *World Start world # (ridA,world) = openRId world # (ridB,world) = openRId world = startProcesses [process "A" (ridA,ridB), process "B" (ridB,ridA)] world process :: String (RId i,RId i) -> ProcessGroup NDIProcess process name (me,you) = ProcessGroup NoState (NDIProcess 0 initialise []) where mc = 10 initialise :: (PSt Int .p) -> PSt Int .p initialise pst = snd (openDialog undef dialog pst) where dialog = Dialog name ( ButtonControl "Press me" [ControlFunction (noLS pressed)] :+: Receiver me (noLS1 received) [] ) [] pressed :: (PSt Int .p) -> PSt Int .p pressed pst=:(ls=i) # (_,pst) = syncSend you undef pst | i'<mc = {pst & ls=i'} | otherwise = closeProcess {pst & ls=i'} where i'= i+1 received :: .i (PSt Int .p) -> PSt Int .p received _ pst=:{ls=i} | i'<mc = {pst & ls=i'} | otherwise = closeProcess {pst & ls=i'} where i' = i+1 Synchronous sending means an immediate call of the receiver of the partner process. The event handler processes a synchronous send and the corresponding receiving of the data in one single atomic action. This means a very strict ordering of events, which can be expressed by introducing strict explicit synchronization conditions at the abstract program level. The construction of the formal proof pointed out that a concrete program performing an asynchronous message passing instead of the synchronous one would not be correct. On the other hand an abstract program with weaker synchronization conditions was to be proved correct in respect to the posed problem, i.e. the concrete program can not be less synchronised but the abstract program corresponding to the concrete one is proved to be over-synchronized. 6.3 An abstract model of the program We present the overall abstract program as the union of three components [3, 8]. The model behind the abstract program assumes an unconditionally fair scheduling which differs from the event driven semantics of the concrete program. Events are represented by conditions and assumed to be initiated by the user. The $s_0$ initialisation assignments of the processes is a composition of the initialisation of the components and the subsequent set of the IO state. \[ \begin{align*} \text{s0}_A : & \quad \text{pst}_A := \text{Init}((\text{Dialog}(\text{Button}(\text{pressed})), \text{Receiver}(\text{received})), (0, \text{NoState}, \text{empty})) \\ S_A : & \quad \{ \\ & \quad \text{pst}_A, \text{button}_A, \text{chab} := \text{pressed}(\text{pst}_A), \text{released}, \text{send}(\text{chab}, 0) \\ & \quad \quad \text{if} \; \text{button}_A = \text{pressed} \land |\text{chab}| = |\text{chba}| = 0 \land \text{pst}_A.\text{io} \neq \text{closed} \\ & \quad \quad \quad \text{pst}_A, \text{chba} := \text{received}(\text{pst}_A), \text{receive}(\text{chba}) \\ & \quad \quad \quad \quad \text{if} \; |\text{chba}| \neq 0 \land |\text{chab}| = 0 \land \text{pst}_A.\text{io} \neq \text{closed} \\ \} \end{align*} \] \[ \begin{align*} \text{s0}_B : & \quad \text{pst}_B := \text{Init}((\text{Dialog}(\text{Button}(\text{pressed})), \text{Receiver}(\text{received})), (0, \text{NoState}, \text{empty})) \\ S_B : & \quad \{ \\ & \quad \text{pst}_B, \text{button}_B, \text{chba} := \text{pressed}(\text{pst}_B), \text{released}, \text{send}(\text{chba}, 0) \\ & \quad \quad \text{if} \; \text{button}_B = \text{pressed} \land |\text{chba}| = |\text{chab}| = 0 \land \text{pst}_B.\text{io} \neq \text{closed} \\ & \quad \quad \quad \text{pst}_B, \text{chab} := \text{received}(\text{pst}_B), \text{receive}(\text{chab}) \\ & \quad \quad \quad \quad \text{if} \; |\text{chab}| \neq 0 \land |\text{chba}| = 0 \land \text{pst}_B.\text{io} \neq \text{closed} \\ \} \end{align*} \] \[ \begin{align*} \text{s0}U : & \quad \text{SKIP} \\ S_U : & \quad \{ \\ & \quad \text{button}_A := \text{pressed}, \text{if} \; \text{button}_A = \text{released} \land |\text{chab}| = 0 \land \text{pst}_A.\text{io} \neq \text{closed} \\ & \quad \quad \text{button}_B := \text{pressed}, \text{if} \; \text{button}_B = \text{released} \land |\text{chba}| = 0 \land \text{pst}_B.\text{io} \neq \text{closed} \\ \} \end{align*} \] where \[ \begin{align*} p\text{ressed}(\text{pst}) & = \begin{cases} (pst.\text{ls} + 1, pst.\text{ps}, pst.\text{io}) & \text{if} \; pst.\text{ls} + 1 < mc \\ (pst.\text{ls} + 1, pst.\text{ps}, \text{closed}) & \text{otherwise} \end{cases} \\ \text{received}(\text{pst}) & = \text{pressed}(\text{pst}) \end{align*} \] 6.4 Formal proof Now we prove\(^3\) that the former abstract program solves the specification properties (5-9) introduced in section 6.1. It is enough to show that the program \(^3\) For the sake of brevity (and also understandability) we omit the computation of weakest preconditions. We restrict ourselves to give a hint how these computations should be performed. Calculations of weakest preconditions are presented in section 5.4. satisfies those properties for its reachable states. Thus we determine a couple of invariants first. \[ \begin{align*} |ch_{ab}| + |ch_{ba}| - |ch_{ba}| &= pst_A.ls \in inv_S \\ |ch_{ba}| + |ch_{ab}| - |ch_{ab}| &= pst_B.ls \in inv_S \end{align*} \] \begin{align*} pst_A.ls \leq mc &\land (pst_A.ls = mc \iff pst_A.io = closed) \in inv_S \\ pst_B.ls \leq mc &\land (pst_B.ls = mc \iff pst_B.io = closed) \in inv_S \end{align*} \begin{align*} |ch_{ab}| * |ch_{ba}| &= 0 \quad \in inv_S \end{align*} \begin{align*} pst_A.ls + |ch_{ba}| &= pst_B.ls + |ch_{ab}| \quad \in inv_S \end{align*} Initially all of the above predicates hold, since the channels and their histories are empty, \(pst_A.ls = pst_B.ls = 0 < mc\) and neither \(pst_A.io\) nor \(pst_B.io\) is closed. For proving the stability of the predicates — according to a well-known hint — it is sufficient to check those assignments that can change the value of one of the variables occurring in a predicate. Let’s start with (14). It formulates that one of the channels should always be empty. Only the assignments containing the \textit{send} function can make an empty channel non-empty. For example the first statement in \(S_A\) can extend channel \(ch_{ab}\), but only when \(ch_{ba}\) is empty. Since this assignment doesn’t change the value of \(ch_{ba}\), there will be an empty channel after executing it, namely \(ch_{ba}\). The sender assignment in \(S_B\) can be checked similarly. Stability of the predicates in (12) and (13) is based on the definition of \textit{pressed} and \textit{received}. Only these two functions change the \textit{ls} and \textit{io} components of \(pst_A\) and \(pst_B\). An \textit{ls} is increased only by one, and it becomes \(mc\) at the very same time as the \textit{io} becomes closed. After the \textit{io} is closed, neither the send nor the receive operation can be called, thus \textit{ls} can not grow above \(mc\). When calculating (10) we can observe that the change (growth) of \(pst_A.ls\) is always accompanied by either a send or a receive operation on \(ch_{ab}\) and \(ch_{ba}\), respectively, which either increase \(|ch_{ab}|\) or decrease \(|ch_{ba}|\). The values in the left-hand side of the equation can also be changed by a send on \(ch_{ba}\), but such an operation will increase both \(|ch_{ba}|\) and \(|ch_{ba}|\), their difference will remain the same. (11) can be done similarly, and (15) is also based on the same phenomenon. Now that the proof of the invariants is completed, we can compute the set of fixed points of the abstract program. All the assignments are such that the left-hand sides cannot be equal with the right-hand sides (either because channels are changed when a send or receive operation is performed on them, or because — in the case of \(S_U\) — the conditions do not allow it). Thus the set of fixed points is a conjunction of the negated conditions of the statements: the program doesn’t change its state when none of the conditions is true. After some steps of simplification the \(\varphi_S\) set of fixed points is the following: \[ \varphi_S = (pst_A.io = closed \vee |ch_{ab}| \neq 0) \land (pst_B.io = closed \vee |ch_{ba}| \neq 0) \] (from 12), thus (15) and the second part of (11) guarantees that \( \text{pst}_B.LS = mc \) and \( |\text{ch}_{ba}| = 0 \), too. Using invariant (10) we can conclude proving the fixed point specification property (7). The truth of property (8) is affected only by two assignments: the first from \( S_A \) and the first from \( S_U \). The others cannot change the value of either \( \text{button}_A \) or \( \text{ch}_{ab} \). Furthermore, the condition of the assignment from \( S_U \) guarantees that this assignment will never change the state of the program if the left-hand side of the \( \triangleright \) property holds. Finally, the sender statement of \( S_A \) should be investigated. A simple weakest precondition calculation reveals, that when the condition of that assignment holds, thus the variables can change at all, both \( \text{button}_A \) and \( \text{ch}_{ab} \) will take on values that satisfy the right-hand side of the \( \triangleright \) relation. The proof is analogous for (9). The correctness of the abstract program in respect of (6) can be proved by applying the theorem of variant function. We choose the variant function \( v = 2 \times mc + 1 - \text{pst}_A.LS - \text{pst}_B.LS \). (The invariants guarantee that its value is a positive integer in every reachable state.) The calculation is similar to the calculations presented in section 5.4 but is more complicated from technical point of view. We can show that the variant function will inevitably fall off if the program is not in one of its fixed points. Let’s suppose e.g. that \( \text{pst}_A.io \neq \text{closed} \land |\text{ch}_{ab}| \neq 0 \). It is possible to prove that the following progress properties hold: \[ \begin{align*} \text{pst}_A.io \neq \text{closed} & \land |\text{ch}_{ab}| \neq 0 & \land |\text{ch}_{ba}| = 0 & \land v = k \iff mc & v < k \\ \text{pst}_A.io \neq \text{closed} & \land \text{ch}_{ab} \neq 0 & \land |\text{ch}_{ba}| = 0 & \land \text{button}_A = \text{pressed} \land v = k \iff mc & v < k \\ \text{pst}_A.io \neq \text{closed} & \land |\text{ch}_{ab}| \neq 0 & \land |\text{ch}_{ba}| = 0 & \land \text{button}_A = \text{released} \land v = k \iff mc \\ & \land (\text{pst}_A.io \neq \text{closed} & \land |\text{ch}_{ab}| \neq 0 & \land |\text{ch}_{ba}| = 0 & \land \text{button}_A = \text{pressed} \land v = k) \\ & \lor v < k \end{align*} \] Based on the properties of the “leads-to” relation and using the theorems of refinements of specifications [6] one can easily derive that: \[ \text{pst}_A.io \neq \text{closed} \land |\text{ch}_{ab}| \neq 0 \land v = k \iff mc \land v < k. \] 7 Conclusions We presented a two phase methodology for proving the correctness of Clean Object I/O processes with a static set of state transition functions. The methodology can be applied for dynamic set of state transition functions, if the condition of adding new and removing old state transition functions is well defined. In that case all the state transition functions should be included into the abstract model at the beginning extended with the appropriate conditions, which conditions allow change of state for the appropriate period only. The model can be used as well to prove the temporal properties of more general Clean programs using uniqueness types in principle\(^4\) if unique objects are regarded as static entities at a different semantical view and abstraction level. Construction of an abstract model having the same semantics as the concrete program could be very difficult in practice. \(^4\) If dynamics are used then open specifications [3, 4] should be applied. The methodology should be assisted by a two phase tool (not necessarily by a fully automatic one) in the future, which helps to formulate an abstract model of the state transitions defined in the Clean program text and ensures the correctness of the abstract program in respect of the main semantical properties of the concrete program. Also a proof tool, for example an appropriate extension of CPS which is working with propositional logic assertions would be necessary to support the verification of the abstract program in respect of the specification. References
{"Source-Url": "http://repository.ubn.ru.nl/bitstream/handle/2066/111088/111088.pdf?sequence=1", "len_cl100k_base": 10337, "olmocr-version": "0.1.53", "pdf-total-pages": 14, "total-fallback-pages": 0, "total-input-tokens": 47054, "total-output-tokens": 12264, "length": "2e13", "weborganizer": {"__label__adult": 0.0003311634063720703, "__label__art_design": 0.0002932548522949219, "__label__crime_law": 0.0003590583801269531, "__label__education_jobs": 0.0006237030029296875, "__label__entertainment": 5.823373794555664e-05, "__label__fashion_beauty": 0.00013267993927001953, "__label__finance_business": 0.0001939535140991211, "__label__food_dining": 0.0003457069396972656, "__label__games": 0.0006732940673828125, "__label__hardware": 0.0009589195251464844, "__label__health": 0.0005297660827636719, "__label__history": 0.0002243518829345703, "__label__home_hobbies": 9.620189666748048e-05, "__label__industrial": 0.00038552284240722656, "__label__literature": 0.00024306774139404297, "__label__politics": 0.00028395652770996094, "__label__religion": 0.0004987716674804688, "__label__science_tech": 0.021636962890625, "__label__social_life": 7.045269012451172e-05, "__label__software": 0.00461578369140625, "__label__software_dev": 0.96630859375, "__label__sports_fitness": 0.0003037452697753906, "__label__transportation": 0.0006055831909179688, "__label__travel": 0.00019669532775878904}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 40134, 0.01338]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 40134, 0.60145]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 40134, 0.78012]], "google_gemma-3-12b-it_contains_pii": [[0, 0, null], [0, 2374, false], [2374, 5882, null], [5882, 9074, null], [9074, 13249, null], [13249, 15797, null], [15797, 17926, null], [17926, 21743, null], [21743, 25122, null], [25122, 26910, null], [26910, 30115, null], [30115, 33319, null], [33319, 36942, null], [36942, 40134, null]], "google_gemma-3-12b-it_is_public_document": [[0, 0, null], [0, 2374, true], [2374, 5882, null], [5882, 9074, null], [9074, 13249, null], [13249, 15797, null], [15797, 17926, null], [17926, 21743, null], [21743, 25122, null], [25122, 26910, null], [26910, 30115, null], [30115, 33319, null], [33319, 36942, null], [36942, 40134, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 40134, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 40134, null]], "pdf_page_numbers": [[0, 0, 1], [0, 2374, 2], [2374, 5882, 3], [5882, 9074, 4], [9074, 13249, 5], [13249, 15797, 6], [15797, 17926, 7], [17926, 21743, 8], [21743, 25122, 9], [25122, 26910, 10], [26910, 30115, 11], [30115, 33319, 12], [33319, 36942, 13], [36942, 40134, 14]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 40134, 0.0]]}
olmocr_science_pdfs
2024-12-06
2024-12-06
3f9362cd13559bf89e57534cef8ef7a82015a6e7
On the expressiveness of single-pass instruction sequences Bergstra, J.A.; Middelburg, C.A. DOI 10.1007/s00224-010-9301-8 Publication date 2012 Document Version Final published version Published in Theory of Computing Systems Citation for published version (APA): General rights It is not permitted to download or to forward/distribute the text or part of it without the consent of the author(s) and/or copyright holder(s), other than for strictly personal, individual use, unless the work is under an open content license (like Creative Commons). Disclaimer/Complaints regulations If you believe that digital publication of certain material infringes any of your rights or (privacy) interests, please let the Library know, stating your reasons. In case of a legitimate complaint, the Library will make the material inaccessible and/or remove it from the website. Please Ask the Library: https://uba.uva.nl/en/contact, or a letter to: Library of the University of Amsterdam, Secretariat, Singel 425, 1012 WP Amsterdam, The Netherlands. You will be contacted as soon as possible. UvA-DARE is a service provided by the library of the University of Amsterdam (https://dare.uva.nl) On the Expressiveness of Single-Pass Instruction Sequences J.A. Bergstra · C.A. Middelburg Published online: 11 November 2010 © The Author(s) 2010. This article is published with open access at Springerlink.com Abstract We perceive programs as single-pass instruction sequences. A single-pass instruction sequence under execution is considered to produce a behaviour to be controlled by some execution environment. Threads as considered in basic thread algebra model such behaviours. We show that all regular threads, i.e. threads that can only be in a finite number of states, can be produced by single-pass instruction sequences without jump instructions if use can be made of Boolean registers. We also show that, in the case where goto instructions are used instead of jump instructions, a bound to the number of labels restricts the expressiveness. Keywords Single-pass instruction sequence · Regular thread · Expressiveness · Jump-free instruction sequence 1 Introduction The work presented in this paper is part of a research program which is concerned with different subjects from the theory of computation and the area of computer architectures where we come across the relevancy of the notion of instruction sequence. The working hypothesis of this research program is that this notion is a central notion of computer science. It is clear that instruction sequence is a key concept in practice, but strangely enough it has as yet not come prominently into the picture in theoretical circles. Program algebra [3], which is intended as a setting suited for developing theory from the above-mentioned working hypothesis, is taken for the basis of the development of theory under the research program. The starting-point of program algebra is the perception of a program as a single-pass instruction sequence, i.e. a finite or infinite sequence of instructions of which each instruction is executed at most once and can be dropped after it has been executed or jumped over. This perception is simple, appealing, and links up with practice. A single-pass instruction sequence under execution is considered to produce a behaviour to be controlled by some execution environment. Threads as considered in basic thread algebra [3] model such behaviours: upon each action performed by a thread, a reply from the execution environment determines how the thread proceeds. A thread may make use of services, i.e. components of the execution environment. Each Turing machine can be simulated by means of a thread that makes use of a service. The thread and service correspond to the finite control and tape of the Turing machine. The threads that correspond to the finite controls of Turing machines are examples of regular threads, i.e. threads that can only be in a finite number of states. The behaviours of all single-pass instruction sequences considered in program algebra are regular threads and each regular thread is produced by some single-pass instruction sequence. In this paper, we show that each regular thread can be produced by some single-pass instruction sequence without jump instructions if use can be made of services that make up Boolean registers. The primitive instructions of program algebra include jump instructions. An interesting variant of program algebra is obtained by leaving out jump instructions and adding labels and goto instructions. It is easy to see that each regular thread can also be produced by some single-pass instruction sequence with labels and goto instructions. In this paper, we show that a bound to the number of labels restricts the expressiveness of this variant. As part of the research program of which the work presented in this paper is part, issues concerning the following subjects from the theory of computation have been investigated from the viewpoint that a program is an instruction sequence: semantics of programming languages [4, 12], expressiveness of programming languages [9, 23], computability [10, 13], and computational complexity [7]. Performance related matters of instruction sequences have also been investigated in the spirit of the theory of computation [11, 12]. In the area of computer architectures, basic techniques aimed at increasing processor performance have been studied as part of this research program (see e.g. [5, 8]). The work referred to above provides evidence for our hypothesis that the notion of instruction sequence is a central notion of computer science. To say the least, it shows that instruction sequences are relevant to diverse subjects. In addition, it is to be expected that the emerging developments with respect to techniques for high-performance program execution on classical or non-classical computers require that programs are considered at the level of instruction sequences. All this has motivated us to continue the above-mentioned research program with the work on expressiveness presented in this paper. 1In [3], basic thread algebra is introduced under the name basic polarized process algebra. This paper is organized as follows. First, we review basic thread algebra and program algebra (Sects. 2 and 3). Next, we present a mechanism for interaction of threads with services and give a description of Boolean register services (Sects. 4 and 5). After that, we show that each regular thread can be produced by some single-pass instruction sequence without jump instructions if use can be made of Boolean register services (Sect. 6). Then, we introduce the variant of program algebra obtained by leaving out jump instructions and adding labels and goto instructions (Sect. 7). Following this, we show that a bound to the number of labels restricts the expressiveness of this variant (Sect. 8). Finally, we make some concluding remarks (Sect. 9). 2 Basic Thread Algebra In this section, we review BTA (Basic Thread Algebra), which is concerned with the behaviours that sequential programs exhibit on execution. These behaviours are called threads. In BTA, it is assumed that a fixed but arbitrary set $\mathcal{A}$ of basic actions has been given. A thread performs actions in a sequential fashion. Upon each action performed, a reply from the execution environment of the thread determines how it proceeds. To simplify matters, there are only two possible replies: $T$ and $F$. BTA has one sort: the sort $T$ of threads. To build terms of sort $T$, it has the following constants and operators: - the deadlock constant $D : T$; - the termination constant $S : T$; - for each $a \in \mathcal{A}$, the binary postconditional composition operator $\_ \triangleleft a \triangleright \_ : T \times T \rightarrow T$. We assume that there are infinitely many variables of sort $T$, including $x, y, z$. We introduce action prefixing as an abbreviation: $a \circ p$ abbreviates $p \triangleleft a \triangleright p$. The thread denoted by a closed term of the form $p \triangleleft a \triangleright q$ will first perform $a$, and then proceed as the thread denoted by $p$ if the reply from the execution environment is $T$ and proceed as the thread denoted by $q$ if the reply from the execution environment is $F$. The threads denoted by $D$ and $S$ will become inactive and terminate, respectively. This implies that each closed BTA term denotes a thread that will become inactive or terminate after it has performed finitely many actions. Infinite threads can be described by guarded recursion. A guarded recursive specification over BTA is a set of recursion equations $E = \{X = t_X \mid X \in V\}$, where $V$ is a set of variables of sort $T$ and each $t_X$ is a BTA term of the form $D$, $S$ or $t \triangleleft a \triangleright t'$ with $t$ and $t'$ that contain only variables from $V$. We write $V(E)$ for the set of all variables that occur in $E$. We are only interested in models of BTA in which guarded recursive specifications have unique solutions, such as the projective limit model of BTA presented in [2]. For each guarded recursive specification $E$ and each $X \in V(E)$, we introduce a constant $\langle X \mid E \rangle$ of sort $T$ standing for the unique solution of $E$ for $X$. The axioms for these constants are given in Table 1. In this table, we write $\langle t_X \mid E \rangle$ for $t_X$ with, for all $Y \in V(E)$, all occurrences of $Y$ in $t_X$ replaced by $\langle Y \mid E \rangle$. $X$, $t_X$ and $E$ stand for an arbitrary variable of sort T, an arbitrary BTA term of sort T and an arbitrary guarded recursive specification over BTA, respectively. Side conditions are added to restrict what X, tX and E stand for. Closed terms that denote the same infinite thread cannot always be proved equal by means of the axioms given in Table 1. We introduce AIP (Approximation Induction Principle) to remedy this. AIP is based on the view that two threads are identical if their approximations up to any finite depth are identical. The approximation up to depth n of a thread is obtained by cutting it off after it has performed n actions. In AIP, the approximation up to depth n is phrased in terms of the unary projection operator πₙ : T → T. AIP and the axioms for the projection operators are given in Table 2. ### 3 Program Algebra In this section, we review PGA (ProGram Algebra). The perception of a program as a single-pass instruction sequence is the starting-point of PGA. In PGA, it is assumed that a fixed but arbitrary set A of basic instructions has been given. PGA has the following primitive instructions: - for each a ∈ A, a plain basic instruction a; - for each a ∈ A, a positive test instruction +a; - for each a ∈ A, a negative test instruction −a; - for each l ∈ N, a forward jump instruction #l; - a termination instruction !. We write J for the set of all primitive instructions. The intuition is that the execution of a basic instruction a produces either T or F at its completion. In the case of a positive test instruction +a, a is executed and execution proceeds with the next primitive instruction if T is produced. Otherwise, the next primitive instruction is skipped and execution proceeds with the primitive instruction following the skipped one. If there is no next instruction to be executed, deadlock occurs. In the case of a negative test instruction −a, the role of the value produced is reversed. In the case of a plain basic instruction a, execution always proceeds as if T is produced. The effect of a forward jump instruction #l is that execution proceeds with the l-th next instruction. If l equals 0 or the l-th next instruction does not exist, deadlock occurs. The effect of the termination instruction ! is that execution terminates. PGA has the following constants and operators: - for each \( u \in \mathcal{I} \), an instruction constant \( u \); - the binary concatenation operator \( _{;} \); - the unary repetition operator \( _{ω} \). We assume that there are infinitely many variables, including \( X, Y, Z \). A closed PGA term is considered to denote a non-empty, finite or eventually periodic infinite sequence of primitive instructions.\(^2\) Closed PGA terms are considered equal if they denote the same instruction sequence. The axioms for instruction sequence equivalence are given in Table 3. In this table, \( n \) stands for an arbitrary natural number greater than 0. For each PGA term \( P \), the term \( P^n \) is defined by induction on \( n \) as follows: \( P^1 = P \) and \( P^{n+1} = P \cdot P^n \). The equation \( X^ω = X \cdot X^ω \) is derivable. Each closed PGA term is derivably equal to one of the form \( P \) or \( P^ω \cdot Q \), where \( P \) and \( Q \) are closed PGA terms in which the repetition operator does not occur. The repetition operator renders backward jump instructions superfluous. In [3], it is shown how programs in a program notation that is close to existing assembly languages with forward and backward jump instructions can be translated into closed PGA terms. The behaviours of the instruction sequences denoted by closed PGA terms are considered threads, with basic instructions taken for basic actions. The thread extraction operation \( |_{;} | \) determines, for each closed PGA term \( P \), a closed term of BTA with guarded recursion that denotes the behaviour of the instruction sequence denoted by \( P \). The thread extraction operation is defined by the equations given in Table 4 (for \( a \in \mathcal{A} \), \( l \in \mathbb{N} \) and \( u \in \mathcal{I} \)) and the rule that \( |_{#l}; X | = D \) if \( #l \) is the beginning of an infinite jump chain. This rule is formalized in e.g. [9]. \[^2\]An eventually periodic infinite sequence is an infinite sequence with only finitely many distinct suffixes. 4 Interaction of Threads with Services A thread may make use of services. That is, a thread may perform an action for the purpose of interacting with a service that takes the action as a command to be processed. The processing of an action may involve a change of state of the service and at completion of the processing of the action the service returns a reply value to the thread. In this section, we introduce the use operators, which are concerned with this kind of interaction between threads and services. It is assumed that a fixed but arbitrary set $F$ of foci and a fixed but arbitrary set $M$ of methods have been given. Each focus plays the role of a name of some service provided by an execution environment that can be requested to process a command. Each method plays the role of a command proper. For the set $A$ of actions, we take the set $\{f.m | f \in F, m \in M\}$. Performing an action $f.m$ is taken as making a request to the service named $f$ to process command $m$. A service $H$ consists of - a set $S$ of states; - an effect function $\text{eff} : M \times S \rightarrow S$; - a yield function $\text{yld} : M \times S \rightarrow \{T, F, B\}$; - an initial state $s_0 \in S$; satisfying the following condition: $$\forall m \in M, s \in S \cdot (\text{yld}(m, s) = B \Rightarrow \forall m' \in M \cdot \text{yld}(m', \text{eff}(m, s)) = B).$$ The set $S$ contains the states in which the service may be, and the functions $\text{eff}$ and $\text{yld}$ give, for each method $m$ and state $s$, the state and reply, respectively, that result from processing $m$ in state $s$. Let $H = (S, \text{eff}, \text{yld}, s_0)$ be a service and let $m \in M$. Then the derived service of $H$ after processing $m$, written $\partial \partial m H$, is the service $(S, \text{eff}, \text{yld}, \text{eff}(m, s_0))$; and the reply of $H$ after processing $m$, written $H(m)$, is $\text{yld}(m, s_0)$. When a thread makes a request to service $H$ to process $m$: - if $H(m) \neq B$, then the request is accepted, the reply is $H(m)$, and the service proceeds as $\partial \partial m H$; - if $H(m) = B$, then the request is rejected. We introduce the sort $S$ of services and, for each $f \in F$, the binary use operator $\_ / f \_ : T \times S \rightarrow T$. The axioms for these operators are given in Table 5. Intuitively, $p / f H$ is the thread that results from processing all actions performed by thread $p$ that are of the form $f.m$ by service $H$. When an action of the form $f.m$ performed by thread $p$ is processed by service $H$, the postconditional composition concerned is eliminated on the basis of the reply value produced. No internal action is left as a trace of the processed action, like with the use operators found in papers on thread interleaving (see e.g. [6]). Combining TSU2 and TSU7, we obtain $\bigwedge_{n \geq 0} \pi_n(x) / f H = D \Rightarrow x / f H = D$. Springer Table 5 Axioms for use operators \[ \begin{align*} S /_f H &= S & \text{TSU1} \\ D /_f H &= D & \text{TSU2} \\ (x \leq g, m \geq y) /_f H &= (x /_f H) \leq g, m \geq (y /_f H) & \text{if } f \neq g \text{ TSU3} \\ (x \leq f, m \geq y) /_f H &= x /_f D_{\delta m} H & \text{if } H(m) = T \text{ TSU4} \\ (x \leq f, m \geq y) /_f H &= y /_f D_{\delta m} H & \text{if } H(m) = F \text{ TSU5} \\ (x \leq f, m \geq y) /_f H &= D & \text{if } H(m) = B \text{ TSU6} \\ \bigwedge_{n \geq 0} \pi_n(x) /_f H &= \pi_n(y) /_f H \Rightarrow x /_f H = y /_f H & \text{TSU7} \end{align*} \] 5 Instruction Sequences Acting on Boolean Registers Our study of jump-free instruction sequences in Sect. 6 is concerned with instruction sequences that act on Boolean registers. In this section, we describe services that make up Boolean registers. A Boolean register service accepts the following methods: - a set to true method set:T; - a set to false method set:F; - a get method get. We write \( M_{\text{BR}} \) for the set \{set:T, set:F, get\}. It is assumed that \( M_{\text{BR}} \subseteq M \). The methods accepted by Boolean register services can be explained as follows: - set:T: the contents of the Boolean register becomes T and the reply is T; - set:F: the contents of the Boolean register becomes F and the reply is F; - get: nothing changes and the reply is the contents of the Boolean register. Let \( s \in \{T, F, B\} \). Then the Boolean register service with initial state \( s \), written \( BR_s \), is the service \((\{T, F, B\}, eff, eff, s)\), where the function \( eff \) is defined as follows \((b \in \{T, F\})\): \[ \begin{align*} \text{eff(set:T, b)} &= T, & \text{eff}(m, b) &= B & \text{if } m \notin M_{\text{BR}}, \\ \text{eff(set:F, b)} &= F, & \text{eff}(m, B) &= B. \\ \text{eff(get, b)} &= b, \end{align*} \] Notice that the effect and yield functions of a Boolean register service are the same. 6 Jump-Free Instruction Sequences In this section, we show that each thread that can only be in a finite number of states can be produced by some single-pass instruction sequence without jump instructions if use can be made of Boolean register services. First, we make precise what it means that a thread can only be in a finite number of states. We assume that a fixed but arbitrary model \( \mathfrak{M} \) of BTA extended with guarded recursion and the use mechanism has been given, we use the term thread only for the elements from the domain of \( M \), and we denote the interpretations of constants and operators in \( M \) by the constants and operators themselves. Let \( p \) be a thread. Then the set of states or residual threads of \( p \), written \( \text{Res}(p) \), is inductively defined as follows: - \( p \in \text{Res}(p) \); - if \( q \sqsubseteq a \sqsupseteq r \in \text{Res}(p) \), then \( q \in \text{Res}(p) \) and \( r \in \text{Res}(p) \). We say that \( p \) is a regular thread if \( \text{Res}(p) \) is finite. We will make use of the fact that being a regular thread coincides with being the solution of a finite guarded recursive specification of a restricted form. A linear recursive specification over BTA is a guarded recursive specification \[ E = \{ X = tX \mid X \in V \} \] where each \( tX \) is a term of the form \( D, S \) or \( Y \sqsubseteq a \sqsupseteq Z \) with \( Y, Z \in V \). **Proposition 1** Let \( p \) be a thread. Then \( p \) is a regular thread iff there exists a finite linear recursive specification \( E \) and a variable \( X \in V(E) \) such that \( p \) is the solution of \( E \) for \( X \). **Proof** This proposition generalizes Theorem 1 from [23] from the projective limit model to an arbitrary model. However, the proof of that theorem is applicable to any model. \(\square\) In the proof of the next theorem, we associate a closed PGA term \( P \) in which jump instructions do not occur with a finite linear recursive specification \[ E = \{ X_i = X_{l(i)} \sqsubseteq a_i \sqsupseteq X_{r(i)} \mid i \in [1,n] \} \cup \{ X_{n+1} = S, X_{n+2} = D \}. \] In \( P \), a number of Boolean register services is used for specific purposes. The purpose of each individual Boolean register is reflected in the focus that serves as its name: - for each \( i \in [1,n+2] \), \( s:i \) serves as the name of a Boolean register that is used to indicate whether the current state of \( \langle X_1 \mid E \rangle \) is \( \langle X_i \mid E \rangle \); - \( rt \) serves as the name of a Boolean register that is used to indicate whether the reply upon the action performed by \( \langle X_1 \mid E \rangle \) in its current state is \( T \); - \( rf \) serves as the name of a Boolean register that is used to indicate whether the reply upon the action performed by \( \langle X_1 \mid E \rangle \) in its current state is \( F \); - \( e \) serves as the name of a Boolean register that is used to achieve that instructions not related to the current state of \( \langle X_1 \mid E \rangle \) are passed correctly; - \( f \) serves as the name of a Boolean register that is used to achieve with the instruction \( +f.set:F \) that the following instruction is skipped. Now we turn to the theorem announced above. It states rigorously that the solution of every finite linear recursive specification can be produced by an instruction sequence without jump instructions if use can be made of Boolean register services. **Theorem 1** Let a finite linear recursive specification \[ E = \{ X_i = X_{l(i)} \sqsubseteq a_i \sqsupseteq X_{r(i)} \mid i \in [1,n] \} \cup \{ X_{n+1} = S, X_{n+2} = D \} \] be given. Then there exists a closed PGA term \( P \) in which jump instructions do not occur such that \[ <X_1|E> = ((((\ldots (|P| /_{s:1} BR_F) \ldots /_{s:n+2} BR_F) /_{t} BR_F) /_{\emptyset} BR_F) /_{\hat{t}} BR_F). \] Proof We associate a closed PGA term \( P \) in which jump instructions do not occur with \( E \) as follows: \[ P = s:1.set:T; (Q_1; \ldots; Q_{n+1})^o, \] where, for each \( i \in [1, n] \): \[ Q_i = +s:i.get; e.set:T; +e.get; s:i.set:F; +e.get; s:i.set:F; rt.set:T; +e.get; s:i.set:F; rt.set:T; +rt.get; s:i.set:T; +rt.get; s:i.set:T; \] and \[ Q_{n+1} = +s:n+1.get; !. \] We use the following abbreviations (for \( i \in [1, n+1] \) and \( j \in [1, n+2] \)): \[ P_i'^{br} \quad \text{for} \quad Q_i; \ldots; Q_{n+1}; (Q_1; \ldots; Q_{n+1})^o; \] \[ |x_{i,j}^{br} \quad \text{for} \quad ((((\ldots (|P_i'| /_{s:1} BR_F) \ldots /_{s:n+2} BR_F) /_{t} BR_F) /_{\emptyset} BR_F) /_{\hat{t}} BR_F); \] where \( b_j = T \) and, for each \( j' \in [1, n+2] \) such that \( j' \neq j, b_{j'} = F \). From the definition of thread extraction, the definition of Boolean register services, and axiom TSU4, it follows that \[ ((((\ldots (|P| /_{s:1} BR_F) \ldots /_{s:n+2} BR_F) /_{t} BR_F) /_{\emptyset} BR_F) /_{\hat{t}} BR_F) /_{\hat{t}} BR_F = |P_1'^{br}|_1. \] This leaves us to show that \( <X_1|E> = |P_1'^{br}|_1 \). Using the definition of thread extraction, the definition of Boolean register services, and axioms P0, P2, TSU1, TSU2, TSU4, TSU5 and TSU7, we easily prove the following: \[ |x_{i,j}^{br} = |P_i'^{br}|_j \quad \text{if} \quad 1 \leq i \leq n \land 1 \leq j \leq n+1 \land i \neq j \quad (1) \] \[ |x_{i,j}^{br} = |P_i'^{br}|_j \quad \text{if} \quad i = n+1 \land 1 \leq j \leq n+1 \land i \neq j \quad (2) \] \[ |x_{i,j}^{br} = |P_i'^{br}|_i(l(i)) \leq a_i \geq |P_{i+1}'^{br}|_{r(i)} \quad \text{if} \quad 1 \leq i \leq n \quad (3) \] \[ |x_{i,j}^{br} = S \quad \text{if} \quad i = n+1 \quad (4) \] \[ |x_{i,j}^{br} = D \quad \text{if} \quad 1 \leq i \leq n+1 \land j = n+2 \quad (5) \] \[\square\] Springer From Properties 1 and 2, it follows that $$|P'_i|_j^{br} = |P'_j|_j^{br}$$ if $1 \leq i \leq n + 1 \land 1 \leq j \leq n + 1 \land i \neq j$. From this and Property 3, it follows that $$|P'_i|_i^{br} = |P'_{l(i)}|_{l(i)}^{br} \leq a_i \geq |P'_{r(i)}|_{r(i)}^{br}$$ if $1 \leq i \leq n$. From this and Properties 4 and 5, it follows that $|P'_1|_1^{br}$ is a solution of $E$ for $X_1$. Because linear recursive specifications have unique solutions, it follows that $\langle X_1 | E \rangle = |P'_1|_1^{br}$. Theorem 1 goes through in the case where $E = \{X_1 = D\}$: a witnessing $P$ is $(f.g)^\omega$. It follows from the proof of Proposition 1 given in [23] that, for each regular thread $p$, either $p$ is the solution of $\{X_1 = D\}$ for $X_1$ or there exists a finite linear recursive specification $E$ of the form considered in Theorem 1 such that $p$ is the solution of $E$ for $X_1$. Hence, we have the following corollary of Proposition 1 and Theorem 1: **Corollary 1** For each regular thread $p$, there exists a closed PGA term $P$ in which jump instructions do not occur such that $p$ is the thread denoted by $$(((\ldots (|P| /_{s:1} BR_F) \ldots /_{s:n+2} BR_F) /_{l} BR_F) /_{r} BR_F) /_{e} BR_F) /_{l} BR_F.$$ In other words, each regular thread can be produced by an instruction sequence without jump instructions if use can be made of Boolean register services. The construction of such instructions sequences given in the proof of Theorem 1 is weakly reminiscent of the construction of structured programs from flow charts found in [14]. However, our construction is more extreme: it yields programs that contain neither unstructured jumps nor a rendering of the conditional and loop constructs used in structured programming. ### 7 Program Algebra with Labels and Goto’s In this section, we introduce PGA$_g$, a variant of PGA obtained by leaving out jump instructions and adding labels and goto instructions. In PGA$_g$, like in PGA, it is assumed that a fixed but arbitrary set $\mathcal{A}$ of basic instructions has been given. PGA$_g$ has the following **primitive instructions**: - for each $a \in \mathcal{A}$, a *plain basic instruction* $a$; - for each $a \in \mathcal{A}$, a *positive test instruction* $+a$; - for each $a \in \mathcal{A}$, a *negative test instruction* $-a$; - for each $l \in \mathbb{N}$, a *label instruction* $[l]$. – for each \( l \in \mathbb{N} \), a goto instruction \(#[l]\); – a termination instruction !. We write \( J_g \) for the set of all primitive instructions of \( \text{PGA}_g \). The plain basic instructions, the positive test instructions, the negative test instructions, and the termination instruction are as in PGA. Upon execution, a label instruction \([l]\) is simply skipped. If there is no next instruction to be executed, deadlock occurs. The effect of a goto instruction \(#[l]\) is that execution proceeds with the occurrence of the label instruction \([l]\) next following if it exists. If there is no occurrence of the label instruction \([l]\), deadlock occurs. \( \text{PGA}_g \) has a constant \( u \) for each \( u \in J_g \). The operators of \( \text{PGA}_g \) are the same as the operators as PGA. Likewise, the axioms of \( \text{PGA}_g \) are the same as the axioms as PGA. Just like in the case of PGA, the behaviours of the instruction sequences denoted by closed \( \text{PGA}_g \) terms are considered threads. The behaviours of the instruction sequences denoted by closed \( \text{PGA}_g \) terms are indirectly given by the behaviour preserving function \( \text{pgag2pga} \) from the set of all closed \( \text{PGA}_g \) terms to the set of all closed PGA terms defined by \[ \text{pgag2pga}(u_1; \ldots; u_n) = \text{pgag2pga}(u_1; \ldots; u_n; (#[1]^o), \] \[ \text{pgag2pga}(u_1; \ldots; u_n; (u_{n+1}; \ldots; u_m)^o) = \phi_1(u_1); \ldots; \phi_n(u_n); (\phi_{n+1}(u_{n+1}); \ldots; \phi_m(u_m))^o, \] where the auxiliary functions \( \phi_j : J_g \rightarrow I \) are defined as follows (\( 1 \leq j \leq m \)): \[ \phi_j([l]) = #1, \] \[ \phi_j([#l]) = #tg_{j}(l), \] \[ \phi_j(u) = u \quad \text{if} \ u \text{ is not a label or goto instruction}, \] where \[ tg_{j}(l) = i \quad \text{if the leftmost occurrence of} \ [l] \ \text{in} \ u_j; \ldots; u_m; u_{n+1}; \ldots; u_m \text{ is the} \ i-th \text{instruction}; \] \[ tg_{j}(l) = 0 \quad \text{if there are no occurrences of} \ [l] \ \text{in} \ u_j; \ldots; u_m; u_{n+1}; \ldots; u_m. \] Let \( P \) be a closed \( \text{PGA}_g \) term. Then the behaviour of \( P \) is \( |\text{pgag2pga}(P)| \). The approach to semantics followed here is introduced under the name projection semantics in [3]. The function \( \text{pgag2pga} \) is called a projection. 8 A Bounded Number of Labels In this section, we show that a bound to the number of labels restricts the expressiveness of \( \text{PGA}_g \). We will refer to \( \text{PGA}_g \) terms that do not contain label instructions \([l]\) with \( l > k \) as \( \text{PGA}_g^k \) terms. Moreover, we will write \( J_g^k \) for the set \( J_g \setminus \{[l] | l > k\} \). We define an alternative projection for closed PGA\(^k\) terms, which takes into account that these terms contain only label instructions \([l]\) with \(1 \leq l \leq k\). The alternative projection \(\text{pgag2pga}^k\) from the set of all closed PGA\(^k\) terms to the set of all closed PGA terms is defined by \[ \text{pgag2pga}^k(u_1; \ldots; u_n) = \text{pgag2pga}^k(u_1; \ldots; u_n; (#[1])^o), \] \[ \text{pgag2pga}^k(u_1; \ldots; u_n; (u_{n+1}; \ldots; u_m)^o) \] \[ = \psi(u_1, u_2); \ldots; \psi(u_n, u_{n+1}); (\psi(u_{n+1}, u_{n+2}); \ldots; \] \[ ; \psi(u_{m-1}, u_m); \psi(u_m, u_{m+1}))^o, \] where the auxiliary function \(\psi: \mathcal{J}_g^k \times \mathcal{J}_g^k \rightarrow \mathcal{J}\) is defined as follows: \[ \psi(u', u'') = \psi'(u') \# k + 2 \# k + 2 \psi''(u''), \] where the auxiliary functions \(\psi', \psi'': \mathcal{J}_g^k \rightarrow \mathcal{J}\) are defined as follows: \[ \psi'([l]) = #1, \] \[ \psi'([#l]) = #l + 2 \quad \text{if } l \leq k, \] \[ \psi'([#l]) = #0 \quad \text{if } l > k, \] \[ \psi'(u) = u \quad \text{if } u \text{ is not a label or goto instruction}, \] \[ \psi''([l]) = (#k + 3)^{l-1} \# k - l + 1 \# (k + 3)^{k-l}, \] \[ \psi''(u) = (#k + 3)^k \quad \text{if } u \text{ is not a label instruction}. \] In order to clarify the alternative projection, we explain how the intended effect of a goto instruction is obtained. If \(u_j\) is \([l]\), then \(\psi'(u_j)\) is \(#l + 2\). The effect of \(#l + 2\) is a jump to the \(l\)-th instruction in the defining thread extraction, and the easy to prove fact that \([P; #0] = |P|\). **Proposition 2** For each PGA context \(C[\cdot]:\) \[ |C[#n + 1; u_1; \ldots; u_n; #m]| = |C[#m + n + 1; u_1; \ldots; u_n; #m]|. \] **Proof** Contexts of the forms \(C[^o; Q\) and \(P; C[^o; Q\) do not need to be considered because of axiom PGA3. For eight of the remaining twelve forms, the equation to be proved follows immediately from the equations to be proved for the other forms, to wit \(_Q\); \(P\); \(_Q\); \(P\); \(_o^o\) and \(P\); \(_Q; P\); \(_o^o\); the axioms of PGA, the defining equations for thread extraction, and the easy to prove fact that \([P; #0] = |P|\). In the case of the form \( \_ : Q \), the equation concerned is easily proved by induction on \( n \). In the case of the form \( P : \_ : Q \), only \( P \) in which the repetition operator does not occur need to be considered because of axiom PGA3. For such \( P \), the equation concerned is easily proved by induction on the length of \( P \), using the equation proved for the form \( \_ : Q \). In the case of the form \( P : \_ : \omega \), only \( P \) in which the repetition operator does not occur need to be considered because of axiom PGA3. For such \( P \), the equations for the approximating forms \( P : \_ : \omega^k \) are easily proved by induction on \( k \), using the equation proved for the form \( P : \_ : Q \). From these equations, the equation for the form \( P : \_ : \omega \) follows using AIP. In the case of the form \( P : (Q : \_ : \omega) \), the equation concerned is proved like in the case of the form \( P : \_ : \omega \). \[ \square \] The following theorem states rigorously that the projections \( \text{pgag2pga} \) and \( \text{pgag2pga}^k \) give rise to instruction sequences with the same behaviour. **Theorem 2** For each closed PGA\(_g^k\) term \( P \), \(|\text{pgag2pga}(P)| = |\text{pgag2pga}^k(P)|\). **Proof** Because \( \text{pgag2pga}(u_1; \ldots ; u_n) = \text{pgag2pga}(u_1; \ldots ; u_n; (\#[1])^{\omega}) \) and \( \text{pgag2pga}^k(u_1; \ldots ; u_n) = \text{pgag2pga}^k(u_1; \ldots ; u_n; (\#[1])^{\omega}) \), we only consider the case where the repetition operator occurs in \( P \). We make use of an auxiliary function \(|\_ , \_|\). This function determines, for each natural number and closed PGA term in which the repetition operator occurs, a closed term of BTA with guarded recursion. The function \(|\_ , \_|\) is defined as follows: \[ |i , u_1; \ldots ; u_n ; \omega| = |u_{i+1}; \ldots ; u_m ; \omega| \quad \text{if} \quad 1 \leq i \leq m, \] \[ |i , u_1; \ldots ; u_n ; \omega| = D \quad \text{if} \quad m < i \leq m. \] Let \( P = u_1; \ldots ; u_n; (u_{n+1}; \ldots ; u_m)^{\omega} \) be a closed PGA\(_g^k\) term, let \( P' = \text{pgag2pga}(P) \), and let \( P'' = \text{pgag2pga}^k(P) \). Moreover, let \( \rho : \mathbb{N} \rightarrow \mathbb{N} \) be such that \( f(i) = (k + 3) \cdot (i - 1) + 1 \). Then it follows easily from the definitions of \(|\_ , \_|\), \(|\_|\), \( \text{pgag2pga} \) and \( \text{pgag2pga}^k \), the axioms of PGA and Proposition 2 that for \( 1 \leq i \leq m \): \[ |i , P'| = a \circ |i + 1, P'| \quad \text{if} \quad u_i = a, \] \[ |i , P'| = |i + 1, P'| \leq a \geq |i + 2, P'| \quad \text{if} \quad u_i = +a, \] \[ |i , P'| = |i + 2, P'| \leq a \geq |i + 1, P'| \quad \text{if} \quad u_i = -a, \] \[ |i , P'| = |i + 1, P'| \quad \text{if} \quad u_i = [l], \] \[ |i , P'| = |i + n, P'| \quad \text{if} \quad u_i = \#[l] \land tgt_i(l) = n, \] \[ |i , P'| = S \quad \text{if} \quad u_i = !. \] and \[ |\rho(i), P''| = a \circ |\rho(i + 1), P''| \quad \text{if } u_i = a, \] \[ |\rho(i), P''| = |\rho(i + 1), P''| \preceq a \succeq |\rho(i + 2), P''| \quad \text{if } u_i = +a, \] \[ |\rho(i), P''| = |\rho(i + 2), P''| \preceq a \succeq |\rho(i + 1), P''| \quad \text{if } u_i = -a, \] \[ |\rho(i), P''| = |\rho(i + 1), P''| \quad \text{if } u_i = [l], \] \[ |\rho(i), P''| = |\rho(i + n), P''| \quad \text{if } u_i = \#[l] \land tgt_i(l) = n, \] \[ |\rho(i), P''| = S \quad \text{if } u_i = ! \] (where \( tgt_i \) is as in the definition of \( pgag2pga \)). Because \( |pgag2pga(P)| = |1, P'| \) and \( |pgag2pga_k(P)| = |\rho(1), P''| \), this means that \( |pgag2pga(P)| \) and \( |pgag2pga_k(P)| \) are solutions of the same guarded recursive specification. Because guarded recursive specifications have unique solutions, it follows that \( |pgag2pga(P)| = |pgag2pga_k(P)| \). The projection \( pgag2pga_k(P) \) yields only closed PGA terms that do not contain jump instructions \( \#l \) with \( l > k + 3 \). Hence, we have the following corollary of Theorem 2: **Corollary 2** For each closed \( \text{PGA}_k \) term \( P \), there exists a closed PGA term \( P' \) not containing jump instructions \( \#l \) with \( l > k + 3 \) such that \( |pgag2pga(P)| = |P'| \). It follows from Corollary 2 that, if a regular thread cannot be denoted by a closed PGA term that does not contain jump instructions \( \#l \) with \( l > k + 3 \), it cannot be denoted by a closed \( \text{PGA}_k \) term. Moreover, it is known that, for each \( k \in \mathbb{N} \), there exists a closed PGA term for which there does not exist a closed PGA term not containing jump instructions \( \#l \) with \( l > k + 3 \) that denotes the same thread (see e.g. [23], Proposition 3). Hence, we also have the following corollary: **Corollary 3** For each \( k \in \mathbb{N} \), there exists a closed PGA term \( P \) for which there does not exist a closed \( \text{PGA}_k \) term \( P' \) such that \( |P| = |pgag2pga(P')| \). ### 9 Conclusions Program algebra is a setting suited for investigating single-pass instruction sequences. In this setting, we have shown that each behaviour that can be produced by a single-pass instruction sequence under execution can be produced by a single-pass instruction sequence without jump instructions if use can be made of Boolean register services. We consider this an interesting expressiveness result. An important variant of program algebra is obtained by leaving out jump instructions and adding labels and goto instructions. We have also shown that a bound to the number of labels restricts the expressiveness of this variant. Earlier expressiveness results on single-pass instruction sequences as considered in program algebra are collected in [23]. Program algebra does not provide a notation for programs that is intended for actual programming. However, to demonstrate that single-pass instruction sequences as considered in program algebra are suited for explaining programs in the form of assembly programs as well as programs in the form of structured programs, a hierarchy of program notations rooted in program algebra is introduced in [3]. One program notation belonging to this hierarchy, called PGLD\textsubscript{g}, is a simple program notation, close to existing assembly languages, with labels and goto instructions. We remark that a projection from the set of all PGLD\textsubscript{g} programs to the set of all closed PGA\textsubscript{g} terms can easily be devised. The idea that programs are in essence single-pass instruction sequences underlies the choice for the name program algebra. The name seems to imply that program algebra is suited for investigating programs in general. We do not intend to claim this generality, which in any case does not matter when investigating single-pass instruction sequences. The name program algebra might as well be used as a collective name for algebras that are based on any viewpoint concerning programs. To our knowledge, it is not common to use the name as such. Most closely related to our work on instruction sequences is work on Kleene algebras (see e.g. [15–18, 24]), but programs are considered at a higher level in that work. For instance, programming features like jump instructions have never been studied. In most work on computer architecture (see e.g. [1, 19–22]), instruction sequences are under discussion. However, the notion of instruction sequence is not subjected to systematic and precise analysis in the work concerned. Acknowledgements This research was partly carried out in the framework of the Jacquard-project Symbiosis, which is funded by the Netherlands Organisation for Scientific Research (NWO). We thank Alban Ponse, colleague at the University of Amsterdam, and Stephan Schroevers, graduate student at the University of Amsterdam, for carefully reading a preliminary version of this paper and pointing out some flaws in it. Moreover, we thank an anonymous referee for suggesting improvements of the presentation of the paper. Open Access This article is distributed under the terms of the Creative Commons Attribution Noncommercial License which permits any noncommercial use, distribution, and reproduction in any medium, provided the original author(s) and source are credited. References
{"Source-Url": "https://pure.uva.nl/ws/files/1412630/107748_360893.pdf", "len_cl100k_base": 11390, "olmocr-version": "0.1.53", "pdf-total-pages": 17, "total-fallback-pages": 0, "total-input-tokens": 61364, "total-output-tokens": 13920, "length": "2e13", "weborganizer": {"__label__adult": 0.0004162788391113281, "__label__art_design": 0.00048661231994628906, "__label__crime_law": 0.0004832744598388672, "__label__education_jobs": 0.0009512901306152344, "__label__entertainment": 0.00010645389556884766, "__label__fashion_beauty": 0.00021064281463623047, "__label__finance_business": 0.00032711029052734375, "__label__food_dining": 0.0005450248718261719, "__label__games": 0.0008640289306640625, "__label__hardware": 0.0030364990234375, "__label__health": 0.0009407997131347656, "__label__history": 0.0003895759582519531, "__label__home_hobbies": 0.0001852512359619141, "__label__industrial": 0.0008692741394042969, "__label__literature": 0.00038504600524902344, "__label__politics": 0.0004596710205078125, "__label__religion": 0.0006890296936035156, "__label__science_tech": 0.1571044921875, "__label__social_life": 8.356571197509766e-05, "__label__software": 0.00659942626953125, "__label__software_dev": 0.8232421875, "__label__sports_fitness": 0.0004377365112304687, "__label__transportation": 0.0009984970092773438, "__label__travel": 0.00024247169494628904}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 43484, 0.02196]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 43484, 0.70726]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 43484, 0.86876]], "google_gemma-3-12b-it_contains_pii": [[0, 1381, false], [1381, 2889, null], [2889, 6403, null], [6403, 9761, null], [9761, 11921, null], [11921, 14079, null], [14079, 17008, null], [17008, 19457, null], [19457, 22609, null], [22609, 24680, null], [24680, 27062, null], [27062, 29792, null], [29792, 31982, null], [31982, 34908, null], [34908, 37705, null], [37705, 41261, null], [41261, 43484, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1381, true], [1381, 2889, null], [2889, 6403, null], [6403, 9761, null], [9761, 11921, null], [11921, 14079, null], [14079, 17008, null], [17008, 19457, null], [19457, 22609, null], [22609, 24680, null], [24680, 27062, null], [27062, 29792, null], [29792, 31982, null], [31982, 34908, null], [34908, 37705, null], [37705, 41261, null], [41261, 43484, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 43484, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 43484, null]], "pdf_page_numbers": [[0, 1381, 1], [1381, 2889, 2], [2889, 6403, 3], [6403, 9761, 4], [9761, 11921, 5], [11921, 14079, 6], [14079, 17008, 7], [17008, 19457, 8], [19457, 22609, 9], [22609, 24680, 10], [24680, 27062, 11], [27062, 29792, 12], [29792, 31982, 13], [31982, 34908, 14], [34908, 37705, 15], [37705, 41261, 16], [41261, 43484, 17]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 43484, 0.0]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
530418531ae42cb4d824d60a6d24d6b0b0febad8
[REMOVED]
{"Source-Url": "https://www.research.ed.ac.uk/portal/files/12289134/lin_cps.pdf", "len_cl100k_base": 13262, "olmocr-version": "0.1.50", "pdf-total-pages": 16, "total-fallback-pages": 0, "total-input-tokens": 71331, "total-output-tokens": 15492, "length": "2e13", "weborganizer": {"__label__adult": 0.0005497932434082031, "__label__art_design": 0.0006666183471679688, "__label__crime_law": 0.0005364418029785156, "__label__education_jobs": 0.0023632049560546875, "__label__entertainment": 0.0001854896545410156, "__label__fashion_beauty": 0.00030231475830078125, "__label__finance_business": 0.0006537437438964844, "__label__food_dining": 0.0008397102355957031, "__label__games": 0.0012569427490234375, "__label__hardware": 0.0011882781982421875, "__label__health": 0.0015745162963867188, "__label__history": 0.0006570816040039062, "__label__home_hobbies": 0.00019741058349609375, "__label__industrial": 0.0009412765502929688, "__label__literature": 0.0017032623291015625, "__label__politics": 0.0006113052368164062, "__label__religion": 0.0012273788452148438, "__label__science_tech": 0.27294921875, "__label__social_life": 0.0002149343490600586, "__label__software": 0.0069122314453125, "__label__software_dev": 0.70263671875, "__label__sports_fitness": 0.0004363059997558594, "__label__transportation": 0.0013141632080078125, "__label__travel": 0.0002918243408203125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 45965, 0.01426]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 45965, 0.27099]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 45965, 0.78907]], "google_gemma-3-12b-it_contains_pii": [[0, 1493, false], [1493, 3993, null], [3993, 7402, null], [7402, 8412, null], [8412, 12073, null], [12073, 15108, null], [15108, 18113, null], [18113, 20309, null], [20309, 22026, null], [22026, 25584, null], [25584, 29066, null], [29066, 32448, null], [32448, 35705, null], [35705, 39303, null], [39303, 42760, null], [42760, 45965, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1493, true], [1493, 3993, null], [3993, 7402, null], [7402, 8412, null], [8412, 12073, null], [12073, 15108, null], [15108, 18113, null], [18113, 20309, null], [20309, 22026, null], [22026, 25584, null], [25584, 29066, null], [29066, 32448, null], [32448, 35705, null], [35705, 39303, null], [39303, 42760, null], [42760, 45965, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 45965, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 45965, null]], "pdf_page_numbers": [[0, 1493, 1], [1493, 3993, 2], [3993, 7402, 3], [7402, 8412, 4], [8412, 12073, 5], [12073, 15108, 6], [15108, 18113, 7], [18113, 20309, 8], [20309, 22026, 9], [22026, 25584, 10], [25584, 29066, 11], [29066, 32448, 12], [32448, 35705, 13], [35705, 39303, 14], [39303, 42760, 15], [42760, 45965, 16]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 45965, 0.0]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
b78deadd5dc19f50f0d2ec75bebb7328bd3ac2c3
The Dark Side of Event Sourcing: Managing Data Conversion Michiel Overeem¹, Marten Spoor¹, and Slinger Jansen² ¹{m.overeem, m.spoor}@afas.nl, Department Architecture and Innovation, AFAS Software, The Netherlands ²slinger.jansen@uu.nl, Department of Information and Computing Sciences, Utrecht University, The Netherlands Abstract—Evolving software systems includes data schema changes, and because of those schema changes data has to be converted. Converting data between two different schemas while continuing the operation of the system is a challenge when that system is expected to be available always. Data conversion in event sourced systems introduces new challenges, because of the relative novelty of the event sourcing architectural pattern, because of the lack of standardized tools for data conversion, and because of the large amount of data that is stored in typical event stores. This paper addresses the challenge of schema evolution and the resulting data conversion for event sourced systems. First of all a set of event store upgrade operations is proposed that can be used to convert data between two versions of a data schema. Second, a set of techniques and strategies that execute the data conversion while continuing the operation of the system is discussed. The final contribution is an event store upgrade framework that identifies which techniques and strategies can be combined to execute the event store upgrade operations while continuing operation of the system. Two utilizations of the framework are given, the first being as decision support in upfront design of an upgrade system for event sourced systems. The framework can also be utilized as the description of an automated upgrade system that can be used for continuous deployment. The event store upgrade framework is evaluated in interviews with three renowned experts in the domain and has been found to be a comprehensive overview that can be utilized in the design and implementation of an upgrade system. The automated upgrade system has been implemented partially and applied in experiments. Index Terms—Event Sourcing, CQRS, Event Driven Architecture, Schema Evolution, Software Evolution, Schema Versioning, Deployment Strategy, Data Transformation, Data Conversion I. INTRODUCTION Applications that do not evolve in response to changing requirements or changing technology become less useful, as Lehman [1] in his law of continuing change stated many years ago. Neamtiu and Dumitras [2] shows that this is a reality for modern cloud systems as many of them update more than once a week. Chen [3] describes how they applied continuous delivery on multiple projects to achieve shorter time to market, and an improved productivity and efficiency. Several technical challenges including seamless upgrades are identified by Claps et al. [4]. The fast pace of evolution and deployment of cloud systems conflicts with the requirement to be available always and support uninterrupted work. For modern cloud systems to support the fast pace of evolution, upgrade strategies that are fast, efficient, and seamless have to be designed and implemented. One of the architectural patterns that in recent years emerged in the development of cloud systems is Command Query Responsibility Segregation (CQRS). The pattern was introduced by Young [5] and Dahan [6], and the goal of the pattern is to handle actions that change data (those are called commands) in different parts in the system than requests that ask for data (called queries). By separating the command-side (the part that validates and accepts changes) from the query-side (the part that answers queries), the system can optimize the two parts for their very different tasks. Young [7] describes CQRS as a stepping stone for event sourcing. Event sourcing is a data storage model that does not store the current (or last) state, but all changes leading up to the current state. Fowler [8] explains event sourcing by comparing it to an audit trail: every data change is stored without removing or changing earlier events. The events stored in an event store are stored as schema-less data, because the different events often do not share properties. A store with an explicit schema would make it more difficult to append events in the store to a single stream. Data in schema-less stores is not without schema, but the schema is implicit: the application assumes a certain schema. This makes the problem of schema evolution and data conversion more difficult as observed by Scherzinger et al. [9]. Schema-less data is more difficult to evolve as the store is unaware of structure and thus cannot offer tools to transform the data into a new structure. Relational data stores that have explicit knowledge of the structure of the data can use the standardized data definition language (DDL) to upgrade the schema and convert the data. Another problem in the evolution of event sourced systems is the amount of data that is stored, not only the current state, but also every change leading up to that state. This huge amount of data makes the problem of performing a seamless upgrade even more important: upgrades may need more time, but they are required to be imperceptible. The frequency of schema changes is researched by Qiu et al. [10]. Although the storage model is different and the architectural pattern is relatively new there is no indication that (implicit) schema changes in event sourcing are less of a challenge. Recovery of the implicit schema does not solve the problem for event stores, it only helps in finding the right operations to transform to a new schema. This paper answers the question “How can an event sourced system be upgraded efficiently when the (implicit) event schema changes?” This question is answered by defining event store upgrade operations that can be used to express the data conversion executed by the upgrade of an event store in Section IV. Existing techniques that are capable of execution these operations to convert the events are discussed in Section V. The efficiency of these techniques is judged on the basis of four quality attributes: functional suitability, maintainability, performance efficiency, and reliability. In Section VI the deployment strategies, categorized by application and data upgrade strategies are discussed that lead to an upgrade system with zero downtime. The final framework that describes how to design and implement either an ad-hoc upgrade strategy, or a fully automated upgrade system is proposed in Section VII. The final framework is evaluated with three Dutch experts in the field of event sourcing, who have six or more years of experience with building and maintaining event sourced systems, and these results can be found in Section VIII. Section IX summarizes the contributions and states future work. II. COMMAND QUERY RESPONSIBILITY SEGREGATION The foundations of CQRS were laid by Meyer [11] in the Command-Query Separation (CQS) principle. He defined a command as “serving to modify objects” and a query is “to return information about objects”, or informally worded “asking a question should not change the answer”. Figure 1 shows the CQRS pattern: commands are accepted by the command-side and produce events which are processed by the query-side. The query-side projects these events into a form that is suitable for querying and presenting. The command-side and the query-side both have their own data store: the first store is used to maintain data that is used in validating requested changes, and the second store is used to retrieve data for displaying or reporting. Figure 1. The architectural pattern CQRS. The command-side communicates with the query-side through asynchronously sending events. These events are used by the query-side to build a view of the state that can be used to query and present data. By doing this asynchronously the query-side does not influence the performance of the command-side. However, this does lead to eventual consistency. This is a weaker form of consistency that Vogels [12] defines as “when no updates are made to the object, the object will eventually have the last updated value”. The system guarantees that the query-side eventually will reflect the events produced in the command-side. However, there are no guarantees on how fast this will be done. A system with a large delay is unfeasible, because in that case queries will often return data that does not reflect the latest changes send to the command-side. There are difficulties introduced by eventual consistency, such as returning items to a client that in fact are already deleted through commands send to the command-side. The patterns to overcome this difficulty and others are out of scope for the current paper. The asynchronous sending of events between the command-side and query-side results in a weak coupling. The resulting freedom and flexibility in designing the system leads to availability, scalability, and performance among other advantages. The store used in the command-side is often an event store, because it is natural to store the events that are produced by the command-side. This proposed data storage model has a number of benefits that make it specifically useful as a store for the command-side of a CQRS system. First of all, the command-side is only used for accepting changes and never for queries, and the performance of the store is not thus not hampered by concurring reads and writes. Second, the store contains every change ever accepted into the system, making it easy to inspect when and by whom a change was done. A third benefit is the possibility to rebuild the current state (for instance the query-store) in the system by replaying the events. The replaying of events also enables easy debugging. The fourth benefit is the possibility to analyze the events for patterns in usage. This information is impossible to extract from a store that only persists the last state of the data. In the query-side a diverse range of stores can be used, such as relational, graph, or NoSql databases. The main goal of this store is to support the easy and fast retrieval of data, in whatever form the application requires. The loosely coupled nature of CQRS combined the benefits of the event sourcing approach makes it a fitting architectural pattern for cloud systems. Event sourcing itself is not tied exclusively to CQRS, the coupling based on events is similar to that in more general event-driven architectures, as described by Michelson [13]. The events in the event store are processed by the system to build the query-side or execute complex processes. The CQRS pattern and its sub-patterns are described in more detail by Kabbedijk et al. [14]. CQRS from a practitioners viewpoint is studied by Korkmaz [15] in order to gain better understanding of the benefits and challenges. Maddodi et al. [16] studies a CQRS system in the context of continuous performance testing. III. RELATED WORK The work related to this paper is divided in data conversion, specifically schema-less data conversion, and application deployment. Data Conversion - Two approaches to data conversion are defined by Jensen et al. [17]: schema versioning and schema evolution. Schema versioning is accommodated when a database system allows the accessing of all data, both retrospectively and prospectively, through user definable version interfaces. Schema evolution is accommodated when a database system facilitates the modification of the database schema without loss of existing data. Section V will show that both schema versioning and schema evolution are suitable techniques for event store upgrades. The event store, used as a storage for the command-side of the CQRS system is schema-less, and in that respect similar to a NoSQL database as described by Scherzinger et al. [18] and Saur et al. [19]. Although the store is schema-less the data itself does have a schema, but it is implicit: the application, as defined by Fowler [20], assumes a certain schema without this schema being actually present in the store. Within relational stores the standardized DDL can be used to upgrade the schema and convert the data, a possibility missing in NoSQL stores. Scherzinger et al. [18] approach the implicit schema and lack of a DDL for NoSQL by proposing a new language that can be used to convert the data in a NoSQL store. Although this fills a gap in the standardization of NoSQL stores, without support in the stores the problem of data conversion in NoSQL stores remains. To aid the evolution of the data stored Saur et al. [19] describe an extension to one specific NoSQL database. This extension implements an approach that Sadalage and Fowler [21] describe as incremental migration: migrating data when it is accessed. While the research of Saur et al. [19] is similar to the research described in this paper, the solution is tied to a specific technology and not applicable in systems that use a similar data model, but with a different database technology. Both Cleve et al. [22] and Qiu et al. [10] quantity schema changes occurring in the evolution of applications. Their work is aimed at relational models, and it is not clear how these results translate to event stores. Future studies need to be conducted before these results can be applied to event stores. The impact of schema changes on application source code is studied by Meurice et al. [23] and Maule et al. [24]. However, the direction of the impact is different with schema-less stores and implicit schemas. The change originates in the application holding the implicit schema and impacts the data in the schema-less store. **Application Deployment** - Blue-green deployment is an upgrade strategy that utilizes two slots to which different versions of an application can be deployed. One of the slots is active, while the other one is inactive. Upgrading is always done in the inactive slot, and the user is not hindered while upgrading. This strategy is followed by different authors. Callaghan [25] describes a tool written by Facebook to perform online (and zero downtime) upgrades on MySql in four phases: (1) copy the original database, (2) upgrade the copy to the new schema, (3) replay any changes happened on the original database during copy/build phase, and (4) finally switch active databases. This approach is very similar to the pattern described by Keller [26] who applied it in the migration of a legacy system. With IMAGO Dumitras and Narasimhan [27, 28] use blue-green deployment for their parallel universe: they reduce upgrade failures by isolating IMAGO the production system from the upgrade operations, and completing the upgrade as an atomic operation. QuantumDB, a tool created by de Jong and van Deursen [29], applies the expand-contract strategy (explained in Section VI) with blue-green deployment. Hick and Hainaut [30] and Domínguez et al. [31] developed and used MeDEA: a tool that focuses on traceability of artifacts. MeDEA makes it possible to translate changes from a conceptual model of a relational database to schema changes in the actual database. Curino et al. [32, 33] worked on PRISM and PRISM++, a database administrator tool that calculates the SQL statements needed to upgrade a schema. While calculating those statements it can check for information preservation, backwards compatibility, and redundancy. These approaches solve the problem of analyzing schema changes and generating data conversion statements, something that is not part of the solution presented in this paper. The main differences between event store data conversion and the existing research are the usage of an implicit schema and the amount of data in an event store. Furthermore, this paper does not propose a new tool which is specific to a certain technology or database type, but rather proposes strategies that can be applied regardless of specific technologies. In this paper the techniques and strategies from existing work are extracted and applied to event sourcing. This results in an event store upgrade framework that can be used in the design and implementation of an upgrade system. **IV. Event Store Upgrade Operations** An event store contains different event streams and events. An example is given: the event store of a WebShop application, shown in Figure 2. The two streams contain many events, but only two events per stream are shown as an example. ![Figure 2. An example event store with different stream and event types.](image) The Figure shows two streams part of the store: one for customer #1, and the stream of shopping cart #13. In the application these streams belong to two separate and independent event sources. These event sources produce these events as the result of certain actions. For example, the addition of a product to a cart by a user should result in the added to cart event. The different event types such as added to cart, removed from cart, and customer created contain different attributes. The added to cart event contains the article (an identifier) and the amount (an integer) among others. Event listeners receive these events and create a view of the data that can be queried. This knowledge of event types and their properties is the implicit schema that is part of the application code. An event store has a structure of three levels: **The event store** - A collection of streams, and every stream is of a certain type and uniquely identified by its identifier. **The event stream** - Every stream is a collection of events that originated from a single source and is ordered by the event creation date. In an event sourced system there should be a single source of all the events in a single stream. The boundary of the stream is very important: a source has a one-to-one relation with its stream. It is this boundary that makes the event sourced systems scalable: every event source is the owner of a stream and has no relation with other streams. An event source and its event stream can be moved between machines in a cluster without difficulty. The different event streams could also be stored in different event stores. This is possible because the event source is not depended on other sources. The events - An event consists of a type and content in the form of key-value pairs. The type is used to route events to the projectors that are interested in specific types of events. The event store upgrade operations are used to express how an event store version 1.0 can be transformed into version 2.0. These operations have the same purpose as the NoSQL schema evolution language proposed by Scherzinger et al. [18]: they give a common language to express the conversion of an event store. The full list of operations is shown in Table I. Two categorizations are applied: structure level and complexity. The operations presented are agnostic of the business domain of the application and its functionality. The process of expressing the transformation in these operations should be done manually, because it should reflect the intent of the upgrade. Schema changes can be expressed by different sets of operations and these different sets have their own effects. An example is given: the WebShop application is upgraded to a new version, and part of the upgrade is a change in storing addresses. Figure 2 shows the old event definition: a single address attribute for both street and number. This data conversion can be done in multiple ways and two possibilities are given: 1) Every event could be updated with the *split attribute* operation, and this would split every address attribute in both a street and number attribute. This increases the maintainability of the system because all event handling code can assume the presence of the two new attributes. 2) Every customer stream is updated with an *add event* operation that represents the conversion. In this transformation the old information is preserved (to repair mistakes in the split operation for instance). But now the application should be able to deal with both old and new addresses, because events can contain either of the two forms. Although both options transform the event store differently the two resulting versions of the WebShop application are functionally equivalent to the users of the system. However, the inner workings differ significantly. In the first solution the knowledge of the initial address property together with the values is removed. The conversion itself has changed the event <table> <thead> <tr> <th>Level</th> <th>Complexity</th> <th>Operation</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td>Event</td> <td>Basic</td> <td>Add attribute</td> <td>An attribute is added to an event.</td> </tr> <tr> <td></td> <td></td> <td>Delete attribute</td> <td>An attribute is deleted from an event.</td> </tr> <tr> <td></td> <td>Complex</td> <td>Merge attributes</td> <td>Two attributes are combined to a single attribute.</td> </tr> <tr> <td></td> <td></td> <td>Split attribute</td> <td>One attribute is split into two attributes.</td> </tr> <tr> <td>Stream</td> <td>Basic</td> <td>Add event</td> <td>A new event is added to the stream.</td> </tr> <tr> <td></td> <td></td> <td>Delete event</td> <td>An event is deleted from the stream.</td> </tr> <tr> <td></td> <td>Complex</td> <td>Merge events</td> <td>Multiple events are combined to one</td> </tr> <tr> <td></td> <td></td> <td>Split event</td> <td>One event is split into two events.</td> </tr> <tr> <td></td> <td></td> <td>Move attribute</td> <td>One attribute is moved from one event type to another.</td> </tr> <tr> <td>Store</td> <td>Basic</td> <td>Add stream</td> <td>A new stream is added to the store.</td> </tr> <tr> <td></td> <td></td> <td>Delete stream</td> <td>A stream is deleted from the stream.</td> </tr> <tr> <td></td> <td>Complex</td> <td>Merge streams</td> <td>Multiple streams are combined to one stream.</td> </tr> <tr> <td></td> <td></td> <td>Split stream</td> <td>One stream is split into two streams.</td> </tr> <tr> <td></td> <td></td> <td>Move event</td> <td>An event is moved from one stream to another stream.</td> </tr> </tbody> </table> Table I: The Event Store Upgrade Operations, Categorized by Level and Complexity. This technique is suggested by both Betts et al. [34] and Axon. There are no extra write operations needed to convert the store. Narasimhan [28]: it copies and transforms every event to a new store. In this technique the old event store stays intact, and a new store is created instead. In this technique the event store remains intact as old versions are never transformed. There are no extra write operations needed to convert the store. **Upcasting** - Upcasting centralizes the update knowledge in an upcaster: a component that transforms an event before offering it to the application. Different than in the multiple versions technique is that the event listeners are not aware of the different versions of events. Because the upcaster changes the event the listeners only need to support the last version. This technique is suggested by both Betts et al. [34] and Axon Framework [35]. **Lazy transformation** - This technique also uses an upcaster to transform every event before offering it to the application, but the result of the transformation is also stored in the event store. The transformation is thus applied only once for every event, and on subsequent reads the transformation is no longer necessary. This technique is similar to the ones described by Sadalage and Fowler [21], Roddick [36], Tan and Katayama [37], and Scherzinger et al. [9]. **In place transformation** - A technique applied by many systems using a relational database. These systems convert the data by executing SQL statements such as ALTER TABLE (to alter the schema) and UPDATE (to alter the data). As described by Scherzinger et al. [9], NoSQL databases do not have such a possibility. In those cases a batch job is run that reads the data, transforms it, and writes the updated data back to the database. The documents in the database are updated by this job: adding, deleting, renaming properties, and transforming the values. This technique can be applied to event stores in the same manner. **Copy and transformation** - This technique is similar to the one described by Callaghan [25] and Dumitras and Narasimhan [28]: it copies and transforms every event to a new store. In this technique the old event store stays intact, and a new store is created instead. The event store upgrade techniques have their own strengths and weaknesses. To make this visible the techniques are judged on four quality characteristics from ISO/IEC 25010:2011 [38]: functional suitability, maintainability, performance efficiency, and reliability. The other four characteristics are regarded as not relevant for these upgrade techniques. Compatibility is a requirement for every upgrade system: it should be compatible with the overall system. End-users of the system will not interact with the upgrade system and thus is usability not relevant. The upgrade system is one of the components in the overall security, and therefore the security should not be different than in other components. Finally, portability is not regarded as a requirement for upgrade systems. **Functional suitability** - All five techniques can be implemented to achieve functional completeness. However, to execute complex store operations such as merging multiple streams the technique needs to read from multiple streams. When the technique is a run-time technique such as multiple versions, upcasting, and lazy transformation this violates the independence of the streams. The streams could be spread out over different databases and reading them together at the same time in the application is unfeasible. Therefore, the techniques multiple versions, upcasting, and lazy transformation are not functionally complete. The other two techniques are executed by a separate batch job that does not adhere to the principle of reading a single stream at a time. **Maintainability** - Multiple versions is the least maintainable technique, because the support of multiple versions is spread throughout the application code. The techniques upcasting and lazy transformation have a better maintainability, because the transformation code can be centralized in those implementations. However, they all do accumulate conversion code, because either the conversion result is not stored, or there is no way in telling when everything is converted. The implementation of the lazy transformation technique should apply all conversions that are not yet applied to specific events when needed. In place transformation and copy and transformation score the highest on maintainability, because in those techniques older transformations and their code do not have to be kept. After the execution of the data conversion, every event is transformed into a new version and thus the conversion code is no longer necessary. **Performance efficiency** - Multiple versions and upcasting are the most efficient, because they only transform events when they need to be transformed without adding extra write operations to the store. The transformations are done in-memory as needed, without writing the events back to the store. The techniques lazy transformation and in place transformation score a bit worse, because they add the extra write operations that permanently store the changes. copy and transformation has the worst performance efficiency, because every event is read and copied to a new store, even if there are no operations affecting the event. **Reliability** - Three techniques score high on reliability, either they do not change the store (multiple versions and upcasting) or make a backup (copy and transformation). The other two techniques change the event store permanently, making a backup mandatory. Table II shows the overview of the different techniques and their evaluation with respect to the four quality characteristics. A plus means that the technique satisfies the quality characteristic, a minus means that the quality characteristic is not satisfied. A plus minus expresses an acceptable satisfaction, but there is room for improvement. These ranks are the result of both literature study and evaluation with the experts as described in Section VIII. <table> <thead> <tr> <th>Technique</th> <th>Functional suitability</th> <th>Maintainability</th> <th>Performance efficiency</th> <th>Reliability</th> </tr> </thead> <tbody> <tr> <td>Multiple versions</td> <td>+/−</td> <td>−</td> <td>+</td> <td>+</td> </tr> <tr> <td>Upcasting</td> <td>+/−</td> <td>+/−</td> <td>+</td> <td>+</td> </tr> <tr> <td>Lazy transformation</td> <td>+/−</td> <td>+/−</td> <td>+/−</td> <td>−</td> </tr> <tr> <td>In place transformation</td> <td>+</td> <td>+</td> <td>+/−</td> <td>−</td> </tr> <tr> <td>Copy and transformation</td> <td>+</td> <td>+</td> <td>−</td> <td>+</td> </tr> </tbody> </table> Table II shows a preference for *upcasting* on the four quality characteristics, but specific context or requirements could steer companies towards a different technique such as *multiple versions*. These requirements could be a short time to market and not having the time to implement a more maintainable technique such as *upcasting*. The event store upgrade operations related to multiple event sources are considered to be executed by non-run-time techniques only. However, the choice for a run-time technique when complex store operations are not supported is not compulsory. Of course systems can implement a non-run-time technique even if they plan not to support the complex store operations. VI. Application and Data Upgrade Strategies According to Humble and Farley [39] and Jansen et al. [40], deploying software involves three phases: *Prepare and manage*, *Installing*, and *Configuring*. In the first phase, the environment in which an application is deployed should be prepared and managed: both hardware and software dependencies should be in place. During the *Installing*-phase the application itself is deployed. The final phase, the *Configuring*-phase is used to configure the application and make it ready for use. The techniques that are discussed in the previous section are performed in different phases. Three of the five techniques were already identified as run-time techniques in the previous section: *multiple versions*, *upcasting*, and *lazy transformations*. They execute the event store upgrade operations at run-time and are deployed along with the application binaries, therefore they are part of the *Installing*-phase. The last two techniques, *in place transformation* and *copy and transformation*, are not part of the actual application. Both techniques perform the data conversion within a separate batch job that needs to be run before the new application version is deployed, and therefore belong to the *Configuring*-phase. Although the code that performs the technique should be deployed it cannot be part of the application as the application itself is only deployed in the *Installing*-phase. These two techniques require a second deployment strategy aimed at the deployment of the data conversion logic. The simplest deployment strategy is to copy the new application onto the machine(s) replacing the older version. Brewer [41] refers to this approach as *fast reboot*. The time that it takes to bring down the application process, copy the new application, and starting the application process again is the downtime that is observed with this strategy. Its simplicity is its biggest selling point, but its biggest downside is that this strategy is not without downtime. Deployment strategies described by Pulkkinen [42] such as feature flagging, dark launching, and canary release are excluded from the list of discussed strategies, because they are specifically used to gain more knowledge about the users and/or (system) performance. Four strategies found in literature, suitable for upgrading an event sourced system, are discussed: **Big flip** - This strategy, described by Brewer [41], uses request routing to route traffic to one half of the machines, while the other half is made available for the upgrade. The traffic is rerouted again when the first half is upgraded after which the second half can be upgraded. When all machines are upgraded the load balancer again can route the traffic to every machine. During the upgrade only half of the machines can be used to handle traffic. **Rolling upgrade** - This strategy too uses some form of request routing to make sure that some machines do not receive requests. The machines in this strategy are upgraded in several upgrade groups defined by Dumitras et al. [43]. Because a small number of machines is being upgraded at a time, more machines are available to handle the traffic. However, the machines that are available are running mixed versions of the application: both those that are not yet upgraded and those that are already upgraded. This makes rolling upgrades complex, and the application should be able to handle these kinds of rolling upgrades. **Blue-green** - Blue-green deployment is described by both Humble and Farley [39] and Fowler [44]. According to Humble [39] this is one of the most powerful techniques for managing releases. Every application is always deployed twice: a current version and either a previous version or a future version. One of the deployments is active at a given time, either the *green* slot or the *blue* slot. When the application is upgraded, the inactive slot is used to deploy the new version. Blue-green deployment can be done without downtime, as no traffic is going to the version that is upgraded. After the upgrade, the traffic can be rerouted to the upgraded slot, switching between blue and green. This strategy is similar to the *big flip* strategy, but reserves extra resources for the upgrade while the *big flip* strategy uses existing resources and thus limits the capacity during an upgrade. Expand-Contract - A strategy, also known as parallel change, described by Sato [45] in three phases. The first phase is the expand phase: an interface is created to support both the old and the new version. After that the old version(s) are (incrementally) updated to the new version in the migrate phase. Finally in the contract phase, the interface is changed so that it only supports the new phase This strategy is suitable for upgrading components that are used by other components. By first expanding the interface of the component depending components can be upgraded. When all the depending components use the new interface the old interfaces can be removed. This strategy is not applicable for application upgrades, however, it can be utilized in upgrading the database. An upgrade of an event sourced system needs an application deployment strategy. This deployment strategy executes the run-time event store upgrade technique, but if the upgrade uses a non-run-time technique a data upgrade strategy is also required. The three run-time techniques multiple version, upcasting, and lazy transformation only need an application deployment strategy as they do not alter the data store. The other two techniques, in place transformation and copy and transformation, do need a data upgrade strategy. Not all combinations result in an upgrade that does not affect the operation of the system in a negative manner. Table III summarizes the combinations that would lead to a zero downtime upgrade. For the run-time techniques, multiple versions, upcasting, or lazy transformation, an application upgrade strategy is sufficient, and the big flip, rolling upgrade, and blue-green deployment strategies will all result in a zero downtime upgrade. All three strategies upgrade part of the machines while maintaining operations on the other parts, and the techniques are performed at run-time. For the non-run-time techniques, in place transformation and copy and transformation, the same three application upgrade strategies can be used and result in zero downtime upgrades. However, a data upgrade strategy is also needed to execute the batch job that converts the data. The strategy blue-green in combination with in place transformation is not possible, because the in place nature of the technique conflicts with the strategy that needs to have two slots available. Therefore, the technique in place transformation only works with the expand-contract strategy. Copy and transformation, the other non-run-time technique works with both the data upgrade strategies, blue-green deployment and expand-contract. VII. Event Store Upgrade Framework This section explains how the event store upgrade operation, techniques, and strategies form the event store upgrade framework that can be utilized in two distinct manners. Figure 3 shows the different event store upgrade operation, techniques, and strategies and their combinations. The first row of Figure 3 shows the event store upgrade operations, the darker yellow identifies the category of operations that crosses event streams and cannot be executed run-time. The event store upgrade techniques are colored green, the darker elements identify schema evolution techniques, while the others are schema versioning techniques. The last two rows identify both application and data upgrade strategies. The arrows between single elements, or groups of elements, identify the valid combinations. The valid combinations are explained in more detail along with the utilization of the framework. ![Figure 3. The Event Store Upgrade Framework.](image-url) The first utilization of the event store upgrade framework is a decision tree that supports the upfront design and implementation of an upgrade system for event sourced systems, presented in Figure 4. This tree shows the decisions that form the design and implementation of an upgrade system. Start an upgrade Are complex store operations present? No Yes Execute the application upgrade Configure the run-time upgrade technique Configure the non-run-time upgrade technique Execute the data upgrade Design an upgrade Is support of complex store operations necessary? No Choose a run-time upgrade technique Choose a non-run-time technique Multiple version || Upcasting || Lazy transformation Choose an application upgrade strategy In place transformation & & Expand-contract Choose a data upgrade strategy Copy and transformation Big flip || Rolling upgrade || Blue-green Expand-contract || Blue-green Implement the upgrade Figure 4. Decision Tree for the Design and Implementation of an Event Store Upgrade System. The design starts with the question if complex store operations need to be supported. This decision influences the possible techniques that can be applied, because these complex store operations cannot be executed with run-time techniques. When support for the complex store operations is not needed the next step is the choice of event store run-time upgrade technique. Any of the three run-time techniques, multiple versions, upcasting, or lazy transformation, will be sufficient (shown with a single arrow and the || combinator) and Table II can be used to decide what technique fits the context. When the upgrade system should support complex store upgrade operations, the choice is between the non-run-time techniques in place transformation and copy and transformation. The expand-contract application strategy follows automatically if in place transformation is chosen as a data upgrade strategy (shown with a single arrow and the & & combinator). Two different data upgrade strategies can be chosen with the technique copy and transformation as follows from Table III. Although the utilization of the framework for upfront design has much room for context specific choices, it shows what the possibilities are and makes the trade-offs explicit. The second utilization of the event store upgrade framework is a run-time decision making system. This system is implemented in the event store upgrade system, and is visualized in Figure 5. In this system the analysis of the event store upgrade operations that need to be executed is done at upgrade time. When the operations do not contain complex store operations, the system can apply the run-time technique in combination with the application upgrade strategy. If there are complex store operations the system can deploy the non-run-time technique with the data upgrade strategy, and then apply the application upgrade strategy. In this utilization, the choice for run-time technique, non-run-time technique, data upgrade strategy, and application upgrade strategy is made upfront. The system implements both a run-time and non-run-time technique that fits the requirements. The two techniques are completed with an implementation of a data upgrade and an application upgrade strategy. Having these implementations in the system allows for a fully automated upgrade system based on Figure 5. VIII. EVALUATION This work was done in the context of the development of a large CQRS system at AFAS Software. Two authors are working as architect and developer on this system, and an earlier list of the event store upgrade operations was discussed with the team that also works on this system. The operations were implemented in combination with the copy and transformation technique and the blue-green strategy. Multiple data conversions were executed with this upgrade system in a smaller experimental setting. The results of these conversions showed to be promising, but more systematic experimentation is necessary. Initial results showed that the event store upgrade operations executed with copy and transformation and deployed with blue-green were able to handle a diverse range of scenarios. These operations could all be performed while maintaining the operation of the system, no downtime was observed. However, it also showed that time needed to perform the conversion... was longer than expected, because the query store needs to be rebuilt as well. To evaluate the event store upgrade framework, interviews were held with three Dutch experts in the field of CQRS and event sourcing. They were selected because of their experience with CQRS and event sourcing, and their presence in the community through speaking engagements. Allard Buijze is the founder and architect of the Axon CQRS Framework\(^1\), and has more than six years of experience with CQRS and event sourcing both as a developer and consultant. Dennis Doomen is the lead architect of a large CQRS system. He has six years of experience with CQRS, and four years with event sourcing. He shares this experience with the community as an international speaker and often discusses this with other practitioners. Pieter Joost van de Sande is the founder of NCQRS\(^2\), an open source CQRS framework. After started applying CQRS and event sourcing more than six years ago, he recently started working on a large event-driven architecture. All three interviewees received training on CQRS and event sourcing from Greg Young. Multiple goals were set for conducting the interviews. The questions asked were directed towards these goals, and the interviews followed this order. 1) Reveal what their experiences of upgrading CQRS applications are, and what problems and situations they ran into. 2) Evaluate the utility and completeness of the event store upgrade operations. 3) Evaluate the completeness and the judgment on the quality characteristics of the event store upgrade techniques. 4) Evaluate the usefulness and completeness of the event store upgrade framework. The interviews led to small adjustments in the overviews and the event store upgrade framework, as summarized in the remainder of this section. **Naming Issues** - Many small misunderstandings were experienced around naming event store upgrade operations, techniques, and application and data upgrade strategies. This shows the immaturity of the field, the relatively new concept of event sourcing, and the joining of different fields (domain-driven design, distributed systems, and event-driven architecture). The event store upgrade technique *lazy transformation* was initially named *lazy upcasting*, but this name caused confusion. It is not the upcasting that is done lazy, but the transformation of the store that is executed lazily. The technique *copy and transformation* was initially named *replay of events*, which was mixed up with the normal procedure that is used to load aggregate roots and rebuild projectors by replaying the events in a CQRS system. **Frequency of Operations, and Business Requirements** - All interviewees agreed that the event store upgrade operations across the boundaries of event streams were not common. One of the interviewees stated “*Complex event store operations, you will not see a lot. There is a exponential relation between the level and the times you encounter an operation.*” These operations cause the need for a data upgrade strategy, which is something that two interviewees found conflicting with the expected immutability of the event store. As a result of this discussion, the support of complex store operations became the first question in the event store upgrade framework. The interviewees explained that an event store upgrade system can be useful, even if it does not support these complex store operations, because they see other possibilities of solving these schema changes. The same holds for the operations that delete information from the store, and all interviewees suggested that deprecating or archiving of data is preferred over the actual deletion. These discussions led to the distinction between *functional immutability* and *technical immutability*. Technical immutability is defined as the most strict form of immutability: no changes to stored events are allowed to be made. If this level of immutability should be preserved the schema evolution techniques (*lazy transformation, in place transformation, and copy and transformation*) cannot be applied. However, another level of immutability is *functional immutability* as one of the interviewees stated. Functional immutability allows the transformation of events as long as the information in the events is preserved from a business perspective. Within functional immutability there is far more room for techniques that alter the stored events. **Variation in Implementation** - Two out of three interviewees explained a variation of the technique *multiple versions* that improved the code reusability and maintainability. By re-using the already existing code to read older versions the maintainability is improved. These comments show that there is a large design space in implementing the techniques that removes some of the disadvantages. However, Table II was not changed, because the conclusion was that the average quality of the technique was not changed by these implementation variations. **Projections** - An event sourced system always has a data store for querying and presenting data next to the event store, because the event store itself cannot be utilized for that purpose. This query store is built from the event data by projectors resulting in *projections*. These projections are the data that is shown to users while the event store is used for validation of new changes. Two interviewees explained that many schema changes can be applied by not changing the event schema at all, but by only changing the projectors and projections. The feasibility of this approach and its up- and downsides are regarded as out of the scope of this paper, and should be studied in more detail. **Upfront Design and Prototyping** - The interviews show two sides to look at event sourced systems. Two out of three interviewees emphasized the importance of upfront design: by designing the event store, the streams, and the events with enough upfront thought, upgrades are less often necessary. One interviewee stated “*Event sourcing needs a lot of upfront thought, which is hard to do with agile development.*” This line \(^1\)http://www.axonframework.org/ \(^2\)https://github.com/pjvds/ncqrs of thought is also seen in the application of event storming\(^3\) in the design of event sourced systems. This design technique is applied to design the events in a system before implementation, and a good design is said to forestall some of the more complex event store upgrade operations, such as those on multiple event streams. The other interviewee stressed the importance of doing event store data upgrades to prevent the accumulation of conversion code, and thus found less value in defending technical immutability at all cost. **Completeness and Usefulness** - The interviewees found the event store upgrade framework unanimously useful and complete. Interest in the end result was shown and encouragement was given to publish this material. One interviewee stated that “You are maybe the only one, which is having such an overview and also thought about edge cases, which I hope never to encounter.” **IX. Conclusion and Future Work** This paper contributes to the research on event sourcing and data conversion in the following ways. First, event store upgrade operations are presented to explicitly express the data conversion needed to evolve an event sourced system to a new data schema. With these operations a common language is proposed for event sourced applications and frameworks and their upgrade systems to express schema evolution. The operations can also be used to analyze the impact of an event store upgrade: one category of operations, the complex store operations, cannot be executed at run-time without violating the independence of the different event streams. The second contribution is an overview of upgrade techniques and strategies that are used in event sourcing to execute the event store upgrade operations. This overview summarizes best practices and literature and makes it accessible to other practitioners. The last contribution is the event store upgrade framework, which is utilized upfront to design and implement an upgrade system. The framework makes the trade-offs explicit, and supports the making of design decisions. The automated utilization can be used to implement an event store upgrade system that handles every event store upgrade operation in an efficient way. The framework enables decision making regarding upgrades downtime and enables selection of the most performant technique and strategy. When there are no complex store operations the conversion can be done at run-time, and techniques that transform events in the event store are not needed. This leads to upgrades that only need an application upgrade strategy, which can be applied faster than the upgrades that also needs a data upgrade strategy. The maintainability problem that run-time techniques have can be solved by executing those accumulated conversions whenever a data upgrade is performed. The event store upgrade framework is also usable as a tool to analyze applications with respect to their level of readiness for the cloud, for continuous delivery, and rapid software evolution. Applications that do not have a clear upgrade system, but use ad-hoc data transformation are not ready. Upgrades are done manually and are error prone. However, applications that implement an automated upgrade system and can handle the complete list of event store upgrade operations are ready for continuous delivery. This allows those applications to incorporate improvements and prevent errors in doing manual upgrades. Part of the upgrade framework is implemented in a CQRS system. The copy and transformation technique together with the blue-green strategy are used in multiple experiments to transform an event store. This showed that more work is needed to enable the co-evolution of the stores in the command-side and query-side. The framework was evaluated with three Dutch experts in the field of event sourcing. Although only three experts were interviewed, and they had different opinions, the event store upgrade framework was found to be valuable by all three. The relative novelty of event sourcing can cause problems in understanding of concepts and definitions. The combination of literature study and expert interviews prevents validity problems in definitions and their interpretation and in making sure that the result of this paper is usable by other practitioners. To validate the event store upgrade framework the authors plan to implement the full automated upgrade system that uses the event store upgrade operations to select an upgrade technique and apply the upgrade strategies. A follow up study on the frequency of schema changes in event sourced systems, and the possible operations should support this implementation. The results of such a study could also help to uncover business decisions in expressing different schema changes with regard to for example data loss. Finally, the upgrade system could be extended by also including the query-side of an event sourced system. This paper only focuses on the event store, but as the interviewees stated, schema changes can be implemented by upgrading the projection, and not the event store. Furthermore, a change in the event store also changes these projections and the rebuilding of projections with the additional performance costs is a problem that also needs more study. **Acknowledgment** This research was supported by the NWO AMUSE project (628.006.001): a collaboration between Vrije Universiteit Amsterdam, Utrecht University, and AFAS Software in the Netherlands. The NEXT Platform is developed and maintained by AFAS Software. The authors also thank the three experts, Allard Buijze, Dennis Doomen, and Pieter Joost van de Sande, for their valuable experience and their willingness to contribute to this study. **References**
{"Source-Url": "https://slingerjansen.files.wordpress.com/2009/04/2017saner-eventsourcing.pdf", "len_cl100k_base": 10568, "olmocr-version": "0.1.50", "pdf-total-pages": 12, "total-fallback-pages": 0, "total-input-tokens": 39199, "total-output-tokens": 13825, "length": "2e13", "weborganizer": {"__label__adult": 0.00023066997528076172, "__label__art_design": 0.000339508056640625, "__label__crime_law": 0.00017464160919189453, "__label__education_jobs": 0.0006151199340820312, "__label__entertainment": 5.02467155456543e-05, "__label__fashion_beauty": 9.97781753540039e-05, "__label__finance_business": 0.00020372867584228516, "__label__food_dining": 0.000209808349609375, "__label__games": 0.00038242340087890625, "__label__hardware": 0.0004458427429199219, "__label__health": 0.00022542476654052737, "__label__history": 0.0001863241195678711, "__label__home_hobbies": 5.537271499633789e-05, "__label__industrial": 0.0002036094665527344, "__label__literature": 0.00021827220916748047, "__label__politics": 0.00013935565948486328, "__label__religion": 0.0002460479736328125, "__label__science_tech": 0.00809478759765625, "__label__social_life": 5.620718002319336e-05, "__label__software": 0.01041412353515625, "__label__software_dev": 0.97705078125, "__label__sports_fitness": 0.00014448165893554688, "__label__transportation": 0.00022745132446289065, "__label__travel": 0.0001405477523803711}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 62722, 0.0219]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 62722, 0.10285]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 62722, 0.93167]], "google_gemma-3-12b-it_contains_pii": [[0, 5633, false], [5633, 11410, null], [11410, 17324, null], [17324, 22673, null], [22673, 28332, null], [28332, 34662, null], [34662, 38265, null], [38265, 42624, null], [42624, 48827, null], [48827, 54822, null], [54822, 60192, null], [60192, 62722, null]], "google_gemma-3-12b-it_is_public_document": [[0, 5633, true], [5633, 11410, null], [11410, 17324, null], [17324, 22673, null], [22673, 28332, null], [28332, 34662, null], [34662, 38265, null], [38265, 42624, null], [42624, 48827, null], [48827, 54822, null], [54822, 60192, null], [60192, 62722, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 62722, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 62722, null]], "pdf_page_numbers": [[0, 5633, 1], [5633, 11410, 2], [11410, 17324, 3], [17324, 22673, 4], [22673, 28332, 5], [28332, 34662, 6], [34662, 38265, 7], [38265, 42624, 8], [42624, 48827, 9], [48827, 54822, 10], [54822, 60192, 11], [60192, 62722, 12]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 62722, 0.11675]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
7841d01d136ed438165f4d4202b9c4e6ca820f9e
Verification Tools for Checking some kinds of Testability A.N. Trahtman Bar-Ilan University, Dep. of Math. and St., 52900,Ramat Gan,Israel email:trakht@macs.biu.ac.il Algebraic Methods in Language Processing, TWLT Proceedings. 21(2003), 253-263 Abstract A locally testable language $L$ is a language with the property that for some nonnegative integer $k$, called the order of local testability, whether or not a word $u$ is in the language $L$ depends on (1) the prefix and suffix of the word $u$ of length $k-1$ and (2) the set of intermediate substrings of length $k$ of the word $u$. For given $k$ the language is called $k$-testable. The local testability has a wide spectrum of generalizations. A set of procedures for deciding whether or not a language given by its minimal automaton or by its syntactic semigroup is locally testable, right or left locally testable, threshold locally testable, strictly locally testable, or piecewise testable was implemented in the package TESTAS written in C/C++. The bounds on order of local testability of transition graph and order of local testability of transition semigroup are also found. For given $k$, the $k$-testability of transition graph is verified. We consider some approaches to verify these procedures and use for this aim some auxiliary programs. The approaches are based on distinct forms of presentation of a given finite automaton and on algebraic properties of the presentation. New proof and fresh wording of necessary and sufficient conditions for local testability of deterministic finite automata is presented. Keywords: deterministic finite automaton, locally testable, algorithm, graph, semigroup Introduction The concept of local testability is connected with languages, finite automata, graphs and semigroups. It was introduced by McNaughton and Papert (1971) and by Brzozowski and Simon (1973). Our investigation is based on both graph and semigroup representation of automaton accepting formal language. Membership of a long text in a locally testable language just depends on a scan of short subpatterns of the text. It is best understood in terms of a kind of computational procedure used to classify a two-dimensional image: a window of relatively small size is moved around on the image and a record is made of the various attributes of the image that are detected by what is observed through the window. No record is kept of the order in which the attributes are observed, where each attribute occurs, or how many times it occurs. We say that a class of images is locally testable if a decision about whether a given image belongs to the class can be made simply on the basis of the set of attributes that occur. How many times the attributes are observed is essential in the definition of locally threshold testable language, but it is considered only for number of occurrences less than given threshold. The order in which the attributes are observed from left [from right] is essential in the definition of the left [right] locally testable languages. The definition of strictly locally testable language differs from definition of locally testable language only by the length of prefixes and suffixes: in this case they have the same length $k$ as substrings. Piecewise testable languages are the finite Boolean combinations of languages of the form $A^*a_1A^*a_2A^*...A^*a_kA^*$ where $k \geq 0$, $a_i$ is a letter from the alphabet $A$ and $A^*$ is the free monoid over $A$. A language is piecewise testable iff its syntactic semigroup is $J$-trivial (distinct elements generate distinct ideals) (Simon 1975). The considered languages form subclasses of star-free languages and have a lot of applications. Regular languages and picture regular languages can be described by help of a strictly locally testable languages (Birget 1991, Hinz 1990). Local automata (a kind of locally testable automaton) are heavily used to construct transducers and coding schemes adapted to constrained channels (Beal Senellart 1998). Locally testable languages are used in the study of DNA and informational macromolecules in biology (Head 1987). The locally threshold testable languages (Beauquier Pin 1989) generalize the concept of locally testable language and have been studied extensively in recent years. An important reason to study locally testable languages is the possibility of being used in pattern recognition (Ruiz Espana Garcia 1998). Stochastic locally threshold testable languages, also known as $n$-grams are used in pattern recognition, particularly in speech recognition, both in acoustic-phonetics decoding and in language modelling (Vidal Casacuberta Garcia 1995). The implementation of algorithms concerning distinct kinds of testability of finite automata was begun by Caron (1998). Our package TESTAS (testability of automata and semigroups), written in C/C++, presents most wide list of different kinds of testability. The package contains a set of procedures for deciding whether or not a language given by its minimal automaton or by its syntactic semigroup is locally testable, right or left locally testable, threshold locally testable, strictly locally testable, bilateral locally testable, or piecewise testable. The bounds on order of local testability of transition graph and order of local testability of transition semigroup are also found. For given $k$, the $k$-testability of transition graph is verified. The transition semigroups of automata are studied in the package for the first time. We present in this paper the theoretical background of the algorithms, giving sometimes fresh wording of results. In particular, we give new short proof for necessary and sufficient conditions for the local testability of DFA. The complexity of the algorithms and programs is estimated here in detail. We consider here some approaches to verify the procedures of the package and use for this aim some auxiliary programs. The approaches are based on distinct forms of presentation of a given finite automaton and on the algebraic properties of the presentation. **PRELIMINARIES** Let $\Sigma$ be an alphabet and let $\Sigma^+$ denote the free semigroup on $\Sigma$. If $w \in \Sigma^+$, let $|w|$ denote the length of $w$. Let $k$ be a positive integer. Let $i_k(w)$ denote the prefix of $w$ of length $k$ or $w$ if $|w| < k$. Let $F_k(w)$ denote the set of factors of $w$ of length $k$. A language $L$ is called $k$-testable if there is an alphabet $\Sigma$ such that for all $u, v \in \Sigma^+$, if $i_{k-1}(u) = i_{k-1}(v)$, then either both $u$ and $v$ are in $L$ or neither is in $L$. An automaton is $k$-testable if the automaton accepts a $k$-testable language. A language $L$ [an automaton $A$] is locally testable if it is $k$-testable for some $k$. The definition of strictly locally testable language is analogous, only the length of prefix and suffix is equal to $k$, in the definition of strongly locally testable language prefix and suffix are omitted at all. The number of nodes of the graph $\Gamma$ is denoted $|\Gamma|$. The direct product of $k$ copies of the graph $\Gamma$ denoted by $\Gamma^k$ consists of states $(p_1, \ldots, p_k)$ where $p_i$ from $\Gamma$ and edges $(p_1, \ldots, p_k) \rightarrow (p_1 \sigma, \ldots, p_k \sigma)$ labeled by $\sigma$ for every $\sigma$ from $\Sigma$. A strongly connected component of the graph will be denoted for brevity $SCC$, a deterministic finite automaton will be denoted DFA. A node from a cycle will be called for brevity $C-node$. $C-node$ can be defined also as a node that has right unit in the transition semigroup of the automaton. If an edge $p \rightarrow q$ is labeled by $\sigma$ then let us denote the node $q$ as $p \sigma$. We shall write $p \succeq q$ if $p = q$ or the node $q$ is reachable from the node $p$ (there exists a directed path from $p$ to $q$). In the case $p \succeq q$ and $q \succeq p$ we write $p \sim q$ (that is $p$ and $q$ belong to one $SCC$). The graph with only trivial SCC (loops) will be called acyclic. The stabilizer $\Sigma(q)$ of the node $q$ from $\Gamma$ is the subset of letters $\sigma \in \Sigma$ such that any edge from $q$ labeled by $\sigma$ is a loop $q \rightarrow q$. Let $\Gamma(\Sigma_i)$ be the directed graph with all nodes from the graph $\Gamma$ and edges from $\Gamma$ with labels only from the subset $\Sigma_i$ of the alphabet $\Sigma$. So, $\Gamma(\Sigma(q))$ is a directed graph with nodes from the graph $\Gamma$ and edges from $\Gamma$ that are labeled by letters from stabilizer of $q$. A semigroup without non-trivial subgroups is called aperiodic. A semigroup $S$ has a property $\rho$ locally if for any idempotent $e \in S$ the subsemigroup $eSe$ has the property $\rho$. So, a semigroup $S$ is called locally idempotent if $eSe$ is an idempotent subsemigroup for any idempotent $e \in S$. ### Complexity Measures The state complexity of the transition graph $\Gamma$ of a deterministic finite automaton is equal to the number of his nodes $|\Gamma|$. The measures of the complexity of the transition graph $\Gamma$ are connected also with the sum of the numbers of the nodes and the edges of the graph $a$ and the size of the alphabet $g$ of the labels on the edges (the number of generators of the transition semigroup). The value of $a$ can be considered sometimes as a product $(g + 1)|\Gamma|$. Let us notice that $(g + 1)|\Gamma| \geq a$. The input of the graph programs of the package is a rectangular table: nodes $X$ labels. So the space complexity of the algorithms considering the transition graph of an automaton is not less than $|\Gamma|g$. The graph programs use usually a table of reachability defined on the nodes of the graph. The table of reachability is a square table and so we have $|\Gamma|^2$ space complexity. The number of the nodes of $\Gamma^k$ is $|\Gamma|^k$, the alphabet is the same as in $\Gamma$. So the sum of the numbers of the nodes and the edges of the graph $\Gamma^k$ is not greater than $(g + 1)|\Gamma|^k$. Some algorithms of the package use the powers $\Gamma^2$, $\Gamma^3$ and even $\Gamma^4$. So the space complexity of the algorithms reaches in these cases $|\Gamma|^2g$, $|\Gamma|^3g$ or $|\Gamma|^4g$. The main measure of complexity for semigroup $S$ is the size of the semigroup $|S|$ denoted by $n$. Important characteristics are also the number of generators (size of alphabet) $g$ and the number of idempotents $i$. The input of the semigroup programs of the package is the Cayley graph of the semigroup presented by a rectangular table: elements $X$ generators. So the space complexity of the algorithms considering the transition semigroup of an automaton is not less than $O(ng)$. Algorithms of the package dealing with the transition semigroup of an automaton use the multiplication table of the semigroup of $O(n^2)$ space. Another arrays used by the package present subsemigroups or subsets of the transition semigroup. So we have usually $O(n^2)$ space complexity. ### 1 Verification Tools of the Package A deterministic finite automaton can be presented by its syntactic semigroup or by the transition graph of the automaton. The package TESTAS includes programs that analyze: 1) an automaton of the language presented by oriented labeled graph; 2) an automaton of the language presented by its syntactic semigroup. Some auxiliary programs ensure verification of the algorithms used in the package. An important verification tool is the possibility to study both transition graph and transition semigroup of a given automaton and compare the results. The algorithms for graphs and for semigroups are completely different. An auxiliary program, written in C, finds the syntactic semigroup from the transition graph of the automaton. The program finds distinct mappings of the graph of the automaton induced by the letters of the alphabet of the labels. Any two mappings must to be compared, so we have $O(n(n - 1)/2)$ steps. These mappings form the set of semigroup elements. The set of generators coincides usually with the alphabet of the labels, but in some singular cases a proper subset of the alphabet is obtained. On this way, the syntactic semigroup of the automaton and the minimal set of semigroup generators is constructed. The time complexity of the considered procedure is $O(|\Gamma|gn^2)$ with $O(|\Gamma|n)$ space complexity. Let us notice that the size of the syntactic semigroup is in general not polynomial in the size of the transition graph. For example, let us consider a graph with 28 nodes and 33 edges (Kim McNaughton McCloskey 1991) and the following modification of this graph (Trahtman 2000a) obtained by adding one edge. The syntactic semigroup of given automaton has over 22 thousand elements. The verifying of local testability and finding the order of local testability for this semigroup needs an algorithm of $O(n^2)$ time complexity (Trahtman 1998). So in semigroup case, we have $O(22126^2)$ time complexity for both checking the local testability and finding the order. In the graph case, checking the local testability needs an algorithm of $O(28^2)$ time complexity (Kim McNaughton 1994, Trahtman 2001), but the finding the order of local testability is in general non-polynomial (Kim McNaughton 1994). However, in our case, the subprogram that finds the lower and upper bounds for the order of local testability finds equal lower and upper bounds and therefore gives the final answer for the graph more fast. The time complexity of the subprogram is $O(|\Gamma|^2g)$ (Trahtman 2000b), whence the algorithm in this case is polynomial and has only $O(28^2)$ time complexity. In many cases the difference between the size of the semigroup and the graph is not so great in spite of the fact that the size of the syntactic semigroup is in general not polynomial in the size of the transition graph. Therefore the passage to the syntactic semigroup is useful because the semigroup algorithms are in many cases more simple and more rapid. The checking of the algorithms is based also on the fact that some of the considered objects form a variety (quasivariety, pseudovariety) and therefore they are closed under direct product. For instance, $k$-testable semigroups form variety (Zalcstein 1973), locally threshold testable semigroups (Beauquier Pin 1989) and piecewise testable semigroups (Simon 1975) form pseudovariety. Left [right] locally testable semigroups form quasivariety because they are locally idempotent and satisfy locally some identities (Garcia Ruiz 2000). Let us mention also Eilenberg classical variety theorem (Eilenberg 1976). Two auxiliary programs, written in C, that find the direct product of two semigroups and of two graphs belong to the package. The input of the semigroup program consists of two semigroups presented by their Cayley graph with generators at the beginning of the element list. The result is presented in the same form and the set of generators of the result is placed in the beginning of the list of elements. The number of generators of the result is $n_1g_2 + n_2g_1 - g_1g_2$ where $n_i$ is the size of the $i$-th semigroup and $g_i$ is the number of its generators. The components of the direct product of graphs are considered as graphs with common alphabet of edge labels. The labels of both graphs are identified according to their order. The number of labels is not necessarily the same for both graphs, but the result alphabet uses only common labels from the beginning of both alphabets. Big size semigroups and graphs with predesigned properties can be obtained by help of these programs. Any direct power of a semigroup or graph keeps important properties of the origin. For example, let us consider the following semigroup $$A_2 = \langle a, b \mid aba = a, bab = b, a^2 = a, b^2 = 0 \rangle$$ It is a 5-element 0-simple semigroup, $A_2 = \{a, b, ab, ba, 0\}$, only $b$ is not an idempotent. The key role of the semigroup $A_2$ in the theory of locally testable semigroups explains the following theorem: Theorem 1.1 (Trahtman 1999) The semigroup $A_2$ generates the variety of 2-testable semigroups. Every $k$-testable semigroup is a $(k - 1)$-nilpotent extension of a 2-testable semigroup. Any variety of semigroups is closed in particular under direct product. Therefore any direct power of a semigroup $A_2$ is 2-testable, locally testable, threshold locally testable, left and right locally testable, locally idempotent. These properties can be checked by the package. The possibility to use distinct independent algorithms of different nature with various measures of complexity to the same object gives us a powerful verification tool. 2 Background of the Algorithms 2.1 The Necessary and Sufficient Conditions of Local Testability for DFA Local testability plays an important role in the study of distinct kinds of star-free languages. Necessary and sufficient conditions of local testability for reduced deterministic finite automaton were found by Kim, McNaughton and McCloskey (1991). Let us present a new short proof and fresh wording of these conditions: Theorem 2.1 Reduced DFA $A$ with state transition graph $\Gamma$ and transition semigroup $S$ is locally testable iff for any $C$-node $(p, q)$ of $\Gamma^2$ such that $p \succeq q$ we have 1. If $q \succeq p$ then $p = q$. 2. For any $s \in S$ holds $ps \succeq q$ iff $qs \succeq q$. Proof. Suppose $A$ is locally testable. Then the transition semigroup $S$ of the automaton is finite, aperiodic and for any idempotent $e \in S$ the subsemigroup $eSe$ is commutative and idempotent (Zalcstein 1973). Let us consider the $C$-node $(p, q)$ from $\Gamma^2$ such that $p \succeq q$. Then for some element $e \in S$ we have $qe = q$ and $pe = p$. We have $qe^i = q$, $pe^i = p$ for any integer $i$. Therefore in view of aperiodicity and finiteness of $S$ we can consider $e$ as an idempotent. Let us notice that for some $a$ from $S$ we have $pa = q$. Suppose first that $q \succeq p$. Then for some $b$ from $S$ we have $q^b = p$. Hence, $peae = q$, $qbe = p$. So $p = peae = p(eaeb)^i$ for any integer $i$. There exists a natural number $n$ such that in the finite aperiodic semigroup $S$ we have $(eae)^n = (eae)^{n+1}$. Commutativity of $eSe$ implies $eaeb = beae$. We have $p = peae = p(eaeb)^n = p(eae)^n(ebe)^n = p(eae)^{n+1}(ebe)^n = p(eae)^n(ebe)^n eae = p = q$. So $p = q$. Thus the condition 1 holds. Let us go to the second condition. For any $s \in S$ we have $p = p = q$. Hence, $peae = q$, $qbe = p$. In idempotent subsemigroup $eSe$ we have $q = (qbe)^2$. Therefore $q = q = q = q = q$. And $q = q = q = q = q$. If we assume that $p \succeq q$, then for some $b$ from $S$ holds $ps \succeq q$, whence $pse = q$. In idempotent subsemigroup $eSe$ we have $esbe = (esbe)^2$. Therefore $q = q = q = q = q$. And $q = q = q = q = q$. Suppose now that the conditions 1 and 2 are valid for any $C$-node from $\Gamma^2$ such that his second component is successor of the first. We must to prove that the subsemigroup $eSe$ is idempotent and commutative for any idempotent $e$ from transition semigroup $S$. Let us consider an arbitrary node $p$ from $\Gamma$ and an arbitrary element $s$ from $S$ such that the node $pse$ exists. The node $(pe, pse)$ is a $C$-node from $\Gamma^2$ and $pe \succeq pse$. We have $(pe, pse)e = (pse, pse)^2$. Therefore, by condition 2, $(pse)^2 \succeq pse$ and the node $pse$ exists too. The node $(pse, pse)^2$ is a $C$-node from $\Gamma^2$, whence by condition 1, $pse = pse$. The node $p$ is an arbitrary node, therefore $e = (e)^2$. Thus the semigroup $eSe$ is an idempotent subsemigroup. Let us consider now arbitrary elements $a, b$ from idempotent subsemigroup $eSe$ and an arbitrary node $p$ such that the node $pab$ exists. We have $ab = (ab)^2$ and $pab = pab$. So, $pab \succeq pab$, whence $pba \sim pab$. The node $(pba, pab)$ is a $C$-node from $\Gamma^2$, whence, by condition 1, $pba = pab$. Therefore $pba = pab$ in view of $b^2 = b$. Notice that \((p, pa b) \succeq (p b a, pa b a)\) in \(\Gamma^2\). In view of \(pa b a = pa b\) and the condition 2, we have \(p b a \succeq p a b\). Therefore the node \(p b a\) exists. We can prove now analogously that \(p a b \succeq p b a\), whence \(p b a \sim p a b\). Because the node \((p b a, p a b)\) is a \(C\)-node, we have, by the condition 1, \(p b a = p a b\). So \(eSe\) is commutative. Let us go to the algorithms for local testability and to measures of complexity of the algorithms. Polynomial-time algorithm for the local testability problem for the transition graph (Trahtman 2001) of order \(O(n^2)\) (or \(O(|\Gamma|^2 g)\)) is implemented in the package TESTAS. The space complexity of the algorithm is also \(O(|\Gamma|^2 g)\). A polynomial-time algorithm of \(O(|\Gamma|^2 g)\) time and of \(O(|\Gamma|^2 g)\) space is used for finding the bounds on order of local testability for a given transition graph of the automaton (Trahtman 2000b, Trahtman 2000a). An algorithm of worst case \(O(|\Gamma|^4 g)\) time complexity and of \(O(|\Gamma|^2 g)\) space complexity checked the 2-testability (Trahtman 2000b). The 1-testability is verified by help of algorithm (Kim McNaughton 1994) of order \(O(|\Gamma|^2 g^k)\). Checking the \(k\)-testability for fixed \(k\) is polynomial but growing with \(k\). For checking the \(k\)-testability (Trahtman 2000b), we use an algorithm of worst case asymptotic cost \(O(|\Gamma|^2 g^{k-1})\) of time complexity with \(O(|\Gamma|^2 g)\) space complexity. The time complexity of the last algorithm is growing with \(k\) and on this way we obtain non-polynomial algorithm for finding the order of local testability. However, \(k\) is not greater than \(\log_2 M\) where \(M\) is the maximal size of the integer in the computer memory. ### 2.2 The Necessary and Sufficient Conditions of Local Testability for Finite Semigroup The best known description of necessary and sufficient conditions of local testability was found independently by Brzozowski and Simon (1973), McNaughton (1974) and Zalcstein (1973): Finite semigroup \(S\) is locally testable iff its subsemigroup \(eSe\) is commutative and idempotent for any idempotent \(e \in S\). The class of \(k\)-testable semigroups forms a variety (Zalcstein 1973). This variety has a finite base of identities (Trahtman 1999). The variety of 2-testable semigroups is generated by 5-element semigroup and any \(k\)-testable semigroup is a nilpotent extension of 2-testable semigroup (Trahtman 1999). We present here necessary and sufficient conditions of local testability of semigroup in new form and from another point of view. **Theorem 2.2** For finite semigroup \(S\), the following four conditions are equivalent: 1. \(S\) is locally testable. 2. \(eSe\) is 1-testable for every idempotent \(e \in S\) (\(eSe\) is commutative and idempotent). 3. \(Se\) is 2-testable for every idempotent \(e \in S\). 4. \(Se\) is 2-testable for every idempotent \(e \in S\). Proof. Equivalency of 1) and 2) is well known (Brzozowski Simon 1973, McNaughton 1974, Zalcstein 1973). 3) \(\rightarrow\) 2). \(Se\) satisfies identities of 2-testability: \(xyx = xyxyx, x^2 = x^3, xyx = xxyx\) (Trahtman 1999), whence \(ese = ese\) an \(ese = e\) for any idempotent \(e \in S\) and for any \(s, t \in S\). Therefore \(eSe\) is commutative and idempotent. 2) \(\rightarrow\) 4). Identities of 1-testability in \(eSe\) may be presented in the following form \[ exe = exe, exey = exye \] for arbitrary \(x, y \in S\). Therefore for any \(u, v, w\) divided by \(e\) we have \[ uu = uu, uvu = uvuvu, uww = uwuuw \] So identities of 2-testability are valid in \(Se\). 4) \(\rightarrow\) 3). \(Se \subseteq Se\) whence identities \(SeSe\) are valid in \(Se\). Let us go now to the semigroup algorithms. The situation here is more favorable than in graphs. We implement in the package TESTAS a polynomial-time algorithms of \(O(n^2)\) time and space complexity for local testability problem and for finding the order of local testability for a given semigroup (Trahtman 1998). In spite of the fact that the last algorithm is more complicated and essentially more prolonged, the time complexity of both algorithms is the same. The verification of associative low needs algorithm of $O(n^3)$ time complexity. Some modification of this algorithm known as Light test (Lidl Pilz 1984) works in $O(n^2 g)$ time. The equality $(ab)j = a(jb)$ where $a, b$ are elements and $j$ is a generator is tested in this case. This algorithm is used also in the package TESTAS. Relatively small gruppoids are checked by the package automatically, verification of big size objects can be omitted by user. 2.3 Threshold Local Testability Let $\Sigma$ be an alphabet and let $\Sigma^+$ denote the free semigroup on $\Sigma$. If $w \in \Sigma^+$, let $|w|$ denote the length of $w$. Let $k$ be a positive integer. Let $i_k(w)$ [$t_k(w)$] denote the prefix [suffix] of $w$ of length $k$ or $w$ if $|w| < k$. Let $F_{k,j}(w)$ denote the set of factors of $w$ of length $k$ with at least $j$ occurrences. A language $L$ is called $l$-threshold $k$-testable if for all $u, v \in \Sigma^+$, if $i_{k-1}(u) = i_{k-1}(v)$, $t_{k-1}(u) = t_{k-1}(v)$ and $F_{k,j}(u) = F_{k,j}(v)$ for all $j \leq l$, then either both $u$ and $v$ are in $L$ or neither is in $L$. An automaton is $l$-threshold $k$-testable if the automaton accepts a $l$-threshold $k$-testable language. A language $L$ [an automaton $A$] is locally threshold testable if it is $l$-threshold $k$-testable for some $k$ and $l$. The syntactic characterization of locally threshold testable languages was given by Beauquier and Pin (1989). Necessary and sufficient conditions of local threshold testability for the transition graph of DFA (Trahmtan 2001, Trahtman 2003) follow from their result. First polynomial-time algorithm for the local threshold testability problem for the transition graph of the language used previously in the package was based on the necessary and sufficient conditions from (Trahmtan 2001). The time complexity of this graph algorithm was $O(|\Gamma|^3 g)$ with $O(|\Gamma|^4 g)$ space. This algorithm is replaced now in the package TESTAS by a new algorithm of worst case asymptotic cost $O(|\Gamma|^4 g)$ of the time complexity (Trahmtan 2003). The algorithm works as a rule more quickly. The space complexity of the new algorithm is $O(|\Gamma|^3 g)$. The algorithm is based on the following concepts and result. Définition 2.3 Let $p, q, r_1$ be nodes of graph $\Gamma$ such that $(p, r_1)$ is a $C$-node, $p \succeq q$ and for some node $r$ ($q, r$) is a $C$-node and $p \succeq r \succeq r_1$. For such nodes $p, q, r_1$ let $T_3SCC(p, q, r_1)$ be the SCC of $\Gamma$ containing the set $T(p, q, r_1) := \{t \mid (p, r_1) \succeq (q, t), q \succeq t \text{ and } (q, t) \text{ is a } C\text{-node}\}$ $T_3SCC$ is not well defined in general case, but an another situation holds for local threshold testability. Theorem 2.4 (Trahmtan 2003) DFA $A$ with state transition complete graph $\Gamma$ (or completed by sink state) is locally threshold testable iff 1) for every $C$-node $(p, q)$ of $\Gamma_2$ $\sim q$ implies $p = q$. 2) for every four nodes $p, q, t, r_1$ of $\Gamma$ such that - the node $(p, r_1)$ is a $C$-node, - $(p, r_1) \succeq (q, t)$, - there exists a node $r$ such that $p \succeq r \succeq r_1$ and $(r, t)$ is a $C$ - node holds $q \succeq t$. The algorithm for semigroups is based on the following modification of Beauquier and Pin ((1989) result): **Theorem 2.5** A language $L$ is locally threshold testable if and only if the syntactic semigroup $S$ of $L$ is aperiodic and for any two idempotents $e$, $f$ and elements $a$, $b$ of $S$ we have $eafuebf = ebfa$. The direct use of this theorem gives us only $O(n^3)$ time complexity algorithm, but there exists a way to reduce the time. So the time complexity of the semigroup algorithm is $O(n^3)$ with $O(n^2)$ space complexity (Trahtman 2001). ### 2.4 Right [Left] Local Testability Let $\Sigma$ be an alphabet and let $\Sigma^+$ denote the free semigroup on $\Sigma$. If $w \in \Sigma^+$, let $|w|$ denote the length of $w$. Let $k$ be a positive integer. Let $i_k(w)$ [$t_k(w)$] denote the prefix [suffix] of $w$ of length $k$ or $w$ if $|w| < k$. Let $F_k(w)$ denote the set of factors of $w$ of length $k$. A language $L$ is called right [left] $k$-testable if for all $u, v \in \Sigma^+$, if $i_{k-1}(u) = i_{k-1}(v), t_{k-1}(u) = t_{k-1}(v)$, $F_k(u) = F_k(v)$ and the order of appearance of these factors in prefixes [suffixes] in the word coincide, then either both $u$ and $v$ are in $L$ or neither is in $L$. An automaton is right [left] $k$-testable if the automaton accepts a right [left] $k$-testable language. A language $L$ [an automaton $A$] is right [left] locally testable if it is right [left] $k$-testable for some $k$. Right [left] local testability was introduced and studied by König (1985) and by Garcia and Ruiz (2000). Algorithms for right local testability, for left local testability for the transition graph and corresponding algorithm for the transition semigroup of an automaton (Trahtman 2002) used in the package TESTAS are based on the results of the paper (Garcia Ruiz 2000). The time complexity of the semigroup algorithm for both left and right local testability is $O(ni)$. The left and right locally testable semigroups are locally idempotent. The package TESTAS checks also local idempotency and the time of corresponding simple algorithm is $O(ni)$ (Trahtman 2002). The situation in the case of the transition graph is more complicated. The algorithms for right and left local testability for the transition graph are essentially distinct, moreover, the time complexity of algorithms differs. The left local testability algorithm for the transition graph needs the algorithm for local idempotency. Thus the graphs of automata with locally idempotent transition semigroup (Trahtman 2002) are checked by the package too and the time complexity of the algorithm is $O(|\Gamma|^3 g)$ (Trahtman 2002). The graph algorithm for the left local testability problem needs in the worst case $O(|\Gamma|^5 g)$ time and $O(|\Gamma|^3 g)$ space (Trahtman 2002). The following two theorems illustrate the difference between necessary and sufficient conditions for right and left local testability in the case of the transition graph. **Theorem 2.6** (Trahtman 2002) Let $S$ be transition semigroup of a deterministic finite automaton with state transition graph $\Gamma$. Then $S$ is left locally testable iff 1. $S$ is locally idempotent, 2. for any $C$-node $(p, q)$ of $\Gamma^2$ such that $p \preceq q$ and for any $s \in S$ we have $ps \succeq q$ iff $qs \succeq q$ and 3. If for arbitrary nodes $p, q, r \in \Gamma$ the node $(p, q, r)$ is $C$-node of $\Gamma^3$, $(p, r) \succeq (q, r)$ and $(p, q) \succeq (r, q)$ in $\Gamma^2$, then $r = q$. The graph $\Gamma^3$ is used in the theorem. However, the following theorem for right local testability does not use it. **Theorem 2.7** (Trahtman 2002) Let $S$ be transition semigroup of deterministic finite automaton with state transition graph $\Gamma$. Then $S$ is right locally testable iff 1. for any $C$-node $(p, q)$ from $\Gamma^2$ such that $p \sim q$ holds $p = q$. 2. for any $C$-node $(p, q) \in \Gamma^2$ and $s \in S$ from $ps \succeq q$ follows $qs \succeq q$. The time complexity of the graph algorithm for the right local testability problem is $O(|\Gamma|^2 g)$ (Trahtman 2002). This algorithm has $O(|\Gamma|^2 g)$ space complexity. The last algorithm does not call the test of local idempotency used only for the left local testability problem. ### 2.5 Piecewise Testability Piecewise testable languages introduced by Simon are finite boolean combinations of the languages of the form $A^+a_1A^+a_2A^+...A^+a_kA^+$ where $k \geq 0$, $a_i$ is a letter from the alphabet $A$ and $A^+$ is a free monoid over $A$ (Simon 1975). An efficient algorithm for piecewise testability implemented in the package is based on the following theorem: **Theorem 2.8** (Trahtman 2001) Let $L$ be a regular language over the alphabet $\Sigma$ and let $\Gamma$ be a minimal automaton accepting $L$. The language $L$ is piecewise testable if and only if the following conditions hold (i) $\Gamma$ is a directed acyclic graph; (ii) for any node $p$ the maximal connected component $C$ of the graph $\Gamma(\Sigma(p))$ such that $p \in C$ has a unique maximal state. The time complexity of the algorithm is $O(|\Gamma|^2 g)$. The space complexity of the algorithm is $O(n)$. The algorithm used linear test of acyclicity of the graph. The test can be executed separately. The considered algorithm essentially improves similar algorithm to verify piecewise testability of DFA of order $O(|\Gamma|^3 g)$ described by Stern (1985) and implemented by Caron (1998). All considered algorithms are based on some modifications of results from the paper (Simon 1975). Not complicated algorithm for the transition semigroup of an automaton verifies piecewise testability of the semigroup in $O(n^2)$ time and space. The algorithm uses the following theorem (recall that $x^\omega$ denotes an idempotent power of the element $x$). Theorem 2.9 (Simon 1975) Finite semigroup \( S \) is piecewise testable iff \( S \) is aperiodic and for any two elements \( x, y \in S \) holds \[(xy)\omega x = y(xy)\omega = (xy)\omega\] REFERENCES
{"Source-Url": "https://u.cs.biu.ac.il/~trakht/VerTWLT.pdf", "len_cl100k_base": 9229, "olmocr-version": "0.1.50", "pdf-total-pages": 11, "total-fallback-pages": 0, "total-input-tokens": 45265, "total-output-tokens": 11509, "length": "2e13", "weborganizer": {"__label__adult": 0.0005474090576171875, "__label__art_design": 0.0006928443908691406, "__label__crime_law": 0.0006051063537597656, "__label__education_jobs": 0.0018768310546875, "__label__entertainment": 0.00025153160095214844, "__label__fashion_beauty": 0.0003044605255126953, "__label__finance_business": 0.00039005279541015625, "__label__food_dining": 0.0006918907165527344, "__label__games": 0.0015077590942382812, "__label__hardware": 0.0012998580932617188, "__label__health": 0.00156402587890625, "__label__history": 0.0005578994750976562, "__label__home_hobbies": 0.00019752979278564453, "__label__industrial": 0.0007877349853515625, "__label__literature": 0.001837730407714844, "__label__politics": 0.0005650520324707031, "__label__religion": 0.0010051727294921875, "__label__science_tech": 0.36962890625, "__label__social_life": 0.00020575523376464844, "__label__software": 0.00946807861328125, "__label__software_dev": 0.6044921875, "__label__sports_fitness": 0.00043392181396484375, "__label__transportation": 0.000934600830078125, "__label__travel": 0.0002655982971191406}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 37428, 0.02607]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 37428, 0.7285]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 37428, 0.84019]], "google_gemma-3-12b-it_contains_pii": [[0, 3474, false], [3474, 7975, null], [7975, 12237, null], [12237, 16054, null], [16054, 20024, null], [20024, 24250, null], [24250, 27470, null], [27470, 29885, null], [29885, 33298, null], [33298, 36202, null], [36202, 37428, null]], "google_gemma-3-12b-it_is_public_document": [[0, 3474, true], [3474, 7975, null], [7975, 12237, null], [12237, 16054, null], [16054, 20024, null], [20024, 24250, null], [24250, 27470, null], [27470, 29885, null], [29885, 33298, null], [33298, 36202, null], [36202, 37428, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 37428, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 37428, null]], "pdf_page_numbers": [[0, 3474, 1], [3474, 7975, 2], [7975, 12237, 3], [12237, 16054, 4], [16054, 20024, 5], [20024, 24250, 6], [24250, 27470, 7], [27470, 29885, 8], [29885, 33298, 9], [33298, 36202, 10], [36202, 37428, 11]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 37428, 0.0]]}
olmocr_science_pdfs
2024-11-28
2024-11-28
e264c17370954464e6e247a6e8f1486dd870548e
Package ‘fRegression’ November 15, 2017 Title Rmetrics - Regression Based Decision and Prediction Date 2017-11-12 Version 3042.82 Author Diethelm Wuertz [aut], Tobias Setz [cre], Yohan Chalabi [ctb] Maintainer Tobias Setz <tobias.setz@live.com> Description A collection of functions for linear and non-linear regression modelling. It implements a wrapper for several regression models available in the base and contributed packages of R. Depends R (>= 2.15.1), timeDate, timeSeries, fBasics Imports lmtest, mgcv, nnet, polspline, methods, stats, utils Suggests MASS, RUnit LazyData yes License GPL (>= 2) URL https://www.rmetrics.org NeedsCompilation no Repository CRAN Date/Publication 2017-11-15 22:31:49 UTC R topics documented: fRegression-package ............................................... 2 coef-methods ...................................................... 4 fitted-methods .................................................. 5 formula-methods ................................................ 6 fREG-class ....................................................... 6 plot-methods .................................................... 8 predict-methods ............................................... 9 regFit .......................................................... 10 RegressionTestsInterface .................................... 15 The Rmetrics "fRegression" package is a collection of functions for linear and non-linear regression modelling. Details Package: fRegression Type: Package Version: R 3.0.1 Date: 2014 License: GPL Version 2 or later Copyright: (c) 1999-2014 Rmetrics Association Repository: R-FORGE URL: https://www.rmetrics.org 1 Introduction Regression modelling, especially linear modelling, LM, is a widely used application in financial engineering. In finance it mostly appears in form that a variable is modelled as a linear or more complex relationship as a function of other variables. For example the decision of buying or selling in a trading model may be triggered by the outcome of a regression model, e.g. neural networks are a well known tool in this field. 2 Fitting Regression Models Rmetrics has build a unique interface to several regression models available in the base and contributed packages of R. The following regression models are interfaced and available through a common function regFit. The argument use allows to select the desired model: regFit - lm fits regression models fits a linear model [stats] - rlm fits a LM by robust regression [MASS] - glm fits a generalized linear model [stats] - gam fits a generalized additive model [mgcv] - ppr fits a projection pursuit regression model [stats] - nnet fits a single hidden-layer neural network model [nnet] - polymars fits an adaptive polynomial spline regression [polspline] An advantage of the regFit function is, that all the underlying functions of its family can be called with the same list of arguments, and the value returned is always an unique object, an object of class "freg" with the following slots: @call, @formula, @method, @data, @fit, @residuals, @fitted, @title, and @description. Furthermore, independent of the selected regression model applied we can use the same S4 methods for all types of regressions. This includes, print, plot, summary, predict, fitted, residuals, coef, vcov, and formula methods. It is possible to add further regression models to this framework either his own implementations or implementations available through other contributed R packages. Suggestions include biglm, earth amongst others. 2 Simulation of Regression Models contains a function to simulate artificial regression models, mostly used for testing. regSim simulates artificial regression model data sets 3 Extractor Functions These generic functions are: fitted extracts fitted values from a fitted 'fREG' object residuals extracts residuals from a fitted 'fREG' object coef extracts coefficients from a fitted 'fREG' object formula extracts formula expression from a fitted 'fREG' object vcov extracts variance-covariance matrix of fitted parameters 4 Forecasting The function predict returns predicted values based on the fitted model object. predict forecasts from an object of class 'fREG' 4 Reporting Functions For printing and plotting use the functions: - `print` prints the results from a regression fit - `plot` plots the results from a regression fit - `summary` returns a summary report About Rmetrics: The fRegression Rmetrics package is written for educational support in teaching "Computational Finance and Financial Engineering" and licensed under the GPL. --- **coef-methods** **REG coefficients Methods** **Description** Extracts coefficients from a fitted regression model. **Methods** - object = "ANY" Generic function. - object = "fREG" Extractor function for coefficients. **Note** `coef` is a generic function which extracts the coefficients from objects returned by modeling functions, here the `regFit` and `gregFit` parameter estimation functions. **Author(s)** Diethelm Wuertz for the Rmetrics R-port. **Examples** ```r ## regSim - x = regSim(model = "LM3", n = 50) ## regFit - fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## coef - coef(fit) ``` Description Extracts fitted values from a fitted regression model. Methods - **object = "ANY"** Generic function - **object = "fREG"** Extractor function for fitted values. Note fitted is a generic function which extracts fitted values from objects returned by modeling functions, here the regFit and gregFit parameter estimation functions. The class of the fitted values is the same as the class of the data input to the function regFit or gregFit. In contrast the slot fitted returns a numeric vector. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim - x.df = regSim(model = "LM3", n = 50) ## regFit - # Use data.frame input: fit = regFit(Y ~ X1 + X2 + X3, data = x.df, use = "lm") ## fitted - val = slot(fit, "fitted") head(val) class(val) val = fitted(fit) head(val) class(val) ## regFit - # Convert to dummy timeSeries Object: x.tS = as.timeSeries(x.df) fit = regFit(Y ~ X1 + X2 + X3, data = x.tS, use = "lm") ## fitted - val = slot(fit, "fitted") head(val) class(val) ``` val = fitted(fit) head(val) class(val) --- ### Description Extracts formula from a fitted regression model. ### Methods - **object = "ANY"** Generic function - **object = "fGARCH"** Formula ### Note `formula` is a generic function which extracts the formula expression from objects returned by modeling functions, here the `regFit` and `gregFit` parameter estimation function. ### Author(s) Diethelm Wuertz for the Rmetrics R-port. ### Examples ```r ## regSim - x = regSim(model = "LM3", n = 50) ## regFit - fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## formula - formula(fit) ``` --- ### fREG-class **Class** "fREG" --- ### Description The class 'fREG' represents a fitted model of an heteroskedastic time series process. ### Objects from the Class Objects can be created by calls of the function `regFit`. The returned object represents parameter estimates of linear and generalized linear models. Slots call: Object of class "call": the call of the garch function. formula: Object of class "formula": the formula used in parameter estimation. family: Object of class "character": the family objects provide a convenient way to specify the details of the models used by function gregFit. For details we refer to the documentation for the function glm in R’s base package on how such model fitting takes place. method: Object of class "character": a string denoting the regression model in use, i.e. one of those listed in the use argument of the function regFit or gregFit. data: Object of class "list": a list with at least two entries named x containing the data frame used for the estimation, and data with the object of the rectangular input data. fit: Object of class "list": a list with the results from the parameter estimation. The entries of the list depend on the selected algorithm, see below. residuals: Object of class "numeric": a numeric vector with the residual values. fitted: Object of class "numeric": a numeric vector with the fitted values. title: Object of class "character": a title string. description: Object of class "character": a string with a brief description. Methods show signature(object = "fREG"): prints an object of class 'fREG'. plot signature(x = "fREG", y = "missing"): plots an object of class 'fREG'. summary signature(object = "fREG"): summarizes results and diagnostic analysis of an ob- ject of class 'fREG'. predict signature(object = "fREG"): forecasts mean and volatility from an object of class 'fREG'. fitted signature(object = "fREG"): extracts fitted values from an object of class 'fREG'. residuals signature(object = "fREG"): extracts residuals from an object of class 'fREG'. coef signature(object = "fREG"): extracts fitted coefficients from an object of class 'fREG'. formula signature(x = "fREG"): extracts formula expression from an object of class 'fREG'. Author(s) Diethelm Wuertz and Rmetrics Core Team. Description Plots results obtained from a fitted regression model. Usage ```r ## S4 method for signature 'fREG,missing' plot(x, which = "ask", ...) ``` Arguments - `x`: an object of class `fREG`. - `which`: a character string selectiong which plot should be displayed. By default `which = "ask"` which allows to generate plots interactively. - `...`: additional arguments to be passed to the underlying plot functions. Details The plots are a set of graphs which are common to the regression models implemented in the function `regFit`. This includes linear regression models use = "lm", robust linear regression models use = "rlm", generalized linear regression models use = "glm", generalized additive regression models use = "gam", projection pursuit regression models use = "ppr", neural network regression models use = "nnet", and polytochomous MARS models use = "polymars". In addition one can also use the original plot functions of the original models, e.g. `plot(slot(object, "fit")).` Methods - `x = "ANY", y = "ANY"` Generic function. - `x = "fREG", y = "missing"` Plot function to display results obtained from a fitted regression model. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim - x = regSim(model = "LM3", n = 50) ## regFit - fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## plot - ``` Regression Models Prediction Function Description Predicts a time series from a fitted regression model. Usage ```r ## S4 method for signature 'fREG' predict(object, newdata, se.fit = FALSE, type = "response", ...) ``` Arguments - `newdata`: new data. - `object`: an object of class `fREG` as returned from the function `regFit()`. - `se.fit`: a logical flag. Should standard errors be included? By default FALSE. - `type`: a character string by default "response". - `...`: arguments to be passed. Value returns ... Methods - `object = "ANY"` Generic function - `object = "fREG"` Predict method for regression models. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim - x <- regSim(model = "LM3", n = 50) ## regFit - fit <- regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ``` regFit Regression Modelling Description Estimates the parameters of a regression model. Usage ```r regFit(formula, data = NULL, family = gaussian, use = c("lm", "rlm", "glm", "gam", "ppr", "nnet", "polymars"), title = NULL, description = NULL, ...) ``` Arguments data data is the data frame containing the variables in the model. By default the variables are taken from `environment(formula)`, typically the environment from which `lm` is called. description a brief description of the project of type character. family a description of the error distribution and link function to be used in `glm` and `gam` models. See `glm` and `family` for more details. formula a symbolic description of the model to be fit. A typical `glm` predictor has the form `response ~ terms` where `response` is the (numeric) response vector and `terms` is a series of terms which specifies a (linear) predictor for `response`. For binomial models the response can also be specified as a factor. A `gam` formula, see also `gam.models`, allows that smooth terms can be added to the right hand side of the formula. See `gam.side.conditions` for details and examples. use denotes the regression method by a character string used to fit the model. `method` must be one of the strings in the default argument. "LM", for linear regression models, "GLM" for generalized linear modelling, "GAM" for generalized additive modelling, "PPR" for projection pursuit regression, "POLYMARS" for molytochomous MARS, and "NNET" for feedforward neural network modelling. title a character string which allows for a project title. ... additional optional arguments to be passed to the underlying functions. For details we refer to inspect the following help pages: `lm`, `glm`, `gam`, `ppr`, `polymars`, or `nnet`. References Details The function `regFit` was created to provide a selection of regression models working together with Rmetrics' "timeSeries" objects and providing a common S4 object as the returned value. These models include linear modeling, robust linear modeling, generalized linear modeling, generalized additive modelling, projection pursuit regression, neural networks, and polytomous MARS models. **LM – Linear Modelling:** Univariate linear regression analysis is a statistical methodology that assumes a linear relationship between some predictor variables and a response variable. The goal is to estimate the coefficients and to predict new data from the estimated linear relationship. R's base function ```r lm(formula, data, subset, weights, na.action, method = "qr", model = TRUE, x = FALSE, y = FALSE, qr = TRUE, singular.ok = TRUE, contrasts = NULL, offset, ...) ``` is used to fit linear models. It can be used to carry out regression, single stratum analysis of variance and analysis of covariance, although `aov` may provide a more convenient interface for these. Rmetrics' function ```r regFit(formula, data, use = "lm", ...) ``` calls R's base function `lm` but with the difference that the data argument, may be any rectangular object which can be transferred by the function `as.data.frame` into a data frame with named columns, e.g. an object of class "timeSeries". The function `regFit` returns an S4 object of class "freg" whose slot @fit is the object as returned by the function "lm". In addition we have S4 methods `fitted` and `residuals` which allow to retrieve the fitted values and the residuals as objects of same class as defined by the argument data. The function `plot.lm` provides four plots: a plot of residuals against fitted values, a Scale-Location plot of sqrt(| residuals |) against fitted values, a normal QQ plot, and a plot of Cook's distances versus row labels. [{stats} `lm`] **LM – Robust Linear Modelling:** To fit a linear model by robust regression using an M estimator R offers the function ```r rlm(formula, data, weights, ..., subset, na.action, method = c("M", "MM", "model.frame"), wt.method = c("inv.var", "case"), model = TRUE, x.ret = TRUE, y.ret = FALSE, contrasts = NULL) ``` from package MASS. Again we can use the Rmetrics' wrapper regFit(formula, data, use = "rlm", ...) which allows us to use for example S4 timeSeries objects as input and to get the output as an S4 object with the known slots. [MASS::rlm] **GLM – Generalized Linear Models:** Generalized linear modelling extends the linear model in two directions. (i) with a monotonic differentiable link function describing how the expected values are related to the linear predictor, and (ii) with response variables having a probability distribution from an exponential family. R’s base function from package stats comes with the function ```r glm(formula, family = gaussian, data, weights, subset, na.action, start = NULL, etastart, mustart, offset, control = glm.control(...), model = TRUE, method = "glm.fit", x = FALSE, y = TRUE, contrasts = NULL, ...) ``` Again we can use the Rmetrics’ wrapper ```r regFit(formula, data, use = "gam", ...) ``` [stats::glm] **GAM – Generalized Additive Models:** An additive model generalizes a linear model by smoothing individually each predictor term. A generalized additive model extends the additive model in the same spirit as the generalized linear model extends the linear model, namely for allowing a link function and for allowing non-normal distributions from the exponential family. [mgcv::gam] **PPR – Projection Pursuit Regression:** The basic method is given by Friedman (1984), and is essentially the same code used by S-PLUS’s pprreg. It is observed that this code is extremely sensitive to the compiler used. The algorithm first adds up to max.terms, by default ppr.nterms, ridge terms one at a time; it will use less if it is unable to find a term to add that makes sufficient difference. The levels of optimization, argument optlevel, by default 2, differ in how thoroughly the models are refitted during this process. At level 0 the existing ridge terms are not refitted. At level 1 the projection directions are not refitted, but the ridge functions and the regression coefficients are. Levels 2 and 3 refit all the terms; level 3 is more careful to re-balance the contributions from each regressor at each step and so is a little less likely to converge to a saddle point of the sum of squares criterion. The plot method plots Ridge functions for the projection pursuit regression fit. [stats::ppr] POLYMARS – Polytomous MARS: The algorithm employed by polymars is different from the MARS(tm) algorithm of Friedman (1991), though it has many similarities. Also the name polymars has been used for this algorithm well before MARS was trademarked. [polymars] NNET – Feedforward Neural Network Regression: If the response in formula is a factor, an appropriate classification network is constructed; this has one output and entropy fit if the number of levels is two, and a number of outputs equal to the number of classes and a softmax output stage for more levels. If the response is not a factor, it is passed on unchanged to nnet.default. A quasi-Newton optimizer is used, written in C. [nnet] Value returns an S4 object of class "fREG". Author(s) The R core team for the lm functions from R’s base package, B.R. Ripley for the glm functions from R’s base package, S.N. Wood for the gam functions from R’s mgcv package, N.N. for the ppr functions from R’s modreg package, M. O’Connors for the polymars functions from R’s polymars package, The R core team for the nnet functions from R’s nnet package, Diethelm Wuertz for the Rmetrics R-port. References Dobson, A.J. (1990); An Introduction to Generalized Linear Models; Chapman and Hall, London. Green, Silverman (1994); Nonparametric Regression and Generalized Linear Models; Chapman and Hall. Myers R.H. (1986); *Classical and Modern Regression with Applications*; Duxbury, Boston. Stone C.J., Hansen M., Kooperberg Ch., and Truong Y.K. (1997); *The use of polynomial splines and their tensor products in extended linear modeling (with discussion)*. Wahba (1990); *Spline Models of Observational Data*; SIAM. Wood (2000); *Modelling and Smoothing Parameter Estimation with Multiple Quadratic Penalties*; JRSSB 62, 413-428. Wood (2001); *Thin Plate Regression Splines*. There exists a vast literature on regression. The references listed above are just a small sample of what is available. The book by Myers’ is an introductory text book that covers discussions of much of the recent advances in regression technology. Seber’s book is at a higher mathematical level and covers much of the classical theory of least squares. **Examples** ```r ## regSim - x <- regSim(model = "LM3", n = 100) # LM regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") # RLM regFit(Y ~ X1 + X2 + X3, data = x, use = "rlm") # AM regFit(Y ~ X1 + X2 + X3, data = x, use = "gam") # PPR regFit(Y ~ X1 + X2 + X3, data = x, use = "ppr") # NNET regFit(Y ~ X1 + X2 + X3, data = x, use = "nnet") # POLYMARS regFit(Y ~ X1 + X2 + X3, data = x, use = "polymars") ``` Description A collection and description of functions to test linear regression models, including tests for higher serial correlations, for heteroskedasticity, for autocorrelations of disturbances, for linearity, and functional relations. The methods are: - "bg" Breusch–Godfrey test for higher order serial correlation, - "bp" Breusch–Pagan test for heteroskedasticity, - "dw" Durbin–Watson test for autocorrelation of disturbances, - "gq" Goldfeld–Quandt test for heteroskedasticity, - "harv" Harvey–Collier test for linearity, - "hmc" Harrison–McCabe test for heteroskedasticity, - "rain" Rainbow test for linearity, and - "reset" Ramsey’s RESET test for functional relation. There is nothing new, it's just a wrapper to the underlying test functions from R's contributed package `lmtest`. The functions are available as "Builtin" functions. Nevertheless, the user can still install and use the original functions from R's `lmtest` package. Usage ```r lmTest(formula, method = c("bg", "bp", "dw", "gq", "harv", "hmc", "rain", "reset"), data = list(), ...) bgTest(formula, order = 1, type = c("Chisq", "F"), data = list()) bpTest(formula, varformula = NULL, studentize = TRUE, data = list()) dwTest(formula, alternative = c("greater", "two.sided", "less"), iterations = 15, exact = NULL, tol = 1e-10, data = list()) gqTest(formula, point=0.5, order.by = NULL, data = list()) harvTest(formula, order.by = NULL, data = list()) hmcTest(formula, point = 0.5, order.by = NULL, simulate.p = TRUE, nsim = 1000, plot = FALSE, data = list()) rainTest(formula, fraction = 0.5, order.by = NULL, center = NULL, data = list()) resetTest(formula, power = 2:3, type = c("fitted", "regressor", "princomp"), data = list()) ``` Arguments alternative [dwTest] - a character string specifying the alternative hypothesis, either "greater", "two.sided", or "less". center [rainTest] - a numeric value. If center is smaller than 1 it is interpreted as percentages of data, i.e. the subset is chosen that \( n \times \text{fraction} \) observations are around observation number \( n \times \text{center} \). If center is greater than 1 it is interpreted to be the index of the center of the subset. By default center is 0.5. If the Mahalanobis distance is chosen center is taken to be the mean regressor, but can be specified to be a \( k \)-dimensional vector if \( k \) is the number of regressors and should be in the range of the respective regressors. data an optional data frame containing the variables in the model. By default the variables are taken from the environment which \texttt{lmtest} and the other tests are called from. exact [dwTest] - a logical flag. If set to \texttt{FALSE} a normal approximation will be used to compute the \( p \) value, if \texttt{TRUE} the "pan" algorithm is used. The default is to use "pan" if the sample size is \( < 100 \). formula a symbolic description for the linear model to be tested. fraction [rainTest] - a numeric value, by default 0.5. The percentage of observations in the subset is determined by \( \text{fraction} \times n \) if \( n \) is the number of observations in the model. iterations [dwTest] - an integer specifying the number of iterations when calculating the \( p \)-value with the "pan" algorithm. By default 15. method the test method which should be applied. nsim [hmcTest] - an integer value. Determines how many runs are used to simulate the \( p \) value, by default 1000. order [bgTest] - an integer. The maximal order of serial correlation to be tested. By default 1. order.by [gqTest][harvTest] - a formula. A formula with a single explanatory variable like \( \sim x \). Then the observations in the model are ordered by the size of \( x \). If set to \texttt{NULL}, the default, the observations are assumed to be ordered (e.g. a time series). plot [hmcTest] - a logical flag. If \texttt{TRUE} the test statistic for all possible breakpoints is plotted, the default is \texttt{FALSE}. RegressionTestsInterface point [ggTest][hmcTest] - a numeric value. If point is smaller than 1 it is interpreted as percentages of data, i.e. \( n \times \text{point} \) is taken to be the (potential) breakpoint in the variances, if \( n \) is the number of observations in the model. If point is greater than 1 it is interpreted to be the index of the breakpoint. By default 0.5. power [resetTest] - integers, by default 2:3. A vector of positive integers indicating the powers of the variables that should be included. By default it is tested for a quadratic or cubic influence of the fitted response. simulate.p [hmcTest] - a logical. If TRUE, the default, a p-value will be assessed by simulation, otherwise the p-value is NA. studentize [resetTest] - a logical value. If set to TRUE Koenker’s studentized version of the test statistic will be used. By default set to TRUE. tol [resetTest] - the tolerance value. Eigenvalues computed have to be greater than tol=1e-10 to be treated as non-zero. type [bgTest] - the type of test statistic to be returned. Either "Chisq" for the Chi-squared test statistic or "F" for the F test statistic. [resetTest] - a string indicating whether powers of the "fitted" response, the "regressor" variables (factors are left out) or the first principal component, "princomp", of the regressor matrix should be included in the extended model. varformula [bgTest] - a formula describing only the potential explanatory variables for the variance, no dependent variable needed. By default the same explanatory variables are taken as in the main regression model. ... [regTest] - additional arguments passed to the underlying lm test. Some of the tests can specify additional optional arguments like for alternative hypothesis, the type of test statistic to be returned, or others. All the optional arguments have default settings. Details bg – Breusch Godfrey Test: Under \( H_0 \) the test statistic is asymptotically Chi-squared with degrees of freedom as given in parameter. If type is set to "F" the function returns the exact F statistic which, under \( H_0 \), follows an F distribution with degrees of freedom as given in parameter. The starting values for the lagged residuals in the supplementary regression are chosen to be 0. bp – Breusch Pagan Test: The Breusch–Pagan test fits a linear regression model to the residuals of a linear regression model (by default the same explanatory variables are taken as in the main regression model) and rejects if too much of the variance is explained by the additional explanatory variables. Under $H_0$ the test statistic of the Breusch-Pagan test follows a chi-squared distribution with parameter (the number of regressors without the constant in the model) degrees of freedom. \textbf{dw – Durbin Watson Test:} The Durbin–Watson test has the null hypothesis that the autocorrelation of the disturbances is 0; it can be tested against the alternative that it is greater than, not equal to, or less than 0 respectively. This can be specified by the alternative argument. The null distribution of the Durbin-Watson test statistic is a linear combination of chi-squared distributions. The p value is computed using a Fortran version of the Applied Statistics Algorithm AS 153 by Farebrother (1980, 1984). This algorithm is called "pan" or "gradsol". For large sample sizes the algorithm might fail to compute the p value; in that case a warning is printed and an approximate p value will be given; this p value is computed using a normal approximation with mean and variance of the Durbin-Watson test statistic. \textbf{gq – Goldfeld Quandt Test:} The Goldfeld–Quandt test compares the variances of two submodels divided by a specified breakpoint and rejects if the variances differ. Under $H_0$ the test statistic of the Goldfeld-Quandt test follows an F distribution with the degrees of freedom as given in parameter. \textbf{harv - Harvey Collier Test:} The Harvey-Collier test performs a t-test (with parameter degrees of freedom) on the recursive residuals. If the true relationship is not linear but convex or concave the mean of the recursive residuals should differ from 0 significantly. \textbf{hmc – Harrison McCabe Test:} The Harrison–McCabe test statistic is the fraction of the residual sum of squares that relates to the fraction of the data before the breakpoint. Under $H_0$ the test statistic should be close to the size of this fraction, e.g. in the default case close to 0.5. The null hypothesis is reject if the statistic is too small. \textbf{rain – Rainbow Test:} The basic idea of the Rainbow test is that even if the true relationship is non-linear, a good linear fit can be achieved on a subsample in the "middle" of the data. The null hypothesis is rejected whenever the overall fit is significantly inferior to the fit of the subsample. The test statistic under $H_0$ follows an F distribution with parameter degrees of freedom. **reset – Ramsey’s RESET Test** RESET test is popular means of diagnostic for correctness of functional form. The basic assumption is that under the alternative, the model can be written by the regression $y = X\beta + Z\gamma + u$. $Z$ is generated by taking powers either of the fitted response, the regressor variables or the first principal component of $X$. A standard F-Test is then applied to determine whether these additional variables have significant influence. The test statistic under $H_0$ follows an F distribution with parameter degrees of freedom. **Value** A list with class "htest" containing the following components: - **statistic** the value of the test statistic. - **parameter** the lag order. - **p.value** the p-value of the test. - **method** a character string indicating what type of test was performed. - **data.name** a character string giving the name of the data. - **alternative** a character string describing the alternative hypothesis. **Note** The underlying lmtest package comes with a lot of helpful examples. We highly recommend to install the lmtest package and to study the examples given therein. **Author(s)** Achim Zeileis and Torsten Hothorn for the lmtest package, Diethelm Wuertz for the Rmetrics R-port. **References** Kraemer W. and Sonnberger H. (1986); *The Linear Regression Model under Test*, Heidelberg: Physica. Racine J. and Hyndman R. (2002); *Using R To Teach Econometrics*, Journal of Applied Econometrics 17, 175–189. Examples ```r ## bg | dw - # Generate a Stationary and an AR(1) Series: x = rep(c(1, -1), 50) y1 = 1 + x + rnorm(100) # Perform Breusch-Godfrey Test for 1st order serial correlation: lmTest(y1 ~ x, "bg") # ... or for fourth order serial correlation: lmTest(y1 ~ x, "bg", order = 4) # Compare with Durbin-Watson Test Results: lmTest(y1 ~ x, "dw") y2 = filter(y1, .5, method = "recursive") lmTest(y2 ~ x, "bg") ## bp - # Generate a Regressor: x = rep(c(-1, 1), 50) # Generate heteroskedastic and homoskedastic Disturbances err1 = rnorm(100, sd = rep(c(1, 2), 50)) err2 = rnorm(100) # Generate a Linear Relationship: y1 = 1 + x + err1 y2 = 1 + x + err2 # Perform Breusch-Pagan Test ``` RegressionTestsInterface bp = lmTest(y1 ~ x, "bp") bp # Calculate Critical Value for 0.05 Level qchisq(0.95, bp$parameter) lmTest(y2 ~ x, "bp") ## dw # Generate two AR(1) Error Terms # with parameter rho = 0 (white noise) # and rho = 0.9 respectively err1 = rnorm(100) # Generate Regressor and Dependent Variable x = rep(c(-1,1), 50) y1 = 1 + x + err1 # Perform Durbin-Watson Test: lmTest(y1 ~ x, "dw") err2 = filter(err1, 0.9, method = "recursive") y2 = 1 + x + err2 lmTest(y2 ~ x, "dw") ## gq # Generate a Regressor: x = rep(c(-1, 1), 50) # Generate Heteroskedastic and Homoskedastic Disturbances: err1 = c(rnorm(50, sd = 1), rnorm(50, sd = 2)) err2 = rnorm(100) # Generate a Linear Relationship: y1 = 1 + x + err1 y2 = 1 + x + err2 # Perform Goldfeld-Quandt Test: lmTest(y1 ~ x, "gq") lmTest(y2 ~ x, "gq") ## harv # Generate a Regressor and Dependent Variable: x = 1:50 y1 = 1 + x + rnorm(50) y2 = y1 + 0.3*x^2 # Perform Harvey-Collier Test: harv = lmTest(y1 ~ x, "harv") harv # Calculate Critical Value for 0.05 level: qt(0.95, harv$parameter) lmTest(y2 ~ x, "harv") ## hmc # Generate a Regressor: x = rep(c(-1, 1), 50) # Generate Heteroskedastic and Homoskedastic Disturbances: err1 = c(rnorm(50, sd = 1), rnorm(50, sd = 2)) err2 = rnorm(100) # Generate a Linear Relationship: y1 = 1 + x + err1 y2 = 1 + x + err2 # Perform Harrison-McCabe Test: lmTest(y2 ~ x, "hmc") ## rain - # Generate Series: x = c(1:30) y = x^2 + rnorm(30, 0, 2) # Perform rainbow Test rain = lmTest(y ~ x, "rain") rain # Compute Critical Value: qf(0.95, rain$parameter[1], rain$parameter[2]) ## reset - # Generate Series: x = c(1:30) y1 = 1 + x + x^2 + rnorm(30) y2 = 1 + x + rnorm(30) # Perform RESET Test: lmTest(y1 ~ x, "reset", power = 2, type = "regressor") lmTest(y2 ~ x, "reset", power = 2, type = "regressor") --- **regSim** *Regression Model Simulation* **Description** Simulates regression models. **Usage** ``` regSim(model = "LM3", n = 100, ...) LM3(n = 100, seed = 4711) LOGIT3(n = 100, seed = 4711) GAM3(n = 100, seed = 4711) ``` **Arguments** - `model`: a character string defining the function name from which the regression model will be simulated. - `n`: an integer value setting the length, i.e. the number of records of the output series, an integer value. By default n=100. - `seed`: an integer value, the recommended way to specify seeds for random number generation. - `...`: arguments to be passed to the underlying function specified by the `model` argument. Details The function `regSim` allows to simulate from various regression models defined by one of the three example functions `LM3`, `LOGIT3`, `GAM3` or by a user specified function. The examples are defined in the following way: ```r # LM3: > y = 0.75 * x1 + 0.25 * x2 - 0.5 * x3 + 0.1 * eps # LOGIT3: > y = 1 / (1 + exp(- 0.75 * x1 + 0.25 * x2 - 0.5 * x3 + eps)) # GAM3: > y = scale(scale(sin(2 * pi * x1)) + scale(exp(x2)) + scale(x3)) > y = y + 0.1 * rnorm(n, sd = sd(y)) ``` "LM3" models a linear regression model, "LOGIT3" a generalized linear regression model expressed by a logit model, and "GAM" an additive model. x1, x2, x3, and eps are random normal deviates of length n. The model function should return an rectangular series defined as an object of class `data.frame`, `timeseries` or `mts` which can be accepted from the parameter estimation functions `regFit` and `gregFit`. Value The function `garchSim` returns an object of the same class as returned by the underlying function `match.fun(model)`. These may be objects of class `data.frame`, `timeSeries` or `mts`. Note This function is still under development. For the future we plan, that the function `regSim` will be able to generate general regression models. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## LM2 - # Data for a user defined linear regression model: LM2 = function(n){ x = rnorm(n) y = rnorm(n) eps = 0.1 * rnorm(n) z = 0.5 + 0.75 * x + 0.25 * y + eps data.frame(Z = z, X = x, Y = y) } for (FUN in c("LM2", "LM3")) { cat(FUN, "::\n", sep = "") ``` residuals-methods Extract Regression Model Residuals Description Extracts residuals from a fitted regression object. Usage ```r ## S4 method for signature 'fREG' residuals(object) ``` Arguments - `object`: an object of class `fREG` as returned from the function `regFit()` or `gregFit()`. Methods - `object = "ANY"` Generic function - `object = "fREG"` Residuals Note `residuals` is a generic function which extracts residual values from objects returned by modeling functions. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim - x = regSim(model = "LM3", n = 50) ## regFit - fit = regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## residuals - residuals(fit) ``` show-methods Regression Modelling Show Methods Description Show methods for regression modelling. Details The show or print method returns the same information for all supported regression models through the `use` argument in the function `regFit`. These are the 'title', the 'formula', the 'family' and the 'model parameters'. Methods - `object = "ANY"` Generic function. - `object = "fREG"` Print method for objects of class 'fREG'. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim x <- regSim(model = "LM3", n = 50) ## regFit fit <- regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## print print(fit) ``` summary-methods Regression Summary Methods Description Summary methods for regressing modelling. Methods - `object = "ANY"` Generic function - `object = "fREG"` Summary method for objects of class 'fREG'. termPlot Regression Model Plot Methods Description Plots results obtained from a fitted regression model. Usage ```r ## S3 method for class 'fREG' termPlot(model, ...) ``` Arguments - `model`: an object of class `fREG`. - `...`: additional arguments to be passed to the underlying functions. Methods - `x = "ANY"` Generic function. - `x = "fREG"` Term plot function. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim x <- regSim(model = "LM3", n = 50) ## regFit fit <- regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## summary summary(fit) ``` Regression Model Plot Methods Description Plots results obtained from a fitted regression model. Usage ```r ## S4 method for signature 'fREG' terms(x, ...) ``` Arguments - `x`: an object of class 'fREG'. - `...`: additional arguments to be passed to the underlying functions. Methods - `x = "ANY"`: Generic function. - `x = "fREG"`: Terms extractor function. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r # regSim x <- regSim(model = "LM3", n = 50) # regFit fit <- regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ``` Extract Regression Model vcov Description Extracts vcov from a fitted regression model. Methods - `object = "ANY"`: Generic function - `object = "fREG"`: Extractor function for vcov. Note vcov is a generic function which extracts fitted values from objects returned by modeling functions, here the regFit and gregFit parameter estimation functions. Author(s) Diethelm Wuertz for the Rmetrics R-port. Examples ```r ## regSim - x <- regSim(model = "LM3", n = 50) ## regFit - fit <- regFit(Y ~ X1 + X2 + X3, data = x, use = "lm") ## vcov - vcov(fit) ``` Index *Topic **htest** RegressionTestsInterface, 15 *Topic **models** coef-methods, 4 fitted-methods, 5 formula-methods, 6 plot-methods, 8 predict-methods, 9 regFit, 10 regSim, 22 residuals-methods, 24 show-methods, 25 summary-methods, 25 termPlot, 26 terms-methods, 27 vcov-methods, 27 *Topic **package** fRegression-package, 2 *Topic **programming** fREG-class, 6 bgTest (RegressionTestsInterface), 15 bpTest (RegressionTestsInterface), 15 coef, ANY-method (coef-methods), 4 coeff, fREG-method (coef-methods), 4 coeff-methods, 4 dwTest (RegressionTestsInterface), 15 family, 10 fitted, ANY-method (fitted-methods), 5 fitted, fREG-method (fitted-methods), 5 fitted-methods, 5 formula, ANY-method (formula-methods), 6 formula, fREG-method (formula-methods), 6 formula-methods, 6 fREG-class, 6 fRegression (fRegression-package), 2 fRegression-package, 2 GAM3 (regSim), 22 glm, 10 gqTest (RegressionTestsInterface), 15 gregFit (regFit), 10 harvTest (RegressionTestsInterface), 15 hmcTest (RegressionTestsInterface), 15 lm, 10 LM3 (regSim), 22 lmTest (RegressionTestsInterface), 15 LOGIT3 (regSim), 22 plot, ANY, ANY-method (plot-methods), 8 plot, fREG, missing-method (plot-methods), 8 plot-methods, 8 ppr, 10 predict, ANY-method (predict-methods), 9 predict, fREG-method (predict-methods), 9 predict-methods, 9 rainTest (RegressionTestsInterface), 15 regFit, 10 RegressionTestsInterface, 15 regSim, 22 resetTest (RegressionTestsInterface), 15 residuals, ANY-method (residuals-methods), 24 residuals, fREG-method (residuals-methods), 24 residuals-methods, 24 show, ANY-method (show-methods), 25 show, fREG-method (show-methods), 25 show-methods, 25 summary, ANY-method (summary-methods), 25 summary, fREG-method (summary-methods), 25 summary-methods, 25 termPlot, 26 terms, ANY-method (terms-methods), 27 terms, fREG-method (terms-methods), 27 terms-methods, 27 vcov, ANY-method (vcov-methods), 27 vcov, fREG-method (vcov-methods), 27 vcov-methods, 27
{"Source-Url": "http://cran.ms.unimelb.edu.au/web/packages/fRegression/fRegression.pdf", "len_cl100k_base": 10875, "olmocr-version": "0.1.53", "pdf-total-pages": 30, "total-fallback-pages": 0, "total-input-tokens": 65202, "total-output-tokens": 14092, "length": "2e13", "weborganizer": {"__label__adult": 0.0003972053527832031, "__label__art_design": 0.0010986328125, "__label__crime_law": 0.0003826618194580078, "__label__education_jobs": 0.00330352783203125, "__label__entertainment": 0.00027108192443847656, "__label__fashion_beauty": 0.00025153160095214844, "__label__finance_business": 0.0025920867919921875, "__label__food_dining": 0.0004799365997314453, "__label__games": 0.001667022705078125, "__label__hardware": 0.0010509490966796875, "__label__health": 0.0004127025604248047, "__label__history": 0.00057220458984375, "__label__home_hobbies": 0.0003273487091064453, "__label__industrial": 0.000988006591796875, "__label__literature": 0.0004591941833496094, "__label__politics": 0.0004673004150390625, "__label__religion": 0.0004260540008544922, "__label__science_tech": 0.227783203125, "__label__social_life": 0.0002300739288330078, "__label__software": 0.06756591796875, "__label__software_dev": 0.68798828125, "__label__sports_fitness": 0.0005450248718261719, "__label__transportation": 0.0005621910095214844, "__label__travel": 0.00029659271240234375}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 44635, 0.02952]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 44635, 0.69602]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 44635, 0.72566]], "google_gemma-3-12b-it_contains_pii": [[0, 1421, false], [1421, 2571, null], [2571, 4336, null], [4336, 5342, null], [5342, 6377, null], [6377, 7308, null], [7308, 9296, null], [9296, 10656, null], [10656, 11472, null], [11472, 13677, null], [13677, 15978, null], [15978, 18291, null], [18291, 20418, null], [20418, 22318, null], [22318, 24036, null], [24036, 26310, null], [26310, 28589, null], [28589, 31175, null], [31175, 33147, null], [33147, 35314, null], [35314, 36619, null], [36619, 37800, null], [37800, 39383, null], [39383, 40093, null], [40093, 40952, null], [40952, 41536, null], [41536, 42272, null], [42272, 42647, null], [42647, 44438, null], [44438, 44635, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1421, true], [1421, 2571, null], [2571, 4336, null], [4336, 5342, null], [5342, 6377, null], [6377, 7308, null], [7308, 9296, null], [9296, 10656, null], [10656, 11472, null], [11472, 13677, null], [13677, 15978, null], [15978, 18291, null], [18291, 20418, null], [20418, 22318, null], [22318, 24036, null], [24036, 26310, null], [26310, 28589, null], [28589, 31175, null], [31175, 33147, null], [33147, 35314, null], [35314, 36619, null], [36619, 37800, null], [37800, 39383, null], [39383, 40093, null], [40093, 40952, null], [40952, 41536, null], [41536, 42272, null], [42272, 42647, null], [42647, 44438, null], [44438, 44635, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 44635, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 44635, null]], "pdf_page_numbers": [[0, 1421, 1], [1421, 2571, 2], [2571, 4336, 3], [4336, 5342, 4], [5342, 6377, 5], [6377, 7308, 6], [7308, 9296, 7], [9296, 10656, 8], [10656, 11472, 9], [11472, 13677, 10], [13677, 15978, 11], [15978, 18291, 12], [18291, 20418, 13], [20418, 22318, 14], [22318, 24036, 15], [24036, 26310, 16], [26310, 28589, 17], [28589, 31175, 18], [31175, 33147, 19], [33147, 35314, 20], [35314, 36619, 21], [36619, 37800, 22], [37800, 39383, 23], [39383, 40093, 24], [40093, 40952, 25], [40952, 41536, 26], [41536, 42272, 27], [42272, 42647, 28], [42647, 44438, 29], [44438, 44635, 30]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 44635, 0.0]]}
olmocr_science_pdfs
2024-12-10
2024-12-10
4598a2a7b45ce272fb4ae858444634586a25f8ea
Fall 2009 Database System Architecture for Fault tolerance and Disaster Recovery Anthony Nguyen Regis University Follow this and additional works at: https://epublications.regis.edu/theses Part of the Computer Sciences Commons Recommended Citation https://epublications.regis.edu/theses/56 This Thesis - Open Access is brought to you for free and open access by ePublications at Regis University. It has been accepted for inclusion in All Regis University Theses by an authorized administrator of ePublications at Regis University. For more information, please contact epublications@regis.edu. Disclaimer Use of the materials available in the Regis University Thesis Collection (“Collection”) is limited and restricted to those users who agree to comply with the following terms of use. Regis University reserves the right to deny access to the Collection to any person who violates these terms of use or who seeks to or does alter, avoid or supersede the functional conditions, restrictions and limitations of the Collection. The site may be used only for lawful purposes. The user is solely responsible for knowing and adhering to any and all applicable laws, rules, and regulations relating or pertaining to use of the Collection. All content in this Collection is owned by and subject to the exclusive control of Regis University and the authors of the materials. It is available only for research purposes and may not be used in violation of copyright laws or for unlawful purposes. The materials may not be downloaded in whole or in part without permission of the copyright holder or as otherwise authorized in the “fair use” standards of the U.S. copyright laws and regulations. Abstract Application systems being used today rely heavily on the availability of the database system. Disruption of database system can be damaging and catastrophic to the organization that depends on the availability of the database system for its business and service operations. To ensure business continuity under foreseeable and unforeseeable man-made or natural disasters, the database system has to be designed and built with fault tolerance and disaster recovery capabilities. This project explored existing technologies and solutions to design, build, and implement database system architecture for fault tolerance and disaster recovery using Oracle database software products. The project goal was to implement database system architecture for migrating multiple web applications and databases onto a consolidated system architecture providing high availability database application systems. Acknowledgements I would like to thank my project advisor Ms. Shari Plantz-Masters for her time to review and provide invaluable comments to help me get my best out on the paper content and organization. I would also like to thank Professor Donald Ina for his guidance, direction, and encouragement to get the project paper to completion. I would like to express my deep gratitude to my wife and children for their love and support for my continuing education and other endeavors. Without them, I would not have the energy and enthusiasm to set and reach worthy goals. # Table of Contents Abstract ......................................................................................................................................................... ii Acknowledgements ........................................................................................................................................... iii Table of Contents ........................................................................................................................................... iv List of Figures ................................................................................................................................................ vii List of Tables ................................................................................................................................................. viii Chapter 1 – Introduction ............................................................................................................................... 1 1.1 Problem Statement ................................................................................................................................. 1 1.2 Review of Existing Situation .................................................................................................................. 2 1.3 Goals of the Project ............................................................................................................................... 3 1.4 Issues and Limitations ............................................................................................................................ 3 1.5 Scope of Project ...................................................................................................................................... 4 Chapter 2 – Review of Literature and Research ......................................................................................... 5 2.1 High Availability Characteristics .......................................................................................................... 5 2.2 High Availability Requirements ........................................................................................................... 6 2.2.1 Requirements Analysis ....................................................................................................................... 7 2.2.2 Risk Analysis ..................................................................................................................................... 9 2.2.3 Cost Analysis ................................................................................................................................... 11 2.3 High Availability Functions and Capabilities ....................................................................................... 15 2.4 High Availability Existing Solutions .................................................................................................... 16 2.5 Research Methods ............................................................................................................................... 20 2.6 Research Summary ............................................................................................................................... 21 Chapter 3 – Project Methodology 3.1 Planning .................................................................23 3.2 Analysis .....................................................................24 3.3 Design ........................................................................24 3.4 Implementation ......................................................25 Chapter 4 – Database System Architecture for Fault Tolerance and Disaster Recovery 4.1 Database System Architecture Design ................................27 4.2 Oracle Database System Architecture Design .....................31 4.3 Implementation Plan ..................................................37 4.3.1 Overview ................................................................38 4.3.2 Scope ....................................................................39 4.3.3 Current System Architecture ...................................40 4.3.4 Proposed System Architecture ..................................41 4.3.5 Database Migration and Upgrade Test Plan .................42 4.3.6 System Architecture Test Plan ..................................43 4.3.7 System Cut-over .....................................................44 4.3.8 Timeline ..................................................................44 4.4 Implementation Procedures ..........................................45 4.4.1 Oracle 10g RAC Software Installation .........................45 4.4.2 Oracle Database Upgrade from 9i to 10g .....................48 Chapter 5 – Project History 5.1 How the project began ................................................51 5.2 Changes to the project plan .........................................51 5.3 What went right and what went wrong ..............................................................52 5.4 Project variables and their impact ........................................................................52 5.5 Results summary ................................................................................................53 Chapter 6 – Lesson Learned ................................................................................54 6.1 What was learned from the project experience .....................................................54 6.2 Did project meet initial project expectations ......................................................54 6.3 Next stage of project if it continued .....................................................................54 6.4 Conclusions/recommendations .........................................................................55 References ..............................................................................................................56 Appendix A - System Requirements Questionnaire .........................................................568 List of Figures Figure 1: Most Common Causes of Unplanned Downtime ........................................... 10 Figure 2: Acceptable downtime measurement .............................................................. 13 Figure 3: Systems Development Life Cycle (SDLC) ..................................................... 23 Figure 4: High Availability Database System Architecture ........................................ 30 Figure 5: High Availability Oracle Database System Architecture ............................... 34 Figure 6: Oracle Standby Database Implementation .................................................... 36 Figure 7: Current System Architecture ..................................................................... 40 Figure 8: Proposed System Architecture ................................................................... 41 Figure 9: System Implementation Timeline ................................................................. 44 List of Tables Table 1: Disaster Recovery (DR) Service Levels ........................................ 8 Table 2: Acceptable downtime measurement ............................................. 12 Table 3: The Direct Costs of Downtime .................................................. 14 Table 4: Microsoft SQL Server Disaster Recovery Options ....................... 28 Table 5: Oracle Database High Availability Architecture ......................... 32 Chapter 1 – Introduction 1.1 Problem Statement This project involved the design and implementation of new database system architecture for a program office within the Department of Justice (DOJ) to consolidate three separate database systems supporting three web applications onto one consolidated database system architecture. The DOJ web applications are used for the collection, dissemination, and collaboration of law enforcement investigation activities. These applications were developed and implemented many years ago at the early stages of web technology and had been continually upgraded over the years. However, other than software version upgrades, the system architectures to support these applications basically remained unchanged. The applications were developed in Java and the databases were running on Oracle. Each database supported its own application. Each application had its own system architecture. The three system architectures were very similar but independent of one another. The main problem was that for each application, the application server and database server were implemented on the same physical server with no redundant or backup server. Even though the servers were all Sun servers, they were different models and had different hardware configurations. Another problem was the application and database servers were running different software versions. The non-uniformity in the software and hardware that were being used for each application and database system made it hard to maintain the systems, to trouble shoot and resolve problems when they occur. Furthermore, the problem resolutions could not be applied across different application systems because of their different configurations. Each application and database system had to be maintained separately since they were running on separate servers. 1.2 Review of Existing Situation The DOJ applications were built on three-tier system architecture. The first tier was the client web browser to log on to the application. The second tier was the application server that contained and executed application programs. The third tier was the database server that processed data and queries coming from the application. When the systems were built, the application and database were put on the same server. This setup had worked for several years because there were not so many transactions being handled by the applications and the user community at the time was rather small. As the number of users and the transaction volume grew significantly over the years, system performance was severely degraded. For each system, the application and database were implemented on a single server with no system redundancy. When one of the systems failed beyond repair, the disaster recovery plan relied on using one of the systems that had spare operational capacity as a new host to rebuild the failed system. The application (second tier) and the database (third tier) should have been implemented on separate physical servers for better system performance, fault tolerance, and ease of maintenance. The applications were developed in Java running on Tomcat web servers implemented on Sun Solaris 9 operating system. The three databases were set up on three separate servers using Oracle 9i database software on Sun Solaris 9 operating system. Oracle 9i and Solaris 9 were at the end of their support cycle. As the systems were being redesigned, the DOJ program office also planned to upgrade the Oracle databases to Oracle 10g and Solaris 9 to Solaris 10 to stay current with advanced technology. 1.3 Goals of the Project The main objectives of the project are to reduce the number of database systems and to simplify database system operations and maintenance tasks while ensuring high system availability for all applications. One of the goals was to find solutions provided by commercial hardware and software vendors and recommend approaches to design and build reliable database system for fault tolerance and disaster recovery. Another goal was to design and implement a consolidated database and application system architecture to migrate existing application and database systems to the consolidated system architecture, to enhance system fault tolerance and disaster recovery capability, and to ease the maintenance tasks by reducing the number of servers to be maintained. 1.4 Issues and Limitations The DOJ program office was using Oracle database software products for its databases and Sun Solaris operating system for its servers and would like to stay with Oracle and Sun products because of the financial and technological investments that it had put into its existing application systems. The program office had interests in the research for technologies offered by other hardware and software vendors that could be considered to build database system architecture for fault tolerance and disaster recovery for future planning, but heavily leaned toward Oracle and Sun products to ease the learning curve for its technical staff and to speed up the implementation timeline. 1.5 Scope of Project This project concentrated on the study of the characteristics of a high availability system as well as the technologies that could be applied to design and build database system architecture for fault tolerance and disaster recovery. The project geared toward the design of a consolidated database system architecture that could be implemented to migrate and upgrade existing database application systems for the DOJ program office. The database system architecture that was designed and implemented in this project incorporates common features of commercially available database software products so that the database system architecture design can be applied to different database software products and independent of the database software products. 2.1 High Availability Characteristics Database system architecture that provides fault tolerance and disaster recovery capabilities is often specified as high availability database system. High availability refers to the characteristics of a system that allow the system to sustain continuous operation in the event of hardware and software failures due to natural or man made causes (Webb, 2008). A highly available system usually survives failures by substituting standby hardware or software components to reproduce normal functions to withstand system disruptions. A high-availability system can also allow replacement of failed components or perform system upgrade without disrupting system operations. The availability of system is normally defined as (Marcus, 2003): \[ A = \frac{MTBF}{MTBF + MTTR} \] Where A is system availability, MTBF is the mean time between failures, and MTTR is the mean time to recover the system. From the formula for system availability, it can be derived that when MTTR approaches zero (i.e., system down time is substantially short), availability (A) increases toward 100 percent. On the other hand, when MTBF gets larger (i.e., system down time occurs very rarely), MTTR has less impact on A. Therefore, the goal of system high availability is to make MTTR as small as possible and MTBF as large as possible. System outages and downtime are considered inevitable. However, the downtime can be reduced by taking steps to minimize the duration of the system outages. Based on the formula for system availability shown above, there are two ways to improve system availability: either extend MTBF (keep the systems’ components from failing) or extend MTTR (shorten the recovery time when they do fail). It may be impossible to predict when a component will fail, but the system can be designed to be protected against component failures and to reduce the amount of time to repair or replace the failed components. For example, by implementing disk mirroring, system downtime can be reduced from hours to no down time for problems caused by a failed disk; by setting up clustering and system failover, system downtime can be reduced from days to just a few minutes for system hardware failure. 2.2 High Availability Requirements The high availability capabilities of a system are defined by the system requirements analysis. The main objective of the requirements analysis is to determine the business needs and identify possible disasters that can happen to a database system. The system requirements analysis essentially analyzes capabilities that the database system should have to serve business needs and identifies the risks that may affect database system operations so that preventative measures can be planned, developed, and implemented to eliminate the risks as much as possible. The more preventative measures that are built into the database system, the lower the chance that the system operations will be disrupted or damaged such that the database cannot be recovered when a disaster strikes. On the other hand, no matter how sophisticated the database system is to be built with all of the preventative measures, there is always residual risk of system disruption. and outage. The system requirements analysis consists of the following areas: requirements analysis, risk analysis, and cost analysis. 2.2.1 Requirements Analysis The purpose of requirements analysis for database fault tolerance and disaster recovery is to determine the timeframe in which the database system can be recovered after a disaster so that appropriate solutions can be utilized in building the system. Sun BluePrints OnLine specifies the following classification levels of disaster recovery capability that can be used as a guideline for implementing high availability system architecture (Stringfellow, 2000). Table 1: Disaster Recovery (DR) Service Levels <table> <thead> <tr> <th>Disaster Recovery Classification</th> <th>Time to Recover</th> <th>Acceptable Data Loss (from Time of Failure)</th> <th>Typical Implementation</th> </tr> </thead> <tbody> <tr> <td>AAA</td> <td>Four Hours or Less</td> <td>Maximum one hour</td> <td>Database Replication and/or Network Mirroring</td> </tr> <tr> <td>AA</td> <td>Four to 12 Hours</td> <td>Four hours</td> <td>Standby Database</td> </tr> <tr> <td>A</td> <td>12 to 24 Hours</td> <td>24 hours</td> <td>Usually restore from offsite backup</td> </tr> <tr> <td>B</td> <td>24 to 72 Hours</td> <td>24 hours</td> <td>Always restore from offsite backup</td> </tr> </tbody> </table> The table above indicates that the less time it takes to recover the system would lower system down time and that in turn ensures higher system availability. It also recommends the technologies that can be implemented to achieve system high availability. 2.2.2 Risk Analysis A system requirements analysis may include a risk analysis that deals with the threats to the system. The threats may be classified as natural, technical, or human threats. The following are some of the threats that must be planned for and dealt with to ensure system high availability. These threats when they occur at the very least could disrupt system operations or in more severe situations could totally break the system (Wold, 1997): Natural Threats: Fire, tornado, hurricane, and flood are calamities that can destroy the building facility where the system is located or damage the equipment that the system depends on. Technical Threats: Power failure/fluctuation, malfunction or failure of CPU, system software, application software, network communications, heating, ventilation or air conditioning would affect system performance and bring the system down. Human Threats: Computer virus, computer crime, burglary, vandalism, terrorism, civil disorder, sabotage, explosion, and war can cause undetected yet irreparable damages to the system. The following figure shows the results of a survey conducted by computer industry analysts from Gartner/Dataquest on system risks that caused system downtime for real time systems (Marcus, 2003). ![Figure 1: Most Common Causes of Unplanned Downtime](image) According to the chart, the greatest causes of system downtime are often contributed by software failures, hardware failures, human error, and network failures. These common causes together accounts for up to 85% of system downtime in which the hardware and software failures are the most common. Based on the chart above, system high availability can be greatly increased by reducing the chance of system hardware, software, or network failures and by circumventing human errors in managing the system as much as possible. A high availability system must have good system architecture with system redundancy to withstand the failures of system components. Additionally it must be managed by highly qualified operations staff with well established procedures put in place to prevent errors from happening. As a result of the risk analysis, a disaster recovery plan should be developed to specify procedures to handle the threats to the system and to provide instructions to repair and recover the system to minimize system downtime when the disasters occur. 2.2.3 Cost Analysis A cost analysis should be included in the system requirements analysis to weight the benefits against the costs of building high availability system architecture in order to fine tune the system requirements. The cost of building a high availability database system is determined by the recoverability and availability of the system. Burleson (2005) defines recoverability as the ability of a system to be recoverable from failures with minimal downtime. Database recoverability is defined as the amount of time it would take to bring a database system back up and running if the system crashes due to reasons such as power surge, power failure, network failure, CPU failure, etc. Database recoverability directly relates to the effectiveness of the database backup and disaster recovery strategy. Ideally, the system should be up and running as quick as possible after a disaster. However, database size and the interval at which database backups are performed significantly affect the recovery time for a database. Choosing a good backup scheme also depends on the recovery time allowed, or the mean time to recover (MTTR). MTTR is the desired time required to perform instance or media recovery on the database. A variety of factors influence MTTR for media recovery, including the speed of detection, the type of method used to perform media recovery and the size of the database. MTTR of a system should be very low. Availability is measured by the amount of time the system has been up and is available for operation. In defining availability of the system, the word 'system' does not apply to just the database tier or the application tier, but to the complete enterprise system. This implies that every piece of equipment, including networks, servers, application controllers, disk subsystems, etc., should be considered for availability. Making all tiers of the enterprise system available also means that each tier should provide redundant hardware, helping to provide continuous service when one of the components fails. The level of system availability is based on operational requirements of the system. If the requirement is 99.99% uptime in 24 hours a day for 365 days of the year, redundant architecture often becomes a necessary to ensure system accessibility at all times and to maintain system transparency in system fail-over scenarios. If some amount of downtime is allowed that does not affect the entire business, some of the redundancy may not be required. The following table shows system availability requirement as measured by the amount of downtime allowed per year (Burleson, 2005). <table> <thead> <tr> <th>Availability Requirement</th> <th>Expected Downtime per Year</th> </tr> </thead> <tbody> <tr> <td>99.995%</td> <td>0.5 hours</td> </tr> <tr> <td>99.97%</td> <td>2.5 hours</td> </tr> <tr> <td>99.8%</td> <td>17.5 hours</td> </tr> <tr> <td>99.5%</td> <td>43.2 hours or 1.8 days</td> </tr> <tr> <td>99%</td> <td>88.8 hours or 3.7 days</td> </tr> <tr> <td>98%</td> <td>175.2 hours or 7.3 days</td> </tr> <tr> <td>96%</td> <td>350.4 hours or 14.6 days</td> </tr> </tbody> </table> Table 2 provides the expected downtime per year for the various levels of system availability requirements. The table illustrates the fact that the cost of availability rises substantially with each fraction increase in the availability requirement. Table 2 can be graphically represented in Figure 2 as follows (Burleson, 2005): ![Figure 2: Acceptable downtime measurement](image) The cost of system downtime can be direct or indirect. The direct costs can often be put in dollar figures, while the indirect costs are much harder to calculate. - **Direct Costs of Downtime** Direct costs of downtime are mainly loss of productivity. The following table provides samples of direct costs of downtime per hour as reported by various services and industries (Marcus, 2003): ### Table 3: The Direct Costs of Downtime <table> <thead> <tr> <th>Industry</th> <th>Average downtime cost per hour</th> </tr> </thead> <tbody> <tr> <td>Brokerage services</td> <td>$6.48 million</td> </tr> <tr> <td>Energy</td> <td>$2.8 million</td> </tr> <tr> <td>Credit card</td> <td>$2.58 million</td> </tr> <tr> <td>Telecomm</td> <td>$2 million</td> </tr> <tr> <td>Financial</td> <td>$1.5 million</td> </tr> <tr> <td>Manufacturing</td> <td>$1.6 million</td> </tr> <tr> <td>Financial institutions</td> <td>$1.4 million</td> </tr> <tr> <td>Retail</td> <td>$1.1 million</td> </tr> <tr> <td>Pharmaceutical</td> <td>$1.0 million</td> </tr> <tr> <td>Chemicals</td> <td>$704,000</td> </tr> <tr> <td>Health care</td> <td>$636,000</td> </tr> <tr> <td>Media</td> <td>$340,000</td> </tr> <tr> <td>Airline reservations</td> <td>$90,000</td> </tr> </tbody> </table> - **Indirect Costs of Downtime** Though the direct costs of downtime can be expensive, the indirect costs can be significantly higher and have much greater long-term impact to the organization. The following are examples of indirect costs: When the web site of a business organization does not function that prevents the customers from making online purchases or performing other business transactions, the customer would get frustrated. That experience would cause customer dissatisfaction and the customers may never buy products or do business with the company again. If the system outage becomes the news (especially for a well-known business organization) it may be a bad publicity incident. Consequently, the bad publicity could lead to company stock price losing value. There could be legal liability from lawsuits brought by stock holders because of the unexpected drop in the stock price. When things are going so bad in the company, employees get discouraged and start to leave the company and that certainly would affect employee morale. The reputation of the company could be significantly damaged when the bad situation gets out of control or goes on over a long period of time. 2.3 High Availability Functions and Capabilities A high availability system must at least have the following functions and capabilities (Marcus, 2003): - Backups and Restores - Highly Available Data Management (RAID, data redundancy, disk space and file system management) - Clustering and Failover - Data Replication - Data Storage Technology (SAN – Storage Area Network, NAS – Network Attached Storage) It is noted that with the implementation clusters and data storage technology, a high availability system can also be considered as a high performance computing system (Boukerche, 2007). 2.4 *High Availability Existing Solutions* A database system built for fault tolerance normally has good system backup and recovery plans with redundant hardware/software to prevent loss of data or to enable the recovery of the loss data. Database disaster recovery plans vary greatly and often involve minimal to complete data recovery and restoration. The data recovery and restoration process itself may be based on time-consuming manual recovery methods or fully automated recovery mechanism. Solutions selected for database disaster recovery plan are often determined by the desired level of system availability and the acceptable data loss in the event of system outage occur. The following are the questions that can be asked to help define database system fault tolerance and disaster recovery objectives. These questions are aimed to quantify the acceptable system downtime, the allowable amount of data that might be lost, whether it is possible to recover the lost data, the time to recover lost data, and if there is a good chance to bring the system back on. How long can an organization or business afford to be without critical data and applications? How much data can it afford to lose? What is the likelihood that the data will be corrupted when system failure occurs? Can the data be recreated after system failure? If a network goes down, how long will it take to restore it? How will that affect the ability to conduct business? If the entire site where the system is physically located suddenly becomes disrupted and out of service, how will that impact organization or business operations? Are there other alternate sites available to be put in service? The answers to these questions would help define system requirements and the level of high availability that the system should be planned and built for. To classify database system fault tolerance and disaster recovery capabilities, IBM and its user group have jointly developed seven tiers of system disaster recovery classification to define disaster recovery levels that a system can attain (Sample, 2005). These seven tiers of recovery help identify system fault tolerance level, current risk for data loss, and the target fault tolerance level that a database system can aim for. The recovery levels range from the lowest with no system backups to the highest with complete, immediate and automatic disaster recovery mechanisms in place. Other database software companies such as Oracle and Microsoft have different terminologies for the disaster recovery capabilities of their database software products as compared to what has been classified by IBM, but their disaster recovery approaches are similar to those defined by Sample (2005): **Tier 0:** No off-site data, no backup hardware, and no disaster recovery plan There is no saved information, no documentation, no backup hardware, no contingency plan, and no disaster recovery plan for this solution. The recovery time in this case is unpredictable. In fact, it may not be possible to recover the database system at all. The database system is usually guarded solely by implementing redundant array of independent disks (RAID) and relies on database backups that are kept on site. **Tier 1:** Data backup with no Hot Site Under this database disaster recovery plan, database backups will be sent to an off-site facility for safekeeping. The database backups provide the only means to restore the database. Depending on how often backups are made and how they are shipped from one site to another, there might be several days to weeks of data loss. The only good thing is that the database backups are secure off-site. However, this tier lacks the systems on which to restore the database should the primary system becomes non-operational. **Tier 2: Data backup with a Hot Site** In this case, regular database backups are saved on magnetic tapes or CDs and sent to an off-site facility that hosts a secondary infrastructure (also known as a hot site) where the database can be restored using the database backups in the event of a disaster. This solution will still result in the need to recreate several hours to days worth of data, but it is less unpredictable in recovery time. **Tier 3: Electronic Vaulting** Tier 3 solutions utilize the hot backup site specified in Tier 2. Additionally, mission-critical data and system backups are vaulted (or copied from the primary site to the backup site) via an automated process. This electronically vaulted data is typically more current than the backups that are shipped using physical media. Electronic vaulting or automated data replication can be implemented by using data mirroring technology from network attached storage (NAS) equipment vendors such as EMC, Network Appliance, Sun, or IBM. **Tier 4: Point-in-time copies** Tier 4 solutions are used by businesses that require both greater data currency and faster recovery time than what are provided by database disaster recovery methods from the lower tiers. Rather than relying on backup tapes, CDs, or database backup files being sent electronically from the primary site to the backup site, Tier 4 incorporates more real time solutions. It is much more efficient to recover the database from point-in-time copies of the database using data changes captured in log files that are replicated from primary site to the backup site than from database backups. Point-in-time copies of database are available using IBM's Batch/Online Database Shadowing and Journaling, Oracle's Data Guard, Microsoft's Warm Standby Server, and similar technologies provided by other database software vendors. **Tier 5: Transaction integrity** Tier 5 solutions are used by businesses with a requirement for consistency of data between primary site and backup site. There is little to no data loss for such solutions. This approach is often referred as two-phase commit in which a transaction has to be successfully committed at both primary and backup database sites or the transaction must be totally discarded. This functionality may ensure the system integrity across the sites, but it could severely impact database system performance because of additional workload in the coordination of data integrity check involved between the sites. This functionality is normally a feature of the database software product and usually encoded in the database application. **Tier 6: Zero or little data loss** Tier 6 database disaster recovery solutions maintain the highest levels of data currency. They are used by businesses with little or no tolerance for data loss and those who need to restore data to applications rapidly when there is a disruption in database operations. The solutions in this tier would have no dependence on the applications to provide data consistency. This tier includes all of the capabilities described in tier 5 and lower. In addition, it introduces system clustering enabled by operating systems (such as Sun Clusters) or hardware/software clusters. For database systems running on clusters, when one of the nodes on the clusters fails, there are still other nodes available to carry on the system operations without any disruption. Over the years, cluster has been a proven technology and is offered by hardware and software vendors such as Sun, HP, Dell, Oracle, and Microsoft. **Tier 7:** Highly automated, business-integrated solution Tier 7 solutions include all the major components being used for a Tier 6 solution with the additional integration of automation. The solutions in this tier ensure consistency of data above that of which is accomplished by Tier 6 solutions. The database recovery process is fully automated. Restoration of database applications and systems could progress much faster and more reliable than would be possible through manual disaster recovery procedures. These 'turnkey' solutions, however, may not be available out of the box but have to be implemented by integrating many different systems and technologies. ### 2.5 Research Methods The research on database system high availability was based on published research papers, case studies, and books on high availability system architecture and technologies. Information on the subject was also gathered from data sheets, white papers, technology tutorials, product specifications, implementation guides, and training materials provided on web sites by database software vendors such as Microsoft, Oracle, and IBM. Relevant information on hardware/software cluster and data replication technologies was obtained from major hardware, software, and storage area network (SAN) vendors such as Sun, HP, EMC, and Network Appliance. Personal experience on database system design, development, implementation, maintenance, and administration also contributed significantly to this research subject. Data collected were generated based on search categories and key words related to database fault tolerance and disaster recovery subject. Relevant information were selected and classified into different categories for analysis and comparison that could be used to support the project goal and objective. 2.6 Research Summary A database system built for high availability demands that the system must have some kind of fault tolerance and disaster recovery capabilities to withstand both planned and unplanned outages and to ensure uninterrupted system operations. The system outages could be caused by natural disasters or due to routine system maintenance tasks such as system backups, or hardware / software upgrades. In today's e-business environment, many companies depend on database systems to provide continuous system availability and transparent disaster recovery ability for business survival. Economically speaking, the cost of a system outage sometimes far outweighs the cost a disaster recovery solution that can be put in place to prevent or minimize the impact of system outages in the first place. The goal of building database system with fault tolerance and disaster recovery capabilities is to use all available resources, establish processes to minimize planned and unplanned system downtime to protect business system operations from unforeseen disasters. A high availability database system usually relies on good database backups, system redundancy, and well-established disaster recovery procedure. Ultimately, planning for any type fault tolerance and disaster recovery solution for a database system is always subject to balancing system downtime versus cost. This project utilized waterfall methodology in which the project proceeded from one phase of the Systems Development Life Cycle (SDLC) to the next in a sequential order. The project included the following phases: planning, analysis, design, and implementation phase as depicted in the SDLC graph below: ![SDLC Diagram] ### Figure 3: Systems Development Life Cycle (SDLC) #### 3.1 Planning The objective of this phase was to determine the business needs and identify possible disasters that could happen to a database system. The outcome of this phase was documentation to analyze capabilities that the database system should have to serve the business needs of the DOJ program office and to identify the risks that might affect database system operations so that preventative measures could be planned, developed, and implemented to eliminate the risks as much as possible. The more preventative measures that could be built into the database system, the lower the chance that the system operations would be disrupted or damaged such that the database might not be recovered when a disaster strikes. On the other hand, no matter how sophisticated the database system was to be built with all of the preventative measures, there might always be residual risks of system disruption and outage. ### 3.2 Analysis In the analysis phase, the risks of the system are identified to define the capabilities of the system to handle the perceived risks to the system. The objective of this phase was to document the risks, specify system requirements, and develop system disaster recovery plan. Appendix A provides the set of questions which was used to gather the system requirements for the new database system architecture. The system requirements gathered and analyzed in this phase were used to determine disaster recovery level required for DOJ application systems. The outcome of the analysis phase was to provide criteria to select the technology for disaster recovery solutions for DOJ application systems. ### 3.3 Design The objective of this phase was to provide a system architecture design that could be implemented to provide disaster recovery and fault tolerance capabilities for DOJ application systems as specified in the requirements analysis phase. The design of a fault tolerance database system is partially dependent on the hardware and software solutions. The solutions generally are similar and comparable with the current available technologies offered by major database software vendors. Open source database software products can provide viable solutions; however, they may not have all of the desired features or options available as other well-known commercial database software products. The design of database system architecture is certainly driven by the database software products and solutions selected. However, the design may not be dependent on the hardware products. The reason is that commercial database software products can run on many different hardware platforms. Furthermore, hardware products normally provide similar functionalities to support high availability database system architecture. A database system architecture designed independent of database software product is provided in Chapter 4. 3.4 Implementation The implementation phase consisted of tasks performed to build the designed database system architecture. The tasks were developed using instructions and guidelines from technical documents provided by database software vendors. It is a common practice to build a development environment that is similar to the production environment to develop and test the implementation procedure and to ensure that the system works as expected before performing the implementation procedure in the production environment. The database system architecture design was divided into two sections and implemented in two independent stages. The first stage was to implement the production database environment. The second stage was to implement the standby database environment as well as to integrate the standby database into the system architecture. Each implementation stage was further broken up into specific tasks to be performed. The implementation plan followed the approach to build and test each system components independently, then integrate the components together as the project was progressed. A detailed implementation plan which lays out the tasks for project implementation is provided in Chapter 4. 4.1 Database System Architecture Design The design of database system architecture is certainly driven by the database software products and solutions selected. This section will look at the solutions for database system high availability and disaster recovery offered by two major database software vendors Microsoft and Oracle for comparison. Microsoft SQL Server database offers the following database fault-tolerance and disaster recovery capabilities (Microsoft, 2007): 1. Failover Clustering 2. Database mirroring 3. Peer-to-peer transactional replication 4. Maintenance of a warm standby database - By log shipping - By transactional replication 5. Backup and restore 6. Disk redundancy of data by using redundant array of independent disks (RAID) The following table provides a brief description of disaster recovery options for Microsoft SQL server database along with the advantages and disadvantages of each option: <table> <thead> <tr> <th>Disaster Recovery Options</th> <th>Functionality</th> <th>Advantage</th> <th>Disadvantage</th> </tr> </thead> <tbody> <tr> <td>1. Failover Clustering</td> <td>Cluster of database servers to provide database failover automatically if hardware failure or a software failure occurs</td> <td>- High server availability with almost no downtime</td> <td>- Install and maintain two servers is two times the costs of maintaining a single server</td> </tr> <tr> <td></td> <td></td> <td>- Automatically occurs if the primary server fails</td> <td>- Servers should be in the same location</td> </tr> <tr> <td>2. Database mirroring</td> <td>A mirror database set up at a backup site</td> <td>- Increase data protection</td> <td>- Mirror database should be identical to the principal database</td> </tr> <tr> <td></td> <td></td> <td>- Increase system availability</td> <td>- The transfer of information from one server to another over a network must be secure</td> </tr> <tr> <td></td> <td></td> <td>- Improve the availability of production database during upgrades</td> <td></td> </tr> <tr> <td>3. Peer-to-peer transactional replication</td> <td>Application can read or modify the data in any database that participates in replication</td> <td>- Improve read performance</td> <td>- All participating databases must contain identical schemas and data</td> </tr> <tr> <td></td> <td></td> <td>- Aggregate update performance, insert performance, and delete performance for the topology resembles the performance of a single node because all changes are propagated to all nodes</td> <td>- Peer-to-peer transactional replication does not provide conflict detection or conflict resolution</td> </tr> </tbody> </table> 4. Warm standby database server Maintain warm standby server by using either of the following methods: - Log shipping - Transaction replication - Log shipping - Can recover all database activities - Restore database faster - Transaction replication - Can read data on standby database - Changes are applied with less latency - Log shipping - Database is unusable during recovery process - Lack of granularity - No automatic failover 5. Backup and restore Use backup copy to re-create the database or to restore the database - Can back the database up to removable media - Do not depend on network as failover clustering or log shipping - If failure occurs, may lose your most recent data - If disaster occurs, must manually restore database 6. Disk redundancy of data by using redundant array of independent disks (RAID) RAID stores redundant data on multiple disks to provide greater reliability and less downtime for servers Do not lose data if any one disk fails - It may take a long time to recover the data - If multiple disks fail, may not be able to recover valuable data The following are Oracle software products and features that deliver similar database disaster recovery options: 1. Real Application Clusters (RAC): Database failover clustering 2. Data Guard: Database mirroring, Physical and Logical Standby Database 3. Oracle Streams: Peer-to-peer transactional replication 4. Recovery Manager (RMAN): Backup and restore 5. Disk redundancy of data by using Automatic Storage Management (ASM) and redundant array of independent disks (RAID) The following figure depicts one of the database system architecture designs for fault tolerance and disaster recovery that can be implemented independent of the database software products. *Figure 4: High Availability Database System Architecture* In this database system architecture, redundant application servers and database servers are used to provide non-interrupted service should one of the servers be damaged and cannot immediately be repaired. The database servers are also clustered to take advantage of the database cluster technology allowing high availability and scalability to the database system. A standby database is also utilized to provide more protection to the database system. The standby database is normally located at a different site as a safeguard in case the production site is totally disrupted. The standby database may possibly be used to generate reports for applications to take some of the workload off the production database. Other options can be derived from this design as a subset of it by taking away those components that are deemed not required or can't be afforded. On the other hand, more nodes can be added to the clustered servers, as well as additional standby database and application servers can be set up at multiple backup sites as required to handle the heavy workload and to attain maximum availability for the system. 4.2 Oracle Database System Architecture Design This section provides a system architecture design specifically for Oracle database technology using the guidelines from the Oracle Database High Availability Best Practices document on how to implement high availability database system architecture for Oracle database. The table below outlines Oracle products and features that may be implemented within database system architecture to handle planned or unplanned database system outages (Oracle, July 2006): ### Table 5: Oracle Database High Availability Architecture <table> <thead> <tr> <th>Outage Type</th> <th>Database Capabilities and Features</th> </tr> </thead> <tbody> <tr> <td><strong>Unplanned</strong></td> <td></td> </tr> <tr> <td>Computer failures</td> <td>• Oracle Database 10g with RAC</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Data Guard</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Streams</td> </tr> <tr> <td></td> <td>• Fast-Start Fault Recovery</td> </tr> <tr> <td>Storage failures</td> <td>• Automatic Storage Management</td> </tr> <tr> <td></td> <td>• Recovery Manager (RMAN)</td> </tr> <tr> <td></td> <td>• Flash Recovery Area</td> </tr> <tr> <td>Human errors</td> <td>• Oracle Security Features</td> </tr> <tr> <td></td> <td>• Oracle Flashback Technology</td> </tr> <tr> <td></td> <td>• LogMiner</td> </tr> <tr> <td>Data corruption</td> <td>• Block Checking</td> </tr> <tr> <td></td> <td>• Block Checksumming</td> </tr> <tr> <td></td> <td>• Hardware Assisted Resilient Data (HARD) Initiative</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Data Guard</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Streams</td> </tr> <tr> <td></td> <td>• Recovery Manager</td> </tr> <tr> <td></td> <td>• Flash Recovery Area</td> </tr> <tr> <td>Site failures</td> <td>• Oracle Database 10g with Data Guard</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Streams</td> </tr> <tr> <td></td> <td>• Recovery Manager (RMAN)</td> </tr> <tr> <td>Outage Type</td> <td>Database Capabilities and Features</td> </tr> <tr> <td>----------------</td> <td>----------------------------------------------------------------</td> </tr> <tr> <td><strong>Planned</strong></td> <td></td> </tr> <tr> <td>Data changes</td> <td>• Online Reorganization and Redefinition</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Data Guard</td> </tr> <tr> <td></td> <td>• Oracle Database 10g with Streams</td> </tr> <tr> <td>System changes</td> <td>• Automatic Storage Management</td> </tr> <tr> <td></td> <td>• Dynamic Resource Provisioning</td> </tr> <tr> <td></td> <td>• Rolling patch updates and system upgrades using Oracle Database 10g with RAC</td> </tr> <tr> <td></td> <td>• Rolling release upgrades and system upgrades using Oracle Database 10g with Data Guard or Oracle Database 10g with Streams</td> </tr> <tr> <td></td> <td>• Platform Migrations and Database Upgrades with Transportable</td> </tr> <tr> <td></td> <td>• Tablespace</td> </tr> </tbody> </table> Based on Oracle database functionalities and features provided in the above table, Figure 5 shows an implementation approach for a high availability database system architecture consisting of clustered database with a standby database for Oracle database software products. In Figure 5 above, Oracle 10g Real Application Clusters (RAC) is used to provide system redundancy for the database servers. The database servers are clustered. There is one database instance running on each of the clustered servers. The database instances can be set up in an active-active configuration for load balancing in which the database instances alternatively receive and process service requests from the web servers. Another option is to have the database instances set up in an active-passive configuration for system fail-over in which only one database instance is up (also known as the primary instance) and the other instance (secondary instance) is down but would be brought up automatically in the event that the primary instance is not functioning. DOJ program office would like to implement active-active configuration for the clustered database. servers for load balancing. In either case, both database instances share one set of database files normally located in a network storage array (NAS). The production database system is disrupted only when both database instances are not functioning. A standby database is used to receive the log files from the production database and serves as a backup database in the event that the production database system is totally in- operational. The database log files are transferred from the production database to the standby database using Oracle Streams or Data Guard feature. The standby database would be activated using Oracle Recovery Manger (RMAN) feature. When the standby database is activated, the web servers will be re-configured to connect to the standby database so that the system can operate normally while the production database environment is repaired. The activation of standby database is usually performed manually, but it can be automated if the criteria for the activation are well defined and can be programmed. For better system protection, the standby database should be located in a different geographical area from the production database site and safeguards should be put in place to reduce the chance that both production database site and standby database site getting hit by the same disaster be it natural or man made. This database system architecture ensures high availability with zero or little data loss. The only scenario that this database system architecture is out of service is when the production database servers and the standby database server are all in-operative. Figure 6 provides technical details on how primary Oracle database communicate with the standby database in the database system architecture (Oracle, September 2006). Legend: LGWR – Log Writer process writes redo log buffer from memory to online redo log file ARCn – Archive processes archives redo log files LNSn – LGWR Network Server processes RFS – Remote File Server process receives archived redo logs from primary database MRP – Managed Recovery Process applies information from archived redo logs LSP – Logical Standby Process applies completed SQL transactions from archived redo logs 4.3 Implementation Plan The implementation plan composes two stages. The first stage is to implement the clustered database servers. The second stage is to implement the standby database and integrate it into the database system architecture. The system architecture design allows the two stages to be built independently. Due to schedule constraints, DOJ program office decided to build and operate the system with just the database cluster for initial operational capability. The database cluster by itself can provide some degree of fault tolerance to the system. When the database cluster is operational in production, the program office will build and implement the standby database at another location, then integrate it into the system architecture. Since the production clustered database servers and the standby database server are located at different sites, it would take some time to work out the network communications for data transfer between the servers and enterprise system security issues at both sites. This section only describes the implementation plan for the first stage which is to implement the clustered database servers. The implementation plan provides an outline of database upgrade and migration tasks for each of the three DOJ application systems. The tasks involve upgrading database software from Oracle 9i to Oracle 10g and migrating existing database to a new infrastructure while ensuring that the current applications work with the new database system. A team of one database administrator, one system administrator, and two application developers is required to work on system migration and upgrade for the entire system architecture. Migration of application systems will be done at the same time but sequentially in the order determined by system priority. The implementation plan for each application system consists of three main tasks: 1. To set up an environment to perform tests and migration of Oracle production database from version 9.2 (Oracle 9i) to version 10.2 (Oracle 10g) without modifying the existing applications. 2. To build infrastructure of redundant web servers, application servers, and configure clustered database servers to maximize the availability and survivability of system operations. 3. To migrate applications and production database onto the new infrastructure. It is estimated that the tasks will be completed in 18 weeks for all three application systems. 4.3.1 Overview An Oracle database consists of two main components: database instance (which includes background processes running in the system memory) and database files (which reside on physical disks.) When the database runs on a single server, hardware problems such as processor failure, memory failure, or disk failure can stall the database operation. In the Oracle Real Application Cluster (RAC) configuration, database instances are set up across multiple servers or processors. These server processors are clustered to allow robust process management and scalability. The cluster can be expanded by adding additional servers to it to get more processing power. Database files of a RAC database normally reside on Redundant Arrays of Inexpensive Disks (RAID) or on Network Attached Storage (NAS). The RAID and NAS provide files protection and storage expansion capability. The current application system architecture consists of one application server and one database server. This configuration does not provide system fault tolerance. System operation can be disrupted when either application server or database server fails. The new system architecture consists of redundant application servers, Oracle Real Application Cluster database running on Sun cluster, and database files residing on network attached storage. The new architecture is designed to be fault tolerant and scalable. It also provides flexibilities including: - Application servers can be added to the architecture to handle additional transactions. - Servers can be added to expand the cluster to provide more processing power to the clustered database. - Disks can be added to NAS to provide more storage area for database files. 4.3.2 Scope The tasks in this implementation plan involve database and application server software installation, configuration, and testing. The scope and objectives of these tasks are as follows: - To set up a test environment to perform database migration and upgrade testing. - To configure and test new system architecture which includes redundant application servers, Oracle Real Application Cluster database on Sun cluster, and standby database. - To upgrade the current production database on a single server environment. To migrate the upgraded production database from single server environment to the new system architecture. These tasks will be performed under the assumption that the hardware, operating system, and network architecture are already set up and functioning. 4.3.3 Current System Architecture The following diagram depicts the current system architecture for the application system to be upgraded: ![Current System Architecture](image) **Figure 7: Current System Architecture** - **Hardware** The hardware of the current system architecture consists of a database server and an application server. Both servers are Sun450 servers. Each server has 1GB RAM and 4x9GB hard disks. There are no redundancy or dedicated backup servers in the current system architecture. - **Software** The current production database is running on Oracle 9i Enterprise Edition (version 9.2). The applications are written in Java, currently running on Tomcat 4.0 application server. The users access the applications through web browsers on their 4.3.4 Proposed System Architecture The proposed system architecture to be implemented for the first milestone is depicted in Figure 8 below. It is a subset of the database system architecture for fault tolerance and disaster recovery. ![Proposed System Architecture Diagram](image) **Figure 8: Proposed System Architecture** - **Hardware** The database for the proposed system architecture depicted above runs on a two-server cluster. The servers are Sun V880 servers. Each server has 2GB RAM and 4x9GB hard disks. The application servers consist of two redundant servers to provide load balancing and fail protection for the system. The servers are Sun V880 servers. Each server has 2GB RAM and 4x9GB hard disks. Network Attached Storage (NAS) provides disk space for RAC databases. The total disk storage capacity of NAS is 2 tetrabytes. NAS is provided by Network Appliance (NetApp) servers and configured by NetApp technicians under a product support contract. ● **Software** The database for the proposed system architecture runs on Oracle 10g Enterprise Edition (version 10.2.) on Solaris 10 operating system. The current Java applications will be migrated to Oracle 10g Application Server on Solaris 10 virtual servers. ### 4.3.5 Database Migration and Upgrade Test Plan - **Software Installation** The following are the tasks to be performed: - Install Oracle 10i Enterprise Edition database software on the new development and test database server - Install Oracle 10g Enterprise Edition database software on the new production database server - **Setup and Configuration** The following are the tasks to be performed: - Create and configure Oracle 10g database on the development and test database server - Create and configure Oracle 10g database on the production database server - Configure the test applications to work with Oracle 10g test database and Oracle 10g test database for parallel testing - Develop procedures to migrate Oracle 9i database to Oracle 10g database - **Testing** The following are the tasks to be performed: - Database upgrade from Oracle 9i to Oracle 10g procedures - Parallel testing on test applications on Oracle 9i and Oracle 10g databases 4.3.6 System Architecture Test Plan - **Software Installation** The following are the tasks to be performed: - Install and configure Solaris 10 and Oracle 10g Real Application Server (Oracle 10g RAC) on the clustered Sun V880 servers - Install and configure Solaris 10 virtual servers and Oracle 10g Application Server on the redundant Sun V880 application servers - Install Solaris 10 and Oracle 10g Enterprise Edition database software on the standby database server - **Setup and Configuration** The following are the tasks to be performed: - Create database instances on Oracle 10g RAC servers - Configure the database instances to work with database files on the storage area network - Configure the Oracle 10g Application Servers to work with the database instances on the Oracle 10g RAC servers - Create and configure Oracle 10g standby database on the standby database server - **Testing** The following are the tasks to be performed: - Oracle 10g RAC architecture testing - Standby database testing - System architecture testing 4.3.7 System Cut-over System cut-over will be carried out in two phases: - **Phase One:** Upgrade the database from Oracle 9i to Oracle 10g on single server configuration - **Phase Two:** Migrate Oracle 10g from single server configuration to clustered servers configuration 4.3.8 Timeline The following graph provides a timeline of the implementation tasks to be performed: *Figure 9: System Implementation Timeline* 4.4 Implementation Procedures This section provides procedures to implement Oracle 10g Real Application Clusters (RAC) and to perform database upgrade from Oracle 9i to Oracle 10g RAC on Sun Solaris servers as part of the implementation plan for the database system architecture described in section 4.3. 4.4.1 Oracle 10g RAC Software Installation The installation of Oracle 10g RAC software includes Oracle 10g Clusterware and Oracle 10g Database software. a. Install Oracle 10g Clusterware Follow the instructions in the Oracle Database Clusterware and Oracle Real Application Clusters Installation Guide 10g Release2 (10.2 for Solaris Operating System document to perform pre-installation tasks to prepare for the installation of Oracle 10g clusterware. When the pre-installation tasks are all done, follow these procedures to install Oracle Database 10g clusterware: 1. Verify that the kernel parameters in the /etc/system file are set to values greater than or equal to the recommended value: <table> <thead> <tr> <th>Parameter</th> <th>Recommended Value</th> </tr> </thead> <tbody> <tr> <td>noexec_user_stack</td> <td>1</td> </tr> <tr> <td>semsys:seminfo_semmni</td> <td>100</td> </tr> <tr> <td>semsys:seminfo_semmns</td> <td>1024</td> </tr> <tr> <td>semsys:seminfo_semmsl</td> <td>256</td> </tr> <tr> <td>semsys:seminfo_semmx</td> <td>32767</td> </tr> <tr> <td>shmsys:shminfo_shmmmax</td> <td>4294967295</td> </tr> <tr> <td>shmsys:shminfo_shmmin</td> <td>1</td> </tr> <tr> <td>Parameter</td> <td>Recommended Value</td> </tr> <tr> <td>-------------------------</td> <td>-------------------</td> </tr> <tr> <td>shmsys:shminfo_shmmni</td> <td>100</td> </tr> <tr> <td>shmsys:shminfo_shmseg</td> <td>10</td> </tr> </tbody> </table> 2. Run Cluster Verification Utility (CVU) to verify whether the servers are ready for Oracle clusterware installation by executing the following command on one of the servers to be clustered: ``` [oracle@tis06db cluvfy]$ <ORACLE_HOME>/runcluvfy.sh comp odereach -n node1,node2 -verbose ``` 3. Run Oracle Universal Installer to install Oracle Clusterware ``` $ <Oracle10g_clusterware_dir>/runInstaller ``` 4. Welcome screen (Click on Next) 5. Specify Inventory Directory and Credentials screen - Enter inventory directory path and OS group name (Click on Next) 6. Specify Home Details screen - Enter name and path for cluster home (Click on Next) 7. Product-Specific Prerequisite Checks screen (Click on Next) 8. Specify Cluster Configuration screen - Enter Cluster Name - Click “Add” and provide public, private, and virtual node names for cluster nodes (Click on Next) 9. Specify Network Interface Usage screen - Select Private and Public interfaces (Click on Next) 10. Specify Voting Disk Location screen - Check box for Normal Redundancy - Enter directory path for Voting Disks (Click on Next) 11. Summary screen (Click on Install) b. **Install Oracle Database 10g Release 2 Software** After installing Oracle Clusterware, follow the instructions in the Oracle Database Clusterware and Oracle Real Application Clusters Installation Guide 10g Release2 (10.2 for Solaris Operating System document to perform pre-installation tasks to prepare for the installation of Oracle Database 10g software. When the pre-installation tasks are all done, follow these procedures to install Oracle Database 10g software: 1. `<Oracle10g_sw>/runInstaller` 2. Select Installation Type screen appears. - Installation Type: Enterprise Edition (Click on Next) 3. Specify Home Details screen - Enter Oracle home name and path (Click on Next) 4. Specify Hardware Cluster Installation Mode screen - Check box for Cluster Installation (Click on Next) 5. Product-Specific Prerequisite Checks screen (Click on Next) 6. Select Configuration Option screen - Check the button for Install database Software only 7. Summary screen (Click on Install) 4.4.2 Oracle Database Upgrade from 9i to 10g This procedure describes the steps to create an Oracle 10g database using the Database Configuration Assistance (dbca) utility, export data from Oracle 9i database, and import the data into Oracle 10g database. a. Create Oracle 10g database 1. Run Database Configuration Assistance (dbca) utility $ dbca 2. Welcome screen appears (Click on Next) 3. DBCA Operations screen - Select Create a Database (Click on Next) 4. DBCA Template screen - Select Custom Database (Click on Next) 5. DBCA Database Identification screen - Enter Global Database Name and SID (Click on Next) 6. DBCA Management Options screen - Select Configure the Database with Enterprise Manager (Click on Next) 7. DBCA Database Credentials screen - Enter password: [enter password] (Click on Next) 8. DBCA Storage Options screen - Select File System (Click on Next) 9. DBCA Database File Locations screen - Select Use Database File Locations from Template (Click on Next) 10. DBCA Storage Options screen - Select Specify Flash Recovery Area and enter a directory location for it (Click on Next) 11. DBCA Database Content screen - Do not check Sample Schemas (Click on Next) 12. DBCA Initialization Parameters screen - Memory tab: . Select Typical 30 percent of physical memory - Connection Mode tab: . Select shared server mode and share server: 10 (Click on Next) 13. DBCA Database Storage screen - Enter the directory and file names for database files (Click on Next) 14. DBCA Database Creation Options screen - Select Create Database - Select Save as a Database Template - Select Generate Database Creation Scripts (Click on Finish) b. **Create Tablespaces** Create tablespaces that exist in production database for the Oracle 10g database. c. **Database Export and Import** Perform database export from the production database (Oracle 9i database) and import the data into the Oracle 10g database. Chapter 5 – Project History 5.1 How the project began This project was based on a system development task order searching for solutions to implement high availability database system architecture to migrate three existing database application systems from single server architectures to fail-safe consolidated database system architecture for the DOJ program office. The project mainly focused on the available technologies provided by major database software vendors that can be recommended to the DOJ program office funding the project. Research for the project took about three months from March to May 2007. Project follow-on work as outlined in the project plan started in June 2007 and was completed in December 2007. Each phase was successfully executed according to plan and met the scheduled timeline. 5.2 Changes to the project plan The original goal of the project was to present different technologies and system architectures provided by the major database vendors such as Oracle, IBM, and Microsoft for comparisons before recommending for a solution. However, there were so much research materials gathered on the subject from these database vendors and other hardware and software vendors that they became overwhelming and posed some risks of getting the project running out of scope and out of schedule. Therefore, rather than going in depth with all available database products, only Oracle database technology was used to develop activities involved in the design, development, and implementation of high availability database system architecture. Furthermore, the DOJ program office heavily leaned toward Oracle database software products to ease the learning curve for its technical staff and to speed up the implementation timeline. 5.3 What went right and what went wrong One of the utmost concerns for this project was to narrow down the scope of the project and to get the problem solved within a reasonable amount of time that the DOJ program office had set out. Throughout the project, the scope of the project was kept in focus by searching for workable solution and narrowing the research to find relevant materials supporting the project goal. A considerable amount of time spent in the research and a lot of research materials were gathered and analyzed. Nevertheless, the research effort deemed to be very worthwhile. Considerable research material had not been included so that it would not distract from the main objectives or to run the project out of scope. Decisions had been made quickly on defining system requirements and to select a workable solution to complete the project on schedule. 5.4 Project variables and their impact This project aimed to build a small scale database system architecture to keep the scope of project in focus while still maintain the complexity of designing, developing, and implementing a high-availability database system architecture. The simple system design presented can be easily scaled up to include additional servers or operational sites as required. The design can also be scaled down to just include must-have functionalities and to forgo those options that may not be needed or could not be afforded - to keep costs within budget if funding was one of the deciding factors. The personnel needed to carry out the project plan would depend on the scale of the project such as the number of servers and sites to be implemented to handle specific needs of the organization. 5.5 Results summary The project addressed major concerns and offered realistic solution for building high-availability database system architecture. It also provided detailed analysis, system design, development, and implementation that could be readily applied and tailored for practical business application systems especially for those systems utilizing Oracle database technology. Customized system design and implementation can certainly be derived from the analysis and study presented in the project paper. The project achieved the main objectives and delivered effective system architecture design for high availability database system architecture for the DOJ program office. Chapter 6 – Lesson Learned 6.1 What was learned from the project experience There were many things that had been learned throughout the project such as project management, time management, organization, and decision making process. Other important skills that had been also acquired or enhanced include research, documentation, and presentation. The project also offered an opportunity to study cutting edge and advanced technologies in database related hardware and software from various database and systems vendors. 6.2 Did project meet initial project expectations The project was set out to present different database technologies for fault tolerance and disaster recovery. Though technologies offered by database vendors may be different in implementation, they all follow the same common disaster recovery strategy. A great percentage of time involved was devoted in studying a particular database software product that the DOJ program office had selected. An implementation plan was successfully developed and executed. This project may be considered a case study for someone who may be looking for such a solution. The material provided in the project paper aim to make the goal of the project succinct, practical, valuable, and worthwhile to study. 6.3 Next stage of project if it continued The next stage is to develop the implementation plan for the second stage of the project which is to implement the standby database and integrate it into the system architecture. Overall, this project can certainly be applied to other business case scenarios that have similar objectives. It may require a considerable investment of financial and human resources to implement the proposed database system architecture in a larger scale. A team consisting of ten or more system analysts, system engineers, database administrators, and application developers may be needed to implement larger scale database system architecture. There is also a need for system maintenance and upgrade after implementation to keep the system up to date with the advance of technologies. 6.4 Conclusions/recommendations Developing reliable database system architecture requires great effort to analyze the risks that can affect the operations of the system so that proper measures can be planned and implemented into the system to mitigate the risks of system disruption when a disaster occurs. The system capabilities must be clearly defined in the system requirements analysis. The analysis phase has to be done throughout with all of the perceived system risks identified so that preventive measures and procedures can be developed to minimize the risks. When the requirements in the analysis phase are changed, sometimes it is hard to propagate the change down the road once the analysis phase has been finalized. A particular instance is that it would be difficult to change the system design after the equipment are already purchased for the scale and functions specified in the analysis phase. One of the approaches that can be used to implement this project is to divide the project into modules so that different components can be added to the system and each module can be modified independently without affecting the entire system architecture. The system architecture should be designed to be scaled up for additional capabilities and functionalities as much as possible. References Retrieved March 5, 2008 from http://portal.acm.org/citation.cfm?id=1296454 Bruni, Paolo et al. (2004). Disaster Recovery with DB2™ UDB for z/OS. IBM Redbooks. Appendix A System Requirements Questionnaire The following are questions that were used to assist in gathering information and provide specifications for database disaster recovery requirements analysis for the DOJ applications. 1. What is the disaster recovery classification required for these applications? 2. How much data can the DOJ program office afford to lose when a disaster happens? 3. How much of system performance degradation is acceptable during a disaster? 4. How often would the program office test and validate the disaster recovery functionalities of the system architecture? (once a year, twice a year, or at other predetermined intervals) 5. What criteria determine the disaster recovery to be put in place for these applications? 6. Do these applications send data to or receive data from other applications? How often is the data exchange? How long each data exchange last? 7. Do these applications interact with other database systems using different database software such as SQL Server, Sybase, Informix, DB2, MySQL, etc.? 8. How big are the databases now? How much will they grow in the next six months, one year, two years, and five years? 9. Are databases updated via online application transactions, batch processes, data feeds, etc.? 10. If data loss occurs after a disaster, is there a way to re-enter the data into database via online transaction processing (OLTP), batch processes, data feeds, or other methods? 11. If network bandwidth must be allocated to support a standby database, what is the average data transfer rate in MB per minute to support the archive logs transfer? 12. What file systems are required by the applications (include file systems for software products, application binaries, external feeds, and so forth) that should be included in the disaster recovery procedures? 13. How do users access the production systems? How should users access the systems in a disaster scenario? 14. Is there a need to build a separate and identical architecture for development and test environments? 15. Are development machines going to be used as alternate servers for disaster recovery? 16. Will the development environment need to be up and running during a disaster?
{"Source-Url": "https://epublications.regis.edu/cgi/viewcontent.cgi?article=1055&context=theses", "len_cl100k_base": 15847, "olmocr-version": "0.1.50", "pdf-total-pages": 68, "total-fallback-pages": 0, "total-input-tokens": 108063, "total-output-tokens": 18645, "length": "2e13", "weborganizer": {"__label__adult": 0.0005135536193847656, "__label__art_design": 0.000804901123046875, "__label__crime_law": 0.000957489013671875, "__label__education_jobs": 0.0197906494140625, "__label__entertainment": 0.0002264976501464844, "__label__fashion_beauty": 0.0002684593200683594, "__label__finance_business": 0.003398895263671875, "__label__food_dining": 0.0004191398620605469, "__label__games": 0.0010662078857421875, "__label__hardware": 0.0041961669921875, "__label__health": 0.0008273124694824219, "__label__history": 0.0008087158203125, "__label__home_hobbies": 0.0002276897430419922, "__label__industrial": 0.0014657974243164062, "__label__literature": 0.0006232261657714844, "__label__politics": 0.0004220008850097656, "__label__religion": 0.0005388259887695312, "__label__science_tech": 0.349365234375, "__label__social_life": 0.0002038478851318359, "__label__software": 0.058837890625, "__label__software_dev": 0.5537109375, "__label__sports_fitness": 0.0002104043960571289, "__label__transportation": 0.0007152557373046875, "__label__travel": 0.00023305416107177737}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 86088, 0.02454]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 86088, 0.34238]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 86088, 0.88682]], "google_gemma-3-12b-it_contains_pii": [[0, 731, false], [731, 1826, null], [1826, 2730, null], [2730, 3301, null], [3301, 6567, null], [6567, 8266, null], [8266, 9383, null], [9383, 10347, null], [10347, 10807, null], [10807, 12429, null], [12429, 14221, null], [14221, 15729, null], [15729, 16671, null], [16671, 18021, null], [18021, 19890, null], [19890, 20515, null], [20515, 21374, null], [21374, 22706, null], [22706, 23731, null], [23731, 25469, null], [25469, 27176, null], [27176, 27953, null], [27953, 29900, null], [29900, 30731, null], [30731, 32561, null], [32561, 34336, null], [34336, 35994, null], [35994, 37698, null], [37698, 39351, null], [39351, 41101, null], [41101, 41264, null], [41264, 42249, null], [42249, 43891, null], [43891, 45611, null], [45611, 45732, null], [45732, 46669, null], [46669, 49273, null], [49273, 50377, null], [50377, 51104, null], [51104, 52741, null], [52741, 54119, null], [54119, 55485, null], [55485, 56353, null], [56353, 57963, null], [57963, 58558, null], [58558, 60358, null], [60358, 61880, null], [61880, 63244, null], [63244, 64278, null], [64278, 65250, null], [65250, 66523, null], [66523, 67617, null], [67617, 68040, null], [68040, 69468, null], [69468, 70655, null], [70655, 71798, null], [71798, 72767, null], [72767, 73630, null], [73630, 73899, null], [73899, 75514, null], [75514, 77358, null], [77358, 78044, null], [78044, 79684, null], [79684, 81417, null], [81417, 83508, null], [83508, 83867, null], [83867, 85135, null], [85135, 86088, null]], "google_gemma-3-12b-it_is_public_document": [[0, 731, true], [731, 1826, null], [1826, 2730, null], [2730, 3301, null], [3301, 6567, null], [6567, 8266, null], [8266, 9383, null], [9383, 10347, null], [10347, 10807, null], [10807, 12429, null], [12429, 14221, null], [14221, 15729, null], [15729, 16671, null], [16671, 18021, null], [18021, 19890, null], [19890, 20515, null], [20515, 21374, null], [21374, 22706, null], [22706, 23731, null], [23731, 25469, null], [25469, 27176, null], [27176, 27953, null], [27953, 29900, null], [29900, 30731, null], [30731, 32561, null], [32561, 34336, null], [34336, 35994, null], [35994, 37698, null], [37698, 39351, null], [39351, 41101, null], [41101, 41264, null], [41264, 42249, null], [42249, 43891, null], [43891, 45611, null], [45611, 45732, null], [45732, 46669, null], [46669, 49273, null], [49273, 50377, null], [50377, 51104, null], [51104, 52741, null], [52741, 54119, null], [54119, 55485, null], [55485, 56353, null], [56353, 57963, null], [57963, 58558, null], [58558, 60358, null], [60358, 61880, null], [61880, 63244, null], [63244, 64278, null], [64278, 65250, null], [65250, 66523, null], [66523, 67617, null], [67617, 68040, null], [68040, 69468, null], [69468, 70655, null], [70655, 71798, null], [71798, 72767, null], [72767, 73630, null], [73630, 73899, null], [73899, 75514, null], [75514, 77358, null], [77358, 78044, null], [78044, 79684, null], [79684, 81417, null], [81417, 83508, null], [83508, 83867, null], [83867, 85135, null], [85135, 86088, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 86088, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 86088, null]], "pdf_page_numbers": [[0, 731, 1], [731, 1826, 2], [1826, 2730, 3], [2730, 3301, 4], [3301, 6567, 5], [6567, 8266, 6], [8266, 9383, 7], [9383, 10347, 8], [10347, 10807, 9], [10807, 12429, 10], [12429, 14221, 11], [14221, 15729, 12], [15729, 16671, 13], [16671, 18021, 14], [18021, 19890, 15], [19890, 20515, 16], [20515, 21374, 17], [21374, 22706, 18], [22706, 23731, 19], [23731, 25469, 20], [25469, 27176, 21], [27176, 27953, 22], [27953, 29900, 23], [29900, 30731, 24], [30731, 32561, 25], [32561, 34336, 26], [34336, 35994, 27], [35994, 37698, 28], [37698, 39351, 29], [39351, 41101, 30], [41101, 41264, 31], [41264, 42249, 32], [42249, 43891, 33], [43891, 45611, 34], [45611, 45732, 35], [45732, 46669, 36], [46669, 49273, 37], [49273, 50377, 38], [50377, 51104, 39], [51104, 52741, 40], [52741, 54119, 41], [54119, 55485, 42], [55485, 56353, 43], [56353, 57963, 44], [57963, 58558, 45], [58558, 60358, 46], [60358, 61880, 47], [61880, 63244, 48], [63244, 64278, 49], [64278, 65250, 50], [65250, 66523, 51], [66523, 67617, 52], [67617, 68040, 53], [68040, 69468, 54], [69468, 70655, 55], [70655, 71798, 56], [71798, 72767, 57], [72767, 73630, 58], [73630, 73899, 59], [73899, 75514, 60], [75514, 77358, 61], [77358, 78044, 62], [78044, 79684, 63], [79684, 81417, 64], [81417, 83508, 65], [83508, 83867, 66], [83867, 85135, 67], [85135, 86088, 68]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 86088, 0.13831]]}
olmocr_science_pdfs
2024-12-01
2024-12-01
bf31a97769f83515f63f0b28f6e02665daf5859b
IMPLEMENTATION AND SIMULATION OF SECURE SOCKETS LAYER (SSL) IN WINDOWS PRESENTATION FOUNDATION by Harsh Vachharajani A Thesis Submitted to the Graduate Faculty of George Mason University in Partial Fulfillment of The Requirements for the Degree of Master of Science Information Security and Assurance Committee: _____________________________ Dr. Kris Gaj, Thesis Director _____________________________ Dr. Jim Jones, Committee Member _____________________________ Dr. Robert Simon, Committee Member _____________________________ Dr. Sanjeev Setia, Department Chair _____________________________ Dr. Kenneth S. Ball, Dean, The Volgenau School of Engineering Date: _________________________ Summer Semester 2015 George Mason University Fairfax, VA Implementation and Simulation of Secure Sockets Layer (SSL) in Windows Presentation Foundation A Thesis submitted in partial fulfillment of the requirements for the degree of Master of Science at George Mason University by Harsh Vachharajani Bachelor of Technology Ganpat University, India, 2013 Director: Kris Gaj, Associate Professor Department of Electrical and Computer Engineering Summer Semester 2015 George Mason University Fairfax, VA I would not miss this opportunity to thank many people involved with my successful completion of the thesis, without whom I could not possibly think of having achieved this goal. My biggest gratitude goes to my thesis director Dr. Kris Gaj, under whom I initiated my research work, further extending it into a thesis, who guided and helped me at each and every step and had a great contribution toward my successful completion of the thesis. Drs. Jones and Simon, the other two members of my committee were of invaluable help in my research. I would like to especially thank two of my friends, Vikram Gawade and Tejas Dakve, for their invaluable input and contribution of their selfless help to my research, implementation, and solving any issues when I was stuck. A big thanks also goes to Devin Kim, a student under Dr. Gaj’s supervision, who helped to review some portions of my thesis for improvements. # TABLE OF CONTENTS <table> <thead> <tr> <th>Section</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>List of Tables</td> <td>vi</td> </tr> <tr> <td>List of Figures</td> <td>vii</td> </tr> <tr> <td>List of Abbreviations</td> <td>viii</td> </tr> <tr> <td>Abstract</td> <td>ix</td> </tr> <tr> <td>Chapter 1: Introduction</td> <td>1</td> </tr> <tr> <td>Chapter 2: Previous Work</td> <td>4</td> </tr> <tr> <td>2.1 CrypTool</td> <td>4</td> </tr> <tr> <td>2.1.1 CrypTool 1</td> <td>4</td> </tr> <tr> <td>2.1.2 CrypTool 2 (CT2)</td> <td>6</td> </tr> <tr> <td>2.1.3 J CrypTool</td> <td>7</td> </tr> <tr> <td>2.1.4 CrypTool Online (CTO)</td> <td>9</td> </tr> <tr> <td>2.2 MAGMA</td> <td>10</td> </tr> <tr> <td>2.3 SageMath</td> <td>11</td> </tr> <tr> <td>2.4 GnuPG</td> <td>12</td> </tr> <tr> <td>Chapter 3: Background Of SSL/TLS and Attacks on it</td> <td>14</td> </tr> <tr> <td>3.1 Differences between SSL and TLS</td> <td>15</td> </tr> <tr> <td>3.1.1 TLS 1.0</td> <td>17</td> </tr> <tr> <td>3.1.2 TLS 1.1</td> <td>17</td> </tr> <tr> <td>3.1.3 TLS 1.2</td> <td>18</td> </tr> <tr> <td>3.2 Different public-key exchange methods supported in SSL/TLS</td> <td>19</td> </tr> <tr> <td>3.2.1 RSA</td> <td>19</td> </tr> <tr> <td>3.2.2 Fixed Diffie-Hellman (DH)</td> <td>20</td> </tr> <tr> <td>3.2.3 Ephemeral Diffie-Hellman (EDH)</td> <td>20</td> </tr> <tr> <td>3.2.4 Anonymous Diffie-Hellman</td> <td>21</td> </tr> <tr> <td>3.3 Use of MAC and HMAC</td> <td>21</td> </tr> <tr> <td>3.4 Use of Symmetric cipher suites</td> <td>23</td> </tr> </tbody> </table> 3.5 SSL Handshake ................................................................. 24 3.6 SSL Record Layer ............................................................... 27 3.7 Attacks on SSL / TLS .......................................................... 29 3.7.1 Cipher Suite Rollback Attack ........................................... 29 3.7.2 Version Rollback Attack .................................................. 30 3.7.3 BEAST .................................................................................. 30 3.7.4 POODLE ............................................................................... 31 3.7.5 HeartBleed Attack ............................................................. 31 Chapter 4: Development Tools and Libraries ........................................ 33 4.1 OpenSSL ................................................................................. 35 4.2 MSDN Library ................................................................. 36 4.3 Mentalis ............................................................................... 37 Chapter 5: Implementation ................................................................. 40 5.1 The Handshake Phase .......................................................... 40 5.1.1 Welcome Screen ............................................................. 40 5.1.2 Generation of Certificate ................................................ 41 5.1.3 Mode Selection .............................................................. 44 5.1.4 The Handshake Protocol ................................................ 44 5.1.5 The Record Protocol ...................................................... 46 5.2 Use of library functions in the implementation ......................... 50 Chapter 6: Conclusion and Future work ............................................. 53 References .................................................................................. 55 LIST OF TABLES <table> <thead> <tr> <th>Table</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>Table 1: Difference between SSL version 2 and SSL version 3</td> <td>15</td> </tr> <tr> <td>Table 2: Library functions used in our program,</td> <td>50</td> </tr> </tbody> </table> # LIST OF FIGURES <table> <thead> <tr> <th>Figure</th> <th>Page</th> </tr> </thead> <tbody> <tr> <td>Figure 1: Without SSL [16]</td> <td>1</td> </tr> <tr> <td>Figure 2: Insecure communication – example [15]</td> <td>2</td> </tr> <tr> <td>Figure 3: With SSL [16]</td> <td>3</td> </tr> <tr> <td>Figure 4: CrypTool 1: Example of a histogram representing relative frequencies of letters in English language</td> <td>5</td> </tr> <tr> <td>Figure 5: CrypTool 2: Example of encryption, decryption, and comparison between the original and decrypted message</td> <td>7</td> </tr> <tr> <td>Figure 6: JcrypTool GUI</td> <td>8</td> </tr> <tr> <td>Figure 7: Fixed Diffie-Hellman</td> <td>20</td> </tr> <tr> <td>Figure 8: Ephemeral Diffie-Hellman</td> <td>21</td> </tr> <tr> <td>Figure 9: CBC-MAC</td> <td>22</td> </tr> <tr> <td>Figure 10: HMAC</td> <td>23</td> </tr> <tr> <td>Figure 11: SSL Handshake steps [13]</td> <td>24</td> </tr> <tr> <td>Figure 12: SSL Record Protocol [8]</td> <td>28</td> </tr> <tr> <td>Figure 13 MSDN library hierarchy example</td> <td>36</td> </tr> <tr> <td>Figure 14 MSDN library hierarchy example</td> <td>39</td> </tr> <tr> <td>Figure 15: Welcome Screen</td> <td>41</td> </tr> <tr> <td>Figure 16: Certificate Generation</td> <td>42</td> </tr> <tr> <td>Figure 17: Certificate Generation – Server Details window</td> <td>43</td> </tr> <tr> <td>Figure 18: Mode Selection window</td> <td>44</td> </tr> <tr> <td>Figure 19: Demo mode Handshake window</td> <td>45</td> </tr> <tr> <td>Figure 20: The Record Protocol</td> <td>46</td> </tr> <tr> <td>Figure 21: Attack selection window</td> <td>47</td> </tr> <tr> <td>Figure 22: Handshake window for Man-in-the-middle attack</td> <td>49</td> </tr> </tbody> </table> LIST OF ABBREVIATIONS Advanced Encryption Standard .............................................................. AES Application Programming Interface ......................................................... API Certification Authority .............................................................................. CA Cipher Block Chaining .............................................................................. CBC Data Encryption Standard ......................................................................... DES Digital Signature Algorithm ....................................................................... DSA Hashed Message Authentication Code ....................................................... HMAC Hyper-Text Transfer Protocol Secure ......................................................... HTTPS Hyper-Text Transfer Protocol ................................................................... HTTP Initialization Vector ..................................................................................... IV Message Authentication Code ................................................................. MAC Message Digest ........................................................................................... MD Microsoft Developer Network ...................................................................... MSDN Secure Hash Algorithm ............................................................................. SHA Secure Sockets Layer .................................................................................. SSL Transport Layer Security ............................................................................. TLS Windows Presentation Foundation ............................................................ WPF World Wide Web ......................................................................................... WWW ABSTRACT IMPLEMENTATION AND SIMULATION OF SECURE SOCKETS LAYER (SSL) IN WINDOWS PRESENTATION FOUNDATION Harsh Vachharajani, M.S. George Mason University, 2015 Thesis Director: Dr. Kris Gaj SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are cryptographic protocols designed to provide secure communication between a web server and a web browser. This thesis introduces a unique approach to understanding SSL and TLS by visualizing these protocols through simulation in WPF (Windows Presentation Foundation). This approach is intended to help students to get a clearer picture of how these protocols actually work by clearly illustrating all steps of SSL and TLS, including the handshake and the record protocols. CHAPTER 1: INTRODUCTION In the rapidly growing technology era, WWW (World Wide Web) provides a platform for exchanging data, such as text, images, videos, etc. There is a growing need to protect this data, as the exchanged information might be sensitive or confidential. An attacker might intercept the data and try to manipulate it by modifying it, thus violating confidentiality and/or integrity of the message. Figure 1: Without SSL [16] As shown in Fig. 2, a user may be sending a message to the recipient on the opposite side via Gmail, and the recipient may be receiving it using his Yahoo account. Then, the connection between the User and the Gmail server, connection between the Gmail server and the Yahoo server, and the connection between the Yahoo server and the Recipient’s computer can be all sniffed by an attacker, such as a hacker, if they are not secured. In order to protect data being transmitted, we use SSL or TLS, which are cryptographic protocols providing security for the communication over an insecure channel. These protocols establish an encrypted and authenticated connection between a web server and a web browser. With the use of SSL/TLS, an attacker can still intercept the data, however, as the data is encrypted, the attacker is not able to extract any useful information from transmitted packets. Thus, the confidentiality and integrity of the message are preserved. As a part of this thesis, I will try to illustrate the operation of SSL/TLS in a practical manner, visualizing the SSL handshake and the record layer protocols through simulation, with the help of a desktop-based application, developed in C# programming language, using WPF (Windows Presentation Foundation), working in Visual Studio 2013. To enhance this application’s functionality, I have made use of inbuilt MSDN cryptographic library along with the external SSL library named Mentalis Security Library, also developed in C#, which explicitly provides various security related functions, grouped into SecureSocket Library, CertificateServices Library and Crypto Library. Figure 3: With SSL [16] CHAPTER 2: PREVIOUS WORK There exist several open-source programs, which can be used for teaching cryptography. The most important ones include CrypTool, MAGMA, SageMath, and GnuPG (Gnu Privacy Guard). 2.1 CrypTool CrypTool is an open-source e-learning software, available for free. The system allows users to experiment with various cryptographic algorithms. The CrypTool project develops the world most-widespread free e-learning programs in the area of cryptography and cryptanalysis. The CrypTool Portal is devoted to several different versions of software, such as CrypTool 1 (CT1), CrypTool 2 (CT2), JCrypTool (JCT), and CrypTool Online (CTO). 2.1.1 CrypTool 1 CrypTool 1 (CT1) was the first version of CrypTool. It was released in 1998 and allows to experiment with various cryptographic algorithms. CT1 is written in C++ and runs under Windows OS. It is available in 5 languages, and is the most wide-spread e-learning software of its kind. It can be used for educational purposes in schools and universities. In particular, CrypTool 1 includes implementations of: - Numerous classical and modern cryptographic algorithms (encryption, decryption, and key generation) - Visualization of several algorithms and cryptographic schemes (Caesar, Enigma, RSA, Diffie-Hellman, digital signatures, AES, etc.) - Cryptanalysis of several algorithms (e.g., Vigenère and RSA with small moduli sizes) - Cryptanalytical methods (e.g., calculations of entropy, n-grams, autocorrelation, etc.) - Related auxiliary methods (primality tests, factorization, base64 encoding, etc.) Figure 4: CrypTool 1: Example of a histogram representing relative frequencies of letters in English language. 2.1.2 CrypTool 2 (CT2) CrypTool 2 is the modern successor to CrypTool 1 and supports visual programming and execution of cascades of cryptographic operations. CT2 also runs under Windows. CT2 provides various functionalities such as, Modern Plug’n’Play Interface / Visual Programming - CrypTool 2 provides a graphical user interface for visual programming, and its workflows can be visualized and controlled to enable intuitive manipulation and interaction among various cryptographic functions. The vector-oriented GUI is based on the Windows Presentation Foundation (WPF), which enables users to visualize the functionality of a particular module and understand it in a better way. CrypTool 2 has been developed using C# language. It is based on .NET Framework, and has a pure-plugin architecture, which makes it very easy to develop new additional functions. Comprehensive Cryptanalysis Functions – CrypTool 2 provides a variety of cryptanalytical tools to analyze or even break classical and modern ciphers. With the current version one can, for instance, apply a ciphertext-only attack on an Enigma-encrypted ciphertext. Plenty of other cryptanalysis functions are also available, such as performing frequency tests to find n-grams and assessing the length of a codeword used for a polyalphabetic cipher. Figure 5: CrypTool 2: Example of encryption, decryption, and comparison between the original and decrypted message. CT2 also is an open-source project, licensed under Apache Open Source License 2.0, and anyone is welcome to contribute to this project. 2.1.3 JCrypTool JCrypTool (JCT) is an open-source e-learning platform that allows users to experiment comprehensively with cryptography on Linux, MAC OS X, and Windows. The program enables analysing cryptographic algorithms in a modern, easy-to-use application. JCT platform creates a new way for the users to develop their own cryptographic plug-ins and extend the JCrypTool platform in new directions. JCT is written in Java and has an Eclipse Rich Client Platform. It includes plenty of cryptographic mechanisms, such as classical, symmetric, and asymmetric ciphers, hash functions, analysis tools, visualizations, and crypto games. JCT is divided into two parts: JCrypTool Core and JCrypTool Crypto. The JCrypTool Core Project takes care of the JCrypTool platform, which contains the bare runtime functions, editors, and crypto procedures, as well as core functionality, such as the Crypto Explorer view or the Actions view. The JCrypTool Crypto Project’s aim is to develop new crypto plug-ins (algorithms, analysis, games, visualizations and others) and integrate them into the JCrypTool. Figure 6: JCrypTool GUI. 2.1.4 CrypTool Online (CTO) CrypTool Online, released in 2009, is the online version of the free e-learning program CrypTool. It allows users to try out different algorithms in a browser or on a smartphone. It provides a huge variety of encryption methods and analysis tools, including many illustrated by examples. It encrypts directly within a browser and provides an exciting insight into the world of cryptology. CrypTool Online is primarily intended for studying the fundamentals of classical ciphers. The download version of CrypTool is also suitable for working with longer texts and conducting high performance analyses on encrypted messages. Additionally, CTO includes a Password generator which provides a user with a safe key. The user can also learn about what a “good” password is and how to remember a seemingly complicated password without a problem. We looked at different open source projects in the area of cryptology. The software which matches most closely the work being done in this thesis is CrypTool. Comparing different versions of CrypTool, CT2 is the best version in terms of visualization of algorithms through simulation, where a user can understand the algorithm / protocol in a much better way, which is the main goal of any educational software. However neither SSL nor TLS protocols have been incorporated in this tool. Hence, our initial idea was to develop their implementations in CT2. Unfortunately, due to the way CT2 operates, this task appeared to be impossible to accomplish, without a substantial redesign of the program. As a result, I decided to develop an educational program devoted to SSL/TLS as a standalone application, which would serve the same purpose as CrypTool, in order to maintain the goal of demonstrating / learning the protocol in an interactive matter. This application was developed with the help of the same development tools, namely, the Windows Presentation Foundation (WPF). 2.2 MAGMA Magma (also known as Matrix Algebra on GPU and Multicore Architectures) is a freely available software, designed for computations in algebra, number theory, algebraic geometry, and algebraic combinatorics. Magma provides an environment for working with structures such as groups, rings, fields, modules, algebras, schemes, curves, graphs, designs, codes and many others. The main feature is to be able to construct canonical representations of structures, hence making operations such as membership testing, the determination of structural properties, and isomorphism testing, possible. Magma contains implementation of structures in five branches of algebra: group theory, ring theory, field theory, module theory, and the theory of algebras. The main features of the Magma include: - Algebraic Design Philosophy - Universality - Integration - Performance. Magma can be used to easily encode all public key operations used in SSL and TLS, but it lacks support for secret-key cryptography. 2.3 SageMath SageMath is a free open-source mathematics software system, which supports research and teaching in algebra, geometry, number theory, cryptography, numerical computation, and related areas. The system is licensed under the GPL. It builds on top of many existing open-source packages: NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R, and many more. SageMath uses the Python programming language, supporting procedural, functional, and object-oriented constructs. The main purpose of SageMath was to create a viable open-source alternative to Magma, Maple, Mathematica, and Matlab. Some of the features of SageMath include: - A text-based command-line interface using IPython - Support for parallel processing using multi-core processors, multiple processors, or distributed computing - Libraries of elementary and special mathematical functions - Libraries of number theory functions - Support for complex numbers, arbitrary precision, and symbolic computation. Sage integrates many specialized mathematics software packages into a common interface, for which a user needs to know only Python. However, Sage contains hundreds of thousands of unique lines of code, adding new functions, and creating the interface between its components. Both binaries and source code for SageMath are available from the download page [30, 31]. SageMath is available for multiple operating systems, including Windows, Linux, OS X, and Solaris. Similarly to Magma, SageMath can be used to easily encode all public key operations used in SSL and TLS, but it lacks support for secret-key cryptography. 2.4 GnuPG GnuPG (also known as Gnu Privacy Guard) is a free software replacement for the PGP suite of Symantec software. It is a complete and free implementation of the OpenPGP standard, designed to interoperate with PGP; the e-mail encryption program. GnuPG is a hybrid encryption software program in that it uses a combination of conventional symmetric-key cryptography for speed, and public-key cryptography for ease of secure key exchange, typically by using the recipient's public key to encrypt a session key, which is used only once. There are different versions of GnuPG. GnuPG 2.x series use Libgcrypt as an encryption library, while GnuPG 1.x series use an integrated library. GnuPG encrypts messages using asymmetric key pairs, individually generated by GnuPG users. Public keys may be exchanged with other users in various ways, e.g., using Internet key servers. It is also possible to add a cryptographic digital signature to a message, so the message integrity and sender identity can be verified. GnuPG also supports symmetric encryption algorithms. At the time of writing this thesis, GnuPG supports the following algorithms: Public key: RSA, ElGamal, DSA Secret key: IDEA, 3DES, CAST5, Blowfish, AES-128, AES-192, AES-256, Twofish, Camellia-128, Camellia-192, Camellia-256 Hash: MD5, SHA-1, RIPEMD-160, SHA-256, SHA-384, SHA-512, SHA-224 Compression: ZIP, ZLIB, BZIP2. Some of the applications that support GPG includes: Claws mail – an email client with GPG plugin GPG4win - a Windows package with tools and manuals for email and file encryption GPGMail – an OS X Mail.app plug-in GPGTools – an OS X package with tools for email and file encryption (GPGMail, GPG Keychain Access, MacGPG2, GPG Services, etc.). The source codes of GnuPG could be used as a basis for our program, however using them would require a substantial effort devoted to rewriting some functions (as the OpenPGP protocol is different than SSL/TLS) and mixing code written in different programming languages. CHAPTER 3: BACKGROUND OF SSL/TLS AND ATTACKS ON IT SSL (Secure Sockets Layer) is a cryptographic protocol designed to provide secure communication over a computer network. It is a standard technology that establishes an encrypted link between a server and a client – typically a web server and a browser. HTTPS (also called HTTP over TLS) is HTTP (Hypertext Transfer Protocol) protected by SSL or TLS. The SSL protocol includes two sub-protocols: the SSL record protocol and the SSL handshake protocol. The SSL record protocol defines the format used to exchange data. The SSL handshake protocol involves a series of messages being exchanged between an SSL-enabled server and an SSL-enabled client, when they first establish an SSL connection, which happens before the SSL record protocol. This exchange of messages serves the following purposes: • Authenticate the server to the client. • Allow the client and server to select the cryptographic algorithms, or ciphers, that they both support. • Optionally authenticate the client to the server. • Use public-key encryption techniques to generate shared secrets. • Establish an encrypted SSL connection. The SSL protocol supports a variety of different cryptographic algorithms. It allows various algorithms to be used in operations, such as, authenticating the server and client to each other, exchanging certificates, and establishing session keys. Clients and servers may support different sets of cipher suites, depending on the SSL version they support. Among its other functions, the SSL handshake protocol determines how the server and client will decide on which cipher suites they will use to authenticate each other, to exchange certificates, and to establish session keys. The protocol combines the following three points to provide communication security: - Privacy - connection through encryption, - Identity authentication – identification through certificates, - Reliability – dependable maintenance of a secure connection through message integrity checking. ### 3.1 Differences between SSL and TLS SSL was developed by Netscape. The first version, named SSL v1.0, was not released and version 2.0 had a number of security flaws, which led to the release of SSL v3.0. The differences between versions 2.0 and 3.0 are summarized in Table 1. <table> <thead> <tr> <th>Security Improvements</th> <th>SSL version 2</th> <th>SSL version 3</th> </tr> </thead> <tbody> <tr> <td></td> <td>Vulnerable to a &quot;man-in-the-middle&quot; attack. An active attacker can invisibly edit the list of</td> <td>Defends against this attack by having the last handshake message include a hash of all the previous handshake</td> </tr> <tr> <td>Functionality Improvements</td> <td>SSL version 2</td> <td>SSL version 3</td> </tr> <tr> <td>----------------------------</td> <td>--------------------------------------------------------------------------------</td> <td>--------------------------------------------------------------------------------</td> </tr> <tr> <td>ciphersuite preferences in the “hello messages” to invisibly force both client and server to use 40-bit encryption.</td> <td>messages.</td> <td></td> </tr> <tr> <td>Uses a weak MAC construction</td> <td>Uses a strong MAC construction.</td> <td></td> </tr> <tr> <td>Feeds padding bytes into the MAC in block cipher modes, but leaves the padding-length field unauthenticated, which could allow active attackers to delete bytes from the end of messages.</td> <td>Fixed the issue of leaving the padding-length field unauthenticated.</td> <td></td> </tr> <tr> <td>Message Authentication uses only 40 bits when using an Export cipher.</td> <td>The Message Authentication Hash uses a full 128 bits of keying material, even when using an Export cipher.</td> <td></td> </tr> <tr> <td>The client can only initiate a handshake at the beginning of the connection.</td> <td>The client can initiate a handshake routine even in the middle of an open session. A server can request that the client starts a new handshake. Thus, the parties can change the algorithms and keys used whenever they want.</td> <td></td> </tr> <tr> <td>Does not allow the server and client to send chains of certificates.</td> <td>Allows the server and client to send chains of certificates. This allows organizations to use a certificate hierarchy that is more than two certifications deep.</td> <td></td> </tr> <tr> <td>Does not allow for record compression and decompression.</td> <td>Allows for record compression and decompression</td> <td></td> </tr> </tbody> </table> **Backward Compatibility** SSL 3.0 can recognize an SSL 2.0 “client hello” and fall back to SSL 2.0. An SSL 3.0 client can also generate an SSL 2.0 “client hello” with the version set to SSL 3.0, so SSL 3.0 servers will continue the handshake in SSL 3.0, and SSL 2.0 server will cause the client to fall back to SSL 2.0. **Other** SSL 3.0 separates the transport of data from the message layer. In 2.0, each packet contained only one handshake message. In 3.0, a record may contain part of a message, a whole message, or several messages. This requires different logic to process packets into handshake messages. Therefore, the formatting of the packets had to be completely changed. Cipher specifications, handshake messages, and other constants are different. 3.1.1 TLS 1.0 This TLS protocol was first defined in January 1999 as an upgrade to SSL v3.0. Some of the major differences are: - Key derivation functions are different - MACs are different - SSL 3.0 uses a modification of an early HMAC, while TLS 1.0 uses HMAC. - The Finished messages are different - TLS has more alerts - TLS requires DSS/DH support. 3.1.2 TLS 1.1 This version of TLS was defined in April 2006 as an upgrade to TLS v1.0. Some of the major differences are: - The Implicit Initialization Vector (IV) is replaced with an explicit IV to protect against Cipher Block Chaining (CBC) attacks. - Handling of padded errors is changed to use the bad_record_mac alert rather than the decryption_failed alert to protect against CBC attacks. - IANA registries are defined for protocol parameters - No longer prematurely closes to cause a session to be non-resumable. 3.1.3 TLS 1.2 This TLS version was defined in August 2008. It contained improved flexibility compared to TLS v1.1. Some of the major differences are: - The MD5/SHA-1 combination in the pseudorandom function (PRF) is replaced with cipher-suite-specified PRFs. - The MD5/SHA-1 combination in the digitally-signed element is replaced with a single hash. Signed elements include a field explicitly specifying the hash algorithm used. - Substantial cleanup of the client's and server's ability to specify which hash and signature algorithms they will accept. - Addition of support for authenticated encryption with additional data modes. - TLS Extensions definition and AES Cipher Suites were merged in. - Tighter checking of EncryptedPreMasterSecret version numbers. - Verify_data length depends on the cipher suite. - Description of Bleichenbacher/Dlima attack defenses cleaned up. With attacks, such as POODLE [20], SSL v3.0 is no longer considered as secure to use. Organizations that still use SSL v3.0 for securing their websites are at a great risk of major attacks. Subsequent versions of TLS — v1.1 and v1.2 are significantly more secure and fix many vulnerabilities present in SSL v3.0 and TLS v1.0. For example, the BEAST attack can completely break web sites running on SSL v3.0 and TLS v1.0 protocols. The newer TLS versions prevent the BEAST, and provide many stronger ciphers and encryption methods. Taking setting up an e-mail application as an example, different options, such as “no encryption,” “SSL,” and “TLS”, indicate how secure the connection to be initiated will be. 3.2 Different public-key exchange methods supported in SSL/TLS The key exchange method defines how the shared key used for application data transfer will be agreed upon by the client and the server. SSL 2.0 uses RSA key exchange only, while SSL 3.0 and all subsequent TLS versions support the choice of a key exchange scheme, including variants of the RSA key exchange and the Diffie-Hellman key exchange. We review these methods shortly in the following subsections. 3.2.1 RSA The secret key that is to be used for encryption of messages in the Record Layer is generated at random by a sender, and encrypted with the receiver’s RSA public key. The public key certificate for the server and, optionally, for the client include the RSA generated public keys. 3.2.2 Fixed Diffie-Hellman (DH) In this key-exchange method, the public-key certificate contains the Diffie-Hellman public parameters signed by the certificate authority (CA). The client provides its Diffie-Hellman public-key parameters either in a certificate, if client authentication is required, or in a key exchange message. This method results in a fixed secret key between two peers based on the Diffie-Hellman calculation using the fixed public keys. ![Diffie-Hellman key agreement scheme](image) **Figure 7:** Fixed Diffie-Hellman 3.2.3 Ephemeral Diffie-Hellman (EDH) This method is used to create temporary secret keys. Each instance of the protocol uses a different key, hence the same key is never used twice. In this method, the DH public keys are exchanged, signed using the sender’s private RSA or DSS key. The receiver can use the corresponding public key to verify the signature. Certificates are used to authenticate the public keys. This method is the most secure method as it results in a temporary, authenticated key. 3.2.4 Anonymous Diffie-Hellman This method does not use any kind of authentication. Each side sends its public Diffie-Hellman parameters to the other with no authentication. This method is not secure as it can be vulnerable to man-in-the-middle attacks. 3.3 Use of MAC and HMAC There are different MAC schemes that are used for SSL/TLS. MACs are used to provide data integrity during the transmission of data in the Record Layer. MAC takes the secret key and the arbitrary-length message to be authenticated as the input, and outputs a MAC of a fixed size length. It protects both message integrity as well as its authenticity. A keyed-hash message authentication code (HMAC) is a specific construction for calculating a message authentication code (MAC) involving a cryptographic hash function in combination with a secret cryptographic key. Any cryptographic hash function, such as MD5 (128-bits) or SHA-1 (160-bits), may be used in the calculation of an HMAC; the resulting MAC algorithm is termed HMAC-MD5 or HMAC-SHA1, accordingly. The cryptographic strength of the HMAC depends on the cryptographic strength of the underlying hash function, the size of its hash output, and on the size and quality of the key. Figure 9: CBC-MAC 3.4 Use of Symmetric cipher suites Symmetric cipher suites are used to encrypt/decrypt data transmitted in the Record Layer phase, using symmetric-key algorithms selected by the server and the client in the Handshake phase. Some of the symmetric-key algorithms used are listed below: - DES – Data Encryption Standard (Key size – 56 bits) - 3DES – DES used 3 times to ensure more security than DES. - AES – Advanced Encryption Standard (key size – 128 / 192 / 256 bits) - RC2-40 (key size – 40 bits) 3.5 SSL Handshake An SSL session always begins with an exchange of data using the SSL handshake. The handshake allows the server to authenticate itself to the client using public-key techniques. Figure 11: SSL Handshake steps [13] • The client sends the SSL version number, the cipher suites supported, a random number, and other information needed to communicate to the server. • The server also sends the SSL version number, the strongest cipher suites chosen and supported by it, a random number, and other information needed to communicate to the client. The server also sends its own certificate. If the client is requesting a server resource that requires client authentication, the server requests the client's certificate. • The client uses the certificate sent by the server to authenticate the server. If the server cannot be authenticated, the user is informed that an encrypted and authenticated connection cannot be established. If the server can be successfully authenticated, the client moves on to the next step. • Using all data generated in the handshake so far, the client creates the premaster secret for the session, encrypts it with the server's public key (which is obtained from the server's public key certificate), and sends the encrypted premaster secret to the server. • If the server has requested client authentication (which is an optional step in the handshake), the client also signs another piece of data with its private key, which is unique to this handshake and known by both the client and server. In this case, the client sends both the signed data and the client's own certificate to the server along with the encrypted premaster secret. • If the server has requested client authentication, the server also tries to authenticate the client. If the client cannot be authenticated, the session is terminated. If the client can be successfully authenticated, the server uses its private key to decrypt the premaster secret, then performs a series of steps (which the client also performs, starting from the same premaster secret) to generate the master secret. - Both the client and the server use the master secret to generate the session keys, which are symmetric keys used to encrypt and decrypt information exchanged during the SSL session and to verify its integrity—that is, to detect any changes in the data between the time it was sent and the time it is received over the SSL connection. - The client sends a message to the server informing it that future messages from the client will be encrypted with the session key. It then sends a separate encrypted message indicating that the client portion of the handshake is finished. - The server sends a message to the client informing it that future messages from the server will be encrypted with the session key. It then sends a separate encrypted message indicating that the server portion of the handshake is finished. The SSL handshake is now complete, and the SSL session has begun. The client and the server use the session keys to encrypt and decrypt data they send to each other and to validate its integrity. There are six different keys generated for each side; the client and the server. These keys are: - Server_write_MAC_secret: The secret key used in MAC operations on data sent by the server. - Client_write_MAC_secret: The client key used in MAC operations on data sent by the client. • **Server_write_key**: The symmetric encryption key used for data encrypted by the server and decrypted by the client. • **Client_write_key**: The symmetric encryption key used for data encrypted by the client and decrypted by the server. • **Server_IV**: Initialization vector maintained by the server for each key when CBC mode is used. • **Client_IV**: Initialization vector maintained by the client for each key when CBC mode is used. The client informs the server that all the future messages from client are encrypted with the generated Client_write key. It then sends a separate encrypted message indicating that the client portion of the handshake is finished. The server sends a message to client informing that future messages from server are encrypted with the generated Server_write key. It then sends a separate encrypted message indicating that the server portion of the handshake is finished. The client sends a message to the server informing that future messages from client are encrypted with the generated Client_write key. It then sends a separate encrypted message indicating that the client portion of the handshake is finished. ### 3.6 SSL Record Layer Communication between the client and the server takes place with the help of SSL Record Protocol. The SSL Record Protocol provides three services for SSL connections: confidentiality, by encrypting application data; and message integrity and authentication, by using MAC. The following figure illustrates the overall operation of the SSL Record Protocol. The Record Protocol takes the application data to be transmitted, fragments the data into blocks, optionally compresses the data, adds MAC to it, encrypts, appends SSL Record Header, and transmits the resulting unit. On the receiver’s side, the received data gets decrypted, verified by computing MAC, decompressed, reassembled, and then gets delivered to the calling application on receiver’s side. Figure 12: SSL Record Protocol [8] The first step is fragmentation. Every application data gets fragmented into fixed sized blocks. Next, compression is optionally applied. No compression algorithm is specified in SSL version 3.0, so the default compression algorithm is null. However, depending on the implementation, Record Protocol may include a compression algorithm. In the next step, a message authentication code gets computed over a compressed data. A hash code gets calculated by a combination of the compressed data, a secret key, and some padding. For this purpose, the Client_write_MAC_secret and Server_write_MAC_secret keys are used. The receiver performs the same calculation and compares the computed MAC value with the incoming MAC value. If the two values match, the receiver is assured that the message has not been altered in transit. Also, by applying MAC, the receiver will have the certainty about the authenticity of the sender. Next, the compressed data and attached MAC are encrypted using a symmetric key cipher. Finally, the SSL Record Protocol prepends an SSL Record Header and transmits the entire resulting unit to the receiver. ### 3.7 Attacks on SSL / TLS We will now have a look at several types of attacks that have been developed against SSL/TLS: #### 3.7.1 Cipher Suite Rollback Attack This attack aims at limiting the offered cipher-suite list provided by the client to a weaker one or the one composed of NULL-ciphers. A Man-in-the-middle (MITM) attacker may alter the ClientHello message (sent by the initiator of the connection), strip the undesirable cipher-suites or completely replace the cipher-suite list with a weak one, and pass the manipulated message to the desired recipient. The server has no real choice - it can either reject the connection or accept the weaker cipher-suite. This problem was fixed with the release of SSL 3.0, through authenticating all messages of the Handshake protocol, by including the hash value of all messages sent and received by the client in the ClientFinished message. ### 3.7.2 Version Rollback Attack In a version rollback attack, a ClientHello message of SSL 3.0 is modified to look like a ClientHello message of SSL 2.0. This forces the server to switch back to the more vulnerable SSL 2.0. As a prevention, the SSL/TLS version is also contained in the PreMasterSecret of the ClientKeyExchange message. ### 3.7.3 BEAST BEAST leverages a type of cryptographic attack called a chosen-plaintext attack. The CBC vulnerability can enable man-in-the-middle (MITM) attacks against SSL in order to silently decrypt and obtain authentication tokens, providing hackers with access to the data passed between a Web server and the Web browser. The attacker mounts the attack by choosing a guess for the plaintext that is associated with a known ciphertext. To check if a guess is correct, the attacker needs access to an encryption oracle to see if the encryption of the plaintext guess matches the known ciphertext. An attacker observing 2 consecutive ciphertext blocks C0, C1 can test if the plaintext block P1 is equal to x by choosing the next plaintext block P2 = x \oplus C0 \oplus C1. Due to the way how CBC works, C2 will be equal to C1 if x = P1. The vulnerability of the attack had been fixed with TLS 1.1 in 2006, but TLS 1.1 had not seen wide adoption prior to this attack demonstration. As a preventive measure, RC4 is used as it is immune to BEAST attack, hence it was used to mitigate this attack on the server side. ### 3.7.4 POODLE This attack, named as Padding Oracle On Downgraded Legacy Encryption, is a vulnerability in the design of SSL 3.0, which makes CBC mode with SSL 3.0 vulnerable to a padding attack. POODLE allows a man-in-the-middle attack, through means of a malicious Wi-Fi hotspot or a compromised ISP to extract data from secure HTTP connections, which could allow the attacker to access online banking and use the victim’s session for malicious purposes. The attackers only need to make 256 SSL 3.0 requests to reveal one byte of encrypted messages. As this vulnerability exists only in SSL v3.0, and currently most of the browsers use TLS 1.0 and above, this attack works only if the attacker can successfully conduct a version rollback attack first. To overcome this attack, the users need to disable SSL v3.0 in their browsers and enable TLS 1.0. ### 3.7.5 HeartBleed Attack The Heartbleed bug is a serious vulnerability specific to the implementation of SSL/TLS in the popular OpenSSL cryptographic software library. This weakness allows attackers to steal private keys from servers that should normally be protected. The Heartbleed bug allows anyone on the Internet to read the memory of the systems protected by the vulnerable versions of the OpenSSL software. This flaw in the code was related to the bad input validation with the data length, meaning that the length of the data sent was not properly validated against the SSL3_RECORD’s length field because of which the attacker was successfully able to overrun the memory, thus adding his malicious code to it. This attack compromised the secret and private keys, the names and passwords of the users, and the sensitive information stored on the users computers. The attack allowed attackers to eavesdrop on communication between the browser and the server, steal data directly from services and users, and impersonate services and users. It should be stressed that, this vulnerability was a bug in the OpenSSL software, rather than any error in the SSL or TLS protocol specification. In terms of the development tools, I have tried to use the same development platform and the programming language as used in CrypTool 2, namely C# as the programming language with .NET Framework 4.0 in Visual Studio 2013, and WPF as a user interface (UI). C# is an object-oriented language that provides developers a way to build robust and secure applications which run on .NET framework. C# is used to create Windows client applications, XML Web services, distributed components, client-server applications, database applications, etc. C# provides language constructs to directly support these concepts, making it a very natural language in which to create and use software components. C# supports generic methods and types, which provide an improved safety and performance, and iterators, which enable the components that implements the collection classes to define iterative behaviors that are simple to use by client code. To ensure that C# programs and libraries can evolve over time in a compatible manner, much emphasis has been placed on versioning in C# design. Many programming languages pay little attention to this issue, and, as a result, programs written in those languages break more often than necessary when newer versions of dependent libraries are introduced. WPF, introduced in .NET framework 3.0 provides a platform for the development of highly functional rich client applications. It is a GUI framework that allows programmers to create an application with a wide range of elements, like labels, textboxes, and other well-known elements. Over the period of time, WPF has become answer for software developers and graphic designers who want to create modern user experiences without having to master several different technologies. As applied to the .NET Framework programming model, XAML simplifies creating a UI for .NET framework applications. There are built-in controls provided as part of WPF, such as buttons, menus, grids, and list boxes. WPF provides an integrated system for building user interfaces with common media elements, like vector and raster images, audio, and video. WPF also provides an animation system and a 2D/3D rendering system. The reason WPF was chosen for the implementation was due to its rich composition and customization. As my goal was to develop a simulation program in order to visualize the exchange of messages, WPF provided a variety of options as well as support for XAML markup language. XAML can be used to create custom controls, graphics, 3D images, animations and many more modules that are included. There are different libraries that provide us with some built-in functionalities that might be useful in implementing our application. In my work too, I have used a few libraries which provide some of the built-in cryptographic functionalitities related to SSL/TLS. 4.1 OpenSSL OpenSSL is a general-purpose cryptography library that provides an open-source implementation of SSL/TLS protocols. It is a robust, full-featured toolkit implementing SSL and TLS. The core library is written in C programming language and implements basic cryptographic algorithms and schemes. There are different versions available for multiple operating systems, such as Linux, Mac OS X, Solaris, and Windows. The source code for OpenSSL is available from the download page [50]. OpenSSL offers a Command Line Interface (CLI) that is used to generate and manage private and public keys, creation of certificates, calculating message digests, handling of S/MIME signed or encrypted mail. OpenSSL is used in: - Generating public and private key pairs - Generating a Certificate Signing Request (CSR) - Sending the request to CA and getting the public certificate - Using the certificate for authentication purposes. There are different data structures used by the OpenSSL library functions: - SSL_METHOD - SSL_CIPHER - SSL_CTX - SSL_SESSION - SSL. 4.2 MSDN Library MSDN is a set of functions that help developers write applications using various APIs that come along with Microsoft products. This library contains technical documentation and content intended for developers using Microsoft Windows. The library has APIs, source code, technical articles, and other programming information. It can be freely downloaded as a package with Microsoft development tools, like Visual Studio, and can be used when developing applications. Every version of Visual Studio has an integrated help viewer that helps you to access the then current edition of MSDN library. The library contains different classes, which have constructors, methods, and properties that as a whole provide you with the functionality that the developer is looking for. Figure 13 describes the tree structure of MSDN library, which defines its hierarchy. ![Figure 13 MSDN library hierarchy example](image-url) Figure 13 MSDN library hierarchy example 4.3 Mentalis Mentalis is a free open-source software available online that contains several security libraries called Mentalis.org security library, which is an add-on for .NET framework. The main purpose of this security library is to provide security related functions and tools in C# for VB.NET development. The library supports the following: - **Authentication** - A password validation library enables you to check a user password according to set of validation rules. - **Cryptography** - The algorithms such as HMAC and RC4. - **Smart Cards** - Offers a framework to connect and communicate with smart cards. There are several different subprojects that the library consists of: - **SecureSocket Library (SSL and TLS support)** - This is a free and open source library that implements SSL v3.0 and TLS v1.0. This library contains a SecureSocket class that encrypts and decrypts the data passed through it. It has several other classes that internally implement algorithms and protocols that help in the functioning of SSL/TLS. - CertificateServices Library (Certificate Management support) - This library is an implementation of Certificate API that includes the following features: - Methods of X509Certificate class, loading private key files, loading certificates from certificate stores, etc. - Building a certificate chain and verifying it - Encrypting and decrypting data with respective public and private parameters of the certificates - Methods pertaining to creating certificates, revoking certificates, deleting certificates, etc. - Crypto Library (Cryptographic Transformations support) - This library implements several cryptographic algorithms such as RC4, AES, HMAC, etc. - It covers Asymmetric Cryptography, Hashing, and Symmetric Cryptography classes and methods. Figure 14 describes the hierarchy/tree structure of the functionality provided by Mentalis library. Figure 14 MSDN library hierarchy example CHAPTER 5: IMPLEMENTATION Having described the background of SSL/TLS theoretically in the previous sections, which helps us to understand each and every aspect of SSL/TLS and the functions associated with it, we shall now have a look at the original work, a working model of SSL/TLS, developed as a part of this thesis. Let us have a look at the implementation and flow of the program. 5.1 The Handshake Phase 5.1.1 Welcome Screen Right before entering the handshake phase, the tool starts with an introductory welcome screen, which displays a brief introduction about the program and also talks in short about the user manual, from which a user can receive help required to understand the functionality of the program in a detailed manner. 5.1.2 Generation of Certificate Moving ahead from the welcome screen, the next part is the certificate generation window where the public key certificate for both, the server and the client is generated. This public key certificate is provided during the handshake phase by the server to the client for authentication purposes, where the client verifies the certificate by using the CA’s public key. As seen in the above image, there are two options provided; one for generating server’s public certificate and another for generating the client’s certificate (which is optional in real scenario). Clicking the “Generate Server Certificate” button redirects the flow to a window that is shown in Figure 17. As shown in this figure, there is an exchange of messages taking place between the server and the CA. First the server provides his details, which includes the public key of a specific size that the server chooses. These details are then sent over to the CA where the CA will create a public key certificate, signs it with its private key, and sends back to the server. Now the server has his public certificate, which can be used at the handshake phase to authenticate himself to the client. In this simulation program, it may not be possible to show how the CA actually verifies whether the certificate requesting server is a legitimate/trusted server or not. In reality, the CA generally carries out a two-step validation process: - Domain name validation: Verifying the authenticity of the domain name owned by the requesting server. - Verifying whether the server is a legitimate server or not. ![Certificate Generation – Server Details window](image) Figure 17: Certificate Generation – Server Details window In the certificate generation step of the developed program shown in Figure 17, the requesting server is already considered legitimate by the CA because the primary purpose of demonstrating the certificate generation step is just to help the user acquire knowledge about the details of the public-key certificate that will be sent by the server to the client during the handshake phase. In the similar manner as explained above, the client public certificate is generated, which is usually optional, as normally the client (i.e., the browser in a real scenario) does not need to always authenticate itself to the server. 5.1.3 Mode Selection After the certificate generation step is done, the flow of the program moves ahead toward the mode selection window, where the user is given an option of selecting one of the two modes – the Demo mode or the Attack mode. Selecting any one of them opens up the corresponding handshake window that demonstrates the inner workings of the handshake protocol. ![Mode Selection window](image) Figure 18: Mode Selection window 5.1.4 The Handshake Protocol The implementation of the handshake protocol is done in a similar manner to the explanation of this protocol provided in Section 3.5. The image shown below is the actual implementation snapshot of the handshake, which is developed as a part of the thesis. Figure 19: Demo mode Handshake window The actual working of the program can be seen by clicking on subsequent buttons, shown in Figure 19. Starting at the client’s side, clicking on “Generate Random” button, a 32-byte random number is generated for the client. Moving ahead and clicking on the “Select Parameters” button, a window opens up that has cipher suites options to be selected from, such as SSL/TLS version, Asymmetric key algorithms, Symmetric key algorithms and Hashing algorithms. At the end of this step, the “Client Hello” message is sent to the server. Then, the user clicks on “Proceed” button and the blue colored text block with the text Client Hello slides across towards the server side, which indicates that the client hello message has been sent over to the server. The sliding of the text block is possible due to the animation feature provided by WPF. The rest of the program flows in the similar manner, where clicking on a certain button slides a text block to the opposite end, indicating that the message has been sent over to the receiving end. At the end of the handshake phase, there are six session keys generated that are used for communication between the client and the server in the record protocol. Having obtained the session keys at the end of the handshake phase, the flow of the program moves to the record protocol, where the client-server communication is shown. 5.1.5 The Record Protocol Figure 20: The Record Protocol Figure 20 is the snapshot of the record protocol window. The client can select any data/file to be sent to the server. Clicking on “Enter Data” button on the client side opens up a new window that allows you to choose a file from your system such as a text file, word file, pdf file, etc. After the selection of the file and before sending it, the file goes through the entire process of **Fragments → Compression → Adding HMAC → Encryption**. It is then sent over to the server where the server does the whole process in a reverse manner (**Decryption → Compare HMAC → Decompression → Assembling the fragments**) to get back the original file. Considering the implementation of the program, the server follows the same process, as mentioned in the above paragraph. Hence, this process goes on till the client and the server want to communicate. Talking about the other mode – Attack mode, there are three types of attacks demonstrated, due to which many other attacks are possible. 1. Cipher Suite Rollback Attack 2. Version Rollback attack 3. Man-in-the-middle attack Figure 21: Attack selection window As seen from the above image, this window opens up by selecting “Attack Mode” from the mode selection window. Selecting any of these attacks directs the program to open the handshake window with additional functionalities available compared to the Demo mode. Figure 22 displays the Man-in-the-middle attack handshake window, where there is an “Interceptor” button that can be seen. This particular flow of the program is shown from the attacker’s perspective. The attacker as a middle man can intercept the communication that is going on between the client and the server. By clicking on the “Intercept” button, the attacker stops the “client hello” message that is sent by the client and instead drafts its own message and sends it to the server, thus impersonating the client. The server on the other side treats this message as coming from the actual client, and sends his response back to the client. The attacker does the same thing here as well; keeps the server message and generates its own server message, thus impersonating the server. Hence, with this attack demonstrated, a conclusion can be drawn that all the communication thereafter can be intercepted and decrypted by the attacker, thus creating a security breach and violating confidentiality and integrity services. Continuing this attack with the record protocol, the attacker can actually modify the content of any message as a middle man, and intercept the whole communication of messages exchanged between the client and the server. In this way, the integrity of the message is no more preserved. In the similar manner, there are other attacks implemented, like cipher suite rollback attack and version rollback attack. In the cipher suite rollback attack, an intruder tries to intercept the message and modify the cipher suite to weaker ones in order to open the way for several other exploits that might be possible with certain weaker cipher suites. The same goes with the version rollback attack, where the attacker intercepts the “client hello” message and downgrades the SSL/TLS version, thus allowing several other attacks to proceed. 5.2 Use of library functions in the implementation This implementation uses several cryptographic library functions provided by MSDN, as well as external security library, called Mentalis. Table 2 describes the entire usage of libraries in our program by specifying what functionality of the program uses which library function. Table 2: Library functions used in our program, <table> <thead> <tr> <th>Button</th> <th>Library used</th> <th>Underlying Class</th> <th>Function defined under the class</th> </tr> </thead> <tbody> <tr> <td><strong>Certify Server</strong></td> <td>MSDN</td> <td>RSACryptoServiceProvider</td> <td>ImportParameters(RSAParameters parameters)</td> </tr> <tr> <td>Primary function associated with the button: Certify()</td> <td></td> <td>RSAParameters</td> <td>ExportParameters(bool IncludePrivateParameters)</td> </tr> <tr> <td><strong>Verify Server Certificate</strong></td> <td>MSDN</td> <td>RSACryptoServiceProvider</td> <td>ImportParameters(RSAParameters parameters)</td> </tr> <tr> <td>Primary Function associated with the button: verifySignature(byte[] signedData, string name)</td> <td></td> <td>RSAParameters</td> <td>ExportParameters(bool IncludePrivateParameters)</td> </tr> <tr> <td>Button</td> <td>Library used</td> <td>Underlying Class</td> <td>Function defined under the class</td> </tr> <tr> <td>--------------------------------</td> <td>--------------</td> <td>------------------</td> <td>----------------------------------</td> </tr> <tr> <td><strong>Enter Client Encrypted Data</strong></td> <td>MSDN</td> <td>RSACryptoServiceProvider, RSAParameters</td> <td>ImportParameters(RSAParameters parameters)</td> </tr> <tr> <td>Primary Function associated with the button: <strong>signData(byte[] DataToSign, RSAParameters key)</strong></td> <td></td> <td></td> <td>ExportParameters(bool IncludePrivateParameters)</td> </tr> <tr> <td></td> <td></td> <td></td> <td>SignData(byte[] buffer, object halg)</td> </tr> <tr> <td></td> <td></td> <td></td> <td>SHA1CryptoServiceProvider SHA1CryptoServiceProvider()</td> </tr> <tr> <td><strong>Verify Client Encrypted Data</strong></td> <td>MSDN</td> <td>RSACryptoServiceProvider, RSAParameters</td> <td>ImportParameters(RSAParameters parameters)</td> </tr> <tr> <td>Primary Function associated with the button: <strong>verifySignature(byte[] DataToVerify, byte[] SignedData, RSAParameters Key)</strong></td> <td></td> <td></td> <td>ExportParameters(bool IncludePrivateParameters)</td> </tr> <tr> <td></td> <td></td> <td></td> <td>VerifyData(byte[] buffer, object halg, byte[] signature)</td> </tr> <tr> <td></td> <td></td> <td></td> <td>SHA1CryptoServiceProvider SHA1CryptoServiceProvider()</td> </tr> <tr> <td><strong>Generate Pre-master Secret</strong></td> <td>MSDN</td> <td>RSACryptoServiceProvider, RSAParameters</td> <td>ImportParameters(RSAParameters parameters)</td> </tr> <tr> <td><strong>Encrypt and Send</strong></td> <td></td> <td></td> <td>ExportParameters(bool IncludePrivateParameters)</td> </tr> <tr> <td>Primary Function associated with the button: <strong>encryptPreMaster()</strong></td> <td></td> <td></td> <td>Encrypt(byte[] rgb, bool fOAEP)</td> </tr> <tr> <td><strong>Generate Master Secret</strong></td> <td>Mentalis .org</td> <td>Ssl3CipherSuites</td> <td>GenerateMasterSecret(byte[] premaster, byte[] clientRandom, byte[] serverRandom)</td> </tr> <tr> <td>Primary function associated with the button: <strong>genmastersecret_client_click()</strong></td> <td></td> <td></td> <td>Ssl3DeriveBytes Ssl3DeriveBytes(byte[])</td> </tr> <tr> <td>Button</td> <td>Library used</td> <td>Underlying Class</td> <td>Function defined under the class</td> </tr> <tr> <td>-------------------</td> <td>--------------</td> <td>------------------</td> <td>----------------------------------</td> </tr> <tr> <td><strong>Enter Data</strong></td> <td></td> <td>HMACMD5</td> <td>HMACMD5(byte[] key)</td> </tr> <tr> <td><strong>Proceed</strong></td> <td></td> <td>HMACSHA1</td> <td>HMACSHA1(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA256</td> <td>HMACSHA256(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA384</td> <td>HMACSHA384(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA512</td> <td>HMACSHA512(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HashAlgorithm</td> <td>ComputeHash(byte[] buffer)</td> </tr> <tr> <td><strong>DataEncryptClient()</strong></td> <td>MSVNDN</td> <td>DESCryptoServiceProvider</td> <td>CreateEncryptor(byte[] rgbKey, byte[] rgbIV)</td> </tr> <tr> <td></td> <td></td> <td>AESCryptoServiceProvider</td> <td>CreateEncryptor(byte[] key, byte[] iv)</td> </tr> <tr> <td><strong>DataDecryptServer()</strong></td> <td></td> <td>DESCryptoServiceProvider</td> <td>CreateDecryptor(byte[] rgbKey, byte[] rgbIV)</td> </tr> <tr> <td></td> <td></td> <td>AESCryptoServiceProvider</td> <td>CreateDecryptor(byte[] key, byte[] iv)</td> </tr> <tr> <td></td> <td></td> <td>HMACMD5</td> <td>HMACMD5(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA1</td> <td>HMACSHA1(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA256</td> <td>HMACSHA256(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA384</td> <td>HMACSHA384(byte[] key)</td> </tr> <tr> <td></td> <td></td> <td>HMACSHA512</td> <td>HMACSHA512(byte[] key)</td> </tr> <tr> <td><strong>CompareHashServer()</strong></td> <td></td> <td>HashAlgorithm</td> <td>ComputeHash(byte[] buffer)</td> </tr> </tbody> </table> CHAPTER 6: CONCLUSION AND FUTURE WORK With the development of this application, we can be assured of one thing that, visualizing the whole protocol gives us better understanding in addition to the theoretical knowledge of SSL/TLS. One could use our program to develop a laboratory exercise to teach students about the protocol. Similarly, students after learning about SSL/TLS from the theoretical perspective could use our program as an educational tool to get the clear picture of the protocol. The use of the available security libraries made the flow and implementation of the program easier and dynamic, where writing the entire piece of code from scratch was replaced by the library function call that provided already built in functionality. As it is the case for every newly developed application, there are certain limitations of the current version of the program. The implementation of the protocol is purely for educational purposes and thus cannot be used in the actual browser for the communication. Also, our implementation cannot be used to exchange data between two machines using socket communication. Being developed with Microsoft IDE (Visual Studio), this application might not be platform independent and may only work on Windows. Considering some features and functionalities, the attacks demonstrated in this program, such as cipher suite rollback and version rollback, could be used as a base for some other exploits that are more complex to implement. This attacks includes POODLE attack, which is based on the version rollback attack, but is really very complex and difficult to demonstrate as a part of our program. Furthermore, I have been able to implement the handshake and the record layer protocols, however as the future work is concerned, this development could also be extended by implementing the “alert protocol” and the “change cipher spec protocol,” which would complete the entire SSL/TLS implementation. REFERENCES [18] C# WPF video, https://www.youtube.com/watch?v=krxYDsee2cQ [26] GNU Privacy Guard,” Wikipedia, the free encyclopedia [28] Magma (algebra),” *Wikipedia, the free encyclopedia* [32] SageMath,” *Wikipedia, the free encyclopedia* [34] SageMath Mathematical Software System - Sage,” *SageMath Mathematical Software System* [44] SSL versus TLS - What’s the difference?, LuxSci FYI. [49] OpenSSL,” Wikipedia, the free encyclopedia BIOGRAPHY Harsh Vachharajani was born in October of 1991 in Gandhinagar, Gujarat, India. He graduated from Infocity Junior Science College, Gujarat, India, in 2009. He received his Bachelor of Technology in Information Technology from Ganpat University, Mehsana, India, in 2013. He further continued his studies pursuing his Master of Science degree in Information Security and Assurance from George Mason University, Fairfax, USA, in 2015. During his course of studies, he worked as a Research Assistant in the Cryptographic Engineering Research Group (CERG). His research interest include software implementation of cryptographic algorithms and protocols, and vulnerability assessment for securing software applications.
{"Source-Url": "http://mars.gmu.edu/jspui/bitstream/handle/1920/10524/Vachharajani_thesis_2015.pdf?isAllowed=y&sequence=1", "len_cl100k_base": 15214, "olmocr-version": "0.1.53", "pdf-total-pages": 69, "total-fallback-pages": 0, "total-input-tokens": 133613, "total-output-tokens": 18830, "length": "2e13", "weborganizer": {"__label__adult": 0.0004906654357910156, "__label__art_design": 0.0007805824279785156, "__label__crime_law": 0.0009226799011230468, "__label__education_jobs": 0.0105743408203125, "__label__entertainment": 0.00016868114471435547, "__label__fashion_beauty": 0.0002263784408569336, "__label__finance_business": 0.0005865097045898438, "__label__food_dining": 0.0003743171691894531, "__label__games": 0.0010528564453125, "__label__hardware": 0.0016908645629882812, "__label__health": 0.0005421638488769531, "__label__history": 0.0005259513854980469, "__label__home_hobbies": 0.00015783309936523438, "__label__industrial": 0.0006117820739746094, "__label__literature": 0.0005130767822265625, "__label__politics": 0.0003635883331298828, "__label__religion": 0.0005717277526855469, "__label__science_tech": 0.12457275390625, "__label__social_life": 0.0002696514129638672, "__label__software": 0.0222930908203125, "__label__software_dev": 0.83154296875, "__label__sports_fitness": 0.00031495094299316406, "__label__transportation": 0.0005545616149902344, "__label__travel": 0.00024890899658203125}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 76463, 0.03041]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 76463, 0.54617]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 76463, 0.85478]], "google_gemma-3-12b-it_contains_pii": [[0, 755, false], [755, 1203, null], [1203, 1203, null], [1203, 2110, null], [2110, 4404, null], [4404, 6388, null], [6388, 6725, null], [6725, 7885, null], [7885, 9764, null], [9764, 10494, null], [10494, 10937, null], [10937, 11900, null], [11900, 12600, null], [12600, 13625, null], [13625, 14289, null], [14289, 15603, null], [15603, 16262, null], [16262, 16981, null], [16981, 18625, null], [18625, 19932, null], [19932, 21193, null], [21193, 22687, null], [22687, 23552, null], [23552, 24714, null], [24714, 26222, null], [26222, 29400, null], [29400, 30279, null], [30279, 31597, null], [31597, 32633, null], [32633, 33573, null], [33573, 34132, null], [34132, 34917, null], [34917, 35419, null], [35419, 35652, null], [35652, 37369, null], [37369, 38827, null], [38827, 40285, null], [40285, 41316, null], [41316, 42606, null], [42606, 44012, null], [44012, 45349, null], [45349, 46342, null], [46342, 47624, null], [47624, 49182, null], [49182, 50248, null], [50248, 51219, null], [51219, 52269, null], [52269, 53153, null], [53153, 53194, null], [53194, 53940, null], [53940, 54341, null], [54341, 55382, null], [55382, 56289, null], [56289, 57020, null], [57020, 57491, null], [57491, 58489, null], [58489, 59598, null], [59598, 61170, null], [61170, 61526, null], [61526, 62963, null], [62963, 65041, null], [65041, 66776, null], [66776, 68031, null], [68031, 68725, null], [68725, 70468, null], [70468, 72125, null], [72125, 73875, null], [73875, 75740, null], [75740, 76463, null]], "google_gemma-3-12b-it_is_public_document": [[0, 755, true], [755, 1203, null], [1203, 1203, null], [1203, 2110, null], [2110, 4404, null], [4404, 6388, null], [6388, 6725, null], [6725, 7885, null], [7885, 9764, null], [9764, 10494, null], [10494, 10937, null], [10937, 11900, null], [11900, 12600, null], [12600, 13625, null], [13625, 14289, null], [14289, 15603, null], [15603, 16262, null], [16262, 16981, null], [16981, 18625, null], [18625, 19932, null], [19932, 21193, null], [21193, 22687, null], [22687, 23552, null], [23552, 24714, null], [24714, 26222, null], [26222, 29400, null], [29400, 30279, null], [30279, 31597, null], [31597, 32633, null], [32633, 33573, null], [33573, 34132, null], [34132, 34917, null], [34917, 35419, null], [35419, 35652, null], [35652, 37369, null], [37369, 38827, null], [38827, 40285, null], [40285, 41316, null], [41316, 42606, null], [42606, 44012, null], [44012, 45349, null], [45349, 46342, null], [46342, 47624, null], [47624, 49182, null], [49182, 50248, null], [50248, 51219, null], [51219, 52269, null], [52269, 53153, null], [53153, 53194, null], [53194, 53940, null], [53940, 54341, null], [54341, 55382, null], [55382, 56289, null], [56289, 57020, null], [57020, 57491, null], [57491, 58489, null], [58489, 59598, null], [59598, 61170, null], [61170, 61526, null], [61526, 62963, null], [62963, 65041, null], [65041, 66776, null], [66776, 68031, null], [68031, 68725, null], [68725, 70468, null], [70468, 72125, null], [72125, 73875, null], [73875, 75740, null], [75740, 76463, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 76463, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 76463, null]], "pdf_page_numbers": [[0, 755, 1], [755, 1203, 2], [1203, 1203, 3], [1203, 2110, 4], [2110, 4404, 5], [4404, 6388, 6], [6388, 6725, 7], [6725, 7885, 8], [7885, 9764, 9], [9764, 10494, 10], [10494, 10937, 11], [10937, 11900, 12], [11900, 12600, 13], [12600, 13625, 14], [13625, 14289, 15], [14289, 15603, 16], [15603, 16262, 17], [16262, 16981, 18], [16981, 18625, 19], [18625, 19932, 20], [19932, 21193, 21], [21193, 22687, 22], [22687, 23552, 23], [23552, 24714, 24], [24714, 26222, 25], [26222, 29400, 26], [29400, 30279, 27], [30279, 31597, 28], [31597, 32633, 29], [32633, 33573, 30], [33573, 34132, 31], [34132, 34917, 32], [34917, 35419, 33], [35419, 35652, 34], [35652, 37369, 35], [37369, 38827, 36], [38827, 40285, 37], [40285, 41316, 38], [41316, 42606, 39], [42606, 44012, 40], [44012, 45349, 41], [45349, 46342, 42], [46342, 47624, 43], [47624, 49182, 44], [49182, 50248, 45], [50248, 51219, 46], [51219, 52269, 47], [52269, 53153, 48], [53153, 53194, 49], [53194, 53940, 50], [53940, 54341, 51], [54341, 55382, 52], [55382, 56289, 53], [56289, 57020, 54], [57020, 57491, 55], [57491, 58489, 56], [58489, 59598, 57], [59598, 61170, 58], [61170, 61526, 59], [61526, 62963, 60], [62963, 65041, 61], [65041, 66776, 62], [66776, 68031, 63], [68031, 68725, 64], [68725, 70468, 65], [70468, 72125, 66], [72125, 73875, 67], [73875, 75740, 68], [75740, 76463, 69]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 76463, 0.19419]]}
olmocr_science_pdfs
2024-12-09
2024-12-09
2be1b02ebc34354af697e659f7d4a02693ef6c29
gRPC Network Management Interface (gNMI) draft-openconfig-rtgwg-gnmi-spec-00 Abstract This document describes the gRPC Network Management Interface (gNMI), a network management protocol based on the gRPC RPC framework. gNMI supports retrieval and manipulation of state from network elements where the data is represented by a tree structure, and addressable by paths. The gNMI service defines operations for configuration management, operational state retrieval, and bulk data collection via streaming telemetry. Status of This Memo This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress." This Internet-Draft will expire on September 14, 2017. Copyright Notice Copyright (c) 2017 IETF Trust and the persons identified as the document authors. All rights reserved. This document is subject to BCP 78 and the IETF Trust’s Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License. Table of Contents 1. Introduction ............................................. 3 2. Common Message Types and Encodings ....................... 4 2.1. Reusable Notification Message Format ................. 4 2.2. Common Data Types .................................... 5 2.2.1. Timestamps ..................................... 5 2.2.2. Paths ......................................... 5 2.2.3. Node Values .................................... 6 2.3. Encoding Data in an Update Message ................... 6 2.3.1. JSON and JSON_IETF ................................ 6 2.3.2. Bytes ......................................... 9 2.3.3. Protobuf ....................................... 9 2.3.4. ASCII ......................................... 9 2.4. Use of Data Schema Paths .............................. 9 2.4.1. Path Prefixes ................................... 9 2.4.2. Path Aliases .................................... 10 2.4.3. Interpretation of Paths Used in RPCs ............ 11 2.5. Error handling ........................................ 12 2.6. Schema Definition Models .............................. 13 2.6.1. The ModelData message ............................ 13 3. Service Definition ........................................ 14 3.2. Capability Discovery .................................. 15 3.2.1. The CapabilityRequest message .................... 15 3.2.2. The CapabilityResponse message .................. 15 3.3. Retrieving Snapshots of State Information ............. 16 3.3.1. The GetRequest Message ............................ 16 3.3.2. The GetResponse message .......................... 17 3.3.3. Considerations for using Get ..................... 18 3.4. Modifying State ....................................... 18 3.4.1. The SetRequest Message ............................ 19 3.4.2. The SetResponse Message .......................... 20 3.4.3. Transactions ..................................... 20 3.4.4. Modes of Update: Replace versus Update ........... 21 3.4.5. Modifying Paths Identified by Attributes .......... 21 3.4.6. Deleting Configuration ............................ 22 3.4.7. Error Handling ................................... 23 3.5. Subscribing to Telemetry Updates ..................... 24 3.5.1. Managing Subscriptions ............................ 26 3.5.2. Sending Telemetry Updates ......................... 32 1. Introduction This document defines a gRPC [1]-based protocol for the modification and retrieval of configuration from a network element, as well as the control and generation of telemetry streams from a network element to a data collection system. The intention is that a single gRPC service definition can cover both configuration and telemetry - allowing a single implementation on the network element, as well as a single NMS element to interact with the device via telemetry and configuration RPCs. All messages within the gRPC service definition are defined as protocol buffers [2] (specifically proto3). gRPC service definitions are expected to be described using the relevant features of the protobuf IDL. A reference protobuf definition is maintained in [REFERENCE-PROTO] [3]. The current, authoritative version of this specification is available at [GNMI-SPEC] [4]. The service defined within this document is assumed to carry payloads that contain data instances of OpenConfig [5] YANG schemas, but can be used for any data with the following characteristics: 1. structure can be represented by a tree structure where nodes can be uniquely identified by a path consisting of node names, or node names coupled with attributes; 2. values can be serialised into a scalar object. Currently, values may be serialised to a scalar object through encoding as a JSON string, a byte-array, or a serialised protobuf object - although the definition of new serialisations is possible. Throughout this specification the following terminology is used: - _Telemetry_ - refers to streaming data relating to underlying characteristics of the device - either operational state or configuration. - _Configuration_ - elements within the data schema which are read/write and can be manipulated by the client. 2. Common Message Types and Encodings 2.1. Reusable Notification Message Format When a target wishes to communicate data relating to the state of its internal database to an interested client, it does so via means of a common "Notification" message. Notification messages are reused in other higher-layer messages for various purposes. The exact use of the Notification message is described on a per-RPC basis. The fields of the Notification message are as follows: - **"timestamp"** - The time at which the data was collected by the device from the underlying source, or the time that the target generated the Notification message (in the case that the data does not reflect an underlying data source). This value is always represented according to the definition in Section 2.2.1. - **"prefix"** - a prefix which is applied to all path fields (encoded as per Section 2.2.2) included in the "Notification" message. The paths expressed within the message are formed by the concatenation of "prefix + path". The "prefix" always precedes the "path" elements. Further semantics of prefixes are described in Section 2.4.1. - **"alias"** - a string providing an alias for the prefix specified within the notification message. The encoding of an alias, and the procedure for their creation is described in Section 2.4.2." - **"update"** - a list of update messages that indicate changes in the underlying data of the target. Both modification and creation of data is expressed through the update message. * An "Update" message has two subfields: + **"path"** - a path encoded as per Section 2.2.2. + **"value"** - a value encoded as per Section 2.2.3. * The set of paths that are specified within the list of updates MUST be unique. In this context, the path is defined to be the fully resolved path (including the prefix). In the case that there is a duplicate path specified within an update, only the final update should be processed by the receiving entity. - "delete" - a list of paths (encoded as per Section 2.2.2) that indicate the deletion of data nodes on the target. The creator of a Notification message MUST include the "timestamp" field. All other fields are optional. 2.2. Common Data Types 2.2.1. Timestamps Timestamp values MUST be represented as the number of nanoseconds since the Unix epoch (January 1st 1970 00:00:00 UTC). The value MUST be encoded as a signed 64-bit integer ("int64"). 2.2.2. Paths Paths are represented according to gNMI Path Conventions [6], a simplified form of XPATH. Rather than utilising a single string to represent the path - with the "/" character separating each element of the path, the path is represented by an ordered list of strings, starting at the root node, and ending at the most specific path element. A path is represented by the "Path" message with the following fields: - "element" -- a set of path elements, encoded as strings (see examples below). - "origin" - field which MAY be used to disambiguate the path if necessary. For example, the origin may be used to indicate which organization defined the schema to which the path belongs. Each "Path" element should correspond to a node in the data tree. For example, the path "/a/b/c/d" is encoded as: ```plaintext path: < element: "a" element: "b" element: "c" element: "d" > ``` Where attributes are to be specified, these are encoded alongside the node name within the path element, for example a node specified by "/a/e[key=k1]/f/g" would have the path encoded as: ```xml path: < element: "a" element: "e[key=k1]" element: "f" element: "g" > ``` The root node ("/") is indicated by encoding a single path element which is an empty string, as per the following example: ```xml path: < element: "" > ``` Paths (defined to be the concatenation of the "Prefix" and "Path" within the message) specified within a message MUST be absolute - no messages with relative paths should be generated. ### 2.2.3. Node Values The value of a data node is encoded as a two-field message: - **"bytes"** - an arbitrary series of bytes which indicates the value of the node referred to within the message context. - **"type"** - a field indicating the type of data contained in the bytes field. Currently defined types are: ### 2.3. Encoding Data in an Update Message #### 2.3.1. JSON and JSON_IETF The "JSON" type indicates that the value included within the "bytes" field of the node value message is encoded as a JSON string. This format utilises the specification in RFC7159 [7]. Additional types (e.g., "JSON_IETF") are utilised to indicate specific additional characteristics of the encoding of the JSON data (particularly where they relate to serialisation of YANG-modeled data). For any JSON encoding: - In the case that the data item at the specified path is a leaf node (i.e., has no children) the value of that leaf is encoded directly - i.e., the "bare" value is specified (i.e., a JSON object is not required, and a bare JSON value is included). - Where the data item referred to has child nodes, the value field contains a serialised JSON entity (object or array) corresponding to the referenced item. Using the following example data tree: ``` root + | +-- a + | | +-- b[name=b1] + | | | +-- c + | | | | +-- d (string) | | | | +-- e (uint32) ``` The following serialisations would be used (note that the examples below follow the conventions for textproto, and Golang-style backticks are used for string literals that would otherwise require escaping): For "/a/b[name=b1]/c/d": ``` update: < path: < element: "a" element: "b[name=b1]" element: "c" element: "d" > value: < value: "AStringValue" type: JSON > > ``` For "/a/b[name=b1]/c/e": ``` update: < ``` For "/a/b[name=b1]/c": ```xml update: < path: < element: "a" element: "b[name=b1]" element: "c" > value: < value: { "d": "AStringValue", "e": 10042 } type: JSON > >} ``` For "/a": ```xml update: < path: < element: "a" > value: < value: '{ "b": [ { "name": "b1", "c": { "d": "AStringValue", "e": 10042 } } ]} type: JSON_IETF > >} ``` Note that all JSON values MUST be valid JSON. That is to say, whilst a value or object may be included in the message, the relevant quoting according to the JSON specification in RFC7159 [8] must be used. This results in quoted string values, and unquoted number values. "JSON_IETF" encoded data MUST conform with the rules for JSON serialisation described in RFC7951 [9]. Data specified with a type of JSON MUST be valid JSON, but no additional constraints are placed upon it. An implementation MUST NOT serialise data with mixed "JSON" and "JSON_IETF" encodings. Both the client and target MUST support the JSON encoding as a minimum. 2.3.2. Bytes The "BYTES" type indicates that the contents of the "bytes" field of the message contains a byte sequence whose semantics is opaque to the protocol. 2.3.3. Protobuf The "PROTobuf" type indicates that the contents of the "bytes" field of the message contains a serialised protobuf message. Note that in the case that the sender utilises this type, the receiver must understand the schema (and hence the type of protobuf message that is serialised) in order to decode the value. Such agreement is not guaranteed by the protocol and hence must be established out-of-band. 2.3.4. ASCII The "ASCII" type indicates that the contents of the "bytes" field of the message contains system-formatted ASCII encoded text. For configuration data, for example, this may consist of semi-structured CLI configuration data formatted according to the target platform. The gNMI protocol does not define the format of the text - this must be established out-of-band. 2.4. Use of Data Schema Paths 2.4.1. Path Prefixes In a number of messages, a prefix can be specified to reduce the lengths of path fields within the message. In this case, a "prefix" field is specified within a message - comprising of a valid path encoded according to Section Section 2.2.2 In the case that a prefix is specified, the absolute path is comprised of the concatenation of the list of path elements representing the prefix and the list of path elements in the "path" field. For example, again considering the data tree shown in Section Section 2.3.1 if a "Notification" message updating values, a prefix could be used to refer to the "/a/b[name=b1]/c/d" and "/a/b[name=b1]/c/e" data nodes: notification: < timestamp: (timestamp) // timestamp as int64 prefix: < element: "a" element: "b[name=b1]" element: "c" > update: < path: < element: "d" > value: < value: "AStringValue" type: JSON > > update: < path: < element: "e" > value: < value: 10042 // converted to int representation type: JSON > > > 2.4.2. Path Aliases In some cases, a client or target MAY desire to utilises aliases for a particular path - such that subsequent messages can be compressed by utilising the alias, rather than using a complete representation of the path. Doing so reduces total message length, by ensuring that redundant information can be removed. Support for path aliases MAY be provided by a target. In a case where a target does not support aliases, the maximum message length SHOULD be considered, especially in terms of bandwidth utilisation, and the efficiency of message generation. A path alias is encoded as a string. In order to avoid valid data paths clashing with aliases (e.g., "a" in the above example), an alias name MUST be prefixed with a "#" character. The means by which an alias is created is defined on a per-RPC basis. In order to delete an alias, the alias name is sent with the path corresponding to the alias empty. Aliases MUST be specified as a fully expanded path, and hence MUST NOT reference other aliases within their definition, such that a single alias lookup is sufficient to resolve the absolute path. ### 2.4.3. Interpretation of Paths Used in RPCs When a client specifies a path within an RPC message which indicates a read, or retrieval of data, the path MUST be interpreted such that it refers to the node directly corresponding with the path *and* all its children. The path refers to the direct node and all descendent branches which originate from the node, recursively down to each leaf element. If specific nodes are expected to be excluded then an RPC MAY provide means to filter nodes, such as regular-expression based filtering, lists of excluded paths, or metadata-based filtering (based on annotations of the data schema being manipulated, should such annotations be available and understood by both client and target). For example, consider the following data tree: ``` root | +-- childA + | | | +-- leafA1 | +-- leafA2 | +-- childA3 ++ | +-- leafA31 | +-- leafA32 | +-- childB + | | | +-- leafB1 | +-- leafB2 ``` A path referring to "root" (which is represented by a Path consisting of a single element specifying an empty string) should result in the nodes "childA" and "childB" and all of their children ("leafA1, leafA2, leafB1, leafB2, childA3, leafA31" and "leafA32") being considered by the relevant operation. In the case that the RPC is modifying the state of data (i.e., a write operation), such recursion is not required - rather the modification operation should be considered to be targeted at the node within the schema that is specified by the path, and the value should be deserialized such that it modifies the content of any child nodes if required to do so. 2.5. Error handling Where the client or target wishes to indicate an error, an "Error" message is generated. Errors MUST be represented by a canonical gRPC error code (Java [10], Golang [11], C++ [12]). The entity generating the error MUST specify a free-text string which indicates the context of the error, allowing the receiving entity to generate log entries that allow a human operator to understand the exact error that occurred, and its context. Each RPC defines the meaning of the relevant canonical error codes within the context of the operation it performs. The canonical error code that is chosen MUST consider the expected behavior of the client on receipt of the message. For example, error codes which indicate that a client may subsequently retry SHOULD only be used where retrying the RPC is expected to result in a different outcome. A re-usable "Error" message MUST be used when sending errors in response to an RPC operation. This message has the following fields: - "code" - an unsigned 32-bit integer value corresponding to the canonical gRPC error code. - "message" - a human-readable string describing the error condition in more detail. This string is not expected to be machine- parsable, but rather provide contextual information which may be passed to upstream systems. - "data" - an arbitrary sequence of bytes (encoded as "[proto.Any](https://github.com/google/protobuf/blob/master/src/ google/protobuf/any.proto)") which provides further contextual information relating to the error. 2.6. Schema Definition Models The data tree supported by the target is expected to be defined by a set of schemas. The definition and format of these models is out of scope of this specification (YANG-modeled data is one example). In the case that such schema definitions are used, the client should be able to determine the models that are supported by the target, so that it can generate valid modifications to the data tree, and interpret the data returned by "Get" and "Subscribe" RPC calls. Additionally, the client may wish to restrict the set of models that are utilised by the target so that it can validate the data returned to it against a specific set of data models. This is particularly relevant where the target may otherwise add new values to restricted value data elements (e.g., those representing an enumerated type), or augment new data elements into the data tree. In order to allow the client to restrict the set of data models to be used when interacting with the target, the client MAY discover the set of models that are supported by the target using the "Capabilities" RPC described in Section 3.2. For subsequent "Get" and "Subscribe" RPCs, the client MAY specify the models to be used by the target. The set of models to use is expressed as a "ModelData" message, as specified in Section 2.6.1. If the client specifies a set of models in a "Get" or "Subscribe" RPC, the target MUST NOT utilize data tree elements that are defined in schema modules outside the specified set. In addition, where there are data tree elements that have restricted value sets (e.g., enumerated types), and the set is extended by a module which is outside of the set, such values MUST NOT be used in data instances that are sent to the client. Where there are other elements of the schema that depend on the existence of such enumerated values, the target MUST NOT include such values in data instances sent to the client. 2.6.1. The ModelData message The "ModelData" message describes a specific model that is supported by the target and used by the client. The fields of the "ModelData" message identify a data model registered in a model catalog, as described in [MODEL_CATALOG_DOC] [13] (the schema of the catalog itself - expressed in YANG - is described in [MODEL_CATALOG_YANG [14]]). Each model specified by a "ModelData" message may refer to a specific schema module, a bundle of modules, or an augmentation or deviation, as described by the catalog entry. Each "ModelData" message contains the following fields: "name" - name of the model expressed as a string. "organization" - the organization publishing the model, expressed as a string. "version" - the supported (or requested) version of the model, expressed as a string which represents the semantic version of the catalog entry. The combination of "name", "organization", and "version" uniquely identifies an entry in the model catalog. 3. Service Definition A single gRPC service is defined - future revisions of this specification MAY result in additional services being introduced, and hence an implementation MUST NOT make assumptions that limit to a single service definition. The service consists of the following RPCs: o "Capabilities" - defined in Section 3.2 and used by the client and target as an initial handshake to exchange capability information. o "Get" - defined in Section 3.3, used to retrieve snapshots of the data on the target by the client. o "Set" - defined in Section 3.4 and used by the client to modify the state of the target. o "Subscribe" - defined in Section 3.5 and used to control subscriptions to data on the target by the client. The session between the client and server MUST be encrypted using TLS - and a target or client MUST NOT fall back to unencrypted channels. New connections are mutually authenticated -- each entity validates the X.509 certificate of the remote entity to ensure that the remote entity is both known, and authorized to connect to the local system. If the target is expected to authenticate an RPC operation, the client MUST supply a username and password in the metadata of the RPC message (e.g., "SubscribeRequest", "GetRequest" or "SetRequest"). If the client supplies username/password credentials, the target MUST authenticate the RPC per its local authentication functionality. Authorization is also performed per-RPC by the server, through validating client-provided metadata. The client MAY include the appropriate AAA metadata, which MUST contain a username, and MAY include a password in the context of each RPC call it generates. If the client includes both username and password, the target MUST authenticate and authorize the request. If the client only supplies the username, the target MUST authorize the RPC request. A more detailed discussion of the requirements for authentication and encryption used for gNMI is in [GNMI-AUTH] [15]. 3.2. Capability Discovery A client MAY discover the capabilities of the target using the "Capabilities" RPC. The "CapabilityRequest" message is sent by the client to interrogate the target. The target MUST reply with a "CapabilityResponse" message that includes its gNMI service version, the versioned data models it supports, and the supported data encodings. This information is used in subsequent RPC messages from the client to indicate the set of models that the client will use (for "Get", "Subscribe" as described in Section 2.6), and the encoding to be used for the data. When the client does not specify the models it is using, the target SHOULD use all data schema modules that it supports when considering the data tree to be addressed. If the client does not specify the encoding in an RPC message, it MUST send JSON encoded values (the default encoding). 3.2.1. The CapabilityRequest message The "CapabilityRequest" message is sent by the client to request capability information from the target. The "CapabilityRequest" message carries no additional fields. 3.2.2. The CapabilityResponse message The "CapabilityResponse" message has the following fields: - "supported_models" - a set of "ModelData" messages (as defined in Section 2.6.1) describing each of the models supported by the target - "supported_encodings" - an enumeration field describing the data encodings supported by the target, as described in Section 2.3. 3.3. Retrieving Snapshots of State Information In some cases, a client may require a snapshot of the state that exists on the target. In such cases, a client desires some subtree of the data tree to be serialized by the target and transmitted to it. It is expected that the values that are retrieved (whether writeable by the client or not) are collected immediately and provided to the client. The "Get" RPC provides an interface by which a client can request a set of paths to be serialized and transmitted to it by the target. The client sends a "GetRequest" message to the target, specifying the data that is to be retrieved. The fields of the "GetRequest" message are described in Section 3.3.1. Upon reception of a "GetRequest", the target serializes the requested paths, and returns a "GetResponse" message. The target MUST reflect the values of the specified leaves at a particular collection time, which MAY be different for each path specified within the "GetRequest" message. The target closes the channel established by the "Get" RPC following the transmission of the "GetResponse" message. 3.3.1. The GetRequest Message The "GetRequest" message contains the following fields: - "prefix" - a path (specified as per Section 2.2.2), and used as described in Section 2.4.1. The prefix is applied to all paths within the "GetRequest" message. - "path" - a set of paths (expressed as per Section 2.2.2) for which the client is requesting a data snapshot from the target. The path specified MAY utilize wildcards. In the case that the path specified is not valid, the target MUST populate the "error" field of the "GetResponse" message indicating an error code of "InvalidArgument" and SHOULD provide information about the invalid path in the error message. - "type" - the type of data that is requested from the target. The valid values for type are described below. - "encoding" - the encoding that the target should utilise to serialise the subtree of the data tree requested. The type MUST be one of the encodings specified in Section 2.3. If the "Capabilities" RPC has been utilised, the client SHOULD use an encoding advertised as supported by the target. If the encoding is not specified, JSON MUST be used. If the target does not support the specified encoding, the target MUST populate the error field of the "GetResponse" message, specifying an error of "InvalidArgument". The error message MUST indicate that the specified encoding is unsupported. - "use_models" - a set of "ModelData" messages (defined in Section 2.6.1) indicating the schema definition modules that define the data elements that should be returned in response to the Get RPC call. The semantics of the "use_models" field are defined in Section 2.6. Since the data tree stored by the target may consist of different types of data (e.g., values that are operational in nature, such as protocol statistics) - the client MAY specify that a subset of values in the tree are of interest. In order for such filtering to be implemented, the data schema on the target MUST be annotated in a manner which specifies the type of data for individual leaves, or subtrees of the data tree. The types of data currently defined are: - "CONFIG" - specified to be data that the target considers to be read/write. If the data schema is described in YANG, this corresponds to the "config true" set of leaves on the target. - "STATE" - specified to be the read-only data on the target. If the data schema is described in YANG, "STATE" data is the "config false" set of leaves on the target. - "OPERATIONAL" - specified to be the read-only data on the target that is related to software processes operating on the device, or external interactions of the device. If the "type" field is not specified, the target MUST return CONFIG, STATE and OPERATIONAL data fields in the tree resulting from the client’s query. 3.3.2. The GetResponse message The "GetResponse" message consists of: o "notification" - a set of "Notification" messages, as defined in Section 2.1. The target MUST generate a "Notification" message for each path specified in the client’s "GetRequest", and hence MUST NOT collapse data from multiple paths into a single "Notification" within the response. The "timestamp" field of the "Notification" message MUST be set to the time at which the target’s snapshot of the relevant path was taken. o "error" - an "Error" message encoded as per the specification in Section 2.5, used to indicate errors in the "GetRequest" received by the target from the client. 3.3.3. Considerations for using Get The "Get" RPC is intended for clients to retrieve relatively small sets of data as complete objects, for example a part of the configuration. Such requests are not expected to put a significant resource burden on the target. Since the target is expected to return the entire snapshot in the "GetResponse" message, "Get" is not well-suited for retrieving very large data sets, such as the full contents of the routing table, or the entire component inventory. For such operations, the "Subscribe" RPC is the recommended mechanism, e.g. using the "ONCE" mode as described in Section 3.5. Another consideration for "Get" is that the timestamp returned is associated with entire set of data requested, although individual data items may have been sampled by the target at different times. If the client requires higher accuracy for individual data items, the "Subscribe" RPC is recommended to request a telemetry stream (see Section 3.5.2). 3.4. Modifying State Modifications to the state of the target are made through the "Set" RPC. A client sends a "SetRequest" message to the target indicating the modifications it desires. A target receiving a "SetRequest" message processes the operations specified within it - which are treated as a transaction (see Section 3.4.3). The server MUST process deleted paths (within the "delete" field of the "SetRequest"), followed by paths to be replaced (within the "replace" field), and finally updated paths (within the "update" field). The order of the replace and update fields MUST be treated as significant within a single "SetRequest" message. If a single path is specified multiple times for a single operation (i.e., within "update" or "replace"), then the state of the target MUST reflect the application of all of the operations in order, even if they overwrite each other. In response to a "SetRequest", the target MUST respond with a "SetResponse" message. For each operation specified in the "SetRequest" message, an "UpdateResult" message MUST be included in the response field of the "SetResponse". The order in which the operations are applied MUST be maintained such that "UpdateResult" messages can be correlated to the "SetRequest" operations. In the case of a failure of an operation, the "error" field of the "UpdateResult" message MUST be populated with an "Error" message as per the specification in Section 2.5. In addition, the "error" field of the "SetResponse" message MUST be populated with an error message indicating the success or failure of the set of operations within the "SetRequest" message (again using the error handling behavior defined in Section 2.5). 3.4.1. The SetRequest Message A "SetRequest" message consists of the following fields: - "prefix" - specified as per Section 2.4.1. The prefix specified is applied to all paths defined within other fields of the message. - "delete" - A set of paths, specified as per Section 2.2.2, which are to be removed from the data tree. A specification of the behavior of a delete is defined in Section 3.4.6. - "replace" - A set of "Update" messages indicating elements of the data tree whose content is to be replaced. - "update" - A set of "Update" messages indicating elements of the data tree whose content is to be updated. The semantics of "updating" versus "replacing" content are defined in Section 3.4.4 A re-usable "Update" message is utilised to indicate changes to paths where a new value is required. The "Update" message contains two fields: - "path" - a path encoded as per Section 2.2.2 indicating the path of the element to be modified. - "value" - a value encoded as per Section 2.2.3 indicating the value applied to the specified node. The semantics of how the node is updated is dependent upon the context of the update message, as specified in Section 3.4.4. 3.4.2. The SetResponse Message A "SetResponse" consists of the following fields: - "prefix" - specified as per Section 2.4.1. The prefix specified is applied to all paths defined within other fields of the message. - "message" - an error message as specified in Section 2.5. The target SHOULD specify a "message" in the case that the update was successfully applied, in which case an error code of "OK (0)" "MUST" be specified. In cases where an update was not successfully applied, the contents of the error message MUST be specified as per Section 2.5. - "response" - containing a list of responses, one per operation specified within the "SetRequest" message. Each response consists of an "UpdateResult" message with the following fields: - "timestamp" - a timestamp (encoded as per Section 2.2.1) at which the set request message was accepted by the system. - "path" - the path (encoded as per Section 2.2.2) specified within the "SetRequest". In the case that a common prefix was not used within the "SetRequest", the target MAY specify a "prefix" to reduce repetition of path elements within multiple "UpdateResult" messages in the "request" field. - "op" - the operation corresponding to the path. This value MUST be one of "DELETE", "REPLACE", or "UPDATE". - "message" - an error message (as specified in Section 2.5). This field follows the same rules as the message field within the "SetResponse" message specified above. 3.4.3. Transactions All changes to the state of the target that are included in an individual "SetRequest" message are considered part of a transaction. That is, either all modifications within the request are applied, or the target MUST rollback the state changes to reflect its state before any changes were applied. The state of the target MUST NOT appear to be changed until such time as all changes have been accepted successfully. Hence, telemetry update messages MUST NOT reflect a change in state until such time as the intended modifications have been accepted. As per the specification in Section 3.4, within an individual transaction ("SetRequest") the order of operations is "delete", "replace", "update". As the scope of a "transaction" is a single "SetRequest" message, a client desiring a set of changes to be applied together MUST ensure that they are encapsulated within a single "SetRequest" message. 3.4.4. Modes of Update: Replace versus Update Changes to read-write values on the target are applied based on the "replace" and "update" fields of the "SetRequest" message. For both replace and update operations, if the path specified does not exist, the target MUST create the data tree element and populate it with the data in the "Update" message, provided the path is valid according to the data tree schema. If invalid values are specified, the target MUST cease processing updates within the "SetRequest" method, return the data tree to the state prior to any changes, and return a "SetResponse" message indicating the error encountered. For "replace" operations, the behavior regarding omitted data elements in the "Update" depends on whether they refer to non-default values (i.e., set by a previous "SetRequest"), or unmodified defaults. When the "replace" operation omits values that have been previously set, they MUST be treated as deleted from the data tree. Otherwise, omitted data elements MUST be created with their default values on the target. For "update" operations, only the value of those data elements that are specified explicitly should be treated as changed. 3.4.5. Modifying Paths Identified by Attributes The path convention defined in Section 2.2.2 allows nodes in the data tree to be identified by a unique set of node names (e.g., "/a/b/c/d") or paths that consist of node names coupled with attributes (e.g., "/a/e[10]"). In the case where a node name plus attribute name is required to uniquely identify an element (i.e., the path within the schema represents a list, map, or array), the following considerations apply: - In the case that multiple attribute values are required to uniquely address an element - e.g., "/a/f[k1=10][k2=20]" - and a replace or update operation’s path specifies a subset of the attributes (e.g., "/a/f[10]"), then this MUST be considered an error by the target system - and an error code of "InvalidArgument (3)" specified. 3.4.6. Deleting Configuration Where a path is contained within the "delete" field of the "SetRequest" message, it should be removed from the target’s data tree. In the case that the path specified is to an element that has children, these children MUST be recursively deleted. If a wildcard path is utilised, the wildcards MUST be expanded by the target, and the corresponding elements of the data tree deleted. Such wildcards MUST support paths specifying a subset of attributes required to identify entries within a collection (list, array, or map) of the data schema. For example, consider a tree corresponding to the examples above, as illustrated below. ``` root + | + a --+ | | +-- f[k1=10][k2=20] --+ | | | k1 = 10 | | | k2 = 20 | +-- f[k1=10][k2=21] --+ | | k1 = 10 | | k2 = 21 ``` In this case, nodes "k1" and "k2" are standalone nodes within the schema, but also correspond to attribute values for the node "f". In this case, an update or replace message specifying a path of "/a/f[k1=10][k2=20]" setting the value of "k1" to 100 MUST be considered erroneous, and an error code of "InvalidArgument (3)" specified. In the case that key values are specified both as attributes of a node, and as their own elements within the data tree, update or replace operations that modify instances of the key in conflicting ways MUST be considered an error. The target MUST return an error code of "InvalidArgument (3)". For example, consider a tree corresponding to the examples above, as illustrated below. ``` root + | + a --+ | | +-- f[k1=10][k2=20] --+ | | | k1 = 10 | | | k2 = 20 | +-- f[k1=10][k2=21] --+ | | k1 = 10 | | k2 = 21 ``` Where the path specified refers to a node which itself represents the collection of objects (list, map, or array) a replace operation MUST remove all collection entries that are not supplied in the value provided in the "SetRequest". An update operation MUST be considered to add new entries to the collection if they do not exist. Where the path specified refers to a node which itself represents the collection of objects (list, map, or array) a replace operation MUST remove all collection entries that are not supplied in the value provided in the "SetRequest". An update operation MUST be considered to add new entries to the collection if they do not exist. In the case that a path specifies an element within the data tree that does not exist, these deletes MUST be silently accepted. 3.4.7. Error Handling When a client issues a "SetRequest", and the target is unable to apply the specified changes, an error MUST be reported to the client. The error is specified in multiple places: - Within a "SetResponse" message, the error field indicates the completion status of the entire transaction. - With a "UpdateResult" message, where the error field indicates the completion status of the individual operation. The target MUST specify the "message" field within a "SetResponse" message such that the overall status of the transaction is reflected. In the case that no error occurs, the target MUST complete this field specifying the "OK (0)" canonical error code. In the case that any operation within the "SetRequest" message fails, then (as per Section 3.4.3), the target MUST NOT apply any of the specified changes, and MUST consider the transaction as failed. The target SHOULD set the "message" field of the "SetResponse" message to an error message with the code field set to "Aborted (10)", and MUST set the "message" field of the "UpdateResult" corresponding to the failed operation to an "Error" message indicating failure. In the case that the processed operation is not the only operation within the "SetRequest" the target MUST set the "message" field of the "UpdateResult" messages for all other operations, setting the code field to "Aborted (10)". For the operation that the target is unable to process, the "message" field MUST be set to a specific error code indicating the reason for failure based on the following mappings to canonical gRPC error codes: - When the client has specified metadata requiring authentication (see Section 3.1), and the authentication fails - "Unauthenticated (16)". - When the client does not have permission to modify the path specified by the operation - "PermissionDenied (7)". - When the operation specifies a path that cannot be parsed by the target - "InvalidArgument (3)". In this case, the "message" field of the "Error" message specified SHOULD specify human-readable text indicating that the path could not be parsed. o When the operation is an update or replace operation that corresponds to a path that is not valid - "NotFound (5)". In this case the "message" field of the "Error" message specified SHOULD specify human-readable text indicating the path that was invalid. o When the operation is an update or replace operation that includes an invalid value within the "Update" message specified - "InvalidArgument (3)". This error SHOULD be used in cases where the payload specifies scalar values that do not correspond to the correct schema type, and in the case that multiple values are specified using a particular encoding (e.g., JSON) which cannot be decoded by the target. 3.5. Subscribing to Telemetry Updates When a client wishes to receive updates relating to the state of data instances on a target, it creates a subscription via the "Subscribe" RPC. A subscription consists of one or more paths, with a specified subscription mode. The mode of each subscription determines the triggers for updates for data sent from the target to the client. All requests for new subscriptions are encapsulated within a "SubscribeRequest" message - which itself has a mode which describes the longevity of the subscription. A client may create a subscription which has a dedicated stream to return one-off data ("ONCE"); a subscription that utilizes a stream to periodically request a set of data ("POLL"); or a long-lived subscription that streams data according to the triggers specified within the individual subscription’s mode ("STREAM"). The target generates messages according to the type of subscription that has been created, at the frequency requested by the client. The methods to create subscriptions are described in Section 3.5.1. Subscriptions are created for a set of paths - which cannot be modified throughout the lifetime of the subscription. In order to cancel a subscription, the client closes the gRPC channel over which the "Subscribe" RPC was initiated, or terminates the entire gRPC session. Subscriptions are fundamentally a set of independent update messages relating to the state of the data tree. That is, it is not possible for a client requesting a subscription to assume that the set of update messages received represent a snapshot of the data tree at a particular point in time. Subscriptions therefore allow a client to: - Receive ongoing updates from a target which allow synchronization between the client and target for the state of elements within the data tree. data tree. In this case (i.e., a "STREAM" subscription), a client creating a subscription receives an initial set of updates, terminated by a message indicating that initial synchronisation has completed, and then receives subsequent updates indicating changes to the initial state of those elements. - Receive a single view (polled, or one-off) for elements of the data tree on a per-data element basis according to the state that they are in at the time that the message is transmitted. This can be more resource efficient for both target and client than a "GetRequest" for large subtrees within the data tree. The target does not need to coalesce values into a single snapshot view, or create an in-memory representation of the subtree at the time of the request, and subsequently transmit this entire view to the client. Based on the fact that subsequent update messages are considered to be independent, and to ensure that the efficiencies described above can be achieved, by default a target MUST NOT aggregate values within an update message. In some cases, however, elements of the data tree may be known to change together, or need to be interpreted by the subscriber together. Such data MUST be explicitly marked in the schema as being eligible to be aggregated when being published. Additionally, the subscribing client MUST explicitly request aggregation of eligible schema elements for the subscription – by means of the "allow_aggregation" flag within a "SubscriptionList" message. For elements covered by a subscription that are not explicitly marked within the schema as being eligible for aggregation the target MUST NOT coalesce these values, regardless of the value of the "allow_aggregation" flag. When aggregation is not permitted by the client or the schema each update message MUST contain a (key, value) pair – where the key MUST be a path to a single leaf element within the data tree (encoded according to Section 2.2.2). The value MUST encode only the value of the leaf specified. In most cases, this will be a scalar value (i.e., a JSON value if a JSON encoding is utilised), but in some cases, where an individual leaf element within the schema represents an object, it MAY represent a set of values (i.e., a JSON or Protobuf object). Where aggregation is permitted by both the client and schema, each update message MUST contain a key value pair, where the key MUST be the path to the element within the data tree which is explicitly marked as being eligible for aggregation. The value MUST be an object which encodes the children of the data tree element specified. For JSON, the value is therefore a JSON object, and for Protobuf is a series of binary-encoded Protobuf messages. 3.5.1. Managing Subscriptions 3.5.1.1. The SubscribeRequest Message A "SubscribeRequest" message is sent by a client to request updates from the target for a specified set of paths. The fields of the "SubscribeRequest" are as follows: - A group of fields, only one of which may be specified, which indicate the type of operation that the "SubscribeRequest" relates to. These are: - "subscribe" - a "SubscriptionList" message specifying a new set of paths that the client wishes to subscribe to. - "poll" - a "Poll" message used to specify (on an existing channel) that the client wishes to receive a polled update for the paths specified within the subscription. The semantics of the "Poll" message are described in Section 3.5.1.5.3. - "aliases" - used by a client to define (on an existing channel) a new path alias (as described in Section 2.4.2). The use of the aliases message is described in Section 3.5.1.6. In order to create a new subscription (and its associated channel) a client MUST send a "SubscribeRequest" message, specifying the "subscribe" field. The "SubscriptionList" may create a one-off subscription, a poll-only subscription, or a streaming subscription. In the case of ONCE subscriptions, the channel between client and target MUST be closed following the initial response generation. Subscriptions are set once, and subsequently not modified by a client. If a client wishes to subscribe to additional paths from a target, it MUST do so by sending an additional "Subscribe" RPC call, specifying a new "SubscriptionList" message. In order to end an existing subscription, a client simply closes the gRPC channel that relates to that subscription. If a channel is initiated with a "SubscribeRequest" message that does not specify a "SubscriptionList" message with the "request" field, the target MUST consider this an error. If an additional "SubscribeRequest" message specifying a "SubscriptionList" is sent via an existing channel, the target MUST respond to this message with a "SubscribeResponse" message indicating an error message, with a contained error message indicating an error. code of "InvalidArgument (4)"; existing subscriptions on other gRPC channels MUST not be modified or terminated. If a client initiates a "Subscribe" RPC with a "SubscribeRequest" message which does not contain a "SubscriptionList" message, this is an error. A "SubscribeResponse" message with the contained "error" message indicating a error code of "InvalidArgument" MUST be sent. The error text SHOULD indicate that an out-of-order operation was requested on a non-existent subscription. The target MUST subsequently close the channel. 3.5.1.2. The SubscriptionList Message A "SubscriptionList" message is used to indicate a set of paths for which common subscription behavior are required. The fields of the message are: - "subscription" - a set of "Subscription" messages that indicate the set of paths associated with the subscription list. - "mode" - the type of subscription that is being created. This may be "ONCE" (described in Section 3.5.1.5.1); "STREAM" (described in Section 3.5.1.5.2); or "POLL" (described in Section 3.5.1.5.3). The default value for the mode field is "STREAM". - "prefix" - a common prefix that is applied to all paths specified within the message as per the definition in Section 2.4.1. The default prefix is null. - "use_aliases" - a boolean flag indicating whether the client accepts target aliases via the subscription channel. In the case that such aliases are accepted, the logic described in Section 2.4.2 is utilised. By default, path aliases created by the target are not supported. - "qos" - a field describing the packet marking that is to be utilised for the responses to the subscription that is being created. This field has a single sub-value, "marking", which indicates the DSCP value as a 32-bit unsigned integer. If the "qos" field is not specified, the device should export telemetry traffic using its default DSCP marking for management-plane traffic. - "allow_aggregation" - a boolean value used by the client to allow schema elements that are marked as eligible for aggregation to be combined into single telemetry update messages. By default, aggregation MUST NOT be used. o "use_models" - a "ModelData" message (as specified in Section 2.6.1) specifying the schema definition modules that the target should use when creating a subscription. When specified, the target MUST only consider data elements within the defined set of schema modules as defined in Section 2.6. When "use_models" is not specified, the target MUST consider all data elements that are defined in all schema modules that it supports. A client generating a "SubscriptionList" message MUST include the "subscription" field - which MUST be a non-empty set of "Subscription" messages, all other fields are optional. 3.5.1.3. The Subscription Message A "Subscription" message generically describes a set of data that is to be subscribed to by a client. It contains a "path", specified as per the definition in Section 2.2.2. There is no requirement for the path that is specified within the message to exist within the current data tree on the server. Whilst the path within the subscription SHOULD be a valid path within the set of schema modules that the target supports, subscribing to any syntactically valid path within such modules MUST be allowed. In the case that a particular path does not (yet) exist, the target MUST NOT close the channel, and instead should continue to monitor for the existence of the path, and transmit telemetry updates should it exist in the future. The target MAY send a "SubscribeResponse" message populating the error field with "NotFound (5)" to inform the client that the path does not exist at the time of subscription creation. For "POLL" and "STREAM" subscriptions, a client may optionally specify additional parameters within the "Subscription" message. The semantics of these additional fields are described in the relevant section of this document. 3.5.1.4. The SubscribeResponse Message A "SubscribeResponse" message is transmitted by a target to a client over an established channel created by the "Subscribe" RPC. The message contains the following fields: o A set of fields referred to as the "response" fields, only one of which can be specified per "SubscribeResponse" message: * "update" - a "Notification" message providing an update value for a subscribed data entity as described in Section 3.5.2. The "update" field is also utilised when a target wishes to create an alias within a subscription, as described in Section 3.5.2.2. * "sync_response" - a boolean field indicating that a particular set of data values has been transmitted, used for "POLL" and "STREAM" subscriptions. * "error" - an "Error" message transmitted to indicate an error has occurred within a particular "Subscribe" RPC call. 3.5.1.5. Creating Subscriptions 3.5.1.5.1. ONCE Subscriptions A subscription operating in the "ONCE" mode acts as a single request/response channel. The target creates the relevant update messages, transmits them, and subsequently closes the channel. In order to create a one-off subscription, a client sends a "SubscribeRequest" message to the target. The "subscribe" field within this message specifies a "SubscriptionList" with the mode field set to "ONCE". Updates corresponding to the subscription are generated as per the semantics described in Section 3.5.2. Following the transmission of all updates which correspond to data items within the set of paths specified within the subscription list, a "SubscribeResponse" message with the "sync_response" field set to "true" MUST be transmitted, and the channel over which the "SubscribeRequest" was received MUST be closed. 3.5.1.5.2. STREAM Subscriptions Stream subscriptions are long-lived subscriptions which continue to transmit updates relating to the set of paths that are covered within the subscription indefinitely. A "STREAM" subscription is created by sending a "SubscribeRequest" message with the subscribe field containing a "SubscriptionList" message with the type specified as "STREAM". Each entry within the "Subscription" message is specified with one of the following modes: - On Change ("ON_CHANGE") - when a subscription is defined to be "on change", data updates are only sent when the value of the data item changes. A heartbeat interval MAY be specified along with an "on change" subscription - in this case, the value of the data item(s) MUST be re-sent once per heartbeat interval regardless of whether the value has changed or not. Sampled ("SAMPLE") - a subscription that is defined to be sampled MUST be specified along with a "sample_interval" encoded as an unsigned 64-bit integer representing nanoseconds. The value of the data item(s) is sent once per sample interval to the client. If the target is unable to support the desired "sample_interval" it MUST reject the subscription by returning a "SubscribeResponse" message with the error field set to an error message indicating the "InvalidArgument (3)" error code. If the "sample_interval" is set to 0, the target MUST create the subscription and send the data with the lowest interval possible for the target. * Optionally, the "suppress_redundant" field of the "Subscription" message may be set for a sampled subscription. In the case that it is set to "true", the target SHOULD NOT generate a telemetry update message unless the value of the path being reported on has changed since the last update was generated. Updates MUST only be generated for those individual leaf nodes in the subscription that have changed. That is to say that for a subscription to "/a/b" - where there are leaves "c" and "d" branching from the "b" node - if the value of "c" has changed, but "d" remains unchanged, an update for "d" MUST NOT be generated, whereas an update for "c" MUST be generated. * A "heartbeat_interval" MAY be specified to modify the behavior of "suppress_redundant" in a sampled subscription. In this case, the target MUST generate one telemetry update per heartbeat interval, regardless of whether the "suppress_redundant" flag is set to "true". This value is specified as an unsigned 64-bit integer in nanoseconds. Target Defined "(TARGET_DEFINED)" - when a client creates a subscription specifying the target defined mode, the target SHOULD determine the best type of subscription to be created on a per-leaf basis. That is to say, if the path specified within the message refers to some leaves which are event driven (e.g., the changing of state of an entity based on an external trigger) then an "ON_CHANGE" subscription may be created, whereas if other data represents counter values, a "SAMPLE" subscription may be created. 3.5.1.5.3. POLL Subscriptions Polling subscriptions are used for on-demand retrieval of statistics via long-lived channels. A poll subscription relates to a certain set of subscribed paths, and is initiated by sending a "SubscribeRequest" message with encapsulated "SubscriptionList". "Subscription" messages contained within the "SubscriptionList" indicate the set of paths that are of interest to the polling client. To retrieve data from the target, a client sends a "SubscribeRequest" message to the target, containing a "poll" field, specified to be an empty "Poll" message. On reception of such a message, the target MUST generate updates for all the corresponding paths within the "SubscriptionList". Updates MUST be generated according to Section 3.5.2. 3.5.1.6. Client-defined Aliases within a Subscription When a client wishes to create an alias that a target should use for a path, the client should send a "SubscribeRequest" message specifying the "aliases" field. The "aliases" field consists of an "AliasList" message. An "AliasList" specifies a list of aliases, each of which consists of: - "path" - the target path for the alias - encoded as per Section 2.2.2. - "alias" - the (client-defined) alias for the path, encoded as per Section 2.4.2. Where a target is unable to support a client-defined alias it SHOULD respond with a "SubscribeResponse" message with the error field indicating an error of the following types: - "InvalidArgument (3)" where the specified alias is not acceptable to the target. - "AlreadyExists (6)" where the alias defined is a duplicate of an existing alias for the client. - "ResourceExhausted (8)" where the target has insufficient memory or processing resources to support the alias. - "Unknown (2)" in all other cases. Thus, for a client to create an alias corresponding to the path "/a/b/c/d[id=10]/e" with the name "shortPath", it sends a "SubscribeRequest" message with the following fields specified: If the alias is acceptable to the target, subsequent updates are transmitted using the "#shortPath" alias in the same manner as described in Section 3.5.2.2. 3.5.2. Sending Telemetry Updates 3.5.2.1. Bundling of Telemetry Updates Since multiple "Notification" messages can be included in the update field of a "SubscribeResponse" message, it is possible for a target to bundle messages such that fewer messages are sent to the client. The advantage of such bundling is clearly to reduce the number of bytes on the wire (caused by message overhead). Since "Notification" messages contain the timestamp at which an event occurred, or a sample was taken, such bundling does not affect the sample accuracy to the client. However, bundling does have a negative impact on the freshness of the data in the client – and on the client’s ability to react to events on the target. Since it is not possible for the target to infer whether its clients are sensitive to the latency introduced by bundling, if a target implements optimizations such that multiple "Notification" messages are bundled together, it MUST provide an ability to disable this functionality within the configuration of the gNMI service. Additionally, a target SHOULD provide means by which the operator can control the maximum number of updates that are to be bundled into a single message, This configuration is expected to be implemented out-of-band to the gNMI protocol itself. 3.5.2.2. Target-defined Aliases within a Subscription Where the "use_aliases" field of a "SubscriptionList" message has been set to "true", a target MAY create aliases for paths within a subscription. A target-defined alias MUST be created separately from an update to the corresponding data item(s). To create a target-defined alias, a "SubscribeResponse" message is generated with the "update" field set to a "Notification" message. The "Notification" message specifies the aliased path within the "prefix" field, and a non-null "alias" field, specified according to Section 2.4.2. Thus, a target wishing to create an alias relating to the path "/a/b/c[id=10]" and subsequently update children of the "c[id=10]" entity must: 1. Generate a "SubscribeResponse" message and transmit it over the channel to the client: ```xml subscriberesponse: < update: < timestamp: (timestamp) prefix: < element: "a" element: "b" element: "c[id=10]" > alias: "#42" > > ``` 1. Subsequently, this alias can be used to provide updates for the "child1" leaf corresponding to "/a/b/c[id=10]/child1": subscriberesponse: < update: < timestamp: (timestamp) prefix: < element: "#42" > update: < path: < element: "child1" > value: < value: 102 // integer representation type: JSON_IETF > > > 3.5.2.3. Sending Telemetry Updates When an update for a subscribed telemetry path is to be sent, a "SubscribeResponse" message is sent from the target to the client, on the channel associated with the subscription. The "update" field of the message contains a "Notification" message as per the description in Section 2.1. The "timestamp" field of the "Notification" message MUST be set to the time at which the value of the path that is being updated was collected. Where a leaf node’s value has changed, or a new node has been created, an "Update" message specifying the path and value for the updated data item MUST be appended to the "update" field of the message. Where a node within the subscribed paths has been removed, the "delete" field of the "Notification" message MUST have the path of the node that has been removed appended to it. When the target has transmitted the initial updates for all paths specified within the subscription, a "SubscribeResponse" message with the "sync_response" field set to "true" MUST be transmitted to the client to indicate that the initial transmission of updates has concluded. This provides an indication to the client that all of the existing data for the subscription has been sent at least once. For "STREAM" subscriptions, such messages are not required for subsequent updates. For "POLL" subscriptions, after each set of updates for individual poll request, a "SubscribeResponse" message with the "sync_response" field set to "true" MUST be generated. 4. References 4.1. URIs Appendix A. Appendix: Current Protobuf Message and Service Specification The latest Protobuf IDL gNMI specification is found at [17]. Appendix B. Appendix: Current Outstanding Issues/Future Features - Ability for the client to exclude paths from a subscription or get. - "Dial out" for the target to register with an NMS and publish pre-configured subscriptions. Authors’ Addresses Rob Shakir Google, Inc. 1600 Amphitheatre Parkway Mountain View, CA 94043 Email: robjs@google.com Anees Shaikh Google 1600 Amphitheatre Pkwy Mountain View, CA 94043 US Email: aashaikh@google.com Paul Borman Google 1600 Amphitheatre Pkwy Mountain View, CA 94043 US Email: borman@google.com Marcus Hines Google 1600 Amphitheatre Pkwy Mountain View, CA 94043 US Email: hines@google.com Carl Lebsack Google 1600 Amphitheatre Pkwy Mountain View, CA 94043 US Email: csl@google.com Chris Morrow Google Email: christopher.morrow@gmail.com
{"Source-Url": "https://tools.ietf.org/pdf/draft-openconfig-rtgwg-gnmi-spec-00.pdf", "len_cl100k_base": 14997, "olmocr-version": "0.1.50", "pdf-total-pages": 37, "total-fallback-pages": 0, "total-input-tokens": 71954, "total-output-tokens": 17349, "length": "2e13", "weborganizer": {"__label__adult": 0.0002868175506591797, "__label__art_design": 0.0004096031188964844, "__label__crime_law": 0.00032329559326171875, "__label__education_jobs": 0.001583099365234375, "__label__entertainment": 0.00019240379333496096, "__label__fashion_beauty": 0.00015234947204589844, "__label__finance_business": 0.0006303787231445312, "__label__food_dining": 0.0002663135528564453, "__label__games": 0.0007462501525878906, "__label__hardware": 0.003025054931640625, "__label__health": 0.00034332275390625, "__label__history": 0.0003771781921386719, "__label__home_hobbies": 9.435415267944336e-05, "__label__industrial": 0.00041866302490234375, "__label__literature": 0.0004191398620605469, "__label__politics": 0.00028777122497558594, "__label__religion": 0.00049591064453125, "__label__science_tech": 0.12115478515625, "__label__social_life": 0.0001283884048461914, "__label__software": 0.142822265625, "__label__software_dev": 0.72509765625, "__label__sports_fitness": 0.0002046823501586914, "__label__transportation": 0.0003888607025146485, "__label__travel": 0.0002033710479736328}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 68172, 0.0276]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 68172, 0.26661]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 68172, 0.83506]], "google_gemma-3-12b-it_contains_pii": [[0, 1572, false], [1572, 4566, null], [4566, 6376, null], [6376, 8034, null], [8034, 9697, null], [9697, 11259, null], [11259, 12229, null], [12229, 12665, null], [12665, 14659, null], [14659, 16155, null], [16155, 17976, null], [17976, 19971, null], [19971, 22504, null], [22504, 24372, null], [24372, 26386, null], [26386, 28269, null], [28269, 30349, null], [30349, 32804, null], [32804, 34793, null], [34793, 36814, null], [36814, 39157, null], [39157, 41633, null], [41633, 43857, null], [43857, 46348, null], [46348, 48950, null], [48950, 51189, null], [51189, 53323, null], [53323, 55638, null], [55638, 57702, null], [57702, 60287, null], [60287, 61827, null], [61827, 63272, null], [63272, 64397, null], [64397, 66171, null], [66171, 67240, null], [67240, 68021, null], [68021, 68172, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1572, true], [1572, 4566, null], [4566, 6376, null], [6376, 8034, null], [8034, 9697, null], [9697, 11259, null], [11259, 12229, null], [12229, 12665, null], [12665, 14659, null], [14659, 16155, null], [16155, 17976, null], [17976, 19971, null], [19971, 22504, null], [22504, 24372, null], [24372, 26386, null], [26386, 28269, null], [28269, 30349, null], [30349, 32804, null], [32804, 34793, null], [34793, 36814, null], [36814, 39157, null], [39157, 41633, null], [41633, 43857, null], [43857, 46348, null], [46348, 48950, null], [48950, 51189, null], [51189, 53323, null], [53323, 55638, null], [55638, 57702, null], [57702, 60287, null], [60287, 61827, null], [61827, 63272, null], [63272, 64397, null], [64397, 66171, null], [66171, 67240, null], [67240, 68021, null], [68021, 68172, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 68172, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 68172, null]], "pdf_page_numbers": [[0, 1572, 1], [1572, 4566, 2], [4566, 6376, 3], [6376, 8034, 4], [8034, 9697, 5], [9697, 11259, 6], [11259, 12229, 7], [12229, 12665, 8], [12665, 14659, 9], [14659, 16155, 10], [16155, 17976, 11], [17976, 19971, 12], [19971, 22504, 13], [22504, 24372, 14], [24372, 26386, 15], [26386, 28269, 16], [28269, 30349, 17], [30349, 32804, 18], [32804, 34793, 19], [34793, 36814, 20], [36814, 39157, 21], [39157, 41633, 22], [41633, 43857, 23], [43857, 46348, 24], [46348, 48950, 25], [48950, 51189, 26], [51189, 53323, 27], [53323, 55638, 28], [55638, 57702, 29], [57702, 60287, 30], [60287, 61827, 31], [61827, 63272, 32], [63272, 64397, 33], [64397, 66171, 34], [66171, 67240, 35], [67240, 68021, 36], [68021, 68172, 37]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 68172, 0.00496]]}
olmocr_science_pdfs
2024-12-03
2024-12-03
5efbaf7362c2ff94e96de58e6dbe34195f8dd7c4
Collaboration behavior enhancement in co-development networks Shadi, M. Citation for published version (APA): General rights It is not permitted to download or to forward/distribute the text or part of it without the consent of the author(s) and/or copyright holder(s), other than for strictly personal, individual use, unless the work is under an open content license (like Creative Commons). Disclaimer/Complaints regulations If you believe that digital publication of certain material infringes any of your rights or (privacy) interests, please let the Library know, stating your reasons. In case of a legitimate complaint, the Library will make the material inaccessible and/or remove it from the website. Please Ask the Library: https://uba.uva.nl/en/contact, or a letter to: Library of the University of Amsterdam, Secretariat, Singel 425, 1012 WP Amsterdam, The Netherlands. You will be contacted as soon as possible. Chapter 4 Normative Virtual Organizations Supervisory Assistant Tool - VOSAT This chapter contains some material from the following paper: 4.1 Introduction To increase the success rate of VOs, it is needed to design and develop a supervisory framework aiming at monitoring the partners’ behavior, and diagnosing the behavior-related risks. In an open multi-agent system that allows agents to enter and exit the system at runtime, an exogenous normative artifact can be defined to organize and control the behavior of agents [10]. This normative artifact consists of norms and sanctions in which activities of participating agents are monitored, violations of /obedience to norms are specified, and finally the consequences for the observed violations/obedience are realized. The VBE is an open border environment, and thus represents an open society of agents, in which an exogenous normative organization can be defined. In Chapter 3 a normative multi-agent framework is proposed for VOs, based on which our VO supervisory artifact, called VOSAT (VO Supervisory Assistant Tool), is designed and developed. VOSAT aims to monitor and control agents’ interactions, through checking their compliance with some norms, and imposing related sanctions against the norms’ violations. It includes five components, as shown in Figure 4.1. Chapter 4. Normative Virtual Organizations Supervisory Assistant Tool - VOSAT Figure 4.1: VO Supervisory Assisting Tool (VOSAT) VOSAT, Norm Monitoring Component (NMC) is responsible for monitoring and controlling the agents’ behavior against their defined norms, and imposing related sanctions against the norms’ violations. To monitor the trust-related norm, it is necessary to continuously measure the trust level of an agent, which is measured by the Trust Evaluating Component (TEC), and set as input to NMC. Norm Abidance Component (NAC) is responsible for measuring the committing norms obedience degree (CNOD) and socio-regulatory norms obedience degree (SNOD) for each agent, using the information related to the norms specified by NMC. If an agent’s trust-related norm is violated then the Risk Predicting Component (RPC) is triggered to find the risky tasks based on the PRIT information, as well as the information related to the risk factors. These information are finally used to assist the VO coordinator to potentially intervene through reassignment of risky tasks and therefore to remove the risk condition at the VO. Moreover, Partner Selecting Component (PSC) provides a mechanism to select the suitable partner for task reassignment or reward distribution among partners. TEC is addressed in Chapter 5, RPC and PSC are further addressed in Chapter 6, while details of NMC, and NAC are discussed in this chapter. To develop NMC aiming at monitoring the VO partners’ behavior against the defined norms in Chapter 3, it is needed to formalize the norm related concepts, such as promises, joint-promises, obligations and prohibitions. The proposed formalization for joint-promises and promises are to the best of our knowledge novel. In fact, all defined norms are formalized by a set of norm manipulating rules which are triggered by external events and partners’ actions. Then, some new 4.2 Norm Monitoring propositions are derived from the fired norm manipulating rules. It means that it is possible to automatically specify the states of promises, and joint-promises, violation or obedience of socio-regulatory norms and controlling norms, based on which, different reactions can be planned. This chapter also addresses how to measure CNOD and SNOD, which are internal measures to be used as criteria in partners’ trust evaluation (addressed in Chapter 5), partner selection for task reassignment, and indirect reward distribution (both addressed in Chapter 6). The rest of this chapter is structured as follows. The details of norm monitoring mechanism are addressed in Section 2. Section 3 discusses how we can measure the norm obedience degrees (CNOD and SNOD) for each VO partner. Section 4 addresses some conclusive remarks. 4.2 Norm Monitoring In order to operationalize norms, a norm enforcement mechanism is required to be developed and provided. This mechanism is responsible for detecting the norms’ violation and imposing sanctions in case of violations. AMELI platform [43], the normative framework of Cardoso [26], and the norm enforcement mechanism of Fornara et al. [45] are some developments in this area. The implementations addressed in [43] and [45] are all aimed at ”procedural” norms, determining which actions should or should not be performed by agents, while the ”declarative” norms (e.g. in [26]) specify a desired state that should be fulfilled within the environment in which the agents interact. In [33], the norms expressed as counts-as rules are declarative. We also define our norms as declarative counts-as rules. The Norm Monitoring Component (NMC) does the monitoring of the agents’ behavior through checking the state of their norms. The inputs of NMC component includes some predefined data related to the norms, such as the thresholds or agents’ trust levels (see Figure 4.1). If agents’ promises or socio-regulatory norms are violated then the Trust Evaluating Component is triggered to calculate the agent’s trust level, while if one of the controlling norms is violated then Risk Predicting Component is triggered to identify the risky tasks. To implement the NMC, it is needed to first formalize norm-related concepts, and specify the configuration of NMC, as provided in the following sections. 4.2.1 Concepts Formalization Promise Formalization. A promise with a specific state is formalized as a proposition, e.g. \( Pr^C(x, y, p, d, q, d', C) \) is used to represent the specific state of the promise \( < x, y, p, d, q, d' > \), as defined in Section 3.4.1 of Chapter 3. Label \( C \) in this expression refers to the conditional state (see Table 3.1). The agents’ actions, and the external events manipulate the states of promises, and this manipulation should respect a specific set of rules (see Table 4.1). In other words, these rules can be used to express how agents’ actions and external events influence the state of promises. The rules have the general form of $\rho, \phi, \alpha \Rightarrow \rho'$ where $\rho, \phi, \alpha$ represent respectively a promise with a specific state, such as $PrC(x, y, p, d, q, d')$, an environment-related fact describing the environment, such as deadline $d$, an action, such as $Fulfill(x, p)$, and $\rho'$ represents the promise with a new state. In these rules, shown in Table 4.1, the notations T and nop are used for True and for no-operation action, respectively. The agents’ actions are as follows: - **Agree**($x, y, p, d, q, d'$): $x$ agrees with $y$ to make the proposition $p$ true, before the deadline $d$, if the proposition $q$ is true before deadline $d'$. - **Withdraw**($x, y, p$): $x$ tells $y$ that he withdraws his promise to make proposition $p$ true. - **Release**($x, y, p$): $x$ tells $y$ that it is no longer needed to keep his promise to make proposition $p$ true. - **Fulfill**($x, p$): $x$ makes proposition $p$ true. In these rules, $Fail(p)$ is considered as an external event showing that proposition $p$ can no longer be made true, because of an external failure. <table> <thead> <tr> <th>Rule Name</th> <th>Promise Manipulating Rules</th> </tr> </thead> <tbody> <tr> <td>Making conditional promise</td> <td>$T, T, Agree(x, y, p, d, q, d') \Rightarrow PrC(x, y, p, d, q, d')$</td> </tr> <tr> <td>Freeing pre-conditions</td> <td>$PrC(x, y, p, d, q, d'), \neg d, Fulfill(z, q) \Rightarrow PrUC(x, y, p, d, q, d')$</td> </tr> <tr> <td>Keeping</td> <td>$PrUC(x, y, p, d, q, d'), \neg d, Fulfill(x, y, p) \Rightarrow PrK(x, y, p, d, q, d')$</td> </tr> <tr> <td>Withdrawing</td> <td>$PrUC(x, y, p, d, q, d'), \neg d, Withdraw(x, y, p) \Rightarrow PrW(x, y, p, d, q, d')$</td> </tr> <tr> <td>Not Keeping</td> <td>$PrUC(x, y, p, d, q, d'), d, \neg p, nop \Rightarrow PrNK(x, y, p, d, q, d')$</td> </tr> <tr> <td>Dissolving</td> <td>$PrC(x, y, p, d, q, d'), d', \neg q, nop \Rightarrow PrDis(x, y, p, d, q, d')$</td> </tr> <tr> <td>Releasing</td> <td>$PrUC(x, y, p, d, q, d'), T, Release(y, x, p) \Rightarrow PrR(x, y, p, d, q, d')$</td> </tr> <tr> <td>Invalidating</td> <td>$PrUC(x, y, p, d, q, d'), Fail(p), nop \Rightarrow PrIns(x, y, p, d, q, d')$</td> </tr> </tbody> </table> Table 4.1: Rules manipulating the promise states The explanations below describe the above rules: - **Making conditional promise rule**: performing the action $Agree(x, y, p, d, q, d')$ implies the creation of a conditional promise. When this rule is applied, $PrC(x, y, p, d, q, d')$ is created. 4.2. Norm Monitoring • Freeing preconditions rule: performing the action $\text{Fulfill}(z, q)$ before passing time $d'$ implies the creation of an unconditional promise. When this rule is applied, the conditional promise transforms to an unconditional promise. • Keeping rule: performing the action $\text{Fulfill}(x, p)$ before passing $d$ implies the creation of a kept promise. When this rule is applied, the unconditional promise transforms to a kept promise. • Withdrawing rule: performing the action $\text{Withdraw}(x, y, p)$ before passing $d$ implies the creation of a withdrawn promise. By applying this rule, the conditional/unconditional promise transforms to a withdrawn promise. • Not keeping rule: not realizing $p$ by the deadline $d$, implies the creation of a not kept promise. When this rule is applied an unconditional promise transforms to a not kept promise. • Dissolving rule: not realizing $q$ by passing $d'$ implies the creation of a dissolved promise. When this rule is applied, the conditional promise transforms to a dissolved promise. • Releasing rule: when $x$ tells $y$ it is no longer needed to fulfill his promise to realize $p$, it implies the creation of a released promise. When this rule is applied, the conditional/unconditional promise transforms to a released promise. • Invalidating rule: when $p$ cannot be realized because of an external failure, it implies the invalidation of an unconditional promise. When this rule is applied, the unconditional promise transforms to an invalidated promise. Joint-promise Formalization. In Section 3.4.1 of Chapter 3 we defined a joint-promise as a tuple $< G, y, p, d, q, d' >$, where $G$ is a set of agents. It means that each member of $G$ make a promise for $y$ to bring about $p$ before $d$ and also each member of $G$ makes a promise to other members to perform its part of the joint-action bringing about $p$. In VOSAT, it is formalized as follows: \[ \text{Joint} - Pr^C(G, y, p, d, q, d') \equiv \\ \bigwedge_{A_i \in G, (A_i, p_i, d_i) \in PL} \left( Pr^C(A_i, y, p, d, q, d') \land \left( \bigwedge_{A_j \in G - \{A_i\}} Pr^C(A_i, A_j, p_i, d_i, q, d') \right) \right) \] (4.1) where, • $G$ is the promiser group • $y$ is the promisee agent in the joint.promise 52 Chapter 4. Normative Virtual Organizations Supervisory Assistant Tool - VOSAT - \( p \) is a proposition which a group of promisers \( G \) should bring about before deadline \( d \). - \( q \) is the condition for realizing \( p \) by group \( G \) that should be fulfilled before \( d' \). - \( PL \) is the plan negotiated for distributing tasks among agents, during the VO operation phase. This plan includes a number of pairs such as \((A_i, p_i, d_i)\) in which \( A_i \) is an agent who should bring about \( p_i \) before deadline \( d_i \), as a part of the joint-action leading to realize \( p \) before \( d \). - \( \bigwedge_{i=1}^n p_i \Rightarrow p, d_i \leq d \) and \( n \) is the number of agents in \( G \). This formalization means that each member of \( G \) makes a conditional promise for \( y \) to bring about \( p \) before \( d \) and also each member of \( G \) makes a conditional promise to other members to perform its part of the joint-action bringing about \( p \). **Obligation Formalization.** In VOSAT, obligations are formalized by two simple rules, because they have only two states, i.e. violation and obedience: 1. Obligation Obeying Rule: \( \text{Obliged}(x, p, d), \text{Fulfill}(x, p), \lnot d \Rightarrow \text{Obeyed}(x, p) \) 2. Obligation Violating Rule: \( \text{Obliged}(x, p, d), \lnot p, d \Rightarrow \text{Violated}(x, p) \) These formalizations are not shown in a specific logic. The proposition \( p \) can be crisp or fuzzy, for example when an obligation is defined for the agent’s trustworthiness, \( p \) is a fuzzy proposition (e.g. agent’s trust level should be more than Low Trust). **Prohibition Formalization.** It should be noticed that for prohibitions, two rules similar to obligation rules are considered, as follows: 1. Prohibition Obeying Rule: \( \text{Prohibited}(x, p, d), \text{Fulfill}(x, p), \lnot p, d \Rightarrow \text{Obeyed}(x, p) \) 2. Prohibition Violating Rule: \( \text{Prohibited}(x, p, d), \text{Fulfill}(x, p), \lnot d \Rightarrow \text{Violated}(x, p) \) ### 4.2.2 The Configuration of Norm Monitoring Component Operational semantics is the means of defining the semantics of the Norm Monitoring Component. It is defined in terms of the configurations of the norm monitoring component and the transition between them \[33\]. The configuration or state of norm monitoring component is specified based on: 1. a set of propositions denoting environment-related facts 2. a set of Norm Manipulating Rules (NMRs) 3. a set of norms 4. a set of Reaction Rules (RRs) Environment-related facts describe the environment in which agents interact. NMRs represent the rules introduced in Section 4.2.1 for formalization of promises, obligations and prohibitions. Socio-regulatory and controlling norms have two states, i.e. violated and obeyed, while promises have more than two states, as shown in Table 3.1. Plans that the VO coordinator wants to execute in case of the violation or obedience of norms correspond to the RRs. **Definition 5.** Configuration of Norm Monitoring Component is defined by the tuple \(<δ_ε, δ_n, R_{nm}, R_r>\), where \(δ_ε\) is a consistent set of propositions denoting the environment-related facts, \(δ_n\) is a consistent set of norms, \(R_{nm}\) is a set of norm manipulating rules, and \(R_r\) is a set of reaction rules. In operational semantics, the transition rules, determine the transitions allowed between configurations. The state of our system can make a transition either when the actions (mentioned in Section 4.2.1) are performed by the agents, or when some external events have occurred. Algorithm 1 shows how the state of NMC makes a transition when an action is performed or an event is occurred. In this algorithm, \(p\) is a proposition representing an external event or the effect of an agent’s action. In Algorithm 1, the set of norms and propositions denoting the environment-related facts is called \(KB\). The proposition \(p\) is added to \(KB\). In outer if statement in Algorithm 1, it is checked whether NM-rule \(r_1\) is applicable based on the updated \(KB\). The applicability of \(r_1\) means that the condition of \(r_1\) is satisfied in \(KB\). If \(r_1\) is applicable, its consequent, i.e. \(q_1\), is derived, which shows a violated or obedient norm, or a promise in a certain state, and it is added to \(KB\). For example, if the precondition of a promise is not fulfilled before its specified deadlines, then the dissolving rule shown in Table 4.1 is applicable, whose consequent \((q_1)\) is a dissolved promise. Furthermore, the inner if statement in Algorithm 1, is related to applicability of the trust-related norms. It means that the trust-related norm has a different level in contrast to other norms, because it is triggered by the violation of the socio-regulatory norms or promises. In a normative environment like a VO, norms can have different levels; norms at level zero are triggered by external events, whereas norms at other levels are triggered in case of a violation of some norm(s) defined at lower levels [94]. If \(q_1\) is a violated promise (not kept or withdrawn) or a violated socio-regulatory norm, and also the condition of NM-rule \(r_2\) specifying the trust-related norm, is satisfied in \(KB\), then \(r_2\)’s consequent, i.e. \(q_2\) is derived. It should be noticed that \(q_2\) shows the violation or obedience of the trust-related norm, and added to \(KB\). Finally, some Reaction Rules may be applicable, which means that their conditions are satisfied in updated \(KB\). The consequent of the applicable R-rule \(r_3\), shows the plan that is considered for different states of promises, or for violation, or obedience of other norms. For example, if trust-related norms, communication-related norms or workload-related norms are violated then it is necessary to find the weak points in VO’s activities fulfillment. The reaction rule, in this case a risk prediction rule gets triggered, which results in invoking the risk prediction function and sending an alarming message to the VO coordinator. Algorithm 1: Norm Monitoring Algorithm Input: - \( KB \), a set of propositions denoting norms & environment-related facts - NM-rules, a set of Norm Manipulating rules - R-rules, a set of Reaction rules - \( p \), a proposition denoting an environment-related fact Add \( p \) to \( KB \) \[ \text{if the condition of the NM-rule } r_1, \text{ is satisfied in } KB \text{ then} \] \[ q_1 := \text{Consequent}(r_1) \] \[ \text{Add } q_1 \text{ to } KB \] \[ \text{if } q_1 \text{ is a violated promise or a violated socio-regulatory norm and the} \] \[ \text{condition of the NM-rule } r_2, \text{ is satisfied in } KB \text{ then} \] \[ q_2 := \text{Consequent}(r_2) \] \[ \text{Add } q_2 \text{ to } KB \] \[ \text{end} \] \[ \text{foreach } r_3 \text{ as a member of R-rules, whose condition is satisfied in } KB \] \[ \text{do} \] \[ b := \text{Consequent}(r_3) \] \[ \text{Add } b \text{ to } KB \] \[ \text{end} \] We use Organization Oriented Programming Language (2OPL) \[\square\] to implement our Norm Monitoring Component. The use of 2OPL is justified when there is an environment within which agents interact to achieve some common goals, and where they need to be organized for it. This language is introduced to specify norms, violations and sanctions within a multi-agent system. The 2OPL has been implemented as a JAVA software project within which a Prolog is used to implement the inference engine to keep and reason about the brute facts and institutional facts. In 2OPL, brute facts describe the states of the environment in which agents perform their actions and institutional facts describe the violation state of norms. The artifact defined by 2OPL is responsible to monitor the violation of norms and impose the related sanctions. All fundamental concepts of the 2OPL including brute facts, effect rules, counts-as rules and sanction rules should be written in a .2opl file, which is then interpreted by the 2OPL \[\square\]. Definitions of the main 2OPL concepts are as follows: 4.2. Norm Monitoring - Brute facts are represented as Prolog facts and are initialized before the execution of 2OPL organization. - Counts-as rule are represented by $\rho \Rightarrow \phi$ in which $\rho$ is brute fact and $\phi$ is an institutional fact. This rule should be read as "$\rho$ counts as $\phi$". It should be mentioned that in 2OPL, institutional facts are not manually programmed, because they are obtained by applying Counts-as rules. - Sanction rules relate institutional facts to brute facts expressed by rules like $\phi \Rightarrow \rho$ where $\phi$ consists of institutional facts and brute facts and $\rho$ is a brute fact. - Effect rules consist of pre-condition, action name, and post-condition parts. When an action is performed, the post-conditions of its related effect rule is realized which in turn changes the brute facts base. The base for 2OPL is sufficiently similar to what we need to implement our supervisory artifact, and specifically the NMC of the VO Supervisory Assisting Tool (VOSAT). Although there are a number of differences in features of a 2OPL organization and our setting, this language can be easily extended in order to properly implement the norm monitoring component. We have implemented our environment-related facts, $\delta_e$, as Brute Facts in 2OPL. For example, $curTime(0)$ is a brute fact which sets the current time before starting of the VO operation phase. The actions (Fulfill, Withdraw, etc.) are programmed as Effect Rules with pre- and post-conditions. For example, the effect rule below specifies that the action $fulfill(X,P)$ can be performed if $P$ is not yet realized, and then the fact $P$ will be realized after the performance of the action. $$\{\text{not realized}(P)\}$$ $$fulfill(X,P)$$ $$\{\text{realized}(P)\}$$ Our norm manipulating rules, $R_{nm}$, are implemented as Counts-as rules. For example, Figure 4.2 illustrates the implementation of the promise manipulating rules, as shown in Table 4.1. The first rule shown in Table 4.1 in which there is only one action, is implemented by an effect rule, while other rules are implemented as counts-as rules. It should be noticed that for each promise, at most one of the mentioned states in Table 3.1 is true at any point in time. The norm manipulating rules determine which state should remain true forever and which state should be removed. The termination states, i.e. kept, not kept, withdrawn, invalidated, released and dissolved will in principle remain true in the VOSAT framework, once they are true. Not kept and withdrawn states are considered as violation states. The VO coordinator may however decide to remove them once the sanctions (e.g. charging some damage costs to an agent or adding the agent to some blacklists) are applied. Ultimately, we implement our reaction rules, $R_r$, as sanction rules in 2OPL. For example, the sanction rule below adds the promiser of a not kept promise $X$, to a specific black list: $$\text{viol(nkept,X,Y)}, \text{blakList1(V)}, \text{add (X,V,V2)} \Rightarrow \text{not viol (nkept,X,Y)}, \text{not blakList1(V)}, \text{blakList1 (V2)}.$$ This list can be used for some future decisions about agents, such as the selection of suitable VO partners for creation of a new VO. Imposing related sanctions against the norms’ violations is very important in Virtual Organizations. For instance, if a promiser notifies the VO coordinator, before reaching the deadline, that it cannot fulfill its promise on time, that agent should then be punished less than if it were in the situation in which the deadline has passed and the promise is not fulfilled. But clearly, the sanction policies are usually not the same in different VOs. Typically, two kinds of sanctions are applied to incentivize the norm compliance by agents and to discourage deviation from norms: one affects agents resources (e.g. financial punishment), and the other one affects agents reputation (e.g. black listing). Sanction rules are either mentioned in the consortium agreement or specified by the VO coordinator. ### 4.2.3 An Example Case To provide more details on how NMC works for promise monitoring in virtual organizations, consider a VO established to produce canned tomato paste. Jobs to be performed in this VO are divided into a set of tasks. Let us consider one such task in this VO responsible for producing and sending 72500 tons of chopped tomato to the main factory, that in turn can produce 50000 tons of canned tomato paste. Further assume that, in this task, three tomato producer companies \(Tp_1, Tp_2, Tp_3\) and two delivery enterprises \(De_1, De_2\) are involved, which jointly prepare and deliver 72500 tons of chopped tomato to the main factory to be processed into canned tomato. After negotiations, a number of sub-tasks are determined, as addressed below. It should be noticed that to simplify the model we assume that the results of the negotiation between the partners and the task leader constitutes a set of non-conflicting sub-tasks. The Task Leader requires agreements from the involved companies. The following agreements are thus made: - **Agreement 1:** \(Tp_1\) agrees with the Task Leader that: it fulfils \(q_1\) (25000 Tn chopped tomato is ready) before January 10. - **Agreement 2:** \(De_1\) agrees with the Task Leader that: if \(q_1\) is fulfilled before January 10 then it fulfils \(q_2\) (25000 Tn chopped tomato is delivered to the main factory) within 2 days. - **Agreement 3:** \(Tp_2\) agrees with the Task Leader that: it fulfils \(q_3\) (21000 Tn chopped tomato is ready) before January 20. - **Agreement 4:** \(De_2\) agrees with the Task Leader that: if \(q_3\) is fulfilled before January 20 then it fulfils \(q_4\) (21000 Tn chopped tomato is delivered to the main factory) within 1 day. - **Agreement 5:** \(Tp_3\) agrees with the Task Leader that: it fulfils \(q_5\) (26500 Tn chopped tomato is ready) before January 21. - **Agreement 6:** \(De_1\) agrees with the Task Leader that: if \(q_5\) is fulfilled before January 21 then it fulfils \(q_6\) (26500 Tn chopped tomato is delivered to the main factory) within 1 day. The formalization of the above mentioned actions in our VO supervisory ap- proach are shown below. - **Act 1:** agree \((Tp_1, TaskLeader, q_1, 10, T, 0)\). - **Act 2:** agree \((De_1, TaskLeader, q_2, 12, q_1, 10)\). - **Act 3:** agree \((Tp_2, TaskLeader, q_3, 20, T, 0)\). - **Act 4:** agree \((De_2, TaskLeader, q_4, 21, q_3, 20)\). - **Act 5:** agree \((Tp_3, TaskLeader, q_5, 21, T, 0)\). Chapter 4. Normative Virtual Organizations Supervisory Assistant Tool - VOSAT - Act 6: agree \((De_1, TaskLeader, q_6, 22, q_5, 21)\). Please note that we use 0 to show the absence of a deadline and T as true when there is no condition for a promise. Also assume that all the above agreement actions are performed on the first day of January, i.e. \(newTime(1)\) is January 1, and \(newTime(n)\) represents date January \(n\). Based on the effect rule implemented in our .2opl file for VOSAT, each action "agree" leads to creation of a promise. For example, performing an action Act2: \(agree(De_1, TaskLeader, q_2, 12, q_1, 10)\) results in \(prCon(De_1, TaskLeader, q_2, 12, q_1, 10)\), which is shown as \(Pr_2^C\) in Table 4.2. The trace in Table 4.2 begins with the six actions mentioned above. According to the first and second rules shown in Table 4.1, three conditional and three unconditional promises are derived, as shown in the third column of Table 4.2. The promiser of an unconditional promise does not need to wait for fulfillment of any other promise. However, after fulfilling a promise or generally realizing a fact, a related conditional promise is converted to unconditional which will be further monitored. Consider that in this scenario, on January 5, when \(Tp_1\) informs the TaskLeader that it is impossible to prepare 25000 Tn till January 10 (because of an external failure which is out of the promiser’s control), and it can just prepare 15000 chopped tomato \(q_7\) instead at that time. Consequently, its first promise to prepare 25000 Tn tomato gets invalidated (last rule in Table 4.1). To assist with handling of this case, \(Tp_3\) agrees with the TaskLeader to prepare 10000 Tn \(q_8\) till January 20, while \(De_1\) also promises to deliver these two amount of chopped tomato prepared by \(Tp_1\) and \(Tp_3\) to the main factory \((q_9,\) and \(q_{10}\), respectively). Now we have new agreements: - Act 7: \(agree(Tp_1, TaskLeader, q_7, 10, T, 0)\). - Act 8: \(agree(Tp_3, TaskLeader, q_8, 20, T, 0)\). - Act 9: \(agree(De_1, TaskLeader, q_9, 12, q_7, 10)\). - Act 10: \(agree(De_1, TaskLeader, q_{10}, 22, q_8, 20)\). Furthermore, consider if in this scenario \(De_1\) does not deliver 10000 Tn prepared by \(Tp_3\) on January 22. Therefore, \(newTime(22)\) triggers the fifth rule in Table 4.1 resulting in \(pr^{NK}(De_1, TaskLeader, q_{10}, 22, q_8, 20)\), which is a violation state, triggering the sanction rule. In this current scenario, everything except the two above mentioned situations goes well, i.e. all other promises except for \(Pr_1, Pr_2\) and \(Pr_{10}\) are kept, as indicated in Table 4.2. The task therefore gets successfully completed on January 22. ### 4.3 Norm Abidance As Figure 4.1 illustrates, the Norm Abidance Component receives the promises’ states, and the violation or obedience of socio-regulatory norms from NMC as inputs, and then measures two degrees: Committing Norm Obedience Degree (CNOD), and Socio-regulatory Norm Obedience Degree (SNOD), which are explained in the following sections. The obedience degrees, (CNOD and SNOD) are used to determine the agent’s trust level, task reassignment, and reward distribution. As mentioned before, joint-promises are decomposed into several individual promises, so the violation and obedience of co-working norms are considered in evaluation of the committing norms. There is also no obedience degree for controlling norms, because the violation of these norms are directly considered in risk prediction, while the violation and obedience of socio-regulatory norms, co-working norms and committing norms are needed for evaluation of trust. #### 4.3.1 CNOD - Committing Norm Obedience Degree CNOD indicates how much the behavior of each agent is compliant with its committing norms (promises). In a VO, typically, based on the type of promised sub-task, some Quality Specification Criterion (QSC) are defined at the time of agreement between promiser and the VO coordinator or task leaders. For example, if a partner is the farmer who delivers tomato in the tomato paste production-example, then for instance the tomato’s quality grades (e.g. $G_1$, $G_2$ or $G_3$) or color (e.g. red, orange, or green) are the QSCs for its delivered product, which is usually agreed between this partner and the promisee, e.g. the VO coordinator. Therefore, QSCs should also be evaluated when measuring the CNOD. <table> <thead> <tr> <th>Step</th> <th>Action</th> <th>Promise</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>Act1, Act2, Act3, Act4, Act5, Act6, newTime(1)</td> <td>$Pr_{1C}^n, Pr_{2C}^n, Pr_{3C}^n, Pr_{4C}^n, Pr_{5C}^n, Pr_{6C}^n$</td> </tr> <tr> <td>2</td> <td>Fullfill($q_1$), Act7, Act8, Act9, Act10, newTime(5)</td> <td>$Pr_{1C}^{in}, Pr_{2C}^{in}, Pr_{3C}^{in}, Pr_{4C}^{in}, Pr_{5C}^{in}, Pr_{6C}^{in}, Pr_{7C}^{in}, Pr_{8C}^{in}, Pr_{9C}^{in}, Pr_{10C}^{in}$</td> </tr> <tr> <td>3</td> <td>Fullfill($Tp_1, q_7$), newTime(10)</td> <td>$Pr_{1C}^{in}, Pr_{2C}^{in}, Pr_{3C}^{in}, Pr_{4C}^{in}, Pr_{5C}^{in}, Pr_{6C}^{in}, Pr_{7C}^{in}, Pr_{8C}^{in}$</td> </tr> <tr> <td>4</td> <td>Fullfill($De_1, q_9$), newTime(12)</td> <td>$Pr_{1C}^{in}, Pr_{2C}^{in}, Pr_{3C}^{in}, Pr_{4C}^{in}, Pr_{5C}^{in}, Pr_{6C}^{in}, Pr_{7C}^{in}, Pr_{8C}^{in}$</td> </tr> <tr> <td>5</td> <td>Fullfill($Tp_2, q_3$), Fullfill($Tp_3, q_8$), newTime(20)</td> <td>$Pr_{1C}^{in}, Pr_{2C}^{in}, Pr_{3C}^{in}, Pr_{4C}^{in}, Pr_{5C}^{in}, Pr_{6C}^{in}, Pr_{7C}^{in}, Pr_{8C}^{in}$</td> </tr> <tr> <td>6</td> <td>Fullfill($De_2, q_4$), Fullfill($Tp_5, q_6$), newTime(21)</td> <td>$Pr_{1C}^{in}, Pr_{2C}^{in}, Pr_{3C}^{in}, Pr_{4C}^{in}, Pr_{5C}^{in}, Pr_{6C}^{in}, Pr_{7C}^{in}, Pr_{8C}^{in}$</td> </tr> <tr> <td>7</td> <td>Fullfill($De_1, q_6$), Fullfill($De_1, q_{10}$), newTime(22)</td> <td>$Pr_{1C}^{in}, Pr_{2C}^{in}, Pr_{3C}^{in}, Pr_{4C}^{in}, Pr_{5C}^{in}, Pr_{6C}^{in}, Pr_{7C}^{in}, Pr_{8C}^{in}$</td> </tr> </tbody> </table> Table 4.2: Execution Trace in Scenario of Tomato Sauce industry. --- 4.3. Norm Abidance As Figure 4.1 illustrates, the Norm Abidance Component receives the promises’ states, and the violation or obedience of socio-regulatory norms from NMC as inputs, and then measures two degrees: Committing Norm Obedience Degree (CNOD), and Socio-regulatory Norm Obedience Degree (SNOD), which are explained in the following sections. The obedience degrees, (CNOD and SNOD) are used to determine the agent’s trust level, task reassignment, and reward distribution. As mentioned before, joint-promises are decomposed into several individual promises, so the violation and obedience of co-working norms are considered in evaluation of the committing norms. There is also no obedience degree for controlling norms, because the violation of these norms are directly considered in risk prediction, while the violation and obedience of socio-regulatory norms, co-working norms and committing norms are needed for evaluation of trust. 4.3.1 CNOD - Committing Norm Obedience Degree CNOD indicates how much the behavior of each agent is compliant with its committing norms (promises). In a VO, typically, based on the type of promised sub-task, some Quality Specification Criterion (QSC) are defined at the time of agreement between promiser and the VO coordinator or task leaders. For example, if a partner is the farmer who delivers tomato in the tomato paste production-example, then for instance the tomato’s quality grades (e.g. $G_1$, $G_2$ or $G_3$) or color (e.g. red, orange, or green) are the QSCs for its delivered product, which is usually agreed between this partner and the promisee, e.g. the VO coordinator. Therefore, QSCs should also be evaluated when measuring the CNOD. Chapter 4. Normative Virtual Organizations Supervisory Assistant Tool - VOSAT for an agent. **QSC Evaluation** The design of our approach to evaluate QSCs for an agent is partially rooted in [88]. In our approach two rating factors for QSC are defined as follows: 1. **Fulfillment of QSC (FQ)** shows the degree of fulfillment of each QSC. The maximum value of FQ for a QSC is the value stated in the contract, which is mutually agreed between each agent and the task leader or the VO coordinator. 2. **Influence of QSC (IQ)** is defined in [0,1] by the task leader or the VO coordinator, to determine the importance and influence of each QSC in quality evaluation of results produced by the agent. We use these two factors to calculate the quality of the results produced by the agent after performing its sub-task against the ideal quality, which are mutually agreed in the contract. In other words, this is defined as a measure of how good the agent delivers his agreed promise with the task leader or the VO coordinator. At first, we define function $C$, $C : S \rightarrow \mathcal{P}(V)$, where $S$ is the set of all sub-tasks defined in a VO, the set of all quality specification criteria defined for results of sub-tasks in a VO, is denoted by $V$, and $\mathcal{P}(V)$ is the power set of $V$. The quality of delivered sub-task $st$, if at least one criterion is specified for it (i.e. $|C(st)| > 0$), is calculated as follows: $$Quality(st) = \sum_{i=1}^{C(st)} FQ(c_i, st) \times IQ(c_i, st)$$ (4.2) where, $st$ shows a sub-task, $FQ : V \times S \rightarrow [0,1]$ and $IQ : V \times S \rightarrow [0,1]$, $V$ is the set of all quality specification criteria, $|C(st)|$ is the number of quality criteria for the sub-task $st$, and $c_i$ shows the $i^{th}$ criterion of the $C(st)$. The $Max\_Quality$ value for a sub-task shows the maximum possible quality occurrence to perform the sub-task. It is calculated as follows: $$Max\_Quality(st) = \sum_{i=1}^{C(st)} \max(FQ(c_i, st)) \times IQ(c_i, st) = \sum_{i=1}^{C(st)} IQ(c_i, st)$$ (4.3) where, $\max(FQ(c_i, st))$ indicates the ideal and maximum value of the fulfillment of the $c_i$, which is here equal to 1, because in our approach, FQ values are normalized into [0,1]. The relative quality between what the agent actually delivered and maximum possible quality value (expected value) is calculated as follows: $$Relative\_Quality(st) = \frac{Quality(st)}{Max\_Quality(st)}$$ (4.4) 4.3. Norm Abidance It should be noticed that relative quality for each sub-task is measured after it is performed, i.e. when the state of the promise made to perform the sub-task is kept. It means that relative quality is ignored for promises, which are not kept, invalidated and withdrawn. Since different criteria have different FQ values, we normalize all received values into [0,1]. Assume that the promisee (service client) for which the sub-task is performed, sends a fulfilment value for a criterion, called \( x \), in \([a,b]\), then the formulas below show how it is normalized into an interval \([0,1]\), and named \( x' \). For those criteria that have positive connotations (e.g. the Availability, Throughput, and Reliability for a developed software service), their values will be scaled as follows [28]: \[ x' = \begin{cases} \frac{x - a}{b - a} & \text{if } a \neq b \\ 1 & \text{otherwise} \end{cases} \] (4.5) For criteria with negative connotation (e.g. the Response time for a software service) the formula below is used [28]: \[ x' = \begin{cases} \frac{b - x}{b - a} & \text{if } a \neq b \\ 1 & \text{otherwise} \end{cases} \] (4.6) Promise Evaluation Considering the Quality Specification Criteria To measure the committing norms obedience degree (CNOD), three measures are considered and explained in the following paragraphs. **Promise Fulfillment (PF).** The evaluation of a promise in its termination state (i.e. kept, not kept, withdrawn, invalidated, released or dissolved) can be different based on the VO in which the promise is made. An example of values assigned by the VO coordinator to different states of a promise is shown in Table 4.3. These values show the fulfillment degree of an agent’s promise. In fact, the promise fulfillment values are determined for a promiser who made a promise to perform a sub-task. The value should be positive, or negative, e.g. promise fulfillment degrees in Table 4.3 are defined in \([-2,-1,-0.3,2]\). Withdrawn and Not Kept states of a promise have negative effects on the performance evaluation of promiser, so their values are also negative, while kept promise has positive effect on the performance evaluation of the promiser. Invalidated promise can negatively influence the promiser performance, however the reason is out of the control of the promiser, so we consider a very little negative value for it (e.g. -0.3 as shown in Table 4.3). Realised promise shows that promisee cancels the promise, so it is not negative or positive for promiser’s performance. Moreover, when preconditions of a promise are not fulfilled, the state of a promise is dissolved, which is not negative or positive for the promiser. Therefore, released and dissolved promises are not considered in CNOD measurement. <table> <thead> <tr> <th>Promise State</th> <th>Promise Fulfillment Value</th> </tr> </thead> <tbody> <tr> <td>Not Kept</td> <td>-2</td> </tr> <tr> <td>Withdrawn</td> <td>-1</td> </tr> <tr> <td>Invalidated</td> <td>-0.3</td> </tr> <tr> <td>Kept</td> <td>2</td> </tr> </tbody> </table> Table 4.3: An example of Promise Fulfillment (PF) values **Promise Importance (PI).** Next to the Promise Fulfillment (PF) value addressed above, it is also needed to consider Promise Importance (PI) in the measuring of CNOD, because some promises are related to the sub-tasks that have more important roles in the collaboration success of the VO. The values of PIs are considered in $[0,1]$. **Q-Factor (QF).** To show the role of Relative-Quality in evaluation of CNOD, we define the Q-Factor (QF) for promise $p_j$ made for performing sub-task $st_{p_j}$, as follows: $$ QF(p_j) = \begin{cases} \text{Relative-Quality}(st_{p_j}) & \text{if } st_{p_j} \text{ is performed} \\ 1 & \text{otherwise} \end{cases} \quad (4.7) $$ where, $st_{p_j}$ shows the sub-task for performing which promise $p_j$ is made. The value of $QF(p_j)$ is in $[0,1]$, because the value of $\text{Relative-Quality}(st_{p_j})$ is $[0,1]$. If the $st_{p_j}$ is performed then its related $PF(p_j)$ in Formula 4.8 has the maximum value (i.e. 2, considering Table 4.3). Moreover, if all quality criteria agreed for this sub-task, are ideally fulfilled, $\text{Relative-Quality}(st_{p_j})$ is 1, and consequently $QF(p_j)$ is 1. When promise $p_j$ is withdrawn, not kept or invalidated, its $PF(p_j)$ is negative. In this situation, $QF(p_j)$ is 1, because 1 is the identity element under multiplication, which shows that Relative-Quality is ignored for withdrawn, not kept and invalidated states. We define the function $f_1$, $f_1 : \delta_A \rightarrow P(\delta_p)$, where $\delta_A$ is the set of agents involved in a VO, $\delta_p$ is the set of promises made so far in the VO, and $P(\delta_p)$ is the power set of $\delta_p$. Similar to the formula for Relative-Quality, the CNOD for agent A is calculated as follows: $$ CNOD(A) = \frac{\sum_{j=1}^{[f_1(A)]} PF(p_j) \cdot PI(p_j) \cdot QF(p_j)}{\sum_{j=1}^{[f_1(A)]} \max(PF(p_j)) \cdot PI(p_j)} \quad (4.8) $$ where, $\left[f_1(A)\right]$ shows the number of promises that agent A has made so far in the VO (for each sub-task only one promise is made), $PI : \delta_p \rightarrow [0,1]$, $QF : \delta_p \rightarrow [0,1]$ and $\max(PF(p_j))$ indicates the ideal and maximum value of the fulfillment 4.3. Norm Abidance of the promise \( p_j \). It should be noticed that considering the example values for promise fulfilment in Table 4.3, \( PF : \delta_p \rightarrow \{-2, -1, -0.3, 2\} \). This formula returns a value for each agent, which shows the ratio of agent’s success in fulfilling its promises and their QSCs in relation to the ideal state. Below, it is shown that CNOD is a value in \([-1,1]\). Since \( PI(p_j) \) and \( QF(p_j) \) are values in \([0,1]\), and PF is defined in \( \{-2,-1,-0.3, 2\} \), we have: \[ |PF(p_j) \cdot PI(p_j) \cdot QF(p_j)| \leq max(PF(p_j)) \cdot PI(p_j), \quad \forall j = 1 \ldots |f_1(A)| \] and then: \[ \sum_{j=1}^{[f_1(A)]} |PF(p_j) \cdot PI(p_j) \cdot QF(p_j)| \leq \sum_{j=1}^{[f_1(A)]} max(PF(p_j)) \cdot PI(p_j) \] Based on the rule \( |a + b| \leq |a| + |b| \), we have: \[ | \sum_{j=1}^{[f_1(A)]} PF(p_j) \cdot PI(p_j) \cdot QF(p_j) | \leq \sum_{j=1}^{[f_1(A)]} |PF(p_j) \cdot PI(p_j) \cdot QF(p_j)| \] and consequently, \[ | \sum_{j=1}^{[f_1(A)]} PF(p_j) \cdot PI(p_j) \cdot QF(p_j) | \leq \sum_{j=1}^{[f_1(A)]} max(PF(p_j)) \cdot PI(p_j) \] It is also clear that: \[ \frac{\sum_{j=1}^{[f_1(A)]} PF(p_j) \cdot PI(p_j) \cdot QF(p_j)}{\sum_{j=1}^{[f_1(A)]} max(PF(p_j)) \cdot PI(p_j)} \leq 1 \] This means that \( |CNOD| \leq 1 \) (see Formula 4.8). If PI for all promises of an agent \( A \) is 1, PF is defined in \( \{-2,-1,-0.3, 2\} \), and all its promises are not kept then \( CNOD(A) = \frac{\sum_{j=1}^{[f_1(A)]} (-2) \cdot 1 \cdot 1}{\sum_{j=1}^{[f_1(A)]} 2 \cdot 1} = -1 \), if all its promises and their related QSCs are kept, \( CNOD(A)=1 \) and if half of its promises and their related QSCs are kept and half of its promises are not kept, \( CNOD(A)=0 \). According to the definition of joint-promise (see Formula 4.1), the creation of a joint-promise generates several individual promises. These individual promises will be counted in the CNOD measurement. It should be noticed that the promises of an agent for performing a specific sub-task are counted only once. CNOD is an internal measure, which is invisible for stakeholders, and only used as a criterion for trust evaluation and other future decisions. Chapter 4. Normative Virtual Organizations Supervisory Assistant Tool - VOSAT Example Considering the case of partners in an R&D project introduced earlier in the thesis, assume that agent $A$ agrees to perform the following two sub-tasks for agent $C$ that represents a task leader or the VO coordinator: - $st_1$: providing a manual report document within 3 weeks from now. - $st_2$: developing a software service within 6 weeks from now. Consequently, two promises are made by agent $A$ to agent $C$ as follows: 1. $Pr_{UC}(A,C,st_1,3\text{weeks},T,0)$. 2. $Pr_{UC}(A,C,st_2,6\text{weeks},T,0)$. For the report document, assume that, based on their agreement, the content of the manual document should be fully compliant with agreed TOC (Table Of Content) with the attachment of 25 screen shots, i.e. $C(st_1) = \{\text{content, attachment}\}$. For the software service, assume that it is agreed that response time of the service should not be greater than one minute, availability of the service should be 24h, and reliability should be greater than 90%, $C(st_2) = \{\text{ResponseTime, Availability, Reliability}\}$. Obviously, QSCs for these sub-tasks would be relevant and measured if they are performed, as explained before. Assume also that, the first promise is kept, with 70% compliant with agreed TOC, and accompanied with 12 screen shots, while the second promise is invalidated, since the development of software could not go on due to reasons beyond the control of the agent. Therefore, two QSCs for the first promise, i.e. content, and attachment need to be measured. For example, if the content is 70% compliant with agreed TOC, then $FQ(content,st_1)$ is $\frac{0.7-0}{1-0}$ and if 12 screen shots are delivered then the normalized $FQ(attachment,st_1)$ is $\frac{12-0}{25-0}$ (considering the Formula 4.5). Furthermore, if the IQ of the content is 0.9, and the IQ of the attachment is 0.5, then we can compute the quality of delivered sub-task, $st_1$, as follows: $$Quality(st_1) = FQ(content,st_1) * IQ(content,st_1) + FQ(attachment,st_1) * IQ(attachment,st_1) = 0.87$$ $max(FQ(content,st_1))$ is 1, because the ideal result for content is 100% compliant with agreed TOC. The ideal result for attachment is 25 screen shots, so $max(FQ(attachment,st_1))$ is $\frac{25}{25} = 1$; therefore, we have: $Max\_Quality(st_1) = 1.4$ and finally $Relative\_Quality(st_1) = 0.621$. Assuming that the Promise Importance (PI) of the first promise (which is fulfilled) is 1 and the PI of the second promise (which is invalidated) is 0.5, we then have $CNOD(A)=0.247$, considering the Formula 4.8 and Table 4.3. 4.3.2 SNOD - Socio-regulatory Norm Obedience Degree Socio-regulatory Norm Obedience Degree shows to which extent an agent has complied with the socio-regulatory norms, as specified in the consortium agreement. We define function $f_2$, $f_2 : \delta_A \rightarrow P(\delta_s)$, where $\delta_A$ is the set of agents involved in a VO, $\delta_s$ is the set of all socio-regulatory norms defined for agents in the VO, and $P(\delta_s)$ is the power set of $\delta_s$. SNOD is calculated as follows: $$SNOD(A) = \frac{\sum_{i=1}^{\left| f_2(A) \right|} NF(n_i)}{\left| f_2(A) \right|}$$ (4.9) where, $NF(n_i)$ shows the Norm Fulfilment (NF) degree of socio-regulatory norm $n_i$ ( $NF : \delta_s \rightarrow \{-1,1\}$). $NF(n_i)$ is 1 if norm $n_i$ is kept (obeyed), while $NF(n_i)$ is -1 if $n_i$ is violated. It is clear that SNOD is a value in [-1,1]. These norms have two states, i.e. violated and obeyed (kept), so in this formula only the number of violated norms and obeyed norms are taken into account. 4.4 Conclusion This chapter addresses the VO Supervisory Assisting Tool (VOSAT). It includes norm monitoring component, norm abidance component, trust evaluating component, risk predicting component and partner selecting component. The first two component are discussed in this chapter. Norm Monitoring Component is responsible for monitoring and controlling the agents’ behavior against their defined norms, and imposing related sanctions against the norms’ violations. This component is implemented using Organization Oriented Programming Language (2OPL). Norm abidance component is responsible for measuring the committing norms obedience degrees (CNOD) and socio-regulatory norms obedience degrees (SNOD) for each agent based on the information calculated in norm monitoring component. CNOD and SNOD are used to evaluate trust level of VO partners during the VO operation phase, to select best-fit partner for reassignment of risky tasks, and reward distribution, which are discussed in Chapters 5 and 6.
{"Source-Url": "https://pure.uva.nl/ws/files/9847324/04.pdf", "len_cl100k_base": 13283, "olmocr-version": "0.1.49", "pdf-total-pages": 20, "total-fallback-pages": 0, "total-input-tokens": 59320, "total-output-tokens": 14434, "length": "2e13", "weborganizer": {"__label__adult": 0.0002827644348144531, "__label__art_design": 0.0004940032958984375, "__label__crime_law": 0.0004925727844238281, "__label__education_jobs": 0.005153656005859375, "__label__entertainment": 0.00010794401168823242, "__label__fashion_beauty": 0.00016307830810546875, "__label__finance_business": 0.002696990966796875, "__label__food_dining": 0.0003764629364013672, "__label__games": 0.00078582763671875, "__label__hardware": 0.0008091926574707031, "__label__health": 0.0004425048828125, "__label__history": 0.0003528594970703125, "__label__home_hobbies": 0.00018513202667236328, "__label__industrial": 0.0007486343383789062, "__label__literature": 0.00040030479431152344, "__label__politics": 0.0003254413604736328, "__label__religion": 0.0003795623779296875, "__label__science_tech": 0.08697509765625, "__label__social_life": 0.0002310276031494141, "__label__software": 0.0362548828125, "__label__software_dev": 0.861328125, "__label__sports_fitness": 0.0002624988555908203, "__label__transportation": 0.00047969818115234375, "__label__travel": 0.00025582313537597656}, "weborganizer_max": "__label__software_dev", "avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_v1__avg_fraction_numbers_in_line_ratio": [[0, 49163, 0.02951]], "fineweb_edu_fasttext_gt2__fineweb_edu_fasttext_gt2__score": [[0, 49163, 0.74879]], "ft_lang_id_en_doc_v2__ft_lang_id_en_doc_v2__en": [[0, 49163, 0.88279]], "google_gemma-3-12b-it_contains_pii": [[0, 1010, false], [1010, 2778, null], [2778, 4685, null], [4685, 7509, null], [7509, 10138, null], [10138, 12406, null], [12406, 14920, null], [14920, 18149, null], [18149, 20523, null], [20523, 23307, null], [23307, 24776, null], [24776, 27087, null], [27087, 29808, null], [29808, 34559, null], [34559, 37023, null], [37023, 39684, null], [39684, 42320, null], [42320, 44513, null], [44513, 47141, null], [47141, 49163, null]], "google_gemma-3-12b-it_is_public_document": [[0, 1010, true], [1010, 2778, null], [2778, 4685, null], [4685, 7509, null], [7509, 10138, null], [10138, 12406, null], [12406, 14920, null], [14920, 18149, null], [18149, 20523, null], [20523, 23307, null], [23307, 24776, null], [24776, 27087, null], [27087, 29808, null], [29808, 34559, null], [34559, 37023, null], [37023, 39684, null], [39684, 42320, null], [42320, 44513, null], [44513, 47141, null], [47141, 49163, null]], "google_gemma-3-4b-it_v2tag__is_academic_paper": [[0, 5000, true], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_class_syllabus": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_completion_certificate": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_court_notice": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_homework_assignment": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_news_article": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_public_order": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_resume_cv": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_test_or_quiz": [[0, 5000, false], [5000, 49163, null]], "google_gemma-3-4b-it_v2tag__is_textbook": [[0, 5000, false], [5000, 49163, null]], "pdf_page_numbers": [[0, 1010, 1], [1010, 2778, 2], [2778, 4685, 3], [4685, 7509, 4], [7509, 10138, 5], [10138, 12406, 6], [12406, 14920, 7], [14920, 18149, 8], [18149, 20523, 9], [20523, 23307, 10], [23307, 24776, 11], [24776, 27087, 12], [27087, 29808, 13], [29808, 34559, 14], [34559, 37023, 15], [37023, 39684, 16], [39684, 42320, 17], [42320, 44513, 18], [44513, 47141, 19], [47141, 49163, 20]], "pipe_delimited_lines_v1__pipe_delimited_lines_v1__pipe_delimited_lines_ratio": [[0, 49163, 0.09541]]}
olmocr_science_pdfs
2024-11-24
2024-11-24