Skip to content

Commit

Permalink
Fix expr/flatcon acceptance #237
Browse files Browse the repository at this point in the history
Restore SCIP::Cos() as 'not recommended' - seems slow

Fix Checker_AMPLS_ModeltTraits() signature
  • Loading branch information
glebbelov committed Aug 21, 2024
1 parent 9a44391 commit 76d8b3e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion include/mp/ampls-ccallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ typedef struct AMPLS_ModelTraits_T {
} AMPLS_ModelTraits;


typedef void (*Checker_AMPLS_ModeltTraits)(AMPLS_ModelTraits*);
typedef void (*Checker_AMPLS_ModeltTraits)(const AMPLS_ModelTraits*);


/// Set of callbacks provided to a driver for licensing issues
Expand Down
36 changes: 23 additions & 13 deletions include/mp/flat/constr_keeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,21 @@ class ConstraintKeeper final

/// Acceptance level of this constraint type in the ModelAPI
ConstraintAcceptanceLevel GetModelAPIAcceptance(
const BasicFlatModelAPI& ba) const override {
const BasicFlatModelAPI& = *(BasicFlatModelAPI*)nullptr)
const override {
return
static_cast<const Backend&>( ba ).
// static_cast<const Backend&>( ba ).
Backend::
AcceptanceLevel((Constraint*)nullptr);
}

/// Acceptance level of the corresponding expression type in the ModelAPI
ExpressionAcceptanceLevel GetModelAPIAcceptanceEXPR(
const BasicFlatModelAPI& ba) const override {
const BasicFlatModelAPI& = *(BasicFlatModelAPI*)nullptr)
const override {
return
static_cast<const Backend&>( ba ).
// static_cast<const Backend&>( ba ).
Backend::
AcceptanceLevel((FlatExprType*)nullptr);
}

Expand Down Expand Up @@ -202,14 +206,15 @@ class ConstraintKeeper final
const std::vector<std::string>* pvnam) override {
if (ExpressionAcceptanceLevel::NotAccepted
== GetChosenAcceptanceLevelEXPR()
|| !GetConverter().IfWantNLOutput())
try {
AddAllUnbridged(be, pvnam);
} catch (const std::exception& exc) {
MP_RAISE(std::string("Adding constraint of type '") +
Constraint::GetTypeName() + "' to " +
Backend::GetTypeName() + std::string(": ") +
exc.what());
|| !GetConverter().IfWantNLOutput()) {
try {
AddAllUnbridged(be, pvnam);
} catch (const std::exception& exc) {
MP_RAISE(std::string("Adding constraint of type '") +
Constraint::GetTypeName() + "' to " +
Backend::GetTypeName() + std::string(": ") +
exc.what());
}
}
}

Expand Down Expand Up @@ -301,7 +306,12 @@ class ConstraintKeeper final
int i=i_last;
const auto acceptanceLevel =
GetChosenAcceptanceLevel();
if (ConstraintAcceptanceLevel::NotAccepted == acceptanceLevel) {
if (ConstraintAcceptanceLevel::NotAccepted == acceptanceLevel
|| (ConstraintAcceptanceLevel::NotAccepted == GetModelAPIAcceptance()
&& (!GetConverter().IfWantNLOutput()
|| ExpressionAcceptanceLevel::NotAccepted
== GetChosenAcceptanceLevelEXPR())
&& 2 != AccLevelCommon())) { // Not when acc:_all=2
if (!IfConverterConverts(GetConverter())) {
i = (int)cons_.size();
} else {
Expand Down
2 changes: 0 additions & 2 deletions include/mp/flat/item_keeper.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ class BasicConstraintKeeper {
al = acc_level_item_;
std::array<int, 5> alv = {0, 1, 2, 1, 2};
acceptance_level_ = alv.at(al);
if (al>2 && !IfWantNLOutput()) // expression accepted but NL format not chosen
acceptance_level_ = 0;
}
return ConstraintAcceptanceLevel(acceptance_level_);
}
Expand Down
4 changes: 2 additions & 2 deletions solvers/scipmp/scipmpmodelapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ class ScipModelAPI :
ACCEPT_CONSTRAINT(SinConstraint, Recommended, CG_General)
void AddConstraint(const SinConstraint& cc);

ACCEPT_EXPRESSION(CosExpression, Recommended)
ACCEPT_EXPRESSION(CosExpression, AcceptedButNotRecommended) //pretty slow in SCIP 8/9
SCIP_EXPR* AddExpression(const CosExpression& );
ACCEPT_CONSTRAINT(CosConstraint, Recommended, CG_General) //pretty slow in SCIP 8
ACCEPT_CONSTRAINT(CosConstraint, AcceptedButNotRecommended, CG_General)
void AddConstraint(const CosConstraint& cc);

// TODO Div; PowVarExponent;
Expand Down

0 comments on commit 76d8b3e

Please sign in to comment.