Class ProblemStub

java.lang.Object
org.moeaframework.problem.AbstractProblem
org.moeaframework.problem.ProblemStub
All Implemented Interfaces:
AutoCloseable, Named, Problem

public class ProblemStub extends AbstractProblem
A problem "stub" that is typically used when processing data files when the specific problem type is unknown. It can be configured with specific variable, objective, and constraint types, if known. However, if specific types are not provided, functionality may be limited and can result in exceptions.
  • Constructor Details

    • ProblemStub

      public ProblemStub(int numberOfObjectives)
      Constructs a problem stub with the specified number of objectives.
      Parameters:
      numberOfObjectives - the number of objectives
    • ProblemStub

      public ProblemStub(String name, int numberOfVariables, int numberOfObjectives, int numberOfConstraints)
      Constructs a problem stub with the specified number of variables, objectives, and constraints.
      Parameters:
      name - the problem name
      numberOfVariables - the number of variables
      numberOfObjectives - the number of objectives
      numberOfConstraints - the number of constraints
    • ProblemStub

      public ProblemStub(Solution solution)
      Constructs a problem stub from the given solution.
      Parameters:
      solution - a sample or prototype solution for the problem
    • ProblemStub

      public ProblemStub(String name, Solution solution)
      Constructs a problem stub from the given solution.
      Parameters:
      name - the problem name
      solution - a sample or prototype solution for the problem
  • Method Details

    • getName

      public String getName()
      Description copied from interface: Problem
      Returns the name of this problem. Whenever possible, this name should match the name recognized by ProblemFactory.
      Returns:
      the name of this problem
    • setVariableDefinition

      public void setVariableDefinition(int index, Variable variable)
      Sets the specific variable type, if known.
      Parameters:
      index - the index
      variable - the variable
    • setObjectiveDefinition

      public void setObjectiveDefinition(int index, Objective objective)
      Sets the specific objective type, if known.
      Parameters:
      index - the index
      objective - the objective
    • setConstraintDefinition

      public void setConstraintDefinition(int index, Constraint constraint)
      Sets the specific constraint type, if known.
      Parameters:
      index - the index
      constraint - the constraint
    • 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.
      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 typically leave the actual value at a default or undefined state.
      Returns:
      a new solution for this problem