Package com.niacin.problem

Source Code of com.niacin.problem.Problem

package com.niacin.problem;

import java.util.Vector;

import com.niacin.annotation.Optimize;
import com.niacin.input.Solution;
import com.niacin.input.Variable;

public class Problem
{
  private Vector<Variable<?>> variables = new Vector<Variable<?>>();
  private String name;
  private int remainingTrials;
  private Optimize.Direction direction;

  public Problem(String name, Vector<Variable<?>> variables, Optimize.Direction direction, int trials)
  {
    this.name = name;
    this.variables.addAll(variables);
    this.direction = direction;
    this.remainingTrials = trials;
  }

  public Solution initialSolution()
  {
    Solution initial = new Solution();
    initial.addAll(variables);
    return initial;
  }

  public Solution generateRandomRestart()
  {
    Solution random = new Solution();
    for (Variable<?> v : variables)
    {
      random.add(v.random());
    }
    return random;
  }

  public String name()
  {
    return name;
  }

  public Optimize.Direction getDirection()
  {
    return direction;
  }

  public int getRemainingTrials()
  {
    return remainingTrials;
  }
}
TOP

Related Classes of com.niacin.problem.Problem

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.