Created
June 7, 2018 04:58
-
-
Save Mackaber/9ae39c81f1f3df36fbecac2f65360650 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Load the Libraries" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"method": "display_data" | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"method": "display_data" | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"method": "display_data" | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"method": "display_data" | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"null" | |
] | |
}, | |
"execution_count": 15, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"%classpath add mvn org.uma.jmetal jmetal-problem 5.5.2\n", | |
"%classpath add mvn org.uma.jmetal jmetal-algorithm 5.5.2\n", | |
"%classpath add mvn org.uma.jmetal jmetal-core 5.5.2\n", | |
"%classpath add mvn org.uma.jmetal jmetal-exec 5.5.2" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 31, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"2018-06-06 18:57:33.209 INFO: Total execution time: 329ms [java_util_logging_Logger$info call]\n", | |
"2018-06-06 18:57:33.220 INFO: Random seed: 1528328086276 [org.uma.jmetal.util.AbstractAlgorithmRunner printFinalSolutionSet]\n", | |
"2018-06-06 18:57:33.221 INFO: Objectives values have been written to file FUN.tsv [org.uma.jmetal.util.AbstractAlgorithmRunner printFinalSolutionSet]\n", | |
"2018-06-06 18:57:33.222 INFO: Variables values have been written to file VAR.tsv [org.uma.jmetal.util.AbstractAlgorithmRunner printFinalSolutionSet]\n", | |
"2018-06-06 18:57:33.265 INFO: \n", | |
"Hypervolume (N) : 0.6591029563900322\n", | |
"Hypervolume : 0.6591029563900322\n", | |
"Epsilon (N) : 0.022189062196556447\n", | |
"Epsilon : 0.022189062196556447\n", | |
"GD (N) : 2.516643536978127E-4\n", | |
"GD : 2.516643536978127E-4\n", | |
"IGD (N) : 1.9949739919128336E-4\n", | |
"IGD : 1.9949739919128336E-4\n", | |
"IGD+ (N) : 0.003977393959358172\n", | |
"IGD+ : 0.003977393959358172\n", | |
"Spread (N) : 0.35686361940604666\n", | |
"Spread : 0.35686361940604666\n", | |
"Error ratio : 1.0\n", | |
" [org.uma.jmetal.util.AbstractAlgorithmRunner printQualityIndicators]\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"null" | |
] | |
}, | |
"execution_count": 31, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import org.uma.jmetal.algorithm.Algorithm;\n", | |
"import org.uma.jmetal.algorithm.multiobjective.nsgaii.NSGAIIBuilder;\n", | |
"import org.uma.jmetal.operator.CrossoverOperator;\n", | |
"import org.uma.jmetal.operator.MutationOperator;\n", | |
"import org.uma.jmetal.operator.SelectionOperator;\n", | |
"import org.uma.jmetal.operator.impl.crossover.SBXCrossover;\n", | |
"import org.uma.jmetal.operator.impl.mutation.PolynomialMutation;\n", | |
"import org.uma.jmetal.operator.impl.selection.BinaryTournamentSelection;\n", | |
"import org.uma.jmetal.problem.Problem;\n", | |
"import org.uma.jmetal.solution.DoubleSolution;\n", | |
"import org.uma.jmetal.util.AbstractAlgorithmRunner;\n", | |
"import org.uma.jmetal.util.AlgorithmRunner;\n", | |
"import org.uma.jmetal.util.JMetalException;\n", | |
"import org.uma.jmetal.util.JMetalLogger;\n", | |
"import org.uma.jmetal.util.ProblemUtils;\n", | |
"import org.uma.jmetal.util.comparator.RankingAndCrowdingDistanceComparator;\n", | |
"import org.uma.jmetal.util.front.Front;\n", | |
"import org.uma.jmetal.util.front.imp.ArrayFront;\n", | |
"\n", | |
"problemName = \"org.uma.jmetal.problem.multiobjective.zdt.ZDT1\";\n", | |
"referenceParetoFrontFile = \"ZDT1.pf\";\n", | |
"\n", | |
"problem = ProblemUtils.loadProblem(problemName);\n", | |
"\n", | |
"crossoverProbability = 0.9 ;\n", | |
"crossoverDistributionIndex = 20.0 ;\n", | |
"crossover = new SBXCrossover(crossoverProbability, crossoverDistributionIndex) ;\n", | |
"\n", | |
"mutationProbability = 1.0 / problem.getNumberOfVariables() ;\n", | |
"mutationDistributionIndex = 20.0 ;\n", | |
"mutation = new PolynomialMutation(mutationProbability, mutationDistributionIndex) ;\n", | |
"\n", | |
"selection = new BinaryTournamentSelection<DoubleSolution>(\n", | |
" new RankingAndCrowdingDistanceComparator<DoubleSolution>());\n", | |
"\n", | |
"algorithm = new NSGAIIBuilder<DoubleSolution>(problem, crossover, mutation)\n", | |
" .setSelectionOperator(selection)\n", | |
" .setMaxEvaluations(25000)\n", | |
" .setPopulationSize(100)\n", | |
" .build() ;\n", | |
"\n", | |
"algorithmRunner = new AlgorithmRunner.Executor(algorithm)\n", | |
" .execute() ;\n", | |
"\n", | |
"population = algorithm.getResult() ;\n", | |
"computingTime = algorithmRunner.getComputingTime() ;\n", | |
"\n", | |
"JMetalLogger.logger.info(\"Total execution time: \" + computingTime + \"ms\");\n", | |
"\n", | |
"AbstractAlgorithmRunner.printFinalSolutionSet(population);\n", | |
"if (!referenceParetoFrontFile.equals(\"\")) {\n", | |
" AbstractAlgorithmRunner.printQualityIndicators(population, referenceParetoFrontFile);\n", | |
"}" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 34, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "0d71c0bf-ba91-4e6a-b1df-1ddf8b233f78", | |
"version_major": 2, | |
"version_minor": 0 | |
}, | |
"method": "display_data" | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"null" | |
] | |
}, | |
"execution_count": 34, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"import org.uma.jmetal.util.front.Front;\n", | |
"import org.uma.jmetal.util.front.imp.ArrayFront;\n", | |
"\n", | |
"//String referenceParetoFront = \"jMetal/jmetal-core/src/main/resources/pareto_fronts/ZDT1.pf\";\n", | |
"referenceFront = new ArrayFront(referenceParetoFrontFile);\n", | |
"points = new Points();\n", | |
"\n", | |
"// Esta es la magia, básicamente se hacen 2 listas y se ponen los puntos x y y en cada una\n", | |
"// También cabe destacar que los frentes de pareto pueden ser multidimensionales! :P \n", | |
"\n", | |
"xList = new ArrayList();\n", | |
"yList = new ArrayList();\n", | |
"\n", | |
"for(int i = 0;i<referenceFront.getNumberOfPoints();i++) {\n", | |
" xList.add(referenceFront.getPoint(i).getValues()[0]);\n", | |
"}\n", | |
"\n", | |
"for(int i = 0;i<referenceFront.getNumberOfPoints();i++) {\n", | |
" yList.add(referenceFront.getPoint(i).getValues()[1]);\n", | |
"} \n", | |
" \n", | |
"points.setX(xList);\n", | |
"points.setY(yList);\n", | |
"\n", | |
"plot = new Plot();\n", | |
"plot.add(points);\n", | |
"plot.display();" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 32, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"ZDT1.pf" | |
] | |
}, | |
"execution_count": 32, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"referenceParetoFrontFile" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 28, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Your Mom!" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"null" | |
] | |
}, | |
"execution_count": 28, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"print(yourmom)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Groovy", | |
"language": "groovy", | |
"name": "groovy" | |
}, | |
"language_info": { | |
"codemirror_mode": "groovy", | |
"file_extension": ".groovy", | |
"mimetype": "", | |
"name": "Groovy", | |
"nbconverter_exporter": "", | |
"version": "2.4.3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment