def test_di_integrator_pure_with_complete_guess(self): # solve Problem for the first time first_guess = {'seed': 20} S1 = TransitionProblem(rhs_di, a=0.0, b=2.0, xa=xa_di, xb=xb_di, ua=0, ub=0, show_ir=False, ierr=None, first_guess=first_guess, use_chains=False) S1.solve() assert S1.reached_accuracy first_guess2 = { 'complete_guess': S1.eqs.sol, 'n_spline_parts': aux.Container(x=S1.eqs.trajectories.n_parts_x, u=S1.eqs.trajectories.n_parts_u) } S2 = S1.create_new_TP(first_guess=first_guess2) S2.solve() assert S2.reached_accuracy # now test changed boundary conditions S3 = S2.create_new_TP(first_guess=first_guess2, xb=[1.5, 0.0]) S3.solve() assert S3.reached_accuracy
def test_get_attributes_from_object(self): c = aux.Container(x=0, y=1.0, z="abc") c.a = 10 y = aux.get_attributes_from_object(c) a, z, x = aux.get_attributes_from_object(c) assert a == c.a assert z == c.z assert x == c.x assert y == c.y # test whether meaningful exception is raised with pytest.raises(NameError): _ = aux.get_attributes_from_object(c)
plt.subplot(rows, 2, i + 1) plt.plot(tt, data[i], 'b', lw=3, label='sim') plt.grid(1) # plt.savefig("ivp.pdf") print xx[-1, :] plt.show() # für Animation S.sim_data = (tt, xx, uu) sys.exit() elif 0: # Simulation is ready, now try to reproduce this solution via collocation refsol = aux.Container(tt=tt, xx=xx, uu=uu, n_raise_spline_parts=0) #xb = xx2[-1, :]*1.0 S2 = TransitionProblem(model_rhs, a=Ta, b=Tb, xa=xa, xb=xb, ua=uu[0, :], ub=uu[-1, :], use_chains=False, refsol=refsol, ierr=None, maxIt=3, eps=1e-1,
xa = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] xb = [pi, pi, pi, 0.0, 0.0, 0.0, 0.0, 0.0] # S = ControlSystem(model_rhs, Ta, Tb, xa, xb, ua, ub) # state, u = S.solve() # constraints for the velocity of the car # con = {"x7": [-4, 4]} con = {} if __name__ == "__main__": args = aux.Container( poolsize=3, ff=model_rhs, a=Ta, xa=xa, xb=xb, ua=0, ub=0, use_chains=False, ierr=None, maxIt=5, eps=4e-1, kx=2, use_std_approach=False, seed=[1, 2, 30, 81], constraints=con, show_ir=False, b=2.4 + np.r_[.4, .5] ) if "single" in sys.argv: args.b = 3.7 args.maxIt = 7 args.dict.pop("poolsize") args.show_ir = True args.seed = 1 args.maxIt = 4 TP1 = TransitionProblem(**args.dict) results = xx, uu = TP1.solve() # ensure that the result is compatible with system dynamics
# con = {"x7": [-4, 4]} con = {} if __name__ == "__main__": args = aux.Container( poolsize=2, ff=model_rhs, a=Ta, xa=xa, xb=xb, ua=0, ub=0, use_chains=False, ierr=None, maxIt=5, eps=4e-1, kx=2, use_std_approach=False, seed=[ 1, ], constraints=con, show_ir=True, b=3.7 # + np.r_[0, .1, .2, .3, .4, .5] ) if "single" in sys.argv: args.b = 3.7 args.maxIt = 7 args.dict.pop("poolsize")