Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
java-wowa-training
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cylab
java-wowa-training
Commits
5a78890f
Commit
5a78890f
authored
6 years ago
by
a.croix
Browse files
Options
Downloads
Patches
Plain Diff
Fix style issues
parent
9aa60eaf
No related branches found
No related tags found
No related merge requests found
Pipeline
#1037
failed
6 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/be/cylab/java/wowa/training/SolutionDistance.java
+9
-9
9 additions, 9 deletions
...in/java/be/cylab/java/wowa/training/SolutionDistance.java
src/main/java/be/cylab/java/wowa/training/Trainer.java
+16
-10
16 additions, 10 deletions
src/main/java/be/cylab/java/wowa/training/Trainer.java
with
25 additions
and
19 deletions
src/main/java/be/cylab/java/wowa/training/SolutionDistance.java
+
9
−
9
View file @
5a78890f
...
...
@@ -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
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/be/cylab/java/wowa/training/Trainer.java
+
16
−
10
View file @
5a78890f
...
...
@@ -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
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment