public override void InitDefaultValue() { //initialize primary Variable Weight dictionary Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); List <string> primaryVarialbeStrList = variableRelationSetting.PrimaryVariableList; if (controller.project != null) { foreach (string primaryVariableStr in primaryVarialbeStrList) { Variable primaryVariable = controller.project.Variables[primaryVariableStr]; List <string> primaryItemStrList = primaryVariable.PlatformList; SerializableDictionary <string, double> weightDict = new SerializableDictionary <string, double>(); double[] weightArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(primaryItemStrList.Count); for (int i = 0; i < primaryItemStrList.Count; i++) { weightDict.Add(primaryItemStrList[i], weightArray[i]); } this.PrimaryVariableWeightDict.Add(primaryVariableStr, weightDict); } } //initialize secondaryItemWeightSetMethod this.SecondaryItemWeightSetMethod.Value = this.SecondaryItemWeightSetMethodDict[typeof(EqualSecondaryItemWeightSetMethod).FullName]; }
// init set equal weight public virtual void InitDefaultValue() { Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); this.DependenceRecordDict = variableRelationSetting.DependenceRecordDict; foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv in this.DependenceRecordDict) { VariableDependenceRecord record = kv.Value; SerializableDictionary <string, SerializableDictionary <string, SecondaryItem> > itemDependecDict = record.ItemDependencDict; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in itemDependecDict) { SerializableDictionary <string, SecondaryItem> secondaryItemDict = kv2.Value; int number = secondaryItemDict.Count; double[] itemArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(number); foreach (KeyValuePair <string, SecondaryItem> kv3 in secondaryItemDict) { kv3.Value.Weight = itemArray[0]; } string lastItemStr = new List <string>(secondaryItemDict.Keys)[secondaryItemDict.Count - 1]; secondaryItemDict[lastItemStr].Weight = itemArray[number - 1]; } } }
public virtual void updateDataFromVariableRelation(AnalysisStrategy strategy) { Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); strategy.project.VariableRelationSetting = variableRelationSetting; List <string> primaryVarialbeStrList = variableRelationSetting.PrimaryVariableList; // update the primary variable //compare the read data with the older one // add new primary variable foreach (string primaryVariableStr in primaryVarialbeStrList) { if (!this.PrimaryVariableWeightDict.ContainsKey(primaryVariableStr)) { Variable primaryVariable = controller.project.Variables[primaryVariableStr]; List <string> primaryItemStrList = primaryVariable.PlatformList; SerializableDictionary <string, double> weightDict = new SerializableDictionary <string, double>(); double[] weightArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(primaryItemStrList.Count); for (int i = 0; i < primaryItemStrList.Count; i++) { weightDict.Add(primaryItemStrList[i], weightArray[i]); } this.PrimaryVariableWeightDict.Add(primaryVariableStr, weightDict); } } // delete the redundant primary variable List <string> keyList = new List <string>(this.PrimaryVariableWeightDict.Keys); for (int i = 0; i < keyList.Count; i++) { if (!primaryVarialbeStrList.Contains(keyList[i])) { this.PrimaryVariableWeightDict.Remove(keyList[i]); } } // update the secondary dependence data foreach (KeyValuePair <string, ISecondaryItemWeightSetMethod> kv in this.SecondaryItemWeightSetMethodDict) { kv.Value.updateSecondaryItemData(); } }
public virtual void updateSecondaryItemData() { Controller controller = Controller.getInstance(); VariableRelation variableRelationSetting = Controller.getInstance().XMLDeserializeVariableRelation(); SerializableDictionary <VariableDependenceRecordKey, VariableDependenceRecord> newDependenceRecordDict = variableRelationSetting.DependenceRecordDict; // compare with the latest data from xml add the lack records and remove the redundant records. // add lack records foreach (KeyValuePair <VariableDependenceRecordKey, VariableDependenceRecord> kv in newDependenceRecordDict) { if (!this.DependenceRecordDict.ContainsKey(kv.Key)) { VariableDependenceRecord record = kv.Value; SerializableDictionary <string, SerializableDictionary <string, SecondaryItem> > itemDependecDict = record.ItemDependencDict; foreach (KeyValuePair <string, SerializableDictionary <string, SecondaryItem> > kv2 in itemDependecDict) { SerializableDictionary <string, SecondaryItem> secondaryItemDict = kv2.Value; int number = secondaryItemDict.Count; double[] itemArray = ManualAssignmentPlatformWeightSetMethod.getAverageWeight(number); foreach (KeyValuePair <string, SecondaryItem> kv3 in secondaryItemDict) { kv3.Value.Weight = itemArray[0]; } string lastItemStr = new List <string>(secondaryItemDict.Keys)[secondaryItemDict.Count - 1]; secondaryItemDict[lastItemStr].Weight = itemArray[number - 1]; } // add the new record this.DependenceRecordDict.Add(kv.Key, kv.Value); } } // remove the redundant records List <VariableDependenceRecordKey> keyList = new List <VariableDependenceRecordKey>(this.DependenceRecordDict.Keys); for (int i = 0; i < keyList.Count; i++) { if (!newDependenceRecordDict.ContainsKey(keyList[i])) { this.DependenceRecordDict.Remove(keyList[i]); } } }
public AnalysisStrategy() { //Platform Weight filed this.PlatformWeightSetMethod = new SerializableGenericObject <IPlatformWeightSetMethod>(); // the candidate platform weight set method this.manualWeightSetMethod = new ManualAssignmentPlatformWeightSetMethod(); this.autoWeightSetMethod = new AutoAssignmentPlatformWeightSetMethod(); // the add order is the same as the radio group present index order this.PlatformWeightSetMethodDict = new SerializableDictionary <string, IPlatformWeightSetMethod>(); this.PlatformWeightSetMethodDict.Add(typeof(ManualAssignmentPlatformWeightSetMethod).FullName, this.manualWeightSetMethod); this.PlatformWeightSetMethodDict.Add(typeof(AutoAssignmentPlatformWeightSetMethod).FullName, this.autoWeightSetMethod); //Platform Assign Method filed this.PlatformAssignMethod = new SerializableGenericObject <IPlatformAssignMethod>(); // two candidate platform assign method this.randomAssignMethod = new RandomPlatformAssignMethod(); this.balancedAssignMethod = new BalancedPlatformAssignMethod(); // the add order is the same as the radio group present index order this.PlatformAssignMethodDict = new SerializableDictionary <string, IPlatformAssignMethod>(); this.PlatformAssignMethodDict.Add(typeof(RandomPlatformAssignMethod).FullName, this.randomAssignMethod); this.PlatformAssignMethodDict.Add(typeof(BalancedPlatformAssignMethod).FullName, this.balancedAssignMethod); InitDefaultValue(); }