force-h2020 / force-bdss

Business Decision System general interface
BSD 2-Clause "Simplified" License
2 stars 2 forks source link

FIX: UniformSampler number of points equal regardless of zero values #334

Closed flongford closed 4 years ago

flongford commented 4 years ago

This PR closes #332

The UniformSampler class is refactored so that the same number of points is generated whether with_zero_values is set to True or False. Consequently, it no longer matters if the resolution attribute is less than dimension, we just sample at different points along the grid.

Example:

For a dimension = 3 vector, a sample resolution = 2 (weight combinations per dimension) will yield the following normalised weight combinations if with_zero_values = True:

[1.0, 0.0, 0.0]
[0.0, 1.0, 0.0]
[0.0, 0.0, 1.0]

This is because 2 possible weight values are allowed: 0.0 and 1.0. However, setting with_zero_values = False will result in the following normalised combinations:

[0.5, 0.25, 0.25]
[0.25, 0.5, 0.25]
[0.25, 0.25, 0.5]

Notice how in each situation the ratio of weightings per dimension is the same, only the values are different (now 0.25 and 0.5).

Additional changes:

codecov[bot] commented 4 years ago

Codecov Report

Merging #334 into master will increase coverage by 0.00%. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #334   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files          60       60           
  Lines        1685     1686    +1     
  Branches      170      172    +2     
=======================================
+ Hits         1658     1659    +1     
  Misses         23       23           
  Partials        4        4           
Impacted Files Coverage Δ
force_bdss/mco/optimizer_engines/space_sampling.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 50caa07...0ec6d67. Read the comment docs.