|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Objectorg.moeaframework.problem.ExternalProblem
public abstract class ExternalProblem
Evaluate solutions using an externally-defined problem. Two modes of operation are supported: standard I/O and sockets.
new ExternalProblem("./problem.exe", "arg1", "arg2") { ... }
Then, solutions are sent to the process on its standard input (stdin) stream,
and the objectives and constraints are read from its standard output (stdout)
stream.
The program can not use the standard I/O for any other purpose. Programs which read from or write to the standard I/O streams should instead use sockets, as discussed below.
ExternalProblem(String, int) or
ExternalProblem(InetAddress, int) constructor.
moeaframework.c and
moeaframework.h files in the examples/ folder for details.
This interface conforms to the communication protocol described below.
The communication protocol consists of sending decision variables to the external process, and the process responding with the objectives and constraints. The decision variables line consists of one or more variables separated by whitespace and terminated by a newline. The process evaluates the problem for the given variables and outputs the objectives separated by whitespace and terminated by a newline. If the problem also has constraints, each constraint is returned after the objectives on the same line. The process must only terminate when the end of stream is reached. In addition, the process should flush the output stream to ensure the output is processed immediately.
Whitespace is one or more spaces, tabs or any combination thereof. The newline is either the line feed ('\n'), carriage return ('\r') or a carriage return followed immediately by a line feed ("\r\n").
It is critical that the close() method be invoked to ensure the
external process is shutdown cleanly.
| Field Summary | |
|---|---|
static int |
DEFAULT_PORT
The default port used by the MOEA Framework to connect to remote evaluation processes via sockets. |
| Constructor Summary | |
|---|---|
ExternalProblem(InetAddress address,
int port)
Constructs an external problem that connects to a remote process via sockets. |
|
ExternalProblem(String... command)
Constructs an external problem using new
ProcessBuilder(command).start(). |
|
ExternalProblem(String host,
int port)
Constructs an external problem that connects to a remote process via sockets. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the connection to the process. |
void |
evaluate(Solution solution)
Evaluates the specified solution using the process defined by this class' constructor. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.moeaframework.core.Problem |
|---|
getName, getNumberOfConstraints, getNumberOfObjectives, getNumberOfVariables, newSolution |
| Field Detail |
|---|
public static final int DEFAULT_PORT
| Constructor Detail |
|---|
public ExternalProblem(String... command)
throws IOException
new
ProcessBuilder(command).start(). If the command contains arguments,
the arguments should be passed in as separate strings, such as
new ExternalProblem("command", "arg1", "arg2");
command - a specified system command
IOException - if an I/O error occured
public ExternalProblem(String host,
int port)
throws IOException,
UnknownHostException
host - the host name of the remote system; or null to use
the local hostport - the port number
UnknownHostException - if the IP address of the specified host
could not be determined
IOException - if an I/O error occurred
public ExternalProblem(InetAddress address,
int port)
throws IOException
address - the IP address of the remote systemport - the port number
IOException - if an I/O error occurred| Method Detail |
|---|
public void close()
evaluate are permitted.
close in interface Problem
public void evaluate(Solution solution)
throws ProblemException
evaluate in interface Problemsolution - the solution to evaluate
ProblemException
|
MOEA Framework 2.5 API Specification |
|||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||