Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

FVar.h

00001 //   -*- C++ -*-
00002 /*****************************************************************************
00003  *
00004  *   |_|_|_  |_|_    |_    |_|_|_  |_                C O M M U N I C A T I O N
00005  * |_        |_  |_  |_  |_        |_                          N E T W O R K S
00006  * |_        |_  |_  |_  |_        |_                                C L A S S
00007  *   |_|_|_  |_    |_|_    |_|_|_  |_|_|_|_                      L I B R A R Y
00008  *
00009  * $Id: FVar.h,v 1.5 2002/02/01 08:46:08 spee Exp $
00010  *
00011  * Class: CNFVar --- Fuzzy variable
00012  *
00013  *****************************************************************************
00014  * Copyright (C) 1992-2002   Communication Networks
00015  *                           Aachen University of Technology
00016  *                           D-52056 Aachen
00017  *                           Germany
00018  *                           Email: cncl-adm@comnets.rwth-aachen.de
00019  *****************************************************************************
00020  * This file is part of the CN class library. All files marked with
00021  * this header are free software; you can redistribute it and/or modify
00022  * it under the terms of the GNU Library General Public License as
00023  * published by the Free Software Foundation; either version 2 of the
00024  * License, or (at your option) any later version.  This library is
00025  * distributed in the hope that it will be useful, but WITHOUT ANY
00026  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
00027  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00028  * License for more details.  You should have received a copy of the GNU
00029  * Library General Public License along with this library; if not, write
00030  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
00031  * USA.
00032  *****************************************************************************/
00033 
00034 #ifndef __CNFVar_h
00035 #define __CNFVar_h
00036 
00037 
00038 #include <CNCL/Class.h>
00039 #include <CNCL/Param.h>
00040 #include <CNCL/Named.h>         // Base class
00041 #include <CNCL/FSet.h>
00042 #include <CNCL/ArrayObject.h>
00043 
00044 extern CNClassDesc CN_FVAR;     // CNClass CNFVar description
00045 
00046 
00050 class CNFVar : public CNNamed
00051 {
00052   public:
00054     double set_value(double x);
00057     double value(double x);
00059     double get_value()         const;
00061     double value()             const;
00062 
00065     CNFSet *set_fuzzy_value(CNFSet *x);
00067     CNFSet *fuzzy_value(CNFSet *x);
00069     CNFSet *get_fuzzy_value()   const;
00071     CNFSet *fuzzy_value()       const;
00072 
00074     double get_xmin()          const;
00076     double get_xmax()          const;
00078     double xmin()              const;
00080     double xmax()              const;
00081 
00085     void add_value_set(CNFSet &fset);
00089     void add_value_set(CNFSet *fset);
00092     void add_value_set(int i, CNFSet &fset);    
00095     void add_value_set(int i, CNFSet *fset);
00096 
00098     CNFSet *get_value_set(int i);
00100     double get_membership(int i);
00101     
00104     void print_membership();
00105 
00106   private:
00107     double        varvalue;             // Current value
00108     CNFSet       *varfvalue;            // Current fuzzy value
00109     double        varxmin, varxmax;     // value range
00110     CNArrayObject varsets;              // Affiliated fuzzy sets
00111 
00112     /****** Constructors ******************************************************/
00113   public:
00115     CNFVar(CNParam *param);
00117     CNFVar(double min=0, double max=1);
00119     CNFVar(CNStringR xname, double min=0, double max=1);
00120 
00122     void init(CNStringR xname, double min, double max);
00123     
00124     /****** Member functions required by CNCL *********************************/
00125   public:
00126     virtual CNClassDesc class_desc() const      // CNClass description
00127     {
00128         return CN_FVAR;
00129     };
00130             
00132     virtual bool is_a(CNClassDesc desc) const
00133     {
00134         return desc == CN_FVAR ? TRUE : CNObject::is_a(desc);
00135     };
00136         
00138     static CNFVar *cast_from_object(CNObject *obj)
00139     {
00140 #   ifdef NO_TYPE_CHECK
00141         return (CNFVar *)obj;
00142 #   else
00143         return (CNFVar *)( !obj || obj->is_a(CN_FVAR)
00144                ? obj : fatal_type(obj->class_desc(), CN_FVAR) );
00145 #   endif
00146     }
00147     
00149     static CNObject *new_object(CNParam *param = NIL)
00150     { return param ? new CNFVar(param) : new CNFVar; }
00151     
00153     virtual void print(ostream &strm = cout) const;
00155     virtual void dump (ostream &strm = cout) const;
00156 };
00157 
00158 
00159 #endif 

Generated on Fri Feb 1 19:53:51 2002 for CNCL by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001