protected override void ValidateResearchParameters()
        {
            if (!ResearchParameterValues.ContainsKey(ResearchParameter.InputPath) ||
                ResearchParameterValues[ResearchParameter.InputPath] == null ||
                ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]).Path == "")
            {
                CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters.");
                throw new InvalidResearchParameters();
            }

            MatrixPath mp = ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]);

            if ((File.GetAttributes(mp.Path) & FileAttributes.Directory) != FileAttributes.Directory)
            {
                CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters." +
                                   " Directory should be specified.");
                throw new InvalidResearchParameters();
            }

            if (Directory.GetFiles(mp.Path, "*.txt").Count() != 1)
            {
                CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters." +
                                   " Directory should contain only 1 .txt file.");
                throw new InvalidResearchParameters();
            }

            base.ValidateResearchParameters();
        }
Example #2
0
        protected override void ValidateResearchParameters()
        {
            if (!ResearchParameterValues.ContainsKey(ResearchParameter.ActivationStepCount) ||
                !ResearchParameterValues.ContainsKey(ResearchParameter.ActivationSpeed) ||
                !ResearchParameterValues.ContainsKey(ResearchParameter.DeactivationSpeed) ||
                !ResearchParameterValues.ContainsKey(ResearchParameter.TracingStepIncrement) ||
                !ResearchParameterValues.ContainsKey(ResearchParameter.InitialActivationProbability))
            {
                CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters.");
                throw new InvalidResearchParameters();
            }

            Int32  Time   = Convert.ToInt32(ResearchParameterValues[ResearchParameter.ActivationStepCount]);
            Double Lambda = Double.Parse(ResearchParameterValues[ResearchParameter.ActivationSpeed].ToString(), CultureInfo.InvariantCulture);
            Double Mu     = Double.Parse(ResearchParameterValues[ResearchParameter.DeactivationSpeed].ToString(), CultureInfo.InvariantCulture);
            Double IP     = Double.Parse(ResearchParameterValues[ResearchParameter.InitialActivationProbability].ToString(), CultureInfo.InvariantCulture);

            if (Time <= 0 || Lambda < 0 || Mu < 0 || IP < 0 || IP > 1)
            {
                CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters.");
                throw new InvalidResearchParameters();
            }

            base.ValidateResearchParameters();
        }
Example #3
0
        /// <summary>
        /// Generates random network from generation parameters.
        /// </summary>
        public bool Generate(bool visualMode = false)
        {
            try
            {
                CustomLogger.Write("Research - " + ResearchName +
                                   ". GENERATION STARTED for network - " + NetworkID.ToString());

                if (GenerationType == GenerationType.Static)
                {
                    Debug.Assert(GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix));
                    MatrixPath fp = (MatrixPath)GenerationParameterValues[GenerationParameter.AdjacencyMatrix];
                    Debug.Assert(fp.Path != null && fp.Path != "");
                    NetworkInfoToRead ni = FileManager.Read(fp.Path, fp.Size);
                    networkGenerator.StaticGeneration(ni);

                    CustomLogger.Write("Research - " + ResearchName +
                                       ". Static GENERATION FINISHED for network - " + NetworkID.ToString());
                }
                else
                {
                    Debug.Assert(!GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix));
                    networkGenerator.RandomGeneration(GenerationParameterValues, visualMode);
                    if (ResearchType == ResearchType.Activation)
                    {
                        Debug.Assert(ResearchParameterValues.ContainsKey(ResearchParameter.InitialActivationProbability));
                        Double IP = Double.Parse(ResearchParameterValues[ResearchParameter.InitialActivationProbability].ToString(),
                                                 CultureInfo.InvariantCulture);
                        (networkGenerator.Container as AbstractNetworkContainer).RandomActivating(IP);
                    }
                    if (visualMode)
                    {
                        Debug.Assert(networkGenerator.GenerationSteps != null);
                        GenerationSteps = networkGenerator.GenerationSteps;
                        Branches        = networkGenerator.Container.GetBranches();
                    }

                    CustomLogger.Write("Research - " + ResearchName +
                                       ". Random GENERATION FINISHED for network - " + NetworkID.ToString());
                }

                UpdateStatus(NetworkStatus.StepCompleted);
            }
            catch (CoreException ex)
            {
                UpdateStatus(NetworkStatus.Failed);

                CustomLogger.Write("Research - " + ResearchName +
                                   "GENERATION FAILED for network - " + NetworkID.ToString() +
                                   ". Exception message: " + ex.Message);
                return(false);
            }

            return(true);
        }
Example #4
0
        protected override void ValidateResearchParameters()
        {
            if (!ResearchParameterValues.ContainsKey(ResearchParameter.ProbabilityDelta) ||
                !ResearchParameterValues.ContainsKey(ResearchParameter.ProbabilityMax))
            {
                Logger.Write("Research - " + ResearchName + ". Invalid research parameters.");
                throw new InvalidResearchParameters();
            }

            Logger.Write("Research - " + ResearchName + ". Validated research parameters.");
        }
Example #5
0
 public override int GetProcessStepsCount()
 {
     Debug.Assert(ResearchParameterValues.ContainsKey(ResearchParameter.EvolutionStepCount));
     Debug.Assert(ResearchParameterValues.ContainsKey(ResearchParameter.TracingStepIncrement));
     if (processStepCount == -1)
     {
         int ev  = (int)Convert.ToUInt32(ResearchParameterValues[ResearchParameter.EvolutionStepCount]);
         int tev = (int)Convert.ToUInt32(ResearchParameterValues[ResearchParameter.TracingStepIncrement]);
         int cc  = tev != 0 ? ev / tev : 0;
         int t   = (TracingPath != "") ? 2 : 1;
         processStepCount = realizationCount * (t + (ev + 1) * GetAnalyzeOptionsCount() + cc) + 1;
     }
     return(processStepCount);
 }
        protected override void ValidateResearchParameters()
        {
            if (!ResearchParameterValues.ContainsKey(ResearchParameter.InputPath) ||
                ResearchParameterValues[ResearchParameter.InputPath] == null ||
                ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]).Path == "")
            {
                Logger.Write("Research - " + ResearchName + ". Invalid research parameters.");
                throw new InvalidResearchParameters();
            }

            MatrixPath mp = ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]);

            if ((File.GetAttributes(mp.Path) & FileAttributes.Directory) != FileAttributes.Directory)
            {
                Logger.Write("Research - " + ResearchName + ". Invalid research parameters." +
                             " Directory should be specified.");
                throw new InvalidResearchParameters();
            }

            Logger.Write("Research - " + ResearchName + ". Validated research parameters.");
        }