/** * Executes the operation * * @param object An object containing an array of two solutions * @return An object containing an array with the offSprings * @throws JMException */ public Object execute(Object object) throws JMException { Solution[] parents = (Solution[]) object; Double crossoverProbability; // if ((parents[0].getType() != SolutionType_.Permutation) || // (parents[1].getType() != SolutionType_.Permutation)) { // // Configuration.logger_.severe("TwoPointsCrossover.execute: the solutions " + // "are not of the right type. The type should be 'Permutation', but " + // parents[0].getType() + " and " + // parents[1].getType() + " are obtained"); // } // if crossoverProbability = (Double) getParameter("probability"); if (parents.length < 2) { Configuration.logger_.severe("SBXCrossover.execute: operator needs two " + "parents"); Class cls = java.lang.String.class; String name = cls.getName(); throw new JMException("Exception in " + name + ".execute()"); } else if (crossoverProbability == null) { Configuration.logger_.severe("SBXCrossover.execute: probability not " + "specified"); Class cls = java.lang.String.class; String name = cls.getName(); throw new JMException("Exception in " + name + ".execute()"); } Solution[] offspring = doCrossover(crossoverProbability.doubleValue(), parents[0], parents[1]); return offspring; } // execute
/** * Obtains an instance of a <code>Variable</code> given its name. * * @param name The name of the class from which we want to obtain an instance object * @throws JMException */ public static Variable getVariable(String name) throws JMException { Variable variable = null; String baseLocation = "jmetal.base.variable."; try { Class c = Class.forName(baseLocation + name); variable = (Variable) c.newInstance(); return variable; } catch (ClassNotFoundException e1) { Configuration.logger_.severe("VariableFactory.getVariable: " + "ClassNotFoundException "); Class cls = java.lang.String.class; String name2 = cls.getName(); throw new JMException("Exception in " + name2 + ".getVariable()"); } catch (InstantiationException e2) { Configuration.logger_.severe("VariableFactory.getVariable: " + "InstantiationException "); Class cls = java.lang.String.class; String name2 = cls.getName(); throw new JMException("Exception in " + name2 + ".getVariable()"); } catch (IllegalAccessException e3) { Configuration.logger_.severe("VariableFactory.getVariable: " + "IllegalAccessException "); Class cls = java.lang.String.class; String name2 = cls.getName(); throw new JMException("Exception in " + name2 + ".getVariable()"); } } // getVariable