當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。