1212import scipy as sp
1313import scipy .optimize
1414
15- from ..config import _process_legacy_keyword
15+ from ..config import _process_kwargs , _process_param
1616from ..exception import ControlArgument
1717from ..nlsys import NonlinearIOSystem
18+ from ..optimal import _optimal_aliases
1819from ..timeresp import _check_convert_array
1920from .poly import PolyFamily
2021from .systraj import SystemTrajectory
@@ -325,7 +326,8 @@ def _basis_flag_matrix(sys, basis, flag, t):
325326
326327# Solve a point to point trajectory generation problem for a flat system
327328def point_to_point (
328- sys , timepts , x0 = 0 , u0 = 0 , xf = 0 , uf = 0 , T0 = 0 , cost = None , basis = None ,
329+ sys , timepts , initial_state = 0 , initial_input = 0 , final_state = 0 ,
330+ final_input = 0 , initial_time = 0 , integral_cost = None , basis = None ,
329331 trajectory_constraints = None , initial_guess = None , params = None , ** kwargs ):
330332 """Compute trajectory between an initial and final conditions.
331333
@@ -340,32 +342,30 @@ def point_to_point(
340342 and produces the flag of flat outputs and a function
341343 `~FlatSystem.reverse` that takes the flag of the flat output and
342344 produces the state and input.
343-
344345 timepts : float or 1D array_like
345346 The list of points for evaluating cost and constraints, as well as
346347 the time horizon. If given as a float, indicates the final time for
347348 the trajectory (corresponding to xf)
348-
349- x0, u0, xf, uf : 1D arrays
350- Define the desired initial and final conditions for the system. If
351- any of the values are given as None, they are replaced by a vector of
352- zeros of the appropriate dimension.
353-
354- T0 : float, optional
349+ initial_state (or x0) : 1D array_like
350+ Initial state for the system. Defaults to zero.
351+ initial_input (or u0) : 1D array_like
352+ Initial input for the system. Defaults to zero.
353+ final_state (or xf) : 1D array_like
354+ Final state for the system. Defaults to zero.
355+ final_input (or uf) : 1D array_like
356+ Final input for the system. Defaults to zero.
357+ initial_time (or T0) : float, optional
355358 The initial time for the trajectory (corresponding to x0). If not
356359 specified, its value is taken to be zero.
357-
358360 basis : `BasisFamily` object, optional
359361 The basis functions to use for generating the trajectory. If not
360362 specified, the `PolyFamily` basis family
361363 will be used, with the minimal number of elements required to find a
362364 feasible trajectory (twice the number of system states)
363-
364- cost : callable
365+ integral_cost (or cost) : callable
365366 Function that returns the integral cost given the current state
366- and input. Called as ``cost(x, u)``.
367-
368- trajectory_constraints : list of tuples, optional
367+ and input. Called as ``integral_cost(x, u)``.
368+ trajectory_constraints (or constraints) : list of tuples, optional
369369 List of constraints that should hold at each point in the time
370370 vector. Each element of the list should consist of a tuple with
371371 first element given by `scipy.optimize.LinearConstraint` or
@@ -382,38 +382,54 @@ def point_to_point(
382382 trajectory and compared against the upper and lower bounds.
383383
384384 The constraints are applied at each time point along the trajectory.
385-
386385 initial_guess : 2D array_like, optional
387386 Initial guess for the trajectory coefficients (not implemented).
388-
389387 params : dict, optional
390388 Parameter values for the system. Passed to the evaluation
391389 functions for the system as default values, overriding internal
392390 defaults.
393391
394- minimize_method : str, optional
395- Set the method used by `scipy.optimize.minimize`.
396-
397- minimize_options : str, optional
398- Set the options keyword used by `scipy.optimize.minimize`.
399-
400- minimize_kwargs : str, optional
401- Pass additional keywords to `scipy.optimize.minimize`.
402-
403392 Returns
404393 -------
405394 traj : `SystemTrajectory` object
406395 The system trajectory is returned as an object that implements the
407396 `~SystemTrajectory.eval` function, we can be used to
408397 compute the value of the state and input and a given time t.
409398
399+ Other Parameters
400+ ----------------
401+ minimize_method : str, optional
402+ Set the method used by `scipy.optimize.minimize`.
403+ minimize_options : str, optional
404+ Set the options keyword used by `scipy.optimize.minimize`.
405+ minimize_kwargs : str, optional
406+ Pass additional keywords to `scipy.optimize.minimize`.
407+
410408 Notes
411409 -----
412410 Additional keyword parameters can be used to fine tune the behavior of
413411 the underlying optimization function. See `minimize_*` keywords in
414412 `OptimalControlProblem` for more information.
415413
416414 """
415+ # Process parameter and keyword arguments
416+ _process_kwargs (kwargs , _optimal_aliases )
417+ x0 = _process_param (
418+ 'initial_state' , initial_state , kwargs , _optimal_aliases , sigval = 0 )
419+ u0 = _process_param (
420+ 'initial_input' , initial_input , kwargs , _optimal_aliases , sigval = 0 )
421+ xf = _process_param (
422+ 'final_state' , final_state , kwargs , _optimal_aliases , sigval = 0 )
423+ uf = _process_param (
424+ 'final_input' , final_input , kwargs , _optimal_aliases , sigval = 0 )
425+ T0 = _process_param (
426+ 'initial_time' , initial_time , kwargs , _optimal_aliases , sigval = 0 )
427+ cost = _process_param (
428+ 'integral_cost' , integral_cost , kwargs , _optimal_aliases )
429+ trajectory_constraints = _process_param (
430+ 'trajectory_constraints' , trajectory_constraints , kwargs ,
431+ _optimal_aliases )
432+
417433 #
418434 # Make sure the problem is one that we can handle
419435 #
@@ -431,13 +447,6 @@ def point_to_point(
431447 Tf = timepts [- 1 ]
432448 T0 = timepts [0 ] if len (timepts ) > 1 else T0
433449
434- # Process keyword arguments
435- trajectory_constraints = _process_legacy_keyword (
436- kwargs , 'constraints' , 'trajectory_constraints' ,
437- trajectory_constraints , warn_oldkey = False )
438- cost = _process_legacy_keyword (
439- kwargs , 'trajectory_cost' , 'cost' , cost , warn_oldkey = False )
440-
441450 minimize_kwargs = {}
442451 minimize_kwargs ['method' ] = kwargs .pop ('minimize_method' , None )
443452 minimize_kwargs ['options' ] = kwargs .pop ('minimize_options' , {})
@@ -657,8 +666,8 @@ def traj_const(null_coeffs):
657666
658667# Solve a point to point trajectory generation problem for a flat system
659668def solve_flat_optimal (
660- sys , timepts , x0 = 0 , u0 = 0 , trajectory_cost = None , basis = None ,
661- terminal_cost = None , trajectory_constraints = None ,
669+ sys , timepts , initial_state = 0 , initial_input = 0 , integral_cost = None ,
670+ basis = None , terminal_cost = None , trajectory_constraints = None ,
662671 initial_guess = None , params = None , ** kwargs ):
663672 """Compute trajectory between an initial and final conditions.
664673
@@ -673,31 +682,25 @@ def solve_flat_optimal(
673682 and produces the flag of flat outputs and a function
674683 `~FlatSystem.reverse` that takes the flag of the flat output and
675684 produces the state and input.
676-
677685 timepts : float or 1D array_like
678686 The list of points for evaluating cost and constraints, as well as
679687 the time horizon. If given as a float, indicates the final time for
680688 the trajectory (corresponding to xf)
681-
682- x0, u0 : 1D arrays
683- Define the initial conditions for the system. If either of the
684- values are given as None, they are replaced by a vector of zeros of
685- the appropriate dimension.
686-
689+ initial_state (or x0), input_input (or u0) : 1D arrays
690+ Define the initial conditions for the system (default = 0).
691+ initial_input (or u0) : 1D array_like
692+ Initial input for the system. Defaults to zero.
687693 basis : `BasisFamily` object, optional
688694 The basis functions to use for generating the trajectory. If not
689695 specified, the `PolyFamily` basis family
690696 will be used, with the minimal number of elements required to find a
691697 feasible trajectory (twice the number of system states)
692-
693- trajectory_cost : callable
698+ integral_cost : callable
694699 Function that returns the integral cost given the current state
695700 and input. Called as ``cost(x, u)``.
696-
697701 terminal_cost : callable
698702 Function that returns the terminal cost given the state and input.
699703 Called as ``cost(x, u)``.
700-
701704 trajectory_constraints : list of tuples, optional
702705 List of constraints that should hold at each point in the time
703706 vector. Each element of the list should consist of a tuple with
@@ -715,15 +718,22 @@ def solve_flat_optimal(
715718 trajectory and compared against the upper and lower bounds.
716719
717720 The constraints are applied at each time point along the trajectory.
718-
719721 initial_guess : 2D array_like, optional
720722 Initial guess for the optimal trajectory of the flat outputs.
721-
722723 params : dict, optional
723724 Parameter values for the system. Passed to the evaluation
724725 functions for the system as default values, overriding internal
725726 defaults.
726727
728+ Returns
729+ -------
730+ traj : `SystemTrajectory`
731+ The system trajectory is returned as an object that implements the
732+ `SystemTrajectory.eval` function, we can be used to
733+ compute the value of the state and input and a given time `t`.
734+
735+ Other Parameters
736+ ----------------
727737 minimize_method : str, optional
728738 Set the method used by `scipy.optimize.minimize`.
729739
@@ -733,13 +743,6 @@ def solve_flat_optimal(
733743 minimize_kwargs : str, optional
734744 Pass additional keywords to `scipy.optimize.minimize`.
735745
736- Returns
737- -------
738- traj : `SystemTrajectory`
739- The system trajectory is returned as an object that implements the
740- `SystemTrajectory.eval` function, we can be used to
741- compute the value of the state and input and a given time `t`.
742-
743746 Notes
744747 -----
745748 Additional keyword parameters can be used to fine tune the behavior of
@@ -758,6 +761,18 @@ def solve_flat_optimal(
758761 used to overcome these errors.
759762
760763 """
764+ # Process parameter and keyword arguments
765+ _process_kwargs (kwargs , _optimal_aliases )
766+ x0 = _process_param (
767+ 'initial_state' , initial_state , kwargs , _optimal_aliases , sigval = 0 )
768+ u0 = _process_param (
769+ 'initial_input' , initial_input , kwargs , _optimal_aliases , sigval = 0 )
770+ trajectory_cost = _process_param (
771+ 'integral_cost' , integral_cost , kwargs , _optimal_aliases )
772+ trajectory_constraints = _process_param (
773+ 'trajectory_constraints' , trajectory_constraints , kwargs ,
774+ _optimal_aliases )
775+
761776 #
762777 # Make sure the problem is one that we can handle
763778 #
@@ -770,12 +785,6 @@ def solve_flat_optimal(
770785 timepts = np .atleast_1d (timepts )
771786 T0 = timepts [0 ] if len (timepts ) > 1 else 0
772787
773- # Process keyword arguments
774- trajectory_constraints = _process_legacy_keyword (
775- kwargs , 'constraints' , 'trajectory_constraints' , trajectory_constraints )
776- trajectory_cost = _process_legacy_keyword (
777- kwargs , 'cost' , 'trajectory_cost' , trajectory_cost )
778-
779788 minimize_kwargs = {}
780789 minimize_kwargs ['method' ] = kwargs .pop ('minimize_method' , None )
781790 minimize_kwargs ['options' ] = kwargs .pop ('minimize_options' , {})
0 commit comments