Skip to content

Commit

Permalink
Exp cone #192 draft
Browse files Browse the repository at this point in the history
  • Loading branch information
glebbelov committed May 14, 2023
1 parent 3547034 commit 2a356f1
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 40 deletions.
11 changes: 6 additions & 5 deletions include/mp/flat/constr_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,16 @@ using ComplementarityQuadratic = ComplementarityConstraint<QuadraticExpr>;

/// Quadratic cone
DEF_STATIC_CONSTR_WITH_PRM( QuadraticConeConstraint, VarArray, DblParamArray,
"Quadratic cone x1 >= sqrt(x2^2 + ...)) with factors "
"applied to the arguments, aka MOSEK 10 affine cones");
"Quadratic cone p1*x1 >= sqrt((p2*x2)^2 + ...)),"
" with factors p1..pn");
/// Rotated quadratic cone
DEF_STATIC_CONSTR_WITH_PRM( RotatedQuadraticConeConstraint, VarArray, DblParamArray,
"Rotated quadratic cone x1*x2 >= sqrt(x3^2 + ...)) with factors "
"applied to the arguments, aka MOSEK 10 affine cones");
"Rotated quadratic cone p1*x1*p2*x2 >= sqrt((p3*x3)^2 + ...)),"
" x1, x2 >= 0, with factors p1..pn");
/// Exponential cone
DEF_STATIC_CONSTR_WITH_PRM( ExponentialConeConstraint, VarArray3, DblParamArray3,
"Exponential cone with factors");
"Exponential cone p1*x1 >= p2*x2*exp(p3*x3 / (p2*x2)),"
" x1, x2 >= 0, with factors p1..p3");
/// Power cone
DEF_STATIC_CONSTR_WITH_PRM( PowerConeConstraint, VarArray, DblParamArray,
"Power cone with factors ");
Expand Down
17 changes: 17 additions & 0 deletions include/mp/flat/converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,12 @@ class FlatConverter :
(int)GetConstraintAcceptance((RotatedQuadraticConeConstraint*)nullptr));
}

/// Whether the ModelAPI accepts exp cones
int ModelAPIAcceptsExponentialCones() {
return
(int)GetConstraintAcceptance((ExponentialConeConstraint*)nullptr);
}


private:
struct Options {
Expand All @@ -837,6 +843,7 @@ class FlatConverter :
int passQuadObj_ = ModelAPIAcceptsQuadObj();
int passQuadCon_ = ModelAPIAcceptsQC();
int passSOCPCones_ = 0;
int passExpCones_ = 0;

int relax_ = 0;
};
Expand Down Expand Up @@ -893,6 +900,13 @@ class FlatConverter :
"0*/1: Multiply out and pass quadratic constraint terms to the solver, "
"vs. linear approximation.",
options_.passQuadCon_, 0, 1);
if (ModelAPIAcceptsExponentialCones())
GetEnv().AddOption("cvt:expcones expcones",
ModelAPIAcceptsExponentialCones()>1 ?
"0/1*: Recognize exponential cones." :
"0*/1: Recognize exponential cones.",
options_.passExpCones_, 0, 1);
options_.passExpCones_ = ModelAPIAcceptsExponentialCones()>1;
if (ModelAPIAcceptsQuadraticCones())
GetEnv().AddOption("cvt:socp passsocp socp",
ModelAPIAcceptsQuadraticCones()>1 ?
Expand Down Expand Up @@ -939,6 +953,9 @@ class FlatConverter :
/// Whether we pass SOCP cones
bool IfPassSOCPCones() const { return options_.passSOCPCones_; }

/// Whether we pass exp cones
bool IfPassExpCones() const { return options_.passExpCones_; }


public:
/// Typedef ModelAPIType. For tests
Expand Down
Loading

0 comments on commit 2a356f1

Please sign in to comment.