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) );
41 $help_text{Pre_help_message} = <<'EOF';
44 Perl script for Stochastic Simulation and Estimation of NONMEM models.
49 $help_text{Options
} = <<'EOF';
52 The options are given here in their long form. Any option may be
53 abbreviated to any nonconflicting prefix. The -threads option
54 may be abbreviated to -t(or even -thr) but -debug may not be
55 abbreviated to -d because it conflicts with -debug_packages and
58 The following options are valid:
61 $help_text{-h
} = <<'EOF';
64 With -h or -? mc will print a list of options and exit.
67 $help_text{-help
} = <<'EOF';
70 With -help mc will print this, longer, help message.
73 $help_text{-alternative_models
} = <<'EOF';
74 -alternative_models=alt1.mod,alt2.mod,...
76 List of one or more alternative models to use for estimation
77 with simulated datasets. The filenames must be comma-separated,
81 $help_text{-samples
} = <<'EOF';
84 The number of simulated datasets to generate.
87 $help_text{-estimate_simulation
} = <<'EOF';
90 By default, the simulation model is also used for estimation with
91 the simulated datasets. The resulting OFV values are used as reference
92 when evaluating the estimation results of alternative models. By setting
93 -no-estimate_simulation the estimation of the simulation model is turned
94 off, and the first alternative model is used as reference instead. See
98 $help_text{-ref_ofv
} = <<'EOF';
101 Instead of using the OFV values from the estimation of a model as
102 reference when evaluating the other estimation results,
103 it is possible to set a fixed reference OFV value. If using ref_ofv,
104 it is not allowed to also estimate the simulation model.
106 $help_text{-parallel_simulations
} = <<'EOF';
107 -parallel_simulations=1
109 parallel_simulations govern the number of simulations that will
110 be done in parallel. Normally simulations are quite fast and
111 need only be run one at a time. See the threads option for
112 controll over the number of estimations to do in parallel.
115 $help_text{Post_help_message
} = <<'EOF';
116 Also see 'execute -help' for a description of common options.
119 common_options
::online_help
( 'sse', \
%options, \
%help_text, \
%required_options, \
%optional_options);
121 ## Check that we do have a model file
122 if ( scalar(@ARGV) < 1 ) {
123 print "A simulation model file must be specified. Use 'mc -h' for help.\n";
127 if( scalar(@ARGV) > 1 ){
128 print "SSE can only handle one modelfile, you listed: ",join(',',@ARGV),". Use 'mc -h' for help.\n";die;
132 unless ( defined $options{'samples'} ){
133 print "samples must be given\n" ;
137 unless ( defined $options{'clean'} ){
138 # Clean is by default much stricter in sse
139 $options{'clean'} = 3;
142 ui
-> category
( 'mc' );
143 ui
-> silent
(1) if( $options{'silent'} );
145 debug
-> level
( $options{'debug'} );
146 debug
-> package( $options{'debug_package'} );
147 debug
-> subroutine
( $options{'debug_subroutine'} );
148 debug
-> warn_with_trace
( $options{'warn_with_trace'} );
150 my $eval_string = common_options
::model_parameters
(\
%options);
152 my $model = model
-> new
( eval( $eval_string ),
153 filename
=> $ARGV[0],
154 ignore_missing_output_files
=> 1 );
159 if ( defined $options{'alternative_models'} ){
160 #split string, assume comma separated
161 foreach my $altfile (split(/,/,$options{'alternative_models'})){
162 if (length($altfile)>0){
163 my $alternative_model = model
->
164 new
( eval( $eval_string ),filename
=> $altfile,ignore_missing_output_files
=> 1 );
165 push(@alternatives,$alternative_model);
168 if (scalar(@alternatives)<1){
169 die "Error: Option alternative_models used, but list of filenames could not be parsed.\n";
172 print "No alternative model given, will only estimate simulation model.\n" ;
176 my $mc = tool
::sse
->
177 new
( eval( $common_options::parameters
),
178 estimate_simulation
=> $options{'estimate_simulation'},
179 ref_ofv
=> $options{'ref_ofv'},
180 parallel_simulations
=> $options{'parallel_simulations'},
181 models
=> [ $model ],
183 alternative_models
=> \
@alternatives,
184 samples
=> $options{'samples'} );
185 open(CMD
, ">", $mc -> directory
. "/command.txt");
186 print CMD
$cmd_line, "\n";
190 $mc -> prepare_results
;
191 $mc -> print_results
;