uk.ac.ucl.che.esf.base
Class EGO

java.lang.Object
  extended by uk.ac.ucl.che.esf.base.EGO
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, uk.ac.ucl.che.esf.util.Sort.Sortable

public class EGO
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable, uk.ac.ucl.che.esf.util.Sort.Sortable

*** full log entries below Revision 15.11 2001/01/26 15:38:35 ucecesf Minor tweaks and addition of generate command for flowsheets Revision 15.10 2000/10/13 10:20:07 ucecesf - Full implementation of QT visualization tool including stream splitting - Better interface to heat exchangers - minor clean-up of unit variable handling Revision 15.9 2000/06/26 15:17:22 ucecesf - added HEN and cost panels and zoom capabilities to Q delta T viewer - implemented generic GA and SA solvers Revision 15.8 2000/05/30 17:04:45 ucecesf - new Q delta T visualization tool - improved UI including ability to load most recent serialized objects Revision 15.7 2000/05/05 10:25:32 ucecesf Minor fixes to new unit variable text input and improved output for virtual heat exchange mode. Revision 15.6 2000/04/21 11:08:16 ucecesf - improved efficiency for heat links catching single link infeasibilities - added ability to re-define unit variables through user interface Revision 15.5 2000/03/28 09:49:42 ucecesf Improved user interface including GUI and HTML reports Revision 15.4 2000/01/06 15:36:49 ucecesf Version for dynamic synthesis paper submission Revision 15.3 1999/12/15 14:44:06 ucecesf Working SMP version as used for ESCAPE-10 paper. Revision 15.2 1999/11/26 17:07:14 ucecesf Added constraints using dynamic Java scripting. Revision 15.1 1999/11/25 14:19:35 ucecesf Minor bug fixes and improved output generation. Revision 15.0 1999/09/09 15:16:32 ucecesf Cleanup in preparation for standard release Revision 14.11 1999/09/01 11:50:42 ucecesf SMP version (almost) working Revision 14.10 1999/05/18 16:36:28 ucecesf - Implementation of auto mVHL parameter selection - minor tweaks to UI and dynamic profile approach Revision 14.9 1999/03/11 14:55:21 ucecesf - redesign of dynamic profile approach - change to stream input format (phases defined separately) - improved handling of flowsheets with recycle structures Revision 14.8 1999/02/23 11:33:15 ucecesf + Reintroduction of IDP (iterative DP) method for recycles + Addition of purge unit for quick 'n' dirty IDP Revision 14.7 1999/02/11 11:20:41 ucecesf - improved statistics collection, particularly with respect to unit models - added new unit variables (of array types mostly) - added simple user interface to Vexpr calculator Revision 14.6 1999/01/20 11:08:26 ucecesf + fixed bug in GA regarding chromosome copies + introduced global settings for ESF package Revision 14.5 1999/01/04 12:08:06 ucecesf - added improved statistics collection for whole ESF package - improved the Vexpr expression calculator (moved to JavaCC parser) - fixed bug in discrete GA flowsheet optimization - improved efficiency for solution comparison with multiple criteria - improved limit qualifier use for multiple uses Revision 14.4 1998/10/09 11:19:51 ucecesf Clipboard functionality added to graphical interface. Revision 14.3 1998/10/06 13:55:08 ucecesf Improved unit variable handling and unit design cache. Revision 14.2 1998/09/21 16:39:22 ucecesf More logical approach to synthesis problem definition and global data handling. Revision 14.1 1998/09/16 16:49:29 ucecesf Full implementation of multicriteria optimization Revision 2.6 1998/06/29 10:05:46 ucecesf Major speed improvement in search procedure due to more efficient object creation and use. Revision 2.5 1998/06/22 15:00:26 ucecesf First implementation of multi-criteria discrete programming approach. Revision 2.4 1998/06/18 14:39:19 ucecesf - improved statistics - extended remote file access - preliminary HTR data analysis Revision 2.3 1998/05/21 09:43:05 ucecesf - Improvements to persistent object handling. - Addition of concept of interesting structures for N-best diversity Revision 2.2 1998/05/07 12:21:55 ucecesf Fixes to persistent object handling to cater for multiple copies of an object and minor fixes to GUI. Revision 2.1 1998/05/06 17:29:38 ucecesf Better and more consistent persistent object handling Revision 1.20 1998/04/30 13:23:02 ucecesf - move to better persistent object handling - alternative GA synthesis selection procedures - improved tuning procedure in GA-HEN - user control of GA-HEN parameters from GA Flowsheet objects Revision 1.19 1998/04/03 15:20:06 ucecesf - minor fixes throughout - improvements to dynamic modelling and discretization - additions to text based user interface for component access Revision 1.18 1998/03/04 14:57:35 ucecesf - updated Copyright and error messages - new user specifications and defaults for dynamic distillation column - implemented discretization for dynamic streams - streams initialized when created - changed key string for Phase objects (more terse) and added new access methods - added UserInput unit variable type - added self-contained Tplot 2d graph method Revision 1.17 1998/02/25 17:15:49 ucecesf - Added top flow control to the dynamic distillation unit. - Added user given unit definitions to the parser: "set" top level command with "define" sub-command. - Search can terminate at leaf nodes without considering other units: "set leafprune true" in PS_Problem. - Method to add two arrays implemented. Revision 1.16 1998/02/19 11:45:39 ucecesf Added new statistics and changed copyright messages Revision 1.15 1998/02/19 10:42:34 ucecesf Incorporation of dynamic streams and distillation unit into search procedure. Revision 1.14 1998/02/09 15:32:01 ucecesf Minor fixes to physical properties routines to guarantee convergence in dynamic simulation. Revision 1.13 1998/02/06 17:03:17 ucecesf First version (almost) working with dynamic distillation unit. Changes include physprops and nonlinear solvers as well as main unit. Revision 1.12 1998/02/03 11:45:27 ucecesf + Addition of StreamArray unit variable type and changes to product identification codes + Further development of the GA Synthesis procedure + Minor changes to GUI aspects Revision 1.11 1998/01/21 11:20:05 ucecesf + Graph node and edge contents must now be EGO objects. + Improved "demo" mode for synthesis (Debug==0) Revision 1.10 1998/01/15 14:34:00 ucecesf + Fixed bug in HPS synthesis approach with accumulation of status value + Fixed flowsheet generation for incomplete synthesis solutions Revision 1.9 1998/01/14 16:15:28 ucecesf + Added control over definition of similar solutions for both normal synthesis and hierarchical synthesis. + redefined debug=0 to be demo level and -1 for default level. Revision 1.8 1998/01/13 10:42:26 ucecesf Preliminary work on GA Synthesis procedure Fixed bug in N-best solution generation Revision 1.7 1997/12/18 14:29:14 ucecesf Added feasibility pruning to qualifier allocation table cycling.

See Also:
Serialized Form

Field Summary
protected  ISODate date
          Date object is only created if explicitly requested using the setDate method below (in order to avoid a performance hit when creating a multitude of objects, such as in automated process synthesis).
static java.lang.String DEFAULT_OUTPUT_PROMPT
          Many objects will want to output to the console when requested.
protected  boolean flush
          When an error is found in an input file, the object which was responsible for parsing the line in error may request that the rest of the input be flushed as it will not be of any use.
protected  boolean initialized
          Has the object been initialized?
protected  boolean inReport
          When generating a report for an object, this flag will be set to true, allowing the object to behave differently than in a normal print command.
protected  uk.ac.ucl.che.esf.util.expr.CompiledExpression model
          Every EGO object model has a "model" which is an expression object.
protected  uk.ac.ucl.che.esf.util.expr.Equations modelEquations
          The original equations which form the model before they are converted to compiled form for efficiency.
protected  java.lang.String name
          The name of the object is used by the user interface to allow the user to distinguish between objects.
static java.lang.Error NOT_IMPLEMENTED_EXCEPTION
          During code development, some methods in some classes might not be fully implemented.
protected  java.lang.String parent
          When objects are made persistent, we have the concept of history where an object may have been created by taking an existing object and modifying it.
protected  java.lang.String type
          The type of the object is used to classify the different objects in the system.
 uk.ac.ucl.che.esf.util.expr.Variables variables
          Variables for use by the model.
 
Constructor Summary
EGO()
          Base constructor does nothing much except collect statistics
EGO(java.lang.String name)
          The only real content of an EGO object is the name of the object.
 
Method Summary
 java.lang.Object clone()
          Provide public access to the clone method so that we can make copies of EGO objects easily.
protected  Method[] combineMethods(Method[] m1, Method[] m2)
          Combine two sets of methods
 int compareTo(uk.ac.ucl.che.esf.util.Sort.Sortable o)
          Compare two EGO objects lexicographically (i.e.
 uk.ac.ucl.che.esf.util.RealVector evaluateModel()
          Evaluate the model, assuming there is one to evaluate.
protected  void generateSaveOutput(java.io.PrintWriter pw)
          The save method uses this method to actually generate the information for output in the form suitable for input by the ESF package.
 java.lang.String getDate()
          The date of the object can be requested.
 Method[] getMethods()
          Each object in the EGO hierarchy has a set of exposed methods suitable for use directly by the user of a text or graphical interface.
 java.lang.String getName()
          Retrieve the name of the object.
 java.lang.String getParent()
          Persistent versions of EGO objects have a history associated with them.
 java.util.Vector getReferencedObjects()
          Deprecated.  
 java.lang.String getType()
          Associated with each EGO object is a "type".
 void initialize()
          All EGO objects provide an initialization method.
static void main(java.lang.String[] args)
          Simple test method
 void parse(uk.ac.ucl.che.esf.ui.Parser parser)
          Parse textual input.
protected  boolean parseLine(java.lang.String[] line, uk.ac.ucl.che.esf.ui.Parser parser)
          Parse a line of input.
 void prepareForEditing()
          The text based interface allows objects to be defined fully and then revisited later.
protected  void prepareSaveOutput(java.io.PrintWriter pw)
          The save command gives the subclass a chance to prepare itself to generate the output text.
 void print()
          Display contents of object on stdout.
 void print(java.io.PrintWriter pw)
          Display contents of object onto specified Writer with no prompt string
 void print(java.io.PrintWriter pw, java.lang.String prompt)
          Display contents of object on the given print writer object.
 void print(java.lang.String prompt)
          Display contents of object on stdout with given prompt
static void printIntroductionMessage()
          Output an intro message which includes the version ID
static void printSystemInfo()
          Output some information about the system.
 void report(java.io.PrintWriter pw)
           Generate an HTML report for the object.
 void save(java.io.PrintWriter pw)
          Save the object in a form suitable for input back into the ESF system.
 void save(java.lang.String filename)
          Alternative interface for saving objects in text input form.
 void setDate()
          Set the date of the object.
static void setDebug(boolean d)
          Set the debug boolean to either true or false.
 void setName(java.lang.String name)
          Set the name of the object.
 void show(java.io.PrintWriter pw, java.lang.String prompt)
          This method is used to display information which is somewhat independent of the actual instance of an object.
 java.lang.String toHTML()
          Generate HTML Applet code for object
 java.lang.String toString()
          Generic string representation of the object consisting of the name and the class.
 void updateHistory(java.lang.String parent)
          Link the object up with the previous version of the object stored in external storage.
protected  void usage()
          Display commands available for this object.
 void view()
          GUI Method for viewing the object.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_OUTPUT_PROMPT

public static final java.lang.String DEFAULT_OUTPUT_PROMPT
Many objects will want to output to the console when requested. For convenience (to make things look pretty), there is a default output leader which should be used. This default is defined so that the ESF leader used by lines showing new class loads and error messages will stand out.

See Also:
Constant Field Values

flush

protected boolean flush
When an error is found in an input file, the object which was responsible for parsing the line in error may request that the rest of the input be flushed as it will not be of any use. This flag controls that behaviour within the parse method.


inReport

protected boolean inReport
When generating a report for an object, this flag will be set to true, allowing the object to behave differently than in a normal print command. See the report method for an example.


model

protected transient uk.ac.ucl.che.esf.util.expr.CompiledExpression model
Every EGO object model has a "model" which is an expression object. This model may be evaluated at any time using the evaluate method. Most objects will not need this but enough do that it eventually became worth my while defining this within the EGO object. This actual datum is the compiled version; the original equations are in the next variable.


modelEquations

protected uk.ac.ucl.che.esf.util.expr.Equations modelEquations
The original equations which form the model before they are converted to compiled form for efficiency.


name

protected java.lang.String name
The name of the object is used by the user interface to allow the user to distinguish between objects.


NOT_IMPLEMENTED_EXCEPTION

public static final java.lang.Error NOT_IMPLEMENTED_EXCEPTION
During code development, some methods in some classes might not be fully implemented. If these methods are invoked, the system should quite immediately with an appropriate message.


type

protected java.lang.String type
The type of the object is used to classify the different objects in the system. An example is to determine the icon to use in a graphical interface.


variables

public uk.ac.ucl.che.esf.util.expr.Variables variables
Variables for use by the model.


date

protected ISODate date
Date object is only created if explicitly requested using the setDate method below (in order to avoid a performance hit when creating a multitude of objects, such as in automated process synthesis).


initialized

protected boolean initialized
Has the object been initialized?


parent

protected java.lang.String parent
When objects are made persistent, we have the concept of history where an object may have been created by taking an existing object and modifying it. This field is a link to the actual persistent instance of the parent object that led to this current instance.

Constructor Detail

EGO

public EGO()
Base constructor does nothing much except collect statistics


EGO

public EGO(java.lang.String name)
The only real content of an EGO object is the name of the object. This constructor allows one to provide that name directly.

Method Detail

clone

public java.lang.Object clone()
Provide public access to the clone method so that we can make copies of EGO objects easily.

Overrides:
clone in class java.lang.Object

combineMethods

protected final Method[] combineMethods(Method[] m1,
                                        Method[] m2)
Combine two sets of methods


compareTo

public int compareTo(uk.ac.ucl.che.esf.util.Sort.Sortable o)
Compare two EGO objects lexicographically (i.e. based on the names)

Specified by:
compareTo in interface uk.ac.ucl.che.esf.util.Sort.Sortable

evaluateModel

public uk.ac.ucl.che.esf.util.RealVector evaluateModel()
Evaluate the model, assuming there is one to evaluate.

Returns:
result of the model evaluation if one to evaluate; null otherwise.

generateSaveOutput

protected void generateSaveOutput(java.io.PrintWriter pw)
The save method uses this method to actually generate the information for output in the form suitable for input by the ESF package.


getDate

public java.lang.String getDate()
The date of the object can be requested. This date is based on when the setDate method was called. If the date has not yet been initialized, it is done so here. Note: The date does not correspond to when the object instance was created but, typically, when the object is saved in external storage (for persistence).


getParent

public java.lang.String getParent()
Persistent versions of EGO objects have a history associated with them. This method returns the name of persistent object from which this particular object was derived.


getReferencedObjects

public java.util.Vector getReferencedObjects()
Deprecated. 

When objects are read in from files, it is often useful to update local copies of referenced objects so that all references are consistent. This method should return a list of objects referenced by the current object so that such a consistent environment can be created by whatever tool is used to manipulated EGO objects. This method used to be used by the graphical interface but we have decided to concentrate on functionality rather than prettiness so the main interface is now textual. Therefore, this method is not really required.

Returns:
list (in a Vector) of objects referenced by this one

getType

public java.lang.String getType()
Associated with each EGO object is a "type". This can be anything. However, the type is used by the graphical tools to associated an Icon with the object so careful use of the type should be made. The default is "ego" as all objects in the ESF package are EGO objects.

Returns:
type of object in the ESF hierarchy

getMethods

public Method[] getMethods()
Each object in the EGO hierarchy has a set of exposed methods suitable for use directly by the user of a text or graphical interface. Although one could use the Java Beans approach, I don't have access to a good Bean tool so I am currently faking this using this method.

Returns:
Array of Method objects describing exposed methods.
See Also:
Method

getName

public java.lang.String getName()
Retrieve the name of the object.

Returns:
Name of the object.

initialize

public void initialize()
                throws java.lang.Exception
All EGO objects provide an initialization method. By default, this method does nothing. It is expected that the init method will be called either directly or by the text based interface when the object definition is finished.

Throws:
java.lang.Exception - Type of exception thrown depends on subclass.

parse

public void parse(uk.ac.ucl.che.esf.ui.Parser parser)
Parse textual input. Each line is read in and sent to the parseLine method which is class specific. When the full object definition has been parsed and processed, the initialize method will be invoked. This may throw an exception which is caught here.


parseLine

protected boolean parseLine(java.lang.String[] line,
                            uk.ac.ucl.che.esf.ui.Parser parser)
Parse a line of input. If the command is not understood, it should be passed up the class hierarchy (ending up here...). Commands available for this mother of all superclasses are given below.
Command Arguments Description
end The object has been fully defined. Input processing now returns to the main input parser.
print Output a description of the object. This will typically be overridden by the subclasses but the base class outputs just the generic information available to all EGO objects.
xml S

Output state of object in XML form to file given. This uses the JSX package (see freshmeat for recent versions). WarningNo error checking is done to ensure that the file does not already exist.

? S Give some basic help information.
In the table, O means the name of an object is expected, I an integer value or expression, R a real number value or expression, and S a string. Expressions should be quote using double quotes.

Returns:
true if end command is found, false otherwise

prepareForEditing

public void prepareForEditing()
The text based interface allows objects to be defined fully and then revisited later. The initial definition will have invoked the initialize() method. In a subsequent visit to the object, using the edit command, it may be necessary to re-initialize. This method allows an instance to prepare itself for further definition.


prepareSaveOutput

protected void prepareSaveOutput(java.io.PrintWriter pw)
The save command gives the subclass a chance to prepare itself to generate the output text.


print

public final void print()
Display contents of object on stdout.


print

public void print(java.io.PrintWriter pw)
Display contents of object onto specified Writer with no prompt string


print

public final void print(java.lang.String prompt)
Display contents of object on stdout with given prompt


print

public void print(java.io.PrintWriter pw,
                  java.lang.String prompt)
Display contents of object on the given print writer object.


printIntroductionMessage

public static void printIntroductionMessage()
Output an intro message which includes the version ID


printSystemInfo

public static void printSystemInfo()
Output some information about the system.


report

public void report(java.io.PrintWriter pw)

Generate an HTML report for the object. the default procedure is to simply generate the standard output within the pre-formatted HTML directive. Note that the HTML generated is expected to correspond to a row in a table.

The inReport boolean variable is set to indicate that this object is the target of a report command. This allows objects to print out, for instance, global data without these data being generated for all objects that may include this type of object. for instance, the esf.fish.units.ps.Phase object defines the granularity of component flows. However, Phase objects are found in Stream objects and it would be silly to have all Stream objects report this information. Therefore, only a Phase object reporting directly will generate this information.


save

public final void save(java.lang.String filename)
Alternative interface for saving objects in text input form. This version is given the name of a file which is openned for writing and then passed to the actual save method.


save

public final void save(java.io.PrintWriter pw)
Save the object in a form suitable for input back into the ESF system. The core of the method is actually the generateSaveOutput method. One other method is the prepareSaveOutput which is called before the generateSaveOutput method and before anything is output for this object. The save method can not be overridden.


setDate

public void setDate()
Set the date of the object. This is only done if explicitly asked for so as to minimize the overhead in object creation when things like streams and heat transfer requests are used in the synthesis procedure.


setDebug

public static final void setDebug(boolean d)
Set the debug boolean to either true or false.


setName

public void setName(java.lang.String name)
Set the name of the object. This is used by any user interfaces to allow the user to manipulate objects by a user specified handle.

Parameters:
name - Name to associated with the object.

show

public void show(java.io.PrintWriter pw,
                 java.lang.String prompt)
This method is used to display information which is somewhat independent of the actual instance of an object. This includes class global data as well as specific data for a set of instances. The print method is used to display instance specific details.


usage

protected void usage()
Display commands available for this object. This method is invoked by the ? or help commands in the text based interface.


toHTML

public java.lang.String toHTML()
Generate HTML Applet code for object


toString

public java.lang.String toString()
Generic string representation of the object consisting of the name and the class.

Overrides:
toString in class java.lang.Object

updateHistory

public final void updateHistory(java.lang.String parent)
Link the object up with the previous version of the object stored in external storage.


view

public void view()
GUI Method for viewing the object. Should bring up its own window and should really provide little in the way of modification etc to the object.


main

public static void main(java.lang.String[] args)
Simple test method