//
// Copyright (c) 2009 Froduald Kabanza and the Université de Sherbrooke.
// Use of this software is permitted for non-commercial research purposes, and
// it may be copied or applied only for that use. All copies must include this
// copyright message.
// 
// This is a research prototype and it has not gone through intensive tests and
// is delivered as is. It may still contain bugs. Froduald Kabanza and the
// Université de Sherbrooke disclaim any responsibility for damage that may be
// caused by using it.
//
// Implementation: Simon Chamberland
// Project Manager: Froduald Kabanza
//
#ifndef _MAXIMIZE_EXP_H
#define _MAXIMIZE_EXP_H

#include "MetricExp.h"

namespace planning
{
  /// <summary>
  /// Represents the minimize expression used in metric specification of the PDDL language.
  /// </summary>
  class MaximizeExp : public MetricExp
  {
  public:
    /// <summary>
    /// Creates a minimize metric with the given expression.
    /// </summary>
    /// <param name="exp">The expression to minimize.</param>
    /// <param name="unnamedPrefs">The unnamed preferences.</param>
    MaximizeExp(const INumericExp* exp);

    /// <summary>
    /// Returns a minimized version of the metric evaluated on a given world.
    /// </summary>
    /// <param name="world">The evaluation world.</param>
    /// <param name="bindings">A set of variable bindings.</param>
    /// <returns>The minimized version of the metric.</returns>
    virtual double evaluateMinimizedMetric(const IClosedWorld* world, const Bindings* bindings) const;

    virtual double evaluateMaximizedMetric(const IClosedWorld* world, const Bindings* bindings) const;

  protected:
    virtual size_t _calculateHashCode() const
    {
      return 57 * m_exp->getHashCode()
           + 45893;
    }

    /// <summary>
    /// Substitutes all occurrences of the variables that occur in this
    /// expression by their corresponding bindings.
    /// </summary>
    /// <param name="bindings">The bindings.</param>
    /// <returns>A substituted copy of this expression.</returns>
    virtual const IExp* _internalApply(const Bindings* bindings) const;

    virtual std::string getTypeName() const;
  };
}

#endif