public class FrevoMain
extends java.lang.Object
Components are placed within 4 main categories: Problems, Methods, Representations, Rankings. Problems are further sorted into multi and single problems.
Problem: Problems are encapsulations of optimization tasks, typically
including an agent-based simulation tool. The controller of each agent is
received in a form of an AbstractRepresentation
.
Method: Methods are optimization algorithms meant to iteratively
improve a set of candidate solutions. Furthermore, they are responsible in
loading and saving these candidates.
Representation: These classes are models of agent controllers
considered as candidate solutions. These controllers implement some kind of
mutation or recombination operators in order to be optimized by the
respective method.
Ranking: Rankings are used to sort a list of candidates in a
decreasing order of fitness. AbstractSingleProblem
s can only use the
AbsoluteRanking
while AbstractMultiProblem
s can use various
more sophisticated algorithms.
Modifier and Type | Class and Description |
---|---|
static class |
FrevoMain.KeywordCategory
This class is a container for a category used for sorting different
components.
|
static class |
FrevoMain.XMLFileFilter
FileFilter class that returns only .xml files.
|
Modifier and Type | Field and Description |
---|---|
static int[] |
componentBrowserParameters
Indicates the size of the ComponentBrowser window
|
static int |
DEBUGLEVEL
Indicates the current debug level
|
static java.lang.String |
FREVO_PACKAGE_EXTENSION
File extension for FREVO component package files
|
static boolean |
FREVO_REDIRECTCONSOLE_TO_FILE
If true console output will be written directly to a file.
|
static java.lang.String |
FREVO_RESULT_EXTENSION
File extension for FREVO result files
|
static FileType |
FREVO_RESULT_FILE_TYPE
File type for FREVO results.
|
static java.lang.String |
FREVO_SESSION_EXTENSION
File extension for FREVO session files
|
static FileType |
FREVO_SESSION_FILE_TYPE
File type for FREVO sessions.
|
static boolean |
isLaunchable
Is true if all necessary elements are loaded and the optimization method
can be started.
|
static boolean |
isRunning
Indicates if a method is currently running or not.
|
static int[] |
mainWindowParameters
Indicates the size of the main window
|
Constructor and Description |
---|
FrevoMain() |
Modifier and Type | Method and Description |
---|---|
static void |
addStatistics(StatKeeper statkeeper)
Adds the given
StatKeeper object to FREVO. |
static boolean |
checkState()
Returns true if all required types of components (problem, method,
representation, ranking) are selected.
|
static boolean |
checkType(XMLFieldType type,
java.lang.String value)
Checks if the value properly conforms with the given property type.
|
static void |
deleteComponent(ComponentXMLData cdata)
Removes the component from the installed components.
|
static void |
eraseStatistics()
Removes all previously added
StatKeeper objects from FREVO. |
static void |
evaluateCandidates(java.util.ArrayList<AbstractRepresentation> candidates,
ProblemXMLData problemData,
java.util.Hashtable<java.lang.String,XMLFieldEntry> properties,
long seed)
Runs a single evaluation session on the provided candidates with the
given problem configuration.
|
static void |
exportComponent(ComponentXMLData component,
java.io.File savefile,
boolean addsources)
Exports the selected component into the given file.
|
static java.lang.String |
getActiveDirectory()
Returns the current active directory used when FREVO was launched.
|
static java.util.ArrayList<FrevoMain.KeywordCategory> |
getCategories(ComponentType ctype)
Returns the corresponding category of keywords to the given component
type.
|
static ComponentXMLData |
getComponent(ComponentType ctype,
java.lang.String componentName)
Returns the data of the component with the given name or
null if not found. |
static java.lang.String |
getComponentDirectory(ComponentType componentType)
Returns the absolute path to the base component directory ending
with a file separator
|
static java.util.HashMap<java.lang.String,ComponentXMLData> |
getComponentList(ComponentType componentType)
Returns a list of components of the given type.
|
static java.lang.String |
getComponentTypeAsString(ComponentType ctype)
Returns a human readable name of the given component type.
|
static int |
getCurrentRun()
Returns the currently active simulation run.
|
static java.lang.String |
getCustomName()
Returns the custom name of the current simulation run.
|
static java.lang.String |
getExtension(java.io.File file)
Returns the extension of the given
File . |
static java.lang.String |
getInstallDirectory()
Returns the directory where FREVO is installed.
|
static FrevoWindow |
getMainWindow()
Returns the instance of the main GUI of FREVO.
|
static java.lang.String |
getMajorVersion()
Returns the major version of FREVO in a
String format. |
static java.lang.String |
getMinorVersion()
Returns the minor version of FREVO in a
String format. |
static int |
getNumberOfSimulationRuns()
Returns the number of simulation runs scheduled.
|
static int |
getNumberofStatistics(boolean skipInvisible)
Returns the number of
StatKeeper objects currently loaded in
FREVO. |
static java.lang.String[] |
getParameters()
Returns the FREVO startup parameters.
|
static AbstractRepresentation |
getRepresentation(java.io.File loadfile,
int rank)
Returns the representation at the given rank loaded from an results XML
file.
|
static long |
getSeed()
Returns the seed of the simulation.
|
static ComponentXMLData |
getSelectedComponent(ComponentType ctype)
Returns the selected component of the given type.
|
static StatKeeper |
getStatistics(int index,
boolean skipInvisible)
Returns the
StatKeeper element with the given index. |
static void |
importComponent(java.io.File importfile)
Imports a component packaged in the FREVO package format (zcp).
|
static boolean |
isFrevoWithGraphics()
Returns true if FREVO is launched with GUI enabled.
|
static boolean |
isStatKeeperLoaded(StatKeeper statkeeper)
Returns
true if this StatKeeper object is
currently loaded by FREVO. |
static org.dom4j.Document |
loadSession(java.io.File loadFile)
Loads the give session file to FREVO.
|
static java.io.File |
loadSystemIndependentFile(java.lang.String filepath)
Creates a new
File instance by converting the given pathname
string into an abstract pathname. |
static void |
main(java.lang.String[] args)
The main function for starting FREVO.
|
static ComponentXMLData |
readIComponentFromXml(java.io.File file,
ComponentType ctype,
boolean validateXML)
Loads the class with all properties and requirements stored in the
appropriate XML file.
|
static void |
reLoadComponents()
Reloads all components from the XML files.
|
static void |
reset()
Resets FREVO to its initial state without reloading the components.
|
static void |
runSimulation(java.lang.String outputname)
Starts a simulation with the given name and starting seed.
|
static void |
saveResult(java.lang.String fileName,
org.dom4j.Element representationRootElement,
long usedSeed)
Starts a saving procedure calling the method's own saveResults function.
|
static void |
saveSettings()
Saves FREVO settings to the configuration file.
|
static void |
setCurrentRun(int currentrun)
Sets the active simulation run to the given number.
|
static void |
setCustomName(java.lang.String customName)
Sets the custom name of the active simulation to the given
String . |
static void |
setLoadingProgress(float progress)
Sets the progress of any results or session file loading operation.
|
static void |
setNumberOfSimulationRuns(int maxRun)
Sets the number of simulation runs to the given value.
|
static void |
setSeed(long seed)
Sets the current seed of the simulation to the given value.
|
static void |
setSelectedComponent(ComponentType ctype,
ComponentXMLData cdata)
Selects the given component of the given type.
|
static void |
writeStatisticsToDisk()
Saves all statistics to the default directory (/Results/session)
|
static void |
writeStatisticsToDisk(java.lang.String pathToSaveDirectory)
Saves the statistics data to the target directory.
|
public static int DEBUGLEVEL
public static final java.lang.String FREVO_SESSION_EXTENSION
public static final FileType FREVO_SESSION_FILE_TYPE
public static final java.lang.String FREVO_RESULT_EXTENSION
public static final FileType FREVO_RESULT_FILE_TYPE
public static final java.lang.String FREVO_PACKAGE_EXTENSION
public static final boolean FREVO_REDIRECTCONSOLE_TO_FILE
public static int[] componentBrowserParameters
public static int[] mainWindowParameters
public static boolean isLaunchable
public static boolean isRunning
public static boolean isFrevoWithGraphics()
public static FrevoWindow getMainWindow()
public static java.lang.String getActiveDirectory()
public static java.lang.String getInstallDirectory()
public static java.lang.String getMajorVersion()
String
format.public static java.lang.String getMinorVersion()
String
format.public static int getCurrentRun()
public static void setCurrentRun(int currentrun)
currentrun
- The new value of the current simulation run.public static int getNumberOfSimulationRuns()
public static void setNumberOfSimulationRuns(int maxRun)
maxRun
- the maxRun to setpublic static long getSeed()
public static void setSeed(long seed)
seed
- The new seed value used for simulations.public static java.lang.String getCustomName()
public static void setCustomName(java.lang.String customName)
String
.customName
- The new custom name to be used.public static java.lang.String[] getParameters()
public static void main(java.lang.String[] args)
args
- Command line arguments entered when starting FREVOpublic static void reLoadComponents()
public static org.dom4j.Document loadSession(java.io.File loadFile)
loadFile
- The session file to load.public static ComponentXMLData readIComponentFromXml(java.io.File file, ComponentType ctype, boolean validateXML) throws java.rmi.RemoteException
file
- The XML file to load.ctype
- Type of this component. E.g. problem, method, etc. Check
ComponentType
enum for more.validateXML
- Validates the XML while loading if true.java.rmi.RemoteException
public static void runSimulation(java.lang.String outputname)
outputname
- The output name used by the method. This is mostly to
formulate result files' names.seed
- The starting random seed of this simulation.public static java.util.ArrayList<FrevoMain.KeywordCategory> getCategories(ComponentType ctype)
ctype
- The type of component whose keyword category is requested.public static void saveResult(java.lang.String fileName, org.dom4j.Element representationRootElement, long usedSeed)
fileName
- Name of the saved file without the extension. (E.g.
solution_generation_13)method
- The corresponding method instance to be called for saving.public static void setLoadingProgress(float progress)
progress
- The new progress value between 0 and 1.public static ComponentXMLData getSelectedComponent(ComponentType ctype)
ctype
- The type of the component requested.public static void setSelectedComponent(ComponentType ctype, ComponentXMLData cdata)
ctype
- The type of the component to be selected.cdata
- The XML data to be selected.public static ComponentXMLData getComponent(ComponentType ctype, java.lang.String componentName)
null
if not found.ctype
- The type of the component to be returned.componentName
- The name of the component to be returned.public static java.util.HashMap<java.lang.String,ComponentXMLData> getComponentList(ComponentType componentType)
componentType
- The type of the components requested.public static java.lang.String getComponentDirectory(ComponentType componentType)
componentType
- The type of the components whose base directory is requested.public static boolean checkState()
public static boolean checkType(XMLFieldType type, java.lang.String value)
type
- The property type against the value check is performed.value
- The value to be used for the check.public static java.lang.String getExtension(java.io.File file)
File
.file
- The file whose extension is requested.public static void evaluateCandidates(java.util.ArrayList<AbstractRepresentation> candidates, ProblemXMLData problemData, java.util.Hashtable<java.lang.String,XMLFieldEntry> properties, long seed) throws java.lang.IllegalStateException
IllegalStateException
will be thrown.candidates
- The array of candidates to be evaluated.problemData
- The source XML descriptor of the problem component to be used.properties
- The properties map used for configuring the problem component.
If null is passed then the problem's default
properties will be used.seed
- The random seed used for the sessionjava.lang.IllegalStateException
- if the number of candidates is not within the range defined
by the problem.public static AbstractRepresentation getRepresentation(java.io.File loadfile, int rank)
loadfile
- The XML results file to be loaded.rank
- The position of the requested representation in the XML
results file.public static void writeStatisticsToDisk()
public static void writeStatisticsToDisk(java.lang.String pathToSaveDirectory) throws java.lang.IllegalAccessError
pathToSaveDirectory
- Path to the directory for saving the statistics data to.java.lang.IllegalAccessError
public static java.lang.String getComponentTypeAsString(ComponentType ctype)
E.g. FREVO_IPROBLEM
: Problem
public static void saveSettings()
public static java.io.File loadSystemIndependentFile(java.lang.String filepath)
File
instance by converting the given pathname
string into an abstract pathname. If the given string point to a file
that does not exist then it replaces file separators and tries again.filepath
- A pathname stringFile
instance with the given file path.public static StatKeeper getStatistics(int index, boolean skipInvisible)
StatKeeper
element with the given index. If
"skipInvisible" is set to true then non-displayed statistics will not
count.index
- Index of the requested statistics.java.lang.IndexOutOfBoundsException
- if index is invalidpublic static int getNumberofStatistics(boolean skipInvisible)
StatKeeper
objects currently loaded in
FREVO. If "skipInvisible" is true, then it returns only the statistics
that are displayed.skipInvisible
- If true, only displayed statistics will be counted.public static boolean isStatKeeperLoaded(StatKeeper statkeeper)
true
if this StatKeeper
object is
currently loaded by FREVO. More formally, returns true if and
only if the FREVO statistics contain at least one element e such
that (sk==null ? e==null : sk.equals(e)).statkeeper
- element whose presence is to be testedStatKeeper
object is currently loaded
by FREVOpublic static void addStatistics(StatKeeper statkeeper)
StatKeeper
object to FREVO. Objects added
will be monitored and saved if needed.statkeeper
- StatKeeper to be addedpublic static void eraseStatistics()
StatKeeper
objects from FREVO.public static void exportComponent(ComponentXMLData component, java.io.File savefile, boolean addsources)
All data found in the component directory will be added to the exported
package that will be compressed by a ZIP algorithm. Adding the source
.java files can be prohibited with the addSources
flag.
component
- The component to be exported.savefile
- The output file that will contain the data of the component.addsources
- Flag indicating if the corresponding .java sources are also
included or not.public static void importComponent(java.io.File importfile)
importfile
- The ZCP file to be imported.public static void reset()
public static void deleteComponent(ComponentXMLData cdata)
cdata
- The component to be removed