Home    Reference Manuals    Return   



Users Manual for Program OPTI  




Table of contents

1) Introduction

2) Command line options

3) Input data commands

   3.1) Summary of all main commands
   3.2) Detailed description of all commands

4) Examples

blurulr2.gif

1) Introduction

Program OPTI starts multiple calculations. The command, script or program which is going to be executed is defined in the input data command SUB_PROG. In each step program OPTI sends the following string to the system:
SUB_PROG READ_RUNF

In command OPTI_PARAM the user can select if program OPTI shall automatically optimize a goal-function, or if each run shall be predefined in RUNF_SUBST.

The user can gracefully stop the execution of program OPTI, if he or she creates a file named opti_stop. The calculations can later be continued with the option -append_overwrite.

blurulr2.gif

2) Command line options

For program OPTI a number of command line options are available. The user can put his or hers favorite options in a file named .gen_conf. Program OPTI searches primarily for the .gen_conf-file in the local working directory. If the file not can be found in the local working directory, program OPTI searches for the .gen_conf-file in the users home-directory. At last if no .gen_conf-file can be found program OPTI reads the file $gensys/bin/gen_conf. Following options are understood:

-addarg = Prompt for more arguments before calculation starts
-no_addarg = Do not prompt for more arguments
-break = If a case terminates abnormally, stop further execution in program OPTI.
-no_break = If a case terminates abnormally, just continue with the next case.
-debug = Don't remove temporary work files after execution
-no_debug = Keep temporary work files after execution
-help = Print this help information
-overwrite = Overwrite old results without questions.
-no_overwrite = Prompt the user before old results are overwritten.
-append_overwrite = Append new results to old results.
(The order of the results will be reordered, if the order of the runf_subst-commands have been changed)
-qident = Prompt the user for an ident before starting the execution.
-no_qident = Use the base name of the input data file as the ident-string.
-run = Create input data files for the subprogram, and run the cases.
-no_run = Do not run the cases, only create input data files for the subprogram.
-save_runf = Save a copy of the created runf-file for each case.
-no_save_runf = Do not save copies of the runf-files.
     
-no_queue = Do not run OPTI in a queue system.
-at_queue "at_time" = Run program CALC under at and send a mail when the job is finished. Under "at_queue" the user can specify a time when the calculation shall start. If "at_time" is set equal to "now", the calculations will start immediately.
-batch_queue "time" = Run program OPTI under batch and send a mail when the job is finished. Under time the user can specify when the calculation shall start. If time is set equal to now, the calculations will start immediately.
The difference between at and batch is that in batch the execution of program OPTI only starts when the system load level is below 0.8.
N.B. batch only works under the LINUX operating system.
-nohup_queue = Run OPTI under nohup. When the calculations are ready the user will be noticed in a mail.
     
arg(1) = Input data file
arg(2) = Ident

Default values for the options above can be set in a local file named gen_conf or .gen_conf. If not gen_conf or .gen_conf exists in the local directory, program OPTI will look for the file $HOME/.gen_conf, where $HOME is your home directory. If not $HOME/.gen_conf exists, program OPTI will open and read the file $gensys/bin/gen_conf.

N.B. the files gen_conf or .gen_conf must have execute permission, in order to work properly. Please write the following UNIX-command:

 chmod 755 gen_conf .gen_conf 

When program OPTI sends the jobs to a queue system, program OPTI uses the script $genys/bin/q_sys. The user must change the $genys/bin/q_sys-script, so it will work together with the local queue system on the computer.

blurulr2.gif

3) Input data commands

Input data are read in free format, valid separators between the input values are <space>, <comma>, <tab>, <equal sign> or <carriage return>. The commands can be written both in lower and upper case letters. The operation of the program is controlled by the commands described below; some of the commands also need arguments.

3.1) Summary of all main commands

CALC_IDENT = Sets the ident-text on the calculations performed by the subprogram.
EXPF_INIT = Define new inital values for the variables to optimize.
EXPF_MAX = Defines the upper limit of EXPF_SUBST in automatic mode.
EXPF_MIN = Defines the lower limit of EXPF_SUBST in automatic mode.
EXPF_OPTI = Defines which component in EXPF_TEXT, that shall be controlled in automatic mode.
EXPF_SUBST = Defines the substitution of EXPF_TEXT, in manual mode.
EXPF_TEXT = Defines the string in expanded input data file, which shall be replaced.
IDEBUG = Starts the debug printing
LOAD_LIMIT = Only start jobs if the CPU-load is low.
OPTI_PARAM = Defines the operation mode in program OPTI.
PARALLEL = Start jobs in parallel.
Q_SYS = Start jobs in a queue system.
READ_RUNF = Defines the input data file for SUB_PROG.
REGEXP = Select type of regular expressions to be used
RUNF_SUBST = Defines the substitution of RUNF_TEXT, in manual mode.
RUNF_TEXT = Defines the string in input data file, which shall be replaced.
SCAL_OPTI = Defines the goal-function which shall be optimized.
STOP = Stops further reading from the input data file.
STOP_AFTER = Stops the execution in program OPTI after calculation number #istop.
SUB_PROG = Defines the sub-program which shall be executed in program OPTI.
WRITE_IDENT_NO = Creates a variable in the subprogram named "ident_no", containing the number of the calculation.
blurulr2.gif

3.2) Detailed description of all commands

Below follows a detailed description of all commands and its arguments:


CALC_IDENT <ident-strings>

Sets the ident-string on the calculations performed by the subprogram. The user can manually define different idents on the different calculations performed by SUB_PROG. As default program OPTI will give same idents to the subprogram as the ident of the OPTI activity, but program OPTI will add three digits after the ident-string.

Declared= Character*80(999)    Default= $ident_001,$ident_002, $ident_003 ,,,etc.


EXPF_INIT <upper limits>

Define inital values for variables to optimize.
As default the optimization process start with the values as defined in the READ_RUNF-file. With this command the user has the possibility to start the optimization process from another point.

Declared= Real*4(200)    Default= As defined in file READ_RUNF


EXPF_MAX <upper limits>

Defines the upper limit of EXPF_SUBST in automatic mode. Program OPTI controls the value in the string EXPF_TEXT, but the user has the possibility in EXPF_MAX to set the upper limits of the values.

Declared= Real*4(200)    Default= 1.e30


EXPF_MIN <lower limits>

Defines the lower limit of EXPF_SUBST in automatic mode. Program OPTI controls the value in the string EXPF_TEXT, but the user has the possibility in EXPF_MIN to set the lower limits of the values.

Declared= Real*4(200)    Default= -1.e30


EXPF_OPTI <quoted digit>

Defines which component in EXPF_TEXT, that shall be controlled in automatic mode. The search expression defined by EXPF_TEXT must contain one or more "remembered patterns". The number of which remembered pattern to be controlled by program OPTI shall be given here as <quoted digit>.
To create a remembered pattern, enclose the pattern within ()-parentheses. Each parentheses in the expression is given a number in the same order as its appearance.
Program OPTI is using the UNIX sed-command when substituting values in the input data file for program SUB_PROG. For further information about the sed-editor and regular expressions, please write the opman sed in a terminal window.
Example:

                                                     
 EXPF_TEXT = '(p_lin pky)  *(0.)  *(40.e3)',         
 EXPF_OPTI  = '\3',                                  
                                                     

Command EXPF_TEXT defines the search expression which is:
p_lin pky 0. 40.e3

The expression is divided into the following three remembered patterns:
1) p_lin pky
2) 0.
3) 40.e3

The spacing between the parts can consist of one or more spaces. Program OPTI shall optimize the value of parentheses number three, therefore command EXPF_OPTI is set equal to \3.

Declared= Character*4(200)    Default= Blank


EXPF_SUBST <replacement strings>

Defines the substitution of EXPF_TEXT, in manual mode.
In command EXPF_TEXT the user defines the strings found in file READ_RUNF which shall be replaced. The <replacement strings> defined under command EXPF_SUBST shall form a matrix of character strings. Number of columns in command EXPF_SUBST must correspond to number of components given under command EXPF_TEXT. Number of rows in command EXPF_SUBST will correspond to number of cases to be run by program OPTI.
Please look under Examples.

Declared= Character*80(200,200)    Default= Blank


EXPF_TEXT <search strings>

Defines the string in expanded input data file READ_RUNF, which shall be replaced.
EXPF_TEXT is written as a regular expression in UNIX, where the characters ^,$,*,\,[xy] and [^x] have special meanings.
The meanings are summarized in the following table:

^ The beginning of the line
$ The end of the line
[xy] Matches both x and y.
[a-z] Matches all lower case letter.
[0-9] Matches all numbers.
[^x] Matches any character except x.
. Any character.
* Repeats the character in front of the *-sign, the character will be repeated zero or more times.
\ Quote the next character. Example: if you are searching for a $-sign you must write \$ in the search expression.

For the full description of regular expressions please read the UNIX manual pages, please write opman re_syntax or opman regexp in a terminal- or genfile-window.

Example #1
Search for a known line in the input data file.

                                        
  EXPF_TEXT= 'coupl p_lin pky 0. 10.'   
                                        

Program OPTI will simply search and replace the string 'coupl p_lin pky 0. 10.' for you.

Example #2
Search for a partly known line in the input data file.

                                               
  EXPF_TEXT= 'coupl p_lin pky 0. [^ ][^ ]*'    
                                               

Program OPTI will search and replace the string 'coupl p_lin pky 0. ' + 'one more character string, consisting of at least one character'. The extra character string may consist of any characters except the <space> character.

Example #3
Design an expression which can be used in automatic mode.

                                                 
  EXPF_TEXT= '(p_lin pky 0.)  *([^ ][^ ]*)'      
                                                 

The expression must be written as a remembered pattern, in order to make it possible to design a replacement string in command EXPF_OPTI

Declared= Character*80(200)    Default= Blank


IDEBUG <idbg>

Starts the debug printing, if idbg is set equal to 1.
Declared= Integer*4    Default= 0


LOAD_LIMIT <l_limit>

Don't start jobs in SUB_PROG if the CPU-load is over l_limit.
The value l_limit is given in percent.
Declared= Integer*4
Default= 100 % (I.e. all jobs will start immediately)


OPTI_PARAM metod indata(*)

Defines the operation mode in program OPTI.
Program OPTI can run in different modes, one manual mode and three automatic modes. In the automatic modes a goal-function must be defined in command SCAL_OPTI. Command `opti_param` has the following subcommands:

manual_step Run OPTI in manual mode, predefined cases
grad_min1 Minimizing a goal-function by searching in the direction of the gradient
grad_min2 Minimizing a goal-function by searching in all direction, one at the time
gitter_min1 Minimizing a goal-function by performing 5 calculations between EXPF_MIN and EXPF_MAX, in all search directions.
RegulaFalsi1 Searches for the input data parameter set which makes the goal-function equal to 0(zero).
manual_step
Program OPTI will run in manual mode. All calculation cases must be defined by the user in command EXPF_SUBST and/or RUNF_SUBST. Mode manual_step do not have any arguments.

grad_min1 Linj_eps, F_linesearch, Tol_bottom, Tol_linj, Tol_dire, Tol_border
Automatic mode where program OPTI will minimize a goal-function in the following way:
  1. Linearization at current position in order to calculate the gradient.
  2. Move in the direction given by the gradient, until the minimum point is passed.
  3. Make a bottom search using the golden ratio method.
The steps above will be repeated until the tolerance is fulfilled. Grad_min1 has the following arguments:
Linj_eps = Epsilon when creating the gradient in step 1. above.
Fl_search = Factor defining the size of the steps towards the min.point in step 2. above.
Tol_bottom = Tolerance which stops further bottom search in step 3. above. And makes program OPTI to start with step 1. again.
Tol_linj = Terminates OPTI normally, because the old min.point in the old optimum search direction is equal to the new min.point in the new optimum search direction, within Tol_linj.
Tol_dire = Terminates OPTI normally, because the old optimum search direction is equal to the new optimum search direction, within Tol_dire.
Tol_border = Terminates OPTI normally, because the min.point is on a border defined in EXPF_MAX and/or EXPF_MIN within Tol_border.

grad_min2 Linj_eps, F_linesearch, Tol_bottom, Tol_linj, Tol_dire, Tol_border
Automatic mode where program OPTI will minimize a goal-function in the following way:
  1. Program OPTI finds the minimum point by searching in one search direction at the time. Number of search direction are defined in EXPF_TEXT
  2. Search in each search direction, until the minimum point is passed.
  3. Make a bottom search using the golden ratio method in this search direction.
The steps above will be repeated until the tolerance is fulfilled. Grad_min2 has the following arguments:
Linj_eps = In the beginning of a new search direction, make a first calculation with offset Linj_eps, in order to determine in which way to continue with the search direction.
Fl_search = Factor defining the size of the steps towards the min.point in step 2. above.
Tol_bottom = Tolerance which stops further bottom search in step 3. above. And makes program OPTI to start with a new search direction.
Tol_linj = Terminates OPTI normally, because the min.point in the first search direction equals the min.point after searching in all search directions, within Tol_linj.
Tol_dire = Not used.
Tol_border = Terminates OPTI normally, because the min.point is on a border defined in EXPF_MAX and/or EXPF_MIN within Tol_border.

gitter_min1 Tol_in
Automatic mode where program OPTI will minimize a goal-function in the following way:
  1. Performs 5 calculations between EXPF_MIN and EXPF_MAX, in each direction according to EXPF_TEXT.
  2. Pick up the best result from all calculations.
  3. Narrow the search area around the best point and start from 1 again.
Tol_in = Terminates OPTI, when the search area is smaller than Tol_in.
The tolerance is both absolute and relative. In FORTRAN the test is written according to:
                                                                         
 IF ((EXPF_MAX-EXPF_MIN).LT.TOL_IN*(1.+ABS((EXPF_MAX+EXPF_MIN)/2.))) STOP 
                                                                         

RegulaFalsi1 Linj_eps, Tol_res, Tol_inpar
Automatic mode where program OPTI will search for a input data which makes the goal-function equal to zero. Method RegulaFalsi1 operates in the following way:
  1. The first calculation will be made with original input data, according to the file read_runf.
  2. The second calculation will have a small offset Linj_eps in input data.
  3. Search for zero goal-function according to the secant method (Regula Falsi). Break when the tolerance Tol_res or Tol_inpar is fulfilled.

Method RegulaFalsi1 has the following arguments:
Linj_eps = The offset in the second calculation.
Tol_res = Tolerance in the value of the goal-function. The type of tolerance is absolute.
Tol_inpar = Tolerance in the value of the input data parameter. The tolerance is a combination of absolute tolerance and relative tolerance

The tolerance Tol_inpar is in FORTRAN written according to:
                                                         
 IF (ABS(INPAR1-INPAR0).LT.TOL_D*(1.+ABS(INPAR1))) STOP  
                                                         
PACK_RUNF <Yes/No>

Pack the expanded RUNF-file before starting the calculation in SUB_PROG.
Before the execution starts in SUB_PROG program OPTI expands all insert- commands in the RUNF-file. If the user so wish the RUNF-file can also be compressed, all delimiters 'equal sign', 'space','tab' and 'comma' will be replaced with only one 'space'.
Declared= Character*3    Default= Yes

-->
PARALLEL <npara>

Start jobs in SUB_PROG in parallel.
Up to "npara" jobs will simultaneously be sent to the system. Program OPTI will not send more jobs until the first job is finished.

If "npara" equals 0(zero) there will be no limitations in number of jobs sent to the queue-system.

N.B. In Q_SYS a queue system must be defined.
Declared= Integer*4    Default= 1 i.e. no parallel jobs.


Q_SYS <qtype>

Start jobs in SUB_PROG in a queue system.
Qtype can be given the following values:

no = No queue system is defined the jobs will be run in current process.
at = The jobs will be run under the UNIX "at" program. When a job is finished the user will obtain a mail, containing the standard output from the job.
nohup = The jobs will be run under the UNIX "nohup" program. I.e the jobs will be running immune to hangups. Standard output from the job will be written to the local file nohup.out.
short = The job is sent to script $gensys/bin/q_sys. The user must modify this file, in order to startup right queue-system in the local network.
long = The job is sent to script $gensys/bin/q_sys. The user must modify this file, in order to startup right queue-system in the local network.
night = The job is sent to script $gensys/bin/q_sys. The user must modify this file, in order to startup right queue-system in the local network.

Declared= Character*16    Default= no


READ_RUNF <input data file>

Base input data file for program SUB_PROG.
The input data file will be send to SUB_PROG after it has been modified by RUNF_SUBST, EXPF_SUBST or EXPF_OPTI.
Declared= Character*132    Default= Blank


REGEXP <type of regular expressions>

Select if "Basic" Regular Expressions or "Extended" Regular Expressions shall be used in the commands RUNF_SUBST and EXPF_SUBST. In the nedit-editor extended regular expressions are used, therefore it is also the default here in program OPTI.
Declared= Character*8    Default= Extended


RUNF_SUBST <replacement strings>

Defines the substitution of RUNF_TEXT, in manual mode. Input data to RUNF_SUBST shall be written in the same way as the input data to command EXPF_SUBST.
Declared= Character(200,200)*80    Default= Blank


RUNF_TEXT <search strings>

Defines the string in input data file READ_RUNF, which shall be replaced.
Input data to RUNF_TEXT shall be written in the same way as the input data to command EXPF_TEXT. The difference between RUNF_TEXT and EXPF_TEXT is that RUNF_TEXT searches in the unexpanded file READ_RUNF, but command EXPF_TEXT searches in the READ_RUNF-file after all insert- and in_substruct-commands have been executed. Since command RUNF_TEXT searches in the unexpanded READ_RUNF-file, it makes it possible to change the names of the files referred to in the insert-commands.
Example: Change the wheel-rail geometry function.

                               
 runf_text = 'kpf_s1002_sj50', 
 runf_subst= 'kpf_uic_0.020',  
             'kpf_uic_0.030',  
             'kpf_kona_0.020', 
             'kpf_kona_0.030', 
                               

The search strings given in command RUNF_TEXT shall be written as an UNIX regular expression, i.e. some characters have special meanings. Example:

^ The beginning of the line
$ The end of the line
\ Quote the next character. Example: if you are searching for a $-sign you must write \$ in the search expression.
* Repeats the character in front of the *-sign, the character will be repeated zero or more times.
[xy] Matches both x and y.
[^x] Matches any character except x.

For the full description of regular expressions please read the UNIX manual pages, please write opman re_syntax or opman regexp in a terminal- or genfile-window.

Declared= Character(200)*80    Default= Blank


SCAL_OPTI <scalar>

Defines the goal-function which shall be optimized.
The goal-function is calculated in program MPLOT and stored as a scalar in the MPdat-file *.mp after the execution of program MPLOT. The scalar is not read if program OPTI is running in manual mode.
Declared= Character*24    Default= Blank


STOP

Stops further reading from the input data file.


STOP_AFTER <istop>

Stops the execution in program OPTI after calculation number #istop.
Declared= Integer*4    Default= 999


SUB_PROG <prog>

Defines the sub-program which shall be executed by program OPTI. Any executable program or script can be started from here, not only programs in the gensys-package. However the program or script must be found in your search path. In order to see your search path, please write echo $PATH in a terminal window.
Declared= Character*80    Default= Blank


WRITE_IDENT_NO <answer>

Create and store a variable named ident_no. Variable ident_no contains the number of the calculation. The variable is created if answer equals y or yes.
Declared= Character*3    Default= no

blurulr2.gif

4) Examples

Table of contents:
4.1) Manual variation of conicity and speed
4.2) Automatic optimization of primary- and secondary- dampers

4.1) Manual variation of conicity and speed

Following example: manual_speed.optif can be used as a master file:


                                                                          
##                                                                        
##      Input data for program OPTI                                       
##                                                                        
##                                                                        
 opti_param manual_step                                                   
 sub_prog  = tsim                  # Sub-program in the opti-loop         
 read_runf = runf/Master.runf      # Input data for sub_prog              
 stop_after= 999                   # Stop the loop after xxx cases        
#                                                                         
 q_sys     = at          # Send the jobs to a queue system                
 parallel  =  2          # Start jobs in parallel                         
 load_limit= 80          # Don't start jobs if the CPU-load is over 80%   
#                                                                         
#                                                                         
 runf_text = 'kpf_[^ ]*',       'Vo= *[^ ]*'                              
 runf_subst= 'kpf_uic_0.020',   'Vo= 200',              # Run  #1         
             'kpf_uic_0.030',   'Vo= 200',              # Run  #2         
             'kpf_uic_0.040',   'Vo= 200',              # Run  #3         
             'kpf_uic_0.050',   'Vo= 200',              # Run  #4         
             'kpf_uic_0.060',   'Vo= 200',              # Run  #5         
             'kpf_uic_0.020',   'Vo= 250',              # Run  #6         
             'kpf_uic_0.030',   'Vo= 250',              # Run  #7         
             'kpf_uic_0.040',   'Vo= 250',              # Run  #8         
             'kpf_uic_0.050',   'Vo= 250',              # Run  #9         
             'kpf_uic_0.060',   'Vo= 250',              # Run #10         
             'kpf_uic_0.020',   'Vo= 300',              # Run #11         
             'kpf_uic_0.030',   'Vo= 300',              # Run #12         
             'kpf_uic_0.040',   'Vo= 300',              # Run #13         
             'kpf_uic_0.050',   'Vo= 300',              # Run #14         
             'kpf_uic_0.060',   'Vo= 300',              # Run #15         
#                                                                         
 calc_ident= uic20_lam20_V200                                             
             uic30_lam30_V200           # Define own idents               
             uic40_lam40_V200           # on all cases.                   
             uic50_lam50_V200                                             
             uic60_lam60_V200                                             
             uic20_lam20_V250                                             
             uic30_lam30_V250                                             
             uic40_lam40_V250                                             
             uic50_lam50_V250                                             
             uic60_lam60_V250                                             
             uic20_lam20_V300                                             
             uic30_lam30_V300                                             
             uic40_lam40_V300                                             
             uic50_lam50_V300                                             
             uic60_lam60_V300                                             
                                                                          
 scal_opti= goal_function                                                 
                                                                          

In order to check the search expression in your input data file you can use the UNIX sed-command in the following way:

Search expression #1:
sed -n 's/kpf_[^ ]*/kpf_xxx/p' runf/Master.runf > testfile.runf

Search expression #2:
sed -n 's/Vo= *[^ ]*/Vo= xxx/p' runf/Master.runf > testfile.runf


4.2) Automatic optimization of primary- and secondary- dampers


Following example: auto_damp.optif can be used as a master file:

                                                                                      
##                                                                                    
##      Input data for program OPTI                                                   
##                                                                                    
##                                                                                    
##                                                                                    
## Optimize Ride Index Wz over the rear bogie by                                      
## changing the properties of damper cbl and cykb.                                    
## -----------------------------------------------                                    
##                                                                                    
##                                                                                    
##                  Linj_eps F_linesearch Tol_bottom Tol_linj Tol_dire Tol_border     
 opti_param grad_min1 0.001   0.1           0.001    0.005    0.001    0.001          
 sub_prog  = tsim                    # Sub-program in the opti-loop                   
 read_runf = runf/Master.runf        # Input data for sub_prog                        
 stop_after= 999                     # Stop the loop after 999 cases                  
#                                                                                     
#                                                                                     
# Test the search expression on expanded runf-file                                    
#                                                                                     
#sed -n 's/(coupl)  *([^ ]*)  *(cbl1)  *([^ ]*)  *([^ ]*) \                           
#         /\1 \2 \3 \4 xxx/p' x.exp2f                                                 
#sed -n 's/(coupl)  *([^ ]*)  *(cykb1)  *([^ ]*)  *([^ ]*) \                          
#         /\1 \2 \3 \4 xxx/p' x.exp2f                                                 
#                                                                                     
 expf_text= '(coupl)  *([^ ]*)  *(cbl1)  *([^ ]*)  *([^ ]*)',                         
            '(coupl)  *([^ ]*)  *(cykb1)  *([^ ]*)  *([^ ]*)',                        
#                                                                                     
 expf_opti= '\5', '\5',                                                               
 expf_max =  100e3 100e3                                                              
 expf_min =   10e3  10e3                                                              
#                                                                                     
#                                                                                     
 scal_opti  = car1b2.WZy                                                              
 write_ident_no= yes                                                                  
                                                                                      

In order to check the search expression in the expanded file, make an initial run of the input data file runf/x.runf in program PREDAT. Program PREDAT will generate a expanded file *.exp2f for you.


Home    Reference Manuals