35 if (vertices->isModified())
37 vertices->computeActiveVertices();
38 vertices->setModified(
false);
39 _dim_param = vertices->getParameterDimension();
40 vertices->computeVertexIndices();
49 if (edges->isModified())
52 edges->computeEdgeIndices();
53 edges->setModified(
false);
92 value += edge->computeSumOfValues();
98 if (edge->isObjectiveLeastSquaresForm() || edge->getObjectiveDimension() == 0)
continue;
101 value += edge->computeSumOfObjectiveValues();
114 edge->computeValues(values.segment(edge->getEdgeIdx(), edge->getDimension()));
120 if (!edge->isObjectiveLeastSquaresForm() || edge->getObjectiveDimension() == 0)
continue;
123 edge->computeObjectiveValues(values.segment(edge->getEdgeObjectiveIdx(), edge->getObjectiveDimension()));
138 PRINT_DEBUG_COND_ONCE(edge->isLeastSquaresForm(),
"BaseHyperGraphOptimizationProblem::computeValueObjective(): "
139 <<
"least-squares edge found in non-lsq container");
140 value += edge->computeSumOfValues();
144 PRINT_DEBUG_COND_ONCE(!edge->isLeastSquaresForm(),
"BaseHyperGraphOptimizationProblem::computeValueObjective(): "
145 <<
"non-least-squares edge found in lsq container");
146 value += edge->computeSquaredNormOfValues();
151 if (edge->getObjectiveDimension() == 0)
continue;
154 if (edge->isObjectiveLeastSquaresForm())
155 value += edge->computeSquaredNormOfObjectiveValues();
157 value += edge->computeSumOfObjectiveValues();
170 edge->computeValues(values.segment(edge->getEdgeIdx(), edge->getDimension()));
175 if (edge->getEqualityDimension() == 0)
continue;
178 edge->computeEqualityValues(values.segment(edge->getEdgeEqualityIdx(), edge->getEqualityDimension()));
190 edge->computeValues(values.segment(edge->getEdgeIdx(), edge->getDimension()));
195 if (edge->getInequalityDimension() == 0)
continue;
198 edge->computeInequalityValues(values.segment(edge->getEdgeInequalityIdx(), edge->getInequalityDimension()));
210 non_lsq_obj_value = 0;
213 non_lsq_obj_value += edge->computeSumOfValues();
218 edge->computeValues(lsq_obj_values.segment(edge->getEdgeIdx(), edge->getDimension()));
223 edge->computeValues(eq_values.segment(edge->getEdgeIdx(), edge->getDimension()));
228 edge->computeValues(ineq_values.segment(edge->getEdgeIdx(), edge->getDimension()));
235 if (edge->isObjectiveLeastSquaresForm())
237 edge->computeObjectiveValues(lsq_obj_values.segment(edge->getEdgeObjectiveIdx(), edge->getObjectiveDimension()));
241 non_lsq_obj_value += edge->computeSumOfObjectiveValues();
244 edge->computeEqualityValues(eq_values.segment(edge->getEdgeEqualityIdx(), edge->getEqualityDimension()));
245 edge->computeInequalityValues(ineq_values.segment(edge->getEdgeInequalityIdx(), edge->getInequalityDimension()));
258 dim += vertex->getNumberFiniteBounds(
true);
272 dim += vertex->getNumberFiniteLowerBounds(
true);
273 dim += vertex->getNumberFiniteUpperBounds(
true);
282 for (
int i = 0; i < values.size(); ++i)
299 for (
int i = 0; i < vertex->getDimension(); ++i)
301 if (vertex->isFixedComponent(i))
continue;
303 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
305 if (vertex->getData()[i] < vertex->getLowerBounds()[i])
306 values[idx] = vertex->getLowerBounds()[i] - vertex->getData()[i];
307 else if (vertex->getData()[i] > vertex->getUpperBounds()[i])
308 values[idx] = vertex->getData()[i] - vertex->getUpperBounds()[i];
325 for (
int i = 0; i < vertex->getDimension(); ++i)
327 if (vertex->isFixedComponent(i))
continue;
329 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
331 lb_minus_x[idx] = vertex->getLowerBounds()[i] - vertex->getData()[i];
332 ub_minus_x[idx] = vertex->getUpperBounds()[i] - vertex->getData()[i];
349 for (
int i = 0; i < vertex->getDimension(); ++i)
351 if (vertex->isFixedComponent(i))
continue;
353 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
355 lb_finite_bounds[idx] = vertex->getLowerBounds()[i];
356 ub_finite_bounds[idx] = vertex->getUpperBounds()[i];
357 x_finite_bounds[idx] = vertex->getData()[i];
376 int vert_idx = vertex->getVertexIdx();
378 for (
int i = 0; i < vertex->getDimension(); ++i)
380 if (vertex->isFixedComponent(i))
continue;
382 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
384 if (vertex->getData()[i] < vertex->getLowerBounds()[i])
386 jacobian(row_idx, vert_idx + free_idx) = -weight;
388 else if (vertex->getData()[i] > vertex->getUpperBounds()[i])
390 jacobian(row_idx, vert_idx + free_idx) = weight;
405 assert(j_col.size() == i_row.size());
410 int vert_idx = vertex->getVertexIdx();
412 for (
int i = 0; i < vertex->getDimension(); ++i)
414 if (vertex->isFixedComponent(i))
continue;
416 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
418 i_row[row_idx] = row_idx;
419 j_col[row_idx] = vert_idx + free_idx;
434 for (
int i = 0; i < vertex->getDimension(); ++i)
436 if (vertex->isFixedComponent(i))
continue;
438 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
440 if (vertex->getData()[i] < vertex->getLowerBounds()[i])
442 values(row_idx) = -weight;
444 else if (vertex->getData()[i] > vertex->getUpperBounds()[i])
446 values(row_idx) = weight;
450 values(row_idx) = 0.0;
470 int vert_idx = vertex->getVertexIdx();
472 for (
int i = 0; i < vertex->getDimension(); ++i)
474 if (vertex->isFixedComponent(i))
continue;
476 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
478 jacobian(row_idx, vert_idx + free_idx) = 1;
494 for (
int i = 0; i < vertex->getDimension(); ++i)
496 if (vertex->isFixedComponent(i))
continue;
498 if (vertex->hasFiniteLowerBound(i) || vertex->hasFiniteUpperBound(i))
500 if (!fun(vertex->getData()[i], idx))
return false;