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


Java JMetalRandom类代码示例

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


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

示例1: remove

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Override
public int remove(List<S> solutionList, DynamicProblem<S, ?> problem) {
  if (solutionList == null) {
    throw new JMetalException("The solution list is null") ;
  } else if (problem == null) {
    throw new JMetalException("The problem is null") ;
  } else if (solutionList.size() == 0) {
    throw new JMetalException("The solution list is empty") ;
  }

  int numberOfSolutionsToRemove = numberOfSolutionsToDelete ;
  IntStream.range(0, numberOfSolutionsToRemove)
          .forEach(s -> {
                    int chosen = JMetalRandom.getInstance().nextInt(0, solutionList.size()-1);
                    solutionList.remove(chosen);
                  }
          );
  return numberOfSolutionsToDelete ;
}
 
开发者ID:jMetal,项目名称:jMetalSP,代码行数:20,代码来源:RemoveNRandomSolutions.java

示例2: run

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Override
public void run() {
	while (true) {
		try {
			Thread.sleep(dataDelay);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

     int x = JMetalRandom.getInstance().nextInt(0, 100) ;
     int y = JMetalRandom.getInstance().nextInt(0, 100) ;
     double value = JMetalRandom.getInstance().nextDouble(1.0, 4000) ;
		observable.setChanged();
		observable.notifyObservers(new SingleObservedData<TSPMatrixData>(new TSPMatrixData("COST", x, y, value)));
   }
}
 
开发者ID:jMetal,项目名称:jMetalSP,代码行数:17,代码来源:StreamingTSPSource.java

示例3: OMOPSO

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
/** Constructor */
public OMOPSO(DoubleProblem problem, SolutionListEvaluator<DoubleSolution> evaluator,
    int swarmSize, int maxIterations, int archiveSize, UniformMutation uniformMutation,
    NonUniformMutation nonUniformMutation) {
  this.problem = problem ;
  this.evaluator = evaluator ;

  this.swarmSize = swarmSize ;
  this.maxIterations = maxIterations ;
  this.archiveSize = archiveSize ;

  this.uniformMutation = uniformMutation ;
  this.nonUniformMutation = nonUniformMutation ;

  localBest = new DoubleSolution[swarmSize];
  leaderArchive = new CrowdingDistanceArchive<DoubleSolution>(this.archiveSize);
  epsilonArchive = new NonDominatedSolutionListArchive<DoubleSolution>(new DominanceComparator<DoubleSolution>(eta));

  dominanceComparator = new DominanceComparator<DoubleSolution>();
  crowdingDistanceComparator = new CrowdingDistanceComparator<DoubleSolution>();

  speed = new double[swarmSize][problem.getNumberOfVariables()];

  randomGenerator = JMetalRandom.getInstance() ;
  crowdingDistance = new CrowdingDistance<DoubleSolution>();
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:27,代码来源:OMOPSO.java

示例4: reproduction

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Override
protected List<S> reproduction(List<S> population) {
	List<S> offspringPopulation = new ArrayList<>(this.getMaxPopulationSize());
	for (int i = 0; i < this.getMaxPopulationSize(); i += 2) {
		List<S> parents = new ArrayList<>(2);
		int parent1Index = JMetalRandom.getInstance().nextInt(0, this.getMaxPopulationSize()-1);
		int parent2Index = JMetalRandom.getInstance().nextInt(0, this.getMaxPopulationSize()-1);
		while (parent1Index==parent2Index)
			parent2Index = JMetalRandom.getInstance().nextInt(0, this.getMaxPopulationSize()-1);
		parents.add(population.get(parent1Index));
		parents.add(population.get(parent2Index));

		List<S> offspring = crossoverOperator.execute(parents);

		mutationOperator.execute(offspring.get(0));
		mutationOperator.execute(offspring.get(1));

		offspringPopulation.add(offspring.get(0));
		offspringPopulation.add(offspring.get(1));
	}
	return offspringPopulation;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:23,代码来源:AbstractMOMBI.java

示例5: MOEADDRA

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
public MOEADDRA(Problem<DoubleSolution> problem, int populationSize, int resultPopulationSize, int maxEvaluations,
    MutationOperator<DoubleSolution> mutation, CrossoverOperator<DoubleSolution> crossover, FunctionType functionType,
    String dataDirectory, double neighborhoodSelectionProbability,
    int maximumNumberOfReplacedSolutions, int neighborSize) {
  super(problem, populationSize, resultPopulationSize, maxEvaluations, crossover, mutation, functionType,
      dataDirectory, neighborhoodSelectionProbability, maximumNumberOfReplacedSolutions,
      neighborSize);

  differentialEvolutionCrossover = (DifferentialEvolutionCrossover)crossoverOperator ;

  savedValues = new DoubleSolution[populationSize];
  utility = new double[populationSize];
  frequency = new int[populationSize];
  for (int i = 0; i < utility.length; i++) {
    utility[i] = 1.0;
    frequency[i] = 0;
  }

  randomGenerator = JMetalRandom.getInstance() ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:21,代码来源:MOEADDRA.java

示例6: MOEADSTM

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
public MOEADSTM(Problem<DoubleSolution> problem, int populationSize, int resultPopulationSize, int maxEvaluations,
								MutationOperator<DoubleSolution> mutation, CrossoverOperator<DoubleSolution> crossover,
								FunctionType functionType, String dataDirectory, double neighborhoodSelectionProbability,
								int maximumNumberOfReplacedSolutions, int neighborSize) {
	super(problem, populationSize, resultPopulationSize, maxEvaluations, crossover, mutation, functionType,
			dataDirectory, neighborhoodSelectionProbability, maximumNumberOfReplacedSolutions, neighborSize);

	differentialEvolutionCrossover = (DifferentialEvolutionCrossover) crossoverOperator;

	savedValues = new DoubleSolution[populationSize];
	utility 	= new double[populationSize];
	frequency 	= new int[populationSize];
	for (int i = 0; i < utility.length; i++) {
		utility[i] 	 = 1.0;
		frequency[i] = 0;
	}

	randomGenerator = JMetalRandom.getInstance();
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:20,代码来源:MOEADSTM.java

示例7: AbstractMOEAD

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
public AbstractMOEAD(Problem<S> problem, int populationSize, int resultPopulationSize,
    int maxEvaluations, CrossoverOperator<S> crossoverOperator, MutationOperator<S> mutation,
    FunctionType functionType, String dataDirectory, double neighborhoodSelectionProbability,
    int maximumNumberOfReplacedSolutions, int neighborSize) {
  this.problem = problem ;
  this.populationSize = populationSize ;
  this.resultPopulationSize = resultPopulationSize ;
  this.maxEvaluations = maxEvaluations ;
  this.mutationOperator = mutation ;
  this.crossoverOperator = crossoverOperator ;
  this.functionType = functionType ;
  this.dataDirectory = dataDirectory ;
  this.neighborhoodSelectionProbability = neighborhoodSelectionProbability ;
  this.maximumNumberOfReplacedSolutions = maximumNumberOfReplacedSolutions ;
  this.neighborSize = neighborSize ;

  randomGenerator = JMetalRandom.getInstance() ;

  population = new ArrayList<>(populationSize);
  indArray = new Solution[problem.getNumberOfObjectives()];
  neighborhood = new int[populationSize][neighborSize];
  idealPoint = new double[problem.getNumberOfObjectives()];
  nadirPoint = new double[problem.getNumberOfObjectives()];
  lambda = new double[populationSize][problem.getNumberOfObjectives()];
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:26,代码来源:AbstractMOEAD.java

示例8: FindNicheReferencePoint

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
int FindNicheReferencePoint()
{
	// find the minimal cluster size
	int min_size = Integer.MAX_VALUE;
	for (ReferencePoint<S> referencePoint : this.referencePoints)
		min_size = Math.min(min_size,referencePoint.MemberSize());
	
	// find the reference points with the minimal cluster size Jmin
	List<Integer> min_rps=new ArrayList<>();
	
	
	for (int r=0; r<this.referencePoints.size(); r+=1)
	{
		if (this.referencePoints.get(r).MemberSize() == min_size)
		{
			min_rps.add(r);
		}
	}
	// return a random reference point (j-bar)
	return min_rps.get(min_rps.size() > 1 ? JMetalRandom.getInstance().nextInt(0, min_rps.size()-1):0);
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:22,代码来源:EnvironmentalSelection.java

示例9: shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Test
public void shouldTheAlgorithmReturnANumberOfSolutionsWhenSolvingASimpleProblem() throws Exception {
  DoubleProblem problem = new ZDT1() ;
  JMetalRandom.getInstance().setSeed(1446505566148L);
  algorithm = new GDE3Builder(problem)
          .setMaxEvaluations(25000)
          .setPopulationSize(100)
          .build() ;

  new AlgorithmRunner.Executor(algorithm).execute();

  List<DoubleSolution> population = algorithm.getResult();

  /*
  Rationale: the default problem is ZDT4, and GDE3, configured with standard settings, should
  return 100 solutions
  */
  assertTrue(population.size() >= 99) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:20,代码来源:GDE3TestIT.java

示例10: shouldTheHypervolumeHaveAMininumValue

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Test
public void shouldTheHypervolumeHaveAMininumValue() throws Exception {
  DoubleProblem problem = new ZDT1() ;

  JMetalRandom.getInstance().setSeed(1446505566148L);
  algorithm = new GDE3Builder(problem)
          .setMaxEvaluations(25000)
          .setPopulationSize(100)
          .build() ;

  new AlgorithmRunner.Executor(algorithm).execute();

  List<DoubleSolution> population = algorithm.getResult();

  QualityIndicator<List<DoubleSolution>, Double> hypervolume = new PISAHypervolume<>("/referenceFronts/ZDT4.pf") ;

  // Rationale: the default problem is ZDT1, and GDE3, configured with standard settings, should
  // return find a front with a hypervolume value higher than 0.66

  double hv = (Double)hypervolume.evaluate(population) ;

  assertTrue(hv > 0.66) ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:24,代码来源:GDE3TestIT.java

示例11: shouldJMetalRandomGeneratorNotBeUsedWhenCustomRandomGeneratorProvided

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Test
public void shouldJMetalRandomGeneratorNotBeUsedWhenCustomRandomGeneratorProvided() {
	// Configuration
	int solutionListSize = 3;
	int numberOfRandomNeighbours = 1;

	// Check configuration leads to use default generator by default
	final int[] defaultUses = { 0 };
	JMetalRandom defaultGenerator = JMetalRandom.getInstance();
	AuditableRandomGenerator auditor = new AuditableRandomGenerator(defaultGenerator.getRandomGenerator());
	defaultGenerator.setRandomGenerator(auditor);
	auditor.addListener((a) -> defaultUses[0]++);

	new AdaptiveRandomNeighborhood<>(solutionListSize, numberOfRandomNeighbours);
	assertTrue("No use of the default generator", defaultUses[0] > 0);

	// Test same configuration uses custom generator instead
	defaultUses[0] = 0;
	final int[] customUses = { 0 };
	new AdaptiveRandomNeighborhood<>(solutionListSize, numberOfRandomNeighbours, (a, b) -> {
		customUses[0]++;
		return new Random().nextInt(b-a+1)+a;
	});
	assertTrue("Default random generator used", defaultUses[0] == 0);
	assertTrue("No use of the custom generator", customUses[0] > 0);
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:27,代码来源:AdaptiveRandomNeighborhoodTest.java

示例12: shouldJMetalRandomGeneratorNotBeUsedWhenCustomRandomGeneratorProvidedInRouletteWheel

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
@Test
public void shouldJMetalRandomGeneratorNotBeUsedWhenCustomRandomGeneratorProvidedInRouletteWheel() {
	// Configuration
	AdaptiveGrid<Solution<?>> grid = new AdaptiveGrid<>(5, 2);

	// Check configuration leads to use default generator by default
	final int[] defaultUses = { 0 };
	JMetalRandom defaultGenerator = JMetalRandom.getInstance();
	AuditableRandomGenerator auditor = new AuditableRandomGenerator(defaultGenerator.getRandomGenerator());
	defaultGenerator.setRandomGenerator(auditor);
	auditor.addListener((a) -> defaultUses[0]++);

	grid.rouletteWheel();
	assertTrue("No use of the default generator", defaultUses[0] > 0);

	// Test same configuration uses custom generator instead
	defaultUses[0] = 0;
	final int[] customUses = { 0 };
	grid.rouletteWheel((a,b) -> {
		customUses[0]++;
		return new Random().nextDouble()*(b-a)+a;
	});
	assertTrue("Default random generator used", defaultUses[0] == 0);
	assertTrue("No use of the custom generator", customUses[0] > 0);
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:26,代码来源:AdaptiveGridTest.java

示例13: PlanningCrossoverOperator

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
/**
 * Constructor
 * @param problem the next release problem
 * @param crossoverProbability the probability to do crossover, between 0.0 and 1.0
 */
public PlanningCrossoverOperator(NextReleaseProblem problem, double crossoverProbability) {
	if (crossoverProbability < 0) {
		throw new JMetalException("Crossover probability is negative: " + crossoverProbability) ;
	}

	this.crossoverProbability = crossoverProbability;
	this.problem = problem;
	randomGenerator = JMetalRandom.getInstance() ;
}
 
开发者ID:supersede-project,项目名称:replan_optimizer_v2,代码行数:15,代码来源:PlanningCrossoverOperator.java

示例14: PlanningMutationOperator

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
/**
 * Constructor
 * @param problem The problem
 * @param mutationProbability The mutation probability between 0.0 and 1.0
 */
public PlanningMutationOperator(NextReleaseProblem problem, double mutationProbability) {
	if (mutationProbability < 0) {
		throw new JMetalException("Mutation probability is negative: " + mutationProbability) ;
	}
	
	this.numberOfTasks = problem.getFeatures().size();
	this.mutationProbability = mutationProbability;
	this.problem = problem;
	randomGenerator = JMetalRandom.getInstance() ;
}
 
开发者ID:supersede-project,项目名称:replan_optimizer_v2,代码行数:16,代码来源:PlanningMutationOperator.java

示例15: SMPSO

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入依赖的package包/类
/**
 * Constructor
 */
public SMPSO(DoubleProblem problem, int swarmSize, BoundedArchive<DoubleSolution> leaders,
             MutationOperator<DoubleSolution> mutationOperator, int maxIterations, double r1Min, double r1Max,
             double r2Min, double r2Max, double c1Min, double c1Max, double c2Min, double c2Max,
             double weightMin, double weightMax, double changeVelocity1, double changeVelocity2,
             SolutionListEvaluator<DoubleSolution> evaluator) {
  this.problem = problem;
  this.swarmSize = swarmSize;
  this.leaders = leaders;
  this.mutation = mutationOperator;
  this.maxIterations = maxIterations;

  this.r1Max = r1Max;
  this.r1Min = r1Min;
  this.r2Max = r2Max;
  this.r2Min = r2Min;
  this.c1Max = c1Max;
  this.c1Min = c1Min;
  this.c2Max = c2Max;
  this.c2Min = c2Min;
  this.weightMax = weightMax;
  this.weightMin = weightMin;
  this.changeVelocity1 = changeVelocity1;
  this.changeVelocity2 = changeVelocity2;

  randomGenerator = JMetalRandom.getInstance();
  this.evaluator = evaluator;

  dominanceComparator = new DominanceComparator<DoubleSolution>();
  localBest = new GenericSolutionAttribute<DoubleSolution, DoubleSolution>();
  speed = new double[swarmSize][problem.getNumberOfVariables()];

  deltaMax = new double[problem.getNumberOfVariables()];
  deltaMin = new double[problem.getNumberOfVariables()];
  for (int i = 0; i < problem.getNumberOfVariables(); i++) {
    deltaMax[i] = (problem.getUpperBound(i) - problem.getLowerBound(i)) / 2.0;
    deltaMin[i] = -deltaMax[i];
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:42,代码来源:SMPSO.java


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