Skip to content
Snippets Groups Projects
Commit 5a78890f authored by a.croix's avatar a.croix
Browse files

Fix style issues

parent 9aa60eaf
No related branches found
No related tags found
No related merge requests found
Pipeline #1037 failed
......@@ -29,9 +29,9 @@ public class SolutionDistance implements Comparable<SolutionDistance> {
* @return
*/
@Override
public String toString() {
return "SolutionDistance{" +
"weights_w=" + Arrays.toString(weights_w)
final public String toString() {
return "SolutionDistance{"
+ "weights_w=" + Arrays.toString(weights_w)
+ ", weights_p=" + Arrays.toString(weights_p)
+ ", distance=" + distance
+ '}';
......@@ -41,7 +41,7 @@ public class SolutionDistance implements Comparable<SolutionDistance> {
* @param data
* @param expected
*/
public void computeScoreTo(List<double[]> data, double[] expected) {
void computeScoreTo(final List<double[]> data, final double[] expected) {
this.distance = 0;
for (int i = 0; i < data.size(); i++) {
......@@ -58,7 +58,7 @@ public class SolutionDistance implements Comparable<SolutionDistance> {
/**
* @param probability
*/
public void randomlyMutateWithProbability(final double probability) {
void randomlyMutateWithProbability(final double probability) {
double tos = Math.random();
if (tos > probability) {
// do nothing
......@@ -92,7 +92,7 @@ public class SolutionDistance implements Comparable<SolutionDistance> {
/**
*
*/
public void normalize() {
void normalize() {
this.weights_w = Utils.normalizeWeights(this.weights_w);
this.weights_p = Utils.normalizeWeights(this.weights_p);
}
......@@ -100,15 +100,15 @@ public class SolutionDistance implements Comparable<SolutionDistance> {
/**
* @return
*/
public double getDistance() {
double getDistance() {
return distance;
}
public double[] getWeightsW() {
double[] getWeightsW() {
return this.weights_w;
}
public double[] getWeightsP() {
double[] getWeightsP() {
return this.weights_p;
}
}
......@@ -279,23 +279,29 @@ public class Trainer {
* @return
*/
private void reproduce(final SolutionDistance dad,
final SolutionDistance mom,
final List<SolutionDistance> solutions,
final int cut_position,
final double beta
final SolutionDistance mom,
final List<SolutionDistance> solutions,
final int cut_position,
final double beta
) {
double p_new1_W = dad.getWeightsW()[cut_position] - beta
* (dad.getWeightsW()[cut_position] - mom.getWeightsW()[cut_position]);
* (dad.getWeightsW()[cut_position]
- mom.getWeightsW()[cut_position]);
double p_new2_W = mom.getWeightsW()[cut_position] + beta
* (dad.getWeightsW()[cut_position] - mom.getWeightsW()[cut_position]);
* (dad.getWeightsW()[cut_position]
- mom.getWeightsW()[cut_position]);
double p_new1_P = dad.getWeightsP()[cut_position] - beta
* (dad.getWeightsP()[cut_position] - mom.getWeightsP()[cut_position]);
* (dad.getWeightsP()[cut_position]
- mom.getWeightsP()[cut_position]);
double p_new2_P = mom.getWeightsP()[cut_position] + beta
* (dad.getWeightsP()[cut_position] - mom.getWeightsP()[cut_position]);
* (dad.getWeightsP()[cut_position]
- mom.getWeightsP()[cut_position]);
SolutionDistance child1 = new SolutionDistance(dad.getWeightsP().length);
SolutionDistance child2 = new SolutionDistance(dad.getWeightsP().length);
SolutionDistance child1 =
new SolutionDistance(dad.getWeightsP().length);
SolutionDistance child2 =
new SolutionDistance(dad.getWeightsP().length);
for (int i = 0; i < cut_position; i++) {
child1.getWeightsW()[i] = dad.getWeightsW()[i];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment