Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 16:46:35 (12 years ago)
Author:
gkronber
Message:

#1847: merged r8084:8205 from trunk into GP move operators branch

Location:
branches/GP-MoveOperators
Files:
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Tests

  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab-3.3/PluginDependenciesTest.cs

    r7948 r8206  
    3535    private static Dictionary<string, string> pluginNames;
    3636    private static Dictionary<string, Assembly> pluginFilesToPluginLookup = new Dictionary<string, Assembly>();
    37     //private static Dictionary<string, string> pluginToPluginFilesLookup = new Dictionary<string, string>();
    3837
    3938    // Use ClassInitialize to run code before running the first test in the class
     
    9190
    9291          var referencedNonPluginAssemblies = pluginAssembly.GetReferencedAssemblies().Where(a => !IsPluginAssemblyName(a));
    93           bool found = (from referencedNonPluginAssemblie in referencedNonPluginAssemblies
    94                         select referencedNonPluginAssemblie.Name into assemblyName
     92          bool found = (from referencedNonPluginAssembly in referencedNonPluginAssemblies
     93                        select referencedNonPluginAssembly.Name into assemblyName
    9594                        where pluginFilesToPluginLookup.ContainsKey(assemblyName)
    9695                        select GetPluginFromAssembly(pluginFilesToPluginLookup[assemblyName]) into pluginType
  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab-3.3/SamplesTest.cs

    r7915 r8206  
    4444using HeuristicLab.Problems.DataAnalysis.Symbolic.Classification;
    4545using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
     46using HeuristicLab.Problems.Instances;
    4647using HeuristicLab.Problems.Instances.DataAnalysis;
    4748using HeuristicLab.Problems.Instances.TSPLIB;
     49using HeuristicLab.Problems.Instances.VehicleRouting;
    4850using HeuristicLab.Problems.Knapsack;
    4951using HeuristicLab.Problems.TestFunctions;
     
    5153using HeuristicLab.Problems.VehicleRouting;
    5254using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    53 using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
    5455using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    5556using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    5657using HeuristicLab.Selection;
    5758using Microsoft.VisualStudio.TestTools.UnitTesting;
    58 using HeuristicLab.Problems.Instances.VehicleRouting;
    59 using HeuristicLab.Problems.Instances;
    6059
    6160
     
    133132
    134133      SolomonFormatInstanceProvider instanceProvider = new SolomonInstanceProvider();
    135       IVRPData data = instanceProvider.LoadData("C101.txt", "C101.opt.txt");
     134      IVRPData data = instanceProvider.Import("C101.txt", "C101.opt.txt");
    136135      vrpProblem.Load(data);
    137136      vrpProblem.Name = "C101 VRP (imported from Solomon)";
     
    439438    }
    440439    #endregion
     440    #region LawnMower
     441    [TestMethod]
     442    public void RunGpLawnMowerSampleTest() {
     443      var ga = CreateGpLawnMowerSample();
     444      ga.SetSeedRandomly.Value = false;
     445      RunAlgorithm(ga);
     446    }
     447
     448    public GeneticAlgorithm CreateGpLawnMowerSample() {
     449      GeneticAlgorithm ga = new GeneticAlgorithm();
     450      #region Problem Configuration
     451      var problem = new HeuristicLab.Problems.LawnMower.Problem();
     452      #endregion
     453      #region Algorithm Configuration
     454      ga.Name = "Genetic Programming - Lawn Mower";
     455      ga.Description = "A standard genetic programming algorithm to solve the lawn mower problem";
     456      ga.Problem = problem;
     457      ConfigureGeneticAlgorithmParameters<TournamentSelector, SubtreeCrossover, MultiSymbolicExpressionTreeArchitectureManipulator>(
     458        ga, 1000, 1, 50, 0.25, 5);
     459      var mutator = (MultiSymbolicExpressionTreeArchitectureManipulator)ga.Mutator;
     460      mutator.Operators.SetItemCheckedState(mutator.Operators
     461        .OfType<OnePointShaker>()
     462        .Single(), false);
     463      #endregion
     464      return ga;
     465    }
     466    #endregion
    441467    #endregion
    442468
  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab-3.3/ToStringTest.cs

    r7915 r8206  
    2020#endregion
    2121
     22using System;
    2223using System.Linq;
    2324using HeuristicLab.Core;
     
    2930  public class ToStringTest {
    3031
     32    private TestContext testContextInstance;
     33    /// <summary>
     34    ///Gets or sets the test context which provides
     35    ///information about and functionality for the current test run.
     36    ///</summary>
     37    public TestContext TestContext {
     38      get {
     39        return testContextInstance;
     40      }
     41      set {
     42        testContextInstance = value;
     43      }
     44    }
     45
    3146    // Use ClassInitialize to run code before running the first test in the class
    3247    [ClassInitialize]
     
    3752    [TestMethod]
    3853    public void TestToString() {
     54      bool success = true;
    3955      // just test for all IItems that the ToString method doesn't throw an exception
    4056      foreach (object item in ApplicationManager.Manager.GetInstances(typeof(IItem))) {
    41         item.ToString();
     57        try {
     58          item.ToString();
     59        }
     60        catch (Exception e) {
     61          TestContext.WriteLine(item.GetType() + " throws a " + e.GetType() + " in the ToString method.");
     62          success = false;
     63        }
    4264      }
     65      Assert.IsTrue(success, "There are potential errors in the ToString methods of  objects.");
    4366    }
    4467  }
  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicDataAnalysisExpressionTreeInterpreterTest.cs

    r8085 r8206  
    365365      Evaluate(interpreter, ds, "(lag -1.0 (* (lagVariable 1.0 a 1) (lagVariable 1.0 b 2)))", 1, ds.GetDoubleValue("A", 1) * ds.GetDoubleValue("B", 2));
    366366      Evaluate(interpreter, ds, "(lag -2.0 3.0)", 1, 3.0);
     367
     368      {
     369        // special functions
     370        Action<double> checkAiry = (x) => {
     371          double ai, aip, bi, bip;
     372          alglib.airy(x, out ai, out aip, out bi, out bip);
     373          Evaluate(interpreter, ds, "(airya " + x + ")", 0, ai);
     374          Evaluate(interpreter, ds, "(airyb " + x + ")", 0, bi);
     375        };
     376
     377        Action<double> checkBessel = (x) => {
     378          Evaluate(interpreter, ds, "(bessel " + x + ")", 0, alglib.besseli0(x));
     379        };
     380
     381        Action<double> checkSinCosIntegrals = (x) => {
     382          double si, ci;
     383          alglib.sinecosineintegrals(x, out si, out ci);
     384          Evaluate(interpreter, ds, "(cosint " + x + ")", 0, ci);
     385          Evaluate(interpreter, ds, "(sinint " + x + ")", 0, si);
     386        };
     387        Action<double> checkHypSinCosIntegrals = (x) => {
     388          double shi, chi;
     389          alglib.hyperbolicsinecosineintegrals(x, out shi, out chi);
     390          Evaluate(interpreter, ds, "(hypcosint " + x + ")", 0, chi);
     391          Evaluate(interpreter, ds, "(hypsinint " + x + ")", 0, shi);
     392        };
     393        Action<double> checkFresnelSinCosIntegrals = (x) => {
     394          double c = 0, s = 0;
     395          alglib.fresnelintegral(x, ref c, ref s);
     396          Evaluate(interpreter, ds, "(fresnelcosint " + x + ")", 0, c);
     397          Evaluate(interpreter, ds, "(fresnelsinint " + x + ")", 0, s);
     398        };
     399        Action<double> checkNormErf = (x) => {
     400          Evaluate(interpreter, ds, "(norm " + x + ")", 0, alglib.normaldistribution(x));
     401          Evaluate(interpreter, ds, "(erf " + x + ")", 0, alglib.errorfunction(x));
     402        };
     403
     404        Action<double> checkGamma = (x) => {
     405          Evaluate(interpreter, ds, "(gamma " + x + ")", 0, alglib.gammafunction(x));
     406        };
     407        Action<double> checkPsi = (x) => {
     408          try {
     409            Evaluate(interpreter, ds, "(psi " + x + ")", 0, alglib.psi(x));
     410          }
     411          catch (alglib.alglibexception) { // ignore cases where alglib throws an exception
     412          }
     413        };
     414        Action<double> checkDawson = (x) => {
     415          Evaluate(interpreter, ds, "(dawson " + x + ")", 0, alglib.dawsonintegral(x));
     416        };
     417        Action<double> checkExpInt = (x) => {
     418          Evaluate(interpreter, ds, "(expint " + x + ")", 0, alglib.exponentialintegralei(x));
     419        };
     420
     421
     422
     423        foreach (var e in new[] { -2.0, -1.0, 0.0, 1.0, 2.0 }) {
     424          checkAiry(e);
     425          checkBessel(e);
     426          checkSinCosIntegrals(e);
     427          checkGamma(e);
     428          checkExpInt(e);
     429          checkDawson(e);
     430          checkPsi(e);
     431          checkNormErf(e);
     432          checkFresnelSinCosIntegrals(e);
     433          checkHypSinCosIntegrals(e);
     434        }
     435      }
    367436    }
    368437
  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionImporter.cs

    r8085 r8206  
    4949        {"COS", new Cosine()},
    5050        {"TAN", new Tangent()},
     51        {"AIRYA", new AiryA()},
     52        {"AIRYB", new AiryB()},
     53        {"BESSEL", new Bessel()},
     54        {"COSINT", new CosineIntegral()},
     55        {"SININT", new SineIntegral()},
     56        {"HYPCOSINT", new HyperbolicCosineIntegral()},
     57        {"HYPSININT", new HyperbolicSineIntegral()},
     58        {"FRESNELSININT", new FresnelSineIntegral()},
     59        {"FRESNELCOSINT", new FresnelCosineIntegral()},
     60        {"NORM", new Norm()},
     61        {"ERF", new Erf()},
     62        {"GAMMA", new Gamma()},
     63        {"PSI", new Psi()},
     64        {"DAWSON", new Dawson()},
     65        {"EXPINT", new ExponentialIntegralEi()},
    5166        {"MEAN", new Average()},
    5267        {"IF", new IfThenElse()},
  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Problems.QuadraticAssignment-3.3/QAPLIBInstancesTest.cs

    r8085 r8206  
    168168      { "wil100", 273038 }
    169169    };
     170    private static Dictionary<string, double> lowerBounds = new Dictionary<string, double>() {
     171      { "bur26a", 5315200 },
     172      { "bur26f", 3706888 },
     173      { "chr25a", 2765 },
     174      { "els19", 11971949 },
     175      { "esc32a", 35 },
     176      { "esc32e", 0 },
     177      { "had20", 6166 },
     178      { "kra32", 67390 },
     179      { "lipa50a", 62020 },
     180      { "lipa50b", 1210244 },
     181      { "nug30", 4539 },
     182      { "scr20", 86766 },
     183      { "sko42", 11311 },
     184      { "tai35a", 1951207 },
     185      { "tai35b", 30866283 },
     186      { "tai100a", 15824355 }
     187    };
    170188    #endregion
    171189
     
    204222          failedInstances.AppendLine(instance.Name + ": " + qap.BestKnownQuality.Value.ToString() + " vs " + qaplibInstances[instance.Name]);
    205223      }
    206       Assert.IsTrue(failedInstances.Length == 0, "Following instances/solutions have suspicious quality: " + Environment.NewLine + failedInstances.ToString());
     224      Assert.IsTrue(failedInstances.Length == 0, "Following instances/solutions have suspicious best quality: " + Environment.NewLine + failedInstances.ToString());
     225    }
     226
     227    [TestMethod]
     228    public void TestQAPLIBLowerBounds() {
     229      var provider = new QAPLIBInstanceProvider();
     230      var qap = new QuadraticAssignmentProblem();
     231      var failedInstances = new StringBuilder();
     232
     233      var instances = provider.GetDataDescriptors();
     234      Assert.IsTrue(instances.Any(), "No instances could be found.");
     235
     236      foreach (var instance in instances) {
     237        if (lowerBounds.ContainsKey(instance.Name)) {
     238          qap.Load(provider.LoadData(instance));
     239          if (qap.LowerBound.Value != lowerBounds[instance.Name])
     240            failedInstances.AppendLine(instance.Name + ": The Gilmore-Lawler lower bound is not valid.");
     241        }
     242      }
     243      Assert.IsTrue(failedInstances.Length == 0, "Following instances failed for the GLB calculation: " + Environment.NewLine + failedInstances.ToString());
    207244    }
    208245  }
  • branches/GP-MoveOperators/HeuristicLab.Tests/HeuristicLab.Tests.csproj

    r8085 r8206  
    225225      <HintPath>..\bin\HeuristicLab.Problems.Knapsack-3.3.dll</HintPath>
    226226    </Reference>
     227    <Reference Include="HeuristicLab.Problems.LawnMower-3.3">
     228      <HintPath>..\bin\HeuristicLab.Problems.LawnMower-3.3.dll</HintPath>
     229    </Reference>
    227230    <Reference Include="HeuristicLab.Problems.LinearAssignment-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    228231      <HintPath>..\bin\HeuristicLab.Problems.LinearAssignment-3.3.dll</HintPath>
     
    275278    <Compile Include="HeuristicLab-3.3\CollectObjectGraphTest.cs" />
    276279    <Compile Include="HeuristicLab-3.3\ContentViewTests.cs" />
     280    <Compile Include="HeuristicLab-3.3\ParameterVisibilityTest.cs" />
    277281    <Compile Include="HeuristicLab-3.3\DeepCloneableCloningTest.cs" />
    278282    <Compile Include="HeuristicLab-3.3\GeneticAlgorithmTest.cs" />
Note: See TracChangeset for help on using the changeset viewer.