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

New hydro remix algorithm #2532

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft

Conversation

guilpier-code
Copy link
Contributor

No description provided.

@guilpier-code guilpier-code marked this pull request as draft December 13, 2024 09:08
BOOST_CHECK(new_H == expected_H);
BOOST_CHECK(new_D == expected_D);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai l'impression que ce test est très similaire au test précédent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui, en effet, la seule chose qui change, c'est la Pmax qui est maintenant de 50 (au lieu de 40).
D'ou le titre de ce 2eme test

std::vector<double> expected_D = {20., 30., 40., 50., 60.};
BOOST_CHECK(new_H == expected_H);
BOOST_CHECK(new_D == expected_D);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lui aussi ressemble beaucoup au précédent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oui, ce test est le symétrique du test hydro_increases_and_pmax_40mwh___H_is_flattened_to_mean_H_20mwh
C'est pour montrer que l'algo est lui-même symétrique

int find_min_index(const std::vector<double>& G_plus_H,
const std::vector<double>& new_D,
const std::vector<double>& new_H,
const std::vector<int>& tried_creux,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear naming

const std::vector<int>& tried_creux,
const std::vector<double>& P_max,
const std::vector<bool>& filter_hours_remix,
double top)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear naming

Comment on lines 58 to 73
static bool isLessThan(const std::vector<double>& a, const std::vector<double>& b)
{
std::vector<double> a_minus_b;
std::ranges::transform(a, b, std::back_inserter(a_minus_b), std::minus<double>());
return std::ranges::all_of(a_minus_b, [](const double& e) { return e <= 0.; });
}

static bool isLessThan(const std::vector<double>& v, const double c)
{
return std::ranges::all_of(v, [&c](const double& e) { return e <= c; });
}

static bool isGreaterThan(const std::vector<double>& v, const double c)
{
return std::ranges::all_of(v, [&c](const double& e) { return e >= c; });
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use operator overloading, I wrote this example

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +75 to +87
static void checkInputCorrectness(const std::vector<double>& G,
const std::vector<double>& H,
const std::vector<double>& D,
const std::vector<double>& levels,
const std::vector<double>& P_max,
const std::vector<double>& P_min,
double initial_level,
double capacity,
const std::vector<double>& inflows,
const std::vector<double>& overflow,
const std::vector<double>& pump,
const std::vector<double>& S,
const std::vector<double>& DTG_MRG)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't really agree with having this function static, it might be public to ease testing
  2. Please avoid single character variable names

Copy link
Contributor Author

@guilpier-code guilpier-code Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. If this function was a method of a class, it would be private.
    Question is : do we expose it to the outside world ?
    Well literature says : people should test classes / objects behaviors, not their methods, and especially their private methods (see here for instance). We can't make every private methods public just to test them. So here, we test how the algorithm reacts to incorrect input data.
  2. I do agree

S.size(),
DTG_MRG.size()};

if (std::ranges::adjacent_find(sizes, std::not_equal_to()) != sizes.end())
Copy link
Member

@flomnes flomnes Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check all sizes against 1st one

Suggested change
if (std::ranges::adjacent_find(sizes, std::not_equal_to()) != sizes.end())
if (!std::ranges::all_of(sizes, [&](std::size_t s){ s == sizes.front();})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants