DART 6.7.3
Loading...
Searching...
No Matches
Population.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2019, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_OPTIMIZER_POPULATION_HPP_
34#define DART_OPTIMIZER_POPULATION_HPP_
35
36#include <iostream>
37#include <memory>
38#include <random>
39
40#include <Eigen/Dense>
41
43
44namespace dart {
45namespace optimizer {
46
47class MultiObjectiveProblem;
48
50{
51public:
56 std::shared_ptr<MultiObjectiveProblem> problem,
57 std::size_t populationSize = 0u);
58
61
63 const MultiObjectiveProblem* getProblem() const;
64
67 void pushBack(const Eigen::VectorXd& x);
68
71 void pushBack(const Eigen::VectorXd& x, const Eigen::VectorXd& f);
72
75 void set(std::size_t index, const Eigen::VectorXd& x);
76
78 void set(
79 std::size_t index, const Eigen::VectorXd& x, const Eigen::VectorXd& f);
80
82 std::size_t getSize() const;
83
85 Eigen::VectorXd getDecisionVector(std::size_t index) const;
86
88 Eigen::VectorXd getFitnessVector(std::size_t index) const;
89
91 std::ostream& print(std::ostream& os) const;
92
93protected:
96 std::shared_ptr<MultiObjectiveProblem> mProblem;
97
99 Eigen::MatrixXd mPopulation;
100
102 Eigen::MatrixXd mFitness;
103};
104
105} // namespace optimizer
106} // namespace dart
107
108#endif // DART_OPTIMIZER_POPULATION_HPP_
std::size_t index
Definition SkelParser.cpp:1617
Definition MultiObjectiveProblem.hpp:47
Definition Population.hpp:50
std::shared_ptr< MultiObjectiveProblem > mProblem
Multi-objective problem that this population is accosiated with.
Definition Population.hpp:96
MultiObjectiveProblem * getProblem()
Returns the associated problem, which is always not null.
Definition Population.cpp:98
Eigen::MatrixXd mPopulation
Decision vectors. A column represents a decision vector.
Definition Population.hpp:99
std::size_t getSize() const
Returns the size of this population.
Definition Population.cpp:158
Eigen::MatrixXd mFitness
Fitness vectors. A column represents a fitness vector.
Definition Population.hpp:102
void pushBack(const Eigen::VectorXd &x)
Adds the decision vector at the back of the population.
Definition Population.cpp:110
Eigen::VectorXd getDecisionVector(std::size_t index) const
Returns a decision vectors at index.
Definition Population.cpp:165
void set(std::size_t index, const Eigen::VectorXd &x)
Sets the decision vector.
Definition Population.cpp:136
std::ostream & print(std::ostream &os) const
Prints information of this class to a stream.
Definition Population.cpp:177
Eigen::VectorXd getFitnessVector(std::size_t index) const
Returns a fitness vectors at index.
Definition Population.cpp:171
Definition BulletCollisionDetector.cpp:63