SimQL Language Specification

(Second Draft)
prepared

by Rushan Jiang

for CS395 (Indepedent Database Project)
July 29, 1996


SimQL Project Information

TABLE OF CONTENTS

1. Introduction 2. SimQL Overview 3. SimQL Syntax and Semantics 4. SimQL Schema Language 5. SimQL Access and Query Language 6. Simulator Interfaces
7. Reusing and Integrating Simulation Results in SimQL 8. Appendix

Some formatting was lost in conversion to HTML.


1. Introduction

1.1 Motivation

Simulation, as defined in the Webster Dictionary, is "the imitative representation of the functioning of one system or process by means of the functioning of another". It is a widely-used method in various areas involving planning, such as manufacturing, finance, military, and so on, to obtain information about events that would happen as outcome of certain courses of actions. There are quite a few computer languages (e.g. QSIM) available for writing simulations, many of which provides simulation application programmers with powerful and efficient ways to write simulations.

However, little support has been given to the users of simulation results. Often the effort spent writing simulations is not adequately justified by the level of effectiveness and efficiency at which the simulation results are used. For example, the U.S. Department of Defense highlighted one of the many shortcomings in its ability to effectively and efficiently use models and simulations: "Significant effort is devoted to developing 'stand alone' models with no intent to reuse--costly duplication". In an attempt to enhance the way people access and reuse simulation results, we in this document propose an initial specification for SimQL, a simulation access and query language.

It is extremely important to point out that SimQL is not a language for writing simulations. Rather, it gives simulation users a better mechanism to access and query simulation results, and provides with value-added services through applications that reuse (through interpolating and extrapolating) and integrate simulation results.

1.2 Organization

In the process of developing this proposal, we have taken concepts from SQL, KQML, CORBA, and IDL. SimQL is very similar to SQL, a relational schema and query language that has become the standard in database industry, in the way we model simulation and query simulation results. Since SimQL is more likely to be used in a distributed environment, where simulators and simulation results residing on a variey of workstation platforms connected through TCP/IP-like networks are shared among SimQL users, we have incorporated features of popular object-oriented CORBA and OMG IDL standards into SimQL. The Object Request Broker(OMG ORB) specification which defines distributed services for interprocess and interplatform messaging, data type translation, and name translation, has also helped us conceptually in designing SimQL.

However, this document mostly defines SimQL at the language level by specifying its syntactic and semantic fundamentals. The "SimQL Overview" section describes the components of SimQL, and the environment in which it operates. The "SimQL Syntax and Semantics" section describes the lexical convention of SimQL and gives the SimQL string syntax in BNF. "SimQL Schema Language" and "SimQL Access and Query Language" describe in detail the modeling and querying mechanisms of respectively. The "Simulator Interfaces" section describes how concepts of CORBA and IDL can be used in SimQL to interact with other existing simulators through a set of wrappers. Finally, the "Appendix" section includes features that could be added to SimQL in the future.

2. SimQL Overview

2.1 SimQL Environment

All SimQL operations are performed within the context of a SimQL environment, which includes among other things an arbitrary number of SimQL catalogs, grouped into clusters. Each catalog consists of a set of SimQL schemas that in turn contain models of simulations. This structure is parallel to that of SQL(i.e. a SimQL model is similar to an SQL view; a SimQL schema is similar to an SQL schema, and so on). An SQL cluster consists of the set of all SQL catalogs that describe any objects that are accessible to a given user; a SimQL cluster has all SimQL catalogs of a user. A SimQL catalog within a given cluster has information about simulations(SimQL schemas) of some kind. A SimQL schema includes all SimQL models that make up the simulation in which a particular user is interested.

However, SimQL schema is different from SQL schema in many ways. Unlike SQL schema, which includes all of the information about objects that an implementation requires, SimQL schema only privides the information about interfaces to simulators. SimQL schema also has IN, OUT, and INOUT data types, which will be discussed in detail in "SimQL Schema Language".

A SimQL model is the most fundamental representation of a simulation through which a user accesses simulation results. For example, for a weather simulation, we could have two SimQL models, (time, location, temparature) and (time, location, precipitation), both of which belong to the schema that represents the simulation. A SimQL model analogous to a view in SQL in the sense that it gives an abstraction of (part of) the simulation but it does not actually exist.

The aforementioned structure can be best pictured in Figure 1.

The SimQL environment also has SimQL agents. A SimQL agent can be thought of as the execution of an application program, which includes one or more SimQL operations. The SimQL agent starts execution under the control of another SimQL environment component, SimQL client. The SimQL agent first causes the SimQL client to establish a SimQL connection with a SimQL server, which in turn carries out the SimQL operations(queries) requested by the SimQL agent.

Based on the SimQL schema defined by the SimQL agent and the qureies submitted, the SimQL server has to access and possibly integrate corresponding simulation results generated by some simulators through some Simulator Interfaces. A Simulator Interface can be thought of as an ORB(Object Request Broker) that will find a proper wrapper for the SimQL server's request. If such a wrapper does indeed exist, the Simulator Interface passes the SimQL server's request along with its parameters to the wrapper, which in turn massages them and passes them to the corresponding simulator. The simulator carries out the desired simulation and generates the simulationm results. The results are passed back from the simulator through the wrapper, the Simulator Interface, processed and possibly integrated by the SimQL server to SimQL results, which are then returned to the SimQL agent. The process is illustrated in Figure 2.

2.2 SimQL Components

To summarize, a SimQL environment has the following: To create a SimQL environment, we will need to have SimQL Management System builders, SimQL wrapper builders, simulation builders, and simulation users. The SimQL Management System builders develop the SimQL system that runs on SimQL server, namely, the SimQL Schema Language and the SimQL Access and Query Language, and the Simulator Interface(ORB). The SimQL wrapper builders develop wrappers for simulators, "register" wrappers, and model simulations in SImQL. The simulation builders actually write the simulation programs. The simulation users use the simulation results through either SimQL agents which include SimQL operations or interactive sessions with the SimQL server.

To Summarize, a SimQL Management System includes:

In this document we focus on the SimQL Schema Language and the SimQL Query Language of a SimQL Management System.

3. SimQL Syntax and Semantics

3.1 SimQL BNF Format

3.2 Lexical Conventions

3.2.1 SimQL Language Characters

The SimQL language character set is exactly the same as the SQL language character set. Namely, the SimQL language characters include the upper case letters A-Z, the lower case letters a-z, the digits 0-9, and a set of SimQL special characters: and a space character.

3.2.2 Tokens and Separators

Tokens (delimiters or nondelimiters) and separators are exactly the same as those in SQL. For brevity reason, we do not repeat them here.

3.2.3 Comments

A comment in SimQL consists of two consecutive minus signs ("--"), followed by any sequence of zero or more characters, terminating with a newline marker.

3.2.4 Identifiers

The definition of an identifier in SimQL is the same as that in SQL. An identifier is either a regular identifier or a delimited identifier.

The following are all identifiers in the foregoing sense:

The following have names that consist of an identifier in the foregoing sense, preceded by a qualifier that is a catalog name (separated from the identifier by a period): The following have names that consist of an identifier in the foregoing sense, preceded by a qualifier that is a schema name (separated from the identifier by a period): The following have names that consist of an identifier in the foregoing sense, preceded by a qualifier that is a model name (separated from the identifier by a period):

3.2.5 Keywords

A key word is a word that has some prescribed meaning within the SimQL language itself. Some key words are reserved, others are not.

Reserved keywords(tentative):

3.2.6 to 3.2.11 categorize and introduce the reserved keywords.

3.2.6 Data Types

3.2.7 Scalar Operators and Functions

3.2.8 Aggregate Functions

3.2.9 SimQL Schema Related Operations

Each of the following is discussed in "SimQL Schema Language".

3.2.10 SimQL Access and Query Related Operations

Each of the following is discussed in "SimQL Access and Query Language".

3.2.11 Simulator Interface Related Operations

Each of the following is discussed in "Simulator Interfaces".

3.3 SimQL Grammar

Syntax for SimQL in BNF format is given in section 4, 5, and 6.

Syntax for SQL is not repeated here.

4. SimQL Schema Language

In this section, we describe the ways to create and modify SimQL models. Most of the features described here are parallel to those of view's in SQL because a SimQL model in SimQL is just like a view in SQL in the sense that it gives an abstraction of some simulation but does not actually exist in its own right.

4.1 Creating SimQL Models

SimQL models are not supported by any separately distinguishable underlying data of their own. Instead, all that happens when a SimQL model is created is that the definition of that model in terms of "registered" simulators is stored by the system in a SimQL schema.

However, SimQL models also differ from views of SQL in many ways. Insertion and deletion are not supported for models because there aren't any "base tables" underneath models. Querying a model means finding out the IN/OUT/INOUT elements or the method of the model. Updating a model means adding/deleting/altering model elements or changing a model method, a privilege restricted to the wrapper writers. We have not included specific model querying and updating mechanisms in our current SimQL specification.

The general syntax of CREATE MODEL is:

Here "model" is the name of the new model. Model element attributes "IN", "OUT", "INOUT" mean input to simulation, output from simulation, input/output to/from simulation, respectively.

An "OUT" element will hold the output value from the simulation as well as a CERTAINTY value upon returning from an access to a simulation. A CERTAINTY value is a floating point number between 0 and 1, representing the probability of the occurrence of such output.

Methods are declared when simulators are registered. Simulators are actually interfaces to simulation wrappers. Methods and simulators will be discussed in detail in "Simulator Interfaces".

Some examples of CREATE MODEL would be:

Here "weather_forecast" is a registered simulator (interface) with at least one method "temperature" declared. The model element attributes and types are checked against those of the method parameters. All the "IN"/"INOUT" model elements must match all the "IN"/"INOUT" method parameters in order for CREATE MODEL to succeed. However, it is not necessary to supply all the "OUT" model elements. For example, if the temperature method is declared as:

Then both the following CREATE MODEL's are fine. In the first model, the "low" output from the simulator is simply ignored.

To delete a SimQL model, use DROP MODEL.

For example,

deletes the above SimQL model.

Dropping the model does not affect the underlying method or simulator at all.

4.2 Updating SimQL Models

Updating SimQL models includes adding/deleting/altering model elements and changing a model method.

This could be achieved through:

Implementing specific model querying and updating mechanisms is part of our future work.

5. SimQL Access and Query Language

Once we have created simulation models in SimQL, we can trigger simulations and access simulation results in SimQL. Further more, integrated use of SimQL and SQL will allow us to build databases of simulation results and query the results, giving us tremendous power and flexibility to reuse and integrate results from different simulations.

In this section, we describe the SimQL access and query language features.

5.1 Accessing Simulations in SimQL

In SimQL, we use SIMULATE to trigger simulations and get results back. The general syntax for SIMULATE is:

The HAVING clause can be used to specify the conditions under which the simulation is to be carried out. For example, if the simulator has an attribute which tells us how long it has been idle, we can choose to simulate only when the idle time is longer than say, 1 msec. If the condition in the HAVING clause is not met, an error message will be returned.

An example of using SIMULATE follows.

Assume we have declared

when we registered simulator weather_forecast, and we did

We use

to simulate the low and high temparatures and precipitation in San Francisco on Jan. 1, 1997 only if the simulator has been idle for at least 6 hours.

To repeatedly trigger a simulation, we can use the FOR ... NEXT statement, which has the following syntax:

The FOR...NEXT is similar to the "for" in C and C++. The identifier declared in the FOR clause has the scope of the FOR...NEXT loop and can be used just like any other identifiers in the loop.

For example, if we want to simulate the weather_forecast 1000 times, we can use

to enclose the SIMULATE clause.

5.2 Querying Simulation Results in SimQL

SimQL models are not supported by any underlying simulation data. Although we can get immediate simulation results back using SIMULATE, reusing and integrating large amount of simulation data requires us to have the capbilities to store intermediate simulation results, query them, and manipulate them. We can use SimQL in conjunction with SQL to achieve this.

Specifically, we use CREATE TABLE (VIEW) in SQL to create the base tables (views), SIMULATE in SimQL to get simulation results back, and SELECT in SQL to query and integrate the databases of simulation results.

A user can use the SQL subset and SimQL to build a simulation result base table, populate it with simulation results from SIMULATE, and query it.

The various table JOIN operations in SQL can also be used in conjunction with SimQL to achieve effective and efficient use of stored simulation results.

6. Simulator Interfaces

Since the actual simulators are often written by independent simulation developers and thus have interfaces different from the SimQL API, SimQL wrapper builders also have to write wrappers for those simulators. The simulators, wrappers, and SimQL server most likely reside on different workstations, which are connected through some kind of finite-speed computer network, for which we think that a CORBA-like ORB built into SimQL would be most effective. The ORB(Object Request Broker) will accept request from the SimQL server, find a proper object implementation (wrapper) for the request, route the request to the implementation, and pass the results back to SimQL server when the implementation completes.

After writing/updating a wrapper for any simulator, the SimQL wrapper builder needs to register the wrapper/simulater so that the ORB will remember it and route a request to the proper wrapper. This is achieved in SimQL by using REGISTER SIMULATOR.

The general syntax for REGISTER SIMULATOR is:

An example would be:

7. Reusing and Integrating Simulation Results in SimQL

To illustrate how powerful and efficient a language SimQL is in providing us with value-added services to simulation results, we want to give a concrete example here.

Imagine a trucking company wants to ship some goods from city A to city B through a most optimal route, which is defined to have minimal amount of rainfall(delay) and minimal amount of shipping cost. The company has two simulators (and corresponding wrappers), one of which forecasts the weather condition along a route given the source, the destination, and the route; the other estimates the shipping cost given the source, the destination, and the route.

7.1 Independent Simulators

Let's first assume the shipping cost does not depend on the weather condition along the route (i.e. the two simulators are independent).

The wrapper writer has written this code in SimQL:

The manager of the trucking company can find the optimal route by using:

7.2 Dependent Simulators

Let's now assume the shipping cost does depend on the weather condition along the route (i.e. the two simulators are dependent). Now we have to trigger the two simulators in a particular order.

The shipping-cost simulator has been changed by the wrapper writer to

and the corresponding SimQL model is

One way to trigger the simulators and query the results would be:

Without SimQL, the task of choosing the optimal route based on the simulation results from two different simulators would be daunting.

8. Appendix

To be furnished later.