NSGA-II implementation - evolutionary-algorithm

I have studied about Non dominating sorting algorithtm (NSGA-II).
I want to use this multi objective optimization algorithm.
could anybody help me by addressing any free implementation of NSGA-II in java or matlab.
Thanks in advance

MOEA Framework is a a free and open source Java framework for Multiobjective Optimization. It has the largest collection of MOEAs of any library, including NSGA-I, NSGA-II, and NSGA-III.
I personally used it to implement and solve a Multi Objective Problem (MOP) for my Master's thesis and found it far superior to PyGMO (for python) and jMetal (in Java).
The following code demonstrates how to use the MOEA Framework API to run NSGA-II to solve the ZDT1 multiobjective problem:
import java.util.List;
import org.moeaframework.Executor;
import org.moeaframework.core.NondominatedPopulation;
import org.moeaframework.core.Solution;
public class NSGAIIExample {
public static void main(String[] args) {
// configure and run this experiment
NondominatedPopulation result = new Executor()
.withProblem("ZDT1")
.withAlgorithm("NSGAII")
.withMaxEvaluations(1000)
.distributeOnAllCores()
.run();
List<NondominatedPopulation> multiRuns = new Executor()
.withProblem("ZDT1")
.withAlgorithm("NSGAII")
.withMaxEvaluations(1000)
.distributeOnAllCores()
.runSeeds(3);
System.out.format("Obj1 Obj2%n");
for (Solution solution : result) {
System.out.format("%.5f\t%.5f%n", solution.getObjective(0),
solution.getObjective(1));
}
}
}

jMetal is the Java framework of MOEA, which NSGA-II is included in. The website is here.

This looks like what you want from Matlab
http://www.mathworks.co.uk/matlabcentral/fileexchange/10429-nsga-ii-a-multi-objective-optimization-algorithm
And here's one for Java:
http://ia-2008.googlecode.com/svn/trunk/TrabajoPracticoFinal/Implementacion/NSGA/src/jmetal/metaheuristics/nsgaII/NSGAII.java

Since it hasn't been mentioned so far: Jenetics
Jenetics is an advanced Genetic Algorithm, Evolutionary Algorithm and Genetic Programming library, respectively, written in modern day Java.
As of version 4.1.0 the jenetics.ext module offers classes for multi-objective problems. It also offers a NSGA2Selector, but (taken from the manual v4.3.0, p. 92):
Since the MOO classes are an extensions to the existing evolution Engine, the implementation doesn't exactly follow an established algorithm, like NSGA2 or SPEA2. The results and performance, described in the relevant papers, are therefore not directly comparable.
Nonetheless, this might reasonable alternative.

Have quickly read this thread and I haven't seen a mention of platEMO. Which is a matlab based optimisation platform that I have used a lot recently. The documentation and installation information can be found at:
https://github.com/BIMK/PlatEMO
It has a large amount of problems and algorithms (including NSGA-II) as standard.

Related

How do I use such a line in Kotlin?

I use Python, but I don't know how it works in Kotlin. This is an example
example => exec("""print("hello")""") output => hello
exec("""print("hello")""") output => hello
Kotlin supports JSR-223. You can use the jvm scripting engine to eval kts files.
val engine = ScriptEngineManager().getEngineByExtension("kts")
engine.eval("""print("hello")""")
You need JSR-223 library dependency. Refer to example
implementation("org.jetbrains.kotlin:kotlin-scripting-jsr223:$kotlinVersion")
Short answer: this isn't practical in Kotlin.
Technically, there may be ways, but they're likely to be far more trouble than they're worth; you're far better looking for a different approach to your problem.
Unlike a dynamic (‘scripting’) language like Python, Kotlin is statically-compiled. In the case of Kotlin/JVM, you run the Kotlin compiler to generate .class files with Java bytecode, which is then run by a JVM.
So if you really need to convert a string into code and run it, you'd have to find a way to ensure that a Kotlin compiler is available on the platform where your code is running (which it often won't be; compiled bytecode can run on any platform with a JVM, and most of those won't have Kotlin installed too). You'd then have to find a way to run the compiler; this will probably mean writing your source code out to a file, starting up the compiler program as a separate process (as I don't think there's an API for calling it directly), and checking the results. Then you'd have find the resulting bytecode and load into the JVM, which will probably mean setting up a separate classloader instance.
All of which is likely to be slow, fragile, and very awkward.
(See these previous questions which cover some of the same ground.)
(The details will be different for Kotlin/JS and Kotlin/Native, but I think the principles are roughly the same.)
In general, each computer language has its own approach, its own mind-set and ways of doing things, and it's best to try to understand that and accept that patterns and techniques from one language don't always translate well into another. (In the Olden Days™, it used to be said that a determined programmer could write FORTRAN programs in any language — but only in satire.)
Perhaps if you could explain why you want to do this, and what sort of problem you're trying to solve (probably as a separate question), we might be able to suggest more natural solutions in Kotlin.

Is there a way to find where the internal classes are moved

We are migrating our application from Eclipse Indigo to Photon and I need help find a solution or alternate for a particular class which is present in Indigo but not in Photon.
The class we are trying to figure out is org.eclipse.ui.internal.navigator.AdaptabilityUtility.
Since it is an Internal class it is not available. But we had no luck finding an alternate.
Only one function of the class is used :
IAdaptable openable = (IAdaptable) AdaptabilityUtility.getAdapter(
selection.getFirstElement(), IResource.class);
If someone knows an alternative method which can be used here, it will be a great help.
Eclipse internals were completely rewritten for Eclipse 4 so in general there may not be exact alternatives for internal classes which were never part of the official API.
However for AdaptabilityUtility it looks like the current org.eclipse.core.runtime.Adapters class should work:
IResource resource = Adapters.adapt(selection.getFirstElement(), IResource.class);
Adapters.adapt uses generics so casts are not needed. Adapters is not internal so it is an official API.

User-specified function in mpfit

I have been an IDL programmer for sometime now and looking to transition to Python. I find that MPFIT's IDL version exists in Python. However, I am looking for MPFITFUN version in Python (http://www.physics.wisc.edu/~craigm/idl/down/mpfitfun.pro) or something similar.
Basically, I am looking for a Python function that takes a user-defined function and uses like Levenberg-Marquardt least-squared fit (like MPFIT).
Thanks,
There are fitting functions built into SciPy but I do not know of any which account for uncertainties in data as MPFITFUN does.
I have found Sherpa to be an excellent modeling and fitting package for Python which accounts for uncertainties and replaces MPFITFUN: http://cxc.harvard.edu/contrib/sherpa/
Since Sherpa is produced by astronomers it has a lot of built in astrophysical models, but you can build your own function to fit with Sherpa's Levenberg-Marquardt, Nelder-Mead or Monte Carlo algorithms. I used the template from the pysherpa blog:
http://pysherpa.blogspot.com/2010/06/user-defined-sherpa-model-types-using.html
mpfit.py is available from https://code.google.com/p/astrolibpy/ and an older version hosted at http://cars.uchicago.edu/software/python/mpfit.html.
A good alternative is lmfit: https://pypi.python.org/pypi/lmfit/, https://github.com/lmfit/lmfit-py, http://lmfit.github.io//lmfit-py/
I accidentally found that there also exists the MPFITEXPR in Python. Here's the link to the code. You can also download it via Astrolibpy project.
Link:
https://code.google.com/p/astrolibpy/source/browse/mpfit/mpfitexpr.py?r=3545675a0662392e3e09c88beaf275c9e7881cf6

how to get knowing more about a class behaviour without looking at its manual?(a fundamental question about how to dive more into OOP)

I'm practicing OOP for 2 years (for real) and I know how to consume objects and packages and I'm developing stuffs mostly using C# .
but I have a problem with consuming unknown objects and packages as an instance :
for now I am working on an enterprise like website and for part of our job we need to consume RSS. I decided to use "System.Xml.Xpath"
and my real problem is:
for using system.xml.xpath I should look at manual and read it carefully and I don't want to do that every time.A plain example of that is like following code :
XPathDocument xp = new XPathDocument(sites[2]);
XPathNavigator nav = xp.CreateNavigator();
XPathNodeIterator it = nav.Select(xpath3);
foreach (XPathNavigator n in it)
{
//get elements here
}
//another way of iterating elements is
while(it.movenext())
{
//it.current.Value;
}
for the "foreeach" part I got it from MSDN manual and I guess I could get this simple fact by looking at class structure.
but I don't know which structure I should look.
I know how to read tooltips and I'm familiar with things like : [] / collection / enum /generic / Ienumerable / Idisposable etc...
but I think there is something about reading class behaviors and I'm missing that part.
for make it more lucid :
I know whenever we have a class that inherited from IEnumerable so we can use foreach statement against that class to iterate it through
my real problem is I think classes are self described enough to not to look at manuals all the time but I don't know how/where to read those descriptions of classes so I need your advice to get more familiar with how to reading classes without looking at manuals.
best regards.
Classes can (and should) be documented with source code comments, and in many languages you can generate API documentation from these comments (in HTML, XML or other format). In Java it is called Javadoc; I don't know the C# term. If this is what you call "manual", then this is your primary source of information. Other than reading the source code comments and the code itself (which you often don't have access to, especially in the MS universe). If you don't find enough information in the API documentation, you can always try googling for more explanation, tutorials or usage examples.
Hope this helps; I am not entirely sure I understood your question though. If this is not the answer you are looking for, please clarify.

Has anyone created any cool rules for FxCop/StyleCop?

I'm just looking for some inspiration. Especially in the area of performance and security, naming conventions are important but not as 'cool' ;)
Even if your rule was only applicable to your domain/project but demonstrates how powerful a rule can be, please let me know.
I work with C#, but I'm interested in rules for any language.
In my experience, the developers that have started out creating custom rule sets for FxCop, usually give up after pulling out much hair. It seems like a great idea, but the pain is just not worth the effort.
An alternative to the mess of writing FxCop custom rules would be to use the commercial tool NDepend. With this tool one can write Code Rule over LINQ Queries (namely CQLinq). Disclaimer: I am one of the developers of the tool
More than 200 code rules are proposed by default, these include naming conventions, design, architecture, code quality, code evolution, dead code, .NET Fx usage...
CQLinq is dedicated to write code rules that can be verified live in Visual Studio, or that can be verified during build process and reported in an HTML/javascript report.
The strength of CQLinq over FxCop API or other tools, is that it is straightforward to write a code rule, and get immediately results. Facilities are proposed to browse matched code elements. Concretely this looks like that:
I've got a nice functioning base with 2 rules so far at breusable.codeplex.com under the fxcop directory
ConfigKeyExistsInConfig (make sure that any references to ConfigurationManager with a magic string key actually exists in the config file.
NoUnderscoresInProperties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.FxCop.Sdk;
namespace RulesByImaginaryDevelopment
{
public class NoUnderscoresInProperties : BaseRule
{
public NoUnderscoresInProperties() : base("NoUnderscoresInProperties") { }
public override ProblemCollection Check(Member member)
{
var prop = member as PropertyNode;
if(prop==null)
return Problems;
if(prop.Name.Name.Contains("_"))
{
Problems.Add(new Problem(new Resolution("Remove any '_' from name "+prop.Name.Name)));
}
return Problems;
}
}
}
Also http://msdn.microsoft.com/en-us/magazine/cc163930.aspx