/*
 * Copyright (c) 1999 Johnny C. Lam.
 * All rights reserved.
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.  The author makes no representations
 * about the suitability of this software for any purpose.  It is
 * provided "as is" without express or implied warranty.
 */

// -*- C++ -*-

#ifndef PATH_CRITERION_H_INCLUDED
#define PATH_CRITERION_H_INCLUDED

#ifndef STL_ALGORITHM_INCLUDED
#include <algorithm>
#define STL_ALGORITHM_INCLUDED
#endif

#ifndef PATH_H_INCLUDED
#include "path.h"
#endif

#ifndef TYPES_H_INCLUDED
#include "types.h"
#endif

struct PathCriterion {
    virtual log_probability compute(const Path&, const Path&) const = 0;
    log_probability operator()(const Path& p, const Path& q) const {
	return compute(p, q);
    }
};

struct AveragePathCriterion : public PathCriterion {
    log_probability compute(const Path& p, const Path& q) const {
	return (p.Weight() + q.Weight()) / 2.0;
    }
};

struct MinPathCriterion : public PathCriterion {
    log_probability compute(const Path& p, const Path& q) const {
	return std::min(p.Weight(), q.Weight());
    }
};

struct MaxPathCriterion : public PathCriterion {
    log_probability compute(const Path& p, const Path& q) const {
	return std::max(p.Weight(), q.Weight());
    }
};

#endif /* PATH_CRITERION_H_INCLUDED */
