public void Initial() { structACOParameters = VariableMaintainer.CurrentStructACOParameters; textBoxQ.Text = structACOParameters.Q.ToString(); textBoxAlpha.Text = structACOParameters.Alpha.ToString(); textBoxBeta.Text = structACOParameters.Beta.ToString(); textBoxRho.Text = structACOParameters.Rho.ToString(); textBoxWeightSuitable.Text = structACOParameters.WeightSuitable.ToString(); textBoxWeightCompact.Text = structACOParameters.WeightCompact.ToString(); textBoxAntCount.Text = structACOParameters.AntCount.ToString(); textBoxIterationCount.Text = structACOParameters.InterationCount.ToString(); }
public void Initial() { structACOParameters = VariableMaintainer.CurrentStructACOParameters; if (string.IsNullOrEmpty(structACOParameters.OutputFolder)) { structACOParameters.OutputFolder = ""; } if (structACOParameters.OutputFolder == "") { structACOParameters.OutputFolder = VariableMaintainer.GetOutputFolder(); } this.textBoxOutputFolder.Text = structACOParameters.OutputFolder; radioButtonOutput.Checked = structACOParameters.IsOutput; if (structACOParameters.MapRefreshInterval == 0) { structACOParameters.MapRefreshInterval = 5; } this.numericUpDownRefreshInvterval.Value = Convert.ToDecimal(structACOParameters.MapRefreshInterval); }
//-------------------------------------------------------------------------------------------------------------- //------------------------------------------------方法---------------------------------------------------------- /// <summary> /// 方法 /// </summary> #region 方法 /// <summary> /// 初始化方法 /// </summary> #region ----------------初始化方法------------------------ public void Initialize(StructACOParameters structACOParameters, int microSearchIterationCountValue, Boolean isNeedSaveValue, DockableWindowOutput currentDockableWindowOutput, DockableWindowGraphy currentDockableWindowGraphy, Boolean isUseCompactnessValue) { q = structACOParameters.Q; //信息素强度 rho = structACOParameters.Rho; //挥发因子 alpha = structACOParameters.Alpha; //信息素权重 beta = structACOParameters.Beta; //启发函数权重 weightSutiable = structACOParameters.WeightSuitable; //阻抗性权重 weightCompact = structACOParameters.WeightCompact; //紧凑性权重 totalItearationCount = structACOParameters.InterationCount; //总迭代次数 currentIteration = 0; //当前迭代次数 currentRefreshIteration = 0; //更新次数 needFinishIterationCount = 0; microSearchIterationCount = microSearchIterationCountValue; //小搜索次数 goalUtilityAntsStatusInMicroSearch = new Ant[structACOParameters.AntCount]; //小搜索内最优状态 currentIterationInMicroSearch = 0; goalUtilityInMicroSearch = 0; isNeedSave = isNeedSaveValue; //判断是否需要保存结果 isNeedUpdate = false; //初始化判断是否需要更新最优状态 isInitialStatusSave = false; //判断是否已经保存初始状态数据 //rows = rrows; //网格行数 //cols = ccols; //网格列数 //xllcorner = xxllcorner; //输出文件左上角横坐标 //yllcorner = yyllcorner; //输出文件左上角纵坐标 //cellsize = ccellsize; //栅格大小 //noDataValue = nnodata_value; //无数据值 outputPath = structACOParameters.OutputFolder; //结果输出路径 outInitName = "_Init.txt"; //结果输出初始状态文件名 outFileName = ""; //结果输出文件名 outPreFileName = "g"; //结果输出文件名前面部分 outGoalName = "GoalFunction.txt"; //结果输出目标函数名 antsCount = structACOParameters.AntCount; //智能体个数 //cellSize = bbianChang; //网格边长 //cellArea = cellSize * cellSize * antsCount; //智能体面积 goalUtilityInAllIterations = 0; randomBound = 1; goalUtilityArray = new string[totalItearationCount + 2]; //保存目标函数值数据 suitabilityData = GetSuitabilityData(VariableMaintainer.OptimizationExpression); InitializeOccupiedAndGoalUtilityAntsStatusInAllIterations(); //初始化挖空 InitializeAnts(); //初始化智能体 InitializePheromone(); //初始化信息素 InitializeHeuristicFunction(); //初始化启发函数 string simulationLayerName = VariableMaintainer.CurrentFoucsMap.get_Layer(0).Name; IRasterLayer simulationImageLayer = ArcGISOperator.GetRasterLayerByName(simulationLayerName); string dateTime = GeneralOpertor.GetDataTimeFullString(DateTime.Now); string rasterName = "ACOArea" + dateTime + ".img"; IRasterDataset rst = ArcGISOperator.CreateRasterDataset(VariableMaintainer.DefaultOutputFolder, rasterName, simulationImageLayer, structRasterMetaData, occupiedStatus, 0); IRasterLayer n = new RasterLayerClass(); n.CreateFromDataset(rst); IColorRamp colorRamp = new RandomColorRampClass(); ArcGISOperator.UniqueValueRenderer(colorRamp, n, "Value"); ArcGISOperator.FoucsMap.AddLayer((ILayer)n); double pixelWidth = ((IRasterDefaultProps)n.Raster).DefaultPixelWidth; double pixelHeight = ((IRasterDefaultProps)n.Raster).DefaultPixelHeight; cellArea = pixelWidth * pixelHeight * antsCount; cellSize = pixelWidth; random = new Random(); dockableWindowOutput = currentDockableWindowOutput; dockableWindowGraphy = currentDockableWindowGraphy; stringBuilderMessage = new StringBuilder(); isUseCompactness = isUseCompactnessValue; dockableWindowGraphy.GraphTitle = "Goal Utility"; dockableWindowGraphy.XAxisTitle = "Iteration"; dockableWindowGraphy.YAxisTitle = "Goal Utility Value"; }