问题
I've been studying the OptaPlanner framwork for a bit and have found the CloudBalancingHelloWorld example fits a problem I'm tasked with fairly well - only it loads a fake generated problem set and I'd like to create my own XML file and load that instead ... but the docs seem a bit sparse on this subject, and I don't see any examples.
The existing code in CloudBalancingHellowWorld.java is:
// Load a problem with 400 computers and 1200 processes
// This gets replaced with a class that loads a *real* problem - from a DB for example.
CloudBalance unsolvedCloudBalance = new CloudBalancingGenerator().createCloudBalance(400, 1200);
And I'd like to be able to programmatically load an XML problem description. Are there any examples out there of this being done or Docs to be perused to gain some inspiration?
回答1:
The whole dataset serialization from and to XML is part of optaplanner-examples: OptaPlanner itself doesn't provide or require any serialization format. That being said, optaplanner-examples includes the following serialization formats:
- Every example: XStream XML format in
data
directoriesunsolved
andsolved
. The format is defined by the XStream annotations (@XStreamAlias
etc) on the domain classes. In some cases the XML format is too verbose, causingOutOfMemoryError
, for example for the bigMachineReassignment
B datasets. - Most examples: Competition specific TXT format in
data
directoriesimport
andexport
. The format is defined by the competition (see docs). In the examples GUI, click on button Import to load them.
来源:https://stackoverflow.com/questions/25636540/loading-real-world-xml-problems-in-optaplanner-6-1-0