Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Transmitter Clusters
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OROBWorld
Transmitter Clusters
Commits
8640138d
Commit
8640138d
authored
3 years ago
by
Paul A. Rubin
Browse files
Options
Downloads
Patches
Plain Diff
Reordered methods.
parent
c1947126
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/xmtrclusters/Problem.java
+29
-29
29 additions, 29 deletions
src/xmtrclusters/Problem.java
with
29 additions
and
29 deletions
src/xmtrclusters/Problem.java
+
29
−
29
View file @
8640138d
...
@@ -83,30 +83,6 @@ public final class Problem {
...
@@ -83,30 +83,6 @@ public final class Problem {
}
}
}
}
/**
* Computes the service quality for a single user.
* @param user the index of the user
* @param cluster the indices of all transmitters in the same cluster as the
* user
* @return the service quality for the user
*/
public
double
userQuality
(
final
int
user
,
final
Collection
<
Integer
>
cluster
)
{
// Make sure at least one transmitter is not in the cluster (to avoid
// division by zero).
if
(
cluster
.
size
()
==
nTrans
)
{
throw
new
IllegalArgumentException
(
"Cannot have all transmitters"
+
" in one cluster."
);
}
// The numerator is the sum of weights for all transmitters in the cluster.
double
num
=
cluster
.
stream
().
mapToDouble
(
t
->
weight
[
t
][
user
]).
sum
();
// The denominator is the sum of weights for all transmitters not in
// the cluster.
HashSet
<
Integer
>
out
=
new
HashSet
<>(
allTransmitters
);
out
.
removeAll
(
cluster
);
double
denom
=
out
.
stream
().
mapToDouble
(
t
->
weight
[
t
][
user
]).
sum
();
return
num
/
denom
;
}
/**
/**
* Generates a summary of a solution.
* Generates a summary of a solution.
* @param solution the solution (a collection of clusters of transmitters)
* @param solution the solution (a collection of clusters of transmitters)
...
@@ -190,12 +166,27 @@ public final class Problem {
...
@@ -190,12 +166,27 @@ public final class Problem {
}
}
/**
/**
* Computes the total quality of a proposed solution.
* Computes the service quality for a single user.
* @param clusters a collection of clusters
* @param user the index of the user
* @return the total user quality for that solution
* @param cluster the indices of all transmitters in the same cluster as the
* user
* @return the service quality for the user
*/
*/
public
double
totalQuality
(
final
Collection
<
Collection
<
Integer
>>
clusters
)
{
public
double
userQuality
(
final
int
user
,
final
Collection
<
Integer
>
cluster
)
{
return
clusters
.
stream
().
mapToDouble
(
c
->
clusterQuality
(
c
)).
sum
();
// Make sure at least one transmitter is not in the cluster (to avoid
// division by zero).
if
(
cluster
.
size
()
==
nTrans
)
{
throw
new
IllegalArgumentException
(
"Cannot have all transmitters"
+
" in one cluster."
);
}
// The numerator is the sum of weights for all transmitters in the cluster.
double
num
=
cluster
.
stream
().
mapToDouble
(
t
->
weight
[
t
][
user
]).
sum
();
// The denominator is the sum of weights for all transmitters not in
// the cluster.
HashSet
<
Integer
>
out
=
new
HashSet
<>(
allTransmitters
);
out
.
removeAll
(
cluster
);
double
denom
=
out
.
stream
().
mapToDouble
(
t
->
weight
[
t
][
user
]).
sum
();
return
num
/
denom
;
}
}
/**
/**
...
@@ -210,4 +201,13 @@ public final class Problem {
...
@@ -210,4 +201,13 @@ public final class Problem {
// Total their quality values.
// Total their quality values.
return
list
.
stream
().
mapToDouble
(
u
->
userQuality
(
u
,
cluster
)).
sum
();
return
list
.
stream
().
mapToDouble
(
u
->
userQuality
(
u
,
cluster
)).
sum
();
}
}
/**
* Computes the total quality of a proposed solution.
* @param clusters a collection of clusters
* @return the total user quality for that solution
*/
public
double
totalQuality
(
final
Collection
<
Collection
<
Integer
>>
clusters
)
{
return
clusters
.
stream
().
mapToDouble
(
c
->
clusterQuality
(
c
)).
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