1 # {{{ include statements
3 start include statements
4 use model
::problem
::record
::init_option
;
7 # }}} include statements
13 if ( defined $self -> options
) {
14 foreach my $option ( @
{$self -> options
} ){
15 $option -> restore_init
;
23 # {{{ set_random_inits
24 start set_random_inits
26 if ( defined $self -> options
and not $self -> {'same'} and
27 not $self -> {'fix'} ) {
28 foreach my $option ( @
{$self -> options
} ){
29 $option -> set_random_init
( degree
=> $degree );
34 # }}} set_random_inits
39 if ( defined $self -> options
) {
40 foreach my $option ( @
{$self -> options
} ){
41 $option -> store_init
;
53 model
::problem
::record
::init_option
->
54 new
( option_string
=> $option_string,
55 on_diagonal
=> $on_diagonal,
57 push( @
{$self -> {'options'}}, $opt_obj ) if( $opt_obj );
67 my @class_names = split('::',ref($self));
68 my $fname = uc(pop(@class_names));
69 $formatted[0] = "\$".$fname." ";
72 my $otype = $self -> {'type'};
73 my $same = $self -> {'same'};
74 my $fix = $self -> {'fix'};
75 my $size = $self -> {'size'};
77 if ( defined $otype ) {
78 $formatted[0] = $formatted[0]." $otype";
79 if ( defined $size ) {
80 $formatted[0] = $formatted[0]."($size)";
83 $formatted[0] = $formatted[0]." FIX";
86 $formatted[0] = $formatted[0]." SAME\n";
90 $len = length $formatted[0];
91 if ( defined $self -> {'options'} ) {
92 foreach my $option ( @
{$self -> {'options'}} ) {
94 $formatted[0] = $formatted[0].' '.
95 $option -> _format_option
( len
=> $len)."\n";
98 $formatted[0] = $formatted[0]."\n";
101 if ( defined $self -> {'comment'} ) {
102 push( @formatted, @
{$self -> {'comment'}} );
103 $formatted[$#formatted] = $formatted[$#formatted];
118 my ( $any_fixed, $block_fixed ) = ( 0, 0 );
119 if ( defined $self -> {'record_arr'} ) {
120 my ( $digit, $comment, $fixed ) = ( undef, undef, 0 );
121 for ( @
{$self -> {'record_arr'}} ) {
126 next unless( length($_) > 0 );
128 # This is a comment row
129 push( @
{$self -> {'comment'}}, $_ . "\n" );
131 # Make sure that the labels and units are in one string
133 # Get rid of unwanted spaces
138 $any_fixed++ if /FIX/;
139 $self -> {'type'} = 'DIAGONAL' if /DIAG\w*/;
140 $self -> {'type'} = 'BLOCK' if /BLOCK*/;
141 $self -> {'size'} = $2
142 if s/^\s*(BLOCK|DIAG\w*)\s*\((\d+)\)\s*//;
143 $self -> {'same'} = 1 if s/SAME//;
145 my ( $line, $line_comment ) = split( ";", $_, 2 );
146 @row = split( " ",$line );
147 for ( my $i = 0; $i <= $#row; $i++ ) {
150 if ( defined $digit ) {
151 push( @digits, $digit );
152 push( @fix , $fixed );
153 push( @comments, $comment );
155 $comment = $i == $#row ?
$line_comment : undef;
158 } elsif ( /FIX/ and not $fixed ) {
161 die "init_record_subs -> _read_options: Unknown option $_\n";
166 if ( defined $digit ) {
167 push( @digits, $digit );
168 push( @fix , $fixed );
169 push( @comments, $comment );
173 $block_fixed = 1 if ( $any_fixed and $self -> {'type'} eq 'BLOCK' );
174 $self -> {'fix'} = $block_fixed;
178 for ( my $i = 0; $i <= $#digits; $i++ ) {
179 if ( $self -> {'type'} eq 'BLOCK' ) {
180 if ( $i+1 == $row*($row+1)/2 ) {
190 $fix[$i] = 0 if ( $block_fixed );
191 my $com_str = defined $comments[$i] ?
';'.$comments[$i] : '';
192 $self -> _add_option
( option_string
=> $digits[$i].$com_str,
194 on_diagonal
=> $on_diag );
197 # if ( defined $self -> {'record_arr'} ) {
198 # for ( @{$self -> {'record_arr'}} ) {
200 # next unless( length($_) > 0 );
201 # # Split inits and labels/units
202 # my ( $line, $comment ) = split( ";", $_, 2 );
203 # # Split the init string to see if we have more than one init.
204 # @row = split( " ",$line );
206 # # If we only have one init, send the whole row to option
207 # $self -> _add_option( option_string => $_ );
208 # print "LINE: $_\n";
209 # print "adding one init\n";
210 # # if ( $self -> {'debug'} );
212 # # If we have more than one init, send one init at a time to option
213 # print "LINE: $_\n";
214 # print "adding ",$#row+1," inits\n";
215 # # if ( $self -> {'debug'} );
217 # $self -> _add_option( option_string => $_ );