/****************************************************************************
 * This file was derived from the CNCL library by the Pablo research group.
 *
 * The complete CNCL library is available at:
 *       http://www.comnets.rwth-aachen.de/doc/cncl.html
 *
 * The CNCL copyright notice is included here:
 *
 * |_|_|_  |_|_    |_    |_|_|_  |_               C O M M U N I C A T I O N
 *|_       |_  |_  |_  |_        |_                         N E T W O R K S
 *|_       |_  |_  |_  |_        |_                               C L A S S
 * |_|_|_  |_    |_|_    |_|_|_  |_|_|_|_                     L I B R A R Y
 *
 *
 *
 * Copyright (C) 1992-1998   Communication Networks
 *                           Aachen University of Technology
 *                           D-52056 Aachen
 *                           Germany
 *                           Email: cncl-adm@comnets.rwth-aachen.de
 *
 *
 * This library is free  software; you can  redistribute it and/or modify
 * it  under   the terms  of the GNU   Library  General Public License as
 * published by the  Free Software Foundation;  either  version 2 of  the
 * License, or  (at  your option)  any  later  version.  This  library is
 * distributed  in the  hope  that  it  will  be useful,  but WITHOUT ANY
 * WARRANTY;  without even the   implied  warranty of MERCHANTABILITY  or
 * FITNESS FOR A PARTICULAR PURPOSE.   See the GNU Library General Public
 * Library General Public License along with  this library; if not, write
 * to the Free Software Foundation,  675  Mass Ave, Cambridge, MA  02139,
 * USA.
 ****************************************************************************/

//   -*- C++ -*-
/*****************************************************************************
 *
 * Class: FlFRule --- Fuzzy rule
 *
 *****************************************************************************/

#ifndef __FlFRule_h
#define __FlFRule_h

#include <FlObject.h>		// Base class
#include <FlFClause.h>
#include <FlFSetArray.h>


/*
 * The class FlFRule
 */

class FlFRule : public FlObject
{
  public:
    void add_lhs(FlFClause *clause);	// Add LHS clause
    void add_lhs(FlFClause &clause);
    void add_rhs(FlFClause *clause);	// Add RHS clause
    void add_rhs(FlFClause &clause);

    int get_n_lhs() const;		// Get # clauses LHS
    int get_n_rhs() const;		// Get # clauses RHS

    FlFClause *get_lhs(int i) const;	// Get clause from LHS
    FlFClause *get_rhs(int i) const;	// Get clause from RHS

    double set_certainty(double x);	// Get/set certainty value
    double certainty(double x);
    double get_certainty() const;
    double certainty() const;

    double aggregate_value() const;
    					// Aggregate rule inputs (LHS)
    double aggregate(/**FIXME: Operator needed**/);

    // Private members
  private:
    FlArrayObject lhs;			// Rule LHS
    FlArrayObject rhs;			// Rule RHS
    double r_certainty;			// Rule certainty
    double agg_value;			// Result of aggregate() LHS
    
    /***** Constructors ******************************************************/
  public:
    FlFRule()
	    : lhs((size_t)0), rhs((size_t)0), r_certainty(1.) {}

    // Print/debug output
    virtual void print(ostream &strm = cout) const;
    virtual void dump (ostream &strm = cout) const;
};


#endif /**__FlFRule_h**/
