MOEA Framework 2.12
API Specification

org.moeaframework.problem
Class ScriptedProblem

java.lang.Object
  extended by org.moeaframework.problem.ScriptedProblem
All Implemented Interfaces:
Problem

public class ScriptedProblem
extends Object
implements Problem

Permits interfacing with problems implemented by one of the many scripting languages supported by the Java Scripting APIs.

Currently, only scripting engines which support the Invocable interface are supported. The script itself should contain methods equivalent to the methods in Problem, with the same names, arguments and return values.


Constructor Summary
ScriptedProblem(File file)
          Constructs a new problem implemented in a scripting language.
ScriptedProblem(Reader reader, String name)
          Constructs a new problem implemented in a scripting language.
ScriptedProblem(String script, String name)
          Constructs a new problem implemented in a scripting language.
 
Method Summary
 void close()
          Closes any underlying resources used by this problem.
 void evaluate(Solution solution)
          Evaluates the solution, updating the solution's objectives in place.
 String getName()
          Returns the user-friendly name for this problem.
 int getNumberOfConstraints()
          Returns the number of constraints defined by this problem.
 int getNumberOfObjectives()
          Returns the number of objectives defined by this problem.
 int getNumberOfVariables()
          Returns the number of decision variables defined by this problem.
 Solution newSolution()
          Returns a new solution for this problem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptedProblem

public ScriptedProblem(String script,
                       String name)
                throws ScriptException
Constructs a new problem implemented in a scripting language.

Parameters:
script - the script
name - the name of the scripting engine
Throws:
ScriptException - if an error occurred in the Scripting APIs

ScriptedProblem

public ScriptedProblem(Reader reader,
                       String name)
                throws ScriptException
Constructs a new problem implemented in a scripting language.

Parameters:
reader - the reader for loading the script contents
name - the name of the scripting engine
Throws:
ScriptException - if an error occurred in the Scripting APIs

ScriptedProblem

public ScriptedProblem(File file)
                throws ScriptException,
                       IOException
Constructs a new problem implemented in a scripting language.

Parameters:
file - the file containing the script contents, and whose file extension identifies the scripting language
Throws:
ScriptException - if an error occurred in the Scripting APIs
IOException - if an I/O error occurred
Method Detail

getName

public String getName()
Description copied from interface: Problem
Returns the user-friendly name for this problem.

Specified by:
getName in interface Problem
Returns:
the user-friendly name for this problem

getNumberOfVariables

public int getNumberOfVariables()
Description copied from interface: Problem
Returns the number of decision variables defined by this problem.

Specified by:
getNumberOfVariables in interface Problem
Returns:
the number of decision variables defined by this problem

getNumberOfObjectives

public int getNumberOfObjectives()
Description copied from interface: Problem
Returns the number of objectives defined by this problem.

Specified by:
getNumberOfObjectives in interface Problem
Returns:
the number of objectives defined by this problem

getNumberOfConstraints

public int getNumberOfConstraints()
Description copied from interface: Problem
Returns the number of constraints defined by this problem.

Specified by:
getNumberOfConstraints in interface Problem
Returns:
the number of constraints defined by this problem

evaluate

public void evaluate(Solution solution)
Description copied from interface: Problem
Evaluates the solution, updating the solution's objectives in place. Algorithms must explicitly call this method when appropriate to evaluate new solutions or reevaluate modified solutions.

Specified by:
evaluate in interface Problem
Parameters:
solution - the solution to be evaluated

newSolution

public Solution newSolution()
Description copied from interface: Problem
Returns a new solution for this problem. Implementations must initialize the variables so that the valid range of values is defined, but may leave the actual value at a default or undefined state.

Specified by:
newSolution in interface Problem
Returns:
a new solution for this problem

close

public void close()
Description copied from interface: Problem
Closes any underlying resources used by this problem. Once closed, further invocations of any methods on this problem may throw exceptions.

Specified by:
close in interface Problem

MOEA Framework 2.12
API Specification

Copyright 2009-2016 MOEA Framework. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage. Visit us on Github!