The Design drop down menu in GraphSynth provides functions to test and synthesize new graphs from the grammar rule sets described in earlier pages (graphs, grammars, rule sets). Firstly, the pane has commands to set the active seed and the first three active rule sets. These can also be set in the GraphSynthSettings.config file, through the settings drop-down under File,  so that they are

established on beginning the program (this proves to be a great time-saver!). The GUI will only allow one to assign the first three rule sets; however, if you want more, you will need to make the assignments in GraphSynthSettings.config or even during Program.runSearchProcess().

This is followed by the “Run Search Process” item, which is the main entry point for a search process that one may implement (more on this in a second). The bottom three items allow for the testing or rules, rule sets, and seeds. The “RecognizeUser ChooseApply” item invokes a dialog to choose the rules by hand. Within the options presented in that dialog, one can double-click a location to see what subgraph the rule is applying to. The “RecognizeRandom ChooseApply” item will continuously call random options on the seed until the process stops (stops by encountering a “Stop” in one of the 5 generation exits). Additionally the gray box that is labeled “#steps” can be changed to a set a integers that will be assigned to the generation cycle limits for each rule set (see int[] maxNumOfCalls). For example by replacing “#steps” with “4, 5 12”, the generation process will be invoked with set maxNumOfCalls to [4, 5, 12] (most common separators such as comma and space can be used).

Search Process Controller

When any of these lower items are clicked, a small controller window appears (often it is hidden for user and random testing). The controller allows one to change how the search process is executing. The snapshot to the right was taken while the process was executing. Notice that the “Play” button is disabled since the process is already in operation. The process can be paused, stopped , or aborted from this point. Pressing the “Stop” button will send a request to the process. This is to allow the process to end and still retain useful results. It will not always function if the search process is using the computational resources elsewhere. Thus as a last resort, the “Abort” button will attempt to kill the thread that the search process is running on.

The Search Process Controller allows on to dynamically control aspects of the search process. It is inspired by the transport bar of computer music applications.
Figure 2: The Search Process Controller allows on to dynamically control aspects of the search process. It is inspired by the transport bar of computer music applications.

In addition to these button, there are three displays that show pertinent information about the process. The time is implemented as part of the controller; it ‘pings’ the thread the search process is on in specific intervals. The rate at which it pings is based on the verbosity setting (described below). The top two displays shown the iterations and a miscellaneous field. These are set in the search process by setting the iteration and miscObject properties of the main Program.cs. At the bottom one can set the priority and verbosity for the search process. The computational processes in GraphSynth run on separate threads, and a thread can be given a priority over other threads. Set this high if you want to speed up the process but do not mind it slowly down other processes including the main thread (thus making GraphSynth appear as if it has locked up!). The verbosity is a highly useful UI that allows the user to adjust how much text is being output by the process. One is encouraged to implement many SearchIO.output statements in a search process to provide information about the progress of a long operation. However, such commands can greatly slow down the processing. By dynamically setting how verbose we want the search process to be, we can get the information we want when we need it.

The SearchIO.output function can be invoked with an object (usually a string) to print and a verbosity limit, which is an integer from 0 to 4. If the verbosity limit is set to 0, then the object will be printed all the time even for verbosity set to “lowest.” If it is set to 4, then it will only print when verbosity is set to “highest.”

Writing a Custom Search Process

Figure 3: The Representation is accomplished by the seed, and rule set; and the Generation by the R->C->A cycle. What remains in the search process is some method to evaluate the quality of candidate graphs (classes and functions to be stored in 3.Evaluation), and methods to learn from these results to improve the next generation (classes and functions to be stored in 4.Guidance).  
Figure 3: The Representation is accomplished by the seed, and rule set; and the Generation by the RCA cycle. What remains in the search process is some method to evaluate the quality of candidate graphs (classes and functions to be stored in Evaluation), and methods to learn from these results to improve the next generation (classes and functions to be stored in Guidance).  

As discussed in the introduction, one may want to automate the creation of candidate solutions. This custom code can be written in under the function Program.runSearchProcess() in the file searchProcess.cs. In fact, any C# code can be written here. One may want to invoke functions or classes from another Visual Studio project, or invoke additionally GUI forms.   In the example code, the swirl seed and rule set are loaded (which encapsulates the representation) , and we create the generate, evaluate and guide methods for the search process: 

Generation.randomChoose GenerationApproach
      = new Generation.randomChoose
        
(Program.seed, Program.rulesets,
          new int[1] { 50 }, false);
Evaluation.EvaluateSwirls EvaluationApproach
      = new Evaluation.EvaluateSwirls(); Guidance.DoNothingButDisplay GuidanceApproach
      = newGuidance.DoNothingButDisplay();

The initiation of these routines is done at the begin-
ning of the process in an attempt to make GraphSynth
modular for a wide range of applications. Throughout the
search process, one can take advantage of a number of fields
in the Program and SearchIO cclasses. These are listed below for your reference:

Program.settings : The class globalSettings is in the Application_UI_and_Search directory. These values are loaded in from the GraphSynthSettings.config file.

Program.mainForm :   this is the reference to the mainForm - the top/largest GraphSynth Window. It may be difficult to reference objects from a search process, as Visual Studio will view this as a cross threading operation (which apparently is a bad thing. See the SafeInvokeHelper class in RepresenationXMLandIO for a solution)

Program.seed : This is the seed graph (of class designGraph) indicated by the "Set Active as Seed" drop-down on the Design menu item or through the settings. It represents the top of the search tree.

Program.rulesets : An array of class ruleSet of length Program.settings.numOfRuleSets. These can be set in the same manner as Program.seed.

(The following can be called from either static class SearchIO or Program. Anything written in the searchProcess.cs file will likely already be in the Program class and the property may be reached without specifying the class. However, if you are in another project (i.e. within Evaluate) you will need to use SearchIO prefix, as you will not be able to see the Program class.)

SearchIO.output or Program.output : Use the various overloads of this statement to print messages to the sidebar text in the main form of GraphSynth. While a verbosityLimit is not mandatory, it is a "nice to have", take the time to put something here.

SearchIO.processNum or Program.processNum : A read-only integer that simply lists what search process one is currently on. Not really that useful, during search process. The integer simply increments for each new search started in a single run of GraphSynth.

SearchIO.terminateRequest or Program.terminateRequest : A read-only Boolean that indicates true when the user has clicked the stop button on the SearchProcessController.

SearchIO.timeInterval or Program.timeInterval : A read-only TimeSpan (a fundamental C# class)object that indicates how long the search has been going on.

SearchIO.iteration or Program.iteration : The number of iterations that have occured in the process. It can be read or set using this. The SearchProcessController will reflect the value in the first box. NOTE: Setting this value through Program.iteration causes an immediate update of the SearchProcessController. This is either a good thing or a bad thing. You will see immediately when the iteration changes, but if it is happening a lot then it may slow down your process.

SearchIO.miscObject or Program.miscObject: Any object that the researcher wants to store. It will be converted to a string and shown in the SearchProcessController.  NOTE: Setting this value through Program.miscObject causes an immediate update of the SearchProcessController. This is either a good thing or a bad thing. You will see immediately when the iteration changes, but if it is happening a lot then it may slow down your process.

Last edited Feb 8, 2014 at 5:54 PM by mattica, version 1