A SYSTEM, METHOD, AND COMPUTER PROGRAM PRODUCT FOR HANDLING DEFERRED EXPRESSIONS IN AN OBJECT ORIENTED STOCHASTIC SIMULATION MODEL

Abstract: A system, method, and computer program product for evaluating deferred expressions contained within programming code at runtime. The present invention provides a new data type called a deferred expression. Composite expressions that contain at least one deferred expression are type cast as a deferred expression. According to the method of the present invention, an expression, having a syntax and a type, contained within programming code is evaluated to generate a result. The expression is classified as one of a deferred expression type or an immediate expression type. A deferred expression type is an expression that includes one of a stochastic operand, an inter-object relationship operand, a domain function operand, and a composite expression having at least one deferred expression operand. The syntax of the expression is independent of the expression's type. A result is determined. The result is a primitive value if the expression is an immediate expression type. The result is a deferred expression if the expression is a deferred expression type. The result is assigned to a left-hand value. The left-hand value is one of a variable and an object property.

Description: A System, Method, and Computer Program Product for Handling Deferred Expressions in an Object Oriented Stochastic Simulation Model Background of the Invention Field of the Invention The present invention relates generally to the field of software-based simulations, and more particularly, to software-based simulations involving stochastic variables and multi-period states. The invention further relates to an object-oriented software architecture that provides a new data type to handle expressions that are better suited for evaluation at runtime. Related Art Software-based simulation programs have wide applicability to a large number of problems ranging from the modeling of physical processes for the purpose of scientific experimentation to economic models designed for the purpose of forecasting future macro- or micro-economic states. One type of software-based simulation is a stochastic simulation. Stochastic simulations calculate the behavior of some entity or set of entities over a number of discrete periods (referred to as multi-period) , where one or more of the entity' s underlying properties or attributes may vary in an uncertain or probabilistic manner. In multi- period, stochastic simulations, an entity's property or attribute usually varies in a stochastic manner over the discrete, non-continuous periods of a given simulation run. Stochastic simulations find great utility in such fields as social science, business management, interactive games, and financial planning. These fields typically address problems that involve a large number of stochastic variables that require the performance of complex calculations during each period of a simulation run. The interaction between various entities within the model may also be quite complex, requiring numerous entity dependencies and functional relationships. The ability of object oriented (OO) software languages to support data encapsulation and inheritance make them particularly well- suited for stochastic simulations that require numerous entity dependencies and functional relationships. Conventional object oriented stochastic simulation programs are typically inflexible. The programs are usually designed for a single, specific problem. The structure of the underlying simulation model is determined in advance and the type and behavior of an entity's properties or attributes are "hard-coded" into the program architecture. During compilation of a given computer program, expressions are evaluated using traditional interpreters that require the right-hand side of an assignment statement to be immediately evaluated and reduced to a primitive value, such as a number or a string. No mechanism exists that would allow an expression to be evaluated at runtime. Object properties which are stochastic are usually predefined by the software architecture and cannot be changed by the end- user at runtime. While the end-user may change the value of some input variables, the end-user cannot alter the underlying structure of the model or determine, at runtime, which properties will be stochastic and which probability distributions will be used to model the stochastic nature of the property. What is needed is a flexible system and method for providing a discrete event simulation space to enable the execution of performance intensive, object oriented stochastic simulations. What is also needed is a system and method for an object oriented stochastic simulation that allows an end-user to define and modify object properties that reference other object properties and/or are stochastic at runtime. What is further needed is a system and method for handling expressions better suited for evaluation at runtime in order to defer the evaluation of these expressions until runtime. Summary of the Invention The present invention solves the above-mentioned problems by providing a system, method, and computer program product for evaluating deferred expressions contained within prograrnming code at runtime. The present invention provides a new data type called a deferred expression. Composite expressions that contain at least one deferred expression are type cast as a deferred expression. According to the method of the present invention, an expression, having a syntax and a type, contained within programming code is evaluated to generate a result. The expression is classified as one of a deferred expression type or an immediate expression type. A deferred expression type is an expression that includes one of a stochastic operand, an inter-object relationship or object reference operand, a domain function operand, and a composite expression having at least one deferred expression operand. The syntax of the expression is independent of the expression's type. A result is determined. The result is a primitive value if the expression is an immediate expression type. The result is a deferred expression if the expression is a deferred expression type. The result is assigned to a left-hand value. The left-hand value is one of a variable and an object property. The results are used to configure an object oriented stochastic simulation model. A proxy/adapter object is created. The proxy/adapter object serves as an intermediary between the deferred expression and a target object within the stochastic simulation model so as to modify a property of the target object in accordance with the deferred expression. The present invention can be used with a variety of different kinds of host applications and can be adapted to a variety of user- interfaces. Further features and advantages of the invention, as well as the structure and operation of various embodiments of the invention, are described in detail below with reference to the accompanying drawings. Brief Description of the Figures The accompanying drawings, which are incorporated herein and form part of the specification, illustrate the present invention and, together with the description, further serve to explain the principles of the invention and to enable a person skilled in the pertinent art to make and use the invention. FIG. 1 A is a flow diagram illustrating a method for evaluating computer programming code having deferred expressions. FIG. IB is a flow diagram illustrating a method for interpreting expressions in a computer program. FIG. 1C is a flow diagram illustrating in greater detail a method for evaluating each node of a parse tree. FIG. ID is a block diagram illustrating the manner in which a proxy/adapter is used to modify properties of an object in an object-oriented stochastic simulation space according to an embodiment of the present invention. FIG. 2 A is a flow diagram illustrating a method for modifying an object ' s input properties using a proxy/adapter. FIG. 2B is a flow diagram illustrating a method for modifying an object's output properties using a proxy/adapter. FIG. 3 illustrates exemplary functional expression components that may be found in a library of functional expression components according to an embodiment of the present invention. FIG. 4 is a flow diagram illustrating a simulation framework/engine for implementing an embodiment of the present invention. FIG.5 is a flow diagram illustrating an initialization process of a simulation framework/engine according to an embodiment of the present invention. FIG. 6 is a flow diagram illustrating a processing method of a simulation framework/engine according to an embodiment of the present invention. FIG. 7 illustrates an exemplary output matrix for an output value of a simulation experiment according to an embodiment of the present invention. FIG. 8 is a diagram illustrating an exemplary computer system. The features, objects, and advantages of the present invention will become more apparent from the detailed description set forth below when taken in conjunction with the drawings in which like reference characters identify corresponding elements throughout. In the drawings, like reference numbers generally indicate identical, functionally similar, and/or structurally similar elements. The drawings in which an element first appears is indicated by the leftmost digit(s) in the corresponding reference number. Detailed Description of the Preferred Embodiments While the present invention is described herein with reference to illustrative embodiments for particular applications, it should be understood that the invention is not limited thereto. Those skilled in the art with access to the teachings provided herein will recognize additional modifications, applications, and embodiments within the scope thereof and additional fields in which the present invention would be of significant utility. /. An Overview of the Invention A. Terminology To more clearly delineate the present invention, an effort is made throughout the specification to adhere to the following term definitions consistently. The term "simulation" refers to both the general field and practice and to a given simulation experiment. The term "domain" or "domain model" refers to a user-defined representation of a given problem or situation. Each domain model contains one or more domain objects that represent the various entities of the problem to be modeled. The term "domain object" refers to a given entity in a domain model. Domain objects typically have one or more properties whose values may be monitored during the simulation to produce simulation output data. The term "simulation experiment" refers to one or more models of a given domain whose behavior is to be simulated. Each "domain model" is made up of a set of independent domain "entities" that contain the internal logic and behavior specific to that entity. Each model is simulated over a "time horizon" or over "time", where "time horizon" refers to a set of one or more discrete periods or steps. The "time horizon" may represent years, months, weeks, days, hours, minutes, seconds, etc. Simulation experiments are processed through all periods and all runs. The term "run" refers to each iteration of the simulation over the time horizon. Each simulation experiment is evaluated over one or more runs, wherein the number of runs is usually quite large (i.e., >1000) in order to produce statistically reliable results. Each run is made up of the same number of discrete periods. The term "period" refers to the interval of time between each update of the simulation model in a given run. The term "output property" refers to a domain object property whose values are to be monitored and collected during the processing of the simulation. The term "simulation output" refers to a set of data collected from all output properties from a given simulation experiment. The term "inter-object relationship" or "object reference" refers to an object property that references another object or object property. The term "deferred expression" refers to expressions that are only evaluated at runtime. The result of these expressions may be different each time they are evaluated since they depend on the current state of other domain objects in the simulation model. The term "domain function" refers to a special kind of deferred expression. A domain function is a function that returns the value of a given domain object property at runtime. Domain functions include, but are not limited to, date domain functions which return a date and numeric domain functions which are standard arithmetic expressions that include deferred expression operands. B. The Invention The present invention is a system and method for evaluating deferred expressions, contained within programming code, at runtime. The present invention provides a new data type called a deferred expression. Composite expressions that contain at least one deferred expression are type cast as a deferred expression. The present invention evaluates expressions, having a syntax and a type, contained within programming code to generate a result. The results are used to configure object oriented stochastic simulation models. In an embodiment of the present invention, Java, developed by Sun Microsystems, Inc., is used as the object oriented programming language. Other object oriented programming languages that provide dynamic binding of method calls may also be used. In one embodiment of the invention, end-user applications may be written using an interpreted, object-based scripting language that provides dynamic type casting, such as, but not limited to, JavaScript, VBScript, and Perl, each of which are well known to those skilled in the relevant art(s). Most scripting languages provide the following data types: a number type, a boolean type, a string type, an array type, and an object type. The present invention introduces a new data type called a deferred expression. Deferred expressions are expressions that are only evaluated at runtime. The present invention provides a method of evaluating expressions contained within computer programs to classify the expression as a deferred expression or an immediate expression. Immediate expressions are evaluated immediately, wherein the result is a primitive value (i.e., number, string, boolean, etc.). Deferred expressions are not evaluated until runtime, wherein the result is the deferred expression itself. The deferred expressions and resulting primitive values from immediate expressions are assigned to a left-hand value for configuring an object oriented stochastic simulation model. The left-hand value may be a variable or an object property. The present invention uses a proxy/adapter as an intermediary between the resulting expressions (i.e., primitive values and deferred expressions) and a target object to modify the property of the object. The target object's property is modified according to the resulting expression. The deferred expression may include many types of functions, including, but not limited to, stochastic functions, date domain functions, and inter-object relationship or object reference functions. Through the use of the proxy/adapter, the present invention allows an end- user to define inputs as well as outputs at run-time. An end-user may also specify derived output expressions. Derived output expressions create new output data that is derived from an original simulation output. A simulation framework engine repeatedly evaluates the behavior of the domain entities within a simulation model over a period of time. The simulation framework/engine is comprised of an initialization phase, a processing phase, and an output phase. In the present invention, domain entities can refer to and depend on each other in a manner that is independent of the location of the objects. This is referred to as inter-object relationships, inter-object relationship functions, or object references. These functions are deferred expressions. The initialization phase of the simulation framework/engine handles all deferred expressions in a single, consistent manner by generating a dependency graph of domain entities to each other. The processing phase of the simulation framework/engine is responsible for processing the simulation model and updating each object for each period in a run. During the processing phase of the simulation, deferred expressions are evaluated in the order in which they appear on the dependency graph. The output phase of the simulation framework/engine provides a means for tracking the value of properties which have been designated as output properties, and for storing the output property values over the designated periods of the simulation. 77. A Deferred Expression Type A deferred expression is an expression that is only evaluated at runtime. The result of these expressions may be different each time they are evaluated since they depend on the current state of other domain objects in a simulation model. The importance of having an expression type that is only evaluated at runtime is explained using the following example. A domain model has two domain objects. One domain object represents International Business Machines, Inc. (IBM) stock. The other domain object represents General Motors (GM) stock. Imagine that the price of GM stock is always twice that of IBM stock, so that whenever the price of IBM changes during the simulation, the price of GM will change also. In a traditional simulation environment, the following equation would result in the immediate evaluation of the right-hand side of the expression when the program is interpreted. GM.price = IBM.price * 2 (1) Thus, if IBM.price is 10, GM.price is 20. In a stochastic simulation, this may not be the desired effect. The right-hand expression may need to be evaluated during the actual simulation, at runtime, in order to use whatever price IBM will currently have at that current period in the current run of the simulation experiment. In order to accomplish this, the creation of a deferred expression is needed. A . Typ es of Deferred Exp ressions If a given expression contains no deferred references, it is evaluated immediately, and the result of the expression is one of the basic data types (e.g., string, number, boolean, or object). If an expression contains one or more deferred references, it becomes a deferred expression and is not immediately evaluated. At design time the result of a deferred expression is not a primitive value, but a function object. Deferred expressions include, but are not limited to, expressions that include object references, stochastic functions, and domain functions. Other expressions specific to a particular domain may also be categorized as deferred expressions. For example, a financial domain may include a "random walk" price process or a Black-Scholes price for an option. The random walk price process and the Black-Scholes price for an option are well known pricing models to persons skilled in the relevant art(s). 1. Object References Object references are one type of deferred expression. Object references, also known as inter-object relationships, depend on the current state of other domain object properties in the simulation model. In other words, they reference another domain object property. An expression that includes one or more object references automatically becomes a deferred expression. In one embodiment, a system function called GetReference ( ) is used to create a deferred reference. GetReference ( ) takes a single parameter, which must be a domain object property that is readable at runtime. One skilled in the relevant art(s) would know that other means for creating a deferred reference may be used without departing from the scope of the present invention. A deferred expression can only be on the right-hand side of an assignment statement, and the left hand side of the assignment statement must either be a variable or a domain object property. [left hand operand] = [deferred expression] (2) 2. Stochastic Functions Stochastic functions are a special kind of deferred expression. Unlike normal system functions that return an immediate result, stochastic functions are only evaluated at runtime in the context of a particular domain model. An expression that includes one or more stochastic functions automatically becomes a deferred expression. Stochastic functions, also known as random variate functions, return variates drawn from a specific probability distribution. Each time a random function is evaluated, a new variate is returned. Successive results from these functions are always independent and identically distributed (IID). Table 1 lists some of the stochastic functions that may be used. Other stochastic functions may easily be added. Stochastic Functions Normal ( ) returns a random variate from a standard normal distribution. Normal (m,v) returns a random variate from a normal distribution with mean m, and standard deviation v, where v>0. Uniform (m,n) returns a random variate from a uniform distribution between m and n, where II>ΠL Lognormal (m,v) returns a random variate from a lognormal distribution with mean, m, and standard deviation, v, where v>0. Weibull (a,b) returns a random variate from a weibull distribution with shape parameter, a, and scale parameter, b, where a>0 and b>0. Geometric (p) returns a random variate drawn from the geometric distribution with constant probability, p, where 0<p<l. The value returned represents the number of failures before the first success in a sequence of independent Bernoulli trials with probability p. DUniform (XI, X2, ..., Xn); Duniform ([XI ... Xn]) returns a random variate drawn from a set of discrete numeric values with equal probability. The function accepts either a discrete set of numeric parameters or a numeric Array object. Triangular (min, mode, max) returns a random variate drawn from a triangular distribution with minimum value, min, maximum value, max, and modal value, mode. RandomEmpirical (d); EmpiricalDistribution (c,v) returns a random variate drawn from an empirical distribution, d. The empirical distribution is an independent domain object of the type EmpiricalDistribution. An EmpiricalDistribution is entirely specified by two parameters, v and c. "v" is a numeric array defining the value points in the distribution, "c" is a numeric array defining the cumulative probabilities of each corresponding value point. Table! 3. Domain Functions Domain functions are a special kind of deferred expression. Unlike normal system functions that return an immediate result, domain functions are only evaluated at runtime in the context of a particular domain model. An expression that includes one or more domain functions automatically becomes a deferred expression. There are many types ofdomain functions, including: (l) datedomain functions and (2) numeric domain functions. a. Date Domain Functions Date domain functions return a date. In addition to the standard date function, special date domain functions are shown in Table 2. Other date functions may be added. Date Domain Functions OffsetDate (n) returns a date n years from the start of each run. n may itself be a domain function returning a numeric result. OffsetDate (n,p) returns a date n time units from the start of each run, where the unit of time is specified by p as a periodic frequency per year, where ? = { 1, 12}. n may itself be a domain function returning a numeric result. OffsetDate (b,n) returns a date n years after a given base date specified by b. n may itself be a domain function returning a numeric result, b may itself be another date domain function. This is equivalent to the expression: b + n. OffsetDate (b,p,n) returns a date n time units from a given base date specified by b, where the unit of time is specified by p as a periodic frequency per year, where p = { 1 , 12 }. n may itself be a domain function returning a numeric result, b may itself be another date domain function. Table 2 b. Numeric Domain Functions Standard arithmetic operations are converted into numeric domain functions if any of the operands contain deferred expressions. In addition to standard arithmetic functions, special numeric domain functions are shown in Table 3. Numeric Domain Functions SerialMean(p) returns the average of the domain object property, p, over all previous periods. SerialMean (p,n) returns the average of the domain object property, p, over the previous n periods, where n>0. SerialMax (p) returns the maximum value of a given domain object property, p, over all previous periods. SerialMax (p,n) returns the maximum value of a given domain object property, p, over the previous n periods, where n>0. SerialMin (p) returns the minimum value of a given domain object property, p, over all previous periods. SerialMin (p,n) returns the minimum value of a given domain object property, p, over the previous n periods, where n>0. SerialSum (p) returns the sum of the values of a given domain object property, p, over all previous periods. SerialSum (p,n) returns the sum of the values of a given domain object property, p, over the previous n periods, where n>0. SerialReference (e,n) returns the value of some expression, e, n periods in the past, e may be any valid deferred expression, including a reference to a domain object property, a domain function, or a composite deferred expression. Table 3 B. Interpreting Deferred Expressions With interpreted, object oriented scripting languages, the text of a computer program is parsed and evaluated. FIG. 1 A is a flow diagram illustrating a method for evaluating computer programming code having deferred expressions. The process begins with step 102, where control is immediately passed to step 104. In step 104, each expression within the computer programming code is classified as being an immediate expression type or a deferred expression type. Expressions that do not contain any deferred expressions are classified as immediate expression types, and can be evaluated immediately. Expressions that contain one or more deferred expressions are classified as deferred expression types, and can only be evaluated at runtime. Control then passes to step 106. In step 106, a result is determined for each expression. If the expression type is immediate, the result of the expression is a primitive value, such as a string, a number, a boolean, or an object. If the expression type is deferred, the result is not a primitive value, but a function object, since deferred expressions are only evaluated at runtime. The value of the function object is equal to the deferred expression itself. Control then passes to step 108. In step 108, each result is assigned to a left-hand value to be used to configure an object oriented stochastic simulation model. The left-hand value is either a variable or an object property. Control then passes to step 110, where the process ends. FIG. IB is a flow diagram illustrating a method for interpreting expressions in a computer program. The process begins with step 122, where control immediately passes to step 124. In step 124, the computer program is parsed and converted into a parse tree. Parsers and parse trees are well known to persons skilled in the relevant art(s). Control then passes to step 126. In step 126, the parse tree is evaluated. Each node of the parse tree is evaluated to determine a result. The result is either a primitive value for an immediate expression or the deferred expression itself for a deferred expression. Control then passes to step 128, where the result is the output. FIG. 1C is a flow diagram illustrating in greater detail method 126 for evaluating each node of a parse tree. The process begins with step 132, where control immediately passes to step 134. In step 134, the process begins for evaluating each node in the parse tree, one node at a time. Control passes to decision step 136. In decision step 136, it is determined whether the node is an atomic node or a composite node. An atomic node contains a single expression. A composite node identifies a composite expression. A composite expression is comprised of more than one expression. If the node is an atomic node, control then passes to step 138. In step 138, the atomic node is evaluated. The atomic node may be one of a primitive value, an object property reference, a domain function, and a stochastic function. If the atomic node can be reduced to a primitive value, the expression type is an immediate type and the primitive value is the result of the evaluation. If the atomic node is an object property reference, a domain function, or a stochastic function, the expression type is a deferred expression type. Deferred expressions cannot be evaluated until runtime, therefore, the result is the deferred expression itself. Control then passes to decision step 148. Returning to decision step 136, if the node is a composite node, control passes to step 140. In step 140, the process begins for evaluating each node having a child component of the composite node. Control then passes to step 142. In step 142, a child node is evaluated. The child node may be one of a primitive value, an object property reference, a domain function, and a stochastic function. If the child node can be reduced to a primitive value, the expression type is an immediate type and the result of the evaluation is the primitive value. If the child node is an object property reference, a domain function, or a stochastic function, the expression type is a deferred expression type. Deferred expressions cannot be evaluated until runtime, therefore, the result is the deferred expression itself. Control then passes to decision step 144. In decision step 144, it is determined whether there are more child components to be evaluated. If there are more child components to be evaluated, control passes back to step 140, where the next child component is evaluated. Returning to decision step 144, if there are no more child components to be evaluated, control passes to step 146. In step 146, the composite expression is evaluated. The composite expression may contain a binary arithmetic expression, a unary arithmetic expression, a binary boolean expression, a function, etc. If the composite expression is comprised of only primitive expressions, the composite expression is of an immediate type and the result of the composite expression is a primitive value. If the any part of the composite expression is a deferred expression, the entire expression is type cast as a deferred expression. The result of the composite expression is the composite or deferred expression itself. In one embodiment, where possible, the parser may take additional steps to collapse all immediate expressions within the composite deferred expression into a primitive expression. Control then passes to decision step 148. In decision step 148, it is determined whether the current node is the last node in the parse tree. If the current node is not the last node in the parse tree, control passes back to step 134 to evaluate the next node in the parse tree. If the current node is the last node in the parse tree, control then passes to step 150, where the process ends. A description for providing a deferred expression type to handle expressions that are better suited for evaluation at runtime is described above. A description of how to modify an object property for evaluation at runtime in a stochastic simulation space is described below. ///. A Proxy/Adapter in an Object Oriented Stochastic Simulation Space FIG. ID is a block diagram illustrating the manner in which a proxy/adapter is used to modify properties of an object in an object-oriented stochastic simulation space. As shown in FIG. ID, the invention provides a tool box 174 that a user 176 uses to generate new functional expression components 178 (functional expression components include deferred expressions, which are described above). User 176 generates the new functional expression components using a scripting language as described above. In one embodiment, an administrator (not shown), as well as user 176, may interact with tool box 174 to generate new functional expression components. The invention also provides a proxy/adapter 170 coupled to a library 172. Library 172 is used to store functional expression components 178 generated by user 176 using a scripting language. Proxy/adapter 170 may connect to any one or all of a plurality of object properties to modify the properties of an object. Shown in phantom in FIG. ID, proxy/adapter 170 may connect to a plurality of object properties 164-166 from a first object 162 A and to an object property 168 from a second object 162B. Proxy/adapter 170 is used to modify object properties 164-166 and 168 as input properties to be entered into the simulation or as output properties to be tracked during execution of a simulation experiment. A proxy and an adapter are design patterns that are well known to those skilled in the relevant art(s). Adapter objects are commonly used to convert a given interface into another given interface by translating one interface into another. Proxy objects are most commonly used to allow communication between a remote object and a local object, wherein the local object communicates with the proxy by sending messages to the it. The proxy, in turn, passes the message on to the remote object, without being concerned as to the location of the remote object. Adapters and proxies are also used to insert figures, tables, and/or spreadsheets into text documents or vice versa. The present invention combines the design patterns of the proxy and adapter objects to generate proxy/adapter object 170 for use in a stochastic simulation space. In one embodiment, a single proxy/adapter is used to specify all input properties and output properties for a simulation experiment. In another embodiment, a plurality of proxy/adapters are used to specify the input properties and output properties for a simulation experiment. For example, a different proxy/adapter may be used for each input and each output property requiring modification, or one proxy/adapter may be used for input properties and another proxy/adapter may be used for output properties, or a proxy/adapter for each type of input or output property may be used, such as a proxy/adapter for stochastic functions, a proxy/adapter for deterministic functions, a proxy/adapter for domain functions and a proxy/adapter for inter-object relationship functions. One skilled in the relevant art(s) would know that alternative methods of allocating proxy/adapters for input and output functions may be implemented without departing from the scope of the present invention. Proxy/adapter 170 acts as a transparent intermediary between library 172 and target objects, such as object 162 A or object 162B, within the stochastic simulation model so as to modify properties of the target objects in accordance with an arbitrarily complex functional expression. The arbitrarily complex functional expression is an arithmetic expression formed from one or more functional expression components found in library 172. In other words, proxy/adapter 170 modifies properties 164-168 of objects 162A and 162B, respectively, with arithmetic expressions formed from one or more functional expression components found in library 172. The operation of proxy/adapter 170 will be described in greater detail with reference to FIGs. 2 A and 2B. From an input property' s point of view, proxy adapter 170 operates similar to an adapter design pattern. FIG. 2A is a flow diagram of a method for modifying an input property using proxy/adapter 170. The process begins with step 202, where control immediately passes to step 204. In step 204, an arbitrarily complex functional expression is written to proxy/adapter 170 without knowing which input property will receive the expression. Control then passes to step 206. In step 206, proxy adapter 170 sets the value of the property of the target object (102A or 102B, for example) to the arbitrarily complex functional expression. Control then passes to step 208, where the process ends. From an output property's viewpoint, proxy adapter 170 operates similar to a proxy design pattern. FIG. 2B is a flow diagram of a method for retrieving the value of an output property using proxy/adapter 170. The process begins with step 212, where control immediately passes to step 214. In step 214, the simulation framework/engine requests a value from proxy/adapter 170. Control then passes to step 216. In step 216, proxy/adapter 170 retrieves the value of the output property without the simulation framework/engine knowing how the value was retrieved or from where it was retrieved. Control then passes to step 218, where the process ends. IV. Functional Expression Components The present invention allows the properties of objects in the simulation to be determined by the evaluation, at runtime, of arbitrarily complex functional expressions that are setup by the end-user. In one embodiment, the end-user may employ a scripting language to implement the arbitrarily complex functional expressions as described above. Scripting languages are well known to those skilled in the relevant art(s). FIG. 3 illustrates the types of functional expression components that may be found in library 172. FIG. 3 contains a Ust of components 302 and a corresponding Ust of examples 304. Components Ust 302 includes numeric expressions 306, stochastic expressions 310, inter-object relationships 314, arithmetic operators 318, and unary expressions 322. Components Ust 302 is just a sample of the many types of expressions and operators that may be used to generate arbitrarily complex functional expressions. One skilled in the relevant art(s) would know that other types of expressions and operators may be used without departing from the scope of the present invention. Numeric expressions 306 are numeric values. Examples Ust 304 shows examples of numeric expressions 308. The examples include, but are not limited to, 5, 3.1416, 10.0, and -5.2. Stochastic expressions 310 are modeled using probabihty distributions. Stochastic expressions return random variates drawn from a specific probabihty distribution. Each time the given stochastic expression is evaluated, a new random variate is returned. Successive results from these expressions are independent and identicaUy distributed. Examples Ust 304 provides examples of stochastic expressions 312. The examples include, but are not limited to, a uniform distribution and a normal distribution. Other examples are Usted above in Table 1. Inter-object relationships 314 are object properties that reference other object properties. Examples Ust 304 provides examples of inter-object relationships 316. In one example, the price of IBM stock references the price of General Motors stock. That is, IBM stock is twice the amount of General Motors stock. In another example, SaUy's age references Harry's age. That is, SaUy's age is Harry's age minus 3. With inter-object relationships, the present invention must insure that the referenced object is evaluated prior to the inter-object relationships expression being evaluated. Thus, the result of the expression cannot be evaluated immediately. Instead, the expression must be evaluated at runtime. Arithmetic operators 318 take numeric values as their operands and return a single numeric value. Examples Ust 304 provides examples of arithmetic operators 320. Standard arithmetic operators 318 include addition, subtraction, multipUcation, and division. Unary expressions 322 take numeric values as their operand and return a single numeric value. Examples Ust 304 provides examples of unary expression 324. The examples include, but are not limited to, log(x) and ln(x). End-users, via a scripting language, may combine one or more functional expression components to form composite or nested functions, referred to as arbitrarily complex functional expressions, for defining input and/or output properties ofdomain objects. For example, stochastic expressions may be nested within other functional expression components to modify an input and/or output property. Returning to example 316 of an inter-object relationship 314, if Harry's age is defined as a uniform random variate between 20 and 30 (i.e., Uniform(20,30)), then SaUy's age represents a composite function that includes an inter-object relationship (because it is dependent upon Harry's age), a stochastic expression (because Harry's age is a uniform random variate between 20 and 30), an arithmetic operator (-), and a numeric expression (3). No special code from the domain object is required. These arbitrarily complex functional expressions are evaluated at runtime using the stochastic simulation framework/engine. V. A Stochastic Simulation Framework/Engine A stochastic simulation framework/engine processes the simulation model and controls the behavior of the input and output properties. The stochastic simulation framework/engine is responsible for making the various components of the present invention work together to process a particular simulation experiment by repeatedly evaluating the behavior of the domain entities over a period of time. FIG. 4 is a flow diagram iUustrating a stochastic simulation framework/engine 400 for implementing an embodiment of the present invention. The stochastic simulation framework/engine 400 is comprised of an initialization phase 402, a processing phase 404, and an output phase 406. Each phase 402-406 of stochastic simulation framework/engine 400 is described in detail with reference to FIGs. 5, 6, and 7, respectively. A. The Initialization Phase Initialization phase 402 of stochastic simulation framework/engine 400 handles aU inter-object relationships and stochastic functions in a single, consistent manner. Initialization phase 402 also handles random variate correlations of object properties. FIG. 5 is a flow diagram illustrating initialization phase 402 of stochastic simulation framework/engine 400. The process begins with step 502, where control immediately passes to step 504. In the present invention, domain entities can refer to and depend on each other in a way that is independent of where the actual target object is located. In fact, a given domain model may have a plurality of objects, each with multiple dependencies on other domain objects in the model. In order to evaluate a domain entity (referred to as domain entity number 1) that references another domain entity (referred to as domain entity number 2), domain entity number 2 must be evaluated first. Referring back to example 316 in FIG. 3, where SaUy's age is Harry's age - 3, Harry's age must be evaluated first before SaUy's age can be evaluated. Thus, prior to evaluating aU of the arbitrarily complex functional expressions within a simulation experiment, the order in which they must be evaluated has to be determined. The present invention automaticaUy determines the order in which each domain entity should be evaluated within the simulation. Referring back to FIG. 5, the present invention automaticaUy generates a dependency graph of domain entities and their relationships to other domain entities having stochastic expressions and inter-object relationship expressions. In step 504, a dependency graph ofdomain entities is generated. The dependency graph Usts aU domain entities in the order in which they must be evaluated during processing phase 404. For example, assuming that Harry's age is equal to a random uniform variate between 20 and 30, and SaUy's age is Harry's age minus 3, Harry's age is calculated first and then SaUy's age is calculated. The dependency graph wiU be: Table 4 Once the dependency graph is generated, control then passes to step 506. The present invention also aUows objects to be correlated with other objects. For example, stock A's price is equal to a uniform variate between 0 and 100 (Uniform (1,100)) and stock B's price is also equal to a uniform variate between 0 and 100. The end-user wants a positive correlation of 75% between the two stocks A and B. Thus, stocks A and B must move higher or lower together. The present invention also provides variance reduction techniques. Correlation and variance reduction techniques are weU known to persons ski ed in the relevant art(s). In step 506, random variate initializations are performed to take into account correlations between domain objects and variance reduction techniques. Control then passes to step 508, where the process ends. B. The Processing Phase The processing phase of simulation framework/engine 400 is responsible for processing a simulation model and updating each object for each period in a run. During the processing phase of the simulation, functional expressions are evaluated in the order in which they appear in the dependency graph. As previously stated, a simulation experiment is processed through aU periods and aU runs over a designated time horizon. FIG. 6 is a flow diagram iUustrating a processing method for stochastic simulation framework/engine 400. The process begins with step 602, where control is immediately passed to step 604. In step 604, processing begins for each run. Control then passes to step 606. In step 606, prior to actuaUy processing a run in the simulation experiment, the simulation is initialized for a new run. Each object initializes itself to its original starting state. Control then passes to step 608. In step 608, processing begins for each period. Control then passes to step 610. In step 610, processing begins for each object. Control then passes to step 612. In step 612, each arbitrarily complex functional expression is evaluated. Each expression is evaluated in the order in which it faUs within the dependency graph. Control then passes to step 614. In step 614, each object is updated at each period of every run. Each object updates its internal state accordingly before the next period is executed. Control then passes back to step 610 for repeating steps 612-614 until every object has been evaluated. Control then passes back to step 608 for repeating steps 610-614 untU every period has been evaluated. Control then passes back to step 604 for repeating steps 606-614 untU every run has been evaluated. Control then passes to step 616, where the process ends. C. The Output Phase The output phase of simulation framework/engine 400 provides a means for tracking the value of properties which have been designated as output properties, and for storing the output property values over the designated periods of the simulation. At the termination of the experiment, the output components generate a set of data structures that may be used to display and analyze the data produced by the experiment. 1. Output Data for Analysis and Display One embodiment of the present invention uses a matrix data structure to display output values. The matrix of output values has as many columns as periods in the current simulation experiment and as many rows as runs. At the termination of the experiment, the value of the property at any given period and run can therefore be retrieved from this matrix for analysis or display. One skiUed in the relevant art(s) would know that other multidimensional output structures could be used without departing from the scope of the present invention. FIG. 7 Ulustrates an exemplary output matrix 700 for an output value of a simulation experiment. The output value is Harry's age at retirement. Harry's age at retirement is a random uniform variate between 50 and 75. The simulation is executed over a time horizon of 2 periods, each period having 10 runs. Output matrix 700 is therefore comprised of two periods 702 displayed in columns 1 and 2 and 10 runs 704 displayed in rows 1 through 10. Each entry 706 in matrix 700 represents Harry's age at retirement for period 702, run 704. In one embodiment of the invention, sparse matrices are used to only allocate memory on an as needed basis. For example, if only the last period's value of a domain entity is to be monitored, memory is only allocated for storing the values for the last period. In another embodiment, aU property outputs are stored in a single repository. In one embodiment of the invention, a simulation output contains one scenario instance for each domain model in the simulation. Each scenario instance contains one property output instance for each domain property whose values were monitored during the simulation experiment. Each property output instance contains the matrix of values generated during the simulation experiment as described in FIG. 7. In an embodiment of the present invention, the output data is structured in such a way that it can be accessed as an n-dimensional space that can be manipulated from any perspective desired. For example, in a 4-dimensional space, each dimension corresponds to the foUowing axes: 1. the domain model; 2. the property; 3. the period index; and 4. the run index. Any specific value can be uniquely identified by specifying aU four axes. Any given vector of values can be identified by specifying any three axes. Any matrix of values can be identified by specifying any two axes. For example, to retrieve the vector of values of a given property for a given period for aU runs, an end-user would specify a scenario, property, and period. To retrieve the matrix of values of aU properties for a given run, an end-user would specify a scenario and run. 2. Time Step Settings The present invention aUows an end-user to define a specific subset of periods in a given simulation. For example, it may be useful to specify that a certain property function should only be evaluated every other period or only in the first period, etc. The present invention provides a special utiUty object caUed a TimeStepSet, to define a set of periods in a given simulation. These objects can be used as filters to determine the periods at which a given domain object or function should be updated or executed. One set of TimeStepSet Objects is Usted in Table 5. Other TimeStepSet Objects that determine the periods at which a given domain object or function should be updated or executed may be added without departing from the scope of the invention. Table 5 3. Derived Output Data The present invention provides the ability to create new output data derived from the original simulation output. This derived output can be treated transparently by outside consumers and is indistinguishable from the original simulation output. The derived output is not calculated during the actual execution of the simulation experiment. Thus, the calculation of derived output data does not impair the performance of the simulation. Moreover, derived output properties can be added after the fact or on an ad-hoc basis by the end-user. This greatly increases the flexibility of the present invention. The foUowing is an exemplary derived output data scenario to illustrate how derived output data may be generated. A simulation experiment produces output data for the properties IBM.price, GM.price, and the cumulative inflation rate. IBM.price represents the price of IBM at the close of each business day. GM.price represents the price of General Motors (GM) at the close of each business day. An end-user is interested in the real price of both IBM and General Motors, which is equivalent to the price of IBM divided by the cumulative inflation rate and the price of GM divided by the cumulative inflation rate, respectively. The present invention provides a mechanism for creating new derived output properties for the real price of both IBM (IBM.realprice) and GM (GM.realprice), where: IBM.realprice = IBM.price / cumulative inflation rate; and GM.realprice = GM.price / cumulative inflation rate. As long as the values of IBM.price, GM.price, and cumulative inflation rate have been saved within memory, these new derived output properties may be generated after the execution of the simulation experiment or on an ad-hoc basis by the end- user. VI. Environment The present invention may be implemented using hardware, software, or a combination thereof and may be implemented in one or more computer systems or other processing systems. In fact, in one embodiment, the invention is directed toward one or more computer systems capable of carrying out the functionaUty described herein. An example implementation of a computer system 800 is shown in FIG. 8. Various embodiments are described in terms of this exemplary computer system 800. After reading this description, it wiU be apparent to a person skilled in the relevant art how to implement the invention using other computer systems and/or computer architectures. The computer system 800 includes one or more processors, such as processor 803. The processor 803 is connected to a communication bus 802. Computer system 800 also includes a main memory 805, preferably random access memory (RAM), and may also include a secondary memory 810. The secondary memory 810 may include, for example, a hard disk drive 812 and/or a removable storage drive 814, representing a floppy disk drive, a magnetic tape drive, an optical disk drive, etc. The removable storage drive 814 reads from and/or writes to a removable storage unit 818 in a weU-known manner. Removable storage unit 818, represents a floppy disk, magnetic tape, optical disk, etc, which is read by and written to by removable storage drive 814. As will be appreciated, the removable storage unit 818 includes a computer usable storage medium having stored therein computer software and/or data. In alternative embodiments, secondary memory 810 may include other similar means for aUowing computer programs or other instructions to be loaded into computer system 800. Such means may include, for example, a removable storage unit 822 and an interface 820. Examples of such may include a program cartridge and cartridge interface (such as that found in video game devices), a removable memory chip (such as an EPROM, or PROM) and associated socket, and other removable storage units 822 and interfaces 820 which aUow software and data to be transferred from the removable storage unit 822 to computer system 800. Computer system 800 may also include a communications interface 824. Communications interface 824 allows software and data to be transferred between computer system 800 and external devices. Examples of communications interface 824 may include a modem, a network interface (such as an Ethernet card), a communications port, a PCMCIA slot and card, a wireless LAN (local area network) interface, etc. Software and data transferred via communications interface 824 are in the form of signals 828 which may be electronic, electromagnetic, optical, or other signals capable of being received by communications interface 824. These signals 828 are provided to communications interface 824 via a communications path (i.e., channel) 826. This channel 826 carries signals 828 and may be implemented using wire or cable, fiber optics, a phone line, a ceUular phone link, a wireless link, and other communications channels. In this document, the term "computer program product" refers to removable storage units 818, 822, and signals 828. These computer program products are means for providing software to computer system 800. The invention is directed to such computer program products. Computer programs (also caUed computer control logic) are stored in main memory 805, and/or secondary memory 810 and/or in computer program products. Computer programs may also be received via communications interface 824. Such computer programs, when executed, enable the computer system 800 to perform the features of the present invention as discussed herein. In particular, the computer programs, when executed, enable the processor 803 to perform the features of the present invention. Accordingly, such computer programs represent controUers of the computer system 800. In an embodiment where the invention is implemented using software, the software may be stored in a computer program product and loaded into computer system 800 using removable storage drive 814, hard drive 812 or communications interface 824. The control logic (software), when executed by the processor 803, causes the processor 803 to perform the functions of the invention as described herein. In another embodiment, the invention is implemented primarily in hardware using, for example, hardware components such as appUcation specific integrated circuits (ASICs). Implementation of hardware state machine(s) so as to perform the functions described herein wiU be apparent to persons skiUed in the relevant art(s). In yet another embodiment, the invention is implemented using a combination of both hardware and software. VII. Conclusion While various embodiments of the present invention have been described above, it should be understood that they have been presented by way of example only, and not limitation. It wiU be understood by those skilled in the art that various changes in form and detaUs may be made therein without departing from the spirit and scope of the invention as defined in the appended claims. Thus, the breadth and scope of the present invention should not be limited by any of the above-described exemplary embodiments, but should be defined only in accordance with the foUowing claims and their equivalents.

Claims: What Is Claimed Is: 1. A method for evaluating a plurality of expressions contained within programming code, each of said expressions having a syntax and a type, comprising the steps of: (a) classifying each of said expressions as one of a deferred expression type and an immediate type, wherein said deferred expression type represents a deferred expression, wherein said deferred expression includes one of a stochastic operand, an object reference operand, a domain function operand, and a deferred expression operand, and wherein said immediate expression type represents an immediate expression, wherein said immediate expression does not include said deferred expression; and (b) determining a result for each of said expressions, wherein the result is a primitive value if the expression is said immediate expression type and the result is said deferred expression if the expression is said deferred expression type, wherein the syntax of each of said expressions is independent of the expression's type. 2. The method of claim 1 , further comprising the step of assigning the result to a left-hand value, said left-hand value being one of a variable and an object property. 3. The method of claim 1, further comprising the step of using the result of each of said expressions to configure a stochastic simulation model, wherein said deferred expressions are used to define input and output properties and are evaluated at runtime. 4. The method of claim 2, wherein a proxy/adapter is used as an intermediary between the result and a target object within a stochastic simulation model to modify said object property in accordance with said deferred expression. 5. The method of claim 1 , wherein step (a) comprises the steps of: (1) parsing the programming code; (2) generating a parse tree having a pluraUty of nodes; and (3) evaluating each of said nodes for classification as one of said immediate expression type and said deferred expression type. 6. The method of claim 5, wherein step (3) comprises the steps of deteirnining whether said node is one of an atomic node and a composite node, wherein said composite node is associated with a composite expression; wherein if said node is said atomic node, determining whether said atomic node comprises one of said immediate expression and said deferred expression; wherein if said node is said composite node, evaluating a pluraUty of child nodes associated with said composite node, wherein if any one of said child nodes is determined to be said deferred expression type, the composite expression is type cast as said deferred expression type. 7. The method of claim3, further comprising the step of determining the behavior of said object properties for the stochastic simulation model over a predeteirnined number of periods, each of said predetermined number of periods having a predetermined number of runs. 8. The method of claim 1, wherein a system function is associated with said deferred expression, and said classifying step further comprises the step of classifying said expression as said deferred expression type when said expression contains at least one system function. 9. The method of claim 8, wherein said system function for creating an object reference is a GetReference function, whereby the GetReference reference function references another object property, and said classifying step further comprises the step of classifying said expression as said deferred expression type when said expression contains at least one GetReference function. 10. The method of claim 1, wherein said domain function operand includes date domain functions and numeric domain functions, and said classifying step further comprises the step of classifying said expression as said deferred expression type when said expression contains one of at least one data domain function and at least one numeric domain function. 11. The method of claim 1 , wherein said stochastic function operand includes random variate functions that return variates drawn from a specific probabihty distribution, and said classifying step further comprises the step of classifying said expression as said deferred expression type when said expression contains at least one random variate function. 12. A systemfor evaluating apluraUty of expressions contained within programming code, each of said expressions having a syntax and a type, comprising: means for classifying each of said expressions as one of a deferred expression type and an immediate type, wherein said deferred expression type represents a deferred expression, wherein said deferred expression includes one of a stochastic operand, an object reference operand, a domain function operand, and a deferred expression operand, and wherein said immediate expression type represents an immediate expression, wherein said immediate expression does not include said deferred expression; and means for determining a result for each of said expressions, wherein the result is a primitive value if the expression is said immediate expression type and the result is said deferred expression if the expression is said deferred expression type, wherein the syntax of each of said expressions is independent of the expression's type. 13. The systemof claim 12, further comprising means for assigning the result to a left-hand value, said left-hand value being one of a variable and an object property. 14. The system of claim 12, further comprising means for using the result of each of said expressions to configure a stochastic simulation model, wherein said deferred expressions are used to define input and output properties and are evaluated at runtime. 15. The system of claim 13, wherein a proxy/adapter is used as an intermediary between the result and a target object within a stochastic simulation model to modify said object property in accordance with said deferred expression. 16. The system of claim 12, wherein said means for classifying each of said expressions comprises: means for parsing the programming code; means for generating a parse tree having a pluraUty of nodes; and means for evaluating each of said nodes for classification as one of said immediate expression type and said deferred expression type. 17. The system of claim 16, wherein said means for evaluating each of said nodes comprises: means for detemώiing whether said node is one of an atomic node and a composite node, wherein said composite node is associated with a composite expression; means for determining whether said atomic node comprises one of said immediate expression and said deferred expression, if said node is said atomic node; and means for evaluating a pluraUty of child nodes associated with said composite node, if said node is said composite node, wherein if any one of said chUd nodes is determined to be said deferred expression type, the composite expression is type cast as said deferred expression type. 18. The system of claim 14, further comprising means for determining the behavior of said object properties for the stochastic simulation model over a predeteirnined number of periods, each of said predetermined number of periods having a predetermined number of runs. 19. The system of claim 1 , wherein a system function is associated with said deferred expression. 20. The system of claim 19, wherein said system function for creating an object reference is a GetReference function, whereby the GetReference reference function references another object property. 21. The system of claim 12, wherein said domain function operand includes date domain functions and numeric domain functions. 22. The system of claim 12, wherein said stochastic function operand includes random variate functions that return variates drawn from a specific probabihty distribution. 23. A computer program product comprising a computer useable medium having computer program logic recorded thereon for enabling a computer to evaluate a plurality of expressions contained within programming code, each of said expressions having a syntax and a type, said computer program logic comprising: means for enabling the computer to classify each of said expressions as one of a deferred expression type and an immediate type, wherein said deferred expression type represents a deferred expression, wherein said deferred expression includes one of a stochastic operand, an object reference operand, a domain function operand, and a deferred expression operand, and wherein said immediate expression type represents an immediate expression, wherein said immediate expression does not include said deferred expression; and means for enabling the computer to determine a result for each of said expressions, wherein the result is a primitive value if the expression is said immediate expression type and the result is said deferred expression if the expression is said deferred expression type, wherein the syntax of each of said expressions is independent of the expression's type. 24. The computer program product of claim 23, further comprising means for enabling the computer to assign the result to a left-hand value, said left- hand value being one of a variable and an object property. 25. The computer program product of claim 23, further comprising means for enabling the computer to use the result of each of said expressions to configure a stochastic simulation model, wherein said deferred expressions are used to define input and output properties and are evaluated at runtime. 26. The computer program product of claim 24, wherein a proxy/adapter is used as an intermediary between the result and a target object within a stochastic simulation model to modify said object property in accordance with said deferred expression. 27. The computer program product of claim 23, wherein said means for enabling the computer to classify each of said expressions comprises: means for enabling the computer to parse the programming code; means for enabling the computer to generate a parse tree having a pluraUty of nodes; and means for enabling the computer to evaluate each of said nodes for classification as one of said immediate expression type and said deferred expression type. 28. The computer program product of claim 27, wherein said means for enabling the computer to evaluate each of said nodes comprises: means for enabling the computer to determine whether said node is one of an atomic node and a composite node, wherein said composite node is associated with a composite expression; means for enabling the computer to determine whether said atomic node comprises one of said immediate expression and said deferred expression, if said node is said atomic node; and means for enabling the computer to evaluate a plurality of child nodes associated with said composite node, if said node is said composite node, wherein if any one of said chud nodes is determined to be said deferred expression type, the composite expression is type cast as said deferred expression type. 29. The computer program product of claim 25, further comprising means for enabling the computer to determine the behavior of said object properties for the stochastic simulation model over a predetermined number of periods, each of said predetermined number of periods having a predetermined number of runs. 30. The computer program product of claim 23, wherein a system function is associated with said deferred expression, and said means for enabling the computer to classify each of said expressions further comprises means for enabling the computer to classify said expression as said deferred expression type when said expression contains at least one system function. 31. The computer program product of claim 30, wherein said system function for creating an object reference is a GetReference function, whereby the GetReference reference function references another object property, and said means for enabling the computer to classify each of said expressions further comprises means for enabling the computer to classify said expression as said deferred expression type when said expression contains at least one GetReference function. 32. The computer program product of claim 23, wherein said domain function operand includes date domain functions and numeric domain functions, and said means for enabling the computer to classify each of said expressions further comprises means for enabling the computer to classify said expression as said deferred expression type when said expression contains one of at least one data domain function and at least one numeric domain function. 33. The computer program product of claim 23, wherein said stochastic function operand includes random variate functions that return variates drawn from a specific probabihty distribution, and said means for enabling the computer to classify each of said expressions further comprises means for enabling the computer to classify said expression as said deferred expression type when said expression contains at least one random variate function.

Inventors: PENN DEREK CHARLES, PENN, DEREK, CHARLES
Applicants: MPOWER COM INC, MPOWER.COM, INC.
Application year: 2000
Main classification: G06F17
IPC codes: G06F9