/****************************************************************** * * * Nest version 2 - 3D Wasp Nest Simulator * * Copyright (C) 1997 Sylvain GUERIN * * LIASC, ENST Bretagne & Santa Fe Institute * * * ****************************************************************** E-mail: Sylvain.Guerin@enst-bretagne.fr or: Sylvain Guerin 13 rue des Monts Lorgeaux, 51460 L'EPINE, FRANCE ****************************************************************** This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ****************************************************************** Name : classify.h Component : crossover in genetic simulations Fonctionality : partionning algorithm - specifications ******************************************************************/ #ifndef __classify_H #define __classify_H #include "config.h" #include "algo.h" class RuleNode; class RuleGraph; enum ClusterType { clusterA, clusterB }; class RuleNode { public: RuleNode (int aNodeId, ClusterType aCluster, int aMaxEdges, RuleGraph* aRuleGraph); ~RuleNode (); void setCluster (ClusterType aCluster); void computeGain (); void computeEntropy (); void connectToNode (int aNeighbourId, int aWeight); int getNodeId (); int getEdgesNumber (); ClusterType getCluster (); int getGain (); int getEntropy (); int getLocked (); int getNeighbourId (int anIndex); int getNeighbourWeight (int anIndex); RuleNode* getNeighbour (int anIndex); void lock (); void unlock (); void swapCluster (); void debug (); protected: int nodeId; /* id du noeud = ruleNumber*/ int edgesNumber; int maxEdges; ClusterType cluster; int gain; /* le gain est ce que l'on gagnerait en "swappant" le noeud */ int entropy; /* l'entropie est le poids des aretes inter-clusters du noeud */ int locked; int* neighbourId; int* neighbourWeight; RuleGraph* ruleGraph; }; class RuleGraph { public: RuleGraph (int aMaxNodes); ~RuleGraph (); void addNode (int aNodeId, ClusterType aCluster); void addEdge (int startNodeId, int endNodeId, int weight); RuleNode* nodeWhichIdIs (int nodeId); void computeAllGains (); void computeAllEntropies (); int getGlobalEntropy (); RuleNode* nodeWithBestGain (ClusterType aCluster, int* foundGain); void incNodesInClusterA (); void decNodesInClusterA (); void incNodesInClusterB (); void decNodesInClusterB (); void partitionning (int aMiniNodesPerCluster); void debug (); protected: int maxNodes; int nodesNumber; int edgesNumber; int miniNodesPerCluster; int nodesInClusterA; int nodesInClusterB; RuleNode** nodes; }; #endif