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


Java DataProperties.put方法代码示例

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


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

示例1: createConfig

import org.cpsolver.ifs.util.DataProperties; //导入方法依赖的package包/类
@Override
public DataProperties createConfig(Long settingsId, Map<Long, String> options) {
	DataProperties properties = new DataProperties();
	
	// Load properties
	for (SolverParameterDef def: (List<SolverParameterDef>)SolverPredefinedSettingDAO.getInstance().getSession().createQuery(
			"from SolverParameterDef where group.type = :type").setInteger("type", SolverParameterGroup.SolverType.EXAM.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.EXAM) 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("ExamGeneral.CBS", true)) {
		if (!ext.isEmpty()) ext += ";";
		ext += ConflictStatistics.class.getName();
		properties.setProperty("ConflictStatistics.Print","true");
	}
	
	String mode = properties.getProperty("ExamBasic.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("ExamBasic.WhenFinished"))) {
           properties.setProperty("General.Save","false");
           properties.setProperty("General.CreateNewSolution","false");
           properties.setProperty("General.Unload","false");
       } else if ("Save".equals(properties.getProperty("ExamBasic.WhenFinished"))) {
           properties.setProperty("General.Save","true");
           properties.setProperty("General.CreateNewSolution","false");
           properties.setProperty("General.Unload","false");
       } else if ("Save and Unload".equals(properties.getProperty("ExamBasic.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("Exam.GreatDeluge", ("Great Deluge".equals(properties.getProperty("Exam.Algorithm","Great Deluge"))?"true":"false"));
       properties.setProperty("Search.GreatDeluge", ("Great Deluge".equals(properties.getProperty("Exam.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", String.valueOf(Math.max(1, Runtime.getRuntime().availableProcessors() / 2)));
       }
       
       properties.setProperty("General.UseAmPm", CONSTANTS.useAmPm() ? "true" : "false");

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

示例2: 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


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