- Timestamp:
- 11/23/15 21:07:22 (9 years ago)
- Location:
- branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3
- Files:
-
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs
r13345 r13348 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Threading; 25 using HeuristicLab.Core; 23 26 using HeuristicLab.Optimization; 24 27 … … 45 48 } 46 49 } 50 51 public abstract class CompiledSingleObjectiveProblemDefinition<TEncoding, TSolution> : CompiledProblemDefinition<TEncoding, TSolution>, ISingleObjectiveProblemDefinition<TEncoding, TSolution> 52 where TEncoding : class, IEncoding<TSolution> 53 where TSolution : class, ISolution { 54 55 protected CompiledSingleObjectiveProblemDefinition() : base() { } 56 57 protected CompiledSingleObjectiveProblemDefinition(TEncoding encoding) 58 : base(encoding) { } 59 60 #region ISingleObjectiveProblemDefinition<TEncoding,TSolution> Members 61 public abstract bool Maximization { get; } 62 public abstract double Evaluate(TSolution individual, IRandom random); 63 public abstract void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random); 64 public abstract IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random); 65 #endregion 66 } 67 68 public abstract class CompiledMultiObjectiveProblemDefinition<TEncoding, TSolution> : CompiledProblemDefinition<TEncoding, TSolution>, IMultiObjectiveProblemDefinition<TEncoding, TSolution> 69 where TEncoding : class, IEncoding<TSolution> 70 where TSolution : class, ISolution { 71 72 protected CompiledMultiObjectiveProblemDefinition() : base() { } 73 74 protected CompiledMultiObjectiveProblemDefinition(TEncoding encoding) 75 : base(encoding) { } 76 77 #region ISingleObjectiveProblemDefinition<TEncoding,TSolution> Members 78 public abstract bool[] Maximization { get; } 79 public abstract double[] Evaluate(TSolution individual, IRandom random); 80 public abstract void Analyze(TSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random); 81 public abstract IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random); 82 #endregion 83 } 47 84 } -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj
r13345 r13348 95 95 <Compile Include="ProblemDefinitionScriptException.cs" /> 96 96 <Compile Include="SingleObjectiveProgrammableProblems.cs" /> 97 <Content Include="Templates\CompiledSingleObjectiveProblemDefinition .cs" />97 <Content Include="Templates\CompiledSingleObjectiveProblemDefinition_Template.cs" /> 98 98 <Compile Include="Templates\ScriptTemplates.Designer.cs"> 99 99 <AutoGen>True</AutoGen> … … 104 104 <Compile Include="SingleObjectiveProblemDefinitionScript.cs" /> 105 105 <EmbeddedResource Include="Templates\ScriptTemplates.resx"> 106 <Generator> ResXFileCodeGenerator</Generator>106 <Generator>PublicResXFileCodeGenerator</Generator> 107 107 <LastGenOutput>ScriptTemplates.Designer.cs</LastGenOutput> 108 <SubType>Designer</SubType> 108 109 </EmbeddedResource> 109 110 <None Include="HeuristicLab.snk" /> -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProblemDefinitionScript.cs
r13345 r13348 82 82 protected ProblemDefinitionScript(ProblemDefinitionScript<TEncoding, TSolution> original, Cloner cloner) 83 83 : base(original, cloner) { 84 encoding = cloner.Clone(original.encoding); 84 85 codeChanged = original.codeChanged; 85 86 } -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblem.cs
r13345 r13348 37 37 where TEncoding : class, IEncoding<TSolution> 38 38 where TSolution : class, ISolution { 39 protected static readonly string ENCODING_NAMESPACE = "ENCODING_NAMESPACE"; 40 protected static readonly string ENCODING_CLASS = "ENCODING_CLASS"; 41 protected static readonly string SOLUTION_CLASS = "SOLUTION_CLASS"; 42 39 43 public static new Image StaticItemImage { 40 44 get { return VSImageLibrary.Script; } … … 61 65 [StorableConstructor] 62 66 protected SingleObjectiveProgrammableProblem(bool deserializing) : base(deserializing) { } 63 public SingleObjectiveProgrammableProblem( string codeTemplate)67 public SingleObjectiveProgrammableProblem() 64 68 : base() { 65 Parameters.Add(new FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>>("ProblemScript", "Defines the problem.", new SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>( codeTemplate) { Name = Name, Encoding = Encoding }));69 Parameters.Add(new FixedValueParameter<SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>>("ProblemScript", "Defines the problem.", new SingleObjectiveProblemDefinitionScript<TEncoding, TSolution>() { Name = Name, Encoding = Encoding })); 66 70 Operators.Add(new BestScopeSolutionAnalyzer()); 67 71 RegisterEvents(); -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProgrammableProblems.cs
r13345 r13348 36 36 private SingleObjectiveBinaryVectorProgrammableProblem(bool deserializing) : base(deserializing) { } 37 37 private SingleObjectiveBinaryVectorProgrammableProblem(SingleObjectiveBinaryVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { } 38 38 39 public SingleObjectiveBinaryVectorProgrammableProblem() 39 : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.BinaryVectorEncoding", "BinaryVectorEncoding", "BinaryVector")) { } 40 : base() { 41 var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template; 42 codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding"); 43 codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding"); 44 codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "BinaryVector"); 45 ProblemScript.Code = codeTemplate; 46 } 47 40 48 41 49 public override IDeepCloneable Clone(Cloner cloner) { -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/CompiledSingleObjectiveProblemDefinition_Template.cs
r13347 r13348 5 5 using HeuristicLab.Core; 6 6 using HeuristicLab.Data; 7 using {0}7 using ENCODING_NAMESPACE; 8 8 using HeuristicLab.Optimization; 9 9 using HeuristicLab.Problems.Programmable; 10 10 11 11 namespace HeuristicLab.Problems.Programmable { 12 public class CompiledSingleObjectiveProblemDefinition : Compiled ProblemDefinition<{1}, {2}>, ISingleObjectiveProblemDefinition<{1}, {2}> {13 public bool Maximization { get { return false; } }12 public class CompiledSingleObjectiveProblemDefinition : CompiledSingleObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> { 13 public override bool Maximization { get { return false; } } 14 14 15 15 public override void Initialize() { … … 19 19 } 20 20 21 public double Evaluate({2} individual, IRandom random) {21 public override double Evaluate(SOLUTION_CLASS solution, IRandom random) { 22 22 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 23 23 var quality = 0.0; … … 25 25 } 26 26 27 public void Analyze({2}[] individuals, double[] qualities, ResultCollection results, IRandom random) {27 public override void Analyze(SOLUTION_CLASS[] solution, double[] qualities, ResultCollection results, IRandom random) { 28 28 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 29 29 // Write or update results given the range of vectors and resulting qualities … … 34 34 35 35 //if (!results.ContainsKey("Best Solution")) { 36 // results.Add(new Result("Best Solution", typeof( {20)));36 // results.Add(new Result("Best Solution", typeof(SOLUTION_CLASS))); 37 37 //} 38 38 //results["Best Solution"].Value = (IItem)best.Clone(); 39 39 } 40 40 41 public IEnumerable<{2}> GetNeighbors({2}individual, IRandom random) {41 public override IEnumerable<SOLUTION_CLASS> GetNeighbors(SOLUTION_CLASS individual, IRandom random) { 42 42 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 43 43 // Create new vectors, based on the given one that represent small changes … … 46 46 // Algorithm will draw only a finite amount of samples 47 47 // Change to a for-loop to return a concrete amount of neighbors 48 var neighbor = ( {2})individual.Clone();48 var neighbor = (SOLUTION_CLASS)individual.Clone(); 49 49 // modify the solution specified as neighbor 50 50 yield return neighbor; -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/ScriptTemplates.Designer.cs
r11949 r13348 2 2 // <auto-generated> 3 3 // This code was generated by a tool. 4 // Runtime Version:4.0.30319. 184444 // Runtime Version:4.0.30319.34209 5 5 // 6 6 // Changes to this file may cause incorrect behavior and will be lost if … … 10 10 11 11 namespace HeuristicLab.Problems.Programmable { 12 using System; 13 14 12 using System; 13 14 15 /// <summary> 16 /// A strongly-typed resource class, for looking up localized strings, etc. 17 /// </summary> 18 // This class was auto-generated by the StronglyTypedResourceBuilder 19 // class via a tool like ResGen or Visual Studio. 20 // To add or remove a member, edit your .ResX file then rerun ResGen 21 // with the /str option, or rebuild your VS project. 22 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 public class ScriptTemplates { 26 27 private static global::System.Resources.ResourceManager resourceMan; 28 29 private static global::System.Globalization.CultureInfo resourceCulture; 30 31 [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 internal ScriptTemplates() { 33 } 34 15 35 /// <summary> 16 /// A strongly-typed resource class, for looking up localized strings, etc.36 /// Returns the cached ResourceManager instance used by this class. 17 37 /// </summary> 18 // This class was auto-generated by the StronglyTypedResourceBuilder 19 // class via a tool like ResGen or Visual Studio. 20 // To add or remove a member, edit your .ResX file then rerun ResGen 21 // with the /str option, or rebuild your VS project. 22 [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 internal class ScriptTemplates { 26 27 private static global::System.Resources.ResourceManager resourceMan; 28 29 private static global::System.Globalization.CultureInfo resourceCulture; 30 31 [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 internal ScriptTemplates() { 38 [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 public static global::System.Resources.ResourceManager ResourceManager { 40 get { 41 if (object.ReferenceEquals(resourceMan, null)) { 42 global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HeuristicLab.Problems.Programmable.Templates.ScriptTemplates", typeof(ScriptTemplates).Assembly); 43 resourceMan = temp; 33 44 } 34 35 /// <summary> 36 /// Returns the cached ResourceManager instance used by this class. 37 /// </summary> 38 [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 internal static global::System.Resources.ResourceManager ResourceManager { 40 get { 41 if (object.ReferenceEquals(resourceMan, null)) { 42 global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HeuristicLab.Problems.Programmable.Templates.ScriptTemplates", typeof(ScriptTemplates).Assembly); 43 resourceMan = temp; 44 } 45 return resourceMan; 46 } 47 } 48 49 /// <summary> 50 /// Overrides the current thread's CurrentUICulture property for all 51 /// resource lookups using this strongly typed resource class. 52 /// </summary> 53 [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 internal static global::System.Globalization.CultureInfo Culture { 55 get { 56 return resourceCulture; 57 } 58 set { 59 resourceCulture = value; 60 } 61 } 62 63 /// <summary> 64 /// Looks up a localized string similar to using System; 65 ///using System.Linq; 66 ///using System.Collections.Generic; 67 ///using HeuristicLab.Common; 68 ///using HeuristicLab.Core; 69 ///using HeuristicLab.Data; 70 ///using HeuristicLab.Encodings.PermutationEncoding; 71 ///using HeuristicLab.Optimization; 72 ///using HeuristicLab.Problems.Programmable; 73 /// 74 ///namespace HeuristicLab.Problems.Programmable { 75 /// public class CompiledMultiObjectiveProblemDefinition : CompiledProblemDefinition, IMultiObjectiveProblemDefinition { 76 /// public bool[] Maximization { get { return new[] { false, fal [rest of string was truncated]";. 77 /// </summary> 78 internal static string CompiledMultiObjectiveProblemDefinition { 79 get { 80 return ResourceManager.GetString("CompiledMultiObjectiveProblemDefinition", resourceCulture); 81 } 82 } 83 84 /// <summary> 85 /// Looks up a localized string similar to using System; 86 ///using System.Linq; 87 ///using System.Collections.Generic; 88 ///using HeuristicLab.Common; 89 ///using HeuristicLab.Core; 90 ///using HeuristicLab.Data; 91 ///using HeuristicLab.Encodings.PermutationEncoding; 92 ///using HeuristicLab.Optimization; 93 ///using HeuristicLab.Problems.Programmable; 94 /// 95 ///namespace HeuristicLab.Problems.Programmable { 96 /// public class CompiledSingleObjectiveProblemDefinition : CompiledProblemDefinition, ISingleObjectiveProblemDefinition { 97 /// public bool Maximization { get { return false; } } 98 /// 99 /// [rest of string was truncated]";. 100 /// </summary> 101 internal static string CompiledSingleObjectiveProblemDefinition { 102 get { 103 return ResourceManager.GetString("CompiledSingleObjectiveProblemDefinition", resourceCulture); 104 } 105 } 45 return resourceMan; 46 } 106 47 } 48 49 /// <summary> 50 /// Overrides the current thread's CurrentUICulture property for all 51 /// resource lookups using this strongly typed resource class. 52 /// </summary> 53 [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 public static global::System.Globalization.CultureInfo Culture { 55 get { 56 return resourceCulture; 57 } 58 set { 59 resourceCulture = value; 60 } 61 } 62 63 /// <summary> 64 /// Looks up a localized string similar to using System; 65 ///using System.Linq; 66 ///using System.Collections.Generic; 67 ///using HeuristicLab.Common; 68 ///using HeuristicLab.Core; 69 ///using HeuristicLab.Data; 70 ///using HeuristicLab.Encodings.BinaryVectorEncoding; 71 ///using HeuristicLab.Encodings.IntegerVectorEncoding; 72 ///using HeuristicLab.Encodings.RealVectorEncoding; 73 ///using HeuristicLab.Encodings.PermutationEncoding; 74 ///using HeuristicLab.Encodings.LinearLinkageEncoding; 75 ///using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 76 ///using HeuristicLab.Optimization; 77 ///using H [rest of string was truncated]";. 78 /// </summary> 79 public static string CompiledMultiObjectiveProblemDefinition_Template { 80 get { 81 return ResourceManager.GetString("CompiledMultiObjectiveProblemDefinition_Template", resourceCulture); 82 } 83 } 84 85 /// <summary> 86 /// Looks up a localized string similar to using System; 87 ///using System.Linq; 88 ///using System.Collections.Generic; 89 ///using HeuristicLab.Common; 90 ///using HeuristicLab.Core; 91 ///using HeuristicLab.Data; 92 ///using ENCODING_NAMESPACE; 93 ///using HeuristicLab.Optimization; 94 ///using HeuristicLab.Problems.Programmable; 95 /// 96 ///namespace HeuristicLab.Problems.Programmable { 97 /// public class CompiledSingleObjectiveProblemDefinition : CompiledSingleObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> { 98 /// public override bool Maximization { get { return false; } } 99 /// 100 /// pub [rest of string was truncated]";. 101 /// </summary> 102 public static string CompiledSingleObjectiveProblemDefinition_Template { 103 get { 104 return ResourceManager.GetString("CompiledSingleObjectiveProblemDefinition_Template", resourceCulture); 105 } 106 } 107 } 107 108 } -
branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/ScriptTemplates.resx
r11753 r13348 119 119 </resheader> 120 120 <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 121 <data name="CompiledMultiObjectiveProblemDefinition " type="System.Resources.ResXFileRef, System.Windows.Forms">122 <value>CompiledMultiObjectiveProblemDefinition .cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>121 <data name="CompiledMultiObjectiveProblemDefinition_Template" type="System.Resources.ResXFileRef, System.Windows.Forms"> 122 <value>CompiledMultiObjectiveProblemDefinition_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> 123 123 </data> 124 <data name="CompiledSingleObjectiveProblemDefinition " type="System.Resources.ResXFileRef, System.Windows.Forms">125 <value>CompiledSingleObjectiveProblemDefinition .cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>124 <data name="CompiledSingleObjectiveProblemDefinition_Template" type="System.Resources.ResXFileRef, System.Windows.Forms"> 125 <value>CompiledSingleObjectiveProblemDefinition_Template.cs;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value> 126 126 </data> 127 127 </root>
Note: See TracChangeset
for help on using the changeset viewer.