本文整理汇总了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);
}
示例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());
}
示例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)));
}
示例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)));
}
示例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;
}
}
}
示例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.");
}
}
示例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()));
}
示例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);
}
}
示例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());
}
示例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]");
}
示例11: testRealDomain
import edacc.parameterspace.domain.RealDomain; //导入依赖的package包/类
@Test
public void testRealDomain() {
RealDomain r = new RealDomain(0, 1);
assertTrue(r.contains(0.5d));
}
示例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;
}