The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
missing equals() for class Example
Legacy User
Member Posts: 0 Newbie
Hello,
During implementation of a new operator I would like to compute the epsilon environment of an example. I implemented the following code:
Thanks,
Robert
During implementation of a new operator I would like to compute the epsilon environment of an example. I implemented the following code:
The problem is that the example itself is always added to the result list, although I check for == and equals():
private List<Example> getEpsilonEnvironment(final Example example, final ExampleSet exampleSet) {
final List<Example> result = new LinkedList<Example>();
log.logNote("EPSILON-ENVIRONMENT FOR " + example);
for (final Example other: exampleSet) {
log.logNote(" TESTING " + other);
/*
* add all (other!) examples which are closer than epsilon
*/
if (!(example == other || example.equals(other)) && distance(example, other) < epsilon) {
result.add(other);
log.logNote(" ADDED!");
}
}
log.logNote("RESULT: " + result);
return result;
}
How can I assure not to add the example to the environment? Is there a way to check the identity of examples?
[NOTE] EPSILON-ENVIRONMENT FOR 5.1 3.5 1.4 0.2 1.0
[NOTE] TESTING 5.1 3.5 1.4 0.2 1.0
[NOTE] ADDED!
[NOTE] TESTING 5.6 3.0 4.1 1.3 2.0
[NOTE] ADDED!
[NOTE] TESTING 5.5 2.6 4.4 1.2 3.0
[NOTE] ADDED!
[NOTE] TESTING 5.4 3.7 1.5 0.2 4.0
[NOTE] ADDED!
[NOTE] TESTING 6.5 3.0 5.2 2.0 5.0
[NOTE] TESTING 5.7 3.8 1.7 0.3 6.0
[NOTE] ADDED!
[NOTE] RESULT: [5.1 3.5 1.4 0.2 1.0 , 5.6 3.0 4.1 1.3 2.0 , 5.5 2.6 4.4 1.2 3.0 , 5.4 3.7 1.5 0.2 4.0 , 5.7 3.8 1.7 0.3 6.0 ]
Thanks,
Robert
Tagged:
0
Answers
Examples are only views onto the data. You should not store them anyway. If you need the data, you should copy them into an double[]
Greetings,
Sebastian