Fixed $PRIOR support and bugfix in shrinkage results handling
[PsN.git] / lib / model / problem / record / theta_option_subs.pm
blobd166ffdce6ba53e60da11f5e065209a8919adb71
1 start _read_option
3 my ( $line, $comment ) =
4 split( ";", $self -> {'option_string'}, 2 );
6 ## Split and store labels and units
7 if ( defined $comment ) {
8 my ($label,$unit) = split( ";",$comment,2 );
9 chomp $label if $label;
10 chomp $unit if $unit;
11 $self -> {'label'} = $label;
12 $self -> {'unit'} = $unit;
15 # $line should be one theta now
16 chomp( $line );
17 $line =~ s/\)//g;
18 $line =~ s/\(//g;
19 $line =~ s/\s+//g;
21 ## Find fix
22 $self -> {'fix'} = $line =~ s/FIX\w*// ? 1 : 0;
24 my @inits = split( ",", $line );
25 if ( $#inits <= 0) {
26 $self -> {'init'} = $inits[0];
27 $self -> {'lobnd'} = undef;
28 $self -> {'upbnd'} = undef;
29 } else {
30 $self -> {'lobnd'} = $inits[0];
31 $self -> {'init'} = $inits[1];
32 $self -> {'upbnd'} = $inits[2];
35 if( defined $self -> {'lobnd'} and $self -> {'lobnd'} =~ /INF/ ){
36 # use Data::Dumper;
37 # print Dumper $PsN::config;
38 $self -> {'lobnd'} = $PsN::config -> {'low_INF'};
39 # print $self -> {'lobnd'};
42 if( defined $self -> {'upbnd'} and $self -> {'upbnd'} =~ /INF/ ){
43 $self -> {'upbnd'} = $PsN::config -> {'high_INF'};
46 # print 'Found lobnd: ',$self -> {'lobnd'},
47 # ', init: ',$self -> {'init'},
48 # ', upbnd: ',$self -> {'upbnd'},
49 # ', label: ',$self -> {'label'},
50 # ', unit: ',$self -> {'unit'},"\n"
51 # if ( $self -> {'debug'} );
52 end _read_option
54 start _format_option
56 my $to_long = 0;
57 my $modifier = 0;
58 my $init = $self -> {'init'};
59 if( length($init) > 8 ){
60 if( $init < 1 && $init > -1 ){
61 if( length($init) - 2 > 8 ){
62 $to_long = 1;
63 } else {
64 $init =~ s/0\././;
66 } else {
67 $to_long = 1;
68 $init = 0.0001;
71 if( $to_long ){
72 debug -> warn( level => 1,
73 message => "Warning: initial theta value: \"".$self -> {'init'}."\"is to loong, replacing with 0.0001" );
76 if ( ( defined $self -> {'upbnd'} ) or
77 ( defined $self -> {'lobnd'} ) ) {
78 $formatted = $formatted."(".
79 $self -> {'lobnd'}.",";
80 $formatted = $formatted.$init;
81 # $formatted = $formatted.sprintf("%6f",$init);
82 #.$init;
83 $formatted = $formatted.",".$self -> {'upbnd'}
84 if ( defined $self -> {'upbnd'} );
85 $formatted = $formatted.")";
86 } else {
87 # $formatted = sprintf("%6f",$init);
88 $formatted = $formatted.$init;
91 if ( $self -> {'fix'} ) {
92 $formatted = $formatted.sprintf("%5s",'FIX');
93 # $formatted = $formatted." "x(30-length($formatted));
94 # $formatted = $formatted.' FIX ';
95 } else {
96 $formatted = $formatted." ";
99 # $formatted = $formatted." "x(40-length($formatted));
100 $formatted = $formatted." ; "
101 if ( ( defined $self -> {'label'} ) or
102 ( defined $self -> {'unit'} ) );
103 if ( defined $self -> {'label'} ) {
104 $formatted = $formatted.sprintf("%15.15s",$self -> {'label'});
107 if ( defined $self -> {'unit'} ) {
108 $formatted = $formatted." ;".sprintf("%15.15s",$self -> {'unit'});
109 # $formatted = $formatted." "x(57-length($formatted))."; ";
110 # $formatted = $formatted.$self -> {'unit'};
113 # $formatted = $formatted." "x(64-length($formatted))."\n";
115 end _format_option