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_model:s' => 'alt1.mod,alt2.mod,...',
28 "selection_method:s" => '\'random\'|\'consecutive\'' );
30 my $res = GetOptions( \%options,
31 @common_options::get_opt_strings,
32 keys(%required_options),
33 keys(%optional_options) );
38 $help_text{Pre_help_message} = <<'EOF';
41 Perl script for Monte-Carlo Simulation of NONMEM runs.
46 $help_text{Options
} = <<'EOF';
49 The options are given here in their long form. Any option may be
50 abbreviated to any nonconflicting prefix. The -threads option
51 may be abbreviated to -t(or even -thr) but -debug may not be
52 abbreviated to -d because it conflicts with -debug_packages and
55 The following options are valid:
58 $help_text{-h
} = <<'EOF';
61 With -h or -? mc will print a list of options and exit.
64 $help_text{-help
} = <<'EOF';
67 With -help mc will print this, longer, help message.
70 $help_text{-alternative_model
} = <<'EOF';
71 -alternative_model=alt1.mod,alt2.mod,...
73 List of one or more alternative models to use for estimation
74 with simulated datasets. The filenames must be comma-separated,
78 $help_text{-bins
} = <<'EOF';
81 Sets the number of databins, or mc datasets, to use. If the
82 number of unique values, or factors, in the based_on column is
83 higher than the number of bins then one or more factors will be
84 deleted in each mc dataset. Specifying $number as higher than
85 the number of factors will have no effect. The bin number is
86 then set to the number of factors.
87 Default value = Number of unique values in the based_on column.
90 $help_text{-selection_method
} = <<'EOF';
91 -selection_method='random' or 'consecutive'
93 Specifies whether the factors selected for exclusion should be
94 drawn randomly or consecutively from the datafile.
95 Default value = 'consecutive'
99 $help_text{Post_help_message
} = <<'EOF';
100 Also see 'execute -help' for a description of common options.
103 common_options
::online_help
( 'mc', \
%options, \
%help_text, \
%required_options, \
%optional_options);
105 ## Check that we do have a model file
106 if ( scalar(@ARGV) < 1 ) {
107 print "A model file must be specified. Use 'mc -h' for help.\n";
111 if( scalar(@ARGV) > 1 ){
112 print "MC can only handle one modelfile. Use 'mc -h' for help.\n";die;
116 unless ( defined $options{'samples'} ){
117 print "samples must be given\n" ;
121 ui
-> category
( 'mc' );
122 ui
-> silent
(1) if( $options{'silent'} );
124 debug
-> level
( $options{'debug'} );
125 debug
-> package( $options{'debug_package'} );
126 debug
-> subroutine
( $options{'debug_subroutine'} );
127 debug
-> warn_with_trace
( $options{'warn_with_trace'} );
129 my $eval_string = common_options
::model_parameters
(\
%options);
131 my $model = model
-> new
( eval( $eval_string ),
132 filename
=> $ARGV[0],
133 ignore_missing_output_files
=> 1 );
138 if ( defined $options{'alternative_model'} ){
139 #split string, assume comma separated
140 foreach my $altfile (split(/,/,$options{'alternative_model'})){
141 if (length($altfile)>0){
142 my $alternative_model = model
->
143 new
( eval( $eval_string ),filename
=> $altfile,ignore_missing_output_files
=> 1 );
144 push(@alternatives,$alternative_model);
147 if (scalar(@alternatives)<1){
148 die "Error: Option alternative_model used, but list of filenames could not be parsed.\n";
151 print "No alternative model given, will only estimate original model.\n" ;
156 new
( eval( $common_options::parameters
),
157 models
=> [ $model ],
158 alternative_models
=> \
@alternatives,
159 samples
=> $options{'samples'} );
160 open(CMD
, ">", $mc -> directory
. "/command.txt");
161 print CMD
$cmd_line, "\n";
165 $mc -> print_results
;