Skip to content

Commit

Permalink
Removed old test that does not apply to new Radau method
Browse files Browse the repository at this point in the history
  • Loading branch information
robfalck committed Jan 8, 2025
1 parent 9587358 commit b3485cc
Showing 1 changed file with 3 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,246 +13,6 @@
from dymos.examples.brachistochrone.test.ex_brachistochrone import brachistochrone_min_time as brach


@use_tempdirs
class TestCollocationBalanceIndex(unittest.TestCase):
"""
Test that the indices used in the StateIndependentsComp are as expected.
"""

def setUp(self):
dm.options['include_check_partials'] = True

def tearDown(self):
dm.options['include_check_partials'] = False

def test_3_lgl(self):
"""
Test one 3rd order LGL segment indices
All nodes are: [0, 1, 2]
Input nodes: [^ ^]
Solver nodes: [ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1}
The indep node is just the first one: {0}
"""
p = brach(transcription='gauss-lobatto', num_segments=1, transcription_order=3,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_5_lgl(self):
"""
Test one 5th order LGL segment indices
All nodes are: [0, 1, 2, 3, 4]
Input nodes: [^ ^ ^]
Solver nodes: [ ^ ^]
Of input nodes, solver nodes for fix_initial are: {1, 2}
The indep node is just the first one: {0}
"""
p = brach(transcription='gauss-lobatto', num_segments=1, transcription_order=5,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_3_lgl_compressed(self):
"""
Test one 3rd order LGL segment indices
All nodes are: [0, 1, 2, 3, 4]
Input nodes: [^ ^ ^]
Solver nodes: [ ^ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2}
The indep node is just the first one: {0}
"""
p = brach(transcription='gauss-lobatto', num_segments=2, transcription_order=3,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_5_lgl_compressed(self):
"""
Test two 5th order LGL segment indices
All nodes are: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Input nodes: [^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3, 4}
The indep node is just the first one: {0}
"""
p = brach(transcription='gauss-lobatto', num_segments=2, transcription_order=5,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3, 4})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_3_lgl_uncompressed(self):
"""
Test two 3rd order LGL segment indices
All nodes are: [0, 1, 2, 3, 4, 5]
Input nodes: [^ ^ ^ ^]
Solver nodes: [ ^ ^]
Indep nodes: [^ ^ ]
Of input nodes, solver nodes for fix_initial are: {1, 3}
The indep node is just the first one: {0, 2}
"""
p = brach(transcription='gauss-lobatto', num_segments=2, transcription_order=3,
compressed=False, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 3})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0, 2})

def test_5_lgl_uncompressed(self):
"""
Test two 5th order LGL segment indices
All nodes are: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Input nodes: [^ ^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^]
Indep nodes: [^ ^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 4, 5}
The indep node is just the first one in each segment: {0, 3}
"""
p = brach(transcription='gauss-lobatto', num_segments=2, transcription_order=5,
compressed=False, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 4, 5})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0, 3})

def test_3_radau(self):
"""
Test one 3rd order radau segment indices
All nodes are: [0, 1, 2, 3]
Input nodes: [^ ^ ^ ^]
Solver nodes: [ ^ ^ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3}
The indep node is just the first one: {0}
"""
p = brach(transcription='radau-ps', num_segments=1, transcription_order=3,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_5_radau(self):
"""
Test one 5th order radau segment indices
All nodes are: [0, 1, 2, 3, 4, 5]
Input nodes: [^ ^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3, 4, 5}
The indep node is just the first one: {0}
"""
p = brach(transcription='radau-ps', num_segments=1, transcription_order=5,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3, 4, 5})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_3_radau_compressed(self):
"""
Test one 3rd order radau segment indices
All nodes are: [0, 1, 2, 3, 4, 5, 6, 7]
Input nodes: [^ ^ ^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^ ^ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3, 4, 5, 6}
The indep node is just the first one: {0}
"""
p = brach(transcription='radau-ps', num_segments=2, transcription_order=3,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3, 4, 5, 6})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_5_radau_compressed(self):
"""
Test two 5th order radau segment indices
All nodes are: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Input nodes: [^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^]
Indep nodes: [^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
The indep node is just the first one: {0}
"""
p = brach(transcription='radau-ps', num_segments=2, transcription_order=5,
compressed=True, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0})

def test_3_radau_uncompressed(self):
"""
Test one 3rd order radau segment indices
All nodes are: [0, 1, 2, 3, 4, 5, 6, 7]
Input nodes: [^ ^ ^ ^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^ ^ ^]
Indep nodes: [^ ^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3, 5, 6, 7}
The indep node is just the first one: {0, 4}
"""
p = brach(transcription='radau-ps', num_segments=2, transcription_order=3,
compressed=False, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3, 5, 6, 7})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0, 4})

def test_5_radau_uncompressed(self):
"""
Test two 5th order radau segment indices
All nodes are: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
Input nodes: [^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^]
Solver nodes: [ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^]
Indep nodes: [^ ^ ]
Of input nodes, solver nodes for fix_initial are: {1, 2, 3, 4, 5, 7, 8, 9, 10, 11}
The indep node is just the first one: {0, 6}
"""
p = brach(transcription='radau-ps', num_segments=2, transcription_order=5,
compressed=False, solve_segments='forward', run_driver=True)

state_indeps_comp = p.model.traj0.phases.phase0.indep_states

self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['solver']), {1, 2, 3, 4, 5, 7, 8, 9, 10, 11})
self.assertSetEqual(set(state_indeps_comp.state_idx_map['x']['indep']), {0, 6})


@use_tempdirs
class TestCollocationBalanceApplyNL(unittest.TestCase):

Expand All @@ -268,9 +28,9 @@ def make_prob(self, transcription, num_segments, transcription_order, compressed
order=transcription_order,
compressed=compressed,)
elif transcription == 'radau-ps':
t = dm.Radau(num_segments=num_segments,
order=transcription_order,
compressed=compressed)
t = dm.RadauDeprecated(num_segments=num_segments,
order=transcription_order,
compressed=compressed)

traj = dm.Trajectory()
phase = dm.Phase(ode_class=BrachistochroneODE, transcription=t)
Expand Down

0 comments on commit b3485cc

Please sign in to comment.