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


Java MRG32k3a类代码示例

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


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

示例1: generateCommandList

import umontreal.ssj.rng.MRG32k3a; //导入依赖的package包/类
/**
 * Generates commands for the workers as a list of strings.
 * @param randomStreams				A map of random streams
 * @param NUM_WORKERS				The number of workers
 * @param REPLICATIONS_PER_WORKER	The number of replications per worker
 * @return {@literal List<List<String>>} A list of commands for the workers
 */
public static List<List<String>> generateCommandList(Map<String, RandomStreamBase> randomStreams, final int NUM_WORKERS, final int REPLICATIONS_PER_WORKER) {
	List<List<String>> commandList = new ArrayList<>(NUM_WORKERS);

	// One list of commands for each worker
	for (int i = 0; i < NUM_WORKERS; i++) {
		List<String> commands = new ArrayList<>();
		
		commands.add(String.valueOf(REPLICATIONS_PER_WORKER));

		// Extract the name and seed from the random streams
		// then convert it to a command list
		for (Entry<String, RandomStreamBase> entry : randomStreams.entrySet()) {
			MRG32k3a tmp = (MRG32k3a) entry.getValue();
			StringBuilder builder = new StringBuilder();
			
			for(long state : tmp.getState()) {
				builder.append(state).append(" ");
			}
			
			commands.add(entry.getKey());
			commands.add(builder.toString());
			
			// Set next substream for next worker
			entry.getValue().resetNextSubstream();
		}
		
		commandList.add(commands);
	}
	
	return commandList;
}
 
开发者ID:dc-sics,项目名称:microsim,代码行数:39,代码来源:Utils.java

示例2: getProbabilisticMachineLocation

import umontreal.ssj.rng.MRG32k3a; //导入依赖的package包/类
public static Location getProbabilisticMachineLocation(int configurationNumber){
   MRG32k3a rng = new MRG32k3a();
   rng.setSeed(new long[]{12345,12345,12345,12345,12345,12345});
   rng.resetStartStream();
   switch(configurationNumber){
   case 0:
      return probabilisticMachineLocation(rng);
   case 1:
      rng.resetNextSubstream();
      return probabilisticMachineLocation(rng);
   case 2:
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      return probabilisticMachineLocation(rng);
   case 3: 
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      return probabilisticMachineLocation(rng);
   case 4:
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      return probabilisticMachineLocation(rng);
   case 5:
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      rng.resetNextSubstream();
      return probabilisticMachineLocation(rng);   
   default:
      throw new NullPointerException("Inexistent machine location configuration");
   }
}
 
开发者ID:gwr3n,项目名称:jsdp,代码行数:37,代码来源:Location.java

示例3: main

import umontreal.ssj.rng.MRG32k3a; //导入依赖的package包/类
/**
 * @param args the command line arguments
 */
public static void main(String[] args) {

	int REPLICATIONS = 1000000;
	int NUM_THREADS = 1;

	StopWatch stopWatch = new StopWatch();

	if(args.length == 2) {
		NUM_THREADS = Integer.valueOf(args[0]);
		REPLICATIONS = Integer.valueOf(args[1]);
	}

	int REPLICATIONS_PER_THREAD = REPLICATIONS / NUM_THREADS;
	
	stopWatch.start();

	// simulation workers
	final SimulationWorkerRunnable[] simulations = new SimulationWorkerRunnable[NUM_THREADS];

	for(int i = 0; i < NUM_THREADS; i++) {
		// Random streams
		Map<String, RandomStreamBase> randomStreams = new HashMap<>();
		randomStreams.put("Cancer", new MRG32k3a());
		randomStreams.put("Death", new MRG32k3a());
		randomStreams.put("CancerDeath", new MRG32k3a());
		randomStreams.put("Attribute", new MRG32k3a());
		
		simulations[i] = new SimulationWorkerRunnable(randomStreams, REPLICATIONS_PER_THREAD);
	}

	ExecutorService es = Executors.newFixedThreadPool(NUM_THREADS);

	final Report report = new Report();

	for(int i = 0; i < NUM_THREADS; i++) {
		final int j = i;

		es.execute(new Runnable(){
			@Override
			public void run() {
				simulations[j].run();
				
				synchronized(report) {
					report.addAll(simulations[j].report);
				}
			}
		});
	}
	
	es.shutdown();
	try {
		es.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
	} catch(InterruptedException ex) {
		System.err.println(ex);
	}
	
	
	System.out.println("Number of events: " + report.getEvents().size());
	
	System.out.println("Life expectancy: " + report.lifeExpectancy(REPLICATIONS));

	stopWatch.stop();
	System.out.println("Time: " + stopWatch.getElapsedTime());
}
 
开发者ID:dc-sics,项目名称:microsim,代码行数:68,代码来源:LocalMaster.java


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