Hi,
I'm new here, I'm developing new KNIME nods which implements different metaheuristic methods of optimalization (TS, SA, EA etc.).
For different problem type (TSP, Function optimization, SAT) node require some problem-specific class to be loaded (representation of Solution, EvaluationFunction etc.)
As for now user can change problem type through node's configuration Dialog:
addDialogComponent(new DialogComponentStringSelection(
new SettingsModelString(
TabuSearchNodeModel.CFGKEY_PROBLEM_TYPE,
TabuSearchNodeModel.DEFAULT_PROBLEM_TYPE),
"Problem type: ", "TSP","FunctionOptimization","SAT"));
in Model this option is specified by this:
private final SettingsModelString m_problem_type = new SettingsModelString(
TabuSearchNodeModel.CFGKEY_PROBLEM_TYPE,
Then, in Model, in config() method I'm trying to load problem-specific classes depending on different option:
_evaluationFunction=ProblemManager.getProblemSpecificEvaluationFunction(m_problem_type.getStringValue());
ProblemManager method is quite plain and simple:
public static EvaluationFunction getProblemSpecificEvaluationFunction(String problemName) throws InstantiationException, IllegalAccessException{
Class creator = null;
try {
creator = Class.forName("pl.wroc.pwr.metaheuristic.evaluationfunction."+problemName+"EvalFunction");
} catch (ClassNotFoundException e) {
logger.error("ClassNotFoundException during loading problem-specific classes (implementation of EvaluationFunction)");
e.printStackTrace();
}
return (EvaluationFunction) creator.newInstance();
}
But as You can see it's not that neat solution - options' name in Dialog doesn't look too user-friendly ("FunctionOptimization", "RandomInitialSolution") and few others things could be programmed better.
So my question is - is there any way to obtain information on chosen option,which is DialogComponentStringSelection,
than using it's getStringValue? Can I get access to index of chosen option in Model class? I looked up KNIME API but I couldn't find any help concerning this aspect.
Maybe there is more neat way to load those classes? Should it be done in config() section of Model class as it is right now, or should it be done somewhere else?
Thank You in advance for any help