Skip to content

Commit 110a178

Browse files
Update to nalgebra 0.33 + switch to anise git
1 parent d1db1d7 commit 110a178

33 files changed

+347
-400
lines changed

Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,18 @@ maintenance = { status = "actively-developed" }
3434
gitlab = { repository = "nyx-space/nyx", branch = "master" }
3535

3636
[dependencies]
37-
nalgebra = "=0.32"
37+
nalgebra = "0.33"
3838
log = "0.4"
3939
hifitime = "4.0.0-alpha"
40-
anise = "0.4.0"
40+
# anise = "0.4.0"
41+
anise = { git = "https://github.com/nyx-space/anise.git", branch = "master" }
4142
flate2 = { version = "1.0", features = [
4243
"rust_backend",
4344
], default-features = false }
4445
serde = "1.0"
4546
serde_derive = "1.0"
4647
csv = "1"
47-
hyperdual = "=1.2.0"
48+
hyperdual = "1.3.0"
4849
bytes = "1.0"
4950
rand = "0.8"
5051
rand_distr = "0.4"

src/cosmic/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ pub trait TimeTagged {
4242
pub trait State: Default + Copy + PartialEq + fmt::Display + fmt::LowerExp + Send + Sync
4343
where
4444
Self: Sized,
45-
DefaultAllocator: Allocator<f64, Self::Size>
46-
+ Allocator<f64, Self::Size, Self::Size>
47-
+ Allocator<f64, Self::VecLength>,
45+
DefaultAllocator: Allocator< Self::Size>
46+
+ Allocator< Self::Size, Self::Size>
47+
+ Allocator< Self::VecLength>,
4848
{
4949
/// Size of the state and its STM
5050
type Size: DimName;
@@ -85,7 +85,7 @@ where
8585
vector: &OVector<f64, Self::VecLength>,
8686
) -> Self
8787
where
88-
DefaultAllocator: Allocator<f64, Self::VecLength>,
88+
DefaultAllocator: Allocator< Self::VecLength>,
8989
{
9090
self.set(self.epoch() + delta_t_s, vector);
9191
self

src/dynamics/mod.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::State;
2323
use anise::almanac::planetary::PlanetaryDataError;
2424
use anise::almanac::Almanac;
2525
use anise::errors::AlmanacError;
26-
use hyperdual::{OHyperdual, Owned};
26+
use hyperdual::Owned;
2727
use snafu::Snafu;
2828

2929
use std::fmt;
@@ -75,9 +75,9 @@ pub use self::sph_harmonics::*;
7575
#[allow(clippy::type_complexity)]
7676
pub trait Dynamics: Clone + Sync + Send
7777
where
78-
DefaultAllocator: Allocator<f64, <Self::StateType as State>::Size>
79-
+ Allocator<f64, <Self::StateType as State>::VecLength>
80-
+ Allocator<f64, <Self::StateType as State>::Size, <Self::StateType as State>::Size>,
78+
DefaultAllocator: Allocator<<Self::StateType as State>::Size>
79+
+ Allocator<<Self::StateType as State>::VecLength>
80+
+ Allocator<<Self::StateType as State>::Size, <Self::StateType as State>::Size>,
8181
{
8282
/// The state of the associated hyperdual state, almost always StateType + U1
8383
type HyperdualSize: DimName;
@@ -96,7 +96,7 @@ where
9696
almanac: Arc<Almanac>,
9797
) -> Result<OVector<f64, <Self::StateType as State>::VecLength>, DynamicsError>
9898
where
99-
DefaultAllocator: Allocator<f64, <Self::StateType as State>::VecLength>;
99+
DefaultAllocator: Allocator<<Self::StateType as State>::VecLength>;
100100

101101
/// Defines the equations of motion for Dual numbers for these dynamics.
102102
/// _All_ dynamics need to allow for automatic differentiation. However, if differentiation is not supported,
@@ -114,10 +114,9 @@ where
114114
DynamicsError,
115115
>
116116
where
117-
DefaultAllocator: Allocator<f64, Self::HyperdualSize>
118-
+ Allocator<f64, <Self::StateType as State>::Size>
119-
+ Allocator<f64, <Self::StateType as State>::Size, <Self::StateType as State>::Size>
120-
+ Allocator<OHyperdual<f64, Self::HyperdualSize>, <Self::StateType as State>::Size>,
117+
DefaultAllocator: Allocator<Self::HyperdualSize>
118+
+ Allocator<<Self::StateType as State>::Size>
119+
+ Allocator<<Self::StateType as State>::Size, <Self::StateType as State>::Size>,
121120
Owned<f64, Self::HyperdualSize>: Copy,
122121
{
123122
Err(DynamicsError::StateTransitionMatrixUnset)

src/io/tracking_data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl DynamicTrackingArc {
8989
pub fn to_tracking_arc<Msr>(&self) -> Result<TrackingArc<Msr>, InputOutputError>
9090
where
9191
Msr: Measurement,
92-
DefaultAllocator: Allocator<f64, Msr::MeasurementSize>,
92+
DefaultAllocator: Allocator< Msr::MeasurementSize>,
9393
{
9494
// Read the file since we closed it earlier
9595
let file = File::open(&self.path).context(StdIOSnafu {

src/io/trajectory_data.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ impl TrajectoryLoader {
9999
pub fn to_traj<S>(&self) -> Result<Traj<S>, InputOutputError>
100100
where
101101
S: Interpolatable,
102-
DefaultAllocator: Allocator<f64, S::VecLength>
103-
+ Allocator<f64, S::Size>
104-
+ Allocator<f64, S::Size, S::Size>,
102+
DefaultAllocator: Allocator< S::VecLength>
103+
+ Allocator< S::Size>
104+
+ Allocator< S::Size, S::Size>,
105105
{
106106
// Check the schema
107107
let mut has_epoch = false; // Required

src/mc/generator.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ impl Dispersion<Normal<f64>> {
5858
#[derive(Clone)]
5959
pub struct DispersedState<S: State>
6060
where
61-
DefaultAllocator: Allocator<f64, S::Size>
62-
+ Allocator<f64, S::Size, S::Size>
63-
+ Allocator<usize, S::Size, S::Size>
64-
+ Allocator<f64, S::VecLength>,
61+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
6562
{
6663
/// The dispersed state
6764
pub state: S,

src/mc/montecarlo.rs

+20-37
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ use rand::SeedableRng;
3636
use rand_distr::Distribution;
3737
use rayon::prelude::ParallelIterator;
3838
use rayon::prelude::*;
39-
use std::f64;
4039
use std::fmt;
4140
use std::sync::mpsc::channel;
4241
use std::sync::Arc;
@@ -47,10 +46,7 @@ use std::time::Instant as StdInstant;
4746
/// One caveat of the design is that the trajectory is used for post processing, not each individual state. This may prevent some event switching from being shown in GNC simulations.
4847
pub struct MonteCarlo<S: Interpolatable, Distr: Distribution<DispersedState<S>>>
4948
where
50-
DefaultAllocator: Allocator<f64, S::Size>
51-
+ Allocator<f64, S::Size, S::Size>
52-
+ Allocator<f64, S::VecLength>
53-
+ Allocator<usize, S::Size, S::Size>,
49+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
5450
{
5551
/// Seed of the [64bit PCG random number generator](https://www.pcg-random.org/index.html)
5652
pub seed: Option<u128>,
@@ -63,10 +59,7 @@ where
6359

6460
impl<S: Interpolatable, Distr: Distribution<DispersedState<S>>> MonteCarlo<S, Distr>
6561
where
66-
DefaultAllocator: Allocator<f64, S::Size>
67-
+ Allocator<f64, S::Size, S::Size>
68-
+ Allocator<f64, S::VecLength>
69-
+ Allocator<usize, S::Size, S::Size>,
62+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
7063
{
7164
pub fn new(
7265
nominal_state: S,
@@ -109,11 +102,10 @@ where
109102
D: Dynamics<StateType = S>,
110103
E: ErrorCtrl,
111104
F: EventEvaluator<S>,
112-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
113-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
114-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
115-
+ Allocator<f64, <D::StateType as State>::VecLength>,
116-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
105+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
106+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
107+
+ Allocator<<D::StateType as State>::VecLength>,
108+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
117109
{
118110
self.resume_run_until_nth_event(prop, almanac, 0, max_duration, event, trigger, num_runs)
119111
}
@@ -135,11 +127,10 @@ where
135127
D: Dynamics<StateType = S>,
136128
E: ErrorCtrl,
137129
F: EventEvaluator<S>,
138-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
139-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
140-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
141-
+ Allocator<f64, <D::StateType as State>::VecLength>,
142-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
130+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
131+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
132+
+ Allocator<<D::StateType as State>::VecLength>,
133+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
143134
{
144135
// Generate the initial states
145136
let init_states = self.generate_states(skip, num_runs, self.seed);
@@ -207,11 +198,10 @@ where
207198
where
208199
D: Dynamics<StateType = S>,
209200
E: ErrorCtrl,
210-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
211-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
212-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
213-
+ Allocator<f64, <D::StateType as State>::VecLength>,
214-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
201+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
202+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
203+
+ Allocator<<D::StateType as State>::VecLength>,
204+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
215205
{
216206
self.resume_run_until_epoch(prop, almanac, 0, end_epoch, num_runs)
217207
}
@@ -230,11 +220,10 @@ where
230220
where
231221
D: Dynamics<StateType = S>,
232222
E: ErrorCtrl,
233-
DefaultAllocator: Allocator<f64, <D::StateType as State>::Size>
234-
+ Allocator<f64, <D::StateType as State>::Size, <D::StateType as State>::Size>
235-
+ Allocator<usize, <D::StateType as State>::Size, <D::StateType as State>::Size>
236-
+ Allocator<f64, <D::StateType as State>::VecLength>,
237-
<DefaultAllocator as Allocator<f64, <D::StateType as State>::VecLength>>::Buffer: Send,
223+
DefaultAllocator: Allocator<<D::StateType as State>::Size>
224+
+ Allocator<<D::StateType as State>::Size, <D::StateType as State>::Size>
225+
+ Allocator<<D::StateType as State>::VecLength>,
226+
<DefaultAllocator as Allocator<<D::StateType as State>::VecLength>>::Buffer<f64>: Send,
238227
{
239228
// Generate the initial states
240229
let init_states = self.generate_states(skip, num_runs, self.seed);
@@ -315,10 +304,7 @@ where
315304
impl<S: Interpolatable, Distr: Distribution<DispersedState<S>>> fmt::Display
316305
for MonteCarlo<S, Distr>
317306
where
318-
DefaultAllocator: Allocator<f64, S::Size>
319-
+ Allocator<f64, S::Size, S::Size>
320-
+ Allocator<f64, S::VecLength>
321-
+ Allocator<usize, S::Size, S::Size>,
307+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
322308
{
323309
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
324310
write!(
@@ -332,10 +318,7 @@ where
332318
impl<S: Interpolatable, Distr: Distribution<DispersedState<S>>> fmt::LowerHex
333319
for MonteCarlo<S, Distr>
334320
where
335-
DefaultAllocator: Allocator<f64, S::Size>
336-
+ Allocator<f64, S::Size, S::Size>
337-
+ Allocator<f64, S::VecLength>
338-
+ Allocator<usize, S::Size, S::Size>,
321+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
339322
{
340323
/// Returns a filename friendly name
341324
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

src/mc/results.rs

+8-20
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ use super::DispersedState;
4747
/// A structure storing the result of a single Monte Carlo run
4848
pub struct Run<S: Interpolatable, R>
4949
where
50-
DefaultAllocator: Allocator<f64, S::Size>
51-
+ Allocator<f64, S::Size, S::Size>
52-
+ Allocator<usize, S::Size, S::Size>
53-
+ Allocator<f64, S::VecLength>,
54-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
50+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
51+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
5552
{
5653
/// The index of this run
5754
pub index: usize,
@@ -64,11 +61,8 @@ where
6461
/// A structure of Monte Carlo results
6562
pub struct Results<S: Interpolatable, R>
6663
where
67-
DefaultAllocator: Allocator<f64, S::Size>
68-
+ Allocator<f64, S::Size, S::Size>
69-
+ Allocator<usize, S::Size, S::Size>
70-
+ Allocator<f64, S::VecLength>,
71-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
64+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
65+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
7266
{
7367
/// Raw data from each run, sorted by run index for O(1) access to each run
7468
pub runs: Vec<Run<S, R>>,
@@ -79,23 +73,17 @@ where
7973
/// A structure that stores the result of a propagation segment of a Monte Carlo.
8074
pub struct PropResult<S: Interpolatable>
8175
where
82-
DefaultAllocator: Allocator<f64, S::Size>
83-
+ Allocator<f64, S::Size, S::Size>
84-
+ Allocator<usize, S::Size, S::Size>
85-
+ Allocator<f64, S::VecLength>,
86-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
76+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
77+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
8778
{
8879
pub state: S,
8980
pub traj: Traj<S>,
9081
}
9182

9283
impl<S: Interpolatable> Results<S, PropResult<S>>
9384
where
94-
DefaultAllocator: Allocator<f64, S::Size>
95-
+ Allocator<f64, S::Size, S::Size>
96-
+ Allocator<usize, S::Size, S::Size>
97-
+ Allocator<f64, S::VecLength>,
98-
<DefaultAllocator as Allocator<f64, S::VecLength>>::Buffer: Send,
85+
DefaultAllocator: Allocator<S::Size> + Allocator<S::Size, S::Size> + Allocator<S::VecLength>,
86+
<DefaultAllocator as Allocator<S::VecLength>>::Buffer<f64>: Send,
9987
{
10088
/// Returns the value of the requested state parameter for all trajectories from `start` to `end` every `step` and
10189
/// using the value of `value_if_run_failed` if set and skipping that run if the run failed

src/md/events/details.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub enum EventEdge {
5050
pub struct EventDetails<S: Interpolatable>
5151
where
5252
DefaultAllocator:
53-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
53+
Allocator< S::VecLength> + Allocator< S::Size> + Allocator< S::Size, S::Size>,
5454
{
5555
/// The state of the trajectory at the found event.
5656
pub state: S,
@@ -71,7 +71,7 @@ where
7171
impl<S: Interpolatable> EventDetails<S>
7272
where
7373
DefaultAllocator:
74-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
74+
Allocator< S::VecLength> + Allocator< S::Size> + Allocator< S::Size, S::Size>,
7575
{
7676
/// Generates detailed information about an event at a specific epoch in a trajectory.
7777
///
@@ -149,7 +149,7 @@ where
149149
impl<S: Interpolatable> fmt::Display for EventDetails<S>
150150
where
151151
DefaultAllocator:
152-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
152+
Allocator< S::VecLength> + Allocator< S::Size> + Allocator< S::Size, S::Size>,
153153
{
154154
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
155155
let prev_fmt = match self.prev_value {
@@ -174,7 +174,7 @@ where
174174
pub struct EventArc<S: Interpolatable>
175175
where
176176
DefaultAllocator:
177-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
177+
Allocator< S::VecLength> + Allocator< S::Size> + Allocator< S::Size, S::Size>,
178178
{
179179
pub rise: EventDetails<S>,
180180
pub fall: EventDetails<S>,
@@ -183,7 +183,7 @@ where
183183
impl<S: Interpolatable> fmt::Display for EventArc<S>
184184
where
185185
DefaultAllocator:
186-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
186+
Allocator< S::VecLength> + Allocator< S::Size> + Allocator< S::Size, S::Size>,
187187
{
188188
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
189189
write!(

src/md/events/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use std::sync::Arc;
3636
pub trait EventEvaluator<S: State>: fmt::Display + Send + Sync
3737
where
3838
DefaultAllocator:
39-
Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size> + Allocator<f64, S::VecLength>,
39+
Allocator< S::Size> + Allocator< S::Size, S::Size> + Allocator< S::VecLength>,
4040
{
4141
// Evaluation of event crossing, must return whether the condition happened between between both states.
4242
fn eval_crossing(

src/md/events/search.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use std::sync::Arc;
3333
impl<S: Interpolatable> Traj<S>
3434
where
3535
DefaultAllocator:
36-
Allocator<f64, S::VecLength> + Allocator<f64, S::Size> + Allocator<f64, S::Size, S::Size>,
36+
Allocator< S::VecLength> + Allocator< S::Size> + Allocator< S::Size, S::Size>,
3737
{
3838
/// Find the exact state where the request event happens. The event function is expected to be monotone in the provided interval because we find the event using a Brent solver.
3939
#[allow(clippy::identity_op)]

src/md/trajectory/interpolatable.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ use enum_iterator::all;
3333
pub trait Interpolatable: State
3434
where
3535
Self: Sized,
36-
DefaultAllocator: Allocator<f64, Self::Size>
37-
+ Allocator<f64, Self::Size, Self::Size>
38-
+ Allocator<f64, Self::VecLength>,
36+
DefaultAllocator: Allocator< Self::Size>
37+
+ Allocator< Self::Size, Self::Size>
38+
+ Allocator< Self::VecLength>,
3939
{
4040
/// Interpolates a new state at the provided epochs given a slice of states.
4141
fn interpolate(self, epoch: Epoch, states: &[Self]) -> Result<Self, InterpolationError>;

0 commit comments

Comments
 (0)