public TestResult(double averageError, double maxError, double averageTime, double maxTime, int n, GeneratorSetup generatorSetup) { AverageError = averageError; MaxError = maxError; AverageTime = averageTime; MaxTime = maxTime; N = n; GeneratorSetup = generatorSetup; }
private static void GenerateRatioCapacityToWeightSum(ICollection <GeneratorSetup> list) { for (var f = 0.1f; f <= 1.0f; f += 0.05f) { GeneratorSetup gen = new GeneratorSetup(); gen.GeneratorName = MethodBase.GetCurrentMethod().Name; gen.RatioCapacityToWeightSum = f; list.Add(gen); } }
private static void GenerateExponent(ICollection <GeneratorSetup> list) { for (var f = 0.01f; f <= 3.0f; f += 0.05f) { GeneratorSetup gen = new GeneratorSetup(); gen.GeneratorName = MethodBase.GetCurrentMethod().Name; gen.Exponent = f; list.Add(gen); } }
private static void GenerateMaxCost(ICollection <GeneratorSetup> list) { for (var i = 100; i <= 5100; i += 500) { GeneratorSetup gen = new GeneratorSetup(); gen.GeneratorName = MethodBase.GetCurrentMethod().Name; gen.MaxCost = i; list.Add(gen); } }
public GeneratorSetup(GeneratorSetup orig) { StartingId = orig.StartingId; ItemCount = orig.ItemCount; InstanceCount = orig.InstanceCount; RatioCapacityToWeightSum = orig.RatioCapacityToWeightSum; MaxWeight = orig.MaxWeight; MaxCost = orig.MaxCost; Exponent = orig.Exponent; EqualThings = orig.EqualThings; LessThings = orig.LessThings; GeneratorName = orig.GeneratorName; }
public ResultPrinter(List <TestResult> testResults, Algorithm algorithm) { _testResults = testResults; _algorithm = algorithm; GeneratorSetup generatorSetup = null; if (_testResults.Count > 0) { generatorSetup = _testResults[0].GeneratorSetup; } if (File.Exists(GetFileName(null))) { File.Delete(GetFileName(null)); } }
public Test(StreamReader streamReader, GeneratorSetup generatorSetup) { KnapsackReader knapsackReader = new KnapsackReader(streamReader); _generatorSetup = generatorSetup; Knapsack knapsack; do { knapsack = knapsackReader.ReadKnapsack(); if (knapsack != null) { _knapsacks.Add(knapsack); } } while (knapsack != null); }
private static void GenerateLessEqualGreater(ICollection <GeneratorSetup> list) { var genL = new GeneratorSetup(); var genE = new GeneratorSetup(); var genG = new GeneratorSetup(); genL.LessThings = true; genL.EqualThings = false; genE.EqualThings = true; genG.LessThings = false; genG.EqualThings = false; list.Add(genL); list.Add(genE); list.Add(genG); genL.GeneratorName = MethodBase.GetCurrentMethod().Name; genE.GeneratorName = MethodBase.GetCurrentMethod().Name; genG.GeneratorName = MethodBase.GetCurrentMethod().Name; }
private StreamReader GenerateTest(GeneratorSetup generatorSetup) { StringBuilder outputBuilder = new StringBuilder(); string output = ""; using (AutoResetEvent outputWaitHandle = new AutoResetEvent(false)) using (AutoResetEvent errorWaitHandle = new AutoResetEvent(false)) { using (Process process = new Process()) { process.StartInfo.FileName = "../../knapgen.exe"; process.StartInfo.UseShellExecute = false; process.EnableRaisingEvents = true; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.RedirectStandardError = true; process.StartInfo.Arguments = $"-I {generatorSetup.StartingId}" + $" -n {generatorSetup.ItemCount}" + $" -N {generatorSetup.InstanceCount}" + $" -m {generatorSetup.RatioCapacityToWeightSum}" + $" -W {generatorSetup.MaxWeight}" + $" -C {generatorSetup.MaxCost}" + $" -k {generatorSetup.Exponent}" + $" -d {(generatorSetup.EqualThings ? 0 : (generatorSetup.LessThings ? -1 : 1))}"; try { process.OutputDataReceived += (sender, e) => { if (e.Data != null) { outputBuilder.AppendLine(e.Data); } }; process.ErrorDataReceived += (sender, e) => { if (e.Data != null) { // outputBuilder.AppendLine(e.Data); } }; process.Start(); process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); output = outputBuilder.ToString(); } finally { outputWaitHandle.WaitOne(1); errorWaitHandle.WaitOne(1); } } } return(new StreamReader(GenerateStreamFromString(output))); }