use of org.cpsolver.ifs.util.DataProperties in project cpsolver by UniTime.
the class Test method test.
private static void test(File inputCfg, String name, String include, String regexp, String outDir) throws Exception {
if (regexp != null) {
String incFile;
if (regexp.indexOf(';') > 0) {
incFile = regexp.substring(0, regexp.indexOf(';'));
regexp = regexp.substring(regexp.indexOf(';') + 1);
} else {
incFile = regexp;
regexp = null;
}
if (incFile.startsWith("[") && incFile.endsWith("]")) {
test(inputCfg, name, include, regexp, outDir);
incFile = incFile.substring(1, incFile.length() - 1);
}
if (incFile.indexOf('{') >= 0 && incFile.indexOf('}') >= 0) {
String prefix = incFile.substring(0, incFile.indexOf('{'));
StringTokenizer middle = new StringTokenizer(incFile.substring(incFile.indexOf('{') + 1, incFile.indexOf('}')), "|");
String sufix = incFile.substring(incFile.indexOf('}') + 1);
while (middle.hasMoreTokens()) {
String m = middle.nextToken();
test(inputCfg, (name == null ? "" : name + "_") + m, (include == null ? "" : include + ";") + prefix + m + sufix, regexp, outDir);
}
} else {
test(inputCfg, name, (include == null ? "" : include + ";") + incFile, regexp, outDir);
}
} else {
DataProperties properties = ToolBox.loadProperties(inputCfg);
StringTokenizer inc = new StringTokenizer(include, ";");
while (inc.hasMoreTokens()) {
String aFile = inc.nextToken();
System.out.println(" Loading included file '" + aFile + "' ... ");
FileInputStream is = null;
if ((new File(aFile)).exists()) {
is = new FileInputStream(aFile);
}
if ((new File(inputCfg.getParent() + File.separator + aFile)).exists()) {
is = new FileInputStream(inputCfg.getParent() + File.separator + aFile);
}
if (is == null) {
System.err.println("Unable to find include file '" + aFile + "'.");
}
properties.load(is);
is.close();
}
String outDirThisTest = (outDir == null ? properties.getProperty("General.Output", ".") : outDir) + File.separator + name + File.separator + sDateFormat.format(new Date());
properties.setProperty("General.Output", outDirThisTest.toString());
System.out.println("Output folder: " + properties.getProperty("General.Output"));
(new File(outDirThisTest)).mkdirs();
ToolBox.configureLogging(outDirThisTest, null);
FileOutputStream fos = new FileOutputStream(outDirThisTest + File.separator + "rcsp.conf");
properties.store(fos, "Random CSP problem configuration file");
fos.flush();
fos.close();
test(properties);
}
}
use of org.cpsolver.ifs.util.DataProperties in project cpsolver by UniTime.
the class Test method main.
public static void main(String[] args) {
try {
Progress.getInstance().addProgressListener(new ProgressWriter(System.out));
File inputCfg = new File(args[0]);
DataProperties properties = ToolBox.loadProperties(inputCfg);
String outDir = properties.getProperty("General.Output", ".") + File.separator + inputCfg.getName().substring(0, inputCfg.getName().lastIndexOf('.')) + File.separator + sDateFormat.format(new Date());
(new File(outDir)).mkdirs();
properties.setProperty("General.Output", outDir.toString());
ToolBox.configureLogging(outDir, null);
test(properties);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.cpsolver.ifs.util.DataProperties in project cpsolver by UniTime.
the class StudentRequestXml method main.
public static void main(String[] args) {
try {
ToolBox.configureLogging();
StudentSectioningModel model = new StudentSectioningModel(new DataProperties());
Assignment<Request, Enrollment> assignment = new DefaultSingleAssignment<Request, Enrollment>();
StudentSectioningXMLLoader xmlLoad = new StudentSectioningXMLLoader(model, assignment);
xmlLoad.setInputFile(new File(args[0]));
xmlLoad.load();
Document document = exportModel(assignment, model);
FileOutputStream fos = new FileOutputStream(new File(args[1]));
(new XMLWriter(fos, OutputFormat.createPrettyPrint())).write(document);
fos.flush();
fos.close();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.cpsolver.ifs.util.DataProperties in project cpsolver by UniTime.
the class StudentSctBBTest method getSolution.
/**
* Compute and return the sectioning solution. It contains only the given
* student with his/her schedule
* @return current solution
*/
public Solution<Request, Enrollment> getSolution() {
if (iSolution == null) {
iSolution = new Solution<Request, Enrollment>(this, new DefaultSingleAssignment<Request, Enrollment>());
BranchBoundSelection.Selection selection = new BranchBoundSelection(new DataProperties()).getSelection(iSolution.getAssignment(), getStudent());
Neighbour<Request, Enrollment> neighbour = selection.select();
if (neighbour != null)
neighbour.assign(iSolution.getAssignment(), 0);
iTime = selection.getTime();
iTimeoutReached = selection.isTimeoutReached();
}
return iSolution;
}
use of org.cpsolver.ifs.util.DataProperties in project cpsolver by UniTime.
the class ChmTest method main.
public static void main(String[] args) throws Exception {
DataProperties config = new DataProperties();
config.load(ChmTest.class.getClass().getResourceAsStream("/org/cpsolver/instructor/test/chm.properties"));
config.putAll(System.getProperties());
ToolBox.configureLogging();
new ChmTest(config).execute();
}
Aggregations