Этот вопрос является продолжением Implementing a SolutionIO Interface for Benchmarking.Конфигурация Benchmark - Ошибка: PlanningProblem (null) не может быть пустым
Вкратце, я работаю над проблемой, подобной проблеме NurseRostering от OptaPlanner. В настоящее время мне нужно реализовать контрольный показатель, где я столкнулся с ошибкой из приведенной выше ссылки.
Теперь эта ошибка была решена, и я получаю сообщение об ошибке The planningProblem (null) must not be null.
Исходя из этого, я считаю, что мой solution
не читается правильно, и мне нужно внести некоторые изменения. Я сделал некоторые исследования, сделал много отладки, не повезло найти то, что мне нужно сделать.
Ниже приведены все конфиги, классы и интерфейсы, которые я модифицировал:
CustomBenchmarkIO:
public class CustomBenchmarkIO<Solution_> implements SolutionFileIO<Solution_>{
public String getInputFileExtension() {
return null;
}
public String getOutputFileExtension() {
return null;
}
public Solution_ read(File inputSolutionFile) {
return null;
}
@Override
public void write(Solution_ solution, File outputSolutionFile) {
}
}
Note:<Solution_> is what i currently have, i tried both <Solution> and <Solution_> , both didn't work.
NurseRosterBenchmarkApp:
public static void main(String[] args) {
new NurseRosteringBenchmarkApp().buildAndBenchmark(args);
}
public NurseRosteringBenchmarkApp() {
super(
new ArgOption("name",
"org/optaplanner/examples/nurserostering/benchmark/BenchmarkConfig.xml"));
}
Note: This is the default NurseRosterBenchmarkApp.
NurseRosterConsoleApp - У меня есть настроен NurseRosteringApp для запуска только с консоли.
public class NurseRosterConsoleApp extends CommonApp{
protected NurseRosterConsoleApp(String name, String description, String solverConfig, String iconResource) {
super(name, description, solverConfig, iconResource);
// TODO Auto-generated constructor stub
}
// function for reading the solution from a file
public static Solution readSolution(File inputFile, boolean inputXmlType) {
// reading from a solution xml file
if (inputXmlType) {
return (Solution) new NurseRosteringDao().readSolution(inputFile);
} else {
Solution solution;
InputStream in = null;
try {
in = new FileInputStream(inputFile);
SAXBuilder builder = new SAXBuilder(false);
Document document = builder.build(in);
XmlInputBuilder xmlInputBuilder = new NurseRosteringImporter.NurseRosteringInputBuilder();
xmlInputBuilder.setInputFile(inputFile);
xmlInputBuilder.setDocument(document);
try {
solution = (Solution) xmlInputBuilder.readSolution();
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("Exception in inputFile (" + inputFile + ")", e);
} catch (IllegalStateException e) {
throw new IllegalStateException("Exception in inputFile (" + inputFile + ")", e);
}
} catch (IOException e) {
throw new IllegalArgumentException("Could not read the file (" + inputFile.getName() + ").", e);
} catch (JDOMException e) {
throw new IllegalArgumentException("Could not parse the XML file (" + inputFile.getName() + ").", e);
} finally {
IOUtils.closeQuietly(in);
}
return solution;
}
}
public static void main(String[] args) {
File inputXml = new File(Settings.inputFilePath);
SolverFactory solverFactory = SolverFactory.createFromXmlResource(Settings.SOLVER_CONFIG);
Solver solver = solverFactory.buildSolver();
Solution unsolvedNurseRoster = readSolution(inputXml, Settings.inputXmlType);
NurseRoster nurseRoster = (NurseRoster) unsolvedNurseRoster;
solver.solve(unsolvedNurseRoster);
NurseRoster solvedNurseRoster = (NurseRoster) solver.getBestSolution();
try {
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected AbstractSolutionExporter createSolutionExporter() {
return new NurseRosteringExporter();
}
@Override
protected SolutionDao createSolutionDao() {
// TODO Auto-generated method stub
return null;
}
@Override
protected SolutionPanel createSolutionPanel() {
// TODO Auto-generated method stub
return null;
}
}
Note: I extended the CommonApp class, and added all of the unimplemented methods,
but it still didn't work. Also i configured the constructor to be the same as the OptaPlanner one
(although i think it's for the GUI, correct me if i'm wrong).
BenchmarkConfig - Это то же самое, что и предыдущий вопрос
<plannerBenchmark>
<benchmarkDirectory>local/data/nurserostering/location</benchmarkDirectory>
<warmUpSecondsSpentLimit>5</warmUpSecondsSpentLimit>
<inheritedSolverBenchmark>
<problemBenchmarks>
<solutionFileIOClass>org.optaplanner.examples.nurserostering.persistence.CustomBenchmarkIO</solutionFileIOClass>
<inputSolutionFile>data/nurserostering/import/importTest/Input0.xml</inputSolutionFile>
</problemBenchmarks>
Мои вопросы здесь являются:
1. Am я что-то отсутствует в отношении настройки решателя?
2. Относительно Экспортера - Необходимо ли добавить все мои объекты планирования , чтобы решение было создано?
3. Будет ли мой NurseRosterConsoleApp вызывать проблемы с бенчмаркингом?
4. Где создано решение?