@Test(expected = OutputExitException.class) public void testSetup() { state.parameters.set(BASE.push(TSPProblem.P_FILE), "/dev/null"); final TSPProblem instance = new TSPProblem(); instance.setup(state, BASE); }
@Override public void setup(EvolutionState state, Parameter base) { assert(state != null); assert(base != null); final File file = state.parameters.getFile(base.push(P_FILE), null); allowCycles = state.parameters.getBoolean(base.push(P_ALLOW_CYCLES), null, false); if (file == null) state.output.fatal(String.format("%s: Unable to read file path '%s'.", this.getClass().getSimpleName(), base.push(P_FILE)), base.push(P_FILE)); try { assert(file != null); graph = new TSPGraph(file); } catch (final Exception e) { state.output.fatal(String.format("%s: Unable to load TSP instance from file '%s': %s", this.getClass().getSimpleName(), state.parameters.getString(base.push(P_FILE), null), e), base.push(P_FILE)); } assert(repOK()); }
TSPProblem extends Problem implements SimpleProblemForm, ConstructiveProblemForm<TSPComponent> { @Override public void setup(EvolutionState state, Parameter base) { assert(state != null); assert(base != null); final File file = state.parameters.getFile(base.push(P_FILE), null); allowCycles = state.parameters.getBoolean(base.push(P_ALLOW_CYCLES), null, false); if (file == null) state.output.fatal(String.format("%s: Unable to read file path '%s'.", this.getClass().getSimpleName(), base.push(P_FILE)), base.push(P_FILE)); try { assert(file != null); graph = new TSPGraph(file); } catch (final Exception e) { state.output.fatal(String.format("%s: Unable to load TSP instance from file '%s': %s", this.getClass().getSimpleName(), state.parameters.getString(base.push(P_FILE), null), e), base.push(P_FILE)); } assert(repOK()); } }
TSPProblem extends Problem implements SimpleProblemForm, ConstructiveProblemForm<TSPComponent> { @Override public void setup(EvolutionState state, Parameter base) { assert(state != null); assert(base != null); final File file = state.parameters.getFile(base.push(P_FILE), null); allowCycles = state.parameters.getBoolean(base.push(P_ALLOW_CYCLES), null, false); if (file == null) state.output.fatal(String.format("%s: Unable to read file path '%s'.", this.getClass().getSimpleName(), base.push(P_FILE)), base.push(P_FILE)); try { assert(file != null); graph = new TSPGraph(file); } catch (final Exception e) { state.output.fatal(String.format("%s: Unable to load TSP instance from file '%s': %s", this.getClass().getSimpleName(), state.parameters.getString(base.push(P_FILE), null), e), base.push(P_FILE)); } assert(repOK()); }  }
TSPProblem extends Problem implements SimpleProblemForm, ConstructiveProblemForm<TSPComponent> { @Override public void setup(EvolutionState state, Parameter base) { assert(state != null); assert(base != null); final File file = state.parameters.getFile(base.push(P_FILE), null); allowCycles = state.parameters.getBoolean(base.push(P_ALLOW_CYCLES), null, false); if (file == null) state.output.fatal(String.format("%s: Unable to read file path '%s'.", this.getClass().getSimpleName(), base.push(P_FILE)), base.push(P_FILE)); try { assert(file != null); graph = new TSPGraph(file); } catch (final Exception e) { state.output.fatal(String.format("%s: Unable to load TSP instance from file '%s': %s", this.getClass().getSimpleName(), state.parameters.getString(base.push(P_FILE), null), e), base.push(P_FILE)); } assert(repOK()); }  TSPComponent getComponent(final int from, final int to); TSPComponent getComponentFromString(final String s); int numNodes(); @Override void setup(EvolutionState state, Parameter base); boolean isViolated(final ConstructiveIndividual<TSPComponent> partialSolution, final Component component); @Override TSPComponent getArbitraryComponent(final EvolutionState state, final int thread); @Override List<TSPComponent> getAllComponents(); @Override List<TSPComponent> getAllowedComponents(final ConstructiveIndividual<TSPComponent> partialSolution); @Override boolean isCompleteSolution(final ConstructiveIndividual<TSPComponent> solution); @Override void evaluate(final EvolutionState state, final Individual ind, final int subpopulation, final int threadnum); @Override int numComponents(); final boolean repOK(); }
TSPProblem extends Problem implements SimpleProblemForm, ConstructiveProblemForm<TSPComponent> { @Override public void setup(EvolutionState state, Parameter base) { assert(state != null); assert(base != null); final File file = state.parameters.getFile(base.push(P_FILE), null); allowCycles = state.parameters.getBoolean(base.push(P_ALLOW_CYCLES), null, false); if (file == null) state.output.fatal(String.format("%s: Unable to read file path '%s'.", this.getClass().getSimpleName(), base.push(P_FILE)), base.push(P_FILE)); try { assert(file != null); graph = new TSPGraph(file); } catch (final Exception e) { state.output.fatal(String.format("%s: Unable to load TSP instance from file '%s': %s", this.getClass().getSimpleName(), state.parameters.getString(base.push(P_FILE), null), e), base.push(P_FILE)); } assert(repOK()); }  TSPComponent getComponent(final int from, final int to); TSPComponent getComponentFromString(final String s); int numNodes(); @Override void setup(EvolutionState state, Parameter base); boolean isViolated(final ConstructiveIndividual<TSPComponent> partialSolution, final Component component); @Override TSPComponent getArbitraryComponent(final EvolutionState state, final int thread); @Override List<TSPComponent> getAllComponents(); @Override List<TSPComponent> getAllowedComponents(final ConstructiveIndividual<TSPComponent> partialSolution); @Override boolean isCompleteSolution(final ConstructiveIndividual<TSPComponent> solution); @Override void evaluate(final EvolutionState state, final Individual ind, final int subpopulation, final int threadnum); @Override int numComponents(); final boolean repOK(); final static String P_FILE; final static String P_ALLOW_CYCLES; }