Skip to content

Commit

Permalink
Fix bugs found by early adopters
Browse files Browse the repository at this point in the history
  • Loading branch information
Viviane Rochon Montplaisir committed Dec 18, 2019
1 parent 0da308a commit 3fcc7f5
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Miguel Anjos
Romain Couderc
Miguel Diago Martinez
Solène Kojtych
Guillaume Lameynardie
Caroline Rocha
Ludovic Salomon
22 changes: 20 additions & 2 deletions src/Param/PbParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ void NOMAD::PbParameters::checkAndComply( )
throw NOMAD::InvalidParameter(__FILE__,__LINE__, s);
}
if ( mPS.isDefined() && ! mFS.isDefined())
{
setAttributeValue("MIN_FRAME_SIZE", iPS );
}



Expand Down Expand Up @@ -261,10 +263,12 @@ void NOMAD::PbParameters::setGranularityAndBBInputType()
auto bbInputType = getAttributeValueProtected<NOMAD::BBInputTypeList>("BB_INPUT_TYPE",false);
auto lb = getAttributeValueProtected<NOMAD::ArrayOfDouble>("LOWER_BOUND",false);
auto ub = getAttributeValueProtected<NOMAD::ArrayOfDouble>("UPPER_BOUND",false);
std::ostringstream oss;

if (granularity.isDefined() && granularity.size() != n)
{
std::string err = "Warning: Parameter GRANULARITY resized from ";
std::string err;
err = "Warning: Parameter GRANULARITY resized from ";
err += std::to_string(granularity.size()) + " to " + std::to_string(n);
err += ". Values may be lost.";
std::cerr << err << std::endl;
Expand Down Expand Up @@ -330,6 +334,21 @@ void NOMAD::PbParameters::setGranularityAndBBInputType()
break;

}

if (!isSetByUser("BB_INPUT_TYPE"))
{
bbInputType.resize(n);
setAttributeValue("BB_INPUT_TYPE", bbInputType);
}

// By this point, bbInputType must be of size n.
if (n != bbInputType.size())
{
oss << "Error: BB_INPUT_TYPE " << bbInputType << " has dimension ";
oss << bbInputType.size() << " which is different from ";
oss << "problem dimension " << n;
throw NOMAD::InvalidParameter(__FILE__,__LINE__, oss.str());
}

/*-----------------------------------------*/
/* Adjust granularity with BB_INPUT_TYPE */
Expand All @@ -347,7 +366,6 @@ void NOMAD::PbParameters::setGranularityAndBBInputType()
// Ensure we have an integer
if (!granularity[i].isInteger())
{
std::ostringstream oss;
oss << "Check: Invalid granularity[";
oss << i;
oss << "] = " << granularity[i];
Expand Down
5 changes: 4 additions & 1 deletion src/Type/BBInputType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@
#include "../Type/BBInputType.hpp"
#include "../Util/ArrayOfString.hpp"
#include "../Util/Exception.hpp"
#include "../Util/utils.hpp"

// Convert a string ("R", "I", "B") to a NOMAD::BBInputType.
NOMAD::BBInputType NOMAD::stringToBBInputType(const std::string &s)
NOMAD::BBInputType NOMAD::stringToBBInputType(const std::string &sConst)
{
NOMAD::BBInputType ret = NOMAD::BBInputType::CONTINUOUS;
std::string s = sConst;
NOMAD::toupper(s);

if (s == "R")
{
Expand Down
6 changes: 5 additions & 1 deletion src/Type/BBOutputType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,16 @@
#include "../Type/BBOutputType.hpp"
#include "../Util/ArrayOfString.hpp"
#include "../Util/Exception.hpp"
#include "../Util/utils.hpp"


// Convert a string (ex "OBJ", "EB", "PB"...)
// to a NOMAD::BBOutputType.
NOMAD::BBOutputType NOMAD::stringToBBOutputType(const std::string &s)
NOMAD::BBOutputType NOMAD::stringToBBOutputType(const std::string &sConst)
{
NOMAD::BBOutputType ret = NOMAD::BBOutputType::BBO_UNDEFINED;
std::string s = sConst;
NOMAD::toupper(s);

if (s == "OBJ")
{
Expand Down Expand Up @@ -123,6 +126,7 @@ NOMAD::BBOutputTypeList NOMAD::stringToBBOutputTypeList(const std::string &s)
return bbOutputType;
}


// Convert a NOMAD::BBOutputTypeList into a string.
std::string NOMAD::BBOutputTypeListToString( const BBOutputTypeList & bbotList )
{
Expand Down
5 changes: 4 additions & 1 deletion src/Type/EvalType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,17 @@

#include "../Type/EvalType.hpp"
#include "../Util/Exception.hpp"
#include "../Util/utils.hpp"


// Convert a string ("BB", "SGTE")
// to a NOMAD::EvalType.
// "UNDEFINED" throws an exception, as well as any value other than "BB" or "SGTE".
NOMAD::EvalType NOMAD::stringToEvalType(const std::string &s)
NOMAD::EvalType NOMAD::stringToEvalType(const std::string &sConst)
{
NOMAD::EvalType ret;
std::string s = sConst;
NOMAD::toupper(s);

if (s == "BB")
{
Expand Down
5 changes: 4 additions & 1 deletion src/Type/SgtelibModelFeasibilityType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@

#include "../Type/SgtelibModelFeasibilityType.hpp"
#include "../Util/Exception.hpp"
#include "../Util/utils.hpp"


// Convert a string (ex "C", "H", "B"...)
// to a NOMAD::SgtelibModelFeasibilityType.
NOMAD::SgtelibModelFeasibilityType NOMAD::stringToSgtelibModelFeasibilityType(const std::string &s)
NOMAD::SgtelibModelFeasibilityType NOMAD::stringToSgtelibModelFeasibilityType(const std::string &sConst)
{
auto ret = NOMAD::SgtelibModelFeasibilityType::UNDEFINED;
std::string s = sConst;
NOMAD::toupper(s);

if (s == "C")
{
Expand Down
5 changes: 4 additions & 1 deletion src/Type/SgtelibModelFormulationType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@

#include "../Type/SgtelibModelFormulationType.hpp"
#include "../Util/Exception.hpp"
#include "../Util/utils.hpp"


// Convert a string (ex "FS", "FSP", "EIS"...)
// to a NOMAD::SgtelibModelFormulationType.
NOMAD::SgtelibModelFormulationType NOMAD::stringToSgtelibModelFormulationType(const std::string &s)
NOMAD::SgtelibModelFormulationType NOMAD::stringToSgtelibModelFormulationType(const std::string &sConst)
{
auto ret = NOMAD::SgtelibModelFormulationType::UNDEFINED;
std::string s = sConst;
NOMAD::toupper(s);

if (s == "FS")
{
Expand Down

0 comments on commit 3fcc7f5

Please sign in to comment.