Changeset 9242 for branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3
- Timestamp:
- 02/25/13 12:37:18 (12 years ago)
- Location:
- branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblem.cs
r9228 r9242 33 33 using HeuristicLab.Problems.DataAnalysis; 34 34 35 namespace HeuristicLab.Problems. CombinedIntegerVectorClassification {35 namespace HeuristicLab.Problems.VariableVectorClassification { 36 36 [StorableClass] 37 37 public class VariableVectorClassificationProblem : ConditionActionClassificationProblem<UniformRandomVariableVectorCreator, 38 38 VariableVectorActionComparer, 39 VariableVectorClassificationProblemData> {39 VariableVectorClassificationProblemData>, IVariableVectorClassificationProblem { 40 40 public override string ChildName { 41 41 get { return "VariableVector"; } … … 49 49 get { return (IFixedValueParameter<VariableVectorActionComparer>)Parameters["ClassifierComparer"]; } 50 50 } 51 public IVariableVectorCoveringCreator VariableVectorCoveringCreator { 52 get { return (IVariableVectorCoveringCreator)CoveringSolutionCreator; } 53 } 51 54 #endregion 52 55 … … 57 60 ProblemDataParameter.Value = value; 58 61 if (value != null) { 59 SetProblemDataS pecificParameters();62 SetProblemDataSettings(); 60 63 } 61 64 } … … 91 94 Parameters.Add(new FixedValueParameter<ItemSet<VariableVectorAction>>("PossibleActionsConcreteClass", new ItemSet<VariableVectorAction>(ClassifierComparer))); 92 95 93 coveringSolutionCreator.SampleVariableVectorParameter.ActualName = problemData.SampleVariableVectorParameter.Name;96 SolutionCreator.VariableVectorParameter.ActualName = ChildName; 94 97 95 SetProblemDataS pecificParameters();98 SetProblemDataSettings(); 96 99 97 100 InitializeOperators(); 98 99 problemData.Changed += new System.EventHandler(problemData_Changed);100 101 } 101 102 102 private void problemData_Changed(object sender, System.EventArgs e) { 103 SetProblemDataSpecificParameters(); 104 } 103 protected override void SetProblemDataSettings() { 104 SolutionCreator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 105 105 106 private void SetProblemDataSpecificParameters() { 107 SolutionCreator.SampleVariableVectorParameter.Value = ProblemData.SampleVariableVectorParameter.Value; 108 SolutionCreator.VariableVectorParameter.ActualName = ChildName; 109 SolutionCreator.SpreadPercentageParameter.Value = ProblemData.SpreadPercentageParameter.Value; 106 VariableVectorCoveringCreator.ProblemDataParameter.ActualName = ProblemDataParameter.Name; 110 107 111 108 SetPossibleActions(); … … 130 127 var sampleAction = ProblemData.SampleVariableVector.Action; 131 128 var actionKeys = sampleAction.Order; 132 var actionsEnumeratorList = sampleAction. ToDictionary(x => x.Key, y => y.Value.GetAllPossibleActions().ToList());129 var actionsEnumeratorList = sampleAction.VariableDictionary.ToDictionary(x => x.Key, y => y.Value.GetAllPossibleActions().ToList()); 133 130 int[] curPos = new int[actionsEnumeratorList.Count]; 134 131 //initialize curPos … … 145 142 cur = 0; 146 143 foreach (var key in actionKeys) { 147 curAction [key].SetTo(actionsEnumeratorList[key][curPos[cur]]);144 curAction.VariableDictionary[key].SetTo(actionsEnumeratorList[key][curPos[cur]]); 148 145 cur++; 149 146 } -
branches/LearningClassifierSystems/HeuristicLab.Problems.VariableVectorClassification/3.3/VariableVectorClassificationProblemData.cs
r9228 r9242 33 33 using HeuristicLab.Problems.DataAnalysis; 34 34 35 namespace HeuristicLab.Problems. CombinedIntegerVectorClassification {35 namespace HeuristicLab.Problems.VariableVectorClassification { 36 36 [StorableClass] 37 37 [Item("CombinedIntegerVectorClassificationProblemData", "A problem data for LCS.")] 38 public class VariableVectorClassificationProblemData : ConditionActionClassificationProblemData {38 public class VariableVectorClassificationProblemData : ConditionActionClassificationProblemData, IVariableVectorClassificationProblemData { 39 39 40 40 #region parameter properites … … 90 90 var doubleValues = (variableValues as List<double>).Distinct(); 91 91 if (doubleValues.All(x => x % 1 == 0)) { 92 variable = new IntVariable(variableName, doubleValues.Select(x => Convert.ToInt32(x))); 92 // ToList call is necessary, because otherwise it wouldn't be possible to serialize it 93 variable = new IntVariable(variableName, doubleValues.Select(x => Convert.ToInt32(x)).ToList()); 93 94 } else { 94 95 variable = new DoubleVariable(variableName, doubleValues); … … 105 106 if (!fetchInputCache.ContainsKey(rowNumber)) { 106 107 VariableVectorInput input = new VariableVectorInput(); 107 IEnumerable<string> variableNames = SampleVariableVector.Condition. Keys.Union(SampleVariableVector.Action.Keys);108 IEnumerable<string> variableNames = SampleVariableVector.Condition.VariableDictionary.Keys.Union(SampleVariableVector.Action.VariableDictionary.Keys); 108 109 foreach (var variableName in variableNames) { 109 input. Add(variableName, Dataset.GetValue(rowNumber, variableName));110 input.InputDictionary.Add(variableName, Dataset.GetValue(rowNumber, variableName)); 110 111 } 111 112 fetchInputCache.Add(rowNumber, input); … … 118 119 if (!fetchActionCache.ContainsKey(rowNumber)) { 119 120 var action = SampleVariableVector.Action.GetEmptyCopy(); 120 foreach (var variableName in action. Keys) {121 action [variableName].SetTo(Dataset.GetValue(rowNumber, variableName));121 foreach (var variableName in action.VariableDictionary.Keys) { 122 action.VariableDictionary[variableName].SetTo(Dataset.GetValue(rowNumber, variableName)); 122 123 } 123 124 fetchActionCache.Add(rowNumber, action);
Note: See TracChangeset
for help on using the changeset viewer.