Coder Social home page Coder Social logo

um-lpm / ears Goto Github PK

View Code? Open in Web Editor NEW
18.0 18.0 19.0 214.2 MB

EARS is a free and open-source Java-based framework for ranking, developing, and experimenting with single- and multi-objective evolutionary algorithms

License: GNU General Public License v3.0

Java 100.00%
evolutionary-algorithms framework metaheuristic-framework optimization optimization-algorithm optimization-problem ranking rating-system

ears's People

Contributors

galme avatar lpm-user avatar mihael-mika avatar mir1001 avatar ravby avatar smidmarko avatar zskamljic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ears's Issues

Update single objective intervals for example in ProblemSphere

upperLimit = new ArrayList(Collections.nCopies(numberOfDimensions, 200.0));
->upperLimit = new ArrayList(Collections.nCopies(numberOfDimensions, 100.0));

public ProblemSphere(int d) {
super(d,0);

    lowerLimit = new ArrayList<Double>(Collections.nCopies(numberOfDimensions, -100.0));
    upperLimit = new ArrayList<Double>(Collections.nCopies(numberOfDimensions, 200.0));

    name = "Sphere";
}

java.lang.IllegalArgumentException: Comparison method violates its general contract

Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(Unknown Source)
	at java.util.TimSort.mergeAt(Unknown Source)
	at java.util.TimSort.mergeForceCollapse(Unknown Source)
	at java.util.TimSort.sort(Unknown Source)
	at java.util.Arrays.sort(Unknown Source)
	at java.util.ArrayList.sort(Unknown Source)
	at java.util.Collections.sort(Unknown Source)
	at org.um.feri.ears.benchmark.RatingBenchmark.setWinLoseFromResultList(RatingBenchmark.java:161)
	at org.um.feri.ears.benchmark.RatingBenchmark.run(RatingBenchmark.java:219)
	at MainBenchMarkTest.TEST_ALGO(MainBenchMarkTest.java:53)
	at MainBenchMarkTest.main(MainBenchMarkTest.java:88)

When running the following configuration I get this exception printed above. (It takes some time, but it will be 100% reproducible)

TEST_ALGO(5, 10, 70, 75, 1508185232848L, 2);
public static void TEST_ALGO(int from_f, int to_f, int from_c, int to_c, long seed, int repeat)
	{
		System.out.println("seed: "+seed);
		Util.rnd.setSeed(seed);

		ArrayList<Algorithm> players = new ArrayList<Algorithm>();
		players.add(new DEE007(10,0.7,0.89,"CrepA"));
		players.add(new DEE007(10,0.71,0.79,"CrepB"));
		if(true)
		{
			for(int pop = 10; pop <= 100; pop += 10)
			{
				for(int c = from_c; c <= to_c; c+=1)
				{
					for(int f = from_f; f <= to_f; f+=1)
					{
						double cParam = c/100.0d;
						double fParam = f/100.0d;
						if(cParam > 1)
							cParam = 1;
						if(fParam > 1)
							fParam = 1;
						String aname = "{{"+Integer.toString(pop)+","+Double.toString(cParam)+","+Double.toString(fParam)+"}}";
					    Algorithm algorithm = new DEE007(pop, cParam, fParam, "new_Dominik"+aname);
					    players.add(algorithm);
					}
				}
			}
		}
		ResultArena ra = new ResultArena(100);
		RatingRPUOed2 suopm = new RatingRPUOed2(); //Create banchmark
		suopm.setDisplayRatingIntervalChart(false);
		for (Algorithm al:players) {
		    ra.addPlayer(al.getID(), 1500, 350, 0.06,0,0,0); //init rating 1500
		    suopm.registerAlgorithm(al);
		}
		BankOfResults ba = new BankOfResults();
		suopm.run(ra, ba, repeat); 
		ArrayList<Player> list = ra.recalcRatings();
		//for(int i=0;i < 10 && i < list.size();i++) {
			System.out.println(list.get(0)); //print rangs
		//}
	}

import java.util.ArrayList;

import org.um.feri.ears.algorithms.Algorithm;
import org.um.feri.ears.algorithms.AlgorithmInfo;
import org.um.feri.ears.algorithms.Author;
import org.um.feri.ears.problems.DoubleSolution;
import org.um.feri.ears.problems.StopCriteriaException;
import org.um.feri.ears.problems.Task;
import org.um.feri.ears.util.Util;

public class DEE007 extends Algorithm {
    int pop_size;
    double CR, F;
	ArrayList<DoubleSolution> pop;
	DoubleSolution best;
	//Initialize all agents {\displaystyle \mathbf {x} } \mathbf {x}  with random positions in the search-space.
	public DEE007(int ps, double CR, double F, String s) {
		pop_size = ps;
		this.CR = CR;
		this.F = F;
		ai = new AlgorithmInfo("","",s,s);  //EARS add algorithm name
		au =  new Author("E007", "N/A"); //EARS author info

	}
	public void init(Task taskProblem) throws StopCriteriaException {
		pop = new ArrayList<>();
		DoubleSolution tmp;
		for (int i=0; i<pop_size;i++) {
			if (taskProblem.isStopCriteria()) break;
			tmp = taskProblem.getRandomSolution();
			if (i==0) best = tmp;
			else if (taskProblem.isFirstBetter(tmp, best)) best = tmp;
			pop.add(tmp);
		}
	   	
	}
	
	@Override
	public DoubleSolution execute(Task taskProblem) throws StopCriteriaException {
		init(taskProblem);
		int a, b, c, R;
		DoubleSolution yEval;
		while (!taskProblem.isStopCriteria()) {
			for (int i=0; i<pop_size;i++) {
				if (taskProblem.isStopCriteria()) break;
				do 
				  a = Util.rnd.nextInt(pop_size);
				while (a==i);
				do 
					  b = Util.rnd.nextInt(pop_size);
				while ((b==i)||(b==a));
				do 
					  c = Util.rnd.nextInt(pop_size);
				while ((c==i)||(c==a)||(c==b));
				R = Util.rnd.nextInt(taskProblem.getNumberOfDimensions());
				double y[] = new double[taskProblem.getNumberOfDimensions()];
				for (int j=0; j<taskProblem.getNumberOfDimensions(); j++) {
					if ((Util.nextDouble()<CR) || (j==R)) {
						y[j] = taskProblem.setFeasible(pop.get(a).getDoubleVariables()[j]+F*(pop.get(b).getDoubleVariables()[j]-pop.get(c).getDoubleVariables()[j]),j);
					} else y[j] = pop.get(i).getDoubleVariables()[j];
				}
				yEval = taskProblem.eval(y);
				if (taskProblem.isFirstBetter(yEval, pop.get(i))){
					pop.set(i, yEval);
					if (taskProblem.isFirstBetter(yEval, best)) best = yEval;
				}
			}
		}
		return best;
	}

	@Override
	public void resetDefaultsBeforNewRun() {
		// TODO Auto-generated method stub
		
	}

}

Build system

I have problems building this project, because some tools do not recognize this project correctly. Please use some build tool like Gradle to ease the problem of project initialization and project building.

Cannot find symbol

Cannot find symbol:

  • Symbol: method addDummyTask(java.lang.String)
  • Location: (318, 27), variable dr of type org.um.feri.ears.benchmark.DummyRating

TaskComparator.compare throws NullPointerException

When testing the example (from project readme) - MainBenchMarkTest - the program sometimes randomly crashed. This issue can be 100% reproduced if random seed at the beginning of main body is set to 3
( Util.rnd.setSeed(3) ).

Missing methods and different return types

The error is reported in org.um.feri.ears.engine.GenerateBenchmarksFile. As far as I can see the following is missing:

  • getNumberOfRuns()
  • getStopCriteria()
  • getStopCondition()
  • getProblems()

RatingRPUOed2 returns a different value than expected in org.um.feri.ears.engine.BenchmarkRunner, it returns TaskBase instead of Task

DoubleMOTask task problem

  • Error example 1
    import org.um.feri.ears.algorithms.moo.demo.D_DEMO
    ...
    val moead = new D_MOEAD(1000)
    val demo = new D_DEMO(1000, 1)
    ...
    val task = new DoubleMOTask(EnumStopCriteria.ITERATIONS, 10000, 10000, 10000, 0.000001, myProblem);
    ...
    val r_moead = moead.execute(task)
    val r_demo = demo.execute(task)
    
    Returns:
    Exception in thread "main" java.lang.NullPointerException
      at org.um.feri.ears.util.Ranking.<init>(Ranking.java:71)
      at org.um.feri.ears.algorithms.MOAlgorithm.execute(MOAlgorithm.java:188)
    
  • Error example 2
    import org.um.feri.ears.algorithms.moo.demo.D_DEMO
    ...
    val moead = new D_MOEAD(1000)
    val demo = new D_DEMO(1000, 1)
    ...
    val task = new DoubleMOTask(EnumStopCriteria.ITERATIONS, 10000, 10000, 10000, 0.000001, myProblem);
    ...
    val r_demo = demo.execute(task)
    val r_moead = moead.execute(task)
    
    Returns:
    Exception in thread "main" java.lang.IndexOutOfBoundsException: Index out of Bound 928
      at org.um.feri.ears.problems.moo.ParetoSolution.get(ParetoSolution.java:155)
      at org.um.feri.ears.algorithms.moo.moead.MOEAD.start(MOEAD.java:208)
      at org.um.feri.ears.algorithms.moo.moead.D_MOEAD.start(D_MOEAD.java:28)
      at org.um.feri.ears.algorithms.MOAlgorithm.execute(MOAlgorithm.java:184)
    

RatingBenchmark comparator can crash when there are many players

Under certain circumstances, RatingBenchmark can crash when there are many competing players with this exception:

Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeLo(TimSort.java:777)
	at java.util.TimSort.mergeAt(TimSort.java:514)
	at java.util.TimSort.mergeCollapse(TimSort.java:441)
	at java.util.TimSort.sort(TimSort.java:245)
	at java.util.Arrays.sort(Arrays.java:1512)
	at java.util.ArrayList.sort(ArrayList.java:1454)
	at java.util.Collections.sort(Collections.java:175)
	at org.um.feri.ears.benchmark.RatingBenchmark.setWinLoseFromResultList(RatingBenchmark.java:164)
	at org.um.feri.ears.benchmark.RatingBenchmark.run(RatingBenchmark.java:222)
	at CrashTest.main(CrashTest.java:38)

Code to reproduce:
(Slightly modified code of the MainBenchmarkTest example that just adds single algorithm 100x to simulate many players)

Util.rnd.setSeed(20);

ArrayList<Algorithm> players = new ArrayList<Algorithm>();
for (int i = 0; i < 100; i++) {
    Algorithm algorithm = new ES1p1sAlgorithm();
    // Give each instance different name, so they don't clash.
    algorithm.setAlgorithmInfo(new AlgorithmInfo("", "", Integer.toString(i), ""));
    players.add(algorithm);
}

ResultArena ra = new ResultArena(100);
RatingRPUOed2 suopm = new RatingRPUOed2(); //Create banchmark
suopm.setDisplayRatingIntervalChart(false);
for (Algorithm al:players) {
    ra.addPlayer(al.getID(), 1500, 350, 0.06,0,0,0); //init rating 1500
    suopm.registerAlgorithm(al);
}
BankOfResults ba = new BankOfResults();
suopm.run(ra, ba, 20); //repeat competition 20X

Quality indicators reference points

  • Resources
    Class QualityIndicator in package org.um.feri.ears.qualityIndicator should use ClassLoader.getResource(path_to_file_in_package)); in lines 148 and 162.
  • Reference points for other problems/tasks
    I would like to see the quality of two pareto fronts from two different MOO algorithms that where run on my problem/task. Some indicators have this options, because they are binary comparison. Indicators that use unary comparison do not have this option.

CPU Stop criteria for single run is not working!

In case of:

public class Main4Run {

public static void main(String[] args) {
	Task t = new Task(EnumStopCriteria.CPU_TIME, 5000, 1000, 0, 0.0001, new Sphere(5)); //run problem Sphere Dimension 5, 3000 evaluations
	RandomWalkAlgorithm test = new RandomWalkAlgorithm();
	try {
		System.out.println(test.execute(t)); //prints best result afrer 3000 runs
	} catch (StopCriteriaException e) {
		e.printStackTrace();
	}
}

}
CPU Time is not working for single run!

Constraints definition

I would like to have an option to set a constraint as a function. Constraint function should be defined as c(A: Array[Type]) -> Type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.