Exemplo n.º 1
0
        public void TestActivationSpreading()
        {
            // make a collection
            atomCollection collection = new atomCollection();

            // add some nodes to the collection
            const int no_of_nodes = 4;
            for (int i = 0; i < no_of_nodes; i++)
            {
                node n = new node();
                collection.Add(n);
            }

            // link the nodes together
            for (int i = 0; i < no_of_nodes; i++)
            {
                node n1 = (node)collection.Get(i);
                for (int j = 0; j < no_of_nodes; j++)
                {
                    if (i != j)
                    {
                        node n2 = (node)collection.Get(j);
                        n1.AddIncomingLink("hebbian", n2, new truthvalue(0.5f));
                    }
                }
            }

            // set an initial activation on channel 0
            node activated1 = (node)collection.Get(0);
            activated1.SetActivation(1.0f, 0);

            // set an initial activation on channel 1
            node activated2 = (node)collection.Get(no_of_nodes-1);
            activated2.SetActivation(1.0f, 1);

            // create an activation spreading agent
            agentActivationSpreading spread = new agentActivationSpreading(collection);

            // run the agent until it completes
            spread.Run();
            while (spread.running) spread.Run();

            Assert.IsTrue(activated1.GetActivation(0) < 1.0f, "activation level 0 has changed");
            Assert.IsTrue(activated2.GetActivation(1) < 1.0f, "activation level 1 has changed");

            node activated3 = (node)collection.Get(1);
            Assert.IsTrue(activated3.GetActivation(0) > 0, "activation level 0 has spread");
            Assert.IsTrue(activated3.GetActivation(1) > 0, "activation level 1 has spread");
        }
Exemplo n.º 2
0
 /// <summary>
 /// returns the given collection as a set of link objects
 /// </summary>
 public ArrayList GetLinks(atomCollection collection)
 {
     ArrayList links = new ArrayList();
     if (collection != null)
     {
         for (int i = 0; i < collection.Count(); i++)
         {
             atom a = collection.Get(i);
             if (a.GetFlag(atom.FLAG_IS_LINK))
             {
                 links.Add((link)a);
             }
         }
     }
     return(links);
 }
Exemplo n.º 3
0
        /// <summary>
        /// parse an xml node
        /// </summary>
        /// <param name="xnod"></param>
        /// <param name="level"></param>
        public override void LoadFromXml(XmlNode xnod, int level, atomCollection all_atoms)
        {
            if (xnod.Name == "ID")
                atom_ID = Convert.ToInt64(xnod.InnerText);

            if (xnod.Name == "Members")
            {
                String[] IDs = xnod.InnerText.Split(',');
                for (int i = 0; i < IDs.Length; i++)
                {
                    long ID = Convert.ToInt64(IDs[i]);
                    if (all_atoms != null)
                    {
                        atom atm = all_atoms.GetID(ID);
                        Add(atm);
                    }
                }
            }

            // call recursively on all children of the current node
            if (xnod.HasChildNodes)
            {
                XmlNode xnodWorking = xnod.FirstChild;
                while (xnodWorking != null)
                {
                    LoadFromXml(xnodWorking, level + 1);
                    xnodWorking = xnodWorking.NextSibling;
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// creates some common ranges
        /// </summary>
        public static atomCollection CreateRanges()
        {
            atomCollection ranges = new atomCollection();
            ranges.SetName("Ranges");

            /// phrases associated with a range of positive emotions
            atomCollection emotions_positive = new atomCollection();
            emotions_positive.SetName("RangeEmotionsPositive");
            String[] emotion_positive_str = {
                "better",
                "tidy",
                "neat",
                "welcome",
                "amusing",
                "initiative",
                "like",
                "invest",
                "investment",
                "growth",
                "lucky",
                "correct",
                "hired",
                "replenish",
                "respect",
                "respects",
                "respected",
                "encouraging",
                "enjoy",
                "pleasurable",
                "pleasure",
                "easy",
                "glad",
                "enjoys",
                "amused",
                "amusing",
                "entertained",
                "entertaining",
                "enjoyed",
                "treasure",
                "treasured",
                "pleasant",
                "joy",
                "happy",
                "good",
                "good at",
                "happiness",
                "popular",
                "esteem",
                "worthy",
                "worthwhile",
                "loving",
                "positive",
                "protect",
                "encouraged",
                "encourage",
                "working",
                "fascinate",
                "fascinated",
                "fascinating",
                "poetic",
                "interested",
                "interesting",
                "genuis",
                "freedom",
                "enjoyable",
                "exciting",
                "pleasing",
                "pleased",
                "increase",
                "increased",
                "joyous",
                "confident",
                "confidence",
                "peace",
                "peacefull",
                "calm",
                "bright",
                "rosy",
                "kindness",
                "goodness",
                "divine",
                "divinely",
                "fantastic",
                "fabulous",
                "funny",
                "devoted",
                "refreshing",
                "refreshed",
                "enthusiast",
                "enthusiastic",
                "enthusiastically",
                "elation",
                "enthused",
                "enthusiasm",
                "love",
                "adore",
                "loved"
            };
            emotions_positive.CreateRange(emotion_positive_str);
            ranges.Add(emotions_positive);

            /// phrases associated with a range of negative emotions
            atomCollection emotions_negative = new atomCollection();
            emotions_negative.SetName("RangeEmotionsNegative");
            String[] emotion_negative_str = {
                "misslead",
                "surrender",
                "hoax",
                "never",
                "dumb",
                "unnecessary",
                "unsophisticated",
                "messy",
                "worse",
                "worse than",
                "stumble",
                "stumbling",
                "frantic",
                "untidy",
                "difficult",
                "hard",
                "trouble",
                "troublesome",
                "stole",
                "steal",
                "stolen",
                "disslike",
                "frustrate",
                "frustration",
                "exclusion",
                "fired",
                "sacked",
                "redundant",
                "criticised",
                "jealous",
                "fear",
                "feared",
                "fearfull",
                "nowhere",
                "unpopular",
                "angry",
                "deluded",
                "delusion",
                "deserted",
                "worthless",
                "criticising",
                "bicker",
                "argue",
                "decline",
                "reduce",
                "cut",
                "unlucky",
                "empty",
                "scary",
                "wrong",
                "go wrong",
                "gone wrong",
                "going wrong",
                "not working",
                "scared",
                "scare",
                "sad",
                "crooked",
                "scam",
                "criticism",
                "criticise",
                "imposed",
                "violent",
                "violence",
                "slave",
                "fighting",
                "paranoia",
                "paranoid",
                "propaganda",
                "fraud",
                "horror",
                "horrible",
                "disturbing",
                "robbed",
                "hate",
                "hated",
                "hates",
                "harm",
                "unhappy",
                "kill",
                "kills",
                "killed",
                "killing",
                "death",
                "grave",
                "victim",
                "killing",
                "offensive",
                "evil",
                "hysterical",
                "hysteria",
                "shot",
                "genocide",
                "liar",
                "lies",
                "lied",
                "frightening",
                "frightened",
                "spam",
                "damn",
                "darn",
                "bad",
                "too bad",
                "scream",
                "screamed",
                "screaming",
                "arrested",
                "virus",
                "bomb",
                "boring",
                "f**k",
                "f****d",
                "shoot",
                "incorrect",
                "shot",
                "shooter",
                "shooting",
                "f****r",
                "f*****g",
                "shit",
                "bitch",
                "dont like",
                "bitchy",
                "bitching",
                "gun",
                "guns",
                "weapon",
                "weapons",
                "war",
                "rifle",
                "lonely",
                "loser",
                "invade",
                "invasion",
                "disease",
                "sick",
                "ill",
                "illness",
                "sickness",
                "damaging",
                "damaged",
                "damage",
                "unloved",
                "devastating",
                "devastated",
                "devastate"
            };
            emotions_negative.CreateRange(emotion_negative_str);
            ranges.Add(emotions_negative);

            /// phrases associated with a range of proximities
            atomCollection proximities = new atomCollection();
            proximities.SetName("RangeProximity");
            String[] proximity_str = {
                "very close", "very near", "short", "nearby", "close", "near",
                "parted", "distant", "far apart", "long way", "far away",
                "far apart", "far from", "far out", "distal"
            };
            proximities.CreateRange(proximity_str);
            ranges.Add(proximities);

            /// phrases associated with a range of amusement
            atomCollection amusement = new atomCollection();
            amusement.SetName("RangeAmusement");
            String[] amusement_str = {
                "very boring", "boring", "boredom", "bores", "tedious", "tedium", "irksome",
                "tiring", "tiresome", "uninteresting", "unexciting", "unexcited", "unimaginitive",
                "amusing", "amused", "amuses", "amuse", "entertain", "entertains",
                "entertaining", "entertained",
                "enjoy", "enjoying", "enjoyed", "enjoyable",
                "enjoys", "excitement", "excite", "excites", "exciting", "excited",
                "fun", "funny", "humor", "humour", "humourous", "humorous", "thrill",
                "thrilling", "thriller", "thrilled"
            };
            amusement.CreateRange(amusement_str);
            ranges.Add(amusement);

            /// phrases associated with a range of cognitive ability
            atomCollection cognitive = new atomCollection();
            cognitive.SetName("RangeCognitive");
            String[] cognitive_str = {
                "mad", "madness", "insane", "insanity", "idiot", "crazy", "loony",
                "lunatic", "craziness", "crazed", "idiotic", "retarded",
                "unintelligent", "not very smart", "not as smart", "not as clever",
                "average intelligence", "clever", "smart", "very smart", "very clever",
                "super smart", "gifted", "genius", "prodigy", "enlightened",
                "ingenius", "superintelligence"
            };
            cognitive.CreateRange(cognitive_str);
            ranges.Add(cognitive);

            /// phrases associated with a range of realness
            atomCollection realness = new atomCollection();
            realness.SetName("RangeRealness");
            String[] realness_str = {
                "dissbelief", "dream", "beggars belief", "ridiculous", "absurd", "absurdity",
                "absurdness", "dreaming", "dreamy", "dreamer",
                "hallucination", "hallucinatory", "hallucinations", "hallucinating",
                "fantasies", "fantastical", "fantasy", "imagined",
                "imaginary", "imagination", "imaginitive", "imagining",
                "unbelievable", "don't believe", "doesn't believe",
                "dont believe", "doesnt believe", "unrealistic",
                "fiction", "fictional", "unreal", "make believe", "pretend",
                "credible", "believable", "reality", "realist", "real",
                "real life", "realistic", "realism"
            };
            realness.CreateRange(realness_str);
            ranges.Add(realness);

            /// phrases associated with a range of strengths
            atomCollection strengths = new atomCollection();
            strengths.SetName("RangeStrength");
            String[] strength_str = {
                "frail", "frailness", "frailty", "frailer", "feeble", "feebleness",
                "fragile", "fragility", "fragileness",
                "weak", "weaker", "weakness", "weaknesses",
                "soft", "softness", "softened", "softer",
                "flimsy", "flimsiness", "robust", "robustness", "robustly",
                "strong", "strength", "strengthen", "strengthened", "stronger", "very strong",
                "tough", "toughness", "hard", "hardness", "harden", "hardened"
            };
            strengths.CreateRange(strength_str);
            ranges.Add(strengths);

            /// phrases associated with a range of heights
            atomCollection heights = new atomCollection();
            heights.SetName("RangeHeight");
            String[] height_str = {
                "low", "diminutive", "tiny", "petite",
                "dwarf", "dwarfed", "midget", "very short", "short", "shortened", "shortens", "shorter", "shortness",
                "below average height", "average height", "above average height",
                "tall", "taller", "tallness", "high", "higher", "very tall", "lofty", "loftier", "oversized", "oversize",
                "sky high", "titanic", "king sized", "king size", "giant", "gargantuan", "gigantic"
            };
            strengths.CreateRange(strength_str);
            ranges.Add(strengths);

            /// phrases associated with a range of widths
            atomCollection widths = new atomCollection();
            widths.SetName("RangeWidth");
            String[] width_str = {
                "extremely narrow", "very narrow", "incredibly narrow", "narrow", "narrowness", "narrower",
                "slim", "slimmer", "slimness", "slimming",
                "wide", "fat", "fatter", "broader", "broaden", "broadens",
                "wider", "widen", "widened", "width"
            };
            widths.CreateRange(width_str);
            ranges.Add(widths);

            /// phrases associated with a range of weights
            atomCollection weights = new atomCollection();
            weights.SetName("RangeWeight");
            String[] weight_str = {
                "weightless", "light weight", "featherweight",
                "light", "heavy", "heavily", "very heavy", "weighty", "massive", "massively",
                "supermassive", "colossal"
            };
            weights.CreateRange(weight_str);
            ranges.Add(weights);

            /// phrases associated with a range of heat
            atomCollection heats = new atomCollection();
            heats.SetName("RangeHeat");
            String[] heat_str = {
                "extremely cold", "very cold", "ice cold", "freezing", "freeze", "freezer",
                "cold", "colder", "cooler", "cools", "cooling", "cool",
                "tepid", "lukewarm", "warm", "warmer", "warmed", "warms", "warming",
                "hot", "hotter", "boils", "boil", "boiling", "boiled",
                "scorched", "scorching", "scorch", "roast", "roasting", "roasted"
            };
            heats.CreateRange(heat_str);
            ranges.Add(heats);

            /// phrases associated with a range of aggressiveness
            atomCollection aggressions = new atomCollection();
            aggressions.SetName("RangeAggression");
            String[] aggression_str = {
                "chordial", "hospitable", "hospitableness", "hospitality",
                "peaceful", "peace", "non violent", "non voilence", "non violently",
                "aggressive", "aggressively", "aggressiveness",
                "violent", "violently", "violence",
                "hostile", "hostility", "hostilities",
                "war", "warlike", "waring", "warlords", "combat", "fight",
            };
            aggressions.CreateRange(aggression_str);
            ranges.Add(aggressions);

            /// phrases associated with a range of liquidity
            atomCollection liquidities = new atomCollection();
            liquidities.SetName("RangeLiquidity");
            String[] liquidity_str = {
                "desert", "dry", "dryness", "arid", "parched", "dust", "dusty",
                "damp", "dampened", "moist", "moistened", "watery", "flood", "flooded",
                "rain", "rainy", "raining", "rained",
                "sea", "river", "seas", "rivers"
            };
            liquidities.CreateRange(liquidity_str);
            ranges.Add(liquidities);

            /// phrases associated with a range of visibility
            atomCollection visibility = new atomCollection();
            visibility.SetName("RangeVisibility");
            String[] visibility_str = {
                "invisible", "poor visibility", "hidden", "hide", "unclear", "shadowy",
                "murky", "dingy", "opaque", "visible",
                "clearly visible", "clearly seen", "clear to see", "clarity", "clear"
            };
            visibility.CreateRange(visibility_str);
            ranges.Add(visibility);

            /// phrases associated with a range of temporal events
            atomCollection temporal = new atomCollection();
            temporal.SetName("RangeTemporal");
            String[] temporal_str = {
                "not much time", "little time", "hardly any time",
                "million years ago", "prehistoric", "long ago", "long time ago", "ancient",
                "centuries ago", "century ago", "last century", "last centurys", "last century's", "previous century",
                "decade ago", "decades ago", "last decade", "last decades", "last decade's", "previous decade",
                "years ago", "past",
                "last year", "last years", "last year's", "past year", "past years", "past year's", "previous year", "previous years", "previous year's",
                "last month", "last month's", "last months", "past month", "past month's", "past months", "previous month", "previous month's", "previous months",
                "last week", "last weeks", "last week's", "past week", "past weeks", "past week's",
                "previously", "previous", "before",
                "this month's", "this month", "this months", "current month", "current months", "current_month's",
                "this week", "this weeks", "this week's", "current week", "current weeks", "current week's",
                "last few days", "last days", "previous day", "recent", "recently", "earlier",
                "yesterday", "today", "currently", "now",
                "tomorrow", "tomorrows", "tomorrow's", "future plans", "a while",
                "next day", "next days", "next day's", "following day", "following days", "following day's",
                "next week", "next weeks", "next week's", "following weeks", "following week",
                "next month", "next month's", "next months", "following months", "following month",
                "next year", "next years", "years", "next year's", "following years", "following year", "many years",
                "next decade", "next decades", "next decade's", "future",
                "years ahead", "years to come", "years from now", "into the future", "in the future", "in future",
                "centuries ahead", "next century", "next centurys", "next century's", "next century",
                "centuries to come", "centuries in the future", "centuries into the future", "far future", "distant future",
                "long time"
            };
            temporal.CreateRange(temporal_str);
            ranges.Add(temporal);

            /// phrases associated with a range of frequencies
            atomCollection frequencies = new atomCollection();
            frequencies.SetName("RangeFrequency");
            String[] frequency_str = {
                "far from certain", "not ever", "never", "unheard of", "exceptionally rare", "rarity", "hardly ever", "rare", "rarely", "scarce", "infrequent", "infrequently",
                "few occasions", "occasional", "occasionally", "periodically", "periodic", "time to time", "unreliable", "unreliably",
                "usually", "usual", "typical", "more often than not", "multiple times", "many times", "frequent", "frequently", "often", "very often", "always", "every time",
                "near certain", "near certainty", "certain", "certainty", "dead cert"
            };
            frequencies.CreateRange(frequency_str);
            ranges.Add(frequencies);

            /// phrases associated with a range of speeds
            atomCollection speeds = new atomCollection();
            speeds.SetName("RangeSpeed");
            String[] speed_str = {
                "incredibly slow", "very slow", "slowest", "much longer", "much slower", "significantly slower",
                "hugely slower", "sluggish", "more slowly", "more gradually", "gradually", "slowly", "slower rate", "lower speed", "slow",
                "longer", "slower rate", "lower rate", "smaller rate", "lesser rate", "slower than", "more slowly",
                "equal speed", "equal time", "same time", "same speed", "same time", "same amount of time", "same duration", "same velocity", "same rate",
                "more quickly", "quicker than", "faster than", "more quickly", "more rapidly",
                "fast", "timely", "faster", "rapidly", "faster rate", "quicker rate", "higher speed", "very rapidly", "very quickly", "speedily", "speed record",
                "quicker", "shorter time", "less time", "rapidly", "rapid", "record time", "record speed", "fastest", "quickest time", "fastest time"
            };
            speeds.CreateRange(speed_str);
            ranges.Add(speeds);

            /// phrases associated with a range of magnitudes
            atomCollection magnitudes = new atomCollection();
            magnitudes.SetName("RangeMagnitude");
            String[] magnitude_str = {
                "vastly less", "vastly under", "vastly below", "vastly fewer", "massively less", "significantly below",
                "hugely less", "substantially less", "substantially smaller", "significantly less", "significantly under",
                "massively under", "hugely under", "well below", "far fewer", "much fewer", "very few",
                "far smaller", "much smaller", "far less", "not much", "not many", "not very much", "not very many",
                "much less", "much lesser", "lesser", "fewer", "smaller", "below", "less sizable", "less extensive", "less extensively", "small",
                "slightly smaller", "slightly less", "just under", "just below", "slightly below",
                "marginally less", "marginally under", "marginally smaller", "just smaller",
                "a little smaller", "bit smaller", "a little less", "bit less", "marginally less",
                "just less than",
                "same size", "equivalent to", "equal to", "equalling", "equivalent", "equals", "same as",
                "slightly larger", "a little larger", "bit more", "little more", "bit larger", "bit bigger",
                "a little bigger", "marginally bigger", "marginally more", "marginally greater", "little over",
                "slightly larger", "slightly bigger", "just bigger", "just larger", "little larger", "little bigger",
                "more substantial", "greater than", "more than", "bigger than", "very many", "quite a few",
                "just over", "more sizable", "more substantial", "more substantive", "huger", "more extensive", "more extensively",
                "considerably bigger", "considerably larger", "substantially bigger", "far bigger", "far larger", "substantially larger", "much larger", "much bigger",
                "far greater", "a lot of", "great deal", "far more", "far bigger", "multitude", "multitudes",
                "significantly bigger", "significantly larger", "significantly more", "significantly above", "massively bigger", "massively larger",
                "vastly bigger", "vastly larger", "vastly greater", "vastly over", "vastly more", "enormous", "huge", "gigantic",
                "hugely bigger", "hugely larger", "hugely greater", "hugely over", "hugely more", "colossal", "colossally"
            };
            magnitudes.CreateRange(magnitude_str);
            ranges.Add(magnitudes);

            return(ranges);
        }
Exemplo n.º 5
0
 /// <summary>
 /// removes an atom from the incoming or outgoing set
 /// </summary>
 private void RemoveFromSet(atom a, atomCollection atomset)
 {
     if (atomset != null)
     {
         atomset.Remove(a);
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// adds an atom to the incoming or outgoing set
 /// </summary>
 private void AddToSet(atom a, ref atomCollection atomset)
 {
     if (atomset == null) atomset = new atomCollection();
     atomset.Add(a);
 }
Exemplo n.º 7
0
        /// <summary>
        /// perform a single search step
        /// searching all atoms may take several steps for large collections
        /// </summary>
        protected override void StepAgent()
        {
            // on the first update initialise the search exemplars
            // by examining incoming links
            if (updates_elapsed == 0)
            {
                running = true;

                // clear the working set
                working_set = new ArrayList();
                working_set_difference = new ArrayList();

                // clear the outgoing results
                ClearOutgoing();

                search_types = new atomCollection();

                // get the search request from the incoming links to this node
                // note that by using an atomcollection we automatically index
                // the atoms referenced by incoming links into separate types
                for (int i = 0; i < atoms_incoming.Count(); i++)
                {
                    // get the incoming link
                    link search_request_link = (link)(atoms_incoming.Get(i));

                    // get the atom referenced by the incoming link
                    atom search_request = search_request_link.atoms_incoming.Get(0);

                    // add this atom to the collection of search exemplars
                    search_types.Add(search_request);
                }

                updates_elapsed++;
                search_atom_index = 0;
                search_type_index = 0;
            }

            // search atoms using the given search exemplars
            while ((search_type_index < search_types.GetNumberOfAtomTypes()) &&
                   (updates_elapsed < updates_per_time_step))
            {
                // get search exemplars for this atom type
                ArrayList search_request = search_types.GetAtomsOfType(search_type_index);
                if (search_request != null)
                {
                    // if some exemplars exist
                    if (search_request.Count > 0)
                    {
                        // pick the first exemplar
                        atom exemplar = (atom)search_request[0];

                        // get atoms of the same type as the exemplar
                        ArrayList atoms_of_search_type = atoms.GetAtomsOfType(search_type_index);

                        // compare these atoms to the exemplar
                        while ((search_atom_index < atoms_of_search_type.Count) &&
                               (updates_elapsed < updates_per_time_step))
                        {
                             atom candidate = (atom)atoms_of_search_type[search_atom_index];

                             // calculate similarity
                             float diff = GetDifference(exemplar, candidate);

                             if (diff != INVALID) AddToWorkingSet(candidate, diff);

                             updates_elapsed++;
                             search_atom_index++;
                        }

                        if (search_atom_index == atoms_of_search_type.Count)
                            search_atom_index = 0;
                    }
                }

                if (search_atom_index == 0)
                {
                    search_type_index++;
                    if (search_type_index == search_types.GetNumberOfAtomTypes())
                    {
                        // sort the results
                        SortWorkingSet();

                        // reset the number of updates
                        updates_elapsed = 0;
                        running = false;
                    }
                }
            }
        }
 public agentActivationSpreading(atomCollection members)
 {
     initAgentActivationSpreading(members, null);
 }
Exemplo n.º 9
0
        public void TestSearch()
        {
            // make a collection
            atomCollection search_collection = new atomCollection();

            // add some nodes to the collection
            const int no_of_nodes = 10;
            for (int i = 0; i < no_of_nodes; i++)
            {
                node n = new node();
                n.SetImportance(1.0f - (i / (float)no_of_nodes), atom.SHORT_TERM_IMPORTANCE);
                search_collection.Add(n);
            }

            // create a search agent
            agentSearch seeker = new agentSearch(search_collection, "importance",
                                                 atom.SHORT_TERM_IMPORTANCE);

            // create an exemplar to match against
            node exemplar = new node();
            exemplar.SetImportance(0.7f, atom.SHORT_TERM_IMPORTANCE);

            // link the exemplar to the the search agent
            bool link_added = seeker.AddIncomingLink("hebbian", exemplar, new truthvalue());
            Assert.IsTrue(link_added, "Link created");

            // run the agent until it completes
            seeker.Run();
            while (seeker.running) seeker.Run();
            atomCollection search_results = seeker.GetSearchResults();

            // check that some results were produced
            Assert.IsNotNull(search_results, "search results were returned");
            if (search_results != null)
            {
                // check that the number of nodes is what we expect
                Assert.AreEqual(search_results.Count(), no_of_nodes, "expected number of nodes in the search pool");

                //check that the results are sorted
                int i = 1;
                bool in_order = true;

                while ((i < search_results.Count()) && (in_order))
                {
                    if (seeker.GetDifference(i) < seeker.GetDifference(i - 1)) in_order = false;
                    i++;
                }
                Assert.IsTrue(in_order, "search results are sorted in ascending order of difference from the exemplar");
            }
        }
Exemplo n.º 10
0
        public void TestAssociativeLearning()
        {
            // make a collection
            atomCollection collection = new atomCollection();

            // add some nodes to the collection
            const int no_of_nodes = 5;
            for (int i = 0; i < no_of_nodes; i++)
            {
                node n = new node();
                collection.Add(n);
            }

            // link the nodes together
            for (int i = 0; i < no_of_nodes; i++)
            {
                node n1 = (node)collection.Get(i);
                for (int j = 0; j < no_of_nodes; j++)
                {
                    if (i != j)
                    {
                        node n2 = (node)collection.Get(j);
                        n1.AddIncomingLink("hebbian", n2, new truthvalue());
                    }
                }
            }

            // create a learning agent
            agentAssociativeLearning learner = new agentAssociativeLearning(collection);

            // run the agent until it completes
            learner.Run();
            while (learner.running) learner.Run();
        }
Exemplo n.º 11
0
        public agentSearch(atomCollection search_pool, 
		                   String searchParameter,
		                   int searchParameterIndex)
        {
            initAgentSearch(search_pool);
            search_parameter = searchParameter;
            search_parameter_index = searchParameterIndex;
        }
Exemplo n.º 12
0
        public agentSearch(atomCollection search_pool, 
		                   String searchParameter)
        {
            initAgentSearch(search_pool);
            search_parameter = searchParameter;
        }
Exemplo n.º 13
0
 public agentSearch(atomCollection search_pool)
 {
     initAgentSearch(search_pool);
 }
Exemplo n.º 14
0
 private void initAgentSearch(atomCollection search_pool)
 {
     atoms = search_pool;
     SetAtomType("agentSearch");
 }
Exemplo n.º 15
0
        /// <summary>
        /// returns the nodes associated with the given collection of links
        /// </summary>
        private ArrayList GetNeighbours(atomCollection links_collection)
        {
            ArrayList neighbours = new ArrayList();

            if (links_collection != null)
            {
                for (int i = 0; i < links_collection.Count(); i++)
                {
                    // each link
                    atom lnk = links_collection.Get(i);
                    if (lnk.atoms_incoming != null)
                    {
                        // each node referred to by the link
                        for (int j = 0; j < lnk.atoms_incoming.Count(); j++)
                        {
                            neighbours.Add(lnk.atoms_incoming.Get(j));
                        }
                    }
                }
            }

            return(neighbours);
        }
        /// <summary>
        /// initialise activetion spreading agent
        /// </summary>
        private void initAgentActivationSpreading(atomCollection members,
                                                  ArrayList activeChannels)
        {
            atoms = members;

            // create default decay rates
            conductance = new float[atom.ACTIVATION_CHANNELS];

            if (activeChannels == null)
            {
                // conduct through all channels
                for (int i = 0; i < atom.ACTIVATION_CHANNELS; i++)
                    conductance[i] = DEFAULT_CONDUCTANCE;
            }
            else
            {
                // conduct only through a limited number of channels
                for (int i = 0; i < activeChannels.Count; i++)
                {
                    int channel = (int)activeChannels[i];
                    conductance[channel] = DEFAULT_CONDUCTANCE;
                }
            }
        }
Exemplo n.º 17
0
 /// <summary>
 /// parse an xml node
 /// </summary>
 /// <param name="xnod"></param>
 /// <param name="level"></param>
 /// <param name="all_atoms"></param>
 public virtual void LoadFromXml(XmlNode xnod, int level, atomCollection all_atoms)
 {
     LoadFromXml(xnod, level);
 }
        public agentActivationSpreading(atomCollection members,
		                                ArrayList activeChannels)
        {
            initAgentActivationSpreading(members, activeChannels);
        }
 public agentAssociativeLearning(atomCollection members)
 {
     atoms = members;
     initAgentAssociativeLearning();
 }