package archimulator.test;

import archimulator.common.ContextMapping;
import archimulator.common.Experiment;
import archimulator.common.ExperimentType;
import org.junit.Test;

/**
 * Experiment test.
 *
 * @author Min Cai
 */
public class ExperimentTest {
    @Test
    public void test_mst_ht_100_aco_detailed() {
        test(
                ExperimentType.DETAILED,
                -1,
                "benchmarks/Olden_Custom1/mst/ht/mst.mips",
                "100",
                "test_results/mst_ht_100_aco_detailed",
                "oddEven",
                "aco"
        );
    }

    @Test
    public void test_mst_ht_1000_aco_two_phase() {
        test(
                ExperimentType.TWO_PHASE,
                1000000,
                "benchmarks/Olden_Custom1/mst/ht/mst.mips",
                "1000",
                "test_results/test_mst_ht_1000_aco_two_phase",
                "oddEven",
                "aco"
        );
    }

    private void test(
            ExperimentType experimentType,
            long numMaxInstructions, String executable,
            String arguments,
            String outputDirectory,
            String routing,
            String selection
    ) {
        Experiment experiment = new Experiment();

        experiment.getConfig().setType(experimentType);

        experiment.getConfig().setNumMaxInstructions(numMaxInstructions);

        experiment.getConfig().setNumCores(16);
        experiment.getConfig().setNumThreadsPerCore(1);

        experiment.getConfig().getContextMappings().add(new ContextMapping(0, executable, arguments));
        experiment.getConfig().getContextMappings().add(new ContextMapping(4, executable, arguments));
        experiment.getConfig().getContextMappings().add(new ContextMapping(8, executable, arguments));
        experiment.getConfig().getContextMappings().add(new ContextMapping(12, executable, arguments));

        experiment.getConfig().setOutputDirectory(outputDirectory);

        experiment.getConfig().setRouting(routing);
        experiment.getConfig().setSelection(selection);

        experiment.getConfig().setAntPacketInjectionRate(0.001);
        experiment.getConfig().setAcoSelectionAlpha(0.45);
        experiment.getConfig().setReinforcementFactor(0.001);

        experiment.run();
    }
}

@@ -308,32 +308,56 @@
 iled() %7B%0A       
+ Experiment experiment =
  test(%0A         
@@ -598,32 +598,59 @@
 %22aco%22%0A        );
+%0A%0A        experiment.run();
 %0A    %7D%0A%0A    @Tes
@@ -709,16 +709,40 @@
 %0A       
+ Experiment experiment =
  test(%0A 
@@ -1013,16 +1013,43 @@
       );
+%0A%0A        experiment.run();
 %0A    %7D%0A%0A
@@ -1060,20 +1060,26 @@
 private 
-void
+Experiment
  test(%0A 
@@ -1156,16 +1156,28 @@
 uctions,
+%0A           
  String 
@@ -2386,32 +2386,39 @@
 .001);%0A%0A        
+return 
 experiment.run()
@@ -2403,32 +2403,26 @@
 eturn experiment
-.run()
 ;%0A    %7D%0A%7D%0A

Update ExperimentTest.