-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solves #367 by reimplementing morris sampling method following SALib implementation to avoid parameters getting out of bounds #369
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Code Health Quality Gates: OK
Change in average Code Health of affected files: +0.00 (8.76 -> 8.76)
- Improving Code Health: 3 findings(s) ✅
@@ -1,15 +1,20 @@ | |||
package gama.core.kernel.batch.exploration.sampling; | |||
|
|||
import java.util.ArrayList; | |||
import java.util.Arrays; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ Getting better: Code Duplication
reduced similar code in: trajectoryBuilder,trajectoryBuilder
@@ -1,15 +1,20 @@ | |||
package gama.core.kernel.batch.exploration.sampling; | |||
|
|||
import java.util.ArrayList; | |||
import java.util.Arrays; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ Getting worse: Primitive Obsession
The ratio of primitive types in function arguments increases from 48.57% to 55.56%, threshold = 30.0%
private static List<Object> trajectoryBuilder(final double delta, final List<Integer> order, final List<Integer> direction, | ||
final List<Double> seed, final List<List<Double>> accPoints, final List<Double> accdelta, final int index) { | ||
if (order.isEmpty()) { | ||
List<Object> trajectory = new ArrayList<>(); | ||
trajectory.add(accPoints); | ||
trajectory.add(accdelta); | ||
return trajectory; | ||
} | ||
int idx = order.get(0); | ||
double deltaOriented = delta * direction.get(0); | ||
double valTemp = seed.get(idx) + deltaOriented; | ||
List<Double> new_seed = new ArrayList<>(seed); | ||
new_seed.set(idx, valTemp); | ||
order.remove(0); | ||
direction.remove(0); | ||
accPoints.add(new_seed); | ||
accdelta.add(deltaOriented); | ||
return trajectoryBuilder(delta, order, direction, new_seed, accPoints, accdelta, index + 1); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ No longer an issue: Excess Number of Function Arguments
trajectoryBuilder is no longer above the threshold for number of arguments
private static List<Trajectory> addTrajectories(final int k, final int p, final int r, final Random rng, | ||
final List<Trajectory> acc) { | ||
if (r == 0) return acc; | ||
acc.add(makeTrajectory(k, p, rng)); | ||
return addTrajectories(k, p, r - 1, rng, acc); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ No longer an issue: Excess Number of Function Arguments
addTrajectories is no longer above the threshold for number of arguments
private static List<Trajectory> morrisTrajectories(final int k, final int p, final int r, final Random rng, final List<Trajectory> acc) { | ||
if (r == 0) return acc; | ||
acc.add(generateTraj(k, p, rng)); | ||
return morrisTrajectories(k, p, r - 1, rng, acc); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ℹ New issue: Excess Number of Function Arguments
morrisTrajectories has 5 arguments, threshold = 4
The sampling method for Morris was made out of a 'simplification' of the original matrix based formula. The new implementation is retro-engineered from SALib (MIT Licence) implementation.