Skip to content
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

Merged

Conversation

chapuisk
Copy link
Contributor

@chapuisk chapuisk commented Nov 1, 2024

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.

@chapuisk chapuisk added 😱 Bug The issue reveals a bug in GAMA About Batch This issue concerns batch experiments labels Nov 1, 2024
@chapuisk chapuisk self-assigned this Nov 1, 2024
@chapuisk chapuisk linked an issue Nov 1, 2024 that may be closed by this pull request
Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a 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) ✅

View detailed results in CodeScene

@@ -1,15 +1,20 @@
package gama.core.kernel.batch.exploration.sampling;

import java.util.ArrayList;
import java.util.Arrays;

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;

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%

Comment on lines -57 to -75
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);
}

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

Comment on lines -125 to -130
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);
}

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

Comment on lines +126 to +130
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);
}

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

@lesquoyb lesquoyb changed the title PR to solve #367 morris experiments may set parameters out of bounds Solves #367 by reimplementing morris sampling method following SALib implementation to avoid parameters getting out of bounds Nov 4, 2024
@lesquoyb lesquoyb merged commit c21e019 into 2024-06 Nov 4, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
About Batch This issue concerns batch experiments 😱 Bug The issue reveals a bug in GAMA
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Morris experiments may set parameters out of bounds
2 participants