7 # Don't edit the line below, it must look exactly like this.
8 # Everything above this line will be replaced #
23 my $cmd_line = $0 . " " . join( " ", @ARGV );
27 my %optional_options = ( "predict_data:s" => undef,
28 "predict_model:s" => undef );
30 my $res = GetOptions( \%options,
31 @common_options::get_opt_strings,
32 keys(%optional_options) );
36 common_options::set_globals( \%options, 'execute');
37 common_options::get_defaults( \%options, 'execute' );
38 common_options::sanity_checks( \%options, 'execute' );
39 common_options::online_help('execute', \%options, undef,{},{});
43 if( $options{'outputfile'} ){
44 @outputfiles = split( /,/, $options{'outputfile'} );
47 if ( scalar( @ARGV ) < 1 ) {
48 unless( $options{'summarize'} and $options{'outputfile'} and not $options{'force'} ){
49 print "At least one model file must be specified. Use 'execute -h' for help.\n";
58 my $eval_string = common_options::model_parameters(\%options);
60 foreach my $model_name ( @ARGV ){
61 my $outputfile = shift @outputfiles;
64 $model = model -> new ( eval( $eval_string ),
65 outputfile => $outputfile,
66 filename => $model_name,
67 ignore_missing_output_files => 1 );
69 if( $options{'nonparametric_etas'} or
70 $options{'nonparametric_marginals'} ) {
71 $model -> add_nonparametric_code;
74 if( $options{'shrinkage'} ) {
75 $model -> shrinkage_stats( enabled => 1 );
78 unless( -e $outputfile ){
79 print "The output file: $outputfile doesn't exist.\n";
82 $model = model -> new( eval( $eval_string ),
83 outputfile => $outputfile,
84 filename => 'dummy.mod',
85 ignore_missing_files => 1 );
88 push( @{$models_array}, $model );
92 if ( defined $options{'predict_data'} and defined $options{'predict_model'} ) {
93 if( scalar @{$models_array} > 1 ) {
94 debug -> die( message => "When using predict_data and predict_model, no "
95 ."more than one model at a time may be run with execute" );
97 my $outfile = $options{'predict_model'};
98 $outfile =~ s/\.mod//;
99 $outfile = $outfile.'.lst';
100 my $pred_mod = $models_array -> [0] -> copy( filename => $options{'predict_model'},
103 $pred_mod -> datafiles( new_names => [$options{'predict_data'}] );
104 $pred_mod -> ignore_missing_files(1);
105 $pred_mod -> outputfile( $outfile );
106 $pred_mod -> maxeval( new_values => [[0]] );
107 $pred_mod -> remove_records( type => 'covariance' );
108 $pred_mod -> update_inits( from_model => $models_array -> [0] );
110 foreach my $file ( @{$pred_mod -> table_names -> [0]} ) {
111 push( @new_tables, $options{'predict_model'}.'.'.$file );
113 $pred_mod -> table_names( new_names => [\@new_tables] );
114 $modelfit = tool::modelfit ->
115 new ( eval( $common_options::parameters ),
116 models => [$pred_mod] );
118 $modelfit = tool::modelfit ->
119 new ( eval( $common_options::parameters ),
120 models => $models_array );
123 open(CMD, ">", $modelfit -> directory . "/command.txt");
124 print CMD $cmd_line, "\n";
129 if( $options{'summarize'} ){
130 $modelfit -> summarize;