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

Add adequacy patch optimization number to MPS filename to avoid overwrite #1187

Closed
wants to merge 5 commits into from

Conversation

flomnes
Copy link
Member

@flomnes flomnes commented Feb 23, 2023

No description provided.

- Move createOptimizationFilename to class OptPeriodStringGenerator
- Remove unused arg from `getFilenameWithExtension`
- Remove std::shared_ptr from function arguments
@flomnes flomnes added the bug Something isn't working label Feb 23, 2023
@flomnes flomnes linked an issue Feb 23, 2023 that may be closed by this pull request
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 6 Code Smells

4.5% 4.5% Coverage
0.0% 0.0% Duplication

@flomnes flomnes added this to the v8.5.2 milestone Mar 1, 2023
@@ -45,9 +45,9 @@ AdequacyPatchOptimization::AdequacyPatchOptimization(PROBLEME_HEBDO* problemeHeb
}
void AdequacyPatchOptimization::solve(uint weekInTheYear, int hourInTheYear)
{
problemeHebdo_->adqPatchParams->AdequacyFirstStep = true;
problemeHebdo_->adequacyPatchRuntimeData->LMR_FirstOptimization = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

ok.
Should conflict with #1189

const std::string filename = createMPSfilename(optPeriodStringGenerator, optimizationNumber);
mpsWriterFactory mps_writer_factory(problemeHebdo->ExportMPS, problemeHebdo->exportMPSOnError, optimizationNumber, &Probleme, ortoolsUsed, solver);

auto adqPatchOptNumber
Copy link
Contributor

@guilpier-code guilpier-code Mar 1, 2023

Choose a reason for hiding this comment

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

Following the oral talk we just had, I think that the MPS filename should not be computed here, but at a higher in the call stack.
Here this name should be passed as an argument.
See this comment

@@ -110,16 +111,20 @@ bool OPT_OptimisationLineaire(PROBLEME_HEBDO* problemeHebdo, uint numSpace)
problemeHebdo->year);

if (!OPT_AppelDuSimplexe(
problemeHebdo, NumeroDeLIntervalle, optimizationNumber, optPeriodStringGenerator))
problemeHebdo, NumeroDeLIntervalle, optimizationNumber, *optPeriodStringGenerator))
Copy link
Contributor

@guilpier-code guilpier-code Mar 1, 2023

Choose a reason for hiding this comment

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

Here we should have (something like) :

auto mpsFileNames = MPSfileNames(problemeHebdo->OptimisationAuPasHebdomadaire,
                                 NumeroDeLIntervalle,
                                 problemeHebdo->adequacyPatchRuntimeData
                                 problemeHebdo->weekInTheYear,
                                 problemeHebdo->year)

if (!OPT_AppelDuSimplexe(problemeHebdo, 
                         NumeroDeLIntervalle, 
                         optimizationNumber, 
                         mpsFileNames->mps()))
        return false;

if (problemeHebdo->ExportMPS ......)
{
    ...
    OPT_EcrireResultatFonctionObjectiveAuFormatTXT(optimalSolutionCost,
                                                   mpsFileNames->criterion());
}

This would allow :

  • extracting filenames creation from functions that print into these files
  • calling getAdqPatchOptmizationNumber(...) only once.

@@ -37,4 +38,8 @@ class OptPeriodStringGenerator
public:
virtual std::string to_string() const = 0;
virtual ~OptPeriodStringGenerator() = default;
std::string createOptimizationFilename(const std::string& title,
Copy link
Contributor

Choose a reason for hiding this comment

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

Base class OptPeriodStringGenerator is an abstraction for the optimization period, that is either :

  • <year>-<week>
  • <year>-<week>-<day>

inside the filename.
So why do we have a new createOptimizationFilename function that take many arguments about the whole file name ?
I guess OptPeriodStringGenerator should concern the optimization period only.

Comment on lines +139 to +140
if (problemeHebdo->adqPatchParams
&& problemeHebdo->adequacyPatchRuntimeData->LMR_FirstOptimization)
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
if (problemeHebdo->adqPatchParams
&& problemeHebdo->adequacyPatchRuntimeData->LMR_FirstOptimization)
if (problemeHebdo->adequacyPatchRuntimeData
&& problemeHebdo->adequacyPatchRuntimeData->LMR_FirstOptimization)

@flomnes flomnes closed this May 10, 2023
@JasonMarechal25 JasonMarechal25 deleted the fix/adq-patch-mps branch November 6, 2023 10:28
@JasonMarechal25 JasonMarechal25 restored the fix/adq-patch-mps branch November 6, 2023 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adq-patch bug Something isn't working size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't overwrite MPS files when adq-patch is enabled
2 participants