List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getDouble
public double getDouble(String key)
From source file:Cresendo.java
public static void main(String[] args) { String cfgFileReceiver = null; // Path to config file for eif receiver agent String cfgFileEngine = null; // Path to config file for xml event engine Options opts = null; // Command line options HelpFormatter hf = null; // Command line help formatter // Setup the message record which will contain text written to the log file ////from ww w . j ava 2s . co m // The message logger object is created when the "-l" is processed // as this object need to be associated with a log file // LogRecord msg = new LogRecord(LogRecord.TYPE_INFO, "Cresendo", "main", "", "", "", "", ""); // Get the directory separator (defaults to "/") // dirSep = System.getProperty("file.separator", "/"); // Initialise the structure containing the event handler objects // Vector<IEventHandler> eventHandler = new Vector<IEventHandler>(10, 10); // Process the command line arguments // try { opts = new Options(); hf = new HelpFormatter(); opts.addOption("h", "help", false, "Command line arguments help"); opts.addOption("i", "instance name", true, "Name of cresendo instance"); opts.addOption("l", "log dir", true, "Path to log file directory"); opts.addOption("c", "config dir", true, "Path to configuarion file directory"); opts.getOption("l").setRequired(true); opts.getOption("c").setRequired(true); BasicParser parser = new BasicParser(); CommandLine cl = parser.parse(opts, args); // Print out some help and exit // if (cl.hasOption('h')) { hf.printHelp("Options", opts); System.exit(0); } // Set the instance name // if (cl.hasOption('i')) { instanceName = cl.getOptionValue('i'); // Set to something other than "default" } // Setup the message and trace logging objects for the EventEngine // if (cl.hasOption('l')) { // Setup the the paths to the message, trace and status log files // logDir = cl.getOptionValue("l"); logPath = logDir + dirSep + instanceName + "-engine.log"; tracePath = logDir + dirSep + instanceName + "-engine.trace"; statusPath = logDir + dirSep + instanceName + "-engine.status"; } else { // NOTE: This should be picked up by the MissingOptionException catch below // but I couldn't get this to work so I added the following code: // hf.printHelp("Option 'l' is a required option", opts); System.exit(1); } // Read the receiver and engine config files in the config directory // if (cl.hasOption('c')) { // Setup and check path to eif config file for TECAgent receiver object // configDir = cl.getOptionValue("c"); cfgFileReceiver = configDir + dirSep + instanceName + ".conf"; checkConfigFile(cfgFileReceiver); // Setup and check path to xml config file for the EventEngine // cfgFileEngine = cl.getOptionValue("c") + dirSep + instanceName + ".xml"; checkConfigFile(cfgFileEngine); } else { // NOTE: This should be picked up by the MissingOptionException catch below // but I couldn't get this to work so I added the following code: // hf.printHelp("Option 'c' is a required option", opts); System.exit(1); } } catch (UnrecognizedOptionException e) { hf.printHelp(e.toString(), opts); System.exit(1); } catch (MissingOptionException e) { hf.printHelp(e.toString(), opts); System.exit(1); } catch (MissingArgumentException e) { hf.printHelp(e.toString(), opts); System.exit(1); } catch (ParseException e) { e.printStackTrace(); System.exit(1); } catch (Exception e) { System.err.println(e.toString()); System.exit(1); } // Main program // try { // ===================================================================== // Setup the message, trace and status logger objects // try { msgHandler = new FileHandler("cresendo", "message handler", logPath); msgHandler.openDevice(); msgLogger = new MessageLogger("cresendo", "message log"); msgLogger.addHandler(msgHandler); trcHandler = new FileHandler("cresendo", "trace handler", tracePath); trcHandler.openDevice(); trcLogger = new TraceLogger("cresendo", "trace log"); trcLogger.addHandler(trcHandler); statLogger = new StatusLogger(statusPath); } catch (Exception e) { System.err.println(e.toString()); System.exit(1); } // Add the shutdown hook // Runtime.getRuntime().addShutdownHook(new ShutdownThread(msgLogger, instanceName)); // --------------------------------------------------------------------- // ===================================================================== // Load and parse the xml event engine configuration file // // msg.setText("Loading xml engine from: '" + cfgFileEngine + "'"); try { XMLConfiguration xmlProcessor = new XMLConfiguration(); xmlProcessor.setFileName(cfgFileEngine); // Validate the xml against a document type declaration // xmlProcessor.setValidating(true); // Don't interpolate the tag contents by splitting them on a delimiter // (ie by default a comma) // xmlProcessor.setDelimiterParsingDisabled(true); // This will throw a ConfigurationException if the xml document does not // conform to its dtd. By doing this we hopefully catch any errors left // behind after the xml configuration file has been edited. // xmlProcessor.load(); // Setup the trace flag // ConfigurationNode engine = xmlProcessor.getRootNode(); List rootAttribute = engine.getAttributes(); for (Iterator it = rootAttribute.iterator(); it.hasNext();) { ConfigurationNode attr = (ConfigurationNode) it.next(); String attrName = attr.getName(); String attrValue = (String) attr.getValue(); if (attrValue == null || attrValue == "") { System.err.println("\n Error: The value of the attribute '" + attrName + "'" + "\n in the xml file '" + cfgFileEngine + "'" + "\n is not set"); System.exit(1); } if (attrName.matches("trace")) { if (attrValue.matches("true") || attrValue.matches("on")) { trcLogger.setLogging(true); } } if (attrName.matches("status")) { if (attrValue.matches("true") || attrValue.matches("on")) { statLogger.setLogging(true); } else { statLogger.setLogging(false); } } if (attrName.matches("interval")) { if (!attrValue.matches("[0-9]+")) { System.err.println("\n Error: The value of the interval attribute in: '" + cfgFileEngine + "'" + "\n should only contain digits from 0 to 9." + "\n It currently contains: '" + attrValue + "'"); System.exit(1); } statLogger.setInterval(Integer.parseInt(attrValue)); } } // Now build and instantiate the list of classes that will process events // received by the TECAgent receiver in a chain like manner. // List classes = xmlProcessor.configurationsAt("class"); for (Iterator it = classes.iterator(); it.hasNext();) { HierarchicalConfiguration sub = (HierarchicalConfiguration) it.next(); // sub contains now all data contained in a single <class></class> tag set // String className = sub.getString("name"); // Log message // msg.setText(msg.getText() + "\n Instantiated event handler class: '" + className + "'"); // The angle brackets describing the class of object held by the // Vector are implemented by Java 1.5 and have 2 effects. // // 1. The list accepts only elements of that class and nothing else // (Of course thanks to Auto-Wrap you can also add double-values) // // 2. the get(), firstElement() ... Methods don't return a Object, but // they deliver an element of the class. // Vector<Class> optTypes = new Vector<Class>(10, 10); Vector<Object> optValues = new Vector<Object>(10, 10); for (int i = 0; i <= sub.getMaxIndex("option"); i++) { Object optValue = null; String optVarName = sub.getString("option(" + i + ")[@varname]"); String optJavaType = sub.getString("option(" + i + ")[@javatype]"); // Use the specified java type in order to make the method call // to the heirarchical sub object [painful :-((] // if (optJavaType.matches("byte")) { optTypes.addElement(byte.class); optValue = sub.getByte("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = 0; // Set to something nullish } } else if (optJavaType.matches("short")) { optTypes.addElement(byte.class); optValue = sub.getShort("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = 0; // Set to something nullish } } else if (optJavaType.matches("int")) { optTypes.addElement(int.class); optValue = sub.getInt("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = 0; // Set to something nullish } } else if (optJavaType.matches("long")) { optTypes.addElement(long.class); optValue = sub.getLong("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = 0; // Set to something nullish } } else if (optJavaType.matches("float")) { optTypes.addElement(float.class); optValue = sub.getFloat("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = 0.0; // Set to something nullish } } else if (optJavaType.matches("double")) { optTypes.addElement(double.class); optValue = sub.getDouble("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = 0.0; // Set to something nullish } } else if (optJavaType.matches("boolean")) { optTypes.addElement(boolean.class); optValue = sub.getBoolean("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = false; // Set to something nullish } } else if (optJavaType.matches("String")) { optTypes.addElement(String.class); optValue = sub.getString("option(" + i + ")"); if (optValue == null) // Catch nulls { optValue = ""; // Set it to something nullish } } else { System.err.println( "Error: Unsupported java type found in xml config: '" + optJavaType + "'"); System.exit(1); } // Add option value element // // System.out.println("Option value is: '" + optValue.toString() + "'\n"); // optValues.addElement(optValue); // Append to message text // String msgTemp = msg.getText(); msgTemp += "\n option name: '" + optVarName + "'"; msgTemp += "\n option type: '" + optJavaType + "'"; msgTemp += "\n option value: '" + optValues.lastElement().toString() + "'"; msg.setText(msgTemp); } try { // Instantiate the class with the java reflection api // Class klass = Class.forName(className); // Setup an array of paramater types in order to retrieve the matching constructor // Class[] types = optTypes.toArray(new Class[optTypes.size()]); // Get the constructor for the class which matches the parameter types // Constructor konstruct = klass.getConstructor(types); // Create an instance of the event handler // IEventHandler eventProcessor = (IEventHandler) konstruct.newInstance(optValues.toArray()); // Add the instance to the list of event handlers // eventHandler.addElement(eventProcessor); } catch (InvocationTargetException e) { System.err.println("Error: " + e.toString()); System.exit(1); } catch (ClassNotFoundException e) { System.err.println("Error: class name not found: '" + className + "' \n" + e.toString()); System.exit(1); } catch (Exception e) { System.err.println( "Error: failed to instantiate class: '" + className + "' \n" + e.toString()); System.exit(1); } } } catch (ConfigurationException cex) // Something went wrong loading the xml file { System.err.println("\n" + "Error loading XML file: " + cfgFileEngine + "\n" + cex.toString()); System.exit(1); } catch (Exception e) { System.err.println(e.toString()); System.exit(1); } // --------------------------------------------------------------------- // ===================================================================== // Setup the TECAgent receiver // Reader cfgIn = null; try { cfgIn = new FileReader(cfgFileReceiver); } catch (Exception e) { System.err.println(e.toString()); System.exit(1); } // Start the TECAgent receiver and register the event engine handler // TECAgent receiver = new TECAgent(cfgIn, TECAgent.RECEIVER_MODE, false); EventEngine ee = new EventEngine(eventHandler, msgLogger, trcLogger); receiver.registerListener(ee); // Construct message and send it to the message log // String text = "\n Cresendo instance '" + instanceName + "' listening for events on port '" + receiver.getConfigVal("ServerPort") + "'"; msg.setText(msg.getText() + text); msgLogger.log(msg); // Send message to log // --------------------------------------------------------------------- // ===================================================================== // Initiate status logging // if (statLogger.isLogging()) { int seconds = statLogger.getInterval(); while (true) { try { statLogger.log(); } catch (Exception ex) { System.err.println("\n An error occurred while writing to '" + statusPath + "'" + "\n '" + ex.toString() + "'"); } Thread.sleep(seconds * 1000); // Convert sleep time to milliseconds } } // --------------------------------------------------------------------- } catch (Exception e) { System.err.println(e.toString()); System.exit(1); } }
From source file:com.vangent.hieos.empi.config.MatchFieldConfig.java
/** * /*from w ww.j a v a 2 s . co m*/ * @param hc * @param empiConfig * @throws EMPIException */ public void load(HierarchicalConfiguration hc, EMPIConfig empiConfig) throws EMPIException { this.name = hc.getString(NAME); //this.enabledDuringSubjectAdd = hc.getBoolean(ENABLED_DURING_SUBJECT_ADD, true); this.acceptThreshold = hc.getDouble(ACCEPT_THRESHOLD); this.rejectThreshold = hc.getDouble(REJECT_THRESHOLD); this.weight = hc.getDouble(WEIGHT); // Link to distance function configuration. HierarchicalConfiguration hcDistanceFunction = hc.configurationAt(DISTANCE_FUNCTION); String distanceFunctionName = hcDistanceFunction.getString(DISTANCE_FUNCTION_NAME); this.distanceFunctionConfig = this.getDistanceFunctionConfig(empiConfig, hcDistanceFunction, distanceFunctionName); // Link to field configuration. this.fieldConfig = empiConfig.getFieldConfig(this.name); }
From source file:com.vangent.hieos.empi.config.MatchConfig.java
/** * /*w ww.j a va2 s . c o m*/ * @param hc * @param empiConfig * @throws EMPIException */ public void load(HierarchicalConfiguration hc, EMPIConfig empiConfig) throws EMPIException { // Load blocking configuration. blockingConfig = new BlockingConfig(); blockingConfig.load(hc.configurationAt(BLOCKING_CONFIG), empiConfig); this.acceptThreshold = hc.getDouble(ACCEPT_THRESHOLD); this.rejectThreshold = hc.getDouble(REJECT_THRESHOLD); // Get the field-level configuration. List matchFields = hc.configurationsAt(MATCH_FIELDS); for (Iterator it = matchFields.iterator(); it.hasNext();) { HierarchicalConfiguration hcMatchField = (HierarchicalConfiguration) it.next(); MatchFieldConfig matchFieldConfig = new MatchFieldConfig(); matchFieldConfig.load(hcMatchField, empiConfig); // FIXME: Put in map? matchFieldConfigs.add(matchFieldConfig); } }
From source file:com.graphhopper.jsprit.core.problem.io.VrpXMLReader.java
private void readShipments(XMLConfiguration config) { List<HierarchicalConfiguration> shipmentConfigs = config.configurationsAt("shipments.shipment"); for (HierarchicalConfiguration shipmentConfig : shipmentConfigs) { String id = shipmentConfig.getString("[@id]"); if (id == null) throw new IllegalStateException("shipment[@id] is missing."); String capacityString = shipmentConfig.getString("capacity-demand"); boolean capacityDimensionsExist = shipmentConfig.containsKey("capacity-dimensions.dimension(0)"); if (capacityString == null && !capacityDimensionsExist) { throw new IllegalStateException("capacity of shipment is not set. use 'capacity-dimensions'"); }/* w w w . jav a 2 s . c o m*/ if (capacityString != null && capacityDimensionsExist) { throw new IllegalStateException( "either use capacity or capacity-dimension, not both. prefer the use of 'capacity-dimensions' over 'capacity'."); } Shipment.Builder builder; if (capacityString != null) { builder = Shipment.Builder.newInstance(id).addSizeDimension(0, Integer.parseInt(capacityString)); } else { builder = Shipment.Builder.newInstance(id); List<HierarchicalConfiguration> dimensionConfigs = shipmentConfig .configurationsAt("capacity-dimensions.dimension"); for (HierarchicalConfiguration dimension : dimensionConfigs) { Integer index = dimension.getInt("[@index]"); Integer value = dimension.getInt(""); builder.addSizeDimension(index, value); } } //name String name = shipmentConfig.getString("name"); if (name != null) builder.setName(name); //pickup location //pickup-locationId Location.Builder pickupLocationBuilder = Location.Builder.newInstance(); String pickupLocationId = shipmentConfig.getString("pickup.locationId"); if (pickupLocationId == null) pickupLocationId = shipmentConfig.getString("pickup.location.id"); if (pickupLocationId != null) { pickupLocationBuilder.setId(pickupLocationId); } //pickup-coord Coordinate pickupCoord = getCoord(shipmentConfig, "pickup."); if (pickupCoord == null) pickupCoord = getCoord(shipmentConfig, "pickup.location."); if (pickupCoord != null) { pickupLocationBuilder.setCoordinate(pickupCoord); } //pickup.location.index String pickupLocationIndex = shipmentConfig.getString("pickup.location.index"); if (pickupLocationIndex != null) pickupLocationBuilder.setIndex(Integer.parseInt(pickupLocationIndex)); builder.setPickupLocation(pickupLocationBuilder.build()); //pickup-serviceTime String pickupServiceTime = shipmentConfig.getString("pickup.duration"); if (pickupServiceTime != null) builder.setPickupServiceTime(Double.parseDouble(pickupServiceTime)); //pickup-tw List<HierarchicalConfiguration> pickupTWConfigs = shipmentConfig .configurationsAt("pickup.timeWindows.timeWindow"); if (!pickupTWConfigs.isEmpty()) { for (HierarchicalConfiguration pu_twConfig : pickupTWConfigs) { builder.addPickupTimeWindow( TimeWindow.newInstance(pu_twConfig.getDouble("start"), pu_twConfig.getDouble("end"))); } } //delivery location //delivery-locationId Location.Builder deliveryLocationBuilder = Location.Builder.newInstance(); String deliveryLocationId = shipmentConfig.getString("delivery.locationId"); if (deliveryLocationId == null) deliveryLocationId = shipmentConfig.getString("delivery.location.id"); if (deliveryLocationId != null) { deliveryLocationBuilder.setId(deliveryLocationId); // builder.setDeliveryLocationId(deliveryLocationId); } //delivery-coord Coordinate deliveryCoord = getCoord(shipmentConfig, "delivery."); if (deliveryCoord == null) deliveryCoord = getCoord(shipmentConfig, "delivery.location."); if (deliveryCoord != null) { deliveryLocationBuilder.setCoordinate(deliveryCoord); } String deliveryLocationIndex = shipmentConfig.getString("delivery.location.index"); if (deliveryLocationIndex != null) deliveryLocationBuilder.setIndex(Integer.parseInt(deliveryLocationIndex)); builder.setDeliveryLocation(deliveryLocationBuilder.build()); //delivery-serviceTime String deliveryServiceTime = shipmentConfig.getString("delivery.duration"); if (deliveryServiceTime != null) builder.setDeliveryServiceTime(Double.parseDouble(deliveryServiceTime)); //delivery-tw List<HierarchicalConfiguration> deliveryTWConfigs = shipmentConfig .configurationsAt("delivery.timeWindows.timeWindow"); if (!deliveryTWConfigs.isEmpty()) { for (HierarchicalConfiguration dl_twConfig : deliveryTWConfigs) { builder.addDeliveryTimeWindow( TimeWindow.newInstance(dl_twConfig.getDouble("start"), dl_twConfig.getDouble("end"))); } } //read skills String skillString = shipmentConfig.getString("requiredSkills"); if (skillString != null) { String cleaned = skillString.replaceAll("\\s", ""); String[] skillTokens = cleaned.split("[,;]"); for (String skill : skillTokens) builder.addRequiredSkill(skill.toLowerCase()); } //build shipment Shipment shipment = builder.build(); // vrpBuilder.addJob(shipment); shipmentMap.put(shipment.getId(), shipment); } }
From source file:com.graphhopper.jsprit.io.problem.VrpXMLReader.java
private void readShipments(XMLConfiguration config) { List<HierarchicalConfiguration> shipmentConfigs = config.configurationsAt("shipments.shipment"); for (HierarchicalConfiguration shipmentConfig : shipmentConfigs) { String id = shipmentConfig.getString("[@id]"); if (id == null) throw new IllegalArgumentException("shipment[@id] is missing."); String capacityString = shipmentConfig.getString("capacity-demand"); boolean capacityDimensionsExist = shipmentConfig.containsKey("capacity-dimensions.dimension(0)"); if (capacityString == null && !capacityDimensionsExist) { throw new IllegalArgumentException("capacity of shipment is not set. use 'capacity-dimensions'"); }//from ww w . j a v a 2 s .c o m if (capacityString != null && capacityDimensionsExist) { throw new IllegalArgumentException( "either use capacity or capacity-dimension, not both. prefer the use of 'capacity-dimensions' over 'capacity'."); } Shipment.Builder builder; if (capacityString != null) { builder = Shipment.Builder.newInstance(id).addSizeDimension(0, Integer.parseInt(capacityString)); } else { builder = Shipment.Builder.newInstance(id); List<HierarchicalConfiguration> dimensionConfigs = shipmentConfig .configurationsAt("capacity-dimensions.dimension"); for (HierarchicalConfiguration dimension : dimensionConfigs) { Integer index = dimension.getInt("[@index]"); Integer value = dimension.getInt(""); builder.addSizeDimension(index, value); } } //name String name = shipmentConfig.getString("name"); if (name != null) builder.setName(name); //pickup location //pickup-locationId Location.Builder pickupLocationBuilder = Location.Builder.newInstance(); String pickupLocationId = shipmentConfig.getString("pickup.locationId"); if (pickupLocationId == null) pickupLocationId = shipmentConfig.getString("pickup.location.id"); if (pickupLocationId != null) { pickupLocationBuilder.setId(pickupLocationId); } //pickup-coord Coordinate pickupCoord = getCoord(shipmentConfig, "pickup."); if (pickupCoord == null) pickupCoord = getCoord(shipmentConfig, "pickup.location."); if (pickupCoord != null) { pickupLocationBuilder.setCoordinate(pickupCoord); } //pickup.location.index String pickupLocationIndex = shipmentConfig.getString("pickup.location.index"); if (pickupLocationIndex != null) pickupLocationBuilder.setIndex(Integer.parseInt(pickupLocationIndex)); builder.setPickupLocation(pickupLocationBuilder.build()); //pickup-serviceTime String pickupServiceTime = shipmentConfig.getString("pickup.duration"); if (pickupServiceTime != null) builder.setPickupServiceTime(Double.parseDouble(pickupServiceTime)); //pickup-tw List<HierarchicalConfiguration> pickupTWConfigs = shipmentConfig .configurationsAt("pickup.timeWindows.timeWindow"); if (!pickupTWConfigs.isEmpty()) { for (HierarchicalConfiguration pu_twConfig : pickupTWConfigs) { builder.addPickupTimeWindow( TimeWindow.newInstance(pu_twConfig.getDouble("start"), pu_twConfig.getDouble("end"))); } } //delivery location //delivery-locationId Location.Builder deliveryLocationBuilder = Location.Builder.newInstance(); String deliveryLocationId = shipmentConfig.getString("delivery.locationId"); if (deliveryLocationId == null) deliveryLocationId = shipmentConfig.getString("delivery.location.id"); if (deliveryLocationId != null) { deliveryLocationBuilder.setId(deliveryLocationId); // builder.setDeliveryLocationId(deliveryLocationId); } //delivery-coord Coordinate deliveryCoord = getCoord(shipmentConfig, "delivery."); if (deliveryCoord == null) deliveryCoord = getCoord(shipmentConfig, "delivery.location."); if (deliveryCoord != null) { deliveryLocationBuilder.setCoordinate(deliveryCoord); } String deliveryLocationIndex = shipmentConfig.getString("delivery.location.index"); if (deliveryLocationIndex != null) deliveryLocationBuilder.setIndex(Integer.parseInt(deliveryLocationIndex)); builder.setDeliveryLocation(deliveryLocationBuilder.build()); //delivery-serviceTime String deliveryServiceTime = shipmentConfig.getString("delivery.duration"); if (deliveryServiceTime != null) builder.setDeliveryServiceTime(Double.parseDouble(deliveryServiceTime)); //delivery-tw List<HierarchicalConfiguration> deliveryTWConfigs = shipmentConfig .configurationsAt("delivery.timeWindows.timeWindow"); if (!deliveryTWConfigs.isEmpty()) { for (HierarchicalConfiguration dl_twConfig : deliveryTWConfigs) { builder.addDeliveryTimeWindow( TimeWindow.newInstance(dl_twConfig.getDouble("start"), dl_twConfig.getDouble("end"))); } } //read skills String skillString = shipmentConfig.getString("requiredSkills"); if (skillString != null) { String cleaned = skillString.replaceAll("\\s", ""); String[] skillTokens = cleaned.split("[,;]"); for (String skill : skillTokens) builder.addRequiredSkill(skill.toLowerCase()); } //build shipment Shipment shipment = builder.build(); // vrpBuilder.addJob(shipment); shipmentMap.put(shipment.getId(), shipment); } }
From source file:com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.java
private static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads, final SolutionCostCalculator solutionCostCalculator, final StateManager stateManager, ConstraintManager constraintManager, boolean addDefaultCostCalculators) { // map to store constructed modules TypedMap definedClasses = new TypedMap(); // algorithm listeners Set<PrioritizedVRAListener> algorithmListeners = new HashSet<PrioritizedVRAListener>(); // insertion listeners List<InsertionListener> insertionListeners = new ArrayList<InsertionListener>(); //threading//from w w w .j ava 2 s . co m final ExecutorService executorService; if (nuOfThreads > 0) { log.debug("setup executor-service with " + nuOfThreads + " threads"); executorService = Executors.newFixedThreadPool(nuOfThreads); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, new AlgorithmEndsListener() { @Override public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { log.debug("shutdown executor-service"); executorService.shutdown(); } })); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread arg0, Throwable arg1) { System.err.println(arg1.toString()); } }); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (!executorService.isShutdown()) { System.err.println("shutdowHook shuts down executorService"); executorService.shutdown(); } } }); } else executorService = null; //create fleetmanager final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp); String switchString = config.getString("construction.insertion.allowVehicleSwitch"); final boolean switchAllowed; if (switchString != null) { switchAllowed = Boolean.parseBoolean(switchString); } else switchAllowed = true; ActivityTimeTracker.ActivityPolicy activityPolicy; if (stateManager.timeWindowUpdateIsActivated()) { UpdateVehicleDependentPracticalTimeWindows timeWindowUpdater = new UpdateVehicleDependentPracticalTimeWindows( stateManager, vrp.getTransportCosts(), vrp.getActivityCosts()); timeWindowUpdater .setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() { Map<VehicleTypeKey, Vehicle> uniqueTypes = new HashMap<VehicleTypeKey, Vehicle>(); @Override public Collection<Vehicle> get(VehicleRoute vehicleRoute) { if (uniqueTypes.isEmpty()) { for (Vehicle v : vrp.getVehicles()) { if (!uniqueTypes.containsKey(v.getVehicleTypeIdentifier())) { uniqueTypes.put(v.getVehicleTypeIdentifier(), v); } } } Collection<Vehicle> vehicles = new ArrayList<Vehicle>(); vehicles.addAll(uniqueTypes.values()); return vehicles; } }); stateManager.addStateUpdater(timeWindowUpdater); activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS; } else { activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_ARRIVED; } stateManager.addStateUpdater( new UpdateActivityTimes(vrp.getTransportCosts(), activityPolicy, vrp.getActivityCosts())); stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager, activityPolicy)); final SolutionCostCalculator costCalculator; if (solutionCostCalculator == null) costCalculator = getDefaultCostCalculator(stateManager); else costCalculator = solutionCostCalculator; PrettyAlgorithmBuilder prettyAlgorithmBuilder = PrettyAlgorithmBuilder.newInstance(vrp, vehicleFleetManager, stateManager, constraintManager); //construct initial solution creator final InsertionStrategy initialInsertionStrategy = createInitialSolution(config, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, costCalculator, constraintManager, addDefaultCostCalculators); if (initialInsertionStrategy != null) prettyAlgorithmBuilder.constructInitialSolutionWith(initialInsertionStrategy, costCalculator); //construct algorithm, i.e. search-strategies and its modules int solutionMemory = config.getInt("strategy.memory"); List<HierarchicalConfiguration> strategyConfigs = config .configurationsAt("strategy.searchStrategies.searchStrategy"); for (HierarchicalConfiguration strategyConfig : strategyConfigs) { String name = getName(strategyConfig); SolutionAcceptor acceptor = getAcceptor(strategyConfig, vrp, algorithmListeners, definedClasses, solutionMemory); SolutionSelector selector = getSelector(strategyConfig, vrp, algorithmListeners, definedClasses); SearchStrategy strategy = new SearchStrategy(name, selector, acceptor, costCalculator); strategy.setName(name); List<HierarchicalConfiguration> modulesConfig = strategyConfig.configurationsAt("modules.module"); for (HierarchicalConfiguration moduleConfig : modulesConfig) { SearchStrategyModule module = buildModule(moduleConfig, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, constraintManager, addDefaultCostCalculators); strategy.addModule(module); } prettyAlgorithmBuilder.withStrategy(strategy, strategyConfig.getDouble("probability")); } //construct algorithm VehicleRoutingAlgorithm metaAlgorithm = prettyAlgorithmBuilder.build(); int maxIterations = getMaxIterations(config); if (maxIterations > -1) metaAlgorithm.setMaxIterations(maxIterations); //define prematureBreak PrematureAlgorithmTermination prematureAlgorithmTermination = getPrematureTermination(config, algorithmListeners); if (prematureAlgorithmTermination != null) metaAlgorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination); else { List<HierarchicalConfiguration> terminationCriteria = config .configurationsAt("terminationCriteria.termination"); for (HierarchicalConfiguration terminationConfig : terminationCriteria) { PrematureAlgorithmTermination termination = getTerminationCriterion(terminationConfig, algorithmListeners); if (termination != null) metaAlgorithm.addTerminationCriterion(termination); } } for (PrioritizedVRAListener l : algorithmListeners) { metaAlgorithm.getAlgorithmListeners().add(l); } return metaAlgorithm; }
From source file:jsprit.core.algorithm.io.VehicleRoutingAlgorithms.java
private static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads, final SolutionCostCalculator solutionCostCalculator, final StateManager stateManager, ConstraintManager constraintManager, boolean addDefaultCostCalculators) { // map to store constructed modules TypedMap definedClasses = new TypedMap(); // algorithm listeners Set<PrioritizedVRAListener> algorithmListeners = new HashSet<PrioritizedVRAListener>(); // insertion listeners List<InsertionListener> insertionListeners = new ArrayList<InsertionListener>(); //threading/*from w w w. j a v a 2 s.c o m*/ final ExecutorService executorService; if (nuOfThreads > 0) { log.debug("setup executor-service with " + nuOfThreads + " threads"); executorService = Executors.newFixedThreadPool(nuOfThreads); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, new AlgorithmEndsListener() { @Override public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { log.debug("shutdown executor-service"); executorService.shutdown(); } })); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread arg0, Throwable arg1) { System.err.println(arg1.toString()); } }); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (!executorService.isShutdown()) { System.err.println("shutdowHook shuts down executorService"); executorService.shutdown(); } } }); } else executorService = null; //create fleetmanager final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp); String switchString = config.getString("construction.insertion.allowVehicleSwitch"); final boolean switchAllowed; if (switchString != null) { switchAllowed = Boolean.parseBoolean(switchString); } else switchAllowed = true; ActivityTimeTracker.ActivityPolicy activityPolicy; if (stateManager.timeWindowUpdateIsActivated()) { UpdateVehicleDependentPracticalTimeWindows timeWindowUpdater = new UpdateVehicleDependentPracticalTimeWindows( stateManager, vrp.getTransportCosts()); timeWindowUpdater .setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() { Map<VehicleTypeKey, Vehicle> uniqueTypes = new HashMap<VehicleTypeKey, Vehicle>(); @Override public Collection<Vehicle> get(VehicleRoute vehicleRoute) { if (uniqueTypes.isEmpty()) { for (Vehicle v : vrp.getVehicles()) { if (!uniqueTypes.containsKey(v.getVehicleTypeIdentifier())) { uniqueTypes.put(v.getVehicleTypeIdentifier(), v); } } } Collection<Vehicle> vehicles = new ArrayList<Vehicle>(); vehicles.addAll(uniqueTypes.values()); return vehicles; } }); stateManager.addStateUpdater(timeWindowUpdater); activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS; } else { activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_ARRIVED; } stateManager.addStateUpdater(new UpdateActivityTimes(vrp.getTransportCosts(), activityPolicy)); stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager, activityPolicy)); final SolutionCostCalculator costCalculator; if (solutionCostCalculator == null) costCalculator = getDefaultCostCalculator(stateManager); else costCalculator = solutionCostCalculator; PrettyAlgorithmBuilder prettyAlgorithmBuilder = PrettyAlgorithmBuilder.newInstance(vrp, vehicleFleetManager, stateManager, constraintManager); //construct initial solution creator final InsertionStrategy initialInsertionStrategy = createInitialSolution(config, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, costCalculator, constraintManager, addDefaultCostCalculators); if (initialInsertionStrategy != null) prettyAlgorithmBuilder.constructInitialSolutionWith(initialInsertionStrategy, costCalculator); //construct algorithm, i.e. search-strategies and its modules int solutionMemory = config.getInt("strategy.memory"); List<HierarchicalConfiguration> strategyConfigs = config .configurationsAt("strategy.searchStrategies.searchStrategy"); for (HierarchicalConfiguration strategyConfig : strategyConfigs) { String name = getName(strategyConfig); SolutionAcceptor acceptor = getAcceptor(strategyConfig, vrp, algorithmListeners, definedClasses, solutionMemory); SolutionSelector selector = getSelector(strategyConfig, vrp, algorithmListeners, definedClasses); SearchStrategy strategy = new SearchStrategy(name, selector, acceptor, costCalculator); strategy.setName(name); List<HierarchicalConfiguration> modulesConfig = strategyConfig.configurationsAt("modules.module"); for (HierarchicalConfiguration moduleConfig : modulesConfig) { SearchStrategyModule module = buildModule(moduleConfig, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, constraintManager, addDefaultCostCalculators); strategy.addModule(module); } prettyAlgorithmBuilder.withStrategy(strategy, strategyConfig.getDouble("probability")); } //construct algorithm VehicleRoutingAlgorithm metaAlgorithm = prettyAlgorithmBuilder.build(); int maxIterations = getMaxIterations(config); if (maxIterations > -1) metaAlgorithm.setMaxIterations(maxIterations); //define prematureBreak PrematureAlgorithmTermination prematureAlgorithmTermination = getPrematureTermination(config, algorithmListeners); if (prematureAlgorithmTermination != null) metaAlgorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination); else { List<HierarchicalConfiguration> terminationCriteria = config .configurationsAt("terminationCriteria.termination"); for (HierarchicalConfiguration terminationConfig : terminationCriteria) { PrematureAlgorithmTermination termination = getTerminationCriterion(terminationConfig, algorithmListeners); if (termination != null) metaAlgorithm.addTerminationCriterion(termination); } } for (PrioritizedVRAListener l : algorithmListeners) { metaAlgorithm.getAlgorithmListeners().add(l); } return metaAlgorithm; }
From source file:com.graphhopper.jsprit.io.algorithm.VehicleRoutingAlgorithms.java
private static VehicleRoutingAlgorithm readAndCreateAlgorithm(final VehicleRoutingProblem vrp, XMLConfiguration config, int nuOfThreads, final SolutionCostCalculator solutionCostCalculator, final StateManager stateManager, ConstraintManager constraintManager, boolean addDefaultCostCalculators, boolean addCoreConstraints) { // map to store constructed modules TypedMap definedClasses = new TypedMap(); // algorithm listeners Set<PrioritizedVRAListener> algorithmListeners = new HashSet<PrioritizedVRAListener>(); // insertion listeners List<InsertionListener> insertionListeners = new ArrayList<InsertionListener>(); //threading/*w w w . j ava 2s . com*/ final ExecutorService executorService; if (nuOfThreads > 0) { log.debug("setup executor-service with " + nuOfThreads + " threads"); executorService = Executors.newFixedThreadPool(nuOfThreads); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, new AlgorithmEndsListener() { @Override public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { log.debug("shutdown executor-service"); executorService.shutdown(); } })); Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { @Override public void uncaughtException(Thread arg0, Throwable arg1) { System.err.println(arg1.toString()); } }); Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { if (!executorService.isShutdown()) { System.err.println("shutdowHook shuts down executorService"); executorService.shutdown(); } } }); } else executorService = null; //create fleetmanager final VehicleFleetManager vehicleFleetManager = createFleetManager(vrp); String switchString = config.getString("construction.insertion.allowVehicleSwitch"); final boolean switchAllowed; if (switchString != null) { switchAllowed = Boolean.parseBoolean(switchString); } else switchAllowed = true; ActivityTimeTracker.ActivityPolicy activityPolicy; if (stateManager.timeWindowUpdateIsActivated()) { UpdateVehicleDependentPracticalTimeWindows timeWindowUpdater = new UpdateVehicleDependentPracticalTimeWindows( stateManager, vrp.getTransportCosts(), vrp.getActivityCosts()); timeWindowUpdater .setVehiclesToUpdate(new UpdateVehicleDependentPracticalTimeWindows.VehiclesToUpdate() { Map<VehicleTypeKey, Vehicle> uniqueTypes = new HashMap<VehicleTypeKey, Vehicle>(); @Override public Collection<Vehicle> get(VehicleRoute vehicleRoute) { if (uniqueTypes.isEmpty()) { for (Vehicle v : vrp.getVehicles()) { if (!uniqueTypes.containsKey(v.getVehicleTypeIdentifier())) { uniqueTypes.put(v.getVehicleTypeIdentifier(), v); } } } Collection<Vehicle> vehicles = new ArrayList<Vehicle>(); vehicles.addAll(uniqueTypes.values()); return vehicles; } }); stateManager.addStateUpdater(timeWindowUpdater); activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_TIME_WINDOW_OPENS; } else { activityPolicy = ActivityTimeTracker.ActivityPolicy.AS_SOON_AS_ARRIVED; } stateManager.addStateUpdater( new UpdateActivityTimes(vrp.getTransportCosts(), activityPolicy, vrp.getActivityCosts())); stateManager.addStateUpdater(new UpdateVariableCosts(vrp.getActivityCosts(), vrp.getTransportCosts(), stateManager, activityPolicy)); final SolutionCostCalculator costCalculator; if (solutionCostCalculator == null) costCalculator = getDefaultCostCalculator(stateManager); else costCalculator = solutionCostCalculator; PrettyAlgorithmBuilder prettyAlgorithmBuilder = PrettyAlgorithmBuilder.newInstance(vrp, vehicleFleetManager, stateManager, constraintManager); if (addCoreConstraints) prettyAlgorithmBuilder.addCoreStateAndConstraintStuff(); //construct initial solution creator final InsertionStrategy initialInsertionStrategy = createInitialSolution(config, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, costCalculator, constraintManager, addDefaultCostCalculators); if (initialInsertionStrategy != null) prettyAlgorithmBuilder.constructInitialSolutionWith(initialInsertionStrategy, costCalculator); //construct algorithm, i.e. search-strategies and its modules int solutionMemory = config.getInt("strategy.memory"); List<HierarchicalConfiguration> strategyConfigs = config .configurationsAt("strategy.searchStrategies.searchStrategy"); for (HierarchicalConfiguration strategyConfig : strategyConfigs) { String name = getName(strategyConfig); SolutionAcceptor acceptor = getAcceptor(strategyConfig, vrp, algorithmListeners, definedClasses, solutionMemory); SolutionSelector selector = getSelector(strategyConfig, vrp, algorithmListeners, definedClasses); SearchStrategy strategy = new SearchStrategy(name, selector, acceptor, costCalculator); strategy.setName(name); List<HierarchicalConfiguration> modulesConfig = strategyConfig.configurationsAt("modules.module"); for (HierarchicalConfiguration moduleConfig : modulesConfig) { SearchStrategyModule module = buildModule(moduleConfig, vrp, vehicleFleetManager, stateManager, algorithmListeners, definedClasses, executorService, nuOfThreads, constraintManager, addDefaultCostCalculators); strategy.addModule(module); } prettyAlgorithmBuilder.withStrategy(strategy, strategyConfig.getDouble("probability")); } //construct algorithm VehicleRoutingAlgorithm metaAlgorithm = prettyAlgorithmBuilder.build(); int maxIterations = getMaxIterations(config); if (maxIterations > -1) metaAlgorithm.setMaxIterations(maxIterations); //define prematureBreak PrematureAlgorithmTermination prematureAlgorithmTermination = getPrematureTermination(config, algorithmListeners); if (prematureAlgorithmTermination != null) metaAlgorithm.setPrematureAlgorithmTermination(prematureAlgorithmTermination); else { List<HierarchicalConfiguration> terminationCriteria = config .configurationsAt("terminationCriteria.termination"); for (HierarchicalConfiguration terminationConfig : terminationCriteria) { PrematureAlgorithmTermination termination = getTerminationCriterion(terminationConfig, algorithmListeners); if (termination != null) metaAlgorithm.addTerminationCriterion(termination); } } for (PrioritizedVRAListener l : algorithmListeners) { metaAlgorithm.getAlgorithmListeners().add(l); } return metaAlgorithm; }
From source file:com.graphhopper.jsprit.core.algorithm.io.VehicleRoutingAlgorithms.java
private static SolutionAcceptor getAcceptor(HierarchicalConfiguration strategyConfig, VehicleRoutingProblem vrp, Set<PrioritizedVRAListener> algorithmListeners, TypedMap typedMap, int solutionMemory) { String acceptorName = strategyConfig.getString("acceptor[@name]"); if (acceptorName == null) throw new IllegalStateException("no solution acceptor is defined"); String acceptorId = strategyConfig.getString("acceptor[@id]"); if (acceptorId == null) acceptorId = "noId"; AcceptorKey acceptorKey = new AcceptorKey(makeKey(acceptorName, acceptorId)); SolutionAcceptor definedAcceptor = typedMap.get(acceptorKey); if (definedAcceptor != null) return definedAcceptor; if (acceptorName.equals("acceptNewRemoveWorst")) { GreedyAcceptance acceptor = new GreedyAcceptance(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; }// w w w . j a v a 2 s . c o m if (acceptorName.equals("acceptNewRemoveFirst")) { AcceptNewRemoveFirst acceptor = new AcceptNewRemoveFirst(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; } if (acceptorName.equals("greedyAcceptance")) { GreedyAcceptance acceptor = new GreedyAcceptance(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; } if (acceptorName.equals("schrimpfAcceptance")) { String nuWarmupIterations = strategyConfig.getString("acceptor.warmup"); double alpha = strategyConfig.getDouble("acceptor.alpha"); SchrimpfAcceptance schrimpf = new SchrimpfAcceptance(solutionMemory, alpha); if (nuWarmupIterations != null) { SchrimpfInitialThresholdGenerator iniThresholdGenerator = new SchrimpfInitialThresholdGenerator( schrimpf, Integer.parseInt(nuWarmupIterations)); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, iniThresholdGenerator)); } else { double threshold = strategyConfig.getDouble("acceptor.initialThreshold"); schrimpf.setInitialThreshold(threshold); } algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, schrimpf)); typedMap.put(acceptorKey, schrimpf); return schrimpf; } if (acceptorName.equals("experimentalSchrimpfAcceptance")) { int iterOfSchrimpf = strategyConfig.getInt("acceptor.warmup"); double alpha = strategyConfig.getDouble("acceptor.alpha"); ExperimentalSchrimpfAcceptance schrimpf = new ExperimentalSchrimpfAcceptance(solutionMemory, alpha, iterOfSchrimpf); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, schrimpf)); typedMap.put(acceptorKey, schrimpf); return schrimpf; } else { throw new IllegalStateException("solution acceptor " + acceptorName + " is not known"); } }
From source file:jsprit.core.algorithm.io.VehicleRoutingAlgorithms.java
private static SolutionAcceptor getAcceptor(HierarchicalConfiguration strategyConfig, VehicleRoutingProblem vrp, Set<PrioritizedVRAListener> algorithmListeners, TypedMap typedMap, int solutionMemory) { String acceptorName = strategyConfig.getString("acceptor[@name]"); if (acceptorName == null) throw new IllegalStateException("no solution acceptor is defined"); String acceptorId = strategyConfig.getString("acceptor[@id]"); if (acceptorId == null) acceptorId = "noId"; AcceptorKey acceptorKey = new AcceptorKey(makeKey(acceptorName, acceptorId)); SolutionAcceptor definedAcceptor = typedMap.get(acceptorKey); if (definedAcceptor != null) return definedAcceptor; if (acceptorName.equals("acceptNewRemoveWorst")) { GreedyAcceptance acceptor = new GreedyAcceptance(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; }/*from w w w . j a va 2s . co m*/ if (acceptorName.equals("acceptNewRemoveFirst")) { AcceptNewRemoveFirst acceptor = new AcceptNewRemoveFirst(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; } if (acceptorName.equals("greedyAcceptance")) { GreedyAcceptance acceptor = new GreedyAcceptance(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; } if (acceptorName.equals("greedyAcceptance_minVehFirst")) { GreedyAcceptance_minVehFirst acceptor = new GreedyAcceptance_minVehFirst(solutionMemory); typedMap.put(acceptorKey, acceptor); return acceptor; } if (acceptorName.equals("schrimpfAcceptance")) { String nuWarmupIterations = strategyConfig.getString("acceptor.warmup"); double alpha = strategyConfig.getDouble("acceptor.alpha"); SchrimpfAcceptance schrimpf = new SchrimpfAcceptance(solutionMemory, alpha); if (nuWarmupIterations != null) { SchrimpfInitialThresholdGenerator iniThresholdGenerator = new SchrimpfInitialThresholdGenerator( schrimpf, Integer.parseInt(nuWarmupIterations)); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, iniThresholdGenerator)); } else { double threshold = strategyConfig.getDouble("acceptor.initialThreshold"); schrimpf.setInitialThreshold(threshold); } algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, schrimpf)); typedMap.put(acceptorKey, schrimpf); return schrimpf; } if (acceptorName.equals("experimentalSchrimpfAcceptance")) { int iterOfSchrimpf = strategyConfig.getInt("acceptor.warmup"); double alpha = strategyConfig.getDouble("acceptor.alpha"); ExperimentalSchrimpfAcceptance schrimpf = new ExperimentalSchrimpfAcceptance(solutionMemory, alpha, iterOfSchrimpf); algorithmListeners.add(new PrioritizedVRAListener(Priority.LOW, schrimpf)); typedMap.put(acceptorKey, schrimpf); return schrimpf; } else { throw new IllegalStateException("solution acceptor " + acceptorName + " is not known"); } }