JP2002175306A - Clustering method for genes - Google Patents

Clustering method for genes

Info

Publication number
JP2002175306A
JP2002175306A JP2000373765A JP2000373765A JP2002175306A JP 2002175306 A JP2002175306 A JP 2002175306A JP 2000373765 A JP2000373765 A JP 2000373765A JP 2000373765 A JP2000373765 A JP 2000373765A JP 2002175306 A JP2002175306 A JP 2002175306A
Authority
JP
Japan
Prior art keywords
pattern
net
art
return
map
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2000373765A
Other languages
Japanese (ja)
Inventor
Takeshi Kobayashi
猛 小林
Hiroyuki Honda
裕之 本多
Taizo Hanai
泰三 花井
Hideta Tomita
秀太 冨田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nagoya Industrial Science Research Institute
Original Assignee
Nagoya Industrial Science Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nagoya Industrial Science Research Institute filed Critical Nagoya Industrial Science Research Institute
Priority to JP2000373765A priority Critical patent/JP2002175306A/en
Priority to AU2002221076A priority patent/AU2002221076A1/en
Priority to PCT/JP2001/010704 priority patent/WO2002046962A1/en
Publication of JP2002175306A publication Critical patent/JP2002175306A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16BBIOINFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR GENETIC OR PROTEIN-RELATED DATA PROCESSING IN COMPUTATIONAL MOLECULAR BIOLOGY
    • G16B40/00ICT specially adapted for biostatistics; ICT specially adapted for bioinformatics-related machine learning or data mining, e.g. knowledge discovery or pattern finding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/23Clustering techniques
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16BBIOINFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR GENETIC OR PROTEIN-RELATED DATA PROCESSING IN COMPUTATIONAL MOLECULAR BIOLOGY
    • G16B25/00ICT specially adapted for hybridisation; ICT specially adapted for gene or protein expression
    • G16B25/10Gene or protein expression profiling; Expression-ratio estimation or normalisation
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16BBIOINFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR GENETIC OR PROTEIN-RELATED DATA PROCESSING IN COMPUTATIONAL MOLECULAR BIOLOGY
    • G16B25/00ICT specially adapted for hybridisation; ICT specially adapted for gene or protein expression

Landscapes

  • Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Medical Informatics (AREA)
  • Evolutionary Biology (AREA)
  • Biotechnology (AREA)
  • Spectroscopy & Molecular Physics (AREA)
  • Genetics & Genomics (AREA)
  • Evolutionary Computation (AREA)
  • General Health & Medical Sciences (AREA)
  • Biophysics (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Epidemiology (AREA)
  • Public Health (AREA)
  • Software Systems (AREA)
  • Databases & Information Systems (AREA)
  • Bioethics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Molecular Biology (AREA)
  • Measuring Or Testing Involving Enzymes Or Micro-Organisms (AREA)
  • Apparatus Associated With Microorganisms And Enzymes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

PROBLEM TO BE SOLVED: To provide a clustering method capable of accurately sorting genes. SOLUTION: Genes are clustered by obtaining a signal pattern, expressing a change of a gene manifestation state and processing the obtained signal pattern by ART technique.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】この発明は遺伝子のクラスタ
リング方法に関し、更に詳しくは遺伝子の時系列発現プ
ロファイルを解析することにより遺伝子をクラスタリン
グする方法に関する。
The present invention relates to a method for clustering genes, and more particularly, to a method for clustering genes by analyzing a time-series expression profile of genes.

【0002】[0002]

【従来の技術】同じ転写調節を受けている遺伝子は時系
列的によく似た挙動を示すと考えられる。そこでDNA
チップを用いて遺伝子の発現状態をモニタリングし、そ
のプロファイルの時系列変化(発現シグナルパターン)
から遺伝子をクラスタリング(グループ化)する方法が
知られている。かかるクラスタリングの方法の一つとし
て階層的クラスタリングがある。この階層的クラスタリ
ングについては X. Wen et al.(Proc. Natl. Acad. Sc
i. USAVol. 95, pp, 334-339, January 1998)及び M.
B. Eisen et al.(Proc. Natl. Acad. Sci. USA Vol. 9
5, pp, 14863-14868, December 1998)を参照された
い。また他のクラスタリング方法として自己組織化法
(SOM)がある。このクラスタリング方法については
P. Tamayo et al.(Proc. Natl. Acad. Sci. USA Vol.
96, pp, 2907-2912, March 1999)を参照されたい。更
に他のクラスタリング方法としてK−means法があ
る。このクラスタリング方法についてはIncyte Pharmac
euticals 社のRoland Somogyiによって提案されてい
る。
2. Description of the Related Art Genes that are under the same transcriptional regulation are considered to behave similarly in time series. So DNA
Monitor the expression status of genes using a chip, and change the profile over time (expression signal pattern)
A method for clustering (grouping) genes from each other is known. Hierarchical clustering is one of such clustering methods. This hierarchical clustering is described in X. Wen et al. (Proc. Natl. Acad. Sc.
i. USAVol. 95, pp, 334-339, January 1998) and M.
B. Eisen et al. (Proc. Natl. Acad. Sci. USA Vol. 9
5, pp., 14863-14868, December 1998). Another clustering method is a self-organizing method (SOM). About this clustering method
P. Tamayo et al. (Proc. Natl. Acad. Sci. USA Vol.
96, pp. 2907-2912, March 1999). Still another clustering method is the K-means method. See Incyte Pharmac for this clustering method.
Proposed by Roland Somogyi of euticals.

【0003】また本発明で情報処理の手法として用いて
いるART(ART1, ART2, Fuzzy ARTを含む)はニューラルネ
ットワークの分野では公知である。例えば G. A. Carpe
nter et al.(Neural Networks. Vol. 4, pp. 759-771,
1991)を参照されたい
[0003] ART (including ART1, ART2, Fuzzy ART) used as an information processing technique in the present invention is well known in the field of neural networks. For example, GA Carpe
nter et al. (Neural Networks. Vol. 4, pp. 759-771,
1991)

【0004】[0004]

【発明が解決しようとする課題】上記のクラスタリング
方法によっても遺伝子をその時系列発現プロファイルか
らクラスタリングすることが可能である。しかしながら
これらの方法ではクラスタリングの精度及び信頼性が充
分とはいえなかった。特に、クラスタリングに研究者や
オペレータの任意操作が介在するので、再現性の点に課
題があった。例えば、階層的クラスタリングにより得ら
れた系統樹において(図8参照)、線引きをどうするか
は研究者やオペレータに委ねられているので、その者の
主観の如何(主観の個人差)によっては異なる結果が生
れる可能性がある。
According to the above clustering method, genes can be clustered from their time-series expression profiles. However, the accuracy and reliability of clustering are not sufficient with these methods. In particular, since an arbitrary operation by a researcher or operator is involved in clustering, there is a problem in reproducibility. For example, in a phylogenetic tree obtained by hierarchical clustering (see Fig. 8), what to do with the drawing is left to the researcher or operator, so the results differ depending on the subject's subjectivity (individual differences in subjectivity). May be born.

【0005】[0005]

【課題を解決するための手段】本発明者らは上記の課題
を解決すべく鋭意検討を重ねた結果、この発明のクラス
タリング方法に想到した。即ち、複数の遺伝子の発現状
態の変化を解析し、該遺伝子をクラスタリングする方法
であって、前記遺伝子の発現状態の変化を表すシグナル
パターンを得るステップ、得られたシグナルパターンを
ARTの手法で処理するステップ、を含む遺伝子のクラス
タリング方法。
The present inventors have made intensive studies to solve the above-mentioned problems, and as a result, have arrived at the clustering method of the present invention. That is, a method of analyzing changes in the expression state of a plurality of genes and clustering the genes, wherein a step of obtaining a signal pattern representing the change in the expression state of the gene is performed.
A method of clustering genes, comprising the step of processing using the ART technique.

【0006】この発明のクラスタリング方法によれば、
複数の遺伝子の発現シグナルパターンをARTの手法で処
理するので、研究者やオペレータの任意判断を何ら経る
ことなくクラスタリングが行われる。従って、クラスタ
リングの再現性が向上する。また、後述の実施例によれ
ば、発現機能既知の遺伝子について本発明のクラスタリ
ングを実行したとき、従来のクラスタリング方法に比べ
てクラスタリング精度が向上することの確認ができた。
According to the clustering method of the present invention,
Since the expression signal patterns of multiple genes are processed by the ART method, clustering can be performed without any discretion of the researcher or operator. Therefore, reproducibility of clustering is improved. Further, according to the examples described below, it was confirmed that when the clustering of the present invention was performed on a gene whose expression function was known, the clustering accuracy was improved as compared with the conventional clustering method.

【0007】 〔発明の詳細な説明〕本発明において、複数の遺伝子は
DNAチップ(オリゴDNAチップ、DNAマイクロア
レイともいう)を用いて解析される。クラスタリングの
対象となる遺伝子(標的遺伝子)と相補的なオリゴヌク
レオチドがDNAチップ上にプローブとして固定されて
いる。このプローブはプレート上で直接合成してもよい
し、また予め調製しておいたDNAをプレート上へ固定
しても良い。クラスタリングの対象となる遺伝子の発現
状態を調べるために、その転写産物であるmRNA量が
測定される。mRNA量の測定にはmRNAを直接用い
ることができるのは勿論のこと、該mRNAに相補的な
cDNAを用いることができる。cDNAは公知の方法
により当該mRNAをい型として合成することができ
る。これら測定対象(標的分子)と相補的なオリゴヌク
レオチドが汎用的な方法で標識される。mRNAを標的
分子とする場合には、全RNAを抽出しこれを標識化し
て分析することもできる。標識方法としてはRI法と非
RI法があるが、非RI法を用いることが好ましい。非
RI法には蛍光標識法、ビオチン標識法、化学発光法等
が挙げられが、蛍光標識法が一般的である。蛍光物質と
しては、核酸の塩基部分と結合できるものであれば特に
限定されないが、シアニン色素(Cy DyeTMシリ
ーズのCy3やCy5等)、ローダミン6G試薬、N−
アセトキシーN2−アセチルアミノフルオレン及びその
ヨウ素誘導体などを用いることが出来る。
DETAILED DESCRIPTION OF THE INVENTION In the present invention, a plurality of genes are analyzed using a DNA chip (also referred to as an oligo DNA chip or a DNA microarray). Oligonucleotides complementary to the gene to be clustered (target gene) are immobilized as probes on a DNA chip. This probe may be synthesized directly on the plate, or DNA prepared in advance may be immobilized on the plate. In order to examine the expression state of the gene to be clustered, the amount of mRNA as a transcription product is measured. In measuring the amount of mRNA, not only can mRNA be used directly, but also cDNA complementary to the mRNA can be used. cDNA can be synthesized using the mRNA as a template by a known method. Oligonucleotides complementary to these measurement targets (target molecules) are labeled by a general-purpose method. When using mRNA as a target molecule, total RNA can be extracted, labeled, and analyzed. Labeling methods include the RI method and the non-RI method, and it is preferable to use the non-RI method. Examples of the non-RI method include a fluorescent labeling method, a biotin labeling method, and a chemiluminescent method, and the fluorescent labeling method is generally used. The fluorescent substance is not particularly limited as long as it can bind to the base portion of the nucleic acid. Cyanine dyes (such as Cy3 and Cy5 of the Cy DyeTM series), rhodamine 6G reagent, N-
Acetoxy-N2-acetylaminofluorene and its iodine derivative can be used.

【0008】例えば、蛍光標識を用いた場合には各プロ
ーブDNAにおける蛍光量を市販のDNAスキャニング
装置で測定することができる。各プローブポイントにお
ける標識量の時系列変化を捉えて標的遺伝子の発現シグ
ナルパターンとする。発現シグナルパターンは各プロー
ブポイントにおける標識量の変化(例えば蛍光強度の変
化)を直接モニタすることにより得ることも出来るが、
未発現のコントロール遺伝子における標識量と被験検遺
伝子のそれとの比をモニタリングして得ることが好まし
い。
For example, when a fluorescent label is used, the amount of fluorescence in each probe DNA can be measured with a commercially available DNA scanning device. A time-series change in the amount of label at each probe point is captured as an expression signal pattern of the target gene. The expression signal pattern can be obtained by directly monitoring a change in the amount of label (for example, a change in fluorescence intensity) at each probe point,
It is preferable that the ratio be obtained by monitoring the ratio between the labeling amount of the unexpressed control gene and that of the test test gene.

【0009】次に、本発明で用いるARTについて説明す
る。ARTはニューラルネットワークにおいて用いられる
学習法の一種である。その学習原理は、入力パターン
(入力ベクトル)に応じた内部パターン(内部ベクト
ル)を持つノード(カテゴリー)を形成し、各入力パタ
ーンを類似度が最も高いノードに分類するというもので
ある。ARTのなかで、実数値に対応したFuzzy ARTの学習
原理は次の通りである。 1:入力パターンと各ノードのパターンとを比較する。 2:最も類似度(T)が高いパターンを持つノードを次
の式Aにより選択する。 式A:T=(| I∧W |)/(α+| W |) I:入力ベクトル、W:内部ベクトル、|x|:xの絶対値和、
α:適当なパラメータ ∧:ファジィ論理積 3:入力パターンと選択されたノードのパターンとの類
似度(式2で定義)が許容範囲内(vigilanceの値=ρ
以上)であれば、入力パターンをそのノードに分類し、
そのノードのパターンを必要に応じて修正する。なお、
vigilanceとは警戒係数であり、これにより許容範囲が
定義される。 式B:(| I∧W |)/| I |≧ρ 4:入力パターンと選択されたノードのパターンとの類
似度が許容範囲外であれば、次に類似度の高いノードを
選び再び許容範囲内にあるか否かを比較する。 5:全てのノードについて3及び4の手順を繰返す。 6:全てのノードが条件を満たさない場合は、その入力
パターンに対応した新しいノードを形成する。 7:以下、全ての入力パターンがいずれかのノードに分
類されるまで1〜6を繰返す。
Next, the ART used in the present invention will be described. ART is a type of learning method used in neural networks. The learning principle is to form a node (category) having an internal pattern (internal vector) corresponding to an input pattern (input vector), and classify each input pattern into a node having the highest similarity. The learning principle of Fuzzy ART corresponding to real values in ART is as follows. 1: The input pattern is compared with the pattern of each node. 2: A node having a pattern having the highest similarity (T) is selected by the following expression A. Formula A: T = (| I∧W |) / (α + | W |) I: input vector, W: internal vector, | x |: sum of absolute values of x,
α: Appropriate parameter ∧: Fuzzy logical product 3: Similarity between the input pattern and the pattern of the selected node (defined by Equation 2) is within the allowable range (vigilance value = ρ
Above), classify the input pattern into that node,
Modify the pattern of the node as needed. In addition,
Vigilance is a vigilance coefficient, which defines an acceptable range. Formula B: (| I∧W |) / | I | ≧ ρ4: If the similarity between the input pattern and the pattern of the selected node is out of the allowable range, the node having the next higher similarity is selected and allowed again. Compare whether it is within the range. 5: Repeat steps 3 and 4 for all nodes. 6: If all the nodes do not satisfy the condition, a new node corresponding to the input pattern is formed. 7: Hereinafter, steps 1 to 6 are repeated until all the input patterns are classified into any of the nodes.

【0010】[0010]

【実施例】以下、この発明の実施例について説明する。
この実施例では、出芽酵母(Saccharomyces cerevisia
e)の野生株(Wild-type)(strain SK1)について検討
を行った。この酵母の胞子形成過程においてタンパク質
をコードする6118個の遺伝子の発現パターンについ
ては既に研究報告がなされている。S.Chu et al., The
transcriptional program of sporulation in budding
yeast, Science 282, 699-705 (1998)を参考されたい。
当該6118個の遺伝子についての発現パターンはスタ
ンフォード大学のサイトから入手できる(hhtp:/
/cmgm.stanford.edu/UBRWWN/参
照)。この実施例は上記の既知の遺伝子の発現パターン
についてFuzzy ARTを実行してクラスタリングを行い、
得られた結果を上記研究報告と比較するものである。ま
た、階層的クラスタリング方法など従来から知られてい
る方法も比較例として実行してみた。
Embodiments of the present invention will be described below.
In this example, budding yeast (Saccharomyces cerevisia) was used.
e) The wild type (Wild-type) (strain SK1) was examined. Research reports have already been made on the expression patterns of 6118 genes encoding proteins in the process of sporulation of yeast. S. Chu et al., The
transcriptional program of sporulation in budding
See yeast, Science 282, 699-705 (1998).
Expression patterns for the 6118 genes are available from the Stanford University site (http: //
/ Cmgm. stanford. edu / UBRWWN /). In this example, clustering is performed by executing Fuzzy ART on the expression pattern of the above-described known gene,
The results obtained are compared with the above research reports. A conventionally known method such as a hierarchical clustering method was also executed as a comparative example.

【0011】まず、約6400個の異なる遺伝子(上記
6118個の各遺伝子を含む)のcDNAをプローブと
したDNAチップを自作した。他方、酵母を窒素欠損培
地(sporulation medium, SPM)に移し、胞子形成を誘
導した。なお、この時間をt=0とする。そして、時系
列的に7点(t=0,0.5,2.0,5.0,7.0,9.0,11.5、
単位:時間)で菌体をサンプリングし、mRNAを精製
しcy5で赤色に標識した。なお、誘導培地へ移す直前
の菌体のmRNAをコントロールとしてcy3で緑色に
標識した。得られた標的mRNAをハイブリダイゼーシ
ョンさせたDNAチップを、自作したレーザー顕微鏡で読
みとり、各プローブにおけるcy5とcy3の蛍光量を
比較した。
First, a DNA chip was prepared by using cDNAs of about 6400 different genes (including the above 6118 genes) as probes. On the other hand, yeast was transferred to a nitrogen deficient medium (Sporulation medium, SPM) to induce sporulation. This time is assumed to be t = 0. Then, seven points in time series (t = 0, 0.5, 2.0, 5.0, 7.0, 9.0, 11.5,
The cells were sampled in (unit: time), the mRNA was purified, and labeled with cy5 in red. The mRNA of the cells immediately before transfer to the induction medium was labeled green with cy3 as a control. The obtained DNA chip on which the target mRNA was hybridized was read with a laser microscope made by itself, and the amounts of fluorescence of cy5 and cy3 of each probe were compared.

【0012】各プローブにおける発現比率Rtを(サン
プリング値の蛍光量)/(コントロールの蛍光量)とし
て定義し、
The expression ratio Rt of each probe is defined as (fluorescence amount of sampling value) / (fluorescence amount of control),

【式1】 の関係を基準として遺伝子を分類したところ、当該関係
を満たすもの、即ちmRNAの発現レベルにおいて著し
い変化の認められたものが1148遺伝子あった。この
うちの522遺伝子が発現誘導、残りが発現抑制された
ものであった。
(Equation 1) When the genes were classified based on the relationship, there were 1148 genes satisfying the relationship, that is, those having a marked change in the mRNA expression level. Of these, 522 genes were expression-induced, and the rest were genes whose expression was suppressed.

【0013】発現誘導された522遺伝子のうち、胞子
形成過程での機能が解明されている45個の遺伝子(図
1のTable 1参照)に関してその発現パターン(発現比
率Rtの時系列変化)をFuzzy ARTでクラスタリング処
理した。なお、Table 1において"Time of expression"
は、胞子形成過程のどの時期に特異的に発現するかを示
したものである。発現時期が不明な遺伝子は空欄として
ある。ここで使用したFuzzy ARTのソースコードを発明
の詳細な説明の欄の最後に記載したので参照されたい。
Fuzzy ARTによるクラスタリングの結果を図2のtable 2
に示す。実施例のFuzzy ARTを実行する際の許容範囲はV
igilanceが0.9以上とした。Vigilanceの値が高いほど、
ノードの内部ベクトルと、そのノードに分類された入力
ベクトルの類似度は高くなる。発現パターンが選択され
たノードのパターンの許容範囲内にあるとき、当該発現
パターンは当該選択されたノードに分類されることとな
るが、そのときノードのパターンを発現パターンに基づ
き式Cによって修正する。学習係数(β)は0.001とし
た。 式C:W‘=β(W∧I)+(1-β)W β:学習係数 公知のソフト(EXCEL多変量解析 Ver.4.0、株式会社エ
スミ)に基づき階層的クラスタリング法を実行したとき
の結果及び公知のソフト(cluster: http://rana.lbl.g
ov/)基づきk-meansクラスタリング法を実行したときの
結果も併せて図2に示されている。
Among the 522 genes whose expression was induced, the expression pattern (time-series change in the expression ratio Rt) of 45 genes (see Table 1 in FIG. 1) whose functions in the sporulation process were elucidated was determined by Fuzzy. Clustered with ART. In Table 1, "Time of expression"
Shows at what time during the sporulation process it is specifically expressed. Genes whose expression time is unknown are blank. Please refer to the source code of Fuzzy ART used at the end of the detailed description of the invention.
The result of clustering by Fuzzy ART is shown in table 2 in Fig. 2.
Shown in The allowable range when executing the Fuzzy ART of the embodiment is V
The igilance was set to 0.9 or more. The higher the value of Vigilance,
The similarity between the internal vector of the node and the input vector classified into the node is high. When the expression pattern is within the permissible range of the pattern of the selected node, the expression pattern is classified into the selected node. At that time, the pattern of the node is modified by Expression C based on the expression pattern. . The learning coefficient (β) was set to 0.001. Formula C: W ′ = β (W∧I) + (1-β) W β: Learning coefficient When the hierarchical clustering method is executed based on known software (EXCEL multivariate analysis Ver.4.0, ESMI Corporation) Results and known software (cluster: http: //rana.lbl.g
FIG. 2 also shows the result when the k-means clustering method is executed based on ov /).

【0014】Fuzzy ARTを実行した結果得られた各ノー
ドのパターン(内部ベクトル)を図3〜図7に折れ線グ
ラフ(太線)で示した。なお、ノードのパターンは本来
ベクトル表示されるものであり、本件では7次元ベクト
ルとなるので2次元の紙面にその全てを表記することは
不可能である。図3〜図7はノードのパターンを出来る
限り視覚的イメージとして把握出来るように折れ線グラ
フにまとめたものである。なお、図3〜図7には各ノー
ドに分類された各遺伝子の発現パターンも併せて記載さ
れている。他方、図8には比較例としての階層的クラス
タリングで得られた系統樹を示した。
The pattern (internal vector) of each node obtained as a result of executing the Fuzzy ART is shown by a line graph (thick line) in FIGS. Note that the node pattern is originally displayed as a vector, and in the present case, it is a seven-dimensional vector, so that it is impossible to write all of the node pattern on a two-dimensional paper. FIG. 3 to FIG. 7 are summarized in line graphs so that the node patterns can be grasped as visually as possible. 3 to 7 also show the expression patterns of each gene classified into each node. On the other hand, FIG. 8 shows a phylogenetic tree obtained by hierarchical clustering as a comparative example.

【0015】図2の結果より、比較例である階層的クラ
スタリングやk-meansクラスタリングを実行して得た分
類に比べ、実施例のFuzzy ARTによるクラスタリングを
実行して得た分類は、発現時期との関係において、精度
よく遺伝子を分類できていることがわかる。即ち、Fuzz
y ARTによるクラスタリングを実行することにより、発
現時期において"Early", "Mid-Late", "Late"の遺伝子
がそれぞれ同じ"Time of expression"の遺伝子ごとに分
類された。比較例である階層的クラスタリングやk-mean
sクラスタリングを実行しても分離不能であった"Mid-La
te"遺伝子群をFuzzy ARTによるクラスタリングでは分類
できた。全ての分類手法において"Middle"遺伝子は他
の"Time of expression"遺伝子と分類され、"Middle"遺
伝子同士での分類は見られなかったことから、SPO12遺
伝子はより"Early"型に近く、SPS1遺伝子はより"Late"
型に近いと考えられる。
From the results shown in FIG. 2, the classification obtained by executing the clustering by the Fuzzy ART of the embodiment is different from the classification obtained by performing the hierarchical clustering and the k-means clustering as the comparative examples. It can be seen that the gene can be classified with high accuracy in the relationship of. That is, Fuzz
By performing clustering by y ART, the genes of "Early", "Mid-Late", and "Late" were classified into genes of the same "Time of expression" at the expression time. Comparative examples of hierarchical clustering and k-mean
"Mid-La was inseparable even after performing s clustering
The "te" gene group was classified by Fuzzy ART clustering. In all classification methods, the "Middle" gene was classified as another "Time of expression" gene, and no classification was found between "Middle" genes. Therefore, the SPO12 gene is closer to the "Early" type, and the SPS1 gene is more "Late"
It is considered to be close to the type.

【0016】図9はこの実施例のクラスタリング方法を
実行するためのデータ処理システムを示すブロック図で
ある。このシステムのハードウエアの構成は、一般的な
PCと同様に中央制御装置1に対してシステムバス2を
介して各種の要素が結合されたものである。中央制御装
置1は汎用的なCPU、メモリ制御装置、バス制御装
置、割り込み制御装置更にはDMA(直接メモリアクセ
ス)装置を含み、システムバス2もデータライン、アド
レスライン、制御ラインを含む。システムバス2にはR
AM(ランダムアクセスメモリ)3、不揮発メモリ(R
OM4,CMOS−RAM5等)からなるメモリ回路が
接続されている。RAM3には中央制御装置1や他のハ
ードウエア要素によって読み取られたり、書き換えられ
たりする。不揮発メモリのデータは読み取り専用であ
り、装置をオフとしたときにもそこのデータは喪失され
ない。このハードウエアを制御するシステムプログラム
はハードディスク装置7に保存されており、また、RA
M3に保存されており、ディスクドライブ制御装置6を
介して適宜中央制御装置1に読みこまれて使用される。
このハードディスク装置7には、また各種のデータ処理
を実行するアプリケーションフログラムも保存される。
また、このハードディスク装置7の所定の区域に発現パ
ターンのデータが保存される。
FIG. 9 is a block diagram showing a data processing system for executing the clustering method of this embodiment. The hardware configuration of this system is such that various elements are connected to a central control unit 1 via a system bus 2 as in a general PC. The central controller 1 includes a general-purpose CPU, a memory controller, a bus controller, an interrupt controller, and a DMA (direct memory access) device. The system bus 2 also includes data lines, address lines, and control lines. The system bus 2 has R
AM (random access memory) 3, nonvolatile memory (R
OM4, CMOS-RAM5, etc.). The RAM 3 is read and rewritten by the central controller 1 and other hardware elements. The data in the non-volatile memory is read-only and will not be lost when the device is turned off. A system program for controlling this hardware is stored in the hard disk device 7, and the RA
It is stored in M3 and is read and used by the central controller 1 via the disk drive controller 6 as needed.
The hard disk device 7 also stores application programs for executing various data processing.
The expression pattern data is stored in a predetermined area of the hard disk device 7.

【0017】システムバス2には、フロッピディスク1
2に対してデータの読み込み及び書き込みを行うフロッ
ピドライブ制御装置11、コンパクトディスク14に対
してそれからデータの読み取りを行うCD−ROM制御
装置13が接続されている。この実施例では直列制御装
置15にスキャナ(DNAスキャニング装置)16、並
列制御装置17にプリンタ18を接続させている。これ
らの制御装置15、17は複数の要素の接続を可能とす
るものであり、任意の要素をこれらに接続することがで
きる。システムバス2にはキーボード・マウス制御装置
21が接続され、キーボード22及びマウス23からの
データ入力を可能としている。モニタ25がモニタ制御
装置24を介してシステムバス2に接続されている。モ
ニタ25にはCRTタイプ、液晶タイプ、プラズマディ
スプレイタイプなどを利用することができる。各種の要
素(モデムなど)の増設を可能とするため空きのスロッ
ト31が準備されている。
The system bus 2 has a floppy disk 1
2, a floppy drive controller 11 for reading and writing data from and a CD-ROM controller 13 for reading data from the compact disk 14 are connected. In this embodiment, a scanner (DNA scanning device) 16 is connected to the serial control device 15 and a printer 18 is connected to the parallel control device 17. These control devices 15 and 17 enable connection of a plurality of elements, and arbitrary elements can be connected to them. A keyboard / mouse controller 21 is connected to the system bus 2 to enable data input from the keyboard 22 and the mouse 23. A monitor 25 is connected to the system bus 2 via the monitor control device 24. As the monitor 25, a CRT type, a liquid crystal type, a plasma display type, or the like can be used. An empty slot 31 is prepared to enable the addition of various elements (such as a modem).

【0018】実施例のシステムはネットワークアダプタ
41を介して、ネットワーク42に接続される。このネ
ットワーク(イントラネット)42にはクライアント4
3となる他のシステムが連結されている。各クライアン
ト43のシステム構成も実質的に図9と同様である。ま
た、このネットワーク42はファイヤーウォールを介し
て外部のインターネットに接続される。
The system of the embodiment is connected to a network 42 via a network adapter 41. This network (intranet) 42 has a client 4
The other three systems are connected. The system configuration of each client 43 is also substantially the same as in FIG. The network 42 is connected to an external Internet via a firewall.

【0019】実施例のシステムを稼動させるために必要
なプログラム(OSプログラム、アプリケーションプロ
グラム(本発明のものも含む))は、各種の媒体を介し
てシステムの中にインストールされる。例えば非書き込
み記録媒体(CD−ROM、ROMカード等)、書き込
み可能記録媒体(FD、DVD等)、更にはネットワー
ク42を利用して通信媒体の形式でインストールするこ
とも可能である。勿論、不揮発メモリ4、5やハードデ
ィスク装置7に予めこれらのプログラムを書きこんでお
くこともできる。
Programs (OS programs and application programs (including those of the present invention)) necessary for operating the system of the embodiment are installed in the system via various media. For example, a non-writable recording medium (CD-ROM, ROM card, or the like), a writable recording medium (FD, DVD, or the like), or a communication medium using the network 42 can be installed. Of course, these programs can be written in the nonvolatile memories 4 and 5 and the hard disk device 7 in advance.

【0020】上記において、クラスタリングを実行する
ためのプログラムはハードディスク7に保存されてい
る。サンプリングされた菌体のmRNAはDANチップ
に対して常法に基づきハイブリダイズされた後、DNA
スキャニング装置16にかけられてDNAチップの各プ
ローブにおける蛍光量が一旦ハードディスク7に保存さ
れる。他方、コントロールにおけるそれもハードディス
クに7に保存される。そして、両者を呼び出して上記各
式の演算を実行するプログラムも同様にPCのメモリに
保存されている。実施例のARTを実行するためのプログ
ラムはCD−ROM等の記録媒体に保存することが出来
る。また、インターネット等を介して他のコンピュータ
装置に移転することもできる。
In the above, a program for executing clustering is stored on the hard disk 7. The sampled mRNA of the cells is hybridized to the DNA chip based on a conventional method,
The amount of fluorescence at each probe of the DNA chip is temporarily stored in the hard disk 7 by the scanning device 16. On the other hand, that in the control is also stored in the hard disk 7. A program that calls both of them to execute the operations of the above equations is also stored in the memory of the PC. A program for executing the ART of the embodiment can be stored in a recording medium such as a CD-ROM. Further, the data can be transferred to another computer device via the Internet or the like.

【0021】この発明は、上記発明の実施の形態及び実
施例の説明に何ら限定されるものではない。特許請求の
範囲の記載を逸脱せず、当業者が容易に想到できる範囲
で種々の変形態様もこの発明に含まれる。実施例では遺
伝子の発現状態の時系列変化を解析対象としたが、時間
以外のパラメータに基づいて遺伝子のプロファイル(シ
グナルパターン)が得られれば、これについても本発明
を適用してそのクラスタリングを行うことが可能であ
る。
The present invention is not at all limited to the description of the above-described embodiments and examples. Various modifications are included in the present invention without departing from the scope of the claims and within the scope of those skilled in the art. In the example, the time series change of the expression state of the gene was analyzed. However, if a gene profile (signal pattern) can be obtained based on a parameter other than time, the clustering is performed by applying the present invention. It is possible.

【0022】実施例のFuzzy ARTのソースプログラムは
次の通りである。 /* Written By: Lars H. Liden&#9;Last Update: 8/02/95&#9;*/ /*&#9;arranged by&#9;: Shuta Tomida&#9;&#9;: June/28/2000&#9;*/ //ここからDef.h #include <math.h> #include <stdio.h> #include <stddef.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <errno.h> #define TRUE 5571 /* An unlikely number */ #define FALSE 0 #define ALPHA 0.1 #define ART 0 #define ARTA 1 #define ARTB 2 #define ARTMAP 1 #define NONE 0 #define ART1 1 #define FUZZYART 2 #define COMPLIMENT 1 #define BINARY 1 #define ANALOG 2 #define MAX 25 char pattern_name[80]; /* ===================================================================== ==== */ /* Neural Network Structures */ /* ===================================================================== ==== */ /*---------------------------------------------------------------------- -----*/ /* Art Network Structure */ /*---------------------------------------------------------------------- -----*/ typedef struct { int type; /* ART1, FUZZYART, NONE */ int style; /* NONE or COMPLIMENT */ int num_inputs; /* Number of inputs to the network */ int nodes_used; /* Num. of category nodes actually used */ int max_nodes; /* Current number of allocated category nodes */ float beta; /* Recoding rate. No recoding (default) when 1 */ float vigil; /* Current vigilence level */ int num_reset; /* Number of resets during last input presentation */ int win_cat; /* Winning category for last input presenation */ float *cat; /* Activation of category node (size max_nodes) */ float *elig; /* Eligibility of category node (size max_nodes) */ int *commit; /* Commitment of category node (size max_nodes) */ float **weight; /* Weights intput->cat (size num_inputs*max_nodes) */ float *sum_weights; /* Sum of weights for each nodes (size max_nodes) */ float *sum_IW; /* Intesection weights and inputs (size max_nodes) */ } artTYPE, *artPTR; /*---------------------------------------------------------------------- -----*/ /* ArtMap Network Structure */ /*---------------------------------------------------------------------- -----*/ typedef struct { float vigil; /* Current mapfield vigilence level */ float base_vigil; /* Base vigilence level for the ArtA Network */ int num_mismatch; /* Number of mismatches during an presentation */ artTYPE artA; /* ArtA - Input art network */ artTYPE artB; /* ArtB - Output art network */ int maxA_nodes; /* Maximum number of allocated ArtA nodes */ int maxB_nodes; /* Maximum number of allocated ArtB nodes */ float *map; /* Activation values of the mapfield (size B) */ float **map_weight; /* weights from A nodes to mapfield (size A x B) */ } mapTYPE, *mapPTR; /*---------------------------------------------------------------------- -----*/ /* General Network Structure */ /*---------------------------------------------------------------------- -----*/ typedef struct { int initB; /* Has the network been initialized - BOOLEAN */ int checkB; /* Has the net been tested against the set */ int doneB; /* Is the network done with recent training */ int type; /* ART, ARTMAP */ int num_inputs; /* Number of inputs to the network */ int num_outputs; /* Number of outputs from the network */ artTYPE art; /* Art Network - only used if type ART */ mapTYPE map; /* Mapping Field - only used if type ARTMAP */ /* Some history about network training */ int num_patterns; /* Number of training presentations so far */ int num_epochs; /* Number of training epochs so far */ } netTYPE, *netPTR; /* ===================================================================== ==== */ /* Pattern Structure */ /* ===================================================================== ==== */ /*---------------------------------------------------------------------- -----*/ /* Single Pattern Structure */ /*---------------------------------------------------------------------- -----*/ typedef struct { float *input; /* Vector of input patterns (size num_inputs) */ float *output; /* Vector out output patterns (size num_outputs) */ } patTYPE, *patPTR; /*---------------------------------------------------------------------- -----*/ /* Pattern Set Structure */ /*---------------------------------------------------------------------- -----*/ typedef struct { int initB; /* Has the set been initialized - BOOLEAN */ int checkB; /* Has the set been tested against the net */ int max_num_patterns; /* Total space allocated for patterns */ int num_patterns; /* Current number of patterns in the set */ int num_inputs; /* Size of input patterns */ int type_inputs; /* BINARY or ANALOG */ int style_inputs; /* Are inputs currently compliment coded */ int num_outputs; /* Size of output patterns */ int type_outputs; /* BINARY, ANALOG or NONE */ int style_outputs; /* Are inputs currently compliment coded */ patTYPE *pattern; /* Individual patterns (size max_num_pat) */ } setTYPE, *setPTR; //ここからInt.c float Intersect(float x, float y, int type) { if ((type==ART1)||(type==NONE)) return x*y; else { /* if (type==FUZZYART) */ if (x>y) return y; else return x; } } float FuzzInt(float x, float y) { if (x>y) return y; else return x; } float FuzzUni(float x, float y) { if (x>y) return x; else return y; } int BinToInt (patPTR pat,int num_outputs) { int i,position; position=0; for (i=0;i<num_outputs;i++) position+=(*(pat->output+i)) * pow(2,i); return position; } void IntToBin (int num_outputs,int position, int *output_list) { int i,j; for (i=(num_outputs-1);i>-1;i--) { j=pow(2,i); if (position>=j) { *(output_list+i)=1; position-=j; } else *(output_list+i)=0; } } int InitArt(artPTR art, int type, int style, int num_inputs) { int i,j; art->type = type; art->num_inputs = num_inputs; if (type==NONE) { art->nodes_used = num_inputs; /* Inputs just copied so number of */ art->max_nodes = num_inputs; /* categories is a constant. */ art->cat=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->cat==NULL) return 1; art->style = NONE; } else { art->style = style; art->nodes_used = 0; /* All categories are currently unused */ art->max_nodes = MAX; /* Starting number of available categories */ art->beta = 1; /* No recoding */ art->vigil = 0; art->num_reset = 0; art->cat=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->cat==NULL) return 1; art->elig=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->elig==NULL) return 1; art->commit=(int *)malloc((size_t) (art->max_nodes*sizeof(int))); if (art->commit==NULL) return 1; art->weight=(float **)malloc((size_t) (art->max_nodes*sizeof(float*))); if (art->weight==NULL) return 1; art->weight[0]=(float *)malloc((size_t) ((art->max_nodes*art->num_inputs )*sizeof(float))); if (art->weight[0]==NULL) return 1; for(i=1;i<art->max_nodes;i++) art->weight[i]=art->weight[i-1]+art->num_inputs; art->sum_weights=(float *)malloc((size_t) (art->max_nodes*sizeof(float)) ); if (art->sum_weights==NULL) return 1; art->sum_IW=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->sum_IW==NULL) return 1; /* Set Initial Weight Values */ for (i=0;i<art->max_nodes;i++) for (j=0;j<art->num_inputs;j++) &#9;*(*(art->weight+i)+j)=1; /* Calculate initial weight sums */ for (i=0;i<art->max_nodes;i++) { *(art->sum_weights+i)=0; for (j=0;j<art->num_inputs;j++) &#9;*(art->sum_weights+i)+=(*(*(art->weight+i)+j)); } /* Set Initial Commitments to false */ for (i=0;i<art->max_nodes;i++) *(art->commit+i)=FALSE; } return 0; } int InitMap(mapPTR map, int typeA, int styleA, int typeB, int styleB, &#9; int num_inputs, int num_outputs) { int i,j; map->vigil = 1; /* Require perfect mapfield match */ map->base_vigil = 0; map->num_mismatch = 0; /* Initialize Art Networks */ if (InitArt(&map->artA,typeA,styleA,num_inputs)) return 1; if (InitArt(&map->artB,typeB,styleB,num_outputs)) return 1; map->maxA_nodes = map->artA.max_nodes; map->maxB_nodes = map->artB.max_nodes; /* Allocate space for map and weights */ map->map=(float *)malloc((size_t) (map->artB.max_nodes*sizeof(float))); if (map->map==NULL) return 1; map->map_weight=(float **)malloc((size_t) (map->artA.max_nodes*sizeof(fl oat*))); if (map->map_weight==NULL) return 1; map->map_weight[0]=(float *)malloc((size_t) ((map->artA.max_nodes*map->a rtB.max_nodes)*sizeof(float))); if (map->map_weight[0]==NULL) return 1; for(i=1;i<map->artA.max_nodes;i++) map->map_weight[i]=map->map_weight[i-1]+map->artB.max_nodes; /* Set Initial Map Field Weight Values */ for (i=0;i<map->artA.max_nodes;i++) { for (j=0;j<map->artB.max_nodes;j++) *(*(map->map_weight+i)+j)=1; } return 0; } int Compliment(setTYPE *set, int input_style, int output_style) { float *tempflt; int i,j; /* If compliment coding is requested of the input patterns */ if (input_style==COMPLIMENT) { /* Allocate space for compliment coded inputs and copy old inputs */ for (j=0;j<set->num_patterns;j++) { tempflt=(float *)malloc((size_t) ((2*set->num_inputs)*sizeof(float))); if (tempflt==NULL) return 1; for (i=0;i<set->num_inputs;i++) *(tempflt+i)=*(set->pattern[j].input+i); free(set->pattern[j].input); set->pattern[j].input = tempflt; /* Complement coding input patterns in new space */ for (i=0;i<set->num_inputs;i++) &#9;*(set->pattern[j].input+(i+set->num_inputs))=(1-(*(set->pattern[j].i nput+i))); } set->style_inputs = COMPLIMENT; } /* If compliment coding is requested of the output patterns */ if (output_style==COMPLIMENT) { /* Allocate space for compliment coded outputs and copy old outputs */ for (j=0;j<set->num_patterns;j++) { tempflt=(float *)malloc((size_t) ((2*set->num_outputs)*sizeof(float))); if (tempflt==NULL) return 1; for (i=0;i<set->num_outputs;i++) *(tempflt+i)=*(set->pattern[j].output+i); free(set->pattern[j].output); set->pattern[j].output = tempflt; /* Complement coding output patterns in new space */ for (i=0;i<set->num_outputs;i++) &#9;*(set->pattern[j].output+(i+set->num_outputs))=(1-(*(set->pattern[j] .output+i))); } set->style_outputs = COMPLIMENT; } return 0; } patTYPE *AddPats(patTYPE *pat, int old_max, int new, &#9;&#9; int num_inputs, int num_outputs) { int i; patTYPE *temppat; /* Allocate space for new patterns */ temppat = (patTYPE *)malloc((size_t) &#9;&#9;&#9;&#9;((old_max+new)*sizeof(patTYPE))); if (temppat==NULL) return NULL; /* Allocate space for input/output vectors patterns */ for (i=0;i<(old_max+new);i++) { /* Number of set inputs are doubled for compliment coding */ temppat[i].input=(float *)malloc((size_t) ((num_inputs)*2*sizeof(float)) ); if (temppat[i].input==NULL) return NULL; if (num_outputs!=0) { temppat[i].output=(float *)malloc((size_t) (num_outputs*sizeof(float))); if (temppat[i].output==NULL) return NULL; } } /* Copy values into new array */&#9; for (i=0;i<old_max;i++) *(temppat+i)=*(pat+i); /* Free Old Space */ free(pat); return temppat; } int AddCats(artPTR art,int new_nodes) { int i,j; int *tempvint; /* Temporary pointer for copying */ float *tempvflt; /* Temporary pointer for copying */ float **tempflt; /* Temporary pointer for copying */ /* Allocate new space */ tempvflt=(float *)malloc((size_t) ((art->max_nodes+new_nodes)*sizeof(flo at))); if (tempvflt==NULL) return 1; for (i=0;i<art->max_nodes;i++) *(tempvflt+i)=*(art->cat+i); free(art->cat); art->cat = tempvflt; tempvflt=(float *)malloc((size_t) ((art->max_nodes+new_nodes)*sizeof(flo at))); if (tempvflt==NULL) return 1; for (i=0;i<art->max_nodes;i++) *(tempvflt+i)=*(art->elig+i); free(art->elig); art->elig = tempvflt; tempvint=(int *)malloc((size_t) ((art->max_nodes+new_nodes)*sizeof(int)) ); if (tempvint==NULL) return 1; for (i=0;i<art->max_nodes;i++) *(tempvint+i)=*(art->commit+i); free(art->commit); art->commit = tempvint; tempflt=(float **)malloc((size_t) (((art->max_nodes+new_nodes))*sizeof(f loat*))); if (tempflt==NULL) return 1; tempflt[0]=(float *)malloc((size_t) (((art->max_nodes+new_nodes)*art->nu m_inputs)*sizeof(float))); if (tempflt[0]==NULL) return 1; for(i=1;i<(art->max_nodes+new_nodes);i++) tempflt[i]=tempflt[i-1]+art->num_inputs; for (i=0;i<art->max_nodes;i++) for (j=0;j<art->num_inputs;j++) *(*(tempflt+i)+j)=*(*(art->weight+i)+j); free(art->weight[0]); free(art->weight); art->weight = tempflt; tempvflt=(float *)malloc((size_t) ((art->max_nodes+new_nodes)*sizeof(flo at))); if (tempvflt==NULL) return 1; for (i=0;i<art->max_nodes;i++) *(tempvflt+i)=*(art->sum_weights+i); free(art->sum_weights); art->sum_weights = tempvflt; tempvflt=(float *)malloc((size_t) ((art->max_nodes+new_nodes)*sizeof(flo at))); if (tempvflt==NULL) return 1; for (i=0;i<art->max_nodes;i++) *(tempvflt+i)=*(art->sum_IW+i); free(art->sum_IW); art->sum_IW = tempvflt; /* Set Initial Weight Values for new weights */ for (i=art->max_nodes;i<(art->max_nodes+new_nodes);i++) for (j=0;j<art->num_inputs;j++) *(*(art->weight+i)+j)=1; /* Set Initial Commitments of new nodes to false */ for (i=art->max_nodes;i<(art->max_nodes+new_nodes);i++) *(art->commit+i)=FALSE; /* Calculate initial weight sums for new nodes */ for (i=art->max_nodes;i<(art->max_nodes+new_nodes);i++) { *(art->sum_weights+i)=0; for (j=0;j<art->num_inputs;j++) *(art->sum_weights+i)+=(*(*(art->weight+i)+j)); } /* Update number of available nodes */ art->max_nodes=art->max_nodes+new_nodes; return 0; } int AddMaps(mapPTR map) { float *tempfltv; /* Temporary pointer for copying */ float **tempflt; /* Temporary pointer for copying */ int i,j; /* Counters */ /* Allocate new space */ tempflt=(float **)malloc((size_t) ((map->artA.max_nodes)*sizeof(float*)) ); if (tempflt==NULL) return 1; tempflt[0]=(float *)malloc((size_t) ((map->artA.max_nodes*map->artB.max_ nodes)*sizeof(float))); if (tempflt[0]==NULL) return 1; for(i=1;i<map->artA.max_nodes;i++) tempflt[i]=tempflt[i-1]+map->artB.max_nodes; for (i=0;i<map->maxA_nodes;i++) for (j=0;j<map->maxB_nodes;j++) *(*(tempflt+i)+j)=*(*(map->map_weight+i)+j); free(map->map_weight[0]); free(map->map_weight); map->map_weight=tempflt; tempfltv=(float *)malloc((size_t) (map->artB.max_nodes*sizeof(float))); if (tempfltv==NULL) return 1; for (i=0;i<map->maxB_nodes;i++) *(tempfltv+i)=*(map->map+i); free(map->map); map->map = tempfltv; /* Set initial weights of all new mapfield nodes */ for (i=map->maxA_nodes;i<(map->artA.max_nodes);i++) for (j=0;j<map->artB.max_nodes;j++) *(*(map->map_weight+i)+j)=1; for (i=0;i<map->artA.max_nodes;i++) for (j=map->maxB_nodes;j<(map->artB.max_nodes);j++) *(*(map->map_weight+i)+j)=1; /* Update mapfield values */ map->maxA_nodes = map->artA.max_nodes; map->maxB_nodes = map->artB.max_nodes; return 0; } int CheckPattern (setPTR set, int num_inputs, float *input, int num_outp uts, &#9; float *output) { int i; int zero_flag; /* Check size of input/output patterns */ if (set->num_inputs!=num_inputs) return 1; if ((set->type_outputs!=NONE)&&(set->num_outputs!=num_outputs)) return 1 ; /* Check Input for ANALOG pattern in BINARY set */ if (set->type_inputs==BINARY) for (i=0;i<num_inputs;i++) if (((*(input+i))!=1.0)&&((*(input+i))!=0.0)) return 2; /* Check Input for improperly bounded ANALOG patterns */ if (set->type_inputs==ANALOG) for (i=0;i<num_inputs;i++) if (((*(input+i))>1.0)||((*(input+i))<0.0)) return 3; /* Check Output for ANALOG pattern in BINARY set */ if (set->type_outputs==BINARY) for (i=0;i<num_outputs;i++) if (((*(output+i))!=1.0)&&((*(output+i))!=0.0)) return 2; /* Check Output for improperly bounded ANALOG patterns */ if (set->type_outputs==ANALOG) for (i=0;i<num_outputs;i++) if (((*(output+i))>1.0)||((*(output+i))<0.0)) return 3; /* Check That At Least One Input is Non-Zero */ zero_flag=TRUE; for (i=0;i<num_inputs;i++) if ((*(input+i))>0.0) zero_flag=FALSE; if (zero_flag) return 4; /* Check That At Least One Output is Non-Zero */ if (set->type_outputs!=NONE) { zero_flag=TRUE; for (i=0;i<num_outputs;i++) if ((*(output+i))>0.0) &#9;zero_flag=FALSE; if (zero_flag) return 4; } /* Everything appears to be ok */ return 0; } int LoadArt(artPTR art, FILE *LoadFile) { int temp_int; float temp_flt; int i,j; fscanf(LoadFile,"%i\n",&art->type); fscanf(LoadFile,"%i\n",&art->num_inputs); fscanf(LoadFile,"%i\n",&art->nodes_used); art->max_nodes = art->nodes_used; /* No unused nodes werre saved */ art->cat=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->cat==NULL) return 1; if (art->type!=NONE) { fscanf(LoadFile,"%i\n",&art->style); fscanf(LoadFile,"%f\n",&art->beta); fscanf(LoadFile,"%f\n",&art->vigil); art->num_reset = 0; /* Number Reset is zero */ /* Allocate space */ art->elig=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->elig==NULL) return 1; art->commit=(int *)malloc((size_t) (art->max_nodes*sizeof(int))); if (art->commit==NULL) return 1; art->weight=(float **)malloc((size_t) (art->max_nodes*sizeof(float*))); if (art->weight==NULL) return 1; art->weight[0]=(float *)malloc((size_t) ((art->max_nodes*art->num_inputs )*sizeof(float))); if (art->weight[0]==NULL) return 1; for(i=1;i<art->max_nodes;i++) art->weight[i]=art->weight[i-1]+art->num_inputs; art->sum_weights=(float *)malloc((size_t) (art->max_nodes*sizeof(float)) ); if (art->sum_weights==NULL) return 1; art->sum_IW=(float *)malloc((size_t) (art->max_nodes*sizeof(float))); if (art->sum_IW==NULL) return 1; /* Read in weights */ for (i=0;i<art->nodes_used;i++) { for (j=0;j<art->num_inputs;j++) { &#9;fscanf(LoadFile,"%f ",&temp_flt); &#9;*(*(art->weight+i)+j)=temp_flt; } fscanf(LoadFile,"\n"); } fscanf(LoadFile,"\n"); /* Re-Calculate initial weight sums */ for (i=0;i<art->max_nodes;i++) { *(art->sum_weights+i)=0; for (j=0;j<art->num_inputs;j++) &#9;*(art->sum_weights+i)+=(*(*(art->weight+i)+j)); } /* Set Initial Commitments of used nodes to true */ for (i=0;i<art->nodes_used;i++) *(art->commit+i)=TRUE; } return 0; } int LoadMap(mapPTR map, FILE *LoadFile) { int temp_int; float temp_flt; int i,j; fscanf(LoadFile,"%f\n",&map->vigil); fscanf(LoadFile,"%f\n",&map->base_vigil); map->num_mismatch = 0; /* No mismatches yet */ if (LoadArt(&map->artA,LoadFile)) return 1; if (LoadArt(&map->artB,LoadFile)) return 1; map->maxA_nodes = map->artA.max_nodes; map->maxB_nodes = map->artB.max_nodes; /* Allocate space */ map->map=(float *)malloc((size_t) (map->artB.max_nodes*sizeof(float))); if (map->map==NULL) return 1; map->map_weight=(float **)malloc((size_t) (map->artA.max_nodes*sizeof(fl oat*))); if (map->map_weight==NULL) return 1; map->map_weight[0]=(float *)malloc((size_t) ((map->artA.max_nodes*map->a rtB.max_nodes)*sizeof(float))); if (map->map_weight[0]==NULL) return 1; for(i=1;i<map->artA.max_nodes;i++) map->map_weight[i]=map->map_weight[i-1]+map->artB.max_nodes; /* Read in map weights */ for (i=0;i<map->maxA_nodes;i++) { for (j=0;j<map->maxB_nodes;j++) { fscanf(LoadFile,"%f ",&temp_flt); *(*(map->map_weight+i)+j)=temp_flt; } fscanf(LoadFile,"\n"); } fscanf(LoadFile,"\n"); return 0; } void SaveArt(artPTR art, FILE *SaveFile) { int i,j; fprintf(SaveFile,"%i\n",art->type); fprintf(SaveFile,"%i\n",art->num_inputs); fprintf(SaveFile,"%i\n",art->nodes_used); if (art->type!=NONE) { fprintf(SaveFile,"%i\n",art->style); fprintf(SaveFile,"%f\n",art->beta); fprintf(SaveFile,"%f\n",art->vigil); /* Save weights */ for (i=0;i<art->nodes_used;i++) { for (j=0;j<art->num_inputs;j++) &#9;fprintf(SaveFile,"%f ",(*(*(art->weight+i)+j))); fprintf(SaveFile,"\n"); } fprintf(SaveFile,"\n"); } } void SaveArt1(artPTR art, FILE *SaveFile) { int i,j; fprintf(SaveFile,"\nart->type\t%i\n",art->type); fprintf(SaveFile,"art->num_inputs\t%i\n",art->num_inputs); fprintf(SaveFile,"art->nodes_used\t%i\n",art->nodes_used); if (art->type!=NONE) { fprintf(SaveFile,"\nart->style\t%i\n",art->style); fprintf(SaveFile,"art->beta\t%f\n",art->beta); fprintf(SaveFile,"art->vigil\t%f\n\n",art->vigil); /* Save weights */ for (i=0;i<art->nodes_used;i++) &#9;{ &#9;&#9;fprintf(SaveFile,"node=%3d",i+1); &#9;&#9;for (j=0;j<art->num_inputs;j++)&#9;&#9;fprintf(SaveFile,"\t%f ", (*(*(art->weight+i)+j))); &#9;&#9;fprintf(SaveFile,"\n"); } fprintf(SaveFile,"\n"); } } void SaveMap(mapPTR map, FILE *SaveFile) { int i,j; fprintf(SaveFile,"%f\n",map->vigil); fprintf(SaveFile,"%f\n",map->base_vigil); SaveArt(&map->artA,SaveFile); SaveArt(&map->artB,SaveFile); /* Save map weights */ for (i=0;i<map->artA.nodes_used;i++) { for (j=0;j<map->artB.nodes_used;j++) fprintf(SaveFile,"%f ",(*(*(map->map_weight+i)+j))); fprintf(SaveFile,"\n"); } fprintf(SaveFile,"\n"); } void ActivateArt(artPTR art, float *input) { float sum_inputs; /* Sum of all the input patterns */ float max_cat; /* Largest category activation */ int win_cat; /* Category which wins the competition */ int matchB; /* Boolean to indicate when a match is found */ int num_elig; /* Number of eligible nodes left */ int i,j; /* Counters */ double ddd; /* --------------------- Check Type of Art Module ---------------------- - */ if (art->type == NONE) { &#9; /* If none, then category activation is just the input string ---- */ &#9; for (i=0;i<art->num_inputs;i++)&#9;*(art->cat+i)=(*(input+i)); &#9; return; } /* Check if there are any used nodes */ else if (art->nodes_used==0) { art->win_cat = -1; return; } else { /* ------- If art module, calculate output category activations ------- */ /* Initially all nodes are eligible to win the competition */ num_elig=art->nodes_used; for (i=0;i<art->nodes_used;i++)&#9;&#9;*(art->elig+i)=TRUE; /* Activate categories */ for (i=0;i<art->nodes_used;i++) { *(art->sum_IW+i)=0; for (j=0;j<art->num_inputs;j++) &#9; { &#9;&#9; /* NOTE: Intersection depends in art type. (Fuzzy or Art1) */ &#9;&#9; ddd=0.0; &#9;&#9; ddd=(*(*(art->weight+i)+j)); &#9;&#9; ddd=(*(input+j)); &#9;&#9; *(art->sum_IW+i)+=Intersect((*(*(art->weight+i)+j)),(*(input+j) ),art->type); &#9; } &#9;*(art->cat+i)=(*(art->elig+i))*((*(art->sum_IW+i))/(ALPHA+(*(art->su m_weights+i)))); ddd=0.0; &#9;ddd=*(art->elig+i); &#9;ddd=*(art->sum_IW+i); &#9;ddd=ALPHA; &#9;ddd=(ALPHA+(*(art->sum_weights+i))); &#9;ddd=*(art->cat+i); &#9;} matchB=FALSE; while (!matchB) { /* Find most activated category */ max_cat=0; win_cat=0; for (i=0;i<art->nodes_used;i++) &#9;if (((*(art->cat+i))>max_cat)&&((*(art->elig+i))!=0)) { &#9; max_cat=(*(art->cat+i)); &#9; win_cat=i; &#9;} /* Find the sum of the inputs */ /* When compliment coded, sum of inputs equal to half network inputs. */ if (art->style==COMPLIMENT) &#9;sum_inputs=(art->num_inputs)/2; else { &#9;sum_inputs=0; &#9;for (i=0;i<art->num_inputs;i++) &#9; sum_inputs+=(*(input+i)); } /* Test to see if winning category meets vigilence level */ &#9; ddd=0.0; &#9; ddd=(*(art->sum_IW+win_cat)); &#9; ddd=((*(art->sum_IW+win_cat))/sum_inputs); if (((*(art->sum_IW+win_cat))/sum_inputs)>=art->vigil) { &#9;/* If so, found a match */ &#9;matchB = TRUE; &#9;/* Set winner-take-all category activations */ &#9;for (i=0;i<art->nodes_used;i++) { &#9; if (i==win_cat) &#9; *(art->cat+i)=1; &#9; else &#9; *(art->cat+i)=0; &#9;} &#9;art->win_cat = win_cat; } else { &#9;/* Otherwise, node becomes ineligible */ &#9;*(art->elig+win_cat)=FALSE; &#9;art->num_reset++; &#9;num_elig--; &#9; &#9;/* Check if any nodes still eligible */ &#9;if (num_elig==0) { &#9; /* Return that no match found */ &#9; art->win_cat = -1; &#9; return; &#9;} } } } } int TrainArtPat(artPTR art, float *input) { &#9;double ddd; int i; /* Counter */ /* ------- Train Art Module with Fast Learning and Slow Recode --------- */ /* NOTE: Slow recode is eliminated if beta is set to one. */ /* When there was no winning category */ if (art->win_cat==-1) { art->win_cat=art->nodes_used; /* Winner becomes next unused node */ art->nodes_used++; /* Increment used nodes counter */ /* If hit the max number of allocated Art nodes */ /* Allocate more space for Art nodes */ if (art->nodes_used==art->max_nodes) if (AddCats(art,25)) return 1; *(art->commit+art->nodes_used)=TRUE; /* Note it as now used */ /* Set winner-take-all category activations */ for (i=0;i<art->nodes_used;i++) { if (i==art->win_cat) &#9;*(art->cat+i)=1; else &#9;*(art->cat+i)=0; } /* Fast learning for uncommited node. (beta = 1) */ for (i=0;i<art->num_inputs;i++) &#9;{ &#9;&#9;ddd=0.0; &#9;&#9;ddd=*(*(art->weight+art->win_cat)+i); &#9;&#9;ddd=(*(input+i)); &#9;&#9;*(*(art->weight+art->win_cat)+i)=Intersect((*(input+i)),(*(*(art ->weight+art->win_cat)+i)),art->type); &#9;&#9; &#9;} } else { /* Slow Recoding for commited node. (beta < 1) */ for (i=0;i<art->num_inputs;i++) *(*(art->weight+art->win_cat)+i)=((art->beta)*Intersect((*(input+i)),(*( *(art->weight+art->win_cat)+i)),art->type))+((1-(art->beta))*(*(*(art->w eight+art->win_cat)+i))); } /* Calculate Art weight sum for speeding up later calculations */ *(art->sum_weights+art->win_cat)=0; for (i=0;i<art->num_inputs;i++) *(art->sum_weights+art->win_cat)+=(*(*(art->weight+art->win_cat)+i)); return 0; } int TrainMapPat(mapPTR map, patPTR pat) { float sum_inputs; /* Sum of all the active inputs */ float sum_cat; /* Sum of all the active Art-B categories */ float sum_map; /* Sum of activations of map nodes */ int doneB; /* Boolean to signal when done with pattern */ int i,j; /* Counters */ /* -------------- First activate and train Art-B network --------------- */ /* Find winning Art-B category */ ActivateArt(&map->artB,pat->output); /* If Art-B not of type NONE train it */ if (map->artB.type!=NONE) { if (TrainArtPat(&map->artB,pat->output)) return 1; /* Check if TrainArtPat allocated new space for ArtB */ if (map->maxB_nodes!=map->artB.max_nodes) if (AddMaps(map)) return 1; } /* -------- Find an Art-A category that meets mapfield vigilence ------- - */ doneB = FALSE; /* Haven't found one yet */ map->artA.vigil = map->base_vigil; /* Reset vigilence to base level */ while (!doneB) { /* Find the winning category */ ActivateArt(&map->artA,pat->input); /* When no previously used Art-A node was able to win, a new Art-A node */ /* is created and trained on the mapfield */ if (map->artA.win_cat == -1) { /* Train New Unused Node in ArtA Module */ if (TrainArtPat(&map->artA,pat->input)) return 1; /* Train mapfield weights for new node */ for (i=0;i<map->artB.nodes_used;i++) &#9;*(*(map->map_weight+map->artA.win_cat)+i)=(*(map->artB.cat+i)); /* Check if TrainArtPat allocated new space for ArtA */ if (map->maxA_nodes!=map->artA.max_nodes) &#9;if (AddMaps(map)) return 1; doneB=TRUE; } /* Otherwise check map vigilence for the used node */ else { /* Calculate Mapfield Activations */ for (i=0;i<map->artB.nodes_used;i++) /* For each mapfield node */ &#9;*(map->map+i)=(*(*(map->map_weight+map->artA.win_cat)+i)); sum_map = 0; sum_cat = 0; for (i=0;i<map->artB.nodes_used;i++) { &#9;sum_map += FuzzInt((*(map->map+i)), &#9;&#9;&#9; (*(map->artB.cat+i))); &#9;sum_cat += FuzzUni((*(map->map+i)), &#9;&#9;&#9; (*(map->artB.cat+i))); } if (map->artB.type != NONE) &#9;sum_cat = 1; /* Calculate sum of inputs */ sum_inputs=0; /* Note: When compliment coded, */ for (i=0;i<map->artA.num_inputs;i++) /* sum of inputs is equal to */ &#9;sum_inputs+=(*(pat->input+i)); /* half the network inputs. */ /* Check vigilence at mapfield */ if ((sum_map/sum_cat)<map->vigil) { &#9;/* If mapfield mismatch then ArtA isn't done */ &#9;doneB=FALSE; &#9;/* Error causes increase in Art-A vigilence unless doing so exceeds */ &#9;/* the highest vigilence level. If this is the case, then mismatch * / &#9;/* was caused by inconsistent or noisy data so ignore and go on. */ &#9;map->artA.vigil=((*(map->artA.sum_IW+map->artA.win_cat))/sum_inputs) &#9;+0.0001; &#9;if (map->artA.vigil>1.0) &#9; doneB=TRUE; &#9;else &#9; map->num_mismatch++; } else { &#9;/* Train mapfield weights */ &#9;for (i=0;i<map->artB.nodes_used;i++) &#9;*(*(map->map_weight+map->artA.win_cat)+i)=(*(map->artB.cat+i)); &#9;/* Train ArtA Module */ if (TrainArtPat(&map->artA,pat->input)) return 1; &#9;/* Check if TrainArtPat allocated new space for ArtA */ if (map->maxA_nodes!=map->artA.max_nodes) &#9;if (AddMaps(map)) return 1; &#9;doneB=TRUE; } } } return 0; } int CheckNetSet(netPTR net, setPTR set) { if (net->type==ART) { /* Check Art Component Input Type Compatibility */ if ((net->art.type==ART1)&&(set->type_inputs==ANALOG)) return 3; if ((net->art.style==NONE)&& &#9;(net->num_inputs!=set->num_inputs)) return 4; if ((net->art.style==COMPLIMENT)&& &#9;(net->num_inputs!=2*(set->num_inputs))) return 4; /* Check if set data needs to be compliment coded */ if (Compliment(set,net->art.style,NONE)) return 7; } if (net->type==ARTMAP) { if ((net->map.artA.type==ART1)&&(set->type_inputs==ANALOG)) return 3; if ((net->map.artB.type==ART1)&&(set->type_outputs==ANALOG)) return 3; if (set->type_outputs==NONE) return 6; /* Check input size */ if ((net->map.artA.style==NONE)&& &#9;(net->num_inputs!=set->num_inputs)) return 4; if ((net->map.artA.style==COMPLIMENT)&& &#9;(net->num_inputs!=2*(set->num_inputs))) return 4; /* Check output size */ if ((net->map.artB.style==NONE)&& &#9;(net->num_outputs!=set->num_outputs)) return 5; if ((net->map.artB.style==COMPLIMENT)&& &#9;(net->num_outputs!=2*(set->num_outputs))) return 5; if ((net->map.artB.type==NONE)&& &#9;(net->num_outputs!=set->num_outputs)) return 5; /* Check if set data needs to be compliment coded */ if (Compliment(set,net->map.artA.style,net->map.artB.style)) return 7; } /* Everything looks ok, so mark as checked */ net->checkB = TRUE; set->checkB = TRUE; /* Training not done since either pattern set or network changed */ net->doneB = FALSE; return 0; } //ここから_ext.c int InitNet(netPTR net, int net_type, &#9; int componentA, int styleA, int num_inputs, int componentB, int styleB, int num_outputs) { if (net==NULL) return 7; /* Check if already initialized */ if (net->initB==TRUE) return 5; /* Check styles */ if ((styleA!=NONE)&&(styleA!=COMPLIMENT)) return 3; /* Check input size */ if (num_inputs<=0) return 4; net->checkB = FALSE; /* Hasn't been tested against the set */ net->doneB = FALSE; /* Training hasn't occured */ net->type = net_type; net->num_inputs = num_inputs; net->num_patterns = 0; /* No training yet, so all zero */ net->num_epochs = 0; if (net_type==ART) { /* First check validity of Art type */ if ((componentA!=ART1)&&(componentA!=FUZZYART)) return 2; net->num_outputs = 0; if (InitArt(&net->art,componentA,styleA,num_inputs)) return 6; net->initB = TRUE; /* The network has been initialized */ return 0; } else if (net_type==ARTMAP) { /* Check output size */ if (num_outputs<=0) return 4; /* Check validity of Art types */ if (((componentA!=ART1)&&(componentA!=FUZZYART))|| &#9;((componentB!=ART1)&&(componentB!=FUZZYART)&&(componentB!=NONE))) return 2; /* Check styles */ if ((styleB!=NONE)&&(styleB!=COMPLIMENT)) return 3; net->num_outputs = num_outputs; if (InitMap(&net->map,componentA,styleA,componentB,styleB, &#9; num_inputs,num_outputs)) return 6; net->initB = TRUE; /* The network has been initialized */ return 0; } else /* Wrong network type */ return 1; } int InitSet(setPTR set, int num_inputs, int type_inputs, &#9;&#9; int num_outputs, int type_outputs) { int i,j; if (set==NULL) return 4; /* First check that types are valid */ if ((type_inputs!=ANALOG)&&(type_inputs!=BINARY)) return 1; if ((type_outputs!=ANALOG)&&(type_outputs!=BINARY)&&(type_outputs!=NONE) ) return 1; /* If type_output is NONE, num_outputs should be 0 */ if ((type_outputs==NONE)&&(num_outputs!=0)) return 2; set->max_num_patterns = 50; /* Allocate space for 50 patterns */ set->num_patterns = 0; /* No patterns to start with */ set->num_inputs = num_inputs; set->type_inputs = type_inputs; set->style_inputs = NONE; /* Not compliment coded until load */ set->num_outputs = num_outputs; set->type_outputs = type_outputs; set->style_outputs = NONE; /* Not compliment coded until load */ /* Allocate space for patterns */ set->pattern = (patTYPE *)malloc((size_t) &#9;&#9;&#9;&#9; (set->max_num_patterns*sizeof(patTYPE))); if (set->pattern==NULL) return 3; /* Allocate space for input/output vectors patterns */ for (i=0;i<set->max_num_patterns;i++) { set->pattern[i].input=(float *)malloc((size_t) (set->num_inputs*sizeof(f loat))); if (set->pattern[i].input==NULL) return 3; /* If there are output patterns, allocate space */ if (set->type_outputs!=NONE) { set->pattern[i].output=(float *)malloc((size_t) (set->num_outputs*sizeof (float))); if (set->pattern[i].output==NULL) return 3; } } set->initB = TRUE; /* The set has been initialized */ set->checkB = FALSE; /* The set has not been checked against the network */ return 0; } int TrainSet(netPTR net, setPTR set, int max_epoch) { int epoch; /* Number of times passed through training set */ int i,j,pat; /* Counters */ int *output_list; /* List of outputs */ int used,unused; /* Number of used and unused nodes */ int oldA_used; /* Old number of ArtA nodes used */ int oldB_used; /* Old number of ArtB nodes used */ /* --------- Check that set was initialized first ---------------------- */ if ((set==NULL)||(set->initB!=TRUE)) { &#9; return 1; } /* --------- Check that network was initialized first ------------------ */ if ((net==NULL)||(net->initB!=TRUE)) { &#9; return 2; } /* --- Check to see if the net and set were tested for compatibility --- */ if ((net->checkB==FALSE)||(set->checkB==FALSE)) if (CheckNetSet(net,set)) /* If not check compatibilty */ return (CheckNetSet(net,set)); /* If there was an error return it */ /* ========= If everything in order, then train the network ============ */ /* --------------- If network is a plain Art network ------------------- */ if (net->type == ART) { /* Initialize Variables */ oldA_used = net->art.nodes_used; net->art.num_reset = 0; /* To ensure at least on epoch */ epoch = 0; net->doneB = FALSE; /* Network isn't done with training */ /* Do another Epoch if there were any resets */ while ((!(net->doneB))&&(epoch!=max_epoch)) { epoch++; net->art.num_reset = 0; oldA_used = net->art.nodes_used; /* Train each pattern in the set checking for mem. allocation errs */ for (pat=0;pat<set->num_patterns;pat++) &#9; { &#9;&#9; ActivateArt(&net->art,set->pattern[pat].input); &#9;&#9; if (TrainArtPat(&net->art,set->pattern[pat].input)) &#9;&#9; { &#9;&#9;&#9; net = NULL; &#9;&#9;&#9; return 7; &#9;&#9; } &#9; } /* Check in no more resents, if so then done training */ if ((net->art.num_reset==0)&&(oldA_used==net->art.nodes_used)) &#9;net->doneB = TRUE; } /* Update network statistics based on new training */ net->num_patterns += set->num_patterns; net->num_epochs += epoch; } /* ------------------ If network is an ArtMap network ------------------ */ else if (net->type == ARTMAP) { /* Initialize Variables */ oldA_used = net->map.artA.nodes_used; oldB_used = net->map.artB.nodes_used; epoch = 0; net->doneB = FALSE; /* Network isn't done with training */ /* Do another Epoch when not done or hit max number of epochs */ while ((!(net->doneB))&&(epoch!=max_epoch)) { epoch++; /* Reset Counters */ net->map.num_mismatch = 0; net->map.artA.num_reset = 0; net->map.artB.num_reset = 0; /* Update Size */ oldA_used = net->map.artA.nodes_used; oldB_used = net->map.artB.nodes_used; /* Train each pattern in the set checking for mem. allocation errs */ for (pat=0;pat<set->num_patterns;pat++) &#9;if (TrainMapPat(&net->map,&set->pattern[pat])) { &#9; net = NULL; &#9; return 7; &#9;} /* Check if done training */ if ((net->map.num_mismatch==0)&& &#9; (net->map.artA.num_reset==0)&& &#9; (net->map.artB.num_reset==0)&& &#9; (oldA_used==net->map.artA.nodes_used)&& &#9; (oldB_used==net->map.artB.nodes_used)) &#9;net->doneB = TRUE; } /* Update network statistics based on new training */ net->num_patterns += set->num_patterns; net->num_epochs += epoch; } return 0; } int ShowPat(netPTR net,setPTR set, int pat_num) { int sum_outputs; /* Counter for number of active output */ int i,j; /* Counters */ /* --------- Check that set was initialized first ---------------------- */ if ((set==NULL)||(set->initB!=TRUE)) return 1; /* --------- Check that netowrk was initialized first ------------------ */ if ((net==NULL)||(net->initB!=TRUE)) return 2; /* --- Check to see if the net and set were tested for compatibility --- */ if ((net->checkB==FALSE)||(set->checkB==FALSE)) if (CheckNetSet(net,set)) /* If not check compatibilty */ return (CheckNetSet(net,set)); /* If there was an error return it */ /* -------------------- Check pattern number --------------------------- */ if ((pat_num<0)||(pat_num>set->num_patterns)) return 7; /* ======== If everything in order, then activate the network ========== */ /* --------------- If network is a plain Art network ------------------- */ if (net->type == ART) { /* Activate Art Network */ ActivateArt(&net->art,set->pattern[pat_num].input); } /* ------------------ If network is an ArtMap network ------------------ */ else if (net->type == ARTMAP) { /* Activate Art Networks */ ActivateArt(&net->map.artA,set->pattern[pat_num].input); ActivateArt(&net->map.artB,set->pattern[pat_num].output); /* Check that there was a winning ArtA category */ if (net->map.artA.win_cat!=-1) /* If so, activate Mapfield Nodes */ for (i=0;i<net->map.artB.nodes_used;i++) /* For each mapfield node */ &#9;*(net->map.map+i)=(*(*(net->map.map_weight+net->map.artA.win_cat)+i) ); else /* If not, set Mapfield Activation to zero */ for (i=0;i<net->map.artB.nodes_used;i++) /* For each mapfield node */ &#9;*(net->map.map+i)=0; } return 0; } int TestNet(netPTR net, setPTR set, int *tot_correct, int *tot_errors, &#9; int *tot_noansA, int *tot_noansB) { int total_correct = 0; int total_errors = 0; int total_noansA = 0; int total_noansB = 0; float sum_map; float&#9;sum_cat; int i,j; int wrongB; /* --------- Check that set was initialized first ---------------------- */ if ((set==NULL)||(set->initB!=TRUE)) return 1; /* --------- Check that netowrk was initialized first ------------------ */ if ((net==NULL)||(net->initB!=TRUE)) return 2; /* --- Check to see if the net and set were tested for compatibility --- */ if ((net->checkB==FALSE)||(set->checkB==FALSE)) if (CheckNetSet(net,set)) /* If not check compatibilty */ return (CheckNetSet(net,set)); /* If there was an error return it */ total_correct = 0; total_errors = 0; total_noansA = 0; total_noansB = 0; if (net->type==ARTMAP) { /* Show each pattern checking for errors */ for (i=0;i<set->num_patterns;i++) { ShowPat(net,set,i); /* Check that there was a winning TypeA and ArtB category */ if (net->map.artA.win_cat==-1) &#9;total_noansA++; else if (net->map.artB.win_cat==-1) total_noansB++; else { &#9;/* Check if correct */ &#9;wrongB=FALSE; &#9; &#9;/* If ArtB is of type NONE check mapfield vigilence */ &#9;if (net->map.artB.type==NONE) {&#9; &#9; sum_map = 0; &#9; sum_cat = 0; &#9; for (j=0;j<net->map.artB.nodes_used;j++) { &#9; sum_map += FuzzInt((*(net->map.map+j)), &#9;&#9;&#9; (*(net->map.artB.cat+j))); &#9; sum_cat += FuzzUni((*(net->map.map+j)), &#9;&#9;&#9; (*(net->map.artB.cat+j))); &#9; } &#9; /* Check vigilence at mapfield */ &#9; if ((sum_map/sum_cat)<net->map.vigil) &#9; wrongB=TRUE; &#9;} &#9;/* If ArtB not of type NONE just compare ArtB winner */ &#9;else { &#9; for (j=0;j<net->map.artB.nodes_used;j++) { &#9; if ((((int)((*(net->map.map+j)))==1)&&(net->map.artB.win_cat!=j))|| &#9;&#9;(((int)((*(net->map.map+j)))==0)&&(net->map.artB.win_cat==j))) &#9; wrongB=TRUE; &#9; } &#9;} &#9;if (wrongB) &#9; total_errors++; &#9;else &#9; total_correct++; } } } else for (i=0;i<set->num_patterns;i++) { ShowPat(net,set,i); /* Check to see if there was a winner */ if (net->art.win_cat==-1) &#9;total_noansA++; else &#9;total_correct++; } *tot_correct = total_correct; *tot_errors = total_errors; *tot_noansA = total_noansA; *tot_noansB = total_noansB; return 0; } void SaveArt3(artPTR art, FILE *SaveFile,float *input) { &#9; &#9;int i,j,win_cat; &#9;double&#9;vig,max_cat=0.0,sum_inputs=0; &#9; &#9;&#9;//Activate categories &#9;&#9;for (i=0;i<art->nodes_used;i++) &#9;&#9;{ &#9;&#9;&#9;*(art->sum_IW+i)=0; &#9;&#9;&#9;for (j=0;j<art->num_inputs;j++) &#9;&#9;&#9;{ &#9;&#9;&#9;&#9;*(art->sum_IW+i)+=Intersect((*(*(art->weight+i)+j)),(*(i nput+j)),art->type); &#9;&#9;&#9;} &#9;&#9;&#9;*(art->cat+i)=((*(art->sum_IW+i))/(ALPHA+(*(art->sum_weights +i)))); &#9;&#9;} &#9;&#9;// Find most activated category &#9;&#9;win_cat=0; &#9;&#9;for (i=0;i<art->nodes_used;i++) &#9;&#9;{ &#9;&#9;&#9;if (((*(art->cat+i))>max_cat)&&((*(art->elig+i))!=0)) &#9;&#9;&#9;{ &#9;&#9;&#9;&#9;max_cat=(*(art->cat+i)); &#9;&#9;&#9;&#9;win_cat=i; &#9;&#9;&#9;} &#9;&#9;} &#9;&#9;&#9; &#9;&#9;// Find the sum of the inputs &#9;&#9;// When compliment coded, sum of inputs equal to half network in puts. &#9;&#9;if (art->style==COMPLIMENT)&#9;&#9;sum_inputs=(art->num_inputs)/ 2; &#9;&#9;else &#9;&#9;{ &#9;&#9;&#9; &#9;&#9;&#9;for (i=0;i<art->num_inputs;i++)&#9;&#9;sum_inputs+=(*(input+ i)); &#9;&#9;} &#9;&#9; &#9;&#9;// Test to see if winning category meets vigilence level &#9;&#9;vig=0.0; &#9;&#9;vig=((*(art->sum_IW+win_cat))/sum_inputs); &#9;&#9;for (j=0;j<art->num_inputs;j++) &#9;&#9;{ &#9;&#9;&#9;fprintf(SaveFile,"\t%f",*(input+j)); &#9;&#9;} &#9;&#9;fprintf(SaveFile,"\t%f",max_cat); &#9;&#9;fprintf(SaveFile,"\t%f",vig); &#9;&#9;fprintf(SaveFile,"\t%3d",win_cat+1); } int SaveNet(netPTR net,setPTR set, char *file_prefix) { char Save_fname[84],Save_fname1[84]; FILE *SaveFile,*SaveFile1; int i,j,pat; if ((net==NULL)||(net->initB!=TRUE)||(net->num_epochs==0)) return 1; /* Add ".net" to Save file prefix */ strncpy(Save_fname,file_prefix,80); strcat(Save_fname,".net"); SaveFile=fopen(Save_fname,"w"); if (SaveFile==NULL)&#9;return 2; fprintf(SaveFile,"%i\n",net->type); fprintf(SaveFile,"%i\n",net->num_inputs); fprintf(SaveFile,"%i\n",net->num_outputs); /* Make ".out" file to save results of calcuration */ strncpy(Save_fname1,file_prefix,80); strcat(Save_fname1,".out"); SaveFile1=fopen(Save_fname1,"w"); if (SaveFile1==NULL)&#9;return 2; fprintf(SaveFile1,"net->type\t%i\n",net->type); fprintf(SaveFile1,"net->num_inputs\t%i\n",net->num_inputs); fprintf(SaveFile1,"net->num_outputs\t%i\n",net->num_outputs); if (net->type == ART) { &#9; SaveArt(&net->art,SaveFile); &#9; SaveArt1(&net->art,SaveFile1); } else /* if net->type == ARTMAP */&#9;SaveMap(&net->map,SaveFile); fprintf(SaveFile,"%i\n",net->num_patterns); fprintf(SaveFile,"%i\n",net->num_epochs); fprintf(SaveFile1,"net->num_patterns\t%i\n",net->num_patterns); fprintf(SaveFile1,"net->num_epochs\t%i\n",net->num_epochs); fprintf(SaveFile1,"\npattern"); for(j=0;j<net->num_inputs;j++)&#9;&#9;fprintf(SaveFile1,"\tinput:%d",j+1 ); fprintf(SaveFile1,"\tmax_cat"); fprintf(SaveFile1,"\tvig"); fprintf(SaveFile1,"\twin_node"); for (pat=0;pat<set->num_patterns;pat++) { &#9; fprintf(SaveFile1,"\npat=%d",pat+1); &#9; SaveArt3(&net->art,SaveFile1,set->pattern[pat].input); } fclose(SaveFile); fclose(SaveFile1); return 0; } int LoadNet(netPTR net, char *file_prefix) { char load_fname[84]; FILE *LoadFile; int temp_int; float temp_flt; int i,j; if (net==NULL) return 3; /* Add ".net" to load file prefix */ strncpy(load_fname,file_prefix,80); strcat(load_fname,".net"); errno=0; LoadFile=fopen(load_fname,"r"); if (LoadFile==NULL) { if (errno==ENOENT) return 1; else return 2; } net->initB = FALSE; /* The network is not initialized yet */ net->doneB = FALSE; fscanf(LoadFile,"%i\n",&net->type); fscanf(LoadFile,"%i\n",&net->num_inputs); fscanf(LoadFile,"%i\n",&net->num_outputs); /* Load sub-components and allocate some extra space */ if (net->type == ART) { if (LoadArt(&net->art,LoadFile)) return 2; if (AddCats(&net->art,5)) return 2; } else { /* if type == ARTMAP */ if (LoadMap(&net->map,LoadFile)) return 2; /* Add a few unused nodes in case training resumes checking for memory * / /* allocation failure each time. */ if (AddCats(&net->map.artA,5)) return 2; if (net->map.artB.type!=NONE) /* Don't add ArtB nodes if */ /* ArtB network is type NONE */ if (AddCats(&net->map.artB,5)) return 2; if (AddMaps(&net->map)) return 2; } fscanf(LoadFile,"%i\n",&net->num_patterns); fscanf(LoadFile,"%i\n",&net->num_epochs); fclose(LoadFile); net->initB = TRUE; /* The network is initialized */ net->checkB = FALSE; /* The network has not been check against the set * / return 0; } int SaveSet(setPTR set, char *file_prefix) { char out_fname[84]; FILE *outfile; int i,j; /* Counters */ if ((set==NULL)||(set->initB!=TRUE)) return 1; /* Add ".pat" to save file prefix */ strncpy(out_fname,file_prefix,80); strcat(out_fname,".pat"); outfile=fopen(out_fname,"w"); if (outfile==NULL) return 2; fprintf(outfile,"%i\n",set->num_patterns); fprintf(outfile,"%i\n",set->num_inputs); fprintf(outfile,"%i\n",set->type_inputs); fprintf(outfile,"%i\n",set->num_outputs); fprintf(outfile,"%i\n",set->type_outputs); /* Save a pattern set. Complement coding is dropped in the process. */ for (i=0;i<set->num_patterns;i++) { for (j=0;j<(set->num_inputs);j++) fprintf(outfile,"%f\n",(*(set->pattern[i].input+j))); /* If there are output patterns, save them */ if (set->type_outputs!=NONE) { for (j=0;j<(set->num_outputs);j++) &#9;fprintf(outfile,"%f ",(*(set->pattern[i].output+j))); fprintf(outfile,"\n"); } fprintf(outfile,"\n"); } fclose(outfile); return 0; } int LoadSet(setPTR set, char *file_prefix) { char in_fname[84]; /* A charcter string to be used as a filename */ FILE *infile; /* A pointer to a file */ float temp_flt; int i,j; if (set==NULL) return 3; /* Add ".pat" to end of input file prefix */ strncpy(in_fname,file_prefix,80); strcat(in_fname,".pat"); errno=0; infile=fopen(in_fname,"r"); if (infile==NULL) { if (errno==ENOENT) return 1; else return 2; } fscanf(infile,"%i\n",&set->num_patterns); fscanf(infile,"%i\n",&set->num_inputs); fscanf(infile,"%i\n",&set->type_inputs); fscanf(infile,"%i\n",&set->num_outputs); fscanf(infile,"%i\n",&set->type_outputs); set->initB = FALSE; /* Not loaded yet */ /* Leave some space for adding more patterns */ set->max_num_patterns = set->num_patterns + 5; /* Allocate space for patterns */ set->pattern = (patTYPE *)malloc((size_t) &#9;&#9;&#9;&#9; (set->max_num_patterns*sizeof(patTYPE))); if (set->pattern==NULL) return 2; /* Allocate space for input/output vectors patterns */ for (i=0;i<set->max_num_patterns;i++) { set->pattern[i].input=(float *)malloc((size_t) (set->num_inputs*sizeof(f loat))); if (set->pattern[i].input==NULL) return 2; set->pattern[i].output=(float *)malloc((size_t) (set->num_outputs*sizeof (float))); if (set->pattern[i].output==NULL) return 2; } /* Read in the pattern set */ for (i=0;i<set->num_patterns;i++) { for (j=0;j<set->num_inputs;j++) { fscanf(infile,"%f\n",&temp_flt); *(set->pattern[i].input+j)=temp_flt; } for (j=0;j<set->num_outputs;j++) { fscanf(infile,"%f ",&temp_flt); *(set->pattern[i].output+j)=temp_flt; } fscanf(infile,"\n",&temp_flt); } set->initB = TRUE; /* The set has been initialized */ set->checkB = FALSE; /* The set has not been checked against the network */ return 0; } int AddPattern (setPTR set, int num_inputs, float *input, int num_outputs, float *output) { patPTR temppat; /* A temporary pattern pointer */ int check_val; /* Return value from compatibility check */ int i; /* Counter */ if ((set==NULL)||(set->initB!=TRUE)) return 6; /* /* --------- First check network & Pattern set compatibility ----------- */ check_val=CheckPattern(set, num_inputs, input, num_outputs, output); if (check_val) return check_val; /* --------- If everything in order, then add the pattern -------------- */ for (i=0;i<num_inputs;i++) *(set->pattern[set->num_patterns].input+i)=(*(input+i)); for (i=0;i<num_outputs;i++) *(set->pattern[set->num_patterns].output+i)=(*(output+i)); set->num_patterns++; /* If input compliment coding is active, compliment code new pattern */ if (set->style_inputs==COMPLIMENT) for (i=0;i<set->num_inputs;i++) *(set->pattern[set->num_patterns].input+(i+set->num_inputs))=(1-(*(input +i))); /* If output compliment coding is active, compliment code new pattern */ if (set->style_outputs==COMPLIMENT) for (i=0;i<set->num_outputs;i++) *(set->pattern[set->num_patterns].output+(i+set->num_outputs))=(1-(*(out put+i))); /* Check if hit maximum number of patterns */ if (set->num_patterns==set->max_num_patterns) { temppat = AddPats(set->pattern,set->max_num_patterns,50, &#9;&#9; set->num_inputs,set->num_outputs); if (temppat==NULL) return 5; else set->pattern = temppat; set->max_num_patterns += 50; } return 0; } int MergeSets (char *file1_prefix, char *file2_prefix, char *save_prefix ) { setTYPE set1; setTYPE set2; char in_fname[84]; /* A charcter string to be used as a filename */ FILE *infile; /* A pointer to a file */ int i; /* Counter */ int status; /* Add ".pat" to end of the file prefix */ strncpy(in_fname,file1_prefix,80); strcat(in_fname,".pat"); /* Load sets */ status=LoadSet(&set1,file1_prefix); if (status==1) return 2; if (status==2) return 4; status=LoadSet(&set2,file2_prefix); if (status==1) return 3; if (status==2) return 4; /* Check compatibility of the two sets */ if (set1.num_inputs != set2.num_inputs) return 1; if (set1.num_outputs != set2.num_outputs) return 1; if (set1.type_inputs != set2.type_inputs) return 1; if (set1.type_outputs!= set2.type_outputs) return 1; /* -------- If everything in order, then merge the sets ---------------- */ for (i=0;i<set2.num_patterns;i++) { status=AddPattern(&set1, set2.num_inputs, set2.pattern[i].input, &#9;&#9; set2.num_outputs, set2.pattern[i].output); if (status==4) return status; } SaveSet(&set1,save_prefix); return 0; } int GetNumPatterns(setPTR set) { if ((set==NULL)||(set->initB!=TRUE)) return -1; else return set->num_patterns; } int MakeSet (setPTR set,char *infile_name, int num_inputs, &#9;&#9; int type_inputs, char *outfile_name, &#9;&#9; int num_outputs, int type_outputs) { FILE *infile; /* A pointer to a file */ FILE *outfile; float *input; float *output; float tempflt; int i; /* Counter */ int status; int done; int out_of_data; if (num_inputs<=0) return 9; if (type_outputs!=NONE) if (num_outputs<=0) return 9; /* Initialize Pattern Set Checking For Errors */ status = InitSet(set, num_inputs, type_inputs, num_outputs,type_outputs) ; if (status) return status; /* Allocate space for input and output strings */ input=(float *)malloc((size_t) (num_inputs*sizeof(float))); if (input==NULL) return 3; if (type_outputs!=NONE) { output=(float *)malloc((size_t) (num_outputs*sizeof(float))); if (output==NULL) return 3; outfile=fopen(outfile_name, "r"); if (outfile==NULL) return 6; } infile=fopen(infile_name,"r"); if (infile==NULL) return 5; done = FALSE; out_of_data = FALSE; while (!done) { /* Read in input data */ status=fscanf(infile,"%f",&tempflt); *(input+0)=tempflt; if (status==EOF) done = TRUE; else { for (i=1;i<num_inputs;i++) &#9;if (!out_of_data) { &#9; status=fscanf(infile,"%f\n",&tempflt); &#9; *(input+i)=tempflt; &#9;} if (status==EOF) out_of_data = TRUE; if (type_outputs!=NONE) &#9;for (i=0;i<num_outputs;i++) &#9; if (!out_of_data) { &#9; status=fscanf(outfile,"%f\n",&tempflt); &#9; *(output+i)=tempflt; &#9; } if (status==EOF) out_of_data = TRUE; } if (out_of_data) done = TRUE; else if (!done) { status=AddPattern(set, num_inputs, input, num_outputs, output); if (status==2) return 7; if (status==3) return 8; if (status==4) return 9; if (status==5) return 3; } } if (GetNumPatterns(set)==0) return 9; /* Not enough data for one pattern ! */ if (out_of_data) return 10; /* Uneven number of pattern data */ return 0; } int SetArtVigil(netPTR net, int component, float vigil) { /* Check range */ if ((vigil>1)||(vigil<0)) return 2; /* Check initialization */ if ((net==NULL)||(net->initB!=TRUE)) return 3; /* Check network type and set */ if (component==ARTA) { if (net->type!=ARTMAP) return 1; net->map.artA.vigil=vigil; net->map.base_vigil=vigil; } else if (component==ARTB) { if ((net->type!=ARTMAP)||(net->map.artB.type==NONE)) return 1; net->map.artB.vigil=vigil; } else if (component==ART) { if (net->type!=ART) return 1; net->art.vigil=vigil; } else return 1; /* New Vigil So Training No Longer Up To Date */ net->doneB = FALSE; return 0; } int SetMapVigil(netPTR net, float map_vigil) { /* Check range */ if ((map_vigil>1)||(map_vigil<0)) return 2; /* Check initialization */ if ((net==NULL)||(net->initB!=TRUE)) return 3; /* Check network type and set */ if (net->type!=ARTMAP) return 1; net->map.vigil=map_vigil; /* New Vigil So Training No Longer Up To Date */ net->doneB = FALSE; return 0; } int GetMapVigil(netPTR net, float *vigil){ if ((net==NULL)||(net->initB!=TRUE)) return 1; /* Check network type and set */ if (net->type!=ARTMAP) return 2; *vigil = net->map.vigil; return 0; } int SetArtBeta(netPTR net, int component, float beta) { /* Check range */ if ((beta>1)||(beta<0)) return 2; /* Check initialization */ if ((net==NULL)||(net->initB!=TRUE)) return 3; /* Check network type and set */ if (component==ARTA) { if (net->type!=ARTMAP) return 1; net->map.artA.beta=beta; } else if (component==ARTB) { if ((net->type!=ARTMAP)||(net->map.artB.type==NONE)) return 1; net->map.artB.beta=beta; } else if (component==ART) { if (net->type!=ART) return 1; net->art.beta=beta; } else return 1; /* New Recoding Rate So Training No Longer Up To Date */ net->doneB = FALSE; return 0; } int GetArtVigil(netPTR net, int component, float *vigil) { &#9; &#9;if ((net==NULL)||(net->initB!=TRUE))&#9;return 1; &#9; &#9;/* Check network type and set */ &#9;if (component==ARTA) { &#9;&#9;if (net->type!=ARTMAP)&#9;return 2; &#9;&#9;*vigil = net->map.base_vigil; &#9;&#9;return 0; &#9;} &#9;else if (component==ARTB) { &#9;&#9;if ((net->type!=ARTMAP)||(net->map.artB.type==NONE))&#9;return 2 ; &#9;&#9;*vigil = net->map.artB.vigil; &#9;&#9;return 0; &#9;} &#9;else if (component==ART) { &#9;&#9;if (net->type!=ART)&#9;return 3; &#9;&#9;*vigil = net->art.vigil; &#9;&#9;return 0; &#9;} &#9;else&#9;return 4; } int GetArtWinner(netPTR net, int component) { if ((net==NULL)||(net->initB!=TRUE)) return -2; /* Check network type and set */ if (component==ARTA) { if (net->type!=ARTMAP) return -2; return net->map.artA.win_cat; } else if (component==ARTB) { if ((net->type!=ARTMAP)||(net->map.artB.type==NONE)) return -2; return net->map.artB.win_cat; } else if (component==ART) { if (net->type!=ART) return -2; return net->art.win_cat; } else return -2; } int GetArtBeta(netPTR net, int component, float *beta) { if ((net==NULL)||(net->initB!=TRUE)) return 1; /* Check network type and set */ if (component==ARTA) { if (net->type!=ARTMAP) return 2; *beta = net->map.artA.beta; return 0; } else if (component==ARTB) { if ((net->type!=ARTMAP)||(net->map.artB.type==NONE)) return 2; *beta = net->map.artB.beta; return 0; } else if (component==ART) { if (net->type!=ART) return 2; *beta = net->art.beta; return 0; } else return 3; } int GetMap(netPTR net, float *list) { int i; FILE *dumpfile; if ((net==NULL)||(net->initB!=TRUE)) return 1; /* Check network type and set */ if (net->type!=ARTMAP) return 2; else { for (i=0;i<net->map.artB.nodes_used;i++) *(list+i)=(*(net->map.map+i)); return 0; } } int GetMapSize(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return -1; /* Check network type and set */ if (net->type!=ARTMAP) return -1; else return net->map.artB.nodes_used; } int GetArtSize(netPTR net, int component) { int i; if ((net==NULL)||(net->initB!=TRUE)) return -1; /* Check network type and set */ if (component==ARTA) { if (net->type!=ARTMAP) return -1; else return net->map.artA.nodes_used; } else if (component==ARTB) { if (net->type!=ARTMAP) return -1; else return net->map.artB.nodes_used; } else if (component==ART) { if (net->type!=ART) return -1; else return net->art.nodes_used; } else return -1; } int GetSetInput(setPTR set, int pat_num, float *list) { int i; if ((set==NULL)||(set->initB!=TRUE)) return 1; else if ((pat_num<0)||(pat_num > set->num_patterns)) return 2; else { for (i=0;i<set->num_inputs;i++) &#9;list[i]=set->pattern[pat_num].input[i]; return 0; } } int GetSetInSize(setPTR set) { if ((set==NULL)||(set->initB!=TRUE)) return -1; else return set->num_inputs; } int GetSetOutput(setPTR set, int pat_num, float *list) { int i; if ((set==NULL)||(set->initB!=TRUE)) return 1; else if ((pat_num<0)||(pat_num>set->num_patterns)) return 2; else { for (i=0;i<set->num_outputs;i++) *(list+i)=(*(set->pattern[pat_num].output+i)); return 0; } } int GetSetOutSize(setPTR set) { if ((set==NULL)||(set->initB!=TRUE)) return -1; else return set->num_outputs; } int GetSetInType(setPTR set) { if ((set==NULL)||(set->initB!=TRUE)) return -1; else return set->type_inputs; } int GetSetOutType(setPTR set) { if ((set==NULL)||(set->initB!=TRUE)) return -1; else return set->type_outputs; } int GetNetType(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return -1; else return net->type; } int GetArtType(netPTR net, int component) { /* First check for unintialized network and invalid network type */ if ((net==NULL)||(net->initB!=TRUE)) return -1; else if (net->type==ART) { if (component==ART) return net->art.type; else return -1; } else if (net->type==ARTMAP) { if (component==ARTA) return net->map.artA.type; else if (component==ARTB) return net->map.artB.type; else return -1; } else return -1; } int GetArtStyle(netPTR net, int component) { /* First check for unintialized network and invalid network type */ if ((net==NULL)||(net->initB!=TRUE)) return -1; else if (net->type==ART) { if (component==ART) return net->art.style; else return -1; } else if (net->type==ARTMAP) { if (component==ARTA) return net->map.artA.style; else if (component==ARTB) return net->map.artB.style; else return -1; } else return -1; } int GetNetInSize(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return -1; else return net->num_inputs; } int GetNetOutSize(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return -1; else return net->num_outputs; } int GetArtResets(netPTR net, int component) { /* First check for unintialized network and invalid network type */ if ((net==NULL)||(net->initB!=TRUE)) return -1; else if (net->type==ART) { if (component==ART) return net->art.num_reset; else return -1; } else if (net->type==ARTMAP) { if (component==ARTA) return net->map.artA.num_reset; else if (component==ARTB) return net->map.artB.num_reset; else return -1; } else return -1; } int GetMapMismatch(netPTR net) { /* Check network type and set */ if ((net==NULL)||(net->initB!=TRUE)||(net->type!=ARTMAP)) return -1; else return net->map.num_mismatch; } int GetNetDone(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return -1; else return net->doneB; } int GetNetInit(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return FALSE; else return TRUE; } int GetSetInit(setPTR set) { if ((set==NULL)||(set->initB!=TRUE)) return FALSE; else return TRUE; } int FreeNet(netPTR net) { if ((net==NULL)||(net->initB!=TRUE)) return 1; net->initB = FALSE; if (net->type==ART) { free(net->art.cat); if (net->art.type!=NONE) { free(net->art.elig); free(net->art.commit); free(net->art.weight); free(net->art.sum_weights); free(net->art.sum_IW); } } else if (net->map.artA.type==ARTMAP) { /* Free ArtA Network */ free(net->map.artA.cat); free(net->map.artA.elig); free(net->map.artA.commit); free(net->map.artA.weight); free(net->map.artA.sum_weights); free(net->map.artA.sum_IW); /* Free ArtB Network */ free(net->map.artB.cat); if (net->map.artB.type!=NONE) { free(net->map.artB.elig); free(net->map.artB.commit); free(net->map.artB.weight); free(net->map.artB.sum_weights); free(net->map.artB.sum_IW); } free(net->map.map); free(net->map.map_weight); } return 0; } int FreeSet(setPTR set) { int i; if ((set==NULL)||(set->initB!=TRUE)) return 1; set->initB = FALSE; /* Free space for input/output vectors patterns */ for (i=0;i<set->max_num_patterns;i++) { free(set->pattern[i].input); if (set->type_outputs!=NONE) free(set->pattern[i].output); } free(set->pattern); return 0; } /* ここからSim.c /* Gets in integer value from the user */ int GetInt(void) { &#9;char input[100]; &#9;gets(input); &#9;return atoi(input); } /* Gets in float value from the user */ float GetFloat(void) { &#9;char input[100]; &#9;gets(input); &#9;return atof(input); } /* Gets in char value from the user */ char GetLetter(void) { &#9;char input[100]; &#9;gets(input); &#9;return input[0]; } void DumpNet(netPTR net) { float vigil,beta; if (GetNetType(net)==ART) { printf("\t ART NETWORK:\n"); if (GetArtType(net,ART)==ART1) printf("\t Art Type: ART1 \n"); else printf("\t Art Type: FUZZYART \n"); printf("\t Inputs: %9i\n",GetNetInSize(net)); printf("\t Nodes: %9i\n",GetArtSize(net,ART)); GetArtVigil(net,ART,&vigil); printf("\t Vigilance: %3.3f\n",vigil); GetArtBeta(net,ART,&beta); printf("\t Recoding Rate: %3.3f\n",beta); if (GetArtStyle(net,ART)==COMPLIMENT) printf("\t Compliment Coding: On \n"); else printf("\t Compliment Coding: Off \n"); } else { GetMapVigil(net,&vigil); printf("\t ARTMAP NETWORK: \t\t Map Vigilance: %3.3f\n",vigil); if (GetArtType(net,ARTA)==ART1) printf("\t ArtA Type: ART1 "); else printf("\t ArtA Type: FUZZYART "); if (GetArtType(net,ARTB)==ART1) printf("\t ArtB Type: ART1 \n"); else if (GetArtType(net,ARTB)==FUZZYART) printf("\t ArtB Type: FUZZYART \n"); else printf("\t ArtB Type: NONE \n"); printf("\t Inputs: %9i",GetNetInSize(net)); printf("\t Outputs: %9i\n",GetNetOutSize(net)); printf("\t Nodes: %9i",GetArtSize(net,ARTA)); printf("\t Nodes: %9i\n",GetArtSize(net,ARTB)); GetArtVigil(net,ARTA,&vigil); printf("\t Vigilance: %3.3f",vigil); if (GetArtType(net,ARTB)!=NONE) { GetArtVigil(net,ARTB,&vigil); printf("\t Vigilance: %3.3f\n",vigil); } else printf("\t Vigilance: n/a\n"); GetArtBeta(net,ARTA,&beta); printf("\t Recoding Rate: %3.3f",beta); if (GetArtType(net,ARTB)!=NONE) { GetArtBeta(net,ARTB,&beta); printf("\t Recoding Rate: %3.3f\n",beta); } else printf("\t Recoding Rate: n/a\n"); if (GetArtStyle(net,ARTA)==COMPLIMENT) printf("\t Compliment Coding: On "); else printf("\t Compliment Coding: Off "); if (GetArtType(net,ARTB)!=NONE) { if (GetArtStyle(net,ARTB)==COMPLIMENT) &#9;printf("\t Compliment Coding: On\n"); else &#9;printf("\t Compliment Coding: Off\n"); } else printf("\t Compliment Coding: n/a\n"); } } void DumpSet(setPTR set) { &#9;printf("\t PATTERN SET:%11s\t Patterns: %12i\n",pattern_name,GetNumP atterns(set)); &#9; &#9;if (GetSetInType(set)==BINARY)&#9;&#9;printf("\t Input Type: BINARY "); &#9;else&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;printf("\t Input Type: ANALOG ") ; &#9; &#9;if (GetSetOutType(set)==BINARY)&#9;&#9;&#9;printf("\t Output Type: B INARY\n"); &#9;else if (GetSetOutType(set)==ANALOG)&#9;printf("\t Output Type: ANAL OG\n"); &#9;else&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;printf("\t Output Type: NONE \n"); &#9; &#9;printf("\t Input Size: %10i ",GetSetInSize(set)); &#9; &#9;if (GetSetOutType(set)!=NONE)&#9;&#9;printf("\t Output Size: %9i\n", GetSetOutSize(set)); &#9;else&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;printf("\n"); } /* Load a network from a data file */ int LoadNetwork(netPTR net) { &#9;char file_name[80]; &#9;int status; &#9; &#9;printf("\n\tNetwork Name: "); &#9;gets(file_name); &#9;printf("\tLoading Network from %s.net\n",file_name); &#9;status = LoadNet(net,file_name); &#9; &#9;if (status==1) { &#9;&#9;printf("\n\tFile %s.net not found!\n\n",file_name); &#9;&#9;return 1; &#9;} &#9;if (status==2) { &#9;&#9;printf("\n\tError! Out of memory!\n\n"); &#9;&#9;return 1; &#9;} &#9;return 0; } /* Load a pattern set from a file */ int LoadPatternSet(setPTR set) { &#9;char file_name[80]; &#9;int status; &#9; &#9;printf("\n\tPattern Set Name: "); &#9;gets(file_name); &#9;strcpy(pattern_name,file_name); &#9;printf("\tLoading Input/Output Patterns from %s.pat\n\tset:%d",file_ name,set); &#9;status=LoadSet(set,file_name); &#9; &#9;if (status==1) { &#9;&#9;printf("\n\tFile %s.pat not found!\n\n",file_name); &#9;&#9;return 1; &#9;} &#9;if (status==2) { &#9;&#9;printf("\n\tError! Out of memory!\n"); &#9;&#9;return 1; &#9;} &#9;return 0; } /* Initialize a new network, getting information from the user */ int InitNetwork(netPTR net) { int nettype; int typeA,typeB; int sizeA,sizeB; int styleA,styleB; int status; /* Initialization status */ char input; status = TRUE; while (status) { printf("\tInitialize Network:\n"); printf("\tNetwork Types:"); printf("\n\t\t %i - Art",ART); printf("\n\t\t %i - ArtMap",ARTMAP); printf("\n\t\t What type: "); nettype = GetInt(); printf("\n\n\t\tArt Types:"); printf("\n\t\t %i - Art1",ART1); printf("\n\t\t %i - FuzzyArt",FUZZYART); printf("\n\t\t What type: "); typeA = GetInt(); printf("\t\t Input Size: "); sizeA = GetInt(); printf("\n\n\t\tInput Styles:"); printf("\n\t\t %i - Normal",NONE); printf("\n\t\t %i - Compliment Coded",COMPLIMENT); printf("\n\t\t What Style: "); styleA = GetInt(); if (nettype==ARTMAP) { printf("\n\n\t\tTypeB Types:\n"); printf("\t\t %i - Art1\n",ART1); printf("\t\t %i - FuzzyArt\n",FUZZYART); printf("\t\t %i - None\n",NONE); printf("\t\t What type: "); typeB = GetInt(); printf("\t\t Output Size: "); sizeB = GetInt(); &#9; if (typeB!=NONE) { &#9;printf("\n\n\t\tOutput Styles:"); &#9;printf("\n\t\t %i - Normal",NONE); &#9;printf("\n\t\t %i - Compliment Coded\n",COMPLIMENT); &#9;printf("\t\t What Style: "); &#9;styleB = GetInt(); } else &#9;styleB = NONE; } printf("\n\tInitializing network.\n\n"); status=InitNet(net,nettype,typeA,styleA,sizeA,typeB,styleB,sizeB); if (status==5) { printf("\n\tNetwork already initialized. Re-initialize (y/n)? "); input=GetLetter(); if (input=='y') { &#9;FreeNet(net); &#9;status=InitNet(net,nettype,typeA,styleA,sizeA,typeB,styleB,sizeB); } else &#9;return 1; } if (status==6) { printf("\n\tError! Out of memory!\n"); return 1; } else if (status) { printf("\tInitialization Error #%i! Incorrect Format.\n",status); printf("\tTry Again (y/n)? "); input=GetLetter(); if (input!='y') &#9;return 1; } } return 0; } /* Set vigilance levels according to user input */ void SetVigil(netPTR net) { &#9;float vigil; &#9;char trash; &#9;int type; &#9;int status; &#9;type=GetNetType(net); &#9;if (type==ART) { &#9;&#9;GetArtVigil(net,ART,&vigil); &#9;&#9;printf("\n\t Art Vigil (%3.3f): ",vigil); &#9;&#9;vigil = GetFloat(); &#9;&#9;status = SetArtVigil(net,ART,vigil); &#9;&#9;if (status) { &#9;&#9;&#9;printf("\n\tIncorrect range (%f)! Must be between 0 and 1.\n ",vigil); &#9;&#9;&#9;return; &#9;&#9;} &#9;} &#9;else if (type==ARTMAP) { &#9;&#9;GetArtVigil(net,ARTA,&vigil); &#9;&#9;printf("\n\tArt-A Vigilance (%3.3f): ",vigil); &#9;&#9;vigil = GetFloat(); &#9;&#9;status = SetArtVigil(net,ARTA,vigil); &#9;&#9;if (status) { &#9;&#9;&#9;printf("\n\tIncorrect range (%f)! Must be between 0 and 1.\n ",vigil); &#9;&#9;&#9;return; &#9;&#9;} &#9;&#9;if (GetArtType(net,ARTB)!=NONE) { &#9;&#9;&#9;GetArtVigil(net,ARTB,&vigil); &#9;&#9;&#9;printf("\tArt-B Vigilance (%3.3f): ",vigil); &#9;&#9;&#9;vigil = GetFloat(); &#9;&#9;&#9;status=SetArtVigil(net,ARTB,vigil); &#9;&#9;&#9;if (status) { &#9;&#9;&#9;&#9;printf("\n\tIncorrect range (%f)! Must be between 0 and 1.\n",vigil); &#9;&#9;&#9;&#9;return; &#9;&#9;&#9;} &#9;&#9;} &#9;&#9;GetMapVigil(net,&vigil); &#9;&#9;printf("\tMapfield Vigilance (%3.3f): ",vigil); &#9;&#9;vigil = GetFloat(); &#9;&#9;status = SetMapVigil(net,vigil); &#9;&#9;if (status) { &#9;&#9;&#9;printf("\n\tIncorrect range (%f)! Must be between 0 and 1.\n ",vigil); &#9;&#9;&#9;return; &#9;&#9;} &#9;} &#9;printf("\n"); } /* Set Recoding Rate according to User Input */ void SetBeta(netPTR net) { float beta; char trash; int type; int status; type=GetNetType(net); if (type==ART) { GetArtBeta(net,ART,&beta); printf("\n\n\tArt Beta (%3.3f): ",beta); beta = GetFloat(); SetArtBeta(net,ART,beta); if (status) { printf("Incorrect range! Must be between 0 and 1.\n"); return; } } else if (type==ARTMAP) { GetArtBeta(net,ARTA,&beta); printf("\n\n\tArt-A Beta (%3.3f): ",beta); beta = GetFloat(); status=SetArtBeta(net,ARTA,beta); if (status) { printf("Incorrect range! Must be between 0 and 1.\n"); return; } GetArtBeta(net,ARTB,&beta); printf("\tArt-B Beta (%3.3f): ",beta); beta = GetFloat(); status=SetArtBeta(net,ARTB,beta); if (status==2) { printf("Incorrect range! Must be between 0 and 1.\n"); return; } else if (status) { printf("Network needs to initialized first!\n"); return; } } } /* Merge two pattern sets */ void MergePatternSets(void) { char set1_name[30]; char set2_name[30]; char save_name[30]; char trash; int status; printf("\n\tFirst Pattern Set Name: "); gets(set1_name); printf("\tSecond Pattern Set Name: "); gets(set2_name); printf("\tNew Pattern Set Name: "); gets(save_name); printf("\tMerging %s.pat & %s.pat into %s.pat.\n\n", &#9; set1_name,set2_name,save_name); status=MergeSets(set1_name,set2_name,save_name); if (status==2) printf("\n\tFile %s.pat not found!\n\n",set1_name); else if (status==3) printf("\n\tFile %s.pat not found!\n\n",set2_name); else if (status==4) printf("\n\tError! Out of memory!\n"); else if (status) printf("\n\tError Merging. Incompatible Sets.\n\n"); } /* Make pattern set */ int MakePatternSet(setPTR set) { char file1_name[80]; char file2_name[80]; int type_inputs; int type_outputs; int num_inputs; int num_outputs; int status; printf("\n\tInput Types:\n"); printf("\t %i - Binary\n",BINARY); printf("\t %i - Analog\n",ANALOG); printf("\t What type: "); type_inputs = GetInt(); printf("\t Input Size: "); num_inputs = GetInt(); printf("\n\tInput Pattern Set Name: "); gets(file1_name); printf("\n\n\tOutput Types:\n"); printf("\t %i - Binary\n",BINARY); printf("\t %i - Analog\n",ANALOG); printf("\t %i - None\n",NONE); printf("\n\t What type: "); type_outputs = GetInt(); if (type_outputs!=NONE) { printf("\t Output Size: "); num_outputs = GetInt(); printf("\tOutput Pattern Set Name: "); gets(file2_name); } else num_outputs = 0; printf("\n\tCreating Pattern Set from: %s\n",file1_name); if (type_outputs!=NONE) printf("\t and: %s\n",file2_name); status=MakeSet(set,file1_name,num_inputs,type_inputs, &#9;&#9; file2_name,num_outputs,type_outputs); printf("\n"); if (status==1) { printf("\t Invalid set type!!\n"); return 1; } if (status==3) { printf("\t Out of memory!\n"); return 1; } if (status==5) { printf("\t Input File %s not found!\n",file1_name); return 1; } else if (status==6) { printf("\t Output file %s not found!\n",file2_name); return 1; } else if (status==7) { printf("\t Analog data given for binary Art type!\n"); return 1; } else if (status==8) { printf("\t Analog data not properly bounded between 0 and 1!\n"); return 1; } else if (status==9) { printf("\t Input or Output Vector has only zero values or zero size!\n") ; return 1; } else if (status==10) { printf("\t Warning. Uneven number of input or output patterns.\n"); return 0; } else if (status) { printf("\tMakeSet Error #%i!\n\n",status); return 1; } return 0; } /* Save a network */ void SaveNetwork(netPTR net, setPTR set) { char save_name[30]; char trash; int status; printf("\tSave Network Name: "); gets(save_name); printf("\tSaving network to %s.net\n\n",save_name); status=SaveNet(net,set,save_name); if (status) printf("\n\tError opening save file %s.net!\n\n",save_name); } /* Save a Pattern Set */ void SavePatternSet(setPTR set) { char save_name[30]; char trash; int status; printf("\tSave Pattern Set Name: "); gets(save_name); printf("\tSaving pattern set to %s.set\n\n",save_name); status=SaveSet(set,save_name); if (status) printf("\n\tError opening save file %s.pat!\n\n",save_name); } /* Train the Network */ int TrainNetwork(netPTR net, setPTR set) { int status; int epoch; int done; /* Train the net */ printf("\n\tTraining Network: \n"); done = FALSE; epoch = 0; /* Continue until training is done */ /* Calls train net with a max_epochs of 1. This allows one */ /* to step through training one epoch at a time dumping results */ /* about the number of mismatches and resets after each epoch. */ while (done==FALSE) { epoch++; printf("\tEPOCH #%i\n",epoch); status=TrainSet(net,set,1); if (status==3) { printf("\n\tAnalog patterns given to binary network!\n"); return 1; } if (status==4) { printf("\n\tNetwork and pattern set input size incompatible!\n"); return 1; } if (status==5) { printf("\n\tNetwork and pattern set output size incompatible!\n"); return 1; } if (status==6) { printf("\n\tNo output patterns provided for ARTMAP network!\n"); return 1; } if (status==7) { printf("\n\tError! Out of memory!\n"); return 1; } else if (status) { printf("\n\tTraining Error #%i: Incompatible Patterns and Network!\n\n", status); return 1; } else if (GetNetType(net)==ART) { printf("\t%5i Art Nodes Used.\n",GetArtSize(net,ART)); printf("\t%5i Art Resets.\n",GetArtResets(net,ART)); } else if (GetArtType(net,ARTB)==NONE) { printf("\t%5i ArtA Nodes Used.\n",GetArtSize(net,ARTA)); printf("\t%5i ArtA Resets.\n",GetArtResets(net,ARTA)); printf("\t%5i Map Mismatches.\n",GetMapMismatch(net)); } else { printf("\t%5i ArtA Nodes Used.\n",GetArtSize(net,ARTA)); printf("\t%5i ArtB Nodes Used.\n",GetArtSize(net,ARTB)); printf("\t%5i ArtA Resets.\n",GetArtResets(net,ARTA)); printf("\t%5i ArtB Resets.\n",GetArtResets(net,ARTB)); printf("\t%5i Map Mismatches.\n",GetMapMismatch(net)); } done=GetNetDone(net); } printf("\tDONE TRAINING.\n\n"); return 0; } /* Test the Network on a Set collecting information about its results */ /* and dumping input/output patterns in a file, "test.result". */ int TestNetwork(netPTR net, setPTR set) { int total_correct; int total_errors; int total_noansA; int total_noansB; int status; printf("\tTesting Network.\n"); status = TestNet(net,set,&total_correct,&total_errors, &#9;&#9; &total_noansA,&total_noansB); if (status==3) { printf("\n\tAnalog patterns given to binary network!\n"); return 1; } if (status==4) { printf("\n\tNetwork and pattern set input size incompatible!\n"); return 1; } if (status==5) { printf("\n\tNetwork and pattern set output size incompatible!\n"); return 1; } if (status==6) { printf("\n\tNo output patterns provided for ARTMAP network!\n"); return 1; } if (status==7) { printf("\n\tError! Out of memory!\n"); return 1; } else if (GetNetType(net)==ARTMAP) { printf("\tTotal Correct :%5i (%6.2f%%)\n",total_correct, &#9; 100*(float)total_correct/GetNumPatterns(set)); printf("\tTotal Errors :%5i (%6.2f%%)\n",total_errors, &#9; 100*(float)total_errors/GetNumPatterns(set)); printf("\tTotal ArtA No Ans:%5i (%6.2f%%)\n",total_noansA, &#9; 100*(float)total_noansA/GetNumPatterns(set)); printf("\tTotal ArtB No Ans:%5i (%6.2f%%)\n",total_noansB, &#9; 100*(float)total_noansB/GetNumPatterns(set)); } else { printf("\tTotal Answered :%5i (%6.2f%)\n",total_correct, &#9; 100*(float)total_correct/GetNumPatterns(set)); printf("\tTotal ArtA No Ans:%5i (%6.2f%)\n",total_noansA, &#9; 100*(float)total_noansA/GetNumPatterns(set)); } printf("\n"); return 0; } /* Main User Interface Loop */ void main() { &#9;netTYPE net; /* Delcare a network of type netTYPE */ &#9;setTYPE set; /* Declare a pattern set of type setTYPE */ &#9;int SetInit = FALSE; &#9;int NetInit = FALSE; &#9;int NetNew = FALSE; &#9;int i,j,status,pause; &#9;char option; &#9;printf("\n"); &#9;option = ' '; &#9;while (option!='Q') { &#9;&#9;pause = FALSE; &#9;&#9;printf("\n\n"); &#9;&#9;printf(" ======================================================\ n"); &#9;&#9;if ((NetInit)||(NetNew))DumpNet(&net); &#9;&#9;else&#9;&#9;&#9;&#9;&#9;printf("\t NO NETWORK IN MEMORY\n"); &#9;&#9;printf(" ------------------------------------------------------\ n"); &#9;&#9;if (SetInit) &#9;&#9;{ &#9;&#9;&#9;//printf("\t PATTERN SET: %s Patterns: %12i\n",GetNumPattern s(set)); &#9;&#9;&#9;DumpSet(&set); &#9;&#9;} &#9;&#9;else&#9;&#9;&#9;&#9;printf("\t NO PATTERN SET IN MEMORY\n"); &#9;&#9;printf(" ======================================================\ n"); &#9;&#9;if (!SetInit)&#9;&#9;&#9;&#9;printf("\t P - Load (P)atterns "); &#9;&#9;else&#9;&#9;&#9;&#9;&#9;&#9;printf("\t T - Save Pa(t)tern Set ") ; &#9;&#9;if ((!NetInit)&&(!NetNew))&#9;printf("\t N - Load (N)etwork\n"); &#9;&#9;else if (NetInit)&#9;&#9;&#9;printf("\t S - (S)ave Network\n"); &#9;&#9;else&#9;&#9;&#9;&#9;&#9;&#9;printf("\n"); &#9;&#9;if (!SetInit)&#9;&#9;&#9;&#9;printf("\t K - Ma(k)e Pattern Set " ); &#9;&#9;else&#9;&#9;&#9;&#9;&#9;&#9;printf("\t F - (F)ree Pattern Space" ); &#9;&#9;if ((!NetInit)&&(!NetNew))&#9;printf("\t W - Make Net(w)ork\n"); &#9;&#9;else&#9;&#9;&#9;&#9;&#9;&#9;printf("\t O - Free Netw(o)rk\n"); &#9;&#9;if ((NetInit)||(NetNew)) { &#9;&#9;&#9;printf("\t V - Set (V)igilance"); &#9;&#9;&#9;printf("\t\t R - Set (R)ecoding Rate\n"); &#9;&#9;} &#9;&#9;if (((NetInit)||(NetNew))&&(SetInit)) { &#9;&#9;&#9;printf("\t A - Tr(a)in Network"); &#9;&#9;&#9;if (NetInit)&#9;&#9;printf("\t\t E - T(e)st Network\n"); &#9;&#9;&#9;else&#9;&#9;&#9;&#9;printf("\n"); &#9;&#9;} &#9;&#9;printf("\t M - (M)erge Pattern Files"); &#9;&#9;printf("\t Q - (Q)uit\n"); &#9;&#9;printf(" ======================================================\ n"); &#9;&#9;printf("\tSetInit :%d",SetInit); &#9;&#9;printf("\tNetInit :%d",NetInit); &#9;&#9;printf("\tNetNew :%d",NetNew); &#9;&#9;printf("\n\tset :%d",set); &#9;&#9;printf("\tnet :%d",net); &#9;&#9;printf("\tpause :%d\n",pause); &#9;&#9;printf(" ======================================================\ n"); &#9;&#9;printf("\n\tOption : "); &#9;&#9;option=GetLetter(); &#9;&#9;switch (option) { &#9;&#9;&#9;case 'Q' : case 'q': &#9;&#9;&#9;&#9;printf("\n Goodbye\n\n"); &#9;&#9;&#9;&#9;option='Q'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'N' : case 'n': &#9;&#9;&#9;&#9;if ((!NetInit)&&(!NetNew)) { &#9;&#9;&#9;&#9;&#9;status = LoadNetwork(&net); &#9;&#9;&#9;&#9;&#9;if (!status) NetInit = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'P' : case 'p': &#9;&#9;&#9;&#9;if (!SetInit) { &#9;&#9;&#9;&#9;&#9;status = LoadPatternSet(&set); &#9;&#9;&#9;&#9;&#9;if (!status)&#9;SetInit = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;printf("\n\tset :%d",set); &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'W' : case 'w': &#9;&#9;&#9;&#9;if ((!NetInit)&&(!NetNew)) { &#9;&#9;&#9;&#9;&#9;status = InitNetwork(&net); &#9;&#9;&#9;&#9;&#9;if (!status)&#9;NetNew = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'V' : case 'v': &#9;&#9;&#9;&#9;if ((NetInit)||(NetNew))&#9;SetVigil(&net); &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'R' : case 'r': &#9;&#9;&#9;&#9;if ((NetInit)||(NetNew))&#9;SetBeta(&net); &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'A' : case 'a': &#9;&#9;&#9;&#9;if ((NetInit)||(NetNew)) { &#9;&#9;&#9;&#9;&#9;status = TrainNetwork(&net,&set); &#9;&#9;&#9;&#9;&#9;if (!status) { &#9;&#9;&#9;&#9;&#9;&#9;NetInit = TRUE; &#9;&#9;&#9;&#9;&#9;&#9;NetNew = FALSE; &#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;&#9;pause = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'E' : case 'e': &#9;&#9;&#9;&#9;if ((NetInit)||(NetNew)) { &#9;&#9;&#9;&#9;&#9;status=TestNetwork(&net,&set); &#9;&#9;&#9;&#9;&#9;if (status==1)&#9;printf("\t\tError! Out of memory!\ n"); &#9;&#9;&#9;&#9;&#9;else&#9;pause = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'M' : case 'm': &#9;&#9;&#9;&#9;MergePatternSets(); &#9;&#9;&#9;&#9;pause = TRUE; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'S' : case 's': &#9;&#9;&#9;&#9;if (NetInit) { &#9;&#9;&#9;&#9;&#9;SaveNetwork(&net,&set); &#9;&#9;&#9;&#9;&#9;pause = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'F': case 'f': &#9;&#9;&#9;&#9;if (SetInit) { &#9;&#9;&#9;&#9;&#9;printf("\n Clearing pattern set from memory.\n"); &#9;&#9;&#9;&#9;&#9;FreeSet(&set); &#9;&#9;&#9;&#9;&#9;SetInit = FALSE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'O': case 'o': &#9;&#9;&#9;&#9;if ((NetInit)||(NetNew)) { &#9;&#9;&#9;&#9;&#9;printf("\n Clearing network from memory.\n"); &#9;&#9;&#9;&#9;&#9;FreeNet(&net); &#9;&#9;&#9;&#9;&#9;NetInit = FALSE; &#9;&#9;&#9;&#9;&#9;NetNew = FALSE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'K': case 'k': &#9;&#9;&#9;&#9;if (!SetInit) { &#9;&#9;&#9;&#9;&#9;status=MakePatternSet(&set); &#9;&#9;&#9;&#9;&#9;if (!status) &#9;&#9;&#9;&#9;&#9;SetInit = TRUE; &#9;&#9;&#9;&#9;&#9;pause = TRUE; &#9;&#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;case 'T': case 't': &#9;&#9;&#9;&#9;if (SetInit) { &#9;&#9;&#9;&#9;&#9;SavePatternSet(&set); &#9;&#9;&#9;&#9;&#9;pause = TRUE; &#9;&#9;&#9;&#9;} &#9;&#9;&#9;&#9;else&#9;option = 'I'; &#9;&#9;&#9;&#9;break; &#9;&#9;&#9;default:&#9; &#9;&#9;&#9;&#9;printf("\n Illegal Option!\n"); &#9;&#9;&#9;&#9;break; &#9;&#9;} &#9;&#9;if (option=='I')&#9;printf("\n\t Illegal Option!\n"); &#9;&#9;if (pause) { &#9;&#9;&#9;printf(" --------------------------------------------------- ----\n"); &#9;&#9;&#9;printf(" Press Enter\n"); &#9;&#9;&#9;option=GetLetter(); &#9;&#9;} &#9;} } なお、上記において&#9はタブをさす。
The source program of Fuzzy ART in the embodiment is
It is as follows. / * Written By: Lars H. Liden &#9; Last Update: 8/02/95 &#9; * / / * &#9; arranged by &#9;: Shuta Tomida &#9;&#9;: June / 28 / 2000 &#9; * / //Def.h #include from here <math.h>#include<stdio.h>#include<stddef.h>#include<stdlib.h>#include<stdarg.h>#include<string.h>#include<errno.h>#define TRUE 5571 / * An unlikely number * / #define FALSE 0 #define ARTA 0.1 #define ARTA 1 #define ARTB 2 #define ARTMAP 1 #define NONE 0 #define ART1 1 #define FUZZYART 2 #define COMPLIMENT 1 #define BINARY 1 #define ANALOG 2 #define MAX 25 char pattern_name [80]; / * ======================== ================================================= / / * Neural Network Structures * / / * ========================================= ============================= ==== * / / * ------------- -------------------------------------------------- ------- ----- * / / * Art Network Structure * / / * --------------------------- ------------------------------------------- ----- * / typedef struct {int type; / * ART1, FUZZYART, NONE * / int style; / * NONE or COMPLIMENT * / int num_inputs; / * Number of inputs to the network * / int nodes_used; / * Num. of category nodes actually used * / int max_nodes; / * Current number of allocated category nodes * / float beta; / * Recoding rate.No recoding (default) when 1 * / float vigil; / * Current vigilence level * / int num_reset; / * Number of resets during last input presentation * / int win_cat; / * Winning category for last input presenation * / float * cat; / * Activation of category node ( size max_nodes) * / float * elig; / * Eligibility of category node (size max_nodes) * / int * commit; / * Commitment of category node (size max_nodes) * / float ** weight; / * Weights intput-> cat ( size num_inputs * max_nodes) * / float * sum_weights; / * Sum of weights for each nodes (size max_nodes) * / float * sum_IW; / * Intesection weights and inputs (size max_nodes) * /} artTYPE, * artPTR; / *- -------------------------------------------------- ------------------- ----- * / / * ArtMap Network Structure * / / * --------------- -------------------------------------------------- ----- ----- * / typedef struct {float vigil; / * Current mapfield vigilence level * / float base_vigil; / * Base vigilence level for the ArtA Network * / int num_mismatch; / * Number of mismatches during an presentation * / ar tTYPE artA; / * ArtA-Input art network * / artTYPE artB; / * ArtB-Output art network * / int maxA_nodes; / * Maximum number of allocated ArtA nodes * / int maxB_nodes; / * Maximum number of allocated ArtB nodes * / float * map; / * Activation values of the mapfield (size B) * / float ** map_weight; / * weights from A nodes to mapfield (size A x B) * /} mapTYPE, * mapPTR; / * ---- -------------------------------------------------- ---------------- ----- * / / * General Network Structure * / / * ------------------ -------------------------------------------------- ------ * / typedef struct {int initB; / * Has the network been initialized-BOOLEAN * / int checkB; / * Has the net been tested against the set * / int doneB; / * Is the network done with recent training * / int type; / * ART, ARTMAP * / int num_inputs; / * Number of inputs to the network * / int num_outputs; / * Number of outputs from the network * / artTYPE art; / * Art Network-only used if type ART * / mapTYPE map; / * Mapping Field-only used if type ARTM AP * / / * Some history about network training * / int num_patterns; / * Number of training presentations so far * / int num_epochs; / * Number of training epochs so far * /} netTYPE, * netPTR; / * ==== =============================================== == =============== ==== * / / * Pattern Structure * / / * ===================== =================================================== == * / / * -------------------------------------------- -------------------------- ----- * / / * Single Pattern Structure * / / * -------- -------------------------------------------------- ------------ ----- * / typedef struct {float * input; / * Vector of input patterns (size num_inputs) * / float * output; / * Vector out output patterns (size num_outputs) * /} patTYPE, * patPTR; / * -------------------------------------- -------------------------------- ----- * / / * Pattern Set Structure * / / *- -------------------------------------------------- ------------------ ----- * / typedef struct {int initB; / * Has the set been initialized-BOOLEAN * / int checkB; / * Has the set been tested against the net * / int max_num_patterns; / * Total space allocated for patterns * / int num_patterns; / * Current number of patterns in the set * / int num_inputs; / * Size of input patterns * / int type_inputs; / * BINARY or ANALOG * / int style_inputs; / * Are inputs currently compliment coded * / int num_outputs; / * Size of output patterns * / int type_outputs; / * BINARY, ANALOG or NONE * / int style_outputs; / * Are inputs currently compliment coded * / patTYPE * pattern; / * Individual patterns (size max_num_pat) * /} setTYPE, * setPTR; //Int.c float Intersect (float x, float y, int type) {if ( (type == ART1) || (type == NONE)) return x * y; else {/ * if (type == FUZZYART) * / if (x> y) return y; else return x;}} float FuzzInt (float x, float y) {if (x> y) return y; else return x;} float FuzzUni (float x, float y) {if (x> y) return x; else return y;} int BinToInt (patPTR pat, int num_outputs) {int i, position; position = 0; for (i = 0; i <num_outputs; i ++) position + = (* (pat-> output + i)) * pow (2, i); return position;} void IntToBin (int num_outputs, int position, int * output_list) {int i, j; for (i = (num_outputs-1); i>-1; i--) {j = pow (2, i); if (position> = j) {* (output_list + i) = 1; position- = j; } else * (output_list + i) = 0;}} int InitArt (artPTR art, int type, int style, int num_inputs) {int i, j; art-> type = type; art-> num_inputs = num_inputs; if ( type == NONE) (art-> nodes_used = num_inputs; / * Inputs just copied so number of * / art-> max_nodes = num_inputs; / * categories is a constant. * / art-> cat = (float *) malloc ( (size_t) (art-> max_nodes * sizeof (float))); if (art-> cat == NULL) return 1; art-> style = NONE;} else {art-> style = style; art-> nodes_used = 0; / * All categories are currently unused * / art-> max_nodes = MAX; / * Starting number of available categories * / art-> beta = 1; / * No recoding * / art-> vigil = 0; art- > num_reset = 0; art-> cat = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if (art-> cat == NULL) return 1; art-> elig = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if (art-> elig == NULL) return 1; art-> commit = (int *) malloc ((size_t) (art-> max_nodes * sizeof (int))); if (art-> commit == NULL) return 1; art-> weight = (float **) malloc ((size_t) (art-> max_nodes * sizeof (float *))); if (art-> weight == NULL) return 1; art-> weight [0] = (float *) malloc ((size_t) ((art-> max_nodes * art-> num_inputs) * sizeof ( float))); if (art-> weight [0] == NULL) return 1; for (i = 1; i <art->max_nodes; i ++) art-> weight [i] = art-> weight [i-1] + art->num_inputs;art-> sum_weights = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if (art-> sum_weights == NULL) return 1; art-> sum_IW = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if ( art-> sum_IW == NULL) return 1; / * Set Initial Weight Values * / for (i = 0; i <art->max_nodes; i ++) for (j = 0; j <art->num_inputs; j ++) &#9; * (* (art-> weight + i) + j) = 1; / * Calculate initial weight sums * / for (i = 0; i <art->max_nodes; i ++) {* (art-> sum_weights + i) = 0; for (j = 0; j <art->num_inputs; j ++) &#9; * (art-> sum_weights + i) + = (* (* (art-> weight + i) + j));} / * Set Initial Commitments to false * / for (i = 0; i <art->max_nodes; i ++) * (art-> commit + i) = FALSE;} return 0;} int InitMap (mapPTR map, int typeA, int styleA, int typeB, int styleB, &#9; int num_inputs, int num_outputs) {int i, j; map-> vigil = 1; / * Require perfect mapfield match * / map-> base_vigil = 0; map-> num_mismatch = 0; / * Initialize Art Networks * / if (InitArt (& map -> artA, typeA, styleA, num_inputs)) return 1; if (InitArt (&map-> artB, typeB, styleB, num_outputs)) return 1; map-> maxA_nodes = map->artA.max_nodes;map-> maxB_nodes = map->artB.max_nodes; / * Allocate space for map and weights * / map-> map = (float *) malloc ((size_t) (map-> artB.max_nodes * sizeof (float))); if (map- > map == NULL) return 1; map-> map_weight = (float **) malloc ((size_t) (map-> artA.max_nodes * sizeof (fl oat *))); if (map-> map_weight == NULL ) return 1; map-> map_weight [0] = (float *) malloc ((size_t) ((map-> artA.max_nodes * map-> a rtB.max_nodes) * sizeof (float))); if (map- > map_weight [0] == NULL) return 1; for (i = 1; i <map->artA.max_nodes; i ++) map-> map_weight [i] = map-> map_weight [i-1] + map->artB.max_nodes; / * Set Initial Map Field Weight Values * / for (i = 0 ; i <map->artA.max_nodes; i ++) {for (j = 0; j <map->artB.max_nodes; j ++) * (* (map-> map_weight + i) + j) = 1;} return 0;} int Compliment (setTYPE * set, int input_style, int output_style) {float * tempflt; int i, j; / * If compliment coding is requested of the input patterns * / if (input_style == COMPLIMENT) {/ * Allocate space for compliment coded inputs and copy old inputs * / for (j = 0; j <set->num_patterns; j ++) {tempflt = (float *) malloc ((size_t) ((2 * set-> num_inputs) * sizeof (float))); if (tempflt == NULL) return 1; for (i = 0; i <set->num_inputs; i ++) * (tempflt + i) = * (set-> pattern [j] .input + i); free (set-> pattern [j] .input); set-> pattern [j] .input = tempflt; / * Complement coding input patterns in new space * / for (i = 0; i <set->num_inputs; i ++) &#9; * (set-> pattern [j] .input + (i + set-> num_inputs)) = (1-(* (set-> pattern [j] .i nput + i)));} set-> style_inputs = COMPLIMENT;} / * If compliment coding is requested of the output patterns * / if (output_style == COMPLIMENT) {/ * Allocate space for compliment coded outputs and copy old outputs * / for (j = 0; j <set->num_patterns; j ++) {tempflt = (float *) malloc ((size_t) ((2 * set-> num_outputs) * sizeof (float))); if (tempflt == NULL) return 1; for (i = 0; i <set->num_outputs; i ++) * (tempflt + i) = * (set-> pattern [j] .output + i); free (set-> pattern [j] .output); set-> pattern [j] .output = tempflt; / * Complement coding output patterns in new space * / for (i = 0; i <set->num_outputs; i ++) &#9; * (set-> pattern [j] .output + (i + set-> num_outputs)) = (1-(* (set-> pattern [j] .output + i )));} set-> style_outputs = COMPLIMENT;} return 0;} patTYPE * AddPats (patTYPE * pat, int old_max, int new, &#9;&#9; int num_inputs, int num_outputs) (int i; patTYPE * temppat; / * Allocate space for new patterns * / temppat = (patTYPE *) malloc ((size_t) &#9;&#9;&#9;&#9; ((old_max + new) * sizeof (patTYPE) )); if (temppat == NULL) return NULL; / * Allocate space for input / output vectors patterns * / for (i = 0; i <(old_max + new); i ++) {/ * Number of set inputs are doubled for compliment coding * / temppat [i] .input = (float *) malloc ((size_t) ((num_inputs) * 2 * sizeof (float) )); if (temppat [i] .input == NULL) return NULL; if (num_outputs! = 0) {temppat [i] .output = (float *) malloc ((size_t) (num_outputs * sizeof (float)) ); if (temppat [i] .output == NULL) return NULL;}} / * Copy values into new array * / &#9; for (i = 0; i <old_max; i ++) * (temppat + i) = * (pat + i); / * Free Old Space * / free (pat); return temppat;} int AddCats (artPTR art, int new_nodes) {int i, j; int * tempvint; / * Temporary pointer for copying * / float * tempvflt; / * Temporary pointer for copying * / float ** tempflt; / * Temporary pointer for copying * / / * Allocate new space * / tempvflt = (float *) malloc ((size_t) ((art-> max_nodes + new_nodes) * sizeof (flo at))); if (tempvflt == NULL) return 1; for (i = 0; i <art->max_nodes; i ++) * (tempvflt + i) = * (art-> cat + i); free (art->cat);art-> cat = tempvflt; tempvflt = (float *) malloc ((size_t ) ((art-> max_nodes + new_nodes) * sizeof (flo at))); if (tempvflt == NULL) return 1; for (i = 0; i <art->max_nodes; i ++) * (tempvflt + i) = * (art-> elig + i); free (art->elig);art-> elig = tempvflt; tempvint = (int *) malloc ((size_t ) ((art-> max_nodes + new_nodes) * sizeof (int))); if (tempvint == NULL) return 1; for (i = 0; i <art->max_nodes; i ++) * (tempvint + i) = * (art-> commit + i); free (art->commit);art-> commit = tempvint; tempflt = (float **) malloc (( size_t) (((art-> max_nodes + new_nodes)) * sizeof (float *))); if (tempflt == NULL) return 1; tempflt [0] = (float *) malloc ((size_t) ((( art-> max_nodes + new_nodes) * art-> nu m_inputs) * sizeof (float))); if (tempflt [0] == NULL) return 1; for (i = 1; i <(art-> max_nodes + new_nodes); i ++) tempflt [i] = tempflt [i-1] + art->num_inputs; for (i = 0; i <art->max_nodes; i ++) for (j = 0; j <art->num_inputs; j ++) * (* (tempflt + i) + j) = * (* (art-> weight + i) + j); free (art-> weight [0]); free (art- >weight);art-> weight = tempflt; tempvflt = (float *) malloc ((size_t) ((art-> max_nodes + new_nodes) * sizeof (flo at))); if (tempvflt == NULL) return 1; for (i = 0; i <art->max_nodes; i ++) * (tempvflt + i) = * (art-> sum_weights + i); free (art->sum_weights);art-> sum_weights = tempvflt; tempvflt = (float *) malloc ((size_t ) ((art-> max_nodes + new_nodes) * sizeof (flo at))); if (tempvflt == NULL) return 1; for (i = 0; i <art->max_nodes; i ++) * (tempvflt + i) = * (art-> sum_IW + i); free (art->sum_IW);art-> sum_IW = tempvflt; / * Set Initial Weight Values for new weights * / for (i = art->max_nodes; i <(art-> max_nodes + new_nodes); i ++) for (j = 0; j <art->num_inputs; j ++) * (* (art-> weight + i) + j) = 1; / * Set Initial Commitments of new nodes to false * / for (i = art->max_nodes; i <(art-> max_nodes + new_nodes); i ++) * (art-> commit + i) = FALSE; / * Calculate initial weight sums for new nodes * / for (i = art->max_nodes; i <(art-> max_nodes + new_nodes); i ++) {* (art-> sum_weights + i) = 0; for (j = 0; j <art->num_inputs; j ++) * (art-> sum_weights + i) + = (* (* (art-> weight + i) + j));} / * Update number of available nodes * / art-> max_nodes = art-> max_nodes + new_nodes; return 0;} int AddMaps (mapPTR map) {float * tempfltv; / * Temporary pointer for copying * / float ** tempflt; / * Temporary pointer for copying * / int i, j; / * Counters * / / * Allocate new space * / tempflt = (float **) malloc ((size_t) ((map-> artA.max_nodes) * sizeof (float *))); if (tempflt == NULL) return 1 ; tempflt [0] = (float *) malloc ((size_t) ((map-> artA.max_nodes * map-> artB.max_nodes) * sizeof (float))); if (tempflt [0] == NULL) return 1; for (i = 1; i <map->artA.max_nodes; i ++) tempflt [i] = tempflt [i-1] + map->artB.max_nodes; for (i = 0; i <map->maxA_nodes; i ++) for (j = 0; j <map->maxB_nodes; j ++) * (* (tempflt + i) + j) = * (* (map-> map_weight + i) + j); free (map-> map_weight [0]); free (map- >map_weight);map-> map_weight = tempflt; tempfltv = (float *) malloc ((size_t) (map-> artB.max_nodes * sizeof (float))); if (tempfltv == NULL) return 1; for (i = 0; i <map->maxB_nodes; i ++) * (tempfltv + i) = * (map-> map + i); free (map->map);map-> map = tempfltv; / * Set initial weights of all new mapfield nodes * / for (i = map->maxA_nodes; i <(map->artA.max_nodes); i ++) for (j = 0; j <map->artB.max_nodes; j ++) * (* (map-> map_weight + i) + j) = 1; for (i = 0; i <map->artA.max_nodes; i ++) for (j = map->maxB_nodes; j <(map->artB.max_nodes); j ++) * (* (map-> map_weight + i) + j) = 1; / * Update mapfield values * / map-> maxA_nodes = map->artA.max_nodes; map- > maxB_nodes = map->artB.max_nodes; return 0;} int CheckPattern (setPTR set, int num_inputs, float * input, int num_outp uts, &#9; float * output) {int i; int zero_flag; / * Check size of input / output patterns * / if (set-> num_inputs! = num_inputs) return 1; if ((set-> type_outputs! = NONE) &&(set-> num_outputs! = num_outputs)) return 1; / * Check Input for ANALOG pattern in BINARY set * / if (set-> type_inputs == BINARY) for (i = 0; i <num_inputs; i ++) if (((* (input + i))! = 1.0) && ((* (input + i))! = 0.0)) return 2; / * Check Input for improperly bounded ANALOG patterns * / if (set-> type_inputs == ANALOG) for (i = 0; i <num_inputs; i ++) if (((* (input + i))> 1.0) || ((* (input + i)) <0.0)) return 3; / * Check Output for ANALOG pattern in BINARY set * / if (set-> type_outputs == BINARY) for (i = 0; i <num_outputs; i ++) if (((* (output + i))! = 1.0) && ((* (output + i))! = 0.0)) return 2; / * Check Output for improperly bounded ANALOG patterns * / if (set-> type_outputs == ANALOG) for (i = 0; i <num_outputs; i ++) if (((* (output + i))> 1.0) || ((* (output + i)) <0.0)) return 3; / * Check That At Least One Input is Non-Zero * / zero_flag = TRUE; for (i = 0; i <num_inputs; i ++) if ((* (input + i))> 0.0) zero_flag = FALSE; if (zero_flag) return 4; / * Check That At Least One Output is Non-Zero * / if (set-> type_outputs! = NONE) {zero_flag = TRUE; for (i = 0; i <num_outputs; i ++) if ((* (output + i))> 0.0) &#9; zero_flag = FALSE; if (zero_flag) return 4;} / * Everything appears to be ok * / return 0;} int LoadArt ( artPTR art, FILE * LoadFile) {int temp_int; float temp_flt; int i, j; fscanf (LoadFile, "% i \ n", &art->type); fscanf (LoadFile, "% i \ n", &art->num_inputs); fscanf (LoadFile, "% i \ n", &art->nodes_used);art-> max_nodes = art->nodes_used; / * No unused nodes werre saved * / art-> cat = (float *) malloc ( (size_t) (art-> max_nodes * sizeof (float))); if (art-> cat == NULL) return 1; if (art-> type! = NONE) {fscanf (LoadFile, "% i \ n" , &art->style); fscanf (LoadFile, "% f \ n", &art->beta); fscanf (LoadFile, "% f \ n", &art->vigil);art-> num_reset = 0; / * Number Reset is zero * / / * Allocate space * / art-> elig = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if (art-> elig == NULL) return 1; art-> commit = (int *) malloc ((size_t) (art-> max_nodes * sizeof (int))); if (art-> commit == NULL) return 1; art-> weight = (float * *) malloc ((size_t) (art-> max_nodes * sizeof (float *)))); if (art-> weight == NULL) retur n 1; art-> weight [0] = (float *) malloc ((size_t) ((art-> max_nodes * art-> num_inputs) * sizeof (float))); if (art-> weight [0] = = NULL) return 1; for (i = 1; i <art->max_nodes; i ++) art-> weight [i] = art-> weight [i-1] + art->num_inputs;art-> sum_weights = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if (art-> sum_weights == NULL) return 1; art-> sum_IW = (float *) malloc ((size_t) (art-> max_nodes * sizeof (float))); if ( art-> sum_IW == NULL) return 1; / * Read in weights * / for (i = 0; i <art->nodes_used; i ++) {for (j = 0; j <art->num_inputs; j ++) {&#9; fscanf (LoadFile, "% f", &temp_flt);&#9; * (* (art-> weight + i) + j) = temp_flt;} fscanf (LoadFile , "\ n");} fscanf (LoadFile, "\ n"); / * Re-Calculate initial weight sums * / for (i = 0; i <art->max_nodes; i ++) {* (art-> sum_weights + i) = 0; for (j = 0; j <art->num_inputs; j ++) &#9; * (art-> sum_weights + i) + = (* (* (art-> weight + i) + j));} / * Set Initial Commitments of used nodes to true * / for (i = 0; i <art->nodes_used; i ++) * (art-> commit + i) = TRUE;} return 0;} int LoadMap (mapPTR map, FILE * LoadFile) {int temp_int; float temp_flt; int i, j; fscanf (LoadFile , "% f \ n", &map->vigil); fscanf (LoadFile, "% f \ n", &map->base_vigil);map-> num_mismatch = 0; / * No mismatches yet * / if (LoadArt (& map -> artA, LoadFile)) return 1; if (LoadArt (&map-> artB, LoadFile)) return 1; map-> maxA_nodes = map->artA.max_nodes;map-> maxB_nodes = map->artB.max_nodes; / * Allocate space * / map-> map = (float *) malloc ((size_t) (map-> artB.max_nodes * sizeof (float))); if (map-> map == NULL) return 1; map-> map_weight = (float **) malloc ((size_t) (map-> artA.max_nodes * sizeof (fl oat *))); if (map-> map_weight == NULL) return 1; map-> map_weight [0] = (float *) malloc ((size_t) ((map-> artA.max_nodes * map-> a rtB.max_nodes) * sizeof (float))); if (map-> map_weight [0] == NULL) return 1; for (i = 1; i <map->artA.max_nodes; i ++) map-> map_weight [i] = map-> map_weight [i-1] + map->artB.max_nodes; / * Read in map weights * / for (i = 0; i <map->maxA_nodes; i ++) {for (j = 0; j <map->maxB_nodes; j ++) {fscanf (LoadFile, "% f", &temp_flt); * (* (map-> map_weight + i) + j) = temp_flt;} fscanf (LoadFile, "\ n");} fscanf (LoadFile, "\ n"); return 0;} void SaveArt (artPTR art, FILE * SaveFile) {int i, j; fprintf (SaveFile, "% i \ n", art->type); fprintf (SaveFile , "% i \ n", art->num_inputs); fprintf (SaveFile, "% i \ n", art->nodes_used); if (art-> type! = NONE) {fprintf (SaveFile, "% i \ n ", art->style); fprintf (SaveFile,"% f \ n ", art->beta); fprintf (SaveFile,"% f \ n ", art->vigil); / * Save weights * / for (i = 0; i <art->nodes_used; i ++) {for (j = 0; j <art->num_inputs; j ++) &#9; fprintf (SaveFile, "% f", (* (* (art-> weight + i) + j)))); fprintf (SaveFile, "\ n");} fprintf (SaveFile, "\ n");}} void SaveArt1 (artPTR art, FILE * SaveFile) {int i, j; fprintf (SaveFile, "\ nart-> type \ t% i \ n", art-> type ); fprintf (SaveFile, "art-> num_inputs \ t% i \ n", art->num_inputs); fprintf (SaveFile, "art-> nodes_used \ t% i \ n", art->nodes_used); if ( art-> type! = NONE) {fprintf (SaveFile, "\ nart-> style \ t% i \ n", art->style); fprintf (SaveFile, "art-> beta \ t% f \ n", art->beta); fprintf (SaveFile, "art-> vigil \ t% f \ n \ n", art->vigil); / * Save weights * / for (i = 0; i <art->nodes_used; i ++) &#9;{&#9;&#9; fprintf (SaveFile, "node =% 3d", i + 1); &#9;&#9; for (j = 0 ; j <art->num_inputs; j ++) &#9;&#9; fprintf (SaveFile, "\ t% f", (* (* (art-> weight + i) + j))); &#9;&#9; fprintf (SaveFile, "\ n");} fprintf (SaveFile, "\ n");}} void SaveMap (mapPTR map, FILE * SaveFile) {int i, j; fprintf (SaveFile, "% f \ n ", map->vigil); fprintf (SaveFile,"% f \ n ", map->base_vigil); SaveArt (&map-> artA, SaveFile); SaveArt (&map-> artB, SaveFile); / * Save map weights * / for (i = 0; i <map->artA.nodes_used; i ++) {for (j = 0; j <map->artB.nodes_used; j ++) fprintf (SaveFile, "% f", (* (* (map-> map_weight + i) + j))); fprintf (SaveFile, "\ n");} fprintf ( SaveFile, "\ n");} void ActivateArt (artPTR art, float * input) {float sum_inputs; / * Sum of all the input patterns * / float max_cat; / * Largest category activation * / int win_cat; / * Category which wins the competition * / int matchB; / * Boolean to indicate when a match is found * / int num_elig; / * Number of eligible nodes left * / int i, j; / * Counters * / double ddd; / * --- ------------------ Check Type of Art Module -----------------------* / if ( art-> type == NONE) {&#9; / * If none, then category activation is just the input string ---- * / &#9; for (i = 0; i <art->num_inputs; i ++) &#9; * (art-> cat + i) = (* (input + i)); &#9;return;} / * Check if there are any used nodes * / else if (art-> nodes_used == 0) {art-> win_cat = -1; return;} else {/ * ------- If art module, calculate output category activations ------- * / / * Initially all nodes are eligible to win the competition * / num_elig = art->nodes_used; for (i = 0; i <art->nodes_used; i ++) &#9;&#9; * (art-> elig + i) = TRUE; / * Activate categories * / for (i = 0; i <art->nodes_used; i ++) {* (art-> sum_IW + i) = 0; for (j = 0; j <art->num_inputs; j ++) &#9;{&#9;&#9; / * NOTE: Intersection depends in art type. (Fuzzy or Art1) * / &#9;&#9; ddd = 0.0; &#9;&#9; ddd = (* (* (art-> weight + i) + j)); &#9;&#9; ddd = (* (input + j)); &#9;&#9; * (art-> sum_IW + i) + = Intersect ((* (* (art-> weight + i) + j)), (* (input + j)), art->type);&#9;}&#9; * (art-> cat + i) = (* (art-> elig + i)) * ((* (art-> sum_IW + i)) / (ALPHA + (* (art->> sum_weights + i)))); ddd = 0.0; &#9; ddd = * (art-> elig + i); &#9; ddd = * (art-> sum_IW + i); &#9; ddd = ALPHA; &#9; ddd = (ALPHA + (* (art-> sum_weights + i))); &#9; ddd = * (art-> cat + i); &#9;} matchB = FALSE; while (! matchB) {/ * Find most activated category * / max_cat = 0; win_cat = 0; for (i = 0; i <art->nodes_used; i ++) &#9; if (((* (art-> cat + i))> max_cat) && ((* (art-> elig + i))! = 0)) {&#9; max_cat = (* (art-> cat + i)); &#9; win_cat = i; &#9;} / * Find the sum of the inputs * / / * When compliment coded, sum of inputs equal to half network inputs. * / if (art-> style == COMPLIMENT) &#9; sum_inputs = (art-> num_inputs) / 2; else {&#9; sum_inputs = 0; &#9; for (i = 0 ; i <art->num_inputs; i ++) &#9; sum_inputs + = (* (input + i));} / * Test to see if winning category meets vigilence level * / &#9; ddd = 0.0; &#9; ddd = (* (art-> sum_IW + win_cat)); &#9; ddd = ((* (art-> sum_IW + win_cat)) / sum_inputs); if ((((* (art-> sum_IW + win_cat)) / sum_inputs)> = art-> vigil) {&#9; / * If so, found a match * / &#9; matchB = TRUE; &#9; / * Set winner-take-all category activations * / &#9; for (i = 0; i <art->nodes_used; i ++) {&#9; if (i == win_cat) &#9; * (art-> cat + i) = 1; &#9; else &#9; * (art-> cat + i) = 0; &#9;}&#9;art-> win_cat = win_cat;} else {&#9; / * Otherwise, node becomes ineligible * / &#9; * (art-> elig + win_cat) = FALSE; &#9;art-> num_reset ++; &#9;num_elig--;&#9;&#9; / * Check if any nodes still eligible * / &#9; if (num_elig == 0 ) {&#9; / * Return that no match found * / &#9;art-> win_cat = -1; &#9;return;&#9;}}}}} int TrainArtPat (artPTR art, float * input) {&#9; double ddd; int i; / * Counter * / / * ------- Train Art Module with Fast Learning and Slow Recode --------- * / / * NOTE : Slow recode is eliminated if beta is set to one. * / / * When there was no winning category * / if (art-> win_cat ==-1) {art-> win_cat = art->nodes_used; / * Winner becomes next unused node * / art-> nodes_used ++; / * Increment used nodes counter * / / * If hit the max number of allocated Art nodes * / / * Allocate more space for Art nodes * / if (art-> nodes_used == art -> max_nodes) if (AddCats (art, 25)) return 1; * (art-> commit + art- > nodes_used) = TRUE; / * Note it as now used * / / * Set winner-take-all category activations * / for (i = 0; i <art->nodes_used; i ++) (if (i == art-> win_cat) &#9; * (art-> cat + i) = 1; else &#9; * (art-> cat + i) = 0;} / * Fast learning for uncommited node. (Beta = 1) * / for (i = 0; i <art->num_inputs; i ++) &#9;{&#9;&#9; ddd = 0.0; &#9;&#9; ddd = * (* (art-> weight + art-> win_cat) + i); &#9;&#9; ddd = (* (input + i)); &#9;&#9; * (* (art-> weight + art-> win_cat) + i) = Intersect ( (* (input + i)), (* (* (art-> weight + art-> win_cat) + i)), art->type);&#9;&#9;&#9;}} else {/ * Slow Recoding for committed node. (Beta <1) * / for (i = 0; i <art->num_inputs; i ++) * (* (art-> weight + art-> win_cat) + i) = ((art-> beta) * Intersect ((* (input + i)), (* (* ( art-> weight + art-> win_cat) + i)), art-> type)) + ((1- (art-> beta)) * (* (* (art-> w eight + art-> win_cat) + i)));} / * Calculate Art weight sum for speeding up later calculations * / * (art-> sum_weights + art-> win_cat) = 0; for (i = 0; i <art->num_inputs; i ++) * (art-> sum_weights + art-> win_cat) + = (* (* (art-> weight + art-> win_cat) + i)); return 0;} int TrainMapPat (mapPTR map, patPTR pat) (float sum_inputs; / * Sum of all the active inputs * / float sum_cat; / * Sum of all the active Art-B categories * / float sum_map; / * Sum of activations of map nodes * / int doneB ; / * Boolean to signal when done with pattern * / int i, j; / * Counters * / / * -------------- First activate and train Art-B network ---- ----------- * / / * Find winning Art-B category * / ActivateArt (&map-> artB, pat->output); / * If Art-B not of type NONE train it * / if (map-> artB.type! = NONE) (if (TrainArtPat (&map-> artB, pat-> output)) return 1; / * Check if TrainArtPat allocated new space for ArtB * / if (map-> maxB_nodes! = map-> artB.max_nodes) if (AddMaps (map)) return 1;} / * -------- Find an Art-A category that meets mapfield vigilence --------* / doneB = FALSE; / * Haven't found one yet * / map-> artA.vigil = map->base_vigil; / * Reset vigilence to base level * / while (! DoneB) {/ * Find the winning category * / ActivateArt (&map-> artA, pat->input); / * When no previously used Art-A node was able to win, a new Art-A node * / / * is created and trained on the mapfield * / if (map-> artA.win_cat == -1) {/ * Train New Unused Node in ArtA Module * / if (TrainArtPat (&map-> artA, pat-> input)) return 1; / * Train mapfield weights for new node * / for (i = 0; i <map->artB.nodes_used; i ++) &#9; * (* (map-> map_weight + map-> artA.win_cat) + i) = (* (map-> artB.cat + i)); / * Check if TrainArtPat allocated new space for ArtA * / if (map-> maxA_nodes! = Map-> artA.max_nodes) &#9; if (AddMaps (map)) return 1; doneB = TRUE;} / * Otherwise check map vigilence for the used node * / else {/ * Calculate Mapfield Activations * / for (i = 0; i <map->artB.nodes_used; i ++) / * For each mapfield node * / &#9; * (map-> map + i) = (* (* (map-> map_weight + map-> artA.win_cat) + i)); sum_map = 0; sum_cat = 0; for (i = 0; i <map->artB.nodes_used; i ++) {&#9; sum_map + = FuzzInt ((* (map-> map + i)), &#9;&#9;&#9; (* (map-> artB.cat + i)))); &#9; sum_cat + = FuzzUni ((* (map-> map + i)), &#9;&#9;&#9; (* (map-> artB. cat + i)));} if (map-> artB.type! = NONE) &#9; sum_cat = 1; / * Calculate sum of inputs * / sum_inputs = 0; / * Note: When compliment coded, * / for (i = 0; i <map->artA.num_inputs; i ++) / * sum of inputs is equal to * / &#9; sum_inputs + = (* (pat-> input + i)); / * half the network inputs. * / / * Check vigilence at mapfield * / if ((sum_map / sum_cat) <map-> vigil) {&#9; / * If mapfield mismatch then ArtA isn't done * / &#9; doneB = FALSE; &#9; / * Error causes increase in Art-A vigilence unless doing so exceeds * / &#9; / * the highest vigilence level.If this is the case, then mismatch * / &#9; / * was caused by inconsistent or noisy data so ignore and go on. * / &#9; map- > artA.vigil = ((* (map-> artA.sum_IW + map-> artA.win_cat)) / sum_inputs) &#9;+0.0001;&#9; if (map->artA.vigil> 1.0) &#9; doneB = TRUE; &#9; else &#9;map-> num_mismatch ++;} else {&#9; / * Train mapfield weights * / &#9; for (i = 0; i <map->artB.nodes_used; i ++) &#9; * (* (map-> map_weight + map-> artA.win_cat) + i) = (* (map-> artB.cat + i)); &#9; / * Train ArtA Module * / if (TrainArtPat (&map-> artA, pat-> input)) return 1; &#9; / * Check if TrainArtPat allocated new space for ArtA * / if (map-> maxA_nodes! = map-> artA.max_nodes) &#9; if (AddMaps (map)) return 1; &#9; doneB = TRUE;}}} return 0;} int CheckNetSet (netPTR net, setPTR set) {if (net -> type == ART) {/ * Check Art Component Input Type Compatibility * / if ((net-> art.type == ART1) &&(set-> type_inputs == ANALOG)) return 3; if ((net- > art.style == NONE) &&&#9;(net-> num_inputs! = set-> num_inputs)) return 4; if ((net-> art.style == COMPLIMENT) &&&#9; (net- > num_inputs! = 2 * (set-> num_inputs))) return 4; / * Check if set data needs to be compliment coded * / if (Compliment (set, net-> art.style, NONE)) return 7;} if (net-> type == ARTMAP) {if ((net-> map.artA.type == ART1) &&(set-> type_inputs == ANALOG)) return 3; if ((net-> map.artB. type == ART1) &&(set-> type_outputs == ANALOG)) return 3; if (set-> type_outputs == NONE) return 6; / * Check input size * / if ((net-> map.artA.style == NONE) &&&#9;(net-> num_inputs! = Set-> num_inputs)) return 4; if ((net-> map .artA.style == COMPLIMENT) &&&#9;(net-> num_inputs! = 2 * (set-> num_inputs))) return 4; / * Check output size * / if ((net-> map.artB. style == NONE) &&&#9;(net-> num_outputs! = set-> num_outputs)) return 5; if ((net-> map.artB.style == COMPLIMENT) &&&#9;(net-> num_outputs! = 2 * (set-> num_outputs))) return 5; if ((net-> map.artB.type == NONE) &&&#9;(net-> num_outputs! = set-> num_outputs)) return 5; / * Check if set data needs to be compliment coded * / if (Compliment (set, net-> map.artA.style, net-> map.artB.style)) return 7;} / * Everything looks ok, so mark as checked * / net-> checkB = TRUE; set-> checkB = TRUE; / * Training not done since either pattern set or network changed * / net-> doneB = FALSE; return 0; ext.c int InitNet (netPTR net, int net_type, &#9; int componentA, int styleA, int num_inputs, int componentB, int styleB, int num_outputs) {if (net == NULL) return 7; / * Check if alre ady initialized * / if (net-> initB == TRUE) return 5; / * Check styles * / if ((styleA! = NONE) && (styleA! = COMPLIMENT)) return 3; / * Check input size * / if (num_inputs <= 0) return 4; net-> checkB = FALSE; / * Hasn't been tested against the set * / net-> doneB = FALSE; / * Training hasn't occured * / net-> type = net_type; net -> num_inputs = num_inputs; net-> num_patterns = 0; / * No training yet, so all zero * / net-> num_epochs = 0; if (net_type == ART) {/ * First check validity of Art type * / if ((componentA! = ART1) && (componentA! = FUZZYART)) return 2; net-> num_outputs = 0; if (InitArt (&net-> art, componentA, styleA, num_inputs)) return 6; net-> initB = TRUE ; / * The network has been initialized * / return 0;} else if (net_type == ARTMAP) {/ * Check output size * / if (num_outputs <= 0) return 4; / * Check validity of Art types * / if (((componentA! = ART1) && (componentA! = FUZZYART)) || &#9; ((componentB! = ART1) && (componentB! = FUZZYART) && (componentB! = NONE))) return 2; / * Check styles * / if ((styleB! = NONE) && (styleB! = COMPLIMENT)) return 3; net-> num_outputs = num_outputs; if (InitMap (&net-> map, componentA, styleA, componentB, styleB, &#9; num_inputs, num_outputs)) return 6; net-> initB = TRUE; / * The network has been initialized * / return 0;} else / * Wrong network type * / return 1;} int InitSet (setPTR set, int num_inputs, int type_inputs, &#9;&#9; int num_outputs, int type_outputs) {int i, j; if (set == NULL) return 4; / * First check that types are valid * / if ((type_inputs! = ANALOG) && (type_inputs! = BINARY)) return 1; if ((type_outputs! = ANALOG) && (type_outputs! = BINARY) && (type_outputs! = NONE )) return 1; / * If type_output is NONE, num_outputs should be 0 * / if ((type_outputs == NONE) && (num_outputs! = 0)) return 2; set-> max_num_patterns = 50; / * Allocate space for 50 patterns * / set-> num_pat terns = 0; / * No patterns to start with * / set-> num_inputs = num_inputs; set-> type_inputs = type_inputs; set-> style_inputs = NONE; / * Not compliment coded until load * / set-> num_outputs = num_outputs; set-> type_outputs = type_outputs; set-> style_outputs = NONE; / * Not compliment coded until load * / / * Allocate space for patterns * / set-> pattern = (patTYPE *) malloc ((size_t) &#9;&#9;&#9;&#9;(set-> max_num_patterns * sizeof (patTYPE))); if (set-> pattern == NULL) return 3; / * Allocate space for input / output vectors patterns * / for (i = 0; i <set->max_num_patterns; i ++) {set-> pattern [i] .input = (float *) malloc ((size_t) (set-> num_inputs * sizeof (float))); if (set-> pattern [i ] .input == NULL) return 3; / * If there are output patterns, allocate space * / if (set-> type_outputs! = NONE) {set-> pattern [i] .output = (float *) malloc (( size_t) (set-> num_outputs * sizeof (float))); if (set-> pattern [i] .output == NULL) return 3;}} set-> initB = TRUE; / * The set has been initialized * / set-> checkB = FALSE; / * The set has not been checked against the network * / return 0;} int TrainSet (netPTR net, setPTR set, int max_epoch) {int epoch; / * Number of times passed through training set * / int i, j, pat; / * Counters * / int * output_list; / * List of outputs * / int used, unused; / * Number of used and unused nodes * / int oldA_used; / * Old number of ArtA nodes used * / int oldB_used; / * Old number of ArtB nodes used * / / * --------- Check that set was initialized first ----------------- ----- * / if ((set == NULL) || (set-> initB! = TRUE)) {&#9; return 1;} / * --------- Chec k that network was initialized first ------------------ * / if ((net == NULL) || (net-> initB! = TRUE)) {&#9; return 2;} / * --- Check to see if the net and set were tested for compatibility --- * / if ((net-> checkB == FALSE) || (set-> checkB == FALSE)) if (CheckNetSet (net, set)) / * If not check compatibilty * / return (CheckNetSet (net, set)); / * If there was an error return it * / / * ========= If everything in order, then train the network ============ * / / * --------------- If network is a plain Art network ---- --------------- * / if (net-> type == ART) {/ * Initialize Variables * / oldA_used = net->art.nodes_used;net-> art.num_reset = 0; / * To ensure at least on epoch * / epoch = 0; net-> doneB = FALSE; / * Network isn't done with training * / / * Do another Epoch if there were any resets * / while ((! (net-> doneB)) && (epoch! = max_epoch)) (epoch ++; net-> art.num_reset = 0; oldA_used = net->art.nodes_used; / * Train each pattern in the set checking for mem. allocation errs * / for (pat = 0; pat <set->num_patterns; pat ++) &#9;{&#9;&#9; ActivateArt (&net-> art, set-> pattern [pat] .input); &#9;&#9; if (TrainArtPat (&net-> art, set-> pattern [pat] .input)) &#9;&#9;{&#9;&#9;&#9; net = NULL; &#9;&#9;&#9; return 7; &#9;&#9;}&#9;} / * Check in no more resents, if so then done training * / if ((net-> art.num_reset == 0) && (oldA_used == net-> art.nodes_used)) &#9;net-> doneB = TRUE;} / * Update network statistics based on new training * / net-> num_patterns + = set->num_patterns;net-> num_epochs + = epoch;} / * ------------------ If network is an ArtMap network ------------------ * / else if (net-> type == ARTMAP) {/ * Initialize Variables * / oldA_used = net->map.artA.nodes_used; oldB_used = net->map.artB.nodes_used; epoch = 0; net-> doneB = FALSE; / * Network isn't done with training * / / * Do another Epoch when not done or hit max number of epochs * / while ((! (Net-> doneB)) && (epoch! = Max_epoch)) {epoch ++ ; / * Reset Counters * / net-> map.num_mismatch = 0; net-> map.artA.num_reset = 0; net-> map.artB.num_reset = 0 ; / * Update Size * / oldA_used = net->map.artA.nodes_used; oldB_used = net->map.artB.nodes_used; / * Train each pattern in the set checking for mem.allocation errs * / for (pat = 0 ; pat <set->num_patterns; pat ++) &#9; if (TrainMapPat (&net-> map, &set-> pattern [pat])) {&#9; net = NULL; &#9; return 7; &#9; } / * Check if done training * / if ((net-> map.num_mismatch == 0) &&&#9;(net-> map.artA.num_reset == 0) &&&#9;(net-> map .artB.num_reset == 0) &&&#9; (oldA_used == net-> map.artA.nodes_used) &&&#9; (oldB_used == net-> map.artB.nodes_used)) &#9; net -> doneB = TRUE;} / * Update network statistics based on new training * / net-> num_patterns + = set->num_patterns;net-> num_epochs + = epoch;} return 0;} int ShowPat (netPTR net, setPTR set , int pat_num) (int sum_outputs; / * Counter for number of active output * / int i, j; / * Counters * / / * --------- Check that set was initialized first ----- ----------------- * / if ((set == NULL) || (set-> initB! = TRUE)) return 1; / * ------ --- Check that netowrk was initialized first ------------------ * / if ((net == NULL) || (net-> initB! = TRUE)) return 2; / * --- Check to see if the net and set were tested for compatibility --- * / if ((net-> checkB == FALSE) || (set-> checkB == FALSE) ) if (CheckNetSet (net, set)) / * If not check compatibilty * / return (CheckNetSet (net, set)); / * If there was an error return it * / / * --------- ----------- Check pattern number --------------------------- * / if ((pat_num <0) || (pat_num>set-> num_patterns)) return 7; / * ======== If everything in order, then activate the network ========== * / / * --------------- If network is a plain Art network ------------------- * / if (net-> type = = ART) {/ * Activate Art Network * / ActivateArt (&net-> art, set-> pattern [pat_num] .input);} / * ------------------ If network is an ArtMap network ------------------ * / else if (net-> type == ARTMAP) {/ * Activate Art Networks * / ActivateArt (&net-> map.artA, set-> pattern [pat_num] .input); ActivateArt (&net-> map.artB, set-> pattern [pat_num] .output); / * Check that there was a winning ArtA category * / if (net -> map.artA.win_cat! =-1) / * If so, activate Mapfield Nodes * / for (i = 0; i <net->map.artB.nodes_used; i ++) / * For each mapfield node * / &#9; * (net-> map.map + i) = (* (* (net-> map.map_weight + net- > map.artA.win_cat) + i)); else / * If not, set Mapfield Activation to zero * / for (i = 0; i <net->map.artB.nodes_used; i ++) / * For each mapfield node * / &#9; * (net-> map.map + i) = 0;} return 0;} int TestNet (netPTR net, setPTR set, int * tot_correct, int * tot_errors, &#9; int * tot_noansA, int * tot_noansB) {int total_correct = 0; int total_errors = 0; int total_noansA = 0; int total_noansB = 0; float sum_map; float &#9;sum_cat; int i, j; int wrongB; / * --------- Check that set was initialized first ---------------------- * / if ((set == NULL) || (set-> initB! = TRUE)) return 1; / * --------- Check that netowrk was initialized first --------- --------- * / if ((net == NULL) || (net-> initB! = TRUE)) return 2; / * --- Check to see if the net and set were tested for compatibility --- * / if ((net-> checkB == FALSE) || (set-> checkB == FALSE)) if (CheckNetSet (net, set)) / * If not check compatibilty * / return (CheckNetSet ( net, set)); / * If there was an error return it * / total_correct = 0; total_errors = 0; total_noansA = 0; total_noansB = 0; if (net-> type == ARTMAP) {/ * Show each pattern checking for errors * / for (i = 0; i <set->num_patterns; i ++) {ShowPat (net, set, i); / * Check that there was a winning TypeA and ArtB category * / if (net-> map.artA.win_cat ==-1) &#9; total_noansA ++; else if (net-> map.artB.win_cat ==-1) total_noansB ++; else {&#9; / * Check if correct * / &#9; wrongB = FALSE; &#9;&#9; / * If ArtB is of type NONE check mapfield vigilence * / &#9; if (net-> map.artB.type == NONE) {&#9;&#9; sum_map = 0; &#9; sum_cat = 0; &#9; for (j = 0; j <net->map.artB.nodes_used; j ++) {&#9; sum_map + = FuzzInt ((* (net-> map.map + j)), &#9;&#9;&#9; (* (net-> map.artB.cat + j))); &#9; sum_cat + = FuzzUni ((* (net-> map.map + j)), &#9;&#9;&#9; (* (net-> map.artB.cat + j))); &#9;}&#9; / * Check vigilence at mapfield * / &#9; if ((sum_map / sum_cat) <net-> map.vigil) &#9; wrongB = TRUE; &#9;}&#9; / * If ArtB not of type NONE just compare ArtB winner * / &#9; else {&#9; for (j = 0; j <net->map.artB.nodes_used; j ++) {&#9; if ((((int) ((* (net-> map.map + j))) == 1) &&(net-> map. artB.win_cat! = j)) || &#9;&#9; (((int) ((* (net-> map.map + j))) == 0) &&(net-> map.artB .win_cat == j))) &#9; wrongB = TRUE; &#9;}&#9;}&#9; if (wrongB) &#9; total_errors ++; &#9; else &#9; total_correct ++ ;}}} else for (i = 0; i <set->num_patterns; i ++) {ShowPat (net, set, i); / * Check to see if there was a winner * / if (net-> art.win_cat ==-1) &#9; total_noansA ++; else &#9; total_correct ++;} * tot_correct = total_correct; * tot_errors = total_errors; * tot_noansA = total_noansA; * tot_noansB = total_noansB; return 0;} void SaveArt3 (artPTR art, FILE * SaveFile, float * input) {&#9;&#9; int i, j, win_cat; &#9; double &#9; vig, max_cat = 0.0, sum_inputs = 0; &#9;&#9;&#9; // Activate categories &#9;&#9; for (i = 0; i <art->nodes_used; i ++) &#9;&#9;{&#9;&#9;&#9; * (art-> sum_IW + i) = 0; &#9;&#9;&#9; for (j = 0; j <art->num_inputs; j ++) &#9;&#9;&#9;{&#9;&#9;&#9;&#9; * (art-> sum_IW + i) + = Intersect ( (* (* (art-> weight + i) + j)), (* (i nput + j)), art->type);&#9;&#9;&#9;}&#9;&#9;&#9; * (art-> cat + i) = ((* (art-> sum_IW + i)) / (ALPHA + (* (art-> sum_weights + i)))); &#9;&#9;}&#9;&#9; // Find most activated category &#9;&#9; win_cat = 0; &#9;&#9; for (i = 0; i <art->nodes_used; i ++) &#9;&#9;{&#9;&#9;&#9; if (((* (art-> cat + i))> max_cat) && ((* (art-> elig + i))! = 0)) &#9;&#9;&#9;{&#9;&#9;&#9;&#9; max_cat = (* (art- > cat + i)); &#9;&#9;&#9;&#9; win_cat = i; &#9;&#9;&#9;}&#9;&#9;}&#9;&#9;&#9;&#9;&#9; // Find the sum of the inputs &#9;&#9; // When compliment coded, sum of inputs equal to half network in puts &#9;&#9; if (art-> style == COMPLIMENT) &#9;&#9; sum_inputs = (art-> num_inputs) / 2; &#9;&#9; else &#9;&#9;{&#9;&#9;&#9;&#9;&#9;&#9; for (i = 0; i <art->num_inputs; i ++) &#9;&#9; sum_inputs + = (* (input + i)); &#9;&#9;}&#9;&#9;&#9;&#9; // Test to see if winning category meets vigilence level &#9;&#9; vig = 0.0; &#9;&#9; vig = ((* (art-> sum_IW + win_cat)) / sum_inputs); &#9;&#9; for (j = 0; j <art->num_inputs; j ++) &#9;&#9;{&#9;&#9;&#9; fprintf (SaveFile, "\ t% f", * (input + j)); &#9;&#9;}&#9;&#9; fprintf (SaveFile, "\ t% f", max_cat); &#9;&#9; fprintf (SaveFile, "\ t% f", vig) ; &#9;&#9; fprintf (SaveFile, "\ t% 3d", win_cat + 1);} int SaveNet (netPTR net, setPTR set, char * file_prefix) {char Save_fname [84], Save_fname1 [84] ; FILE * SaveFile, * SaveFile1; int i, j, pat; if ((net == NULL) || (net-> initB! = TRUE) || (net-> num_epochs == 0)) return 1; / * Add ".net" to Save file prefix * / strncpy (Save_fname, file_prefix, 80); strcat (Save_fname, ". Net"); SaveFile = fopen (Save_fname, "w"); if (SaveFile == NULL) &#9; return 2; fprintf (SaveFile, "% i \ n", net->type); fprintf (SaveFile, "% i \ n", net->num_inputs); fprintf (SaveFile, "% i \ n" , net->num_outputs); / * Make ".out" file to save results of calcuration * / strncpy (Save_fname1, file_prefix, 80); strcat (Save_fname1, ". out"); SaveFile1 = fopen (Save_fname1, "w"); if (SaveFile1 == NULL) &#9; return 2; fprintf (SaveFile1, "net-> type \ t% i \ n", net->type); fprintf (SaveFile1, "net-> num_inputs \ t % i \ n ", net->num_inputs); fprintf (SaveFile1, "net-> num_outputs \ t% i \ n", net->num_outputs); if (net-> type == ART) {&#9; SaveArt (&net-> art, SaveFile); &#9; SaveArt1 (&net-> art, SaveFile1);} else / * if net-> type == ARTMAP * / &#9; SaveMap (&net-> map, SaveFile); fprintf (SaveFile, "% i \ n" , net->num_patterns); fprintf (SaveFile, "% i \ n", net->num_epochs); fprintf (SaveFile1, "net-> num_patterns \ t% i \ n", net->num_patterns); fprintf (SaveFile1 , "net-> num_epochs \ t% i \ n", net->num_epochs); fprintf (SaveFile1, "\ npattern"); for (j = 0; j <net->num_inputs; j ++) &#9;&#9; fprintf (SaveFile1, "\ tinput:% d", j + 1); fprintf (SaveFile1, "\ tmax_cat"); fprintf (SaveFile1, "\ tvig "); fprintf (SaveFile1," \ twin_node "); for (pat = 0; pat <set->num_patterns; pat ++) {&#9; fprintf (SaveFile1, "\ npat =% d", pat + 1); &#9; SaveArt3 (&net-> art, SaveFile1, set-> pattern [pat] .input);} fclose (SaveFile); fclose (SaveFile1); return 0;} int LoadNet (netPTR net, char * file_prefix) {char load_fname [84]; FILE * LoadFile; int temp_int; float temp_flt; int i, j ; if (net == NULL) return 3; / * Add ".net" to load file prefix * / strncpy (load_fname, file_prefix, 80); strcat (load_fname, ". net"); errno = 0; LoadFile = fopen (load_fname, "r"); if (LoadFile == NULL) {if (errno == ENOENT) return 1; else return 2;} net-> initB = FALSE; / * The network is not initialized yet * / net- > doneB = FALSE; fscanf (LoadFile, "% i \ n", &net->type); fscanf (LoadFile, "% i \ n", &net->num_inputs); fscanf (LoadFile, "% i \ n", &net->num_outputs); / * Load sub-components and allocate some extra space * / if (net-> type == ART) {if (LoadArt (&net-> art, LoadFile)) return 2; if (AddCats (& net -> art, 5)) return 2;} else {/ * if type == ARTMAP * / if (LoadMap (&net-> map, LoadFile)) return 2; / * Add a few unused nodes i n case training resumes checking for memory * / / * allocation failure each time. * / if (AddCats (&net-> map.artA, 5)) return 2; if (net-> map.artB.type! = NONE) / * Don't add ArtB nodes if * / / * ArtB network is type NONE * / if (AddCats (&net-> map.artB, 5)) return 2; if (AddMaps (&net-> map)) return 2;} fscanf (LoadFile, "% i \ n", &net->num_patterns); fscanf (LoadFile, "% i \ n", &net->num_epochs); fclose (LoadFile); net-> initB = TRUE; / * The network is initialized * / net-> checkB = FALSE; / * The network has not been check against the set * / return 0;} int SaveSet (setPTR set, char * file_prefix) {char out_fname [84]; FILE * outfile; int i, j; / * Counters * / if ((set == NULL) || (set-> initB! = TRUE)) return 1; / * Add ".pat" to save file prefix * / strncpy (out_fname, file_prefix , 80); strcat (out_fname, ". Pat"); outfile = fopen (out_fname, "w"); if (outfile == NULL) return 2; fprintf (outfile, "% i \ n", set-> num_patterns ); fprintf (outfile, "% i \ n", set->num_inputs); fprintf (outfile, "% i \ n", set->type_inputs); fprintf (outfile, "% i \ n", set-> n um_outputs); fprintf (outfile, "% i \ n", set->type_outputs); / * Save a pattern set.Complement coding is dropped in the process. * / for (i = 0; i <set->num_patterns; i ++) {for (j = 0; j <(set->num_inputs); j ++) fprintf (outfile, "% f \ n", (* (set-> pattern [i] .input + j))); / * If there are output patterns, save them * / if (set-> type_outputs! = NONE) {for (j = 0; j <(set->num_outputs); j ++) &#9; fprintf (outfile, "% f", (* (set-> pattern [i] .output + j))); fprintf (outfile, "\ n") ;} fprintf (outfile, "\ n");} fclose (outfile); return 0;} int LoadSet (setPTR set, char * file_prefix) {char in_fname [84]; / * A charcter string to be used as a filename * / FILE * infile; / * A pointer to a file * / float temp_flt; int i, j; if (set == NULL) return 3; / * Add ".pat" to end of input file prefix * / strncpy ( in_fname, file_prefix, 80); strcat (in_fname, ". pat"); errno = 0; infile = fopen (in_fname, "r"); if (infile == NULL) {if (errno == ENOENT) return 1; else return 2;} fscanf (infile, "% i \ n", &set->num_patterns); fscanf (infile, "% i \ n", &set->num_inputs); fscanf (infile, "% i \ n", &set->type_inputs); fscanf (infile, "% i \ n", &set->num_outputs); fscanf (infile, "% i \ n", &set->type_outputs);set-> initB = FALSE; / * Not loaded yet * / / * Leave some space for adding more patterns * / set-> max_num_patterns = set-> num_patterns + 5; / * Allocate space for patterns * / set-> pattern = (patTYPE *) malloc ((size_t) &#9;&#9;&#9;&#9;(set-> max_num_patterns * sizeof (patTYPE))); if (set-> pattern == NULL) return 2; / * Allocate space for input / output vectors patterns * / for (i = 0; i <set->max_num_patterns; i ++) {set-> pattern [i] .input = (float *) malloc ((size_t) (set-> num_inputs * sizeof (float))); if (set-> pattern [i ] .input == NULL) return 2; set-> pattern [i] .output = (float *) malloc ((size_t) (set-> num_outputs * sizeof (float))); if (set-> pattern [i ] .output == NULL) return 2;} / * Read in the pattern set * / for (i = 0; i <set->num_patterns; i ++) {for (j = 0; j <set->num_inputs; j ++) {fscanf (infile, "% f \ n", &temp_flt); * (set-> pattern [i] .input + j) = temp_flt;} for (j = 0; j <set->num_outputs; j ++) {fscanf (infile, "% f", &temp_flt); * (set-> pattern [i] .output + j) = temp_flt;} fscanf (infile, "\ n", &temp_flt);}set-> initB = TRUE; / * The set has been initialized * / set-> checkB = FALSE; / * The set has not been checked against the network * / return 0;} int AddPattern (setPTR set, int num_inputs , float * input, int num_outputs, float * output) (patPTR temppat; / * A temporary pattern pointer * / int check_val; / * Return value from compatibility check * / int i; / * Counter * / if ((set == (NULL) || (set-> initB! = TRUE)) return 6; / * / * --------- First check network & Pattern set compatibility ----------- * / check_val = CheckPattern (set, num_inputs, input, num_outputs, output); if (check_val) return check_val; / * --------- If everything in order, then add the pattern -------- ------ * / for (i = 0; i <num_inputs; i ++) * (set-> pattern [set-> num_patterns] .input + i) = (* (input + i)); for (i = 0; i <num_outputs; i ++) * (set-> pattern [set-> num_patterns] .output + i) = (* (output + i)); set-> num_patterns ++; / * If input compliment coding is active, compliment code new pattern * / if (set-> style_inputs == COMPLIMENT) for (i = 0; i <set->num_inputs; i ++) * (set-> pattern [set-> num_patterns] .input + (i + set-> num_inputs)) = (1-(* (input + i))); / * If output compliment coding is active, compliment code new pattern * / if (set-> style_outputs == COMPLIMENT) for (i = 0; i <set->num_outputs; i ++) * (set-> pattern [set-> num_patterns] .output + (i + set-> num_outputs)) = (1-(* (out put + i))); / * Check if hit maximum number of patterns * / if (set-> num_patterns == set-> max_num_patterns) {temppat = AddPats (set-> pattern, set-> max_num_patterns, 50, &#9;&#9;set-> num_inputs, set->num_outputs); if (temppat == NULL) return 5; else set-> pattern = temppat; set-> max_num_patterns + = 50;} return 0;} int MergeSets (char * file1_prefix, char * file2_prefix, char * save_prefix) (setTYPE set1; setTYPE set2; char in_fname [84]; / * A charcter string to be used as a filename * / FILE * infile; / * A pointer to a file * / int i; / * Counter * / int status; / * Add ".pat" to end of the file prefix * / strncpy (in_fname, file1_prefix, 80); strcat (in_fname, ". pat"); / * Load sets * / status = LoadSet (& set1, file1_prefix) ; if (status == 1) return 2; if (status == 2) return 4; status = LoadSet (& set2, file2_prefix); if (status == 1) return 3; if (status == 2) return 4; / * Check compatibility of the two sets * / if (set1.num_inputs ! = set2.num_inputs) return 1; if (set1.num_outputs! = set2.num_outputs) return 1; if (set1.type_inputs! = set2.type_inputs) return 1; if (set1.type_outputs! = set2.type_outputs) return 1 ; / * -------- If everything in order, then merge the sets ---------------- * / for (i = 0; i <set2.num_patterns; i ++) {status = AddPattern (& set1, set2.num_inputs, set2.pattern [i] .input, &#9;&#9; set2.num_outputs, set2.pattern [i] .output); if (status == 4) return status;} SaveSet (& set1, save_prefix); return 0;} int GetNumPatterns (setPTR set) {if ((set == NULL) || (set-> initB! = TRUE)) return- 1; else return set->num_patterns;} int MakeSet (setPTR set, char * infile_name, int num_inputs, &#9;&#9; int type_inputs, char * outfile_name, &#9;&#9; int num_outputs, int type_outputs) {FILE * infile; / * A pointer to a file * / FILE * outfile; float * input; float * output; float tempflt; int i; / * Counter * / int status; int done; int out_of_data; if ( num_inputs <= 0) return 9; if (type_outputs! = NONE) if (num_outputs <= 0) return 9; / * Initialize Pattern Set Checking For Errors * / status = InitSet (set, num_inputs, type_inputs, num_outputs, type_outputs); if (status) return status; / * Allocate space for input and output strings * / input = (float *) malloc ((size_t) (num_inputs * sizeof (float))); if (input == NULL) return 3; if (type_outputs! = NONE) {output = (float *) malloc ((size_t) (num_outputs * sizeof (float))); if (output == NULL) return 3; outfile = fopen (outfile_name, "r"); if (outfile == NULL) return 6;} infile = fopen (infile_name, "r "); if (infile == NULL) return 5; done = FALSE; out_of_data = FALSE; while (! done) {/ * Read in input data * / status = fscanf (infile,"% f ", &tempflt); * (input + 0) = tempflt; if (status == EOF) done = TRUE; else {for (i = 1; i <num_inputs; i ++) &#9; if (! out_of_data) {&#9; status = fscanf (infile, "% f \ n", &tempflt);&#9; * (input + i) = tempflt; &#9;} if (status == EOF) out_of_data = TRUE; if (type_outputs! = NONE) &#9; for (i = 0; i <num_outputs; i ++) &#9; if (! out_of_data) {&#9; status = fscanf (outfile, "% f \ n", &tempflt);&#9; * (output + i) = tempflt; &#9;} if (status == EOF) out_of_data = TRUE;} if (out_of_data) done = TRUE; else if (! Done) {status = AddPattern (set, num_inputs, input, num_outputs, output); if (status == 2) return 7; if (status == 3) return 8; if (status == 4) return 9; if (status == 5) return 3;}} if (GetNumPatterns (set) == 0) return 9; / * Not enough data for one pattern! * / If (out_of_data) return 10; / * Uneven number of pattern data * / return 0;} int SetArtVigil (netPTR net, int component, float vigil) {/ * Check range * / if ((vigil> 1) || (vigil <0)) return 2; / * Check initialization * / if ((net == NULL) || (net-> initB! = TRUE)) return 3; / * Check network type and set * / if (component == ARTA) {if (net-> type! = ARTMAP) return 1; net-> map.artA.vigil = vigil; net-> map.base_vigil = vigil;} else if (component == ARTB) {if ((net -> type! = ARTMAP) || (net-> map.artB.type == NONE)) return 1; net-> map.artB.vigil = vigil;} else if (component == ART) {if (net -> type! = ART) return 1; net-> art.vigil = vigil;} else return 1; / * New Vigil So Training No Longer Up To Date * / net-> doneB = FALSE; return 0;} int SetMapVigil (netPTR net, float map_vigil) {/ * Check range * / if ((map_vigil> 1) || (map_vigil <0)) return 2; / * Check initialization * / if ((net == NULL) || (net-> initB! = TRUE)) return 3; / * Check network type and set * / if (net-> type! = ARTMAP) return 1; net-> map.vigil = map_vigil; / * New Vigil So Training No Longer Up To Date * / net-> doneB = FALSE; return 0;} int GetMapVigil (netPTR net, float * vigil ) {if ((net == NULL) || (net-> initB! = TRUE)) return 1; / * Check network type and set * / if (net-> type! = ARTMAP) return 2; * vigil = net->map.vigil; return 0;} int SetArtBeta (netPTR net, int component, float beta) {/ * Check range * / if ((beta> 1) || (beta <0)) return 2; / * Check initialization * / if ((net == NULL) || (net-> initB! = TRUE)) return 3; / * Check network type and set * / if (component == ARTA) {if (net-> type! = ARTMAP) return 1; net-> map.artA.beta = beta;} else if (component == ARTB) {if ((net-> type! = ARTMAP) || (net-> map.artB.type == NONE)) return 1; net-> map.artB.beta = beta;} else if (component == ART) {if (net-> type! = ART) return 1 ; net-> art.beta = beta;} else return 1; / * New Recoding Rate So Training No Longer Up To Date * / net-> doneB = FALSE; return 0;} int GetArtVigil (netPTR net, int component, float * vigil) {&#9;&#9; if ((net == NULL) || (net-> initB! = TRUE)) &#9; return 1; &#9;&#9; / * Check network type and set * / &#9; if (component == ARTA) {&#9;&#9; if (net-> type! = ARTMAP) &#9; return 2; &#9;&#9; * vigil = net->map.base_vigil;&#9;&#9; return 0; &#9;}&#9; else if (component == ARTB) {&#9;&#9; if ( (net-> type! = ARTMAP) || (net-> map.artB.type == NONE)) &#9; return 2; &#9;&#9; * vigil = net-> map.artB. vigil; &#9;&#9; return 0; &#9;}&#9; else if (component == ART) {&#9;&#9; if (net-> type! = ART) &#9; return 3; &#9;&#9; * vigil = net->art.vigil;&#9;&#9; return 0; &#9;}&#9; else &#9; return 4;} int GetArtWinner (netPTR net, int component) {if ((net == NULL) || (net-> initB! = TRUE)) return -2; / * Check network type and set * / if (component == ARTA) {if (net-> type! = ARTMAP) return -2; return net->map.artA.win_cat;} else if (component == ARTB) {if ((net-> type! = ARTMAP) || (net-> map.artB.type == NONE)) return -2; return net->map.artB.win_cat;} else if ( component == ART) {if (net-> type! = ART) return -2; return net->art.win_cat;} else return -2;} int GetArtBeta (netPTR net, int component, float * beta) {if ((net == NULL) || (net-> initB! = TRUE)) return 1; / * Check network type and set * / if (component == ARTA) (if (net-> type! = ARTMAP) return 2; * beta = net->map.artA.beta; return 0;} else if (component == ARTB) {if ((net-> type! = ARTMAP) || (net-> map.artB.type = = NONE)) return 2; * beta = net->map.artB.beta; return 0;} else if (component == ART) {if (net-> type! = ART) return 2; * beta = net- > ar t.beta; return 0;} else return 3;} int GetMap (netPTR net, float * list) {int i; FILE * dumpfile; if ((net == NULL) || (net-> initB! = TRUE) ) return 1; / * Check network type and set * / if (net-> type! = ARTMAP) return 2; else {for (i = 0; i <net->map.artB.nodes_used; i ++) * (list + i) = (* (net-> map.map + i)); return 0;}} int GetMapSize (netPTR net) {if ((net = = NULL) || (net-> initB! = TRUE)) return -1; / * Check network type and set * / if (net-> type! = ARTMAP) return -1; else return net-> map.artB .nodes_used;} int GetArtSize (netPTR net, int component) {int i; if ((net == NULL) || (net-> initB! = TRUE)) return -1; / * Check network type and set * / if (component == ARTA) {if (net-> type! = ARTMAP) return -1; else return net->map.artA.nodes_used;} else if (component == ARTB) {if (net-> type! = ARTMAP) return -1; else return net->map.artB.nodes_used;} else if (component == ART) {if (net-> type! = ART) return -1; else return net->art.nodes_used;} else return -1;} int GetSetInput (setPTR set, int pat_num, float * list) {int i; if ((set == NULL) || (set-> initB! = TRUE)) return 1; else if ((pat_num <0) || (pat_num>set-> num_patterns)) return 2; else {for (i = 0; i <set->num_inputs; i ++) &#9; list [i] = set-> pattern [pat_num] .input [i]; return 0;}} int GetSetInSize (setPTR set) {if ((set == NULL) || (set-> initB! = TRUE)) return -1; else return set->num_inputs;} int GetSetOutput (setPTR set, int pat_num, float * list) {int i; if ((set == NULL) | | (set-> initB! = TRUE)) return 1; else if ((pat_num <0) || (pat_num>set-> num_patterns)) return 2; else {for (i = 0; i <set->num_outputs; i ++) * (list + i) = (* (set-> pattern [pat_num] .output + i)); return 0;}} int GetSetOutSize (setPTR set) {if ((set == (NULL) || (set-> initB! = TRUE)) return -1; else return set->num_outputs;} int GetSetInType (setPTR set) {if ((set == NULL) || (set-> initB! = TRUE)) return -1; else return set->type_inputs;} int GetSetOutType (setPTR set) {if ((set == NULL) || (set-> initB! = TRUE)) return -1; else return set- >type_outputs;} int GetNetType (netPTR net) {if ((net == NULL) || (net-> initB! = TRUE)) return -1; else return net->type;} int GetArtType (netPTR net, int component) {/ * First check for unintialized network and invalid network type * / if ((net == NULL) || (net-> initB! = TRUE)) return -1; else if (net-> type == ART ) {if (component == ART) return net->art.type; else return -1;} else if (net-> type == ARTMAP) (if (component == ARTA) return net-> map.artA. type; else if (component == ARTB) return net->map.artB.type; else return -1;} else return -1;} int GetArtStyle (netPTR net, int component) {/ * First check for unintialized network and invalid network type * / if ((net == NULL) || (net-> initB! = TRUE)) return -1; else if (net-> type == ART) {if (component == ART ) return net->art.style; else return -1;} else if (net-> type == ARTMAP) {if (component == ARTA) return net->map.artA.style; else if (component == ARTB) return net->map.artB.style; else return -1;} else return -1;} int GetNetInSize (netPTR net) {if ((net == NULL) || (net-> initB! = TRUE) ) return -1; else return net->num_inputs;} int GetNetOutSize (netPTR net) {if ((net == NULL) || (net-> initB! = TRUE)) return -1; else return net->num_outputs;} int GetArtResets (netPTR net, int component) {/ * First check for unintialized network and invalid network type * / if ((net == NULL) || (net-> initB! = TRUE)) return -1; else if (net-> type == ART) {if (component == ART) return net->art.num_reset; else return -1;} else if (net-> type == ARTMAP) {if (component == ARTA ) return net->map.artA.num_reset; else if (component == ARTB) return net->map.artB.num_reset; else return -1;} else return -1;} int GetMapMismatch (netPTR net) {/ * Check network type and set * / if ((net == NULL) || (net-> initB! = TRUE) || (net-> type! = ARTMAP) ) return -1; else return net->map.num_mismatch;} int GetNetDone (netPTR net) {if ((net == NULL) || (net-> initB! = TRUE)) return -1; else return net- >doneB;} int GetNetInit (netPTR net) {if ((net == NULL) || (net-> initB! = TRUE)) return FALSE; else return TRUE;} int GetSetInit (setPTR set) {if ((set == NULL) || (set-> initB! = TRUE)) return FALSE; else return TRUE;} int FreeNet (netPTR net) {if ((net == NULL) || (net-> initB! = TRUE) ) return 1; net-> initB = FALSE; if (net-> type == ART) (free (net->art.cat); if (net-> art.type! = NONE) (free (net->art.elig); free (net->art.commit); free (net->art.weight); free (net->art.sum_weights); free (net->art.sum_IW);}} else if ( net-> map.artA.type == ARTMAP) (/ * Free ArtA Network * / free (net->map.artA.cat); free (net->map.artA.elig); free (net-> map .artA.commit); free (net->map.artA.weight); free (net->map.artA.sum_weights); free (net->map.artA.sum_IW); / * Free ArtB Network * / free (net->map.artB.cat); if (net-> map.artB.type! = NONE) (free (net->map.artB.elig); free (net-> map .artB.commit); free (net->map.artB.weight); free (net->map.artB.sum_weights); free (net->map.artB.sum_IW);} free (net-> map. map); free (net->map.map_weight);} return 0;} int FreeSet (setPTR set) {int i; if ((set == NULL) || (set-> initB! = TRUE)) return 1 ; set-> initB = FALSE; / * Free space for input / output vectors patterns * / for (i = 0; i <set->max_num_patterns; i ++) {free (set-> pattern [i] .input); if (set-> type_outputs! = NONE) free (set-> pattern [i] .output);} free (set- >pattern); return 0;} / * Sim.c / * Gets in integer value from the user * / int GetInt (void) {&#9; char input [100]; &#9; gets (input) ; &#9; return atoi (input);} / * Gets in float value from the user * / float GetFloat (void) {&#9; char input [100]; &#9; gets (input); &#9; return atof (input);} / * Gets in char value from the user * / char GetLetter (void) {&#9; char input [100]; &#9; gets (input); &#9; return input [0];} void DumpNet (netPTR net) {float vigil, beta; if (GetNetType (net) == ART) {printf ("\ t ART NETWORK: \ n"); if (GetArtType (net, ART) == ART1) printf ("\ t Art Type: ART1 \ n"); else printf ("\ t Art Type: FUZZYART \ n"); printf ("\ t Inputs:% 9i \ n", GetNetInSize (net) ); printf ("\ t Nodes:% 9i \ n", GetArtSize (net, ART)); GetArtVigil (net, ART, &vigil); printf ("\ t Vigilance:% 3.3f \ n", vigil); GetArtBeta (net, ART, &beta); printf ("\ t Recoding Rate:% 3.3f \ n", beta); if (GetArtStyle ( net, ART) == COMPLIMENT) printf ("\ t Compliment Coding: On \ n"); else printf ("\ t Compliment Coding: Off \ n");} else {GetMapVigil (net, &vigil); printf (" \ t ARTMAP NETWORK: \ t \ t Map Vigilance:% 3.3f \ n ", vigil); if (GetArtType (net, ARTA) == ART1) printf (" \ t ArtA Type: ART1 "); else printf (" \ t ArtA Type: FUZZYART "); if (GetArtType (net, ARTB) == ART1) printf (" \ t ArtB Type: ART1 \ n "); else if (GetArtType (net, ARTB) == FUZZYART) printf ( "\ t ArtB Type: FUZZYART \ n"); else printf ("\ t ArtB Type: NONE \ n"); printf ("\ t Inputs:% 9i", GetNetInSize (net)); printf ("\ t Outputs :% 9i \ n ", GetNetOutSize (net)); printf (" \ t Nodes:% 9i ", GetArtSize (net, ARTA)); printf (" \ t Nodes:% 9i \ n ", GetArtSize (net, ARTB )); GetArtVigil (net, ARTA, &vigil); printf ("\ t Vigilance:% 3.3f", vigil); if (GetArtType (net, ARTB)! = NONE) {GetArtVigil (net, ARTB, &vigil); printf ("\ t Vigilance:% 3.3f \ n", vigil);} else printf ("\ t Vigilance: n / a \ n"); GetArtBeta (net, ARTA, &beta); printf ("\ t Recoding Rate: % 3.3f ", beta); if (GetArtType (net, ARTB)! = NONE) {GetArtBeta (net, A RTB, &beta); printf ("\ t Recoding Rate:% 3.3f \ n", beta);} else printf ("\ t Recoding Rate: n / a \ n"); if (GetArtStyle (net, ARTA) = = COMPLIMENT) printf ("\ t Compliment Coding: On"); else printf ("\ t Compliment Coding: Off"); if (GetArtType (net, ARTB)! = NONE) {if (GetArtStyle (net, ARTB) = = COMPLIMENT) &#9; printf ("\ t Compliment Coding: On \ n"); else &#9; printf ("\ t Compliment Coding: Off \ n");} else printf ("\ t Compliment Coding: n / a \ n ");}} void DumpSet (setPTR set) {&#9; printf (" \ t PATTERN SET:% 11s \ t Patterns:% 12i \ n ", pattern_name, GetNumP atterns (set)); &#9;&#9; if (GetSetInType (set) == BINARY) &#9;&#9; printf ("\ t Input Type: BINARY");&#9; else &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; printf ("\ t Input Type: ANALOG");&#9;&#9; if (GetSetOutType (set) == BINARY) &#9;&#9;&#9; printf ("\ t Output Type: B INARY \ n");&#9; else if (GetSetOutType (set) == ANALOG) &#9; printf ("\ t Output Type: ANAL OG \ n");&#9; else &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; printf ("\ t Output Type: NONE \ n");&#9;&#9; printf ("\ t Input Size:% 10i", GetSetInSize ( set)); &#9;&#9; if (GetSetOutType (set)! = NONE) &#9;&#9; printf ("\ t Output Size:% 9i \ n", GetSetOutSize (set)); &#9; else &#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; printf ("\ n");} / * Load a network from a data file * / int LoadNetwork (netPTR net) {&#9; char file_name [80]; &#9; int status; &#9;&#9; printf ("\ n \ tNetwork Name:");&#9; gets (file_name); &#9; printf ("\ tLoading Network from% s.net \ n", file_name); &#9; status = LoadNet (net, file_name); &#9;&#9; if (status == 1) {&#9;&#9; printf ("\ n \ tFile% s.net not found! \ N \ n", file_name); &#9;&#9; return 1; &#9;}&#9; if (status == 2) {&#9;&#9; printf ("\ n \ tError! Out of memory! \ N \ n");&#9;&#9; return 1; &#9;}&#9; return 0;} / * Load a pattern set from a file * / int LoadPatternSet (setPTR set) {&#9; char file_name [80]; &#9; int status; &#9;&#9; printf ("\ n \ tPattern Set Name:");&#9; gets (file_name); &#9; strcpy (pattern_name, file_name); &#9; printf ("\ tLoading Input / Output Patterns from% s.pat \ n \ tset:% d", file_name, set); &#9; status = LoadSet (set, file_name); &#9;&#9; if (status == 1) {&#9;&#9; printf ("\ n \ tFile% s.pat not found! \ N \ n", file_name); &#9;&#9; return 1; &#9;}&#9; if (status == 2) {&#9;&#9; printf ("\ n \ tError! Out of memory! \ n");&#9;&#9; return 1; &#9;}&#9; return 0;} / * Initialize a new network, getting information from the user * / int InitNetwork (netPTR net) {int nettype; int typeA, typeB; int sizeA, sizeB; int styleA, styleB; int status; / * Initialization status * / char input; status = TRUE; while (status) {printf ("\ tInitialize Network: \ n"); printf ("\ tNetwork Types:"); printf ("\ n \ t \ t% i -Art ", ART); printf (" \ n \ t \ t% i-ArtMap ", ARTMAP); printf (" \ n \ t \ t What type: "); nettype = GetInt (); printf (" \ n \ n \ t \ tArt Types: "); printf (" \ n \ t \ t% i-Art1 ", ART1); printf (" \ n \ t \ t% i-FuzzyArt ", FUZZYART); printf ( "\ n \ t \ t What type:"); typeA = GetInt (); printf ("\ t \ t Input Size:"); sizeA = GetInt (); printf ("\ n \ n \ t \ tInput Styles : "); printf (" \ n \ t \ t% i-Normal ", NONE); printf (" \ n \ t \ t% i-Compliment Coded ", COMPLIMENT); printf (" \ n \ t \ t What Style: "); styleA = GetInt (); if (nettype == A RTMAP) {printf ("\ n \ n \ t \ tTypeB Types: \ n"); printf ("\ t \ t% i-Art1 \ n", ART1); printf ("\ t \ t% i-FuzzyArt \ n ", FUZZYART); printf (" \ t \ t% i-None \ n ", NONE); printf (" \ t \ t What type: "); typeB = GetInt (); printf (" \ t \ t Output Size: "); sizeB = GetInt (); &#9; if (typeB! = NONE) {&#9; printf (" \ n \ n \ t \ tOutput Styles: ");&#9; printf ("\ n \ t \ t% i-Normal", NONE); &#9; printf ("\ n \ t \ t% i-Compliment Coded \ n", COMPLIMENT); &#9; printf ("\ t \ t What Style: ");&#9; styleB = GetInt ();} else &#9; styleB = NONE;} printf (" \ n \ tInitializing network. \ n \ n "); status = InitNet ( net, nettype, typeA, styleA, sizeA, typeB, styleB, sizeB); if (status == 5) {printf ("\ n \ tNetwork already initialized.Re-initialize (y / n)?"); input = GetLetter (); if (input == 'y') {&#9; FreeNet (net); &#9; status = InitNet (net, nettype, typeA, styleA, sizeA, typeB, styleB, sizeB);} else &#9; return 1;} if (status == 6) {printf ("\ n \ tError! Out of memory! \ N"); return 1;} else if (status) {printf ("\ tInitialization Error #% i! Incorrect Format. \ n ", status); printf (" \ tTry Again ( y / n)? "); input = GetLetter (); if (input! = 'y') &#9; return 1;}} return 0;} / * Set vigilance levels according to user input * / void SetVigil ( netPTR net) {&#9; float vigil; &#9; char trash; &#9; int type; &#9; int status; &#9; type = GetNetType (net); &#9; if (type == ART) {&#9;&#9; GetArtVigil (net, ART, &vigil);&#9;&#9; printf ("\ n \ t Art Vigil (% 3.3f):", vigil); &#9;&#9; vigil = GetFloat (); &#9;&#9; status = SetArtVigil (net, ART, vigil); &#9;&#9; if (status) {&#9;&#9;&#9; printf ("\ n \ tIncorrect range (% f)! Must be between 0 and 1. \ n", vigil); &#9;&#9;&#9;return;&#9;&#9;}&#9;}&#9; else if (type == ARTMAP) {&#9;&#9; GetArtVigil (net, ARTA, &vigil);&#9;&#9; printf ("\ n \ tArt-A Vigilance (% 3.3f):", vigil); &#9;&#9; vigil = GetFloat (); &#9;&#9; status = SetArtVigil (net, ARTA, vigil); &#9;&#9; if (status) {&#9;&#9;&#9; printf ("\ n \ tIncorrect range (% f)! Must be between 0 and 1. \ n ", vigil); &#9;&#9;&#9;return;&#9;&#9;}&#9;&#9; if (GetArtType (net, ARTB)! = NONE) {&#9;&#9;&#9; GetArtVigil (net, ARTB, &vigil);&#9;&#9;&#9; printf (" \ tArt-B Vigilance (% 3.3f): ", vigil); &#9;&#9;&#9; vigil = GetFloat (); &#9;&#9;&#9; status = SetArtVigil ( net, ARTB, vigil); &#9;&#9;&#9; if (status) {&#9;&#9;&#9;&#9; printf ("\ n \ tIncorrect range (% f)! Must be between 0 and 1. \ n ", vigil); &#9;&#9;&#9;&#9;return;&#9;&#9;&#9;}&#9;&#9;}&#9;&#9; GetMapVigil (net, &vigil);&#9;&#9; printf ("\ tMapfield Vigilance (% 3.3f):", vigil); &#9;&#9; vigil = GetFloat (); &#9;&#9; status = SetMapVigil (net, vigil); &#9;&#9; if (status) {&#9;&#9;&#9; printf ("\ n \ tIncorrect range (% f)! Must be between 0 and 1. \ n", vigil); &#9;&#9;&#9;return;&#9;&#9;}&#9;}&#9; printf ("\ n");} / * Set Recoding Rate according to User Input * / void SetBeta (netPTR net) {float beta; char trash; int type; int status ; type = GetNetType (net); if (type == ART) {GetArtBeta (net, ART, &beta); printf ("\ n \ n \ tArt Beta (% 3.3f):", beta); beta = GetFloat ( ); SetArtBeta (net, ART, beta); if (status) {printf ("Incorrect range! Must be between 0 and 1. \ n");return;}} else if (type == ARTMAP) {GetArtBeta (net , ARTA, & beta ); printf ("\ n \ n \ tArt-A Beta (% 3.3f):", beta); beta = GetFloat (); status = SetArtBeta (net, ARTA, beta); if (status) {printf (" Incorrect range! Must be between 0 and 1. \ n ");return;} GetArtBeta (net, ARTB, &beta); printf (" \ tArt-B Beta (% 3.3f): ", beta); beta = GetFloat ( ); status = SetArtBeta (net, ARTB, beta); if (status == 2) {printf ("Incorrect range! Must be between 0 and 1. \ n");return;} else if (status) {printf ( "Network needs to initialized first! \ N");return;}}} / * Merge two pattern sets * / void MergePatternSets (void) {char set1_name [30]; char set2_name [30]; char save_name [30]; char trash; int status; printf ("\ n \ tFirst Pattern Set Name:"); gets (set1_name); printf ("\ tSecond Pattern Set Name:"); gets (set2_name); printf ("\ tNew Pattern Set Name: "); gets (save_name); printf (" \ tMerging% s.pat &% s.pat into% s.pat. \ n \ n ", &#9; set1_name, set2_name, save_name); status = MergeSets (set1_name , set2_name, save_name); if (status == 2) printf ("\ n \ tFile% s.pat not found! \ n \ n", set1_name); else if (status == 3) pri ntf ("\ n \ tFile% s.pat not found! \ n \ n", set2_name); else if (status == 4) printf ("\ n \ tError! Out of memory! \ n"); else if (status) printf ("\ n \ tError Merging. Incompatible Sets. \ n \ n");} / * Make pattern set * / int MakePatternSet (setPTR set) {char file1_name [80]; char file2_name [80]; int type_inputs; int type_outputs; int num_inputs; int num_outputs; int status; printf ("\ n \ tInput Types: \ n"); printf ("\ t% i-Binary \ n", BINARY); printf ("\ t% i-Analog \ n ", ANALOG); printf (" \ t What type: "); type_inputs = GetInt (); printf (" \ t Input Size: "); num_inputs = GetInt (); printf (" \ n \ tInput Pattern Set Name: "); gets (file1_name); printf (" \ n \ n \ tOutput Types: \ n "); printf (" \ t% i-Binary \ n ", BINARY); printf (" \ t % i-Analog \ n ", ANALOG); printf (" \ t% i-None \ n ", NONE); printf (" \ n \ t What type: "); type_outputs = GetInt (); if (type_outputs! = NONE) {printf ("\ t Output Size:"); num_outputs = GetInt (); printf ("\ tOutput Pattern Set Name:"); gets (file2_name);} else num_outputs = 0; printf ("\ n \ tCreating Pattern Set from: % s \ n ", file1_name); if (type_outputs! = NONE) printf (" \ t and:% s \ n ", file2_name); status = MakeSet (set, file1_name, num_inputs, type_inputs, &#9;&#9; file2_name, num_outputs, type_outputs); printf ("\ n"); if (status == 1) {printf ("\ t Invalid set type !! \ n"); return 1;} if (status == 3 ) {printf ("\ t Out of memory! \ n"); return 1;} if (status == 5) {printf ("\ t Input File% s not found! \ n", file1_name); return 1; } else if (status == 6) {printf ("\ t Output file% s not found! \ n", file2_name); return 1;} else if (status == 7) {printf ("\ t Analog data given for binary Art type! \ n "); return 1;} else if (status == 8) {printf (" \ t Analog data not properly bounded between 0 and 1! \ n "); return 1;} else if ( status == 9) {printf ("\ t Input or Output Vector has only zero values or zero size! \ n"); return 1;} else if (status == 10) {printf ("\ t Warning. Uneven number of input or output patterns. \ n "); return 0;} else if (status) {printf (" \ tMakeSet Error #% i! \ n \ n ", status); return 1;} return 0;} / * Save a network * / void S aveNetwork (netPTR net, setPTR set) {char save_name [30]; char trash; int status; printf ("\ tSave Network Name:"); gets (save_name); printf ("\ tSaving network to% s.net \ n \ n ", save_name); status = SaveNet (net, set, save_name); if (status) printf (" \ n \ tError opening save file% s.net! \ n \ n ", save_name);} / * Save a Pattern Set * / void SavePatternSet (setPTR set) {char save_name [30]; char trash; int status; printf ("\ tSave Pattern Set Name:"); gets (save_name); printf ("\ tSaving pattern set to% s.set \ n \ n ", save_name); status = SaveSet (set, save_name); if (status) printf (" \ n \ tError opening save file% s.pat! \ n \ n ", save_name); / * Train the Network * / int TrainNetwork (netPTR net, setPTR set) {int status; int epoch; int done; / * Train the net * / printf ("\ n \ tTraining Network: \ n"); done = FALSE ; epoch = 0; / * Continue until training is done * / / * Calls train net with a max_epochs of 1.This allows one * / / * to step through training one epoch at a time dumping results * / / * about the number of mismatches and re sets after each epoch. * / while (done == FALSE) {epoch ++; printf ("\ tEPOCH #% i \ n", epoch); status = TrainSet (net, set, 1); if (status == 3) {printf ("\ n \ tAnalog patterns given to binary network! \ n"); return 1;} if (status == 4) {printf ("\ n \ tNetwork and pattern set input size incompatible! \ n"); return 1;} if (status == 5) {printf ("\ n \ tNetwork and pattern set output size incompatible! \ n"); return 1;} if (status == 6) {printf ("\ n \ tNo output patterns provided for ARTMAP network! \ n "); return 1;} if (status == 7) {printf (" \ n \ tError! Out of memory! \ n "); return 1;} else if (status) {printf ("\ n \ tTraining Error #% i: Incompatible Patterns and Network! \ n \ n", status); return 1;} else if (GetNetType (net) == ART) {printf ("\ t% 5i Art Nodes Used. \ N ", GetArtSize (net, ART)); printf (" \ t% 5i Art Resets. \ N ", GetArtResets (net, ART));} else if (GetArtType (net, ARTB) == NONE) {printf ("\ t% 5i ArtA Nodes Used. \ N", GetArtSize (net, ARTA)); printf ("\ t% 5i ArtA Resets. \ N", GetArtResets (net, ARTA)); printf ( "\ t% 5i Map Mismatches. \ n", GetM apMismatch (net));} else {printf ("\ t% 5i ArtA Nodes Used. \ n", GetArtSize (net, ARTA)); printf ("\ t% 5i ArtB Nodes Used. \ n", GetArtSize (net , ARTB)); printf ("\ t% 5i ArtA Resets. \ N", GetArtResets (net, ARTA)); printf ("\ t% 5i ArtB Resets. \ N", GetArtResets (net, ARTB)); printf ("\ t% 5i Map Mismatches. \ n", GetMapMismatch (net));} done = GetNetDone (net);} printf ("\ tDONE TRAINING. \ n \ n"); return 0;} / * Test the Network on a Set collecting information about its results * / / * and dumping input / output patterns in a file, "test.result". * / Int TestNetwork (netPTR net, setPTR set) {int total_correct; int total_errors; int total_noansA; int total_noansB; int status; printf ("\ tTesting Network. \ n"); status = TestNet (net, set, & total_correct, & total_errors, &#9;&#9;& total_noansA, &total_noansB); if (status == 3) {printf ("\ n \ tAnalog patterns given to binary network! \ n"); return 1;} if (status == 4) {printf ("\ n \ tNetwork and pattern set input size incompatible! \ n"); return 1;} if (status == 5) {printf ("\ n \ tNetwork and pattern s et output size incompatible! \ n "); return 1;} if (status == 6) {printf (" \ n \ tNo output patterns provided for ARTMAP network! \ n "); return 1;} if (status == 7) {printf ("\ n \ tError! Out of memory! \ N"); return 1;} else if (GetNetType (net) == ARTMAP) {printf ("\ tTotal Correct:% 5i (% 6.2f% %) \ n ", total_correct, &#9; 100 * (float) total_correct / GetNumPatterns (set)); printf (" \ tTotal Errors:% 5i (% 6.2f %%) \ n ", total_errors, &#9; 100 * (float) total_errors / GetNumPatterns (set)); printf ("\ tTotal ArtA No Ans:% 5i (% 6.2f %%) \ n", total_noansA, &#9; 100 * (float) total_noansA / GetNumPatterns (set)); printf ("\ tTotal ArtB No Ans:% 5i (% 6.2f %%) \ n", total_noansB, &#9; 100 * (float) total_noansB / GetNumPatterns (set));} else {printf ("\ tTotal Answered:% 5i (% 6.2f%) \ n", total_correct, &#9; 100 * (float) total_correct / GetNumPatterns (set)); printf ("\ tTotal ArtA No Ans:% 5i (% 6.2f%) \ n ", total_noansA, &#9; 100 * (float) total_noansA / GetNumPatterns (set));} printf (" \ n "); return 0;} / * Main User Interface Loop * / void main () {&#9; netTYPE net; / * D elcare a network of type netTYPE * / &#9; setTYPE set; / * Declare a pattern set of type setTYPE * / &#9; int SetInit = FALSE; &#9; int NetInit = FALSE; &#9; int NetNew = FALSE; &#9; int i, j, status, pause; &#9; char option; &#9; printf ("\ n");&#9; option = '';&#9; while ( option! = 'Q') {&#9;&#9; pause = FALSE; &#9;&#9; printf ("\ n \ n");&#9;&#9; printf ("= ================================================== === \ n ");&#9;&#9; if ((NetInit) || (NetNew)) DumpNet (&net);&#9;&#9; else &#9;&#9;&#9;&#9;&#9; printf ("\ t NO NETWORK IN MEMORY \ n");&#9;&#9; printf ("--------------- --------------------------------------- \ n ");&#9;&#9; if (SetInit) &#9;&#9;{&#9;&#9;&#9; // printf ("\ t PATTERN SET:% s Patterns:% 12i \ n", GetNumPattern s ( set)); &#9;&#9;&#9; DumpSet (&set);&#9;&#9;}&#9;&#9; else &#9;&#9;&#9;&#9; printf ("\ t NO PATTERN SET IN MEMORY \ n");&#9;&#9; printf ("==================== ================================== \ n ");&#9;&#9; if (! SetInit) &#9;&#9;&#9;&#9; printf ("\ t P-Load (P) atterns");&#9;&#9; else &#9;&#9;&#9;&#9;&#9;&#9; printf ("\ t T-Save Pa (t) tern Set");&#9;&#9; if ((! NetInit) && (! NetNew)) &#9; printf ("\ t N-Load ( N) etwork \ n ");&#9;&#9; else if (NetInit) &#9;&#9;&#9; printf (" \ t S-(S) ave Network \ n ");&#9;&#9; else &#9;&#9;&#9;&#9;&#9;&#9; printf ("\ n");&#9;&#9; if ( ! SetInit) &#9;&#9;&#9;&#9; printf ("\ t K-Ma (k) e Pattern Set");&#9;&#9; else &#9;&#9;&#9;&#9;&#9;&#9; printf ("\ t F-(F) ree Pattern Space");&#9;&#9; if ((! NetInit) && ( ! NetNew)) &#9; printf ("\ t W-Make Net (w) ork \ n");&#9;&#9; else &#9;&#9;&#9;&#9;&#9;&#9; printf ("\ t O-Free Netw (o) rk \ n");&#9;&#9; if ((NetInit) || (NetNew)) {&#9;&#9;&#9; printf ("\ t V-Set (V) igilance");&#9;&#9;&#9; printf ("\ t \ t R-Set (R) ecoding Rate \ n ");&#9;&#9;}&#9;&#9; if (((NetInit) || (NetNew)) && (SetInit)) {&#9;&#9;&#9; printf ("\ t A-Tr (a) in Network");&#9;&#9;&#9; if (NetInit) &#9;&#9; printf ("\ t \ t E -T (e) st Network \ n ");&#9;&#9;&#9; else &#9;&#9;&#9;&#9; printf (" \ n ");&#9;&#9;}&#9;&#9; printf ("\ t M-(M) erge Pattern Files");&#9;&#9; printf ("\ t Q-(Q) uit \ n ");&#9;&#9; printf (" ====== ================================================ \ n ");&#9;&#9; printf (" \ tSetInit:% d ", SetInit); &#9;&#9; printf (" \ tNetInit:% d ", NetInit); &#9;&#9; printf ("\ tNetNew:% d", NetNew); &#9;&#9; printf ("\ n \ tset:% d", set); &#9;&#9; printf (" \ tnet:% d ", net); &#9;&#9; printf (" \ tpause:% d \ n ", pause); &#9;&#9; printf (" ====== ================================================ \ n ");&#9;&#9; printf (" \ n \ tOption: ");&#9;&#9; option = GetLetter (); &#9;&#9; switch (option) {&#9;&#9;&#9; case 'Q': case 'q': &#9;&#9;&#9;&#9; printf ("\ n Goodbye \ n \ n");&#9;&#9;&#9;&#9; option = 'Q';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'N': case 'n': &#9;&#9;&#9;&#9; if ((! NetInit) && (! NetNew)) {&#9;&#9;&#9;&#9;&#9; status = LoadNetwork (&net);&#9;&#9;&#9;&#9;&#9; if (! Status) NetInit = TRUE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'P': case 'p': &#9;&#9;&#9;&#9; if (! SetInit ) {&#9;&#9;&#9;&#9;&#9; status = LoadPatternSet (&set);&#9;&#9;&#9;&#9;&#9; if (! status) &#9; SetInit = TRUE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9; printf ("\ n \ tset:% d", set); &#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'W': case 'w': &#9;&#9;&#9;&#9; if ((! NetInit) && (! NetNew)) {&#9;&#9;&#9;&#9;&#9; status = InitNetwork (&net);&#9;&#9;&#9;&#9;&#9; if (! Status) &#9; NetNew = TRUE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'V': case 'v': &#9;&#9;&#9;&#9; if ( (NetInit) || (NetNew)) &#9; SetVigil (&net);&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'R': case 'r': &#9;&#9;&#9;&#9; if ((NetInit) || (NetNew)) &#9; SetBeta (&net);&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'A': case 'a': &#9;&#9;&#9;&#9; if ((NetInit) || (NetNew)) {&#9;&#9;&#9;&#9;&#9; status = TrainNetwork (& net, &set);&#9;&#9;&#9;&#9;&#9; if (! Status) {&#9;&#9;&#9;&#9;&#9;&#9; NetInit = TRUE; &#9;&#9;&#9;&#9;&#9;&#9; NetNew = FALSE; &#9;&#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9;&#9; pause = TRUE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'E': case 'e': &#9;&#9;&#9;&#9; if ((NetInit) || (NetNew)) {&#9;&#9;&#9;&#9;&#9; status = TestNetwork (& net, &set);&#9;&#9;&#9;&#9;&#9; if (status == 1) &#9; printf ("\ t \ tError! Out of memory! \ N");&#9;&#9;&#9;&#9;&#9; else &#9; pause = TRUE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'M': case 'm': &#9;&#9;&#9;&#9; MergePatternSets ( ); &#9;&#9;&#9;&#9; pause = TRUE; &#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'S': case 's': &#9;&#9;&#9;&#9; if (NetInit) {&#9;&#9;&#9;&#9;&#9; SaveNetwork (& net, &set);&#9;&#9;&#9;&#9;&#9; pause = TRUE; &#9;&#9;&#9;&#9; } &#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'F': case 'f': &#9;&#9;&#9;&#9; if (SetInit) {&#9;&#9;&#9;&#9;&#9; printf ("\ n Clearing pattern set from memory. \ N");&#9;&#9;&#9;&#9;&#9; FreeSet (&set);&#9;&#9;&#9;&#9;&#9; SetInit = FALSE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'O': case 'o': &#9;&#9;&#9;&#9; if (( (NetInit) || (NetNew)) {&#9;&#9;&#9;&#9;&#9; printf ("\ n Clearing network from memory. \ N");&#9;&#9;&#9;&#9;&#9; FreeNet (&net);&#9;&#9;&#9;&#9;&#9; NetInit = FALSE; &#9;&#9;&#9;&#9;&#9; NetNew = FALSE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'K': case 'k': &#9;&#9;&#9;&#9; if (! SetInit) {&#9;&#9;&#9;&#9;&#9; status = MakePatternSet (&set);&#9;&#9;&#9;&#9;&#9; if (! Status) &#9;&#9;&#9;&#9;&#9; SetInit = TRUE; &#9;&#9;&#9;&#9;&#9; pause = TRUE; &#9;&#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; case 'T': case 't': &#9;&#9;&#9;&#9; if (SetInit) {&#9;&#9;&#9;&#9;&#9; SavePatternSet (&set);&#9;&#9;&#9;&#9;&#9; pause = TRUE; &#9;&#9;&#9;&#9;}&#9;&#9;&#9;&#9; else &#9; option = 'I';&#9;&#9;&#9;&#9;break;&#9;&#9;&#9; default: &#9;&#9;&#9;&#9;&#9; printf ("\ n Illegal Option! \ N");&#9;&#9;&#9;&#9;break;&#9;&#9;}&#9;&#9; if (option == 'I') &#9; printf ( "\ n \ t Illegal Option! \ n");&#9;&#9; if (pause) {&#9;&#9;&#9; printf ("--------- ------------------------------------------ ---- \ n ") ; &#9;&#9;&#9; printf ("Press Enter \ n");&#9;&#9;&#9; option = GetLetter (); &#9;&#9;}&#9;}} In the above description, &# 9 indicates a tab.

【図面の簡単な説明】[Brief description of the drawings]

【図1】図1はこの発明の実施例においてクラスタリン
グ処理を適用された遺伝子を示す表である。
FIG. 1 is a table showing genes to which clustering processing has been applied in an embodiment of the present invention.

【図2】図2はこの発明の他の実施例のクラスタリング
方法と比較例のクラスタリング方法との結果を比較する
表である。
FIG. 2 is a table comparing results of a clustering method according to another embodiment of the present invention and a clustering method according to a comparative example.

【図3】図3は実施例のクラスタリング方法でノード1
に分類された表現パターンを表すグラフである。
FIG. 3 is a diagram illustrating a node 1 in the clustering method according to the embodiment;
7 is a graph showing expression patterns classified into.

【図4】図4は実施例のクラスタリング方法でノード2
に分類された表現パターンを表すグラフである。
FIG. 4 is a diagram illustrating a node 2 in the clustering method according to the embodiment;
7 is a graph showing expression patterns classified into.

【図5】図5は実施例のクラスタリング方法でノード3
に分類された表現パターンを表すグラフである。
FIG. 5 is a diagram illustrating a node 3 in the clustering method according to the embodiment;
7 is a graph showing expression patterns classified into.

【図6】図6は実施例のクラスタリング方法でノード4
に分類された表現パターンを表すグラフである。
FIG. 6 is a diagram showing a node 4 in the clustering method according to the embodiment;
7 is a graph showing expression patterns classified into.

【図7】図7は実施例のクラスタリング方法でノード5
に分類された表現パターンを表すグラフである。
FIG. 7 is a diagram showing a node 5 in the clustering method according to the embodiment;
7 is a graph showing expression patterns classified into.

【図8】図8は比較例としての階層的クラスタリング方
法を実行して得られた系統樹を示す。
FIG. 8 shows a phylogenetic tree obtained by executing a hierarchical clustering method as a comparative example.

【図9】図9は実施例の装置を示す。FIG. 9 shows an apparatus of an embodiment.

【符号の説明】[Explanation of symbols]

16 スキャナ(DNAスキャニング装置) 16 Scanner (DNA scanning device)

───────────────────────────────────────────────────── フロントページの続き (51)Int.Cl.7 識別記号 FI テーマコート゛(参考) C12Q 1/68 C12N 15/00 F (72)発明者 冨田 秀太 愛知県名古屋市昭和区福原町3−12 コー ポふくしま202 Fターム(参考) 4B024 AA11 BA80 CA04 CA09 CA12 HA12 4B029 AA07 BB20 FA12 4B063 QA01 QA08 QQ42 QQ53 QR08 QR32 QR55 QR62 QS25 QS34 QS36 QX02 5B075 ND03 ND20 NR02 NR12 PP30 PQ02 PR06 QM08 UU19 ──────────────────────────────────────────────────の Continued on the front page (51) Int.Cl. 7 Identification symbol FI Theme coat ゛ (Reference) C12Q 1/68 C12N 15/00 F (72) Inventor Shuta Tomita 3-12 Fukuharacho, Showa-ku, Nagoya-shi, Aichi Prefecture Corporate Fukushima 202 F term (reference) 4B024 AA11 BA80 CA04 CA09 CA12 HA12 4B029 AA07 BB20 FA12 4B063 QA01 QA08 QQ42 QQ53 QR08 QR32 QR55 QR62 QS25 QS34 QS36 QX02 5B075 ND03 ND20 NR02 Q19 U08

Claims (20)

【特許請求の範囲】[Claims] 【請求項1】 複数の遺伝子の発現状態の変化を解析
し、該遺伝子をクラスタリングする方法であって、 前記遺伝子の発現状態の変化を表すシグナルパターンを
得るステップ、 得られたシグナルパターンをARTの手法で処理するステ
ップ、を含む遺伝子のクラスタリング方法。
1. A method for analyzing changes in the expression state of a plurality of genes and clustering the genes, wherein a step of obtaining a signal pattern representing the change in the expression state of the gene is performed. A method of clustering genes, the method comprising:
【請求項2】 前記シグナルパターンは蛍光量の変化の
パターンである、ことを特徴とする請求項1に記載の方
法。
2. The method according to claim 1, wherein the signal pattern is a pattern of a change in the amount of fluorescence.
【請求項3】 複数の遺伝子の発現状態の変化を解析
し、該遺伝子をクラスタリングする装置であって、 前記遺伝子の発現状態の変化を表すシグナルパターンを
得る手段、 得られたシグナルパターンをARTの手法で処理する手
段、を含む遺伝子のクラスタリング装置。
3. An apparatus for analyzing changes in the expression states of a plurality of genes and clustering the genes, wherein the means for obtaining a signal pattern representing the changes in the expression states of the genes is provided. A gene clustering apparatus, comprising: means for processing by a method.
【請求項4】 前記シグナルパターンは蛍光量の変化の
パターンである、ことを特徴とする請求項3に記載の装
置。
4. The apparatus according to claim 3, wherein the signal pattern is a pattern of a change in the amount of fluorescence.
【請求項5】 複数の遺伝子の発現状態の変化を解析
し、該遺伝子をクラスタリングする方法であって、 前記遺伝子の発現状態の変化を表すシグナルパターンを
得るステップ、 得られたシグナルパターンと既存のノードパターンとの
類似度を演算し、得られた前記シグナルパターンに最も
類似するノードパターンを選択する選択ステップ、 該選択されたノードパターンと前記シグナルパターンと
の類似度が予め定められた許容範囲内のとき前記シグナ
ルパターンを前記選択されたノードパターンに分類し、
前記類似度が前記許容範囲外のとき前記シグナルパター
ンに基づき新たなノードパターンを形成するパターン分
類ステップ、 とを含む遺伝子のクラスタリング方法。
5. A method for analyzing changes in the expression state of a plurality of genes and clustering the genes, wherein a step of obtaining a signal pattern representing the change in the expression state of the genes is performed. A selecting step of calculating a similarity with the node pattern and selecting a node pattern most similar to the obtained signal pattern; a similarity between the selected node pattern and the signal pattern is within a predetermined allowable range At the time of classifying the signal pattern into the selected node pattern,
A pattern classification step of forming a new node pattern based on the signal pattern when the similarity is outside the allowable range.
【請求項6】 前記分類ステップにおいて前記選択され
たノードパターンと前記シグナルパターンとの類似度が
前記所定範囲内のとき、前記選択されたノードパターン
を修正する修正ステップが更に含まれる、ことを特徴と
する請求項5に記載の方法。
6. The method according to claim 6, further comprising the step of modifying the selected node pattern when the degree of similarity between the selected node pattern and the signal pattern in the classification step is within the predetermined range. The method according to claim 5, wherein
【請求項7】 前記修正ステップでは前記シグナルパタ
ーンに基づいて前記選択されたノードパターンが修正さ
れる、ことを特徴とする請求項6に記載の方法。
7. The method of claim 6, wherein the modifying step modifies the selected node pattern based on the signal pattern.
【請求項8】 前記シグナルパターンは蛍光量変化のパ
ターンである、ことを特徴とする請求項5〜7のいずれ
かに記載の方法。
8. The method according to claim 5, wherein the signal pattern is a pattern of a change in the amount of fluorescence.
【請求項9】 複数の遺伝子の発現状態の変化を解析
し、該遺伝子をクラスタリングする装置であって、 前記遺伝子の発現状態の変化を表すシグナルパターンを
得る手段、 得られたシグナルパターンと既存のノードパターンとの
類似度を演算し、得られた前記シグナルパターンに最も
類似するノードパターンを選択する選択手段、 該選択されたノードパターンと前記シグナルパターンと
の類似度が予め定められた許容範囲内のとき前記シグナ
ルパターンを前記選択されたノードパターンに分類し、
前記類似度が前記許容範囲外のとき前記シグナルパター
ンに基づき新たなノードパターンを形成するパターン分
類手段、 とを含む遺伝子のクラスタリング装置。
9. An apparatus for analyzing changes in the expression states of a plurality of genes and clustering the genes, wherein the means for obtaining a signal pattern representing the changes in the expression states of the genes is provided. Selecting means for calculating the degree of similarity with the node pattern and selecting a node pattern most similar to the obtained signal pattern; the degree of similarity between the selected node pattern and the signal pattern is within a predetermined allowable range At the time of classifying the signal pattern into the selected node pattern,
A pattern classification unit that forms a new node pattern based on the signal pattern when the similarity is outside the allowable range.
【請求項10】 前記分類手段において前記選択された
ノードパターンと前記シグナルパターンとの類似度が前
記所定範囲内のとき、前記選択されたノードパターンを
修正する修正手段が更に含まれる、ことを特徴とする請
求項9に記載の装置。
10. The method according to claim 10, further comprising: modifying means for modifying the selected node pattern when the degree of similarity between the selected node pattern and the signal pattern in the classification means is within the predetermined range. The apparatus according to claim 9, wherein:
【請求項11】 前記修正手段では前記シグナルパター
ンに基づいて前記選択されたノードパターンが修正され
る、ことを特徴とする請求項10に記載の装置。
11. The apparatus according to claim 10, wherein said correction means corrects said selected node pattern based on said signal pattern.
【請求項12】 前記シグナルパターンは蛍光量変化の
パターンである、ことを特徴とする請求項9〜11のい
ずれかに記載の装置。
12. The apparatus according to claim 9, wherein the signal pattern is a pattern of a change in the amount of fluorescence.
【請求項13】 遺伝子の発現シグナルパターンを解析
することにより前記遺伝子をクラスタリングするための
プログラムを記録したコンピュータ読み取り可能な記録
媒体であって、 遺伝子の発現に基づき得られたシグナルパターンと既存
のノードパターンとを比較し、前記シグナルパターンに
最も類似するノードパターンを選択する選択ステップ、 該選択されたノードパターンと前記シグナルパターンと
の類似度が予め定められた許容範囲内のとき前記シグナ
ルパターンを前記選択されたノードパターンに分類し、
前記類似度が前記許容範囲外のとき前記シグナルパター
ンに基づき新たなノードパターンを形成するパターン分
類ステップ、 とを実行させるためのプログラムを記録したコンピュー
タ読み取り可能な記録媒体。
13. A computer-readable recording medium on which a program for clustering genes by analyzing a gene expression signal pattern is recorded, wherein the signal pattern obtained based on the gene expression and an existing node are stored. Selecting a node pattern that is most similar to the signal pattern, comparing the signal pattern when the similarity between the selected node pattern and the signal pattern is within a predetermined allowable range. Classify into the selected node pattern,
A pattern classification step of forming a new node pattern based on the signal pattern when the similarity is outside the allowable range.
【請求項14】 前記分類ステップにおいて前記選択さ
れたノードパターンと前記シグナルパターンとの類似度
が前記所定範囲内のとき、前記選択されたノードパター
ンを修正する修正ステップを更に実行させるためのプロ
グラムを記録したことを特徴とする請求項13に記載の
コンピュータ読み取り可能な記録媒体。
14. A program for further executing a correction step of correcting the selected node pattern when the degree of similarity between the selected node pattern and the signal pattern in the classification step is within the predetermined range. 14. The computer-readable recording medium according to claim 13, wherein the recording medium is recorded.
【請求項15】 前記修正ステップでは前記シグナルパ
ターンに基づいて前記選択されたノードパターンが修正
される、ことを特徴とする請求項14に記載の記録媒
体。
15. The recording medium according to claim 14, wherein in the correcting step, the selected node pattern is corrected based on the signal pattern.
【請求項16】 前記シグナルパターンは蛍光量変化の
パターンである、ことを特徴とする請求項13〜15の
いずれかに記載の記録媒体。
16. The recording medium according to claim 13, wherein the signal pattern is a pattern of a change in the amount of fluorescence.
【請求項17】 遺伝子の発現シグナルパターンを解析
することにより前記遺伝子をクラスタリングするための
プログラムであって、 遺伝子の発現に基づき得られたシグナルパターンと既存
のノードパターンとを比較し、前記シグナルパターンに
最も類似するノードパターンを選択する選択ステップ、 該選択されたノードパターンと前記シグナルパターンと
の類似度が予め定められた許容範囲内のとき前記シグナ
ルパターンを前記選択されたノードパターンに分類し、
前記類似度が前記許容範囲外のとき前記シグナルパター
ンに基づき新たなノードパターンを形成するパターン分
類ステップ、 とをコンピュータに実行させるためのプログラム。
17. A program for clustering genes by analyzing gene expression signal patterns, comprising: comparing a signal pattern obtained based on gene expression with an existing node pattern; A selecting step of selecting a node pattern that is most similar to, classifying the signal pattern into the selected node pattern when the degree of similarity between the selected node pattern and the signal pattern is within a predetermined allowable range,
A pattern classification step of forming a new node pattern based on the signal pattern when the similarity is outside the allowable range.
【請求項18】 前記分類ステップにおいて前記選択さ
れたノードパターンと前記シグナルパターンとの類似度
が前記所定範囲内のとき、前記選択されたノードパター
ンを修正する修正ステップを更にコンピュータに実行さ
せる請求項17に記載のプログラム。
18. The computer according to claim 18, further comprising, when the similarity between the selected node pattern and the signal pattern in the classification step is within the predetermined range, modifying the selected node pattern. 18. The program according to 17.
【請求項19】 前記修正ステップでは前記シグナルパ
ターンに基づいて前記選択されたノードパターンが修正
される、ことを特徴とする請求項18に記載のプログラ
ム。
19. The program according to claim 18, wherein in the correcting step, the selected node pattern is corrected based on the signal pattern.
【請求項20】 前記シグナルパターンは蛍光量変化の
パターンである、ことを特徴とする請求項20〜17の
いずれかに記載のプログラム。
20. The program according to claim 20, wherein the signal pattern is a pattern of a change in the amount of fluorescence.
JP2000373765A 2000-12-08 2000-12-08 Clustering method for genes Pending JP2002175306A (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2000373765A JP2002175306A (en) 2000-12-08 2000-12-08 Clustering method for genes
AU2002221076A AU2002221076A1 (en) 2000-12-08 2001-12-06 Method of clustering genes
PCT/JP2001/010704 WO2002046962A1 (en) 2000-12-08 2001-12-06 Method of clustering genes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000373765A JP2002175306A (en) 2000-12-08 2000-12-08 Clustering method for genes

Publications (1)

Publication Number Publication Date
JP2002175306A true JP2002175306A (en) 2002-06-21

Family

ID=18843076

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000373765A Pending JP2002175306A (en) 2000-12-08 2000-12-08 Clustering method for genes

Country Status (3)

Country Link
JP (1) JP2002175306A (en)
AU (1) AU2002221076A1 (en)
WO (1) WO2002046962A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007312653A (en) * 2006-05-24 2007-12-06 Nec Soft Ltd Analyzing method for character extraction and comparison classification of sequential gene expression data and analyzing apparatus based on the analyzing method

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103390165B (en) * 2012-05-10 2017-08-22 北京百度网讯科技有限公司 A kind of method and device of picture cluster

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007312653A (en) * 2006-05-24 2007-12-06 Nec Soft Ltd Analyzing method for character extraction and comparison classification of sequential gene expression data and analyzing apparatus based on the analyzing method
JP4555256B2 (en) * 2006-05-24 2010-09-29 Necソフト株式会社 Analysis method aiming at feature extraction and comparative classification of time-series gene expression data, and analysis apparatus based on the analysis method

Also Published As

Publication number Publication date
AU2002221076A1 (en) 2002-06-18
WO2002046962A1 (en) 2002-06-13

Similar Documents

Publication Publication Date Title
US7366719B2 (en) Method for the manipulation, storage, modeling, visualization and quantification of datasets
US20110106740A1 (en) Tissue classification method for diagnosis and treatment of tumors
EP2864919A1 (en) Systems and methods for generating biomarker signatures with integrated dual ensemble and generalized simulated annealing techniques
Lehmussola et al. Evaluating the performance of microarray segmentation algorithms
JP2006323846A (en) Method using network for identifying significant molecule by using high-throughput data analysis
CN110362481A (en) Automatic test approach and terminal device
CN1770161A (en) K-means clustering using t-test computation
Shin et al. Graph sharpening
EP2006785A1 (en) Method and system for identifying DNA copy number aberrations by calculating noise-corrected interval scores from array-based, comparative-hybridization data
US7587280B2 (en) Genomic data mining using clustering logic and filtering criteria
EP3598350A1 (en) Optimal solution assessment method, optimal solution assessment program, and optimal solution assessment device
CN108595912A (en) Detect the method, apparatus and system of chromosomal aneuploidy
Gong et al. Single cell lineage reconstruction using distance-based algorithms and the R package, DCLEAR
JP2002175306A (en) Clustering method for genes
US20030233196A1 (en) Method for processing expression data of genes
KR100734430B1 (en) A protocol for searching classifier gene set from microarray dataset
Agarwal et al. MDI+: A Flexible Random Forest-Based Feature Importance Framework
US20050026199A1 (en) Method for identifying biomarkers using Fractal Genomics Modeling
JP2022154862A (en) Information processing method, program and information processing device
Wu et al. Cosbin: cosine score-based iterative normalization of biologically diverse samples
JP6975682B2 (en) Medical information processing equipment, medical information processing methods, and medical information processing programs
CN114724625A (en) Content-based gene interaction network and construction method thereof
JP7347528B2 (en) Information processing program, information processing method, and information processing device
TWI831462B (en) Customer consumption behavior prediction system and customer consumption behavior prediction method
Rahnenführer Clustering algorithms and other exploratory methods for microarray data analysis