@@ -288,7 +288,8 @@ mp_default_list = function(model, include_all = FALSE) {
288288
289289# ' @export
290290mp_default.TMBModelSpec = function (model , include_all = FALSE ) {
291- melt_default_matrix_list(mp_default_list(model , include_all ))
291+ lst = mp_default_list(model , include_all )
292+ melt_default_matrix_list(lst )
292293}
293294
294295# ' @export
@@ -303,7 +304,8 @@ mp_default_list.TMBModelSpec = function(model, include_all = FALSE) {
303304
304305# ' @export
305306mp_default.TMBSimulator = function (model , include_all = FALSE ) {
306- melt_default_matrix_list(mp_default_list(model , include_all ))
307+ lst = mp_default_list(model , include_all )
308+ melt_default_matrix_list(lst )
307309}
308310
309311# ' @export
@@ -458,6 +460,33 @@ mp_final_list.TMBSimulator = function(model) {
458460 mp_final(model ) | > cast_default_matrix_list()
459461}
460462
463+
464+ # ' Print Objective Function
465+ # '
466+ # ' @param model Model object with an objective function, probably a
467+ # ' calibrator produced using \code{\link{mp_tmb_calibrator}}.
468+ # '
469+ # ' @return Called to print the objective function for humans to read.
470+ # ' Invisibly returns the underlying objective function object that is
471+ # ' of limited utility.
472+ # '
473+ # ' @export
474+ mp_print_obj_fn = function (model ) UseMethod(" mp_print_obj_fn" )
475+
476+ # ' @export
477+ mp_print_obj_fn.TMBSimulator = function (model ) {
478+ obj_fn = model $ tmb_model $ obj_fn
479+ obj_formula = obj_fn $ formula_list()[[1L ]]
480+ obj_str = deparse1(obj_formula , width.cutoff = 500L )
481+ cat(obj_str )
482+ cat(" \n " )
483+ invisible (obj_fn )
484+ }
485+
486+ # ' @export
487+ mp_print_obj_fn.TMBCalibrator = function (model ) mp_print_obj_fn(model $ simulator )
488+
489+
461490# ' Simulate Dynamical Model Trajectories
462491# '
463492# ' Return simulations of the trajectory of the output
@@ -550,7 +579,7 @@ mp_trajectory.TMBSimulator = function(model, include_initial = FALSE) {
550579 if (length(macro ) > 1L ) macro = macro [[1L ]]
551580 if (length(macro ) < 1L ) macro = " simulate"
552581 traj = model [[macro ]](.phases = phases ) | > reset_rownames()
553- rm_no_info_traj_cols(traj , " matrix " )
582+ rm_no_info_traj_cols(traj )
554583}
555584
556585# ' @export
@@ -599,7 +628,7 @@ trajectory_par_util = function(simulator
599628 phases = trajectory_phases_util(include_initial , include_final )
600629 vector = trajectory_vec_util(simulator , parameter_updates , value_column_name )
601630 traj = simulator $ simulate(vector , .phases = phases )
602- rm_no_info_traj_cols(traj , " matrix " )
631+ rm_no_info_traj_cols(traj )
603632}
604633
605634trajectory_rep_util = function (n , simulator
@@ -766,7 +795,7 @@ mp_trajectory_sd.TMBSimulator = function(model
766795 vars = intersect(c(" value" , " conf.low" , " conf.high" ), names(r ))
767796 r = backtrans(r , vars , " matrix" , " sd" , " value" )
768797 }
769- rm_no_info_traj_cols(r , " matrix " )
798+ rm_no_info_traj_cols(r )
770799}
771800
772801# ' @export
@@ -782,7 +811,7 @@ mp_trajectory_sd.TMBCalibrator = function(model
782811 , back_transform
783812 )
784813 traj $ time = model $ time_steps_obj $ internal_to_external(traj $ time )
785- rm_no_info_traj_cols(traj , " matrix " )
814+ rm_no_info_traj_cols(traj )
786815}
787816
788817# ' @export
@@ -792,7 +821,7 @@ mp_trajectory_ensemble.TMBSimulator = function(model
792821 ) {
793822 best_pars = get_last_best_par(model $ ad_fun())
794823 traj = model $ report_ensemble(best_pars , .n = n , .probs = probs )
795- rm_no_info_traj_cols(traj , " matrix " )
824+ rm_no_info_traj_cols(traj )
796825}
797826
798827# ' @export
@@ -878,7 +907,7 @@ mp_trajectory_sim.TMBSimulator = function(model
878907 , n
879908 , probs = c(0.025 , 0.25 , 0.5 , 0.75 , 0.975 )
880909 ) {
881- r = model $ simulate() | > rm_no_info_traj_cols(" matrix " )
910+ r = model $ simulate() | > rm_no_info_traj_cols()
882911 r = r [, names(r ) != " value" , drop = FALSE ]
883912 rr = (n
884913 | > replicate(model $ simulate_values())
0 commit comments