Changeset 13469 for branches/ProblemRefactoring
- Timestamp:
- 12/15/15 15:16:24 (9 years ago)
- Location:
- branches/ProblemRefactoring
- Files:
-
- 37 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleCreator.cs
r13437 r13469 25 25 26 26 namespace HeuristicLab.Encodings.ScheduleEncoding { 27 public interface IScheduleCreator : ISolutionCreator<ISchedule>, IScheduleOperator { 28 ILookupParameter<ISchedule> ScheduleParameter { get; } 27 public interface IScheduleCreator<TSchedule> : ISolutionCreator<TSchedule>, IScheduleOperator 28 where TSchedule : class,ISchedule { 29 ILookupParameter<TSchedule> ScheduleParameter { get; } 29 30 IValueLookupParameter<IntValue> JobsParameter { get; } 30 31 IValueLookupParameter<IntValue> ResourcesParameter { get; } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Interfaces/IScheduleDecoder.cs
r13443 r13469 30 30 Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData); 31 31 } 32 33 public interface IScheduleDecoder<TSchedule> : IScheduleDecoder 34 where TSchedule : class, ISchedule { 35 Schedule DecodeSchedule(TSchedule solution, ItemList<Job> jobData); 36 } 32 37 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/Decoder/JSMDecoder.cs
r13449 r13469 34 34 [Item("JobSequenceMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequence Matrix.")] 35 35 [StorableClass] 36 public class JSMDecoder : ScheduleDecoder {36 public class JSMDecoder : ScheduleDecoder<JSMEncoding> { 37 37 38 38 public IFixedValueParameter<EnumValue<JSMDecodingErrorPolicy>> DecodingErrorPolicyParameter { … … 130 130 } 131 131 132 public override Schedule DecodeSchedule(ISchedule encoding, ItemList<Job> jobData) { 133 var solution = encoding as JSMEncoding; 134 if (solution == null) throw new InvalidOperationException("Encoding is not of type JSMEncoding"); 135 return DecodeSchedule(solution, jobData, DecodingErrorPolicy, ForcingStrategy); 132 public override Schedule DecodeSchedule(JSMEncoding encoding, ItemList<Job> jobData) { 133 return Decode(encoding, jobData, DecodingErrorPolicy, ForcingStrategy); 136 134 } 137 135 138 public static Schedule Decode Schedule(JSMEncoding solution, ItemList<Job> jobData, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy) {136 public static Schedule Decode(JSMEncoding solution, ItemList<Job> jobData, JSMDecodingErrorPolicy decodingErrorPolicy, JSMForcingStrategy forcingStrategy) { 139 137 var random = new FastRandom(solution.RandomSeed); 140 138 var jobs = (ItemList<Job>)jobData.Clone(); -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/JobSequenceMatrix/JSMRandomCreator.cs
r13443 r13469 30 30 [Item("JobSequenceMatrixCreator", "Creator class used to create Job Sequence Matrix solutions for standard JobShop scheduling problems.")] 31 31 [StorableClass] 32 public class JSMRandomCreator : ScheduleCreator , IStochasticOperator {32 public class JSMRandomCreator : ScheduleCreator<JSMEncoding>, IStochasticOperator { 33 33 34 34 public ILookupParameter<IRandom> RandomParameter { … … 56 56 } 57 57 58 protected override IScheduleCreateSolution() {58 protected override JSMEncoding CreateSolution() { 59 59 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue); 60 60 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/Decoder/PWRDecoder.cs
r13443 r13469 28 28 [Item("PWRDecoder", "An item used to convert a PWR-individual into a generalized schedule.")] 29 29 [StorableClass] 30 public class PWRDecoder : ScheduleDecoder {30 public class PWRDecoder : ScheduleDecoder<PWREncoding> { 31 31 [StorableConstructor] 32 32 protected PWRDecoder(bool deserializing) : base(deserializing) { } … … 38 38 } 39 39 40 public override Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData) { 41 var pwr = solution as PWREncoding; 42 if (pwr == null) throw new InvalidOperationException("Encoding is not of type PWREncoding"); 43 return DecodeSchedule(pwr, jobData); 40 public override Schedule DecodeSchedule(PWREncoding solution, ItemList<Job> jobData) { 41 return Decode(solution, jobData); 44 42 } 45 43 46 public static Schedule Decode Schedule(PWREncoding solution, ItemList<Job> jobData) {44 public static Schedule Decode(PWREncoding solution, ItemList<Job> jobData) { 47 45 var jobs = (ItemList<Job>)jobData.Clone(); 48 46 var resultingSchedule = new Schedule(jobs[0].Tasks.Count); -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PermutationWithRepetition/PWRRandomCreator.cs
r13437 r13469 29 29 [Item("PermutationWithRepetitionRandomCreator", "Creates PWR-individuals at random.")] 30 30 [StorableClass] 31 public class PWRRandomCreator : ScheduleCreator , IStochasticOperator {31 public class PWRRandomCreator : ScheduleCreator<PWREncoding>, IStochasticOperator { 32 32 33 33 public ILookupParameter<IRandom> RandomParameter { … … 51 51 } 52 52 53 protected override IScheduleCreateSolution() {53 protected override PWREncoding CreateSolution() { 54 54 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue); 55 55 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/Plugin.cs.frame
r13321 r13469 35 35 [PluginDependency("HeuristicLab.Parameters", "3.3")] 36 36 [PluginDependency("HeuristicLab.Persistence", "3.3")] 37 [PluginDependency("HeuristicLab.Random", "3.3")] 37 38 public class HeuristicLabEncodingsScheduleEncodingPlugin : PluginBase { 38 39 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/Decoder/PRVDecoder.cs
r13443 r13469 20 20 #endregion 21 21 22 using System;23 22 using System.Linq; 24 23 using HeuristicLab.Common; 25 24 using HeuristicLab.Core; 26 using HeuristicLab.Encodings.ScheduleEncoding;27 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 26 using HeuristicLab.Random; … … 31 29 [Item("JobSequencingMatrixDecoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")] 32 30 [StorableClass] 33 public class PRVDecoder : ScheduleDecoder {31 public class PRVDecoder : ScheduleDecoder<PRVEncoding> { 34 32 #region Priority Rules 35 33 //smallest number of remaining tasks … … 189 187 } 190 188 191 public override Schedule DecodeSchedule(ISchedule encoding, ItemList<Job> jobData) { 192 var solution = encoding as PRVEncoding; 193 if (solution == null) throw new InvalidOperationException("Encoding is not of type PRVEncoding"); 194 return DecodeSchedule(solution, jobData); 195 } 196 197 public static Schedule DecodeSchedule(PRVEncoding solution, ItemList<Job> jobData) { 189 public override Schedule DecodeSchedule(PRVEncoding encoding, ItemList<Job> jobData) { 190 return Decode(encoding, jobData); 191 } 192 193 public static Schedule Decode(PRVEncoding solution, ItemList<Job> jobData) { 198 194 var random = new FastRandom(solution.RandomSeed); 199 195 var jobs = (ItemList<Job>)jobData.Clone(); -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/PriorityRulesVector/PRVRandomCreator.cs
r13443 r13469 29 29 [Item("PriorityRulesRandomCreator", "Creator class used to create PRV encoding objects for scheduling problems.")] 30 30 [StorableClass] 31 public class PRVRandomCreator : ScheduleCreator , IStochasticOperator {31 public class PRVRandomCreator : ScheduleCreator<PRVEncoding>, IStochasticOperator { 32 32 33 33 [Storable] … … 58 58 } 59 59 60 protected override IScheduleCreateSolution() {60 protected override PRVEncoding CreateSolution() { 61 61 return Apply(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, RandomParameter.ActualValue, NrOfRules); 62 62 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleCreator.cs
r13437 r13469 30 30 [Item("ScheduleCreator", "Represents the generalized form of creators for Scheduling Problems.")] 31 31 [StorableClass] 32 public abstract class ScheduleCreator : InstrumentedOperator, IScheduleCreator { 32 public abstract class ScheduleCreator<TSchedule> : InstrumentedOperator, IScheduleCreator<TSchedule> 33 where TSchedule : class,ISchedule { 33 34 34 public ILookupParameter< ISchedule> ScheduleParameter {35 get { return (ILookupParameter< ISchedule>)Parameters["Schedule"]; }35 public ILookupParameter<TSchedule> ScheduleParameter { 36 get { return (ILookupParameter<TSchedule>)Parameters["Schedule"]; } 36 37 } 37 38 public IValueLookupParameter<IntValue> JobsParameter { … … 44 45 [StorableConstructor] 45 46 protected ScheduleCreator(bool deserializing) : base(deserializing) { } 46 protected ScheduleCreator(ScheduleCreator original, Cloner cloner) : base(original, cloner) { }47 protected ScheduleCreator(ScheduleCreator<TSchedule> original, Cloner cloner) : base(original, cloner) { } 47 48 public ScheduleCreator() 48 49 : base() { 49 Parameters.Add(new LookupParameter< ISchedule>("Schedule", "The new scheduling solution candidate."));50 Parameters.Add(new LookupParameter<TSchedule>("Schedule", "The new scheduling solution candidate.")); 50 51 Parameters.Add(new ValueLookupParameter<IntValue>("Jobs", "The number of jobs handled in this problem instance.")); 51 52 Parameters.Add(new ValueLookupParameter<IntValue>("Resources", "The number of resources used in this problem instance.")); … … 57 58 } 58 59 59 protected abstract ISchedule CreateSolution();60 protected abstract TSchedule CreateSolution(); 60 61 } 61 62 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleDecoder.cs
r13443 r13469 20 20 #endregion 21 21 22 using System; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 29 30 [Item("ScheduleDecoder", "A schedule decoder translates a respresentation into an actual schedule.")] 30 31 [StorableClass] 31 public abstract class ScheduleDecoder : SingleSuccessorOperator, IScheduleDecoder { 32 public abstract class ScheduleDecoder<TSchedule> : SingleSuccessorOperator, IScheduleDecoder<TSchedule> 33 where TSchedule : class, ISchedule { 32 34 33 35 public ILookupParameter<ISchedule> ScheduleEncodingParameter { … … 43 45 [StorableConstructor] 44 46 protected ScheduleDecoder(bool deserializing) : base(deserializing) { } 45 protected ScheduleDecoder(ScheduleDecoder original, Cloner cloner) : base(original, cloner) { }47 protected ScheduleDecoder(ScheduleDecoder<TSchedule> original, Cloner cloner) : base(original, cloner) { } 46 48 public ScheduleDecoder() 47 49 : base() { … … 51 53 } 52 54 53 public abstract Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData); 55 public Schedule DecodeSchedule(ISchedule schedule, ItemList<Job> jobData) { 56 TSchedule solution = schedule as TSchedule; 57 if (solution == null) throw new InvalidOperationException("Encoding is not of type " + typeof(TSchedule).GetPrettyName()); 58 return DecodeSchedule(solution, jobData); 59 } 60 public abstract Schedule DecodeSchedule(TSchedule schedule, ItemList<Job> jobData); 54 61 55 62 public override IOperation Apply() { -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding.cs
r13443 r13469 34 34 namespace HeuristicLab.Encodings.ScheduleEncoding { 35 35 [StorableClass] 36 public abstract class ScheduleEncoding<TSchedule> : Encoding< ISchedule>, IScheduleEncoding36 public abstract class ScheduleEncoding<TSchedule> : Encoding<TSchedule>, IScheduleEncoding 37 37 where TSchedule : class, ISchedule { 38 38 #region Encoding Parameters … … 85 85 86 86 [Storable] 87 private IValueParameter<IScheduleDecoder> decoderParameter; 88 89 public IValueParameter<IScheduleDecoder> DecoderParameter { 87 private IValueParameter<IScheduleDecoder<TSchedule>> decoderParameter; 88 public IValueParameter<IScheduleDecoder<TSchedule>> DecoderParameter { 90 89 get { return decoderParameter; } 91 90 set { … … 114 113 } 115 114 116 public IScheduleDecoder Decoder {115 public IScheduleDecoder<TSchedule> Decoder { 117 116 get { return DecoderParameter.Value; } 118 117 set { DecoderParameter.Value = value; } … … 123 122 protected ScheduleEncoding(ScheduleEncoding<TSchedule> original, Cloner cloner) 124 123 : base(original, cloner) { 124 jobDataParameter = cloner.Clone(original.JobDataParameter); 125 jobsParameter = cloner.Clone(original.JobsParameter); 126 resourcesParameter = cloner.Clone(original.ResourcesParameter); 127 decoderParameter = cloner.Clone(original.DecoderParameter); 125 128 } 126 129 … … 135 138 jobsParameter = new FixedValueParameter<IntValue>(Name + ".Jobs", new IntValue(jobs)); 136 139 resourcesParameter = new FixedValueParameter<IntValue>(Name + ".Resources", new IntValue(resources)); 137 decoderParameter = new ValueParameter<IScheduleDecoder >(Name + ".Decoder");140 decoderParameter = new ValueParameter<IScheduleDecoder<TSchedule>>(Name + ".Decoder"); 138 141 139 142 Parameters.Add(jobDataParameter); … … 163 166 164 167 public override void ConfigureOperators(IEnumerable<IItem> operators) { 165 ConfigureCreators(operators.OfType<IScheduleCreator >());168 ConfigureCreators(operators.OfType<IScheduleCreator<TSchedule>>()); 166 169 ConfigureCrossovers(operators.OfType<IScheduleCrossover>()); 167 170 ConfigureManipulators(operators.OfType<IScheduleManipulator>()); 168 171 } 169 172 170 private void ConfigureCreators(IEnumerable<IScheduleCreator > creators) {173 private void ConfigureCreators(IEnumerable<IScheduleCreator<TSchedule>> creators) { 171 174 foreach (var creator in creators) { 172 175 creator.ScheduleParameter.ActualName = Name; -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/Decoder/DirectScheduleDecoder.cs
r13443 r13469 20 20 #endregion 21 21 22 using System;23 22 using HeuristicLab.Common; 24 23 using HeuristicLab.Core; … … 28 27 [Item("DirectScheduleDecoder", "An item used to convert a direct schedule into a generalized schedule.")] 29 28 [StorableClass] 30 public class DirectScheduleDecoder : ScheduleDecoder {29 public class DirectScheduleDecoder : ScheduleDecoder<Schedule> { 31 30 [StorableConstructor] 32 31 protected DirectScheduleDecoder(bool deserializing) : base(deserializing) { } … … 38 37 } 39 38 40 public override Schedule DecodeSchedule(ISchedule solution, ItemList<Job> jobData) { 41 var schedule = solution as Schedule; 42 if (schedule == null) throw new InvalidOperationException("Encoding is not of type PWREncoding"); 43 return DecodeSchedule(schedule, jobData); 39 public override Schedule DecodeSchedule(Schedule solution, ItemList<Job> jobData) { 40 return Decode(solution, jobData); 44 41 } 45 42 46 public static Schedule Decode Schedule(Schedule solution, ItemList<Job> jobData) {43 public static Schedule Decode(Schedule solution, ItemList<Job> jobData) { 47 44 return solution; 48 45 } -
branches/ProblemRefactoring/HeuristicLab.Encodings.ScheduleEncoding/3.3/ScheduleEncoding/DirectScheduleRandomCreator.cs
r13443 r13469 30 30 [Item("DirectScheduleRandomCreator", "Creator class used to create schedule encoding objects.")] 31 31 [StorableClass] 32 public class DirectScheduleRandomCreator : ScheduleCreator , IStochasticOperator, IDirectScheduleOperator {32 public class DirectScheduleRandomCreator : ScheduleCreator<Schedule>, IStochasticOperator, IDirectScheduleOperator { 33 33 34 34 public ILookupParameter<IRandom> RandomParameter { … … 68 68 69 69 70 71 protected override ISchedule CreateSolution() { 70 protected override Schedule CreateSolution() { 72 71 var jobData = (ItemList<Job>)JobDataParameter.ActualValue.Clone(); 73 72 var pwrEncoding = new PWREncoding(JobsParameter.ActualValue.Value, ResourcesParameter.ActualValue.Value, -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Encoding.cs
r13396 r13469 53 53 foreach (var op in value) encodingOperators.Add(op); 54 54 55 ISolutionCreator<TSolution> newSolutionCreator = (ISolutionCreator<TSolution>)encodingOperators.FirstOrDefault(o => o.GetType() == solutionCreator.GetType()) ??55 ISolutionCreator<TSolution> newSolutionCreator = (ISolutionCreator<TSolution>)encodingOperators.FirstOrDefault(o => o.GetType() == SolutionCreator.GetType()) ?? 56 56 encodingOperators.OfType<ISolutionCreator<TSolution>>().First(); 57 57 SolutionCreator = newSolutionCreator; … … 60 60 } 61 61 62 ISolutionCreator IEncoding.SolutionCreator {63 get { return solutionCreator; }62 public IValueParameter SolutionCreatorParameter { 63 get { return (IValueParameter)Parameters[Name + ".SolutionCreator"]; } 64 64 } 65 65 66 [Storable] 67 private ISolutionCreator<TSolution> solutionCreator; 66 ISolutionCreator IEncoding.SolutionCreator { 67 get { return SolutionCreator; } 68 } 68 69 public ISolutionCreator<TSolution> SolutionCreator { 69 get { 70 return solutionCreator; 71 } 70 get { return (ISolutionCreator<TSolution>)SolutionCreatorParameter.Value; } 72 71 set { 73 72 if (value == null) throw new ArgumentNullException("SolutionCreator must not be null."); 74 if (solutionCreator == value) return; 75 encodingOperators.Remove(solutionCreator); 73 encodingOperators.Remove(SolutionCreator); 76 74 encodingOperators.Add(value); 77 solutionCreator= value;75 SolutionCreatorParameter.Value = value; 78 76 OnSolutionCreatorChanged(); 79 77 } 80 78 } 81 79 80 82 81 [StorableConstructor] 83 82 protected Encoding(bool deserializing) : base(deserializing) { } 83 [StorableHook(HookType.AfterDeserialization)] 84 private void AfterDeserialization() { 85 RegisterEventHandlers(); 86 } 87 84 88 protected Encoding(Encoding<TSolution> original, Cloner cloner) 85 89 : base(original, cloner) { 86 90 encodingOperators = cloner.Clone(original.encodingOperators); 87 solutionCreator = cloner.Clone(original.solutionCreator); 91 92 RegisterEventHandlers(); 88 93 } 94 89 95 protected Encoding(string name) 90 96 : base(name) { 97 Parameters.Add(new ValueParameter<ISolutionCreator<TSolution>>(name + ".SolutionCreator", "The operator to create a solution.")); 91 98 Parameters.Add(new FixedValueParameter<ReadOnlyItemSet<IOperator>>(name + ".Operators", "The operators that the encoding specifies.", encodingOperators.AsReadOnly())); 99 100 RegisterEventHandlers(); 101 } 102 103 private void RegisterEventHandlers() { 104 SolutionCreatorParameter.ValueChanged += (o, e) => OnSolutionCreatorChanged(); 92 105 } 93 106 -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncoding.cs
r13396 r13469 26 26 namespace HeuristicLab.Optimization { 27 27 public interface IEncoding : IParameterizedNamedItem { 28 IValueParameter SolutionCreatorParameter { get; } 28 29 ISolutionCreator SolutionCreator { get; } 30 29 31 IEnumerable<IOperator> Operators { get; set; } 30 32 … … 32 34 void ConfigureOperators(IEnumerable<IItem> operators); 33 35 36 event EventHandler OperatorsChanged; 34 37 event EventHandler SolutionCreatorChanged; 35 event EventHandler OperatorsChanged;36 38 } 37 39 38 40 public interface IEncoding<TSolution> : IEncoding 39 41 where TSolution : class, ISolution { 40 new ISolutionCreator<TSolution> SolutionCreator { get; set; }42 //new ISolutionCreator<TSolution> SolutionCreator { get; } 41 43 } 42 44 } -
branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Problem.cs
r13396 r13469 30 30 namespace HeuristicLab.Optimization { 31 31 [StorableClass] 32 public abstract class Problem<TEncoding, TSolution, TEvaluator> : HeuristicOptimizationProblem<TEvaluator, ISolutionCreator<TSolution>>, IProblemDefinition<TEncoding, TSolution>, IStorableContent 32 public abstract class Problem<TEncoding, TSolution, TEvaluator> : Problem, 33 IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TSolution>, IStorableContent 33 34 where TEncoding : class, IEncoding<TSolution> 34 35 where TSolution : class, ISolution 35 36 where TEvaluator : class, IEvaluator { 36 37 37 public string Filename { get; set; } // TODO: Really okay here? 38 public string Filename { get; set; } // TODO: Really okay here? should be in Problem (non-generic) 38 39 40 //TODO remove parametr for encoding? 39 41 protected IValueParameter<TEncoding> EncodingParameter { 40 42 get { return (IValueParameter<TEncoding>)Parameters["Encoding"]; } 41 43 } 42 43 44 //mkommend necessary for reuse of operators if the encoding changes 44 45 private TEncoding oldEncoding; 45 46 46 public TEncoding Encoding { 47 47 get { return EncodingParameter.Value; } … … 51 51 } 52 52 } 53 54 ISolutionCreator IHeuristicOptimizationProblem.SolutionCreator { 55 get { return Encoding.SolutionCreator; } 56 } 57 IParameter IHeuristicOptimizationProblem.SolutionCreatorParameter { 58 get { return Encoding.SolutionCreatorParameter; } 59 } 60 event EventHandler IHeuristicOptimizationProblem.SolutionCreatorChanged { 61 add { Encoding.SolutionCreatorChanged += value; } 62 remove { Encoding.SolutionCreatorChanged -= value; } 63 } 64 65 //TODO is a parameter for the evaluator really necessary, only single-objective or multi-objective evulators calling the func are possible 66 public ValueParameter<TEvaluator> EvaluatorParameter { 67 get { return (ValueParameter<TEvaluator>)Parameters["Evaluator"]; } 68 } 69 public TEvaluator Evaluator { 70 get { return EvaluatorParameter.Value; } 71 protected set { EvaluatorParameter.Value = value; } 72 } 73 IEvaluator IHeuristicOptimizationProblem.Evaluator { get { return Evaluator; } } 74 IParameter IHeuristicOptimizationProblem.EvaluatorParameter { get { return EvaluatorParameter; } } 75 76 public event EventHandler EvaluatorChanged; 77 protected virtual void OnEvaluatorChanged() { 78 EventHandler handler = EvaluatorChanged; 79 if (handler != null) 80 handler(this, EventArgs.Empty); 81 } 82 53 83 54 84 protected override IEnumerable<IItem> GetOperators() { … … 66 96 : base() { 67 97 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.")); 98 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.")); 99 68 100 if (Encoding != null) { 69 101 oldEncoding = Encoding; 70 SolutionCreator = Encoding.SolutionCreator;71 102 Parameterize(); 72 103 } … … 76 107 if (encoding == null) throw new ArgumentNullException("encoding"); 77 108 Parameters.Add(new ValueParameter<TEncoding>("Encoding", "Describes the configuration of the encoding, what the variables are called, what type they are and their bounds if any.", encoding)); 109 Parameters.Add(new ValueParameter<TEvaluator>("Evaluator", "The operator used to evaluate a solution.")); 110 78 111 oldEncoding = Encoding; 79 SolutionCreator = Encoding.SolutionCreator;80 112 Parameterize(); 81 113 … … 99 131 private void RegisterEvents() { 100 132 EncodingParameter.ValueChanged += (o, e) => OnEncodingChanged(); 133 EvaluatorParameter.ValueChanged += (o, e) => OnEvaluatorChanged(); 101 134 //var multiEncoding = Encoding as MultiEncoding; 102 135 //if (multiEncoding != null) multiEncoding.EncodingsChanged += MultiEncodingOnEncodingsChanged; … … 122 155 op.EncodingParameter.ActualName = EncodingParameter.Name; 123 156 124 SolutionCreator = Encoding.SolutionCreator;125 126 157 //var multiEncoding = Encoding as MultiEncoding; 127 158 //if (multiEncoding != null) multiEncoding.EncodingsChanged += MultiEncodingOnEncodingsChanged; 128 159 } 129 160 130 protected override void OnSolutionCreatorChanged() {131 base.OnSolutionCreatorChanged();132 Encoding.SolutionCreator = SolutionCreator;133 }161 //protected override void OnSolutionCreatorChanged() { 162 // base.OnSolutionCreatorChanged(); 163 // Encoding.SolutionCreator = SolutionCreator; 164 //} 134 165 135 166 private static void AdaptEncodingOperators(IEncoding oldEncoding, IEncoding newEncoding) { 136 167 if (oldEncoding.GetType() != newEncoding.GetType()) return; 137 168 138 if (oldEncoding .GetType() == typeof(CombinedEncoding)) {169 if (oldEncoding is CombinedEncoding) { 139 170 var oldMultiEncoding = (CombinedEncoding)oldEncoding; 140 171 var newMultiEncoding = (CombinedEncoding)newEncoding; -
branches/ProblemRefactoring/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r13404 r13469 132 132 Parameterize(); 133 133 } 134 protected override void OnSolutionCreatorChanged() { 135 base.OnSolutionCreatorChanged(); 136 Parameterize(); 137 } 134 //TODO check with abeham if this is really necessary 135 //protected override void OnSolutionCreatorChanged() { 136 // base.OnSolutionCreatorChanged(); 137 // Parameterize(); 138 //} 138 139 protected override void OnEvaluatorChanged() { 139 140 base.OnEvaluatorChanged(); -
branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment.Algorithms/3.3/RobustTabooSearch.cs
r13396 r13469 395 395 private void ParameterizeOperators() { 396 396 if (Problem != null) { 397 solutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;397 solutionsCreator.SolutionCreatorParameter.ActualName = base.Problem.SolutionCreatorParameter.Name; 398 398 solutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 399 399 -
branches/ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r13396 r13469 169 169 170 170 #region Events 171 protected override void OnSolutionCreatorChanged() { 172 Parameterize(); 173 base.OnSolutionCreatorChanged(); 174 } 171 //TODO check with abhem if this is necessary 172 //protected override void OnSolutionCreatorChanged() { 173 // Parameterize(); 174 // base.OnSolutionCreatorChanged(); 175 //} 175 176 protected override void OnEvaluatorChanged() { 176 177 Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged; -
branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj
r13443 r13469 158 158 <Private>False</Private> 159 159 </ProjectReference> 160 <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">161 <Project>{DDFB14DD-2A85-493C-A52D-E69729BBAEB0}</Project>162 <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>163 <Private>False</Private>164 </ProjectReference>165 160 <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj"> 166 161 <Project>{DBECB8B0-B166-4133-BAF1-ED67C3FD7FCA}</Project> … … 201 196 <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project> 202 197 <Name>HeuristicLab.Problems.Instances-3.3</Name> 203 <Private>False</Private>204 </ProjectReference>205 <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">206 <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>207 <Name>HeuristicLab.Random-3.3</Name>208 198 <Private>False</Private> 209 199 </ProjectReference> -
branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem new.cs
r13449 r13469 96 96 97 97 #region Properties 98 98 99 public ItemList<Job> JobData { 99 100 get { return JobDataParameter.Value; } … … 166 167 167 168 #region Events 168 protected override void OnSolutionCreatorChanged() {169 170 171 }169 //protected override void OnSolutionCreatorChanged() { 170 //SolutionCreator.ScheduleParameter.ActualNameChanged += SolutionCreator_SchedulingEncodingParameter_ActualNameChanged; 171 //InitializeOperators(); 172 //} 172 173 protected override void OnEvaluatorChanged() { 173 174 base.OnEvaluatorChanged(); … … 196 197 #region Helpers 197 198 private void InitializeOperators() { 198 Operators.Clear(); 199 ApplyEncoding(); 199 //ApplyEncoding(); 200 200 Operators.Add(new BestSchedulingSolutionAnalyzer()); 201 201 ParameterizeOperators(); … … 289 289 } 290 290 } 291 BestKnownSolution = JSMDecoder.Decode Schedule(enc, jobData, JSMDecodingErrorPolicy.RandomPolicy, JSMForcingStrategy.SwapForcing);291 BestKnownSolution = JSMDecoder.Decode(enc, jobData, JSMDecodingErrorPolicy.RandomPolicy, JSMForcingStrategy.SwapForcing); 292 292 //if (ScheduleEvaluator is MeanTardinessEvaluator) 293 293 // BestKnownQuality = MeanTardinessEvaluator.GetMeanTardiness(BestKnownSolution, jobData); -
branches/ProblemRefactoring/HeuristicLab.Problems.Scheduling/3.3/Plugin.cs.frame
r13321 r13469 30 30 [PluginDependency("HeuristicLab.Core", "3.3")] 31 31 [PluginDependency("HeuristicLab.Data", "3.3")] 32 [PluginDependency("HeuristicLab.Encodings.IntegerVectorEncoding", "3.3")]33 32 [PluginDependency("HeuristicLab.Encodings.PermutationEncoding", "3.3")] 34 33 [PluginDependency("HeuristicLab.Encodings.ScheduleEncoding", "3.3")] -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/EsGriewankSampleTest.cs
r13408 r13469 64 64 problem.ProblemSize = 10; 65 65 problem.TestFunction = new Griewank(); 66 problem. SolutionCreatorParameter.Value= new UniformRandomRealVectorCreator();66 problem.Encoding.SolutionCreator = new UniformRandomRealVectorCreator(); 67 67 problem.Bounds = new DoubleMatrix(new double[,] { { -600, 600 } }); 68 68 problem.BestKnownQuality = 0; -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/LocalSearchKnapsackSampleTest.cs
r13408 r13469 62 62 problem.BestKnownSolution = new HeuristicLab.Encodings.BinaryVectorEncoding.BinaryVector(new bool[] { 63 63 true , false, false, true , true , true , true , true , false, true , true , true , true , true , true , false, true , false, true , true , false, true , true , false, true , false, true , true , true , false, true , true , false, true , true , false, true , false, true , true , true , true , true , true , true , true , true , true , true , true , true , false, true , false, false, true , true , false, true , true , true , true , true , true , true , true , false, true , false, true , true , true , true , false, true , true , true , true , true , true , true , true}); 64 problem. SolutionCreatorParameter.Value= new RandomBinaryVectorCreator();64 problem.Encoding.SolutionCreator = new RandomBinaryVectorCreator(); 65 65 problem.KnapsackCapacity = 297; 66 66 problem.Values = new IntArray(new int[] { -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/OSESGriewankSampleTest.cs
r13408 r13469 64 64 problem.ProblemSize = 10; 65 65 problem.TestFunction = new Griewank(); 66 problem. SolutionCreatorParameter.Value= new UniformRandomRealVectorCreator();66 problem.Encoding.SolutionCreator = new UniformRandomRealVectorCreator(); 67 67 problem.Bounds = new DoubleMatrix(new double[,] { { -600, 600 } }); 68 68 problem.BestKnownQuality = 0; -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/PsoSchwefelSampleTest.cs
r13408 r13469 73 73 problem.TestFunction = new Schwefel(); 74 74 problem.ProblemSize = 2; 75 problem. SolutionCreatorParameter.Value= new UniformRandomRealVectorCreator();75 problem.Encoding.SolutionCreator = new UniformRandomRealVectorCreator(); 76 76 #endregion 77 77 #region Algorithm Configuration -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/RAPGASchedulingSampleTest.cs
r12012 r13469 23 23 using System.Linq; 24 24 using HeuristicLab.Algorithms.RAPGA; 25 using HeuristicLab.Encodings.ScheduleEncoding .JobSequenceMatrix;25 using HeuristicLab.Encodings.ScheduleEncoding; 26 26 using HeuristicLab.Persistence.Default.Xml; 27 27 using HeuristicLab.Problems.Scheduling; … … 57 57 private RAPGA CreateRAPGASchedulingSample() { 58 58 #region Problem Configuration 59 JobShopSchedulingProblem problem = new JobShopSchedulingProblem();59 var problem = new JobShopSchedulingProblemNew(); 60 60 #endregion 61 61 -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab-3.3/Samples/SimulatedAnnealingRastriginSampleTest.cs
r13408 r13469 62 62 problem.TestFunction= new Rastrigin(); 63 63 problem.ProblemSize = 2; 64 problem. SolutionCreatorParameter.Value= new UniformRandomRealVectorCreator();64 problem.Encoding.SolutionCreator = new UniformRandomRealVectorCreator(); 65 65 #endregion 66 66 #region Algorithm Configuration -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/DirectScheduleGTCrossoverTest.cs
r12012 r13469 22 22 using System.Linq; 23 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 25 using HeuristicLab.Encodings.ScheduleEncoding.ScheduleEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding; 26 25 using HeuristicLab.Tests; 27 26 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 48 47 Schedule actual; 49 48 actual = DirectScheduleGTCrossover.Apply(random, parent1, parent2, jobData, mutProp); 50 Schedule expected = DirectScheduleRandomCreator.Apply( 3, 3,new PWREncoding(3, 3, new TestRandom(new int[] { 0, 2, 1, 1, 0, 2, 1, 2, 0 }, null)), TestUtils.CreateJobData());49 Schedule expected = DirectScheduleRandomCreator.Apply(new PWREncoding(3, 3, new TestRandom(new int[] { 0, 2, 1, 1, 0, 2, 1, 2, 0 }, null)), TestUtils.CreateJobData()); 51 50 Assert.IsTrue(TestUtils.ScheduleEquals(actual, expected)); 52 51 } -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMJOXCrossoverTest.cs
r12012 r13469 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Encodings.PermutationEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;25 24 using HeuristicLab.Tests; 26 25 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 40 39 [TestProperty("Time", "short")] 41 40 public void ApplyTest() { 42 IRandom random = new TestRandom(new int[] { 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, null);41 IRandom random = new TestRandom(new int[] { 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1 }, null); 43 42 JSMEncoding p1 = TestUtils.CreateTestJSM1(); 44 43 JSMEncoding p2 = TestUtils.CreateTestJSM2(); 45 JSMEncoding expected = new JSMEncoding( );46 ItemList<Permutation> jsm = new ItemList<Permutation>();44 JSMEncoding expected = new JSMEncoding(0); 45 ItemList<Permutation> jsm = expected.JobSequenceMatrix; 47 46 for (int i = 0; i < 6; i++) { 48 47 jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 0, 1, 2 })); 49 48 } 50 expected.JobSequenceMatrix = jsm; 49 51 50 52 51 JSMEncoding actual; -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMSXXCrossoverTest.cs
r12012 r13469 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Encodings.PermutationEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;25 24 using HeuristicLab.Tests; 26 25 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 40 39 [TestProperty("Time", "short")] 41 40 public void ApplyTest() { 42 IRandom random = new TestRandom(new int[] { 3 }, null);41 IRandom random = new TestRandom(new int[] { 0, 3 }, null); 43 42 JSMEncoding p1 = TestUtils.CreateTestJSM1(); 44 43 JSMEncoding p2 = TestUtils.CreateTestJSM2(); 45 JSMEncoding expected = new JSMEncoding( );46 ItemList<Permutation> jsm = new ItemList<Permutation>();44 JSMEncoding expected = new JSMEncoding(0); 45 ItemList<Permutation> jsm = expected.JobSequenceMatrix; 47 46 for (int i = 0; i < 6; i++) { 48 47 jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 2, 1, 0, 3, 4, 5 })); 49 48 } 50 expected.JobSequenceMatrix = jsm;51 49 52 50 JSMEncoding actual; -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/JSMShiftChangeManipulatorTest.cs
r12012 r13469 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Encodings.PermutationEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix;25 24 using HeuristicLab.Tests; 26 25 using Microsoft.VisualStudio.TestTools.UnitTesting; … … 43 42 JSMEncoding individual = TestUtils.CreateTestJSM1(); 44 43 JSMShiftChangeManipulator.Apply(random, individual); 45 JSMEncoding expected = new JSMEncoding( );46 ItemList<Permutation> jsm = new ItemList<Permutation>();44 JSMEncoding expected = new JSMEncoding(0); 45 ItemList<Permutation> jsm = expected.JobSequenceMatrix; 47 46 for (int i = 0; i < 3; i++) { 48 47 jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 3, 2, 4, 5 })); 49 48 jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 3, 4, 2, 5 })); 50 49 } 51 expected.JobSequenceMatrix = jsm;52 50 53 51 Assert.IsTrue(TestUtils.JSMEncodingEquals(expected, individual)); -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/PWRGOXCrossoverTest.cs
r12012 r13469 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Encodings.IntegerVectorEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;25 24 using HeuristicLab.Tests; 26 25 using Microsoft.VisualStudio.TestTools.UnitTesting; -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/PWRPPXCrossoverTest.cs
r12012 r13469 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Encodings.IntegerVectorEncoding; 24 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition;25 24 using HeuristicLab.Tests; 26 25 using Microsoft.VisualStudio.TestTools.UnitTesting; -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Encodings.ScheduleEncoding-3.3/TestUtils.cs
r12012 r13469 24 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 25 25 using HeuristicLab.Encodings.PermutationEncoding; 26 using HeuristicLab.Encodings.ScheduleEncoding.JobSequenceMatrix; 27 using HeuristicLab.Encodings.ScheduleEncoding.PermutationWithRepetition; 26 28 27 using HeuristicLab.Tests; 29 28 … … 31 30 public class TestUtils { 32 31 public static JSMEncoding CreateTestJSM1() { 33 JSMEncoding result = new JSMEncoding( );34 ItemList<Permutation> jsm = new ItemList<Permutation>();32 JSMEncoding result = new JSMEncoding(0); 33 ItemList<Permutation> jsm = result.JobSequenceMatrix; 35 34 for (int i = 0; i < 6; i++) 36 35 jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 0, 1, 2, 3, 4, 5 })); 37 result.JobSequenceMatrix = jsm;38 36 return result; 39 37 } 40 38 41 39 public static JSMEncoding CreateTestJSM2() { 42 JSMEncoding result = new JSMEncoding( );43 ItemList<Permutation> jsm = new ItemList<Permutation>();40 JSMEncoding result = new JSMEncoding(0); 41 ItemList<Permutation> jsm = result.JobSequenceMatrix; 44 42 for (int i = 0; i < 6; i++) 45 43 jsm.Add(new Permutation(PermutationTypes.Absolute, new int[] { 5, 4, 3, 2, 1, 0 })); 46 result.JobSequenceMatrix = jsm;47 44 return result; 48 45 } … … 66 63 public static ItemList<Job> CreateJobData() { 67 64 Job j1 = new Job(0, 0); 68 j1.Tasks = new ItemList<Task> {65 j1.Tasks.AddRange(new[]{ 69 66 new Task (0, 0, j1.Index, 1), 70 67 new Task (1, 1, j1.Index, 2), 71 68 new Task (2, 2, j1.Index, 1) 72 } ;69 }); 73 70 74 71 Job j2 = new Job(1, 0); 75 j2.Tasks = new ItemList<Task>{72 j2.Tasks.AddRange(new[]{ 76 73 new Task (3, 2, j2.Index, 2), 77 74 new Task (4, 1, j2.Index, 1), 78 75 new Task (5, 0, j2.Index, 2) 79 } ;76 }); 80 77 81 78 Job j3 = new Job(2, 0); 82 j3.Tasks = new ItemList<Task>{79 j3.Tasks.AddRange(new[]{ 83 80 new Task (6, 0, j3.Index, 1), 84 81 new Task (7, 2, j3.Index, 2), 85 82 new Task (8, 1, j3.Index, 1) 86 } ;83 }); 87 84 88 85 return new ItemList<Job> { j1, j2, j3 }; … … 90 87 91 88 public static Schedule CreateTestSchedule1() { 92 Schedule result = DirectScheduleRandomCreator.Apply( 3, 3,new PWREncoding(3, 3, new TestRandom(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 }, null)), CreateJobData());89 Schedule result = DirectScheduleRandomCreator.Apply(new PWREncoding(3, 3, new TestRandom(new int[] { 1, 0, 1, 1, 2, 0, 2, 2, 0 }, null)), CreateJobData()); 93 90 return result; 94 91 } 95 92 96 93 public static Schedule CreateTestSchedule2() { 97 Schedule result = DirectScheduleRandomCreator.Apply( 3, 3,new PWREncoding(3, 3, new TestRandom(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 }, null)), CreateJobData());94 Schedule result = DirectScheduleRandomCreator.Apply(new PWREncoding(3, 3, new TestRandom(new int[] { 0, 1, 1, 0, 2, 0, 1, 2, 2 }, null)), CreateJobData()); 98 95 return result; 99 96 } -
branches/ProblemRefactoring/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPLIBInstancesTest.cs
r13408 r13469 202 202 try { 203 203 qap.Load(provider.LoadData(instance)); 204 } catch (Exception ex) { 204 } 205 catch (Exception ex) { 205 206 failedInstances.AppendLine(instance + ": " + ex.Message); 206 207 } … … 223 224 qap.Load(provider.LoadData(instance)); 224 225 if (qaplibInstances.ContainsKey(instance.Name) 225 && qap.BestKnownQuality != null && qap.BestKnownQuality !=qaplibInstances[instance.Name])226 && qap.BestKnownQuality != qaplibInstances[instance.Name]) 226 227 failedInstances.AppendLine(instance.Name + ": " + qap.BestKnownQuality.ToString() + " vs " + qaplibInstances[instance.Name]); 227 228 }
Note: See TracChangeset
for help on using the changeset viewer.