133 number_of_variables_ = 0;
144 number_of_variables_ = number_of_variables;
154 virtual void resetBody(
const std::size_t number_of_constraints = 0,
155 const bool initialize_matrices =
false) = 0;
164 virtual void resetBounds(
const std::size_t number_of_constraints = 0,
165 const bool initialize_matrices =
false) = 0;
175 void reset (
const std::size_t number_of_constraints = 0,
176 const std::size_t number_of_variables = 0,
177 const bool initialize_matrices =
false)
179 setNumberOfVariables(number_of_variables);
181 resetBody(number_of_constraints, initialize_matrices);
182 resetBounds(number_of_constraints, initialize_matrices);
195 const std::string &name =
"constraints")
const = 0;
204 virtual void logBounds(
humoto::Logger &logger HUMOTO_GLOBAL_LOGGER_IF_DEFINED,
206 const std::string &name =
"constraints")
const = 0;
217 return (number_of_variables_);
227 virtual std::size_t getNumberOfConstraints()
const = 0;
240 const std::string &name =
"constraints")
const 245 logger.log(
LogEntryName(subname).add(
"number_of_variables"), number_of_variables_);
247 logBody(logger, subname,
"");
248 logBounds(logger, subname,
"");
263 const std::size_t constraints_offset,
264 const std::size_t number_of_variables)
const 266 Location ctr_location(constraints_offset, number_of_constraints);
269 "Added constraints exceed preallocated storage space.");
270 HUMOTO_ASSERT( getNumberOfVariables() == number_of_variables,
271 "Constraints have mismatching number of variables.")
273 return (ctr_location);
326 if (getNumberOfConstraints() == 0)
336 for (std::size_t i = 0; i < getNumberOfConstraints(); ++i)
338 unsigned int variable_index = getIndices()[i];
340 if (lb[variable_index] < getLowerBounds()[i])
342 lb[variable_index] = getLowerBounds()[i];
345 if (ub[variable_index] > getUpperBounds()[i])
347 ub[variable_index] = getUpperBounds()[i];
351 if (lb[variable_index] > ub[variable_index])
353 std::stringstream err_msg;
354 err_msg << std::setprecision(std::numeric_limits<double>::digits10);
355 err_msg <<
"Inconsistent bounds (lb > ub): variable index = '" << variable_index
356 <<
"', lb = '" << lb[variable_index]
357 <<
"', ub = '" << ub[variable_index]
388 number_of_variables_ = 0;
400 virtual void copyBoundsTo( Eigen::VectorXd & lb,
401 Eigen::VectorXd & ub,
402 const Location & location)
const = 0;
410 virtual void copyBodyTo(Eigen::MatrixXd & A,
411 const Location & location)
const = 0;
420 virtual void copyNegativeBodyTo(Eigen::MatrixXd & A,
421 const Location & location)
const = 0;
436 virtual void getATAandATb(Eigen::MatrixXd &H, Eigen::VectorXd &g)
const 443 virtual void addATAandATb(Eigen::MatrixXd &H, Eigen::VectorXd &g)
const 458 const std::size_t constraints_offset)
const 473 const std::size_t constraints_offset)
const 488 const std::size_t constraints_offset)
const 503 const std::size_t constraints_offset)
const 544 virtual void checkConsistency()
const = 0;
557 const Solution & solution)
const = 0;
568 const Solution & solution)
const = 0;
599 template<
class t_Base>
611 using t_Base::copyTo;
616 const std::size_t constraints_offset)
const 623 t_Base::copyBodyTo(container.
getA(), ctr_location);
632 template<
class t_Base>
644 using t_Base::copyTo;
649 const std::size_t constraints_offset)
const 656 t_Base::copyBodyTo(container.
getA(), ctr_location);
664 template<
class t_Base>
676 using t_Base::copyTo;
681 const std::size_t constraints_offset)
const 688 t_Base::copyNegativeBodyTo(container.
getA(), ctr_location);
696 template<
class t_Base>
709 using t_Base::copyTo;
714 const std::size_t constraints_offset)
const 727 template<
class t_Base>
739 using t_Base::copyTo;
744 const std::size_t constraints_offset)
const 761 template<
class t_Base>
773 using t_Base::copyTo;
778 const std::size_t constraints_offset)
const 784 t_Base::copyEqualityBoundsTo(container.
getB(), ctr_location);
785 t_Base::copyBodyTo(container.
getA(), ctr_location);
Container for simple inequality constraints.
std::size_t number_of_variables_
virtual std::size_t copyTo(ContainerALU &container, const std::size_t constraints_offset) const
Copy constraints to a container.
Constraints abstract interface class.
bool checkLength(const std::size_t max_length) const
Check length of location.
Violations corresponding to Constraints class.
Eigen::VectorXd & getB()
Get vector b from equalities: 'A*x = b' or 'x = b'.
CopyTwoSidedInequalityToALMixin()
~CopyTwoSidedInequalityToALMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
bool isEquality() const
Check properties of the constriaints.
~ContainerBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
virtual std::size_t copyTo(ContainerAL &container, const std::size_t constraints_offset) const
Copy constraints to a container.
void setNumberOfVariables(const std::size_t number_of_variables)
Set number of variables.
std::size_t getNumberOfVariables() const
Returns number of variables in the task.
~CopySimpleToILUMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
const double g_infinity
Infinity.
Mixin representing matrix of indices 'I' in a simple constraint.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
static bool isSimple(const Type ctr_type)
humoto::IndexVector & getIndices()
Get indices.
Container of the solution.
Active set corresponding to Constraints class.
~CopyLowerInequalityToALMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
#define HUMOTO_THROW_MSG(s)
HUMOTO_THROW_MSG throws an error message concatenated with the name of the function (if supported)...
Represents log entry name.
bool isSimple() const
Check properties of the constriaints.
virtual std::size_t copyTo(ContainerAL &container, const std::size_t constraints_offset) const
Set constraints.
void reset(const std::size_t number_of_constraints=0, const std::size_t number_of_variables=0, const bool initialize_matrices=false)
Initialize constraints.
virtual std::size_t copyTo(ContainerAB &container, const std::size_t constraints_offset) const
Copy constraints to a container.
This mixin provides functionality for conversion of specific type of constraints to a certain contain...
Eigen::VectorXd & getUpperBounds()
Get upper bounds (ub vectors from 'A*x <= ub').
~CopyUpperInequalityToALMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
Eigen::MatrixXd & getA()
Get matrix A from general constraints: 'A*x = b', 'lb <= A*x <= ub'.
CopyUpperInequalityToALMixin()
~CopyAnyToALUMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
virtual void addATAandATb(Eigen::MatrixXd &H, Eigen::VectorXd &g) const
Compute 'A^T * A' for general equality constaints and save or add the result to H. Compute 'A^T * b' for general equality constaints and save or add the result to g.
std::size_t copyTo(ContainerAL &container, const std::size_t constraints_offset) const
Set constraints.
This mixin provides functionality for conversion of specific type of constraints to a certain contain...
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
void initializeSolutionBounds(Eigen::VectorXd &lb, Eigen::VectorXd &ub) const
Generates LB and UB, such that 'LB <= X <= UB'.
~CopyEqualityToABMixin()
Protected destructor: prevent destruction of the child classes through a base pointer.
std::size_t copyTo(ContainerALU &container, const std::size_t constraints_offset) const
Set constraints.
std::size_t copyTo(ContainerAB &container, const std::size_t constraints_offset) const
Set constraints.
bool isTwoSidedInequality() const
Check properties of the constriaints.
This mixin provides functionality for conversion of specific type of constraints to a certain contain...
Location getCopyLocation(const std::size_t number_of_constraints, const std::size_t constraints_offset, const std::size_t number_of_variables) const
Computes location of the copied constraints in a container and verifies their consistency.
Container for general onesided inequality constraints.
The root namespace of HuMoTo.
std::size_t copyTo(ContainerILU &container, const std::size_t constraints_offset) const
Set constraints.
virtual std::size_t copyTo(ContainerAL &container, const std::size_t constraints_offset) const
Set constraints.
virtual void getATAandATb(Eigen::MatrixXd &H, Eigen::VectorXd &g) const
Compute 'A^T * A' for general equality constaints and save or add the result to H. Compute 'A^T * b' for general equality constaints and save or add the result to g.
~ConstraintsBase()
Protected destructor: prevent destruction of the child classes through a base pointer.
void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="constraints") const
Log data.
Container for general equality constraints.
Mixin representing matrix 'A' in a general constraint.
CopyLowerInequalityToALMixin()
LogEntryName & add(const char *name)
extends entry name with a subname
Location of a data chunk (offset + length).
static bool isEquality(const Type ctr_type)
Eigen::VectorXd & getLowerBounds()
Get lower bounds (lb/ub vectors from 'lb <= A*x <= ub').
This mixin provides functionality for conversion of specific type of constraints to a certain contain...
This mixin provides functionality for conversion of specific type of constraints to a certain contain...
static bool isTwoSidedInequality(const Type ctr_type)
virtual std::size_t copyTo(ContainerILU &container, const std::size_t constraints_offset) const
Set constraints.
This mixin provides functionality for conversion of specific type of constraints to a certain contain...
Container for general inequality constraints.
Constraints abstract interface class.