List of usage examples for org.apache.commons.math3.exception NullArgumentException NullArgumentException
public NullArgumentException()
From source file:eu.crisis_economics.abm.firm.plugins.RandomVariableLabourWageAlgorithm.java
static private double initGuard(AbstractRealDistribution labourWageDistribution) { if (labourWageDistribution == null) throw new NullArgumentException(); return labourWageDistribution.sample(); }
From source file:eu.crisis_economics.utilities.EnumDistribution.java
public static <T extends Enum<T>> EnumDistribution<T> // Immutable create(Class<T> token, String sourceFile) throws IOException { if (token == null) throw new NullArgumentException(); if (!token.isEnum()) throw new IllegalArgumentException("EnumDistribution: " + token.getSimpleName() + " is not an enum."); if (token.getEnumConstants().length == 0) throw new IllegalArgumentException("EnumDistribution: " + token.getSimpleName() + " is an empty enum."); EnumDistribution<T> result = new EnumDistribution<T>(); result.values = token.getEnumConstants(); result.probabilities = new EnumMap<T, Double>(token); Map<String, T> converter = new HashMap<String, T>(); final int numberOfValues = result.values.length; int[] valueIndices = new int[numberOfValues]; double[] valueProbabilities = new double[numberOfValues]; BitSet valueIsComitted = new BitSet(numberOfValues); {//from ww w.ja v a 2s. c o m int counter = 0; for (T value : result.values) { valueIndices[counter] = counter++; result.probabilities.put(value, 0.); converter.put(value.name(), value); } } BufferedReader reader = new BufferedReader(new FileReader(sourceFile)); try { String newLine; while ((newLine = reader.readLine()) != null) { if (newLine.isEmpty()) continue; StringTokenizer tokenizer = new StringTokenizer(newLine); final String name = tokenizer.nextToken(" ,:\t"), pStr = tokenizer.nextToken(" ,:\t"); if (tokenizer.hasMoreTokens()) throw new ParseException( "EnumDistribution: " + newLine + " is not a valid entry in " + sourceFile + ".", 0); final double p = Double.parseDouble(pStr); if (p < 0. || p > 1.) throw new IOException(pStr + " is not a valid probability for the value " + name); result.probabilities.put(converter.get(name), p); final int ordinal = converter.get(name).ordinal(); if (valueIsComitted.get(ordinal)) throw new ParseException("The value " + name + " appears twice in " + sourceFile, 0); valueProbabilities[converter.get(name).ordinal()] = p; valueIsComitted.set(ordinal, true); } { // Check sum of probabilities double sum = 0.; for (double p : valueProbabilities) sum += p; if (Math.abs(sum - 1.) > 1e2 * Math.ulp(1.)) throw new IllegalStateException("EnumDistribution: parser has succeeded, but the resulting " + "probaility sum (value " + sum + ") is not equal to 1."); } } catch (Exception e) { throw new IOException(e.getMessage()); } finally { reader.close(); } result.dice = new EnumeratedIntegerDistribution(valueIndices, valueProbabilities); return result; }
From source file:eu.crisis_economics.configuration.AssignmentExpression.java
private static List<ConfigurationExpression> initGuard(ConfigurationExpression asigneeExpression, ConfigurationExpression definitionExpression) { if (asigneeExpression == null || definitionExpression == null) throw new NullArgumentException(); return Arrays.asList(asigneeExpression, definitionExpression); }
From source file:eu.crisis_economics.configuration.CompoundExpression.java
private static List<ConfigurationExpression> initGuard(ConfigurationExpression typeDeclarationExpression, ConfigurationExpression instanceAssignmentExpression) { if (typeDeclarationExpression == null || instanceAssignmentExpression == null) throw new NullArgumentException(); return Arrays.asList(typeDeclarationExpression, instanceAssignmentExpression); }
From source file:eu.crisis_economics.configuration.CommaListExpression.java
private static List<ConfigurationExpression> initGuard(TypeDeclarationExpression typeExpression, List<ArgumentAssignmentExpression> assignmentExpressions) { if (assignmentExpressions == null || typeExpression == null) throw new NullArgumentException(); List<ConfigurationExpression> result = new ArrayList<ConfigurationExpression>(); result.add(typeExpression);/* w ww . ja v a 2 s .c o m*/ result.addAll(assignmentExpressions); return result; }
From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.CompleteNetworkMarket.java
public CompleteNetworkMarket(final ClearingInstrument resource, final ResourceExchangeDelegate resourceExchangeDelegate) { if (resource == null || resourceExchangeDelegate == null) throw new NullArgumentException(); this.resource = resource; this.resourceExchangeDelegate = resourceExchangeDelegate; }
From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.PartitionedResponseFunction.java
public PartitionedResponseFunction(final MarketResponseFunction partitionFunction, final BoundedUnivariateFunction univariateTradeDemand) { if (partitionFunction == null || univariateTradeDemand == null) throw new NullArgumentException(); this.partitionFunction = partitionFunction; this.univariateTradeDemand = univariateTradeDemand; }
From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.AbstractResponseFunction.java
protected AbstractResponseFunction(final SimpleDomainBounds domainBounds) { if (domainBounds == null) throw new NullArgumentException(); this.domainBounds = domainBounds; }
From source file:eu.crisis_economics.abm.contracts.stocks.StockTrade.java
public StockTrade(final String instrumentName, final double pricePerShare, final double volume, final StockHolder buyer, final StockHolder seller) { super(buyer, seller); if (instrumentName == null) throw new NullArgumentException(); this.instrumentName = instrumentName; this.pricePerShare = pricePerShare; this.volume = volume; }
From source file:eu.crisis_economics.configuration.NameDeclarationExpression.java
private NameDeclarationExpression(String literalName, FromFileConfigurationContext interpretationContext) { super(null, interpretationContext); if (literalName == null) throw new NullArgumentException(); this.literalName = literalName; interpretationContext.registerNameDeclaration(this); }