code: private InstanceTypeDescription getType(Map<InstanceType, InstanceTypeDescription> types)
  	throws CompilerException
  	{
  		if (types == null || types.size() < 1) {
  			throw new IllegalArgumentException("No instance type found.");
  		}
  		
  		InstanceTypeDescription retValue = null;
  		long totalMemory = 0;
  		int numInstances = 0;
  		
  		final Iterator<InstanceTypeDescription> it = types.values().iterator();
  		while(it.hasNext())
  		{
  			final InstanceTypeDescription descr = it.next();
  			
  			// skip instances for which no hardware description is available
  			// this means typically that no 
  			if (descr.getHardwareDescription() == null || descr.getInstanceType() == null) {
  				continue;
  			}
  			
  			final int curInstances = descr.getMaximumNumberOfAvailableInstances();
  			final long curMemory = curInstances * descr.getHardwareDescription().getSizeOfFreeMemory();
  			
  			// get, if first, or if it has more instances and not less memory, or if it has significantly more memory
  			// and the same number of cores still
  			if ( (retValue == null) ||
  				(curInstances > numInstances && (int) (curMemory * 1.2f) > totalMemory) ||
  				(curInstances * retValue.getInstanceType().getNumberOfCores() >= numInstances && 
  							(int) (curMemory * 1.5f) > totalMemory)
  				)
  			{
  				retValue = descr;
  				numInstances = curInstances;
  				totalMemory = curMemory;
  			}
  		}
  		
  		if (retValue == null) {
  			throw new CompilerException("No instance currently registered at the job-manager. Retry later.\n" +
  				"If the system has recently started, it may take a few seconds until the instances register.");
  		}
  		
  		return retValue;
  	}
docs: This utility method picks the instance type to be used for executing programs.
  <p>
  
  @param types The available types.
  @return The type to be used for scheduling.
  
  @throws CompilerException
  @throws IllegalArgumentException