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


Java JMetalRandom.getInstance方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: ABYSS

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入方法依赖的package包/类
public ABYSS(DoubleProblem problem, int maxEvaluations, int populationSize, int referenceSet1Size,
    int referenceSet2Size, int archiveSize, Archive<DoubleSolution> archive,
    LocalSearchOperator<DoubleSolution> localSearch,
    CrossoverOperator<DoubleSolution> crossoverOperator,
    int numberOfSubRanges) {

  setPopulationSize(populationSize);

  this.problem = problem ;
  this.maxEvaluations = maxEvaluations ;
  this.referenceSet1Size = referenceSet1Size ;
  this.referenceSet2Size = referenceSet2Size ;
  this.archiveSize = archiveSize ;
  this.archive = archive ;
  this.localSearch = localSearch ;
  this.crossover = crossoverOperator ;

  referenceSet1 = new ArrayList<>(referenceSet1Size) ;
  referenceSet2 = new ArrayList<>(referenceSet2Size) ;

  this.numberOfSubRanges = numberOfSubRanges ;

  randomGenerator = JMetalRandom.getInstance() ;

  sumOfFrequencyValues       = new int[problem.getNumberOfVariables()] ;
  sumOfReverseFrequencyValues = new int[problem.getNumberOfVariables()] ;
  frequency       = new int[numberOfSubRanges][problem.getNumberOfVariables()] ;
  reverseFrequency = new int[numberOfSubRanges][problem.getNumberOfVariables()] ;

  strengthRawFitness = new StrengthRawFitness<DoubleSolution>() ;
  fitnessComparator = new StrengthFitnessComparator<DoubleSolution>();
  marked = new MarkAttribute();
  distanceToSolutionListAttribute = new DistanceToSolutionListAttribute();
  crowdingDistanceComparator = new CrowdingDistanceComparator<DoubleSolution>();

  dominanceComparator = new DominanceComparator<DoubleSolution>();
  equalComparator = new EqualSolutionsComparator<DoubleSolution>();

  evaluations = 0 ;
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:41,代码来源:ABYSS.java

示例11: randomPermutation

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入方法依赖的package包/类
public static void randomPermutation(int[] perm, int size) {
  JMetalRandom randomGenerator = JMetalRandom.getInstance() ;
  int[] index = new int[size];
  boolean[] flag = new boolean[size];

  for (int n = 0; n < size; n++) {
    index[n] = n;
    flag[n] = true;
  }

  int num = 0;
  while (num < size) {
    int start = randomGenerator.nextInt(0, size - 1);
    while (true) {
      if (flag[start]) {
        perm[num] = index[start];
        flag[start] = false;
        num++;
        break;
      }
      if (start == (size - 1)) {
        start = 0;
      } else {
        start++;
      }
    }
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:29,代码来源:MOEADUtils.java

示例12: StandardPSO2011

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param problem
 * @param objectiveId This field indicates which objective, in the case of a multi-objective problem,
 *                    is selected to be optimized.
 * @param swarmSize
 * @param maxIterations
 * @param numberOfParticlesToInform
 * @param evaluator
 */
public StandardPSO2011(DoubleProblem problem, int objectiveId, int swarmSize, int maxIterations,
                       int numberOfParticlesToInform, SolutionListEvaluator<DoubleSolution> evaluator) {
  this.problem = problem;
  this.swarmSize = swarmSize;
  this.maxIterations = maxIterations;
  this.numberOfParticlesToInform = numberOfParticlesToInform;
  this.evaluator = evaluator;
  this.objectiveId = objectiveId;

  weight = 1.0 / (2.0 * Math.log(2)); //0.721;
  c = 1.0 / 2.0 + Math.log(2); //1.193;
  changeVelocity = -0.5 ;

  fitnessComparator = new ObjectiveComparator<DoubleSolution>(objectiveId);
  findBestSolution = new BestSolutionSelection<DoubleSolution>(fitnessComparator);

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

  positionInSwarm = new GenericSolutionAttribute<DoubleSolution, Integer>();

  randomGenerator = JMetalRandom.getInstance() ;
  randomGenerator.setRandomGenerator(new ExtendedPseudoRandomGenerator(new JavaRandomGenerator()));

  bestFoundParticle = null;
  neighborhood = new AdaptiveRandomNeighborhood<DoubleSolution>(swarmSize, this.numberOfParticlesToInform);
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:40,代码来源:StandardPSO2011.java

示例13: ArrayDoubleSolution

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入方法依赖的package包/类
/**
 * Constructor
 */
public ArrayDoubleSolution(DoubleProblem problem) {
  this.problem = problem ;
  attributes = new HashMap<>() ;
  randomGenerator = JMetalRandom.getInstance() ;

  objectives = new double[problem.getNumberOfObjectives()] ;
  variables = new double[problem.getNumberOfVariables()] ;
  for (int i = 0; i < problem.getNumberOfVariables(); i++) {
    variables[i] = randomGenerator.nextDouble(getLowerBound(i), getUpperBound(i)) ;
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:15,代码来源:ArrayDoubleSolution.java

示例14: AbstractGenericSolution

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入方法依赖的package包/类
/**
 * Constructor
 */
protected AbstractGenericSolution(P problem) {
  this.problem = problem ;
  attributes = new HashMap<>() ;
  randomGenerator = JMetalRandom.getInstance() ;

  objectives = new double[problem.getNumberOfObjectives()] ;
  variables = new ArrayList<>(problem.getNumberOfVariables()) ;
  for (int i = 0; i < problem.getNumberOfVariables(); i++) {
    variables.add(i, null) ;
  }
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:15,代码来源:AbstractGenericSolution.java

示例15: shouldJMetalRandomGeneratorNotBeUsedWhenCustomRandomGeneratorProvided

import org.uma.jmetal.util.pseudorandom.JMetalRandom; //导入方法依赖的package包/类
@Test
public void shouldJMetalRandomGeneratorNotBeUsedWhenCustomRandomGeneratorProvided() {
	// Configuration
	double lowerBound = -1.0;
	double upperBound = 1.0;
	int value = 4;

	// 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 RepairDoubleSolutionAtRandom().repairSolutionVariableValue(value, lowerBound, upperBound);
	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 RepairDoubleSolutionAtRandom((a, b) -> {
		customUses[0]++;
		return new Random().nextDouble()*(b-a)+a;
	}).repairSolutionVariableValue(value, lowerBound, upperBound);
	assertTrue("Default random generator used", defaultUses[0] == 0);
	assertTrue("No use of the custom generator", customUses[0] > 0);
}
 
开发者ID:jMetal,项目名称:jMetal,代码行数:28,代码来源:RepairDoubleSolutionAtRandomTest.java


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