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


Java RealDomain类代码示例

本文整理汇总了Java中edacc.parameterspace.domain.RealDomain的典型用法代码示例。如果您正苦于以下问题:Java RealDomain类的具体用法?Java RealDomain怎么用?Java RealDomain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setParameterValue

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
public void setParameterValue(Parameter p, Object v) {
	if (!parameter_instances.containsKey(p))
		throw new IllegalArgumentException("The parameter has to be part of a solver configuration");
	if (v == null) {
	    parameter_instances.put(p, null);
	    return;
	}
	
	if (!p.getDomain().contains(v)) {
		throw new IllegalArgumentException("Domain of parameter " + p.getName() + " does not contain the given value " + v + " Domain: " + p.getDomain());
	}
       if (p.getDomain() instanceof RealDomain) {
           if (v instanceof Integer) v = ((Integer)v).floatValue();
       }
	parameter_instances.put(p, v);
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:17,代码来源:ParameterConfiguration.java

示例2: testUniformDistributedValues

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testUniformDistributedValues() {
	RealDomain r = new RealDomain(0.54421, 1.35667);
	List<Object> vals = r.getUniformDistributedValues(42);
	assertEquals(vals.size(), 42);
	for (int i = 0; i < vals.size(); i++) {
		assertTrue(vals.get(i) instanceof Double);
	}
	Double d1 = (Double) vals.get(0);
	Double d2 = (Double) vals.get(1);
	assertTrue(r.contains(d1));
	Double dist = d2 - d1;
	for (int i = 2; i < vals.size(); i++) {
		d1 = d2;
		d2 = (Double) vals.get(i);
		assertTrue(r.contains(d2));
		Double test = d2 - d1 - dist;
		assertTrue((test > -eps && test < eps));			
	}
	assertEquals(vals.get(0), r.getLow());
	assertEquals(vals.get(vals.size()-1), r.getHigh());
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:23,代码来源:RealDomainTest.java

示例3: testContains

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testContains() {
	RealDomain r = new RealDomain(0, 100);
	assertTrue(r.contains(new Double(0.1)));
	assertFalse(r.contains(new Double(-4.0)));
	assertTrue(r.contains(new Integer(10)));
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:8,代码来源:RealDomainTest.java

示例4: testRandomValue

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testRandomValue() {
	RealDomain r = new RealDomain(0, 100);
	Random rng = new MersenneTwister();
	for (int i = 0; i < 1000; i++)
		assertTrue(r.contains(r.randomValue(rng)));
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:8,代码来源:RealDomainTest.java

示例5: testMidValue

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testMidValue() {
	RealDomain r = new RealDomain(-10.0, 10.0);
	Double d0 = null;
	Random rng = null;
	for (int state = 0; state < 2; state++) {
		if (state == 0)
			rng = new Random(42);
		else if (state == 1)
			rng = new Random();
		for (int i = 0; i < 10000; i++) {
			double d = rng.nextDouble() * 20 - 10;
			assertTrue(r.contains(d));
			if (d0 != null) {
				Object o = r.getMidValueOrNull(d0, d);
				Object o2 = r.getMidValueOrNull(d, d0);
				if (o == null || o2 == null) {
					assertTrue(o == o2);
					assertTrue(d0.equals(d));
				} else {
					assertTrue(o instanceof Double);
					assertTrue(o2 instanceof Double);
					Double d1 = (Double) o;
					Double d2 = (Double) o2;
					double test = d1 - d2;
					assertTrue((test > -eps && test < eps));
					assertTrue(r.contains(d1));
					assertTrue(r.contains(d2));
					test = (d1 + d2) / 2. - d1;
					assertTrue((test > -eps && test < eps));
					test = (d1 + d2) / 2. - d2;
					assertTrue((test > -eps && test < eps));
				}
			}
			d0 = d;
		}
	}
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:39,代码来源:RealDomainTest.java

示例6: getDomain

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Override
public Domain getDomain() throws InvalidDomainException {
    try {
        double lo = Double.parseDouble(txtLow.getText());
        double hi = Double.parseDouble(txtHigh.getText());
        return new RealDomain(lo, hi);
    } catch (NumberFormatException e) {
        throw new InvalidDomainException("You have to specify real numbers for lower and upper limit for real domain.");
    }
}
 
开发者ID:EDACC,项目名称:edacc_gui,代码行数:11,代码来源:SelectRealDomainPanel.java

示例7: setDomain

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Override
public void setDomain(Domain orDomain, Domain andDomain) throws InvalidDomainException {
    if (!(orDomain instanceof RealDomain) || !(andDomain instanceof RealDomain)) {
        throw new InvalidDomainException("Got domains " + orDomain.getName() + "/" + andDomain.getName() + ", expected real/real domains.");
    }
    RealDomain d = (RealDomain) andDomain;
    txtLow.setText(String.valueOf(d.getLow()));
    txtHigh.setText(String.valueOf(d.getHigh()));
}
 
开发者ID:EDACC,项目名称:edacc_gui,代码行数:10,代码来源:SelectRealDomainPanel.java

示例8: btnUseDomainActionPerformed

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
private void btnUseDomainActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUseDomainActionPerformed
    UseDomainDialog dialog = new UseDomainDialog(EDACCApp.getApplication().getMainFrame(), true, main.getParameters(), RealDomain.class);
    dialog.setName("UseDomainDialog");
    EDACCApp.getApplication().show(dialog);
    Parameter p;
    if ((p = dialog.getSelectedItem()) != null && p.getDomain() instanceof RealDomain) {
        this.setDomain(p.getDomain(), null);
    }
}
 
开发者ID:EDACC,项目名称:edacc_gui,代码行数:10,代码来源:SpecifyRealDomainPanel.java

示例9: setDomain

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Override
public void setDomain(Domain orDomain, Domain andDomain) {
    if (!(orDomain instanceof RealDomain) || andDomain != null) {
        return;
    }
    RealDomain rDomain = (RealDomain) orDomain;
    txtLow.setText("" + rDomain.getLow());
    txtHigh.setText("" + rDomain.getHigh());
}
 
开发者ID:EDACC,项目名称:edacc_gui,代码行数:10,代码来源:SpecifyRealDomainPanel.java

示例10: testToString

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testToString() {
	RealDomain r = new RealDomain(0, 100);
	assertEquals(r.toString(), "[0.0,100.0]");
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:6,代码来源:RealDomainTest.java

示例11: testRealDomain

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testRealDomain() {
	RealDomain r = new RealDomain(0, 1);
	assertTrue(r.contains(0.5d));
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:6,代码来源:RealDomainTest.java

示例12: paramConfigToTuple

import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
private double[] paramConfigToTuple(ParameterConfiguration paramConfig, List<Parameter> configurableParameters) {
    double[] theta = new double[configurableParameters.size()];
    for (Parameter p: configurableParameters) {
        int pIx = configurableParameters.indexOf(p);
        Object paramValue = paramConfig.getParameterValue(p);
        if (paramValue == null) theta[pIx] = Double.NaN;
        else {
            if (p.getDomain() instanceof RealDomain) {
                if (paramValue instanceof Float) {
                    theta[pIx] = (Float)paramValue;
                } else if (paramValue instanceof Double) {
                    theta[pIx] = (Double)paramValue;
                }
            } else if (p.getDomain() instanceof IntegerDomain) {
                if (paramValue instanceof Integer) {
                    theta[pIx] = (Integer)paramValue;
                } else if (paramValue instanceof Long) {
                    theta[pIx] = (Long)paramValue;
                }
            } else if (p.getDomain() instanceof CategoricalDomain) {
                theta[pIx] = catDomainMap.get(p).get((String)paramValue);
            } else if (p.getDomain() instanceof OrdinalDomain) {
                // map ordinal parameters to integers 1 through domain.size, 0 = not set
                Map<String, Integer> valueMap = new HashMap<String, Integer>();
                int intVal = 1;
                for (String val: ((OrdinalDomain)p.getDomain()).getOrdered_list()) {
                    valueMap.put(val, intVal++);
                }
                
                theta[pIx] = valueMap.get((String)paramValue);
            } else if (p.getDomain() instanceof FlagDomain) {
                // map flag parameters to {0, 1}
                if (FlagDomain.FLAGS.ON.equals(paramValue)) theta[pIx] = 2;
                else theta[pIx] = 1;
            } else {
                // TODO
                theta[pIx] = paramValue.hashCode();
            }
        }
        
    }
    
    return theta;
}
 
开发者ID:EDACC,项目名称:edacc_api,代码行数:45,代码来源:Benchmark.java


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