61 number_of_variables_ = 0;
62 variable_map_.clear();
73 const std::size_t length)
75 Location location(number_of_variables_, length);
77 variable_map_.insert(std::pair< std::string, Location > (
id, location));
79 number_of_variables_ += length;
90 if (variable_map_.size() == 0)
111 return (number_of_variables_);
124 std::map<std::string, Location>::const_iterator it;
126 it = variable_map_.find(
id);
128 if (it == variable_map_.end())
134 return( it->second );
147 Eigen::Block<Eigen::MatrixXd>
getMatrixPart(
const std::string &
id, Eigen::MatrixXd & matrix)
const 149 Location loc_var = getSolutionPartLocation(
id);
151 return (matrix.block(0, loc_var.
offset_, matrix.rows(), loc_var.
length_));
163 const Eigen::Block<const Eigen::MatrixXd>
getMatrixPart(
const std::string &
id,
const Eigen::MatrixXd & matrix)
const 165 Location loc_var = getSolutionPartLocation(
id);
167 return (matrix.block(0, loc_var.
offset_, matrix.rows(), loc_var.
length_));
178 #define HUMOTO_CONFIG_SECTION_ID "Solution" 179 #define HUMOTO_CONFIG_CONSTRUCTOR Solution 180 #define HUMOTO_CONFIG_ENTRIES \ 181 HUMOTO_CONFIG_COMPOUND_(x) 182 #include HUMOTO_CONFIG_DEFINE_ACCESSORS 217 SolutionStructure::operator=(sol_structure);
218 x_.resize(getNumberOfVariables());
233 SolutionStructure::operator=(sol_structure);
236 x_.setZero(getNumberOfVariables());
240 x_.setConstant(getNumberOfVariables(), value);
254 initialize(sol_structure, 0.0);
257 for (std::map<std::string, Location>::const_iterator i = variable_map_.begin();
258 i != variable_map_.end();
267 getData(guess_part) = old_solution.
getData(old_part);
283 return ( getData( getSolutionPartLocation(
id) ) );
311 return ( getData( getSolutionPartLocation(
id) ) );
337 const Eigen::VectorXd &
get_x()
const 353 const std::string & name =
"solution")
const 359 logger.log(
LogEntryName(subname).add(
"status"), return_status_);
371 std::string description(
"Status description is not available.");
372 return (description);
std::size_t getNumberOfVariables() const
Get total number of variables in the solution vector.
virtual ~SolutionStructure()
Virtual destructor.
void setDefaults()
No defaults.
bool checkLength(const std::size_t max_length) const
Check length of location.
Eigen::Block< Eigen::MatrixXd > getMatrixPart(const std::string &id, Eigen::MatrixXd &matrix) const
Get part of a matrix corresponding to given part of the solution.
Eigen::VectorBlock< Eigen::VectorXd > getSolutionPart(const std::string &id)
Get part of the solution by its id.
#define HUMOTO_GLOBAL_LOGGER_IF_DEFINED
#define HUMOTO_ASSERT(condition, message)
void initialize(const SolutionStructure &sol_structure, const double value)
Initialize the solution vector.
SolutionStructure()
Default constructor.
Eigen::VectorBlock< Eigen::VectorXd > getData(const Location &location)
Get data from solution vector.
Default configurable base is strict.
Analog of 'sol_structure' struct in Octave code. [determine_solution_structure.m].
std::size_t number_of_variables_
Container of the solution.
Represents log entry name.
bool isNonEmpty() const
Checks if the structure is empty or not.
SolverStatus::Status return_status_
void initialize(const SolutionStructure &sol_structure, const Solution &old_solution)
Initialize the solution vector using an old solution.
const Eigen::Block< const Eigen::MatrixXd > getMatrixPart(const std::string &id, const Eigen::MatrixXd &matrix) const
Get part of a matrix corresponding to given part of the solution.
virtual ~Solution()
Virtual destructor.
Threaded logger: any data sent to this logger is wrapped in a message and pushed to a queue...
void initialize(const SolutionStructure &sol_structure)
Initialize the solution vector.
Return status of a solver.
virtual void log(humoto::Logger &logger, const LogEntryName &parent=LogEntryName(), const std::string &name="solution") const
Log a QP problem.
Location getSolutionPartLocation(const std::string &id) const
Get location of a data in the solution vector.
The root namespace of HuMoTo.
const Eigen::VectorXd & get_x() const
Returns solution vector.
Eigen::VectorXd getSolutionPart(const std::string &id) const
Get part of the solution by its id.
std::map< std::string, Location > variable_map_
virtual std::string getStatusDescription() const
Status description.
Eigen::VectorXd getData(const Location &location) const
Get data from solution vector.
LogEntryName & add(const char *name)
extends entry name with a subname
Location of a data chunk (offset + length).
void addSolutionPart(const std::string &id, const std::size_t length)
Add part of the solution.