25 #ifndef SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_HYPER_GRAPH_EDGE_SET_H_
26 #define SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_HYPER_GRAPH_EDGE_SET_H_
46 class EdgeSetInterface
49 using Ptr = std::shared_ptr<EdgeSetInterface>;
58 virtual void clear() = 0;
64 void setEdgeIdx(BaseEdge& edge,
int idx) { edge._edge_idx = idx; }
65 void setEdgeIdx(BaseMixedEdge& edge,
int obj_idx,
int eq_idx,
int ineq_idx)
67 edge._edge_idx_obj = obj_idx;
68 edge._edge_idx_eq = eq_idx;
69 edge._edge_idx_ineq = ineq_idx;
74 class OptimizationEdgeSet :
public EdgeSetInterface
77 using Ptr = std::shared_ptr<OptimizationEdgeSet>;
79 void clear()
override;
85 void getDimensions(
int& non_lsq_obj_dim,
int& lsq_obj_dim,
int& eq_dim,
int& ineq_dim);
87 void addEdges(std::initializer_list<BaseEdge::Ptr> objective_edges, std::initializer_list<BaseEdge::Ptr> lsq_objective_edges,
88 std::initializer_list<BaseEdge::Ptr> equality_edges, std::initializer_list<BaseEdge::Ptr> inequality_edges,
89 std::initializer_list<BaseMixedEdge::Ptr> mixed_edges)
92 if (objective_edges.size() > 0)
_objectives.insert(
_objectives.end(), objective_edges.begin(), objective_edges.end());
94 if (equality_edges.size() > 0)
_equalities.insert(
_equalities.end(), equality_edges.begin(), equality_edges.end());
96 if (mixed_edges.size() > 0)
_mixed.insert(
_mixed.end(), mixed_edges.begin(), mixed_edges.end());
99 void addEdges(std::initializer_list<BaseEdge::Ptr> objective_edges, std::initializer_list<BaseEdge::Ptr> equality_edges,
100 std::initializer_list<BaseEdge::Ptr> inequality_edges, std::initializer_list<BaseMixedEdge::Ptr> mixed_edges)
103 if (objective_edges.size() > 0)
105 for (
auto& edge : objective_edges)
107 if (edge->isLeastSquaresForm())
113 if (equality_edges.size() > 0)
_equalities.insert(
_equalities.end(), equality_edges.begin(), equality_edges.end());
115 if (mixed_edges.size() > 0)
_mixed.insert(
_mixed.end(), mixed_edges.begin(), mixed_edges.end());
120 if (edge->isLeastSquaresForm())
135 "OptimizationEdgeSet::addLsqObjectiveEdge(): The added edge does not return isLeastSquaresForm() == true.");
184 void computeEdgeIndices(std::vector<BaseMixedEdge::Ptr>& edges,
int& idx_obj,
int& idx_lsq_obj,
int& idx_eq,
int& idx_ineq);
191 std::vector<BaseMixedEdge::Ptr>
_mixed;
196 #endif // SRC_OPTIMIZATION_INCLUDE_CORBO_OPTIMIZATION_HYPER_GRAPH_EDGE_SET_H_