@Test public void testInitChain() throws Exception { SimulatedAnnealing simulatedAnnealing = new SimulatedAnnealing(); Knapsack knapsack = new Knapsack("9035 4 100 4 236 68 237 74 121 22 112"); Configuration configuration = knapsack.getRandomConfiguration(); double fitness = knapsack.getDefaultFitness().getValue(configuration); simulatedAnnealing.init(new BaseObjectiveProblem(knapsack), configuration); assert simulatedAnnealing.getBestFitness() == fitness : "Expected fitness to be " + fitness + ", got " + simulatedAnnealing.getBestFitness(); assert simulatedAnnealing.getBestConfiguration() == configuration : "Expected solution to be " + configuration + ", got " + simulatedAnnealing.getBestConfiguration(); // try to perform optimize step - SA should not raise an exception simulatedAnnealing.optimize(); }