- Timestamp:
- 04/17/19 16:03:57 (5 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:mergeinfo changed
/trunk merged: 16729,16737,16740,16743,16757-16758,16762-16764,16768-16769,16779,16782-16784,16788,16792,16794-16799
- Property svn:mergeinfo changed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveCombinedEncodingProblem_Template.cs
r13390 r16801 7 7 using HeuristicLab.Optimization; 8 8 using HeuristicLab.Problems.Programmable; 9 //using HeuristicLab.Encodings.BinaryVectorEncoding; 10 //using HeuristicLab.Encodings.IntegerVectorEncoding; 11 //using HeuristicLab.Encodings.RealVectorEncoding; 12 //using HeuristicLab.Encodings.PermutationEncoding; 13 //using HeuristicLab.Encodings.LinearLinkageEncoding; 9 using HeuristicLab.Encodings.BinaryVectorEncoding; 10 using HeuristicLab.Encodings.IntegerVectorEncoding; 11 using HeuristicLab.Encodings.RealVectorEncoding; 12 using HeuristicLab.Encodings.PermutationEncoding; 13 using HeuristicLab.Encodings.LinearLinkageEncoding; 14 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 14 15 15 16 namespace HeuristicLab.Problems.Programmable { … … 21 22 // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property 22 23 // Add additional initialization code e.g. private variables that you need for evaluating 23 //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });24 Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 }); 24 25 //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) }); 25 //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) });26 Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) }); 26 27 //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute }); 27 28 //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 }); … … 31 32 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 32 33 var quality = new[] { 0.0, 0.0 }; 33 //var b = solution.GetSolution<BinaryVector>("b");34 //quality[0] = b.Count(x => x); // one max!35 //var r = solution.GetSolution<RealVector>("r");36 //quality[1] = r.Select((i, v) => new { Idx = i, Val = v }).Sum(x => b[x.Idx] ? x.Val * x.Val : 0.0); // sphere34 var b = solution.GetEncodedSolution<BinaryVector>("b"); 35 quality[0] = b.Count(x => x); // one max! 36 var r = solution.GetEncodedSolution<RealVector>("r"); 37 quality[1] = r.Select((i, v) => new { Idx = i, Val = v }).Sum(x => b[x.Idx] ? x.Val * x.Val : 0.0); // sphere 37 38 38 39 // NOTE: Check the Maximization property above (true or false)! -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/SingleObjectiveCombinedEncodingProblem_Template.cs
r16723 r16801 1 using System.Collections.Generic; 1 using System; 2 using System.Linq; 3 using System.Collections.Generic; 4 using HeuristicLab.Common; 2 5 using HeuristicLab.Core; 3 6 using HeuristicLab.Data; 4 7 using HeuristicLab.Optimization; 5 //using HeuristicLab.Encodings.BinaryVectorEncoding; 6 //using HeuristicLab.Encodings.IntegerVectorEncoding; 7 //using HeuristicLab.Encodings.RealVectorEncoding; 8 //using HeuristicLab.Encodings.PermutationEncoding; 9 //using HeuristicLab.Encodings.LinearLinkageEncoding; 8 using HeuristicLab.Encodings.BinaryVectorEncoding; 9 using HeuristicLab.Encodings.IntegerVectorEncoding; 10 using HeuristicLab.Encodings.RealVectorEncoding; 11 using HeuristicLab.Encodings.PermutationEncoding; 12 using HeuristicLab.Encodings.LinearLinkageEncoding; 13 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 10 14 11 15 namespace HeuristicLab.Problems.Programmable { … … 17 21 // Define e.g. the length of the solution encoding or the solution creator by modifying the Encoding property 18 22 // Add additional initialization code e.g. private variables that you need for evaluating 19 //Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 });23 Encoding.Add(new BinaryVectorEncoding("b") { Length = 10 }); 20 24 //Encoding.Add(new IntegerVectorEncoding("i") { Length = 10, Bounds = new IntMatrix(new int[,] { { -100, 100 } }) }); 21 //Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) });25 Encoding.Add(new RealVectorEncoding("r") { Length = 10, Bounds = new DoubleMatrix(new double[,] { { -100, 100 } }) }); 22 26 //Encoding.Add(new PermutationEncoding("p") { Length = 20, Type = PermutationTypes.Absolute }); 23 27 //Encoding.Add(new LinearLinkageEncoding("lle") { Length = 30 }); … … 27 31 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 28 32 var quality = 0.0; 29 //var b = solution.GetSolution<BinaryVector>("b");30 //quality = b.Count(x => x); // one max!31 //var r = solution.GetSolution<RealVector>("r");32 //quality += r.Sum(x => -x * x); // sphere33 var b = solution.GetEncodedSolution<BinaryVector>("b"); 34 quality = b.Count(x => x); // one max! 35 var r = solution.GetEncodedSolution<RealVector>("r"); 36 quality += r.Sum(x => -x * x); // sphere 33 37 34 38 // NOTE: Check the Maximization property above (true or false)! … … 45 49 46 50 //if (!results.ContainsKey("Best Solution")) { 47 // results.Add(new Result("Best Solution", typeof( SOLUTION_CLASS)));51 // results.Add(new Result("Best Solution", typeof(CombinedSolution))); 48 52 //} 49 53 //results["Best Solution"].Value = (IItem)best.Clone();
Note: See TracChangeset
for help on using the changeset viewer.