Create new problem with MOEA
A Free and Open Source Java Framework for Multiobjective Optimization
Brought to you by:
dhadka
Hi I am new user of MOEA, I would like to use NSGAII for generating rules to evaluate interface. I have two objective : detect the maximum of problem and using minimum number of rules. I tried to difine new problem but I am not getting the correct solution yet.Can any one help me to define my own new problem and use it with the NSGAII.
Problem
Exception in thread "main" org.moeaframework.core.FrameworkException: java.lang.NoSuchMethodException: No such accessible constructor on object: org.moeaframework.examples.ga.EvaluationRule.Myprob at org.moeaframework.ProblemBuilder.getProblemInstance(ProblemBuilder.java:296) at org.moeaframework.Executor.runSingleSeed(Executor.java:657) at org.moeaframework.Executor.run(Executor.java:629) at org.moeaframework.examples.ga.EvaluationRule.evaluate.main(evaluate.java:55) Caused by: java.lang.NoSuchMethodException: No such accessible constructor on object: org.moeaframework.examples.ga.EvaluationRule.Myprob at org.apache.commons.lang3.reflect.ConstructorUtils.invokeConstructor(ConstructorUtils.java:121) at org.apache.commons.lang3.reflect.ConstructorUtils.invokeConstructor(ConstructorUtils.java:88) at org.moeaframework.ProblemBuilder.getProblemInstance(ProblemBuilder.java:287) ... 3 more
I apperciate any suggestions and help.
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
I believe the problem is the Myprob class is nested within the EvaluationRule class. Ensure the Myprob class is public and static:
public static class Myprob ... {
}
If this is unable to resolve the issue, please post the code if able. Thanks!
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
thanks a lot for responding, I tried to use pablic and static claas but it also caused a problem
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Ok, replace the first two lines:
~~~~~~~
public class Myprob implements Problem {
public Myprob(int numberOfVariables, int numberOfObjectives) {
public static class Myprob implements Problem {
public Myprob() {
~~~~~~
By default, it's looking for the empty constructor,
Myprob()
. Since it doesn't appear you use the two arguments, they can be removed.If you do require arguments, then you will need to pass those arguments to the Executor, such as
new Executor().withProblemClass(Myprob.class, 10, 5)
, so it can call the appropriate constructor.View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Sorry, but when I use static it make this error : Illegal modifier for the class Myprob; only public, abstract & final are permitted
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Ok, try it without the static modifier. Hopefully it works with the empty constructor.
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
I tried it but always the same problem
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
I'm not sure what's happening then. Can you please post the Myprob.java file and any other files needed to run this problem (such as the file containing your main method)? (Use the Add attachments link to include any file attachments).
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Thanks a lot for your feedback, I think this attached files can help you to understand what I do.
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Try the following. When you are running the Executor, you are passing in the argument
S.create_rules(...)
with typeArrayList<Rule>
:You'll need to have a corresponding constructor in Myprob.java to input this argument:
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Thanks a lot this problem is solve. But I dont understand who MOEA can do crossover, mutation... automatically. I create my own fitness function but I dont know when you should put it. I dont understand very well steps necessary to customize MOEA, Please you Can explain that??
The result now is
Solution 1:
Number of problem -8.0
Number of rules -0.0
Rules: 10101110
In Rules: I need to display My rules (String)
Last edit: Anonymous 2015-07-02
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
The genetic operators are based on the type of your decision variables. Since you are using a binary representation, the MOEA Framework by default uses Half-uniform crossover (HUX) and bit-flip mutation. Refer to the OperatorFactory for more details on the available operators.
You can customize the MOEA by changing the algorithm's parameters. Use the Executors's
withProperty
method to achieve this:See Chapter 9 in the user manual and the OperatorFactory documentation for more details on the available parameters.
If you're looking for more customization, you will need to dive into the code. To start, I would suggest looking at the src/org/moeaframework/algorithm/NSGAII.java file to see how a basic MOEA is implemented.
Good luck!
Last edit: Anonymous 2015-07-02
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
It is necessary to use binary representation with MOEA??
Thanks!
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
No, the MOEA Framework supports real, binary, permutation, grammar, and program representations. Refer to this table to see which representations are supported by each algorithm.
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi, I try to use Grammar representation because I need to generate rules :
IF A and B then Prob i
I evaluate the derivation using the Groovy scripting language but I have problem. Please find the attached files.
The problem is that i'm getting the following error:
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Please I need your help, Can any one help me???
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Hi, I see two issues in the files posted. First, it doesn't appear to be generating valid Groovy code. According to http://www.groovy-lang.org/semantics.html, the
<rule>
should be:Second, whenever you see an exception saying
No such property: M
, it is indicating that one of the variables in the Groovy code is undefined. In this example, the variableM
is missing. The bindings for these variables must be set:View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
what's wrong with this part ?? result is emplty
ScriptEngineManager sem = new ScriptEngineManager();
ScriptEngine engine = sem.getEngineByName("JAVASCRIPT");
// initialize the variables used by the program
Bindings b = new SimpleBindings();
b.put("Cont", Input.Context()[source_index0]);
b.put("level", Input.ValuesOfContext( [source_index3]);
b.put("metr", Input.Metrics()[source_index1]);
b.put("operator", Input.Operator()[source_index4]);
b.put("source_index", number_generator.nextDouble());
b.put("prob", Input.Problem()[source_index2]);
try {
result = ((String)engine.eval(program, b)).toString();
// System.out.println("######"+result);
} catch (ScriptException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Last edit: Anonymous 2015-07-08
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
Not 100% sure, but my guess is that since your expression is
if (A and B) then C
, it only returns a result,C
, when conditionsA
andB
are satisfied. If not satisfied, it returnsnull
.View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
I tried to solve my problem with Jmetal (for mono-objective algorithm), but I need to use multi-objective algorithm, I heard about MOEA So I tried tu use it for the same problem with NSGA2.
I need to generate this rules :
IF (Interest=L) and ( Simplicity<0.14395609003413368 ) THEN ( Problem6 )
IF (Age=H) and ( Symmetry<=0.9696987668669881 ) THEN ( Problem5 )
IF (User Experience=M) and ( Unity>=0.6906152578571493 ) THEN ( Problem4 )
IF (Education Level=L) and ( Regularity<=0.29971648662249517 ) THEN ( Problem5 )
IF (User Experience=H) and ( Sequence>0.6977428629106479 ) THEN ( Problem4 )
IF (Age=H) and ( Regularity<=0.4017929040344044 ) THEN ( Problem5 )
IF (Motivation=M) and ( Simplicity<0.645669980192507 ) THEN ( Problem2 )
IF (User Experience=L) and ( Symmetry>0.7240407949705044 ) THEN ( Problem4 )
IF (Education Level=H) and ( Grouping<=0.9733628578631573 ) THEN ( Problem5 )
IF (User Experience=M) and ( Simplicity<0.256567413247895 ) THEN ( Problem5 )
In my case individual is :
IF (Interest=L) and ( Simplicity<0.14395609003413368 ) THEN ( Problem6 )
For this reason I choose Grammar representation to define my individuals and use it with NSAG2 algorithm.
I need to generate set of perfect rules which detect maximum of problem.
With Jmetal I generate this rules automatically and randomly then I choose the perfect rules (by using fitness function). Please , is it possible to solve this problem with MOEA ??? Grammar repsentation Let me to difine and generate this rule automacally ?? Please I don't know If I'm in the right way or no ??
View and moderate all "feature-requests Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Feature Requests"
You can definitely use the grammar representation to define these rules. However, it sounds like you already have this working in JMetal. JMetal also supports multi-objective algorithms, so you may be better off using JMetal's NSGA-II implementation since you already have working code there.