# Issue with Setting a Minimum Value for Input Parameters in Genetic Algorithm Training

**URL:** <https://root-forum.cern.ch/t/issue-with-setting-a-minimum-value-for-input-parameters-in-genetic-algorithm-training/62833>\
**Category:** TMVA\
**Tags:** tmva\
**Created:** [February 6, 2025, 2:34pm UTC](https://root-forum.cern.ch/t/issue-with-setting-a-minimum-value-for-input-parameters-in-genetic-algorithm-training/62833 "2025-02-06T14:34:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpramanik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ebca7d/32.png) [@rpramanik](https://root-forum.cern.ch/u/rpramanik)\
**Post date:** [February 6, 2025, 2:34pm UTC](https://root-forum.cern.ch/t/issue-with-setting-a-minimum-value-for-input-parameters-in-genetic-algorithm-training/62833/1 "2025-02-06T14:34:37Z")

</div>

I am using TMVA with `FitMethod=GA` to optimize five input parameters. I want to define both a minimum and maximum range for each parameter. When I specify only the maximum range, the training runs smoothly. However, when I set a minimum range, the training results in cuts on the parameter being set to zero. To cross-check, I explicitly set `CutRangeMin[0]=0`, but the training still does not proceed as expected. I am attaching my code and output when using `CutRangeMin[0]`. I am currently stuck on this issue and would appreciate any suggestions.

```cpp
void optimizer_EB() {
   TMVA::Tools::Instance();
    TFile* outputFile = TFile::Open("tmva_EB.root", "RECREATE");
    TMVA::Factory* factory = new TMVA::Factory("TMVAClassification", outputFile, 
                                               "!V:!Silent:Color:DrawProgressBar");
    TMVA::DataLoader* dataloader = new TMVA::DataLoader("dataset");
    TFile* inputFile = TFile::Open("bdt_scores_EB.root");
    TTree* signalTree = (TTree*)inputFile->Get("test_signal");
    TTree* backgroundTree = (TTree*)inputFile->Get("test_background");
    dataloader->AddVariable("pho_EB_TrkIso", 'F');
    dataloader->AddVariable("pho_EB_ECalIso", 'F');
    dataloader->AddVariable("pho_EB_HCalIso", 'F');
    dataloader->AddVariable("pho_EB_HoverE", 'F');
    dataloader->AddVariable("BDT_score", 'F');
  dataloader->AddSignalTree(signalTree, 1.0);
    dataloader->AddBackgroundTree(backgroundTree, 1.0);
    dataloader->SetSignalWeightExpression("1");
    dataloader->SetBackgroundWeightExpression("1");
    TCut signalCut = "";
    TCut backgroundCut = "";
    dataloader->PrepareTrainingAndTestTree(signalCut, backgroundCut, "nTrain_Signal=100000:nTrain_Background=100000:nTest_Signal=100000:nTest_Background=100000");
    dataloader->SetBackgroundWeightExpression("1");
    dataloader->SetSignalWeightExpression("1");
 TString methodName = "Cut_GA";
    TString methodOptions = "!H:!V:FitMethod=GA:EffMethod=EffSel:VerbosityLevel=Debug"; 
    methodOptions += ":VarProp[0]=FMin:VarProp[1]=FMin:VarProp[2]=FMin:VarProp[3]=FMin:VarProp[4]=FMin";
    methodOptions += ":CutRangeMin[0]=0:CutRangeMax[0]=5";
    methodOptions += ":CutRangeMin[1]=0:CutRangeMax[1]=10";
    methodOptions += ":CutRangeMin[2]=0:CutRangeMax[2]=9.989";
    methodOptions += ":CutRangeMin[3]=0:CutRangeMax[3]=0.1";
    methodOptions += ":CutRangeMin[4]=0:CutRangeMax[4]=0.9989";
   TMVA::gConfig().GetVariablePlotting().fNbinsXOfROCCurve = 500;
    factory->BookMethod(dataloader, TMVA::Types::kCuts, methodName, methodOptions);  
    factory->TrainAllMethods();
    factory->TestAllMethods();
    factory->EvaluateAllMethods();  
    outputFile->Close();
    std::cout << "==> Wrote root file: " << outputFile->GetName() << std::endl;
    std::cout << "==> TMVAClassification is done!" << std::endl;
    delete factory;
    delete dataloader;
}

```

and this is the output

```auto
 Cut_GA : Cut values for requested signal efficiency: 0.8
                         : Corresponding background efficiency : -0.1
                         : Transformation applied to input variables : None
                         : --------------------------------------------------
                         : Cut[0]: -1e+30 < pho_EB_TrkIso <= 0
                         : Cut[1]: -1e+30 < pho_EB_ECalIso <= 0
                         : Cut[2]: -1e+30 < pho_EB_HCalIso <= 0
                         : Cut[3]: -1e+30 < pho_EB_HoverE <= 0
                         : Cut[4]: -1e+30 < BDT_score <= 0
                         : --------------------------------------------------
                         : --------------------------------------------------
Cut_GA : Cut values for requested signal efficiency: 0.9
                         : Corresponding background efficiency : -0.1
                         : Transformation applied to input variables : None
                         : --------------------------------------------------
                         : Cut[0]: -1e+30 < pho_EB_TrkIso <= 0
                         : Cut[1]: -1e+30 < pho_EB_ECalIso <= 0
                         : Cut[2]: -1e+30 < pho_EB_HCalIso <= 0
                         : Cut[3]: -1e+30 < pho_EB_HoverE <= 0
                         : Cut[4]: -1e+30 < BDT_score <= 0`

```

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [February 6, 2025, 9:13pm UTC](https://root-forum.cern.ch/t/issue-with-setting-a-minimum-value-for-input-parameters-in-genetic-algorithm-training/62833/2 "2025-02-06T21:13:13Z")

</div>

Hi,

Welcome to the ROOT Community!  
I am adding @moneta in the loop, who might provide some hint.

Best,  
D

---

<div class="post-metadata">

**Author:** ![rpramanik](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/r/ebca7d/32.png) [@rpramanik](https://root-forum.cern.ch/u/rpramanik)\
**Post date:** [February 11, 2025, 7:44am UTC](https://root-forum.cern.ch/t/issue-with-setting-a-minimum-value-for-input-parameters-in-genetic-algorithm-training/62833/3 "2025-02-11T07:44:42Z")

</div>

Dear ROOT Community,  
I previously posted regarding an issue with setting both minimum and maximum ranges for parameters in TMVA when using FitMethod=GA. While I received a suggestion to involve @moneta, I haven’t received any further feedback yet. Here’s a quick summary of the issue:  
When I specify only the maximum range, training runs smoothly.  
However, when I set a minimum range (e.g., CutRangeMin[0]=0), the parameter values are set to zero during training, and I can’t get past this issue. Even when I explicitly set CutRangeMin[0]=0, the training does not proceed as expected.  
I would really appreciate any guidance or suggestions on how to resolve this.  
Thank you for your time and assistance!  
Best regards,  
Riya

---

<div class="post-metadata">

**Author:** ![Shilpi](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/s/958977/32.png) [@Shilpi](https://root-forum.cern.ch/u/Shilpi)\
**Post date:** [February 17, 2025, 1:52pm UTC](https://root-forum.cern.ch/t/issue-with-setting-a-minimum-value-for-input-parameters-in-genetic-algorithm-training/62833/4 "2025-02-17T13:52:55Z")

</div>

Dear Experts,

Just wanted to follow up on the question posed above. Could you please let us know if it is possible to put the minimum cut on the variables going inside the GA?  
We have been trying but none of the methods seem to work.  
Any help would be greatly appreciated.

Best regards,  
Shilpi
