6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
17 my $cmd_line = $0 . " " . join( " ", @ARGV );
19 ## Configure the command line parsing
20 Getopt::Long::config("auto_abbrev");
23 ## Declare the options
25 my %required_options = ( 'samples:i' => '100');
26 my %optional_options = ( 'alternative_models:s' => 'alt1.mod,alt2.mod,...',
28 'parallel_simulations:i' => '1',
29 'estimate_simulation!' => '1' );
31 #"selection_method:s" => '\'random\'|\'consecutive\'' );
33 my $res = GetOptions( \%options,
34 @common_options::get_opt_strings,
35 keys(%required_options),
36 keys(%optional_options) );
39 common_options::set_globals( \%options, 'sse' );
40 common_options::get_defaults( \%options, 'sse' );
41 common_options::sanity_checks( \%options, 'sse' );
45 $help_text{Pre_help_message} = <<'EOF';
48 Perl script for Stochastic Simulation and Estimation of NONMEM models.
53 $help_text{Options
} = <<'EOF';
56 The options are given here in their long form. Any option may be
57 abbreviated to any nonconflicting prefix. The -threads option
58 may be abbreviated to -t(or even -thr) but -debug may not be
59 abbreviated to -d because it conflicts with -debug_packages and
62 The following options are valid:
65 $help_text{-h
} = <<'EOF';
68 With -h or -? sse will print a list of options and exit.
71 $help_text{-help
} = <<'EOF';
74 With -help sse will print this, longer, help message.
77 $help_text{-alternative_models
} = <<'EOF';
78 -alternative_models=alt1.mod,alt2.mod,...
80 List of one or more alternative models to use for estimation
81 with simulated datasets. The filenames must be comma-separated,
85 $help_text{-samples
} = <<'EOF';
88 The number of simulated datasets to generate.
91 $help_text{-estimate_simulation
} = <<'EOF';
94 By default, the simulation model is also used for estimation with
95 the simulated datasets. The resulting OFV values are used as reference
96 when evaluating the estimation results of alternative models. By setting
97 -no-estimate_simulation the estimation of the simulation model is turned
98 off, and the first alternative model is used as reference instead. See
102 $help_text{-ref_ofv
} = <<'EOF';
105 Instead of using the OFV values from the estimation of a model as
106 reference when evaluating the other estimation results,
107 it is possible to set a fixed reference OFV value. If using ref_ofv,
108 it is not allowed to also estimate the simulation model.
110 $help_text{-parallel_simulations
} = <<'EOF';
111 -parallel_simulations=1
113 parallel_simulations govern the number of simulations that will
114 be done in parallel. Normally simulations are quite fast and
115 need only be run one at a time. See the threads option for
116 controll over the number of estimations to do in parallel.
119 $help_text{Post_help_message
} = <<'EOF';
120 Also see 'execute -help' for a description of common options.
123 common_options
::online_help
( 'sse', \
%options, \
%help_text, \
%required_options, \
%optional_options);
125 ## Check that we do have a model file
126 if ( scalar(@ARGV) < 1 ) {
127 print "A simulation model file must be specified. Use 'sse -h' for help.\n";
131 if( scalar(@ARGV) > 1 ){
132 print "SSE can only handle one modelfile, you listed: ",join(',',@ARGV),". Use 'sse -h' for help.\n";die;
136 unless ( defined $options{'samples'} ){
137 print "samples must be given\n" ;
141 unless ( defined $options{'clean'} ){
142 # Clean is by default much stricter in sse
143 $options{'clean'} = 3;
146 my $eval_string = common_options
::model_parameters
(\
%options);
148 my $model = model
-> new
( eval( $eval_string ),
149 filename
=> $ARGV[0],
150 ignore_missing_output_files
=> 1 );
155 if ( defined $options{'alternative_models'} ){
156 #split string, assume comma separated
157 foreach my $altfile (split(/,/,$options{'alternative_models'})){
158 if (length($altfile)>0){
159 my $alternative_model = model
->
160 new
( eval( $eval_string ),filename
=> $altfile,ignore_missing_output_files
=> 1 );
161 push(@alternatives,$alternative_model);
164 if (scalar(@alternatives)<1){
165 die "Error: Option alternative_models used, but list of filenames could not be parsed.\n";
168 print "No alternative model given, will only estimate simulation model.\n" ;
172 my $sse = tool
::sse
->
173 new
( eval( $common_options::parameters
),
174 estimate_simulation
=> $options{'estimate_simulation'},
175 ref_ofv
=> $options{'ref_ofv'},
176 parallel_simulations
=> $options{'parallel_simulations'},
177 models
=> [ $model ],
179 alternative_models
=> \
@alternatives,
180 samples
=> $options{'samples'} );
181 open(CMD
, ">", $sse -> directory
. "/command.txt");
182 print CMD
$cmd_line, "\n";
186 $sse -> prepare_results
;
187 $sse -> print_results
;