当前位置: 首页>>代码示例>>Java>>正文


Java DataProperties.load方法代码示例

本文整理汇总了Java中org.cpsolver.ifs.util.DataProperties.load方法的典型用法代码示例。如果您正苦于以下问题:Java DataProperties.load方法的具体用法?Java DataProperties.load怎么用?Java DataProperties.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.cpsolver.ifs.util.DataProperties的用法示例。


在下文中一共展示了DataProperties.load方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        // Configure logging
        org.apache.log4j.BasicConfigurator.configure();
        
        // Load properties (take first argument as input file, containing key=value lines)
        DataProperties properties = new DataProperties();
        properties.load(new FileInputStream(args[0]));
        
        // Generate model
        Assignment<Activity, Location> assignment = new DefaultSingleAssignment<Activity, Location>();
        TimetableModel model = TimetableModel.generate(new DataProperties(), assignment);
        System.out.println(model.getInfo(assignment));
        
        // Save solution (take second argument as output file)
        model.saveAsXML(properties, true, new Solution<Activity, Location>(model, assignment), assignment, new File(args[1]));
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:21,代码来源:TimetableModel.java

示例2: main

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ToolBox.configureLogging();

    DataProperties config = new DataProperties();
    if (System.getProperty("config") == null) {
        config.load(Test.class.getClass().getResourceAsStream("/org/cpsolver/instructor/default.properties"));
    } else {
        config.load(new FileInputStream(System.getProperty("config")));
    }
    config.putAll(System.getProperties());
    
    new Test(config).execute();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:14,代码来源:Test.java

示例3: main

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    DataProperties config = new DataProperties();
    config.load(MathTest.class.getClass().getResourceAsStream("/org/cpsolver/instructor/test/math.properties"));
    config.putAll(System.getProperties());
    ToolBox.configureLogging();
    
    new MathTest(config).execute();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:MathTest.java

示例4: main

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
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();
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:9,代码来源:ChmTest.java

示例5: createConfig

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public DataProperties createConfig(Long settingsId, Map<Long, String> options) {
	DataProperties properties = new DataProperties();
	
	try {
		InputStream is = getClass().getClassLoader().getResourceAsStream("org/cpsolver/instructor/default.properties");
		if (is != null) properties.load(is);
	} catch (IOException e) {
		sLog.warn("Failed to load configuration defaults:" + e.getMessage());
	}
	
	// Load properties
	for (SolverParameterDef def: (List<SolverParameterDef>)SolverPredefinedSettingDAO.getInstance().getSession().createQuery(
			"from SolverParameterDef where group.type = :type").setInteger("type", SolverParameterGroup.SolverType.INSTRUCTOR.ordinal()).list()) {
		if (def.getDefault() != null) properties.put(def.getName(), def.getDefault());
		if (options != null && options.containsKey(def.getUniqueId()))
			properties.put(def.getName(), options.get(def.getUniqueId()));
	}
	
	SolverPredefinedSetting settings = SolverPredefinedSettingDAO.getInstance().get(settingsId);
	for (SolverParameter param: settings.getParameters()) {
		if (!param.getDefinition().isVisible() || param.getDefinition().getGroup().getSolverType() != SolverParameterGroup.SolverType.INSTRUCTOR) continue;
		properties.put(param.getDefinition().getName(),param.getValue());
		if (options != null && options.containsKey(param.getDefinition().getUniqueId()))
			properties.put(param.getDefinition().getName(), options.get(param.getDefinition().getUniqueId()));
	}
	properties.setProperty("General.SettingsId", settings.getUniqueId().toString());
	
	// Generate extensions
	String ext = properties.getProperty("Extensions.Classes", "");
	if (properties.getPropertyBoolean("General.CBS", true)) {
		if (!ext.isEmpty()) ext += ";";
		ext += ConflictStatistics.class.getName();
		properties.setProperty("ConflictStatistics.Print","true");
	}
	
	String mode = properties.getProperty("Basic.Mode","Initial");
       if ("MPP".equals(mode)) 
           properties.setProperty("General.MPP","true");

       properties.setProperty("Extensions.Classes", ext);
       
       // Interactive mode?
       if (properties.getPropertyBoolean("Basic.DisobeyHard", false))
       	properties.setProperty("General.InteractiveMode", "true");
       
       // When finished?
       if ("No Action".equals(properties.getProperty("Basic.WhenFinished"))) {
           properties.setProperty("General.Save","false");
           properties.setProperty("General.CreateNewSolution","false");
           properties.setProperty("General.Unload","false");
       } else if ("Save".equals(properties.getProperty("Basic.WhenFinished"))) {
           properties.setProperty("General.Save","true");
           properties.setProperty("General.CreateNewSolution","false");
           properties.setProperty("General.Unload","false");
       } else if ("Save and Unload".equals(properties.getProperty("Basic.WhenFinished"))) {
           properties.setProperty("General.Save","true");
           properties.setProperty("General.CreateNewSolution","false");
           properties.setProperty("General.Unload","true");
       }
       
       // XML save/load properties
       properties.setProperty("Xml.ShowNames", "true");
       
       properties.setProperty("Search.GreatDeluge", ("Great Deluge".equals(properties.getProperty("General.Algorithm","Great Deluge"))?"true":"false"));
       
       // Distances Matrics
       if (properties.getProperty("Distances.Ellipsoid") == null || properties.getProperty("Distances.Ellipsoid").equals("DEFAULT"))
           properties.setProperty("Distances.Ellipsoid", ApplicationProperties.getProperty(ApplicationProperty.DistanceEllipsoid));
       
       if (properties.getProperty("Parallel.NrSolvers") == null) {
       	properties.setProperty("Parallel.NrSolvers", "1"); // String.valueOf(Math.max(1, Runtime.getRuntime().availableProcessors() / 2))
       }
       
       properties.setProperty("General.UseAmPm", CONSTANTS.useAmPm() ? "true" : "false");

       properties.expand();
       
       return properties;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:81,代码来源:InstructorSchedulingSolverService.java

示例6: main

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        DataProperties cfg = new DataProperties();
        cfg.setProperty("Termination.Class","org.cpsolver.ifs.termination.GeneralTerminationCondition");
        cfg.setProperty("Termination.StopWhenComplete","true");
        cfg.setProperty("Termination.TimeOut","600");
        cfg.setProperty("Comparator.Class","org.cpsolver.ifs.solution.GeneralSolutionComparator");
        cfg.setProperty("Value.Class","org.cpsolver.ifs.heuristics.GeneralValueSelection");
        cfg.setProperty("Value.WeightConflicts", "1.0");
        cfg.setProperty("Value.WeightNrAssignments", "0.0");
        cfg.setProperty("Variable.Class","org.cpsolver.ifs.heuristics.GeneralVariableSelection");
        cfg.setProperty("Neighbour.Class","org.cpsolver.studentsct.heuristics.StudentSctNeighbourSelection");
        cfg.setProperty("General.SaveBestUnassigned", "-1");
        cfg.setProperty("Extensions.Classes","org.cpsolver.ifs.extension.ConflictStatistics;org.cpsolver.studentsct.extension.DistanceConflict");
        cfg.setProperty("Data.Initiative","woebegon");
        cfg.setProperty("Data.Term","Fal");
        cfg.setProperty("Data.Year","2007");
        cfg.setProperty("Load.IncludeCourseDemands", (sIncludeCourseDemands?"true":"false"));
        cfg.setProperty("Load.IncludeLastLikeStudents", (sIncludeLastLikeStudents?"true":"false"));
        cfg.setProperty("Load.IncludeUseCommittedAssignments", (sIncludeUseCommittedAssignments?"true":"false"));
        //cfg.setProperty("Load.MakeupAssignmentsFromRequiredPrefs", "true");
        if (args.length>=1) {
            cfg.load(new FileInputStream(args[0]));
        }
        cfg.putAll(System.getProperties());
        
        if (args.length>=2) {
            File logFile = new File(ToolBox.configureLogging(args[1], cfg, true, false));
            cfg.setProperty("General.Output", logFile.getParentFile().getAbsolutePath());
        } else {
            ToolBox.configureLogging();
            cfg.setProperty("General.Output", System.getProperty("user.home", ".")+File.separator+"Sectioning-Test");
        }
        Logger.getLogger(BacktrackNeighbourSelection.class).setLevel(cfg.getPropertyBoolean("Debug.BacktrackNeighbourSelection",false)?Level.DEBUG:Level.INFO);
        
        HibernateUtil.configureHibernate(cfg);
        
        batchSectioning(cfg);
    } catch (Exception e) {
        sLog.error(e.getMessage(),e);
        e.printStackTrace();
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:44,代码来源:BatchStudentSectioningTest.java

示例7: test

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
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 outDirTisTest = (outDir == null ? properties.getProperty("General.Output", ".") : outDir)
                + File.separator + name + File.separator + sDateFormat.format(new Date());
        properties.setProperty("General.Output", outDirTisTest.toString());
        System.out.println("Output folder: " + properties.getProperty("General.Output"));
        (new File(outDirTisTest)).mkdirs();
        ToolBox.configureLogging(outDirTisTest, null);
        FileOutputStream fos = new FileOutputStream(outDirTisTest + File.separator + "rcsp.conf");
        properties.store(fos, "Random CSP problem configuration file");
        fos.flush();
        fos.close();
        boolean mpp = properties.getPropertyBoolean("General.MPP", true);
        if (mpp)
            testMPP(properties);
        else
            test(properties);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:61,代码来源:Test.java

示例8: test

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:67,代码来源:Test.java

示例9: test

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
public 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();
        test2(properties);
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:67,代码来源:Test.java

示例10: main

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
/** Main 
 * @param args program arguments
 **/
public static void main(String[] args) {
    try {
        DataProperties cfg = new DataProperties();
        cfg.setProperty("Termination.Class", "org.cpsolver.ifs.termination.GeneralTerminationCondition");
        cfg.setProperty("Termination.StopWhenComplete", "true");
        cfg.setProperty("Termination.TimeOut", "600");
        cfg.setProperty("Comparator.Class", "org.cpsolver.ifs.solution.GeneralSolutionComparator");
        cfg.setProperty("Value.Class", "org.cpsolver.studentsct.heuristics.EnrollmentSelection");// org.cpsolver.ifs.heuristics.GeneralValueSelection
        cfg.setProperty("Value.WeightConflicts", "1.0");
        cfg.setProperty("Value.WeightNrAssignments", "0.0");
        cfg.setProperty("Variable.Class", "org.cpsolver.ifs.heuristics.GeneralVariableSelection");
        cfg.setProperty("Neighbour.Class", "org.cpsolver.studentsct.heuristics.StudentSctNeighbourSelection");
        cfg.setProperty("General.SaveBestUnassigned", "0");
        cfg.setProperty("Extensions.Classes",
                "org.cpsolver.ifs.extension.ConflictStatistics;org.cpsolver.studentsct.extension.DistanceConflict" +
                ";org.cpsolver.studentsct.extension.TimeOverlapsCounter");
        cfg.setProperty("Data.Initiative", "puWestLafayetteTrdtn");
        cfg.setProperty("Data.Term", "Fal");
        cfg.setProperty("Data.Year", "2007");
        cfg.setProperty("General.Input", "pu-sectll-fal07-s.xml");
        if (args.length >= 1) {
            cfg.load(new FileInputStream(args[0]));
        }
        cfg.putAll(System.getProperties());

        if (args.length >= 2) {
            cfg.setProperty("General.Input", args[1]);
        }

        File outDir = null;
        if (args.length >= 3) {
            outDir = new File(args[2], sDateFormat.format(new Date()));
        } else if (cfg.getProperty("General.Output") != null) {
            outDir = new File(cfg.getProperty("General.Output", "."), sDateFormat.format(new Date()));
        } else {
            outDir = new File(System.getProperty("user.home", ".") + File.separator + "Sectioning-Test" + File.separator + (sDateFormat.format(new Date())));
        }
        outDir.mkdirs();
        setupLogging(new File(outDir, "debug.log"));
        cfg.setProperty("General.Output", outDir.getAbsolutePath());

        if (args.length >= 4 && "online".equals(args[3])) {
            onlineSectioning(cfg);
        } else if (args.length >= 4 && "simple".equals(args[3])) {
            cfg.setProperty("Sectioning.UseOnlinePenalties", "false");
            onlineSectioning(cfg);
        } else {
            batchSectioning(cfg);
        }
    } catch (Exception e) {
        sLog.error(e.getMessage(), e);
        e.printStackTrace();
    }
}
 
开发者ID:UniTime,项目名称:cpsolver,代码行数:58,代码来源:Test.java


注:本文中的org.cpsolver.ifs.util.DataProperties.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。