Skip to content

Commit

Permalink
Added performance threshold test with newly created test, modified RE…
Browse files Browse the repository at this point in the history
…ADME
  • Loading branch information
JanPalasek committed Oct 28, 2020
1 parent 3a8cc0a commit 49129ef
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
using NUnit.Framework;
using Serilog;

/// <summary>
/// Verifies whether Job Shop Genetic Algorithm doesn't copy.
/// </summary>
[TestFixture]
public class JobShopGeneticAlgorithmTests
public class JobShopGeneticAlgorithmCloneTests
{
private JobShopGeneticAlgorithm ga;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using GeneticSharp.Domain.Randomizations;
using JobShopScheduling.JobShopStructures;
using Moq;
using NUnit.Framework;
using Serilog;

namespace JobShopScheduling.Tests
{
/// <summary>
/// Checks whether it can find the best result on easy tasks. This test is a lower performance threshold for the algorithm.
/// </summary>
/// <remarks>
/// There is no easy option to set a fixed seed unfortunately in GeneticSharp Random Provider, but the test should still work
/// even with bad seeds.
/// </remarks>
[TestFixture]
public class JobShopGeneticAlgorithmPerformanceThresholdTests
{
/// <summary>
/// Runs performance threshold test.
///
/// This configurations graph is depicted in test2.graphml graph file with arrows specifying order of machine evaluation.
/// </summary>
[Test]
public void RunTest()
{
var jobShop = new JobShopLoader().Load("TestExamples/test2.in");
var mockLogger = new Mock<ILogger>();

var ga = new JobShopGeneticAlgorithm(jobShop, 1, mockLogger.Object, adaptive: false);

Global.Config.MinPopulationSize = 100;
Global.Config.MaxPopulationSize = 100;
Global.Config.GenerationsCount = 100;
Global.Config.CrossoverProbability = 0.75f;
Global.Config.MutationProbability = 0.3f;
Global.Config.MutationPerGeneProbability = 0.01f;
Global.Config.ElitismPercent = 0.02f;

ga.Run();

int expectedScheduleLength = 26;
Assert.That(ga.BestSchedule.ScheduleLength, Is.EqualTo(expectedScheduleLength));
}
}
}
5 changes: 5 additions & 0 deletions JobShopScheduling.Tests/JobShopScheduling.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="TestExamples\test2.in">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Loading

0 comments on commit 49129ef

Please sign in to comment.