Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ set(albatross_HEADERS
albatross/models/ransac_gp.h
albatross/models/least_squares.h
albatross/covariance_functions/covariance_function.h
albatross/covariance_functions/covariance_functions.h
albatross/covariance_functions/distance_metrics.h
albatross/covariance_functions/noise.h
albatross/covariance_functions/polynomials.h
Expand All @@ -68,4 +67,3 @@ add_custom_target(albatross DEPENDS ${albatross_SRCS} ${albatross_HEADERS} COMME

add_subdirectory(tests)
add_subdirectory(examples)

38 changes: 38 additions & 0 deletions albatross/Common
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 2019 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_COMMON_H
#define ALBATROSS_COMMON_H

#include <cereal/cereal.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/archives/json.hpp>
#include <cereal/archives/xml.hpp>
#include <cereal/types/polymorphic.hpp>

#include <Eigen/Core>
#include <Eigen/Dense>

#include <math.h>
#include <iomanip>
#include <map>
#include <string>
#include <iostream>
#include <unordered_map>
#include <functional>
#include <memory>
#include <vector>

#include "map_utils.h"
#include "random_utils.h"

#endif
42 changes: 42 additions & 0 deletions albatross/Core
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (C) 2019 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_CORE_H
#define ALBATROSS_CORE_H

#include "Dataset"

#include <type_traits>
#include "core/declarations.h"
#include "core/traits.h"
#include "core/priors.h"
#include "core/parameter_handling_mixin.h"
#include "core/parameter_macros.h"
#include "core/fit_model.h"
#include "core/prediction.h"
#include "core/model.h"

//#include <algorithm>
//#include <assert.h>
//#include <iomanip>
//#include <map>
//#include <memory>
//#include <sstream>
//#include <vector>
//
//#include "cereal/cereal.hpp"
//#include "keys.h"
//#include "map_utils.h"
//#include "priors.h"
//#include <cereal/types/map.hpp>

#endif
33 changes: 33 additions & 0 deletions albatross/CovarianceFunctions
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2019 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_COVARIANCE_FUNCTIONS_H
#define ALBATROSS_COVARIANCE_FUNCTIONS_H

#include "Common"

#include "core/declarations.h"
#include "core/traits.h"
#include "core/priors.h"
#include "core/parameter_handling_mixin.h"
#include "core/parameter_macros.h"

#include "covariance_functions/traits.h"
#include "covariance_functions/covariance_function.h"
#include "covariance_functions/call_trace.h"
#include "covariance_functions/distance_metrics.h"
#include "covariance_functions/noise.h"
#include "covariance_functions/polynomials.h"
#include "covariance_functions/radial.h"
#include "covariance_functions/scaling_function.h"

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Swift Navigation Inc.
* Copyright (C) 2019 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
Expand All @@ -9,14 +9,12 @@
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_DATASET_H
#define ALBATROSS_DATASET_H

#ifndef ALBATROSS_COVARIANCE_FUNCTIONS_COVARIANCE_FUNCTIONS_H
#define ALBATROSS_COVARIANCE_FUNCTIONS_COVARIANCE_FUNCTIONS_H
#include "Distribution"

#include "covariance_function.h"
#include "noise.h"
#include "polynomials.h"
#include "radial.h"
#include "scaling_function.h"
#include "core/dataset.h"

#endif
#endif
26 changes: 26 additions & 0 deletions albatross/Distribution
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (C) 2019 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_DISTRIBUTION_H
#define ALBATROSS_DISTRIBUTION_H

#include "Common"

#include "cereal/traits.h"
#include "eigen/serializable_diagonal_matrix.h"

#include "core/declarations.h"
#include "core/indexing.h"
#include "core/distribution.h"
#include "core/concatenate.h"

#endif
21 changes: 21 additions & 0 deletions albatross/GP
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (C) 2019 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_GP_H
#define ALBATROSS_GP_H

#include "CovarianceFunctions"

#include "eigen/serializable_ldlt.h"
#include "models/gp.h"

#endif
71 changes: 71 additions & 0 deletions albatross/cereal/traits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (C) 2018 Swift Navigation Inc.
* Contact: Swift Navigation <dev@swiftnav.com>
*
* This source is subject to the license found in the file 'LICENSE' which must
* be distributed together with this source. All other rights reserved.
*
* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
*/

#ifndef ALBATROSS_CEREAL_TRAITS_H
#define ALBATROSS_CEREAL_TRAITS_H

#include "cereal/details/traits.hpp"

namespace albatross {

/*
* This little trick was borrowed from cereal, you an think of it as
* a function that will always return false ... but that doesn't
* get resolved until template instantiation, which when combined
* with a static assert let's you include a static assert that
* only triggers with a particular template parameter is used.
*/
template <class T> struct delay_static_assert : std::false_type {};

/*
* The following helper functions let you inspect a type and cereal Archive
* and determine if the type has a valid serialization method for that Archive
* type.
*/
template <typename X, typename Archive> class valid_output_serializer {
template <typename T>
static typename std::enable_if<
1 == cereal::traits::detail::count_output_serializers<T, Archive>::value,
std::true_type>::type
test(int);
template <typename T> static std::false_type test(...);

public:
static constexpr bool value = decltype(test<X>(0))::value;
};

template <typename X, typename Archive> class valid_input_serializer {
template <typename T>
static typename std::enable_if<
1 == cereal::traits::detail::count_input_serializers<T, Archive>::value,
std::true_type>::type
test(int);
template <typename T> static std::false_type test(...);

public:
static constexpr bool value = decltype(test<X>(0))::value;
};

template <typename X, typename Archive> class valid_in_out_serializer {
template <typename T>
static typename std::enable_if<valid_input_serializer<T, Archive>::value &&
valid_output_serializer<T, Archive>::value,
std::true_type>::type
test(int);
template <typename T> static std::false_type test(...);

public:
static constexpr bool value = decltype(test<X>(0))::value;
};
}

#endif
3 changes: 0 additions & 3 deletions albatross/core/concatenate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#ifndef ALBATROSS_CORE_CONCATENATE_H
#define ALBATROSS_CORE_CONCATENATE_H

#include "core/dataset.h"
#include "map_utils.h"

namespace albatross {

template <typename FeatureType>
Expand Down
33 changes: 13 additions & 20 deletions albatross/core/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,8 @@
#ifndef ALBATROSS_CORE_DATASET_H
#define ALBATROSS_CORE_DATASET_H

#include "core/distribution.h"
#include "core/traits.h"
#include <Eigen/Core>
#include <cereal/archives/json.hpp>
#include <map>
#include <vector>

namespace albatross {

// A JointDistribution has a dense covariance matrix, which
// contains the covariance between each variable and all others.
using JointDistribution = Distribution<Eigen::MatrixXd>;

// We use a wrapper around DiagonalMatrix in order to make
// the resulting distribution serializable
using DiagonalMatrixXd =
Eigen::SerializableDiagonalMatrix<double, Eigen::Dynamic>;
// A MarginalDistribution has only a digaonal covariance
// matrix, so in turn only describes the variance of each
// variable independent of all others.
using MarginalDistribution = Distribution<DiagonalMatrixXd>;

/*
* A RegressionDataset holds two vectors of data, the features
* where a single feature can be any class that contains the information used
Expand Down Expand Up @@ -67,6 +47,8 @@ template <typename FeatureType> struct RegressionDataset {
metadata == other.metadata);
}

std::size_t size() const { return features.size(); }

template <class Archive>
typename std::enable_if<valid_in_out_serializer<FeatureType, Archive>::value,
void>::type
Expand All @@ -86,6 +68,17 @@ template <typename FeatureType> struct RegressionDataset {
}
};

/*
* Convenience method which subsets the features and targets of a dataset.
*/
template <typename SizeType, typename FeatureType>
inline RegressionDataset<FeatureType>
subset(const std::vector<SizeType> &indices,
const RegressionDataset<FeatureType> &dataset) {
return RegressionDataset<FeatureType>(subset(indices, dataset.features),
subset(indices, dataset.targets));
}

} // namespace albatross

#endif
Loading