BasicSolver.java

  1. /* Copyright 2015 Laurent COCAULT
  2.  * Licensed to Laurent COCAULT under one or more contributor license agreements.
  3.  * See the NOTICE file distributed with this work for additional information
  4.  * regarding copyright ownership. Laurent COCAULT licenses this file to You
  5.  * under the Apache License, Version 2.0 (the "License"); you may not use this
  6.  * file except in compliance with the License.  You may obtain a copy of the
  7.  * License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.csp.constraint.solver;

  18. import org.csp.constraint.model.Value;
  19. import org.csp.constraint.model.Variable;

  20. public class BasicSolver<T> extends Solver<T> {

  21.     /**
  22.      * Constructor of the basic solver.
  23.      * @param problem
  24.      *            Problem to solve
  25.      */
  26.     public BasicSolver(final Problem<T> problem) {
  27.         super(problem);
  28.     }

  29.     /**
  30.      * {@inheritDoc}
  31.      */
  32.     @Override
  33.     protected Value<T> selectValue(final Variable<T> variable) {
  34.         return variable.getFirstValue();
  35.     }

  36.     /**
  37.      * {@inheritDoc}
  38.      */
  39.     @Override
  40.     protected Variable<T> selectVariableToBind() {
  41.         return getProblem().getFirstUnboundVariable();
  42.     }
  43. }