    001package net.sf.cpsolver.ifs.criteria;
    002
    003import java.util.Collection;
    004import java.util.Set;
    005
    006import net.sf.cpsolver.ifs.model.InfoProvider;
    007import net.sf.cpsolver.ifs.model.ModelListener;
    008import net.sf.cpsolver.ifs.model.Value;
    009import net.sf.cpsolver.ifs.model.Variable;
    010
    011/**
    012 * Criterion. <br>
    013 * <br>
    014 * An optimization objective can be split into several (optimization) criteria
    015 * and modeled as a weighted sum of these. This makes the implementation of a particular problem
    016 * more versatile as it allows for an easier modification of the optimization objective.
    017 *
    018 * @version IFS 1.2 (Iterative Forward Search)<br>
    019 *          Copyright (C) 2006 - 2011 Tomáš Müller<br>
    020 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    021 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    022 * <br>
    023 *          This library is free software; you can redistribute it and/or modify
    024 *          it under the terms of the GNU Lesser General Public License as
    025 *          published by the Free Software Foundation; either version 3 of the
    026 *          License, or (at your option) any later version. <br>
    027 * <br>
    028 *          This library is distributed in the hope that it will be useful, but
    029 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    030 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    031 *          Lesser General Public License for more details. <br>
    032 * <br>
    033 *          You should have received a copy of the GNU Lesser General Public
    034 *          License along with this library; if not see
    035 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    036 */
    037public interface Criterion<V extends Variable<V, T>, T extends Value<V, T>> extends ModelListener<V, T>, InfoProvider<V> {
    038
    039    /** Current value of the criterion (optimization objective) */
    040    public double getValue();
    041
    042    /** Weighted value of the objectives */
    043    public double getWeightedValue();
    044
    045    /** Bounds (minimum and maximum) estimate for the value */
    046    public double[] getBounds();
    047
    048    /** Weighted best value of the objective (value in the best solution). */
    049    public double getWeightedBest();
    050
    051    /** Best value (value of the criterion in the best solution) */
    052    public double getBest();
    053
    054    /** Weight of the criterion */
    055    public double getWeight();
    056
    057    /** Weighted value of a proposed assignment (including hard conflicts) */
    058    public double getWeightedValue(T value, Set<T> conflicts);
    059
    060    /** Value of a proposed assignment (including hard conflicts) */
    061    public double getValue(T value, Set<T> conflicts);
    062
    063    /** Weighted value of a part of the problem (given by the collection of variables) */
    064    public double getWeightedValue(Collection<V> variables);
    065
    066    /** Value of a part of the problem (given by the collection of variables) */
    067    public double getValue(Collection<V> variables);
    068
    069    /** Value bounds (minimum and maximum) of the criterion on a part of the problem */
    070    public double[] getBounds(Collection<V> variables);
    071
    072    /** Criterion name */
    073    public String getName();
    074
    075    /** Outside update of the criterion (usefull when the criterion is driven by a set of constraints). */
    076    public void inc(double value);
    077
    078    /** Notification that the current solution has been saved to the best. */
    079    public void bestSaved();
    080
    081    /** Notification that the current solution has been restored from the best. */
    082    public void bestRestored();
    083}