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
15534c3d
Commit
15534c3d
authored
6 years ago
by
a.croix
Browse files
Options
Downloads
Patches
Plain Diff
Change float to double in some function + writting Utils function
parent
3b757ecb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#1005
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
+14
-2
14 additions, 2 deletions
...in/java/be/cylab/java/wowa/training/SolutionDistance.java
src/main/java/be/cylab/java/wowa/training/Utils.java
+28
-12
28 additions, 12 deletions
src/main/java/be/cylab/java/wowa/training/Utils.java
with
42 additions
and
14 deletions
src/main/java/be/cylab/java/wowa/training/SolutionDistance.java
+
14
−
2
View file @
15534c3d
...
@@ -2,8 +2,8 @@ package be.cylab.java.wowa.training;
...
@@ -2,8 +2,8 @@ package be.cylab.java.wowa.training;
public
class
SolutionDistance
{
public
class
SolutionDistance
{
private
float
weights_w
[]
;
private
double
[]
weights_w
;
private
float
weights_p
[]
;
private
double
[]
weights_p
;
private
double
distance
=
Double
.
POSITIVE_INFINITY
;
private
double
distance
=
Double
.
POSITIVE_INFINITY
;
public
float
computeScoreTo
()
{
public
float
computeScoreTo
()
{
...
@@ -21,4 +21,16 @@ public class SolutionDistance {
...
@@ -21,4 +21,16 @@ public class SolutionDistance {
public
static
void
sort
(
SolutionDistance
[])
{
public
static
void
sort
(
SolutionDistance
[])
{
}
}
public
double
[]
getWeights_w
()
{
return
weights_w
;
}
public
double
[]
getWeights_p
()
{
return
weights_p
;
}
public
double
getDistance
()
{
return
distance
;
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/be/cylab/java/wowa/training/Utils.java
+
28
−
12
View file @
15534c3d
...
@@ -5,31 +5,47 @@ import java.util.Arrays;
...
@@ -5,31 +5,47 @@ import java.util.Arrays;
public
class
Utils
{
public
class
Utils
{
public
float
[]
normalizeWeights
(
float
[]
weights
)
{
public
double
[]
normalizeWeights
(
double
[]
weights
)
{
float
sum_weight
=
Utils
.
sumArrayElements
(
weights
);
double
sum_weight
=
Utils
.
sumArrayElements
(
weights
);
float
[]
weightsNormalized
=
null
;
double
[]
weightsNormalized
=
null
;
for
(
int
i
=
0
;
i
<
weights
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
weights
.
length
;
i
++)
{
weightsNormalized
[
i
]
=
weights
[
i
]
/
sum_weight
;
weightsNormalized
[
i
]
=
weights
[
i
]
/
sum_weight
;
}
}
return
weightsNormalized
;
return
weightsNormalized
;
}
}
public
float
findMaxDistance
(
SolutionDistance
[]
solutions
)
{
public
double
findMaxDistance
(
SolutionDistance
[]
solutions
)
{
double
max
=
Double
.
NEGATIVE_INFINITY
;
for
(
SolutionDistance
solution
:
solutions
)
{
if
(
solution
.
getDistance
()
>
max
)
{
max
=
solution
.
getDistance
();
}
}
return
max
;
}
}
public
float
findMinDistance
(
SolutionDistance
[]
solutions
)
{
public
double
findMinDistance
(
SolutionDistance
[]
solutions
)
{
double
min
=
Double
.
POSITIVE_INFINITY
;
for
(
SolutionDistance
solution
:
solutions
)
{
if
(
solution
.
getDistance
()
<
min
){
min
=
solution
.
getDistance
();
}
}
return
min
;
}
}
public
float
sumTotalDistance
(
SolutionDistance
[]
solutions
)
{
public
double
sumTotalDistance
(
SolutionDistance
[]
solutions
)
{
double
sum
=
0
;
for
(
SolutionDistance
solution
:
solutions
)
{
sum
+=
solution
.
getDistance
();
}
return
sum
;
}
}
public
static
float
sumArrayElements
(
float
[]
array
)
{
public
static
double
sumArrayElements
(
double
[]
array
)
{
float
sum
=
0
;
float
sum
=
0
;
for
(
int
i
=
0
;
i
<
array
.
length
;
i
++
)
{
for
(
double
weight
:
array
)
{
sum
+=
array
[
i
]
;
sum
+=
weight
;
}
}
return
sum
;
return
sum
;
}
}
...
...
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