Home Search Up Reference Manuals Return
Introduction
Command line options
Input data commands
Summary of all main commands
Detailed description of all commands
Alternatives
Examples
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.
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.
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.
CALC_IDENT | = | Sets the ident-text on the calculations performed by the subprogram. |
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. |
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_INIT | = | Define new inital values for the variables to optimize. |
RUNF_MAX | = | Defines the upper limit of RUNF_SUBST in automatic mode. |
RUNF_MIN | = | Defines the lower limit of RUNF_SUBST in automatic mode. |
RUNF_OPTI | = | Defines which component in RUNF_TEXT, that shall be controlled in automatic mode. |
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. |
Below follows a detailed description of all commands and its arguments:
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(99999)*80 Default= $ident_00001, $ident_00002, $ident_00003,,, etc.Starts the debug printing, if idbg is set equal to 1.
Declared= Integer*4 Default= 0 Don't start jobs in SUB_PROG if the CPU-load
is over l_limit.
The value l_limit is given in percent.
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 RUNF_MIN and RUNF_MAX, in all search directions. |
RegulaFalsi1 | Searches for the input data parameter set which makes the goal-function equal to 0(zero). |
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 with RUNF_MAX or RUNF_MIN within Tol_border. |
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 with RUNF_MAX or RUNF_MIN within Tol_border. |
gitter_min1 has the following arguments:
Tol_in | = | Terminates OPTI, when the search area is smaller than Tol_in. |
IF ((RUNF_MAX-RUNF_MIN).LT.TOL_IN*(1.+ABS((RUNF_MAX+RUNF_MIN)/2.))) STOP
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 |
IF (ABS(INPAR1-INPAR0).LT.TOL_D*(1.+ABS(INPAR1))) STOP
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 get an email, containing the standard output from the job. |
batch | = | The jobs will be run under the UNIX "batch" program. When a job is finished the user will get an email, 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
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 or
RUNF_OPTI.
Select if commands RUNF_SUBST shall use Basic- or Extended- Regular Expressions.
In the nedit-editor "Extended Regular Expressions" is used,
why it is recommended to use "Extended Regular Expressions" also here.
Define inital values for variables to optimize.
As default the optimization process start with the values as set in the READ_RUNF-file.
With this command the user has the possibility to start the optimization process from another point.
Defines the upper limit of RUNF_SUBST in automatic mode.
Program OPTI controls the value in the string RUNF_SUBST,
but the user has the possibility with RUNF_MAX to set the upper limits of the values.
Defines the lower limit of RUNF_SUBST in automatic mode.
Program OPTI controls the value in the string RUNF_SUBST,
but the user has the possibility with RUNF_MIN to set the lower limits of the values.
Defines which component in RUNF_TEXT, that shall be controlled in automatic mode.
The search expression defined by RUNF_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 <remembered pattern number>.
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:
RUNF_TEXT = '(p_lin pky) *(0.) *(40.e3)', RUNF_OPTI = '\3',
Command RUNF_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 RUNF_OPTI is set equal to \3.
Defines the substitution of RUNF_TEXT, in manual mode.
In command RUNF_TEXT the user defines the strings
found in file READ_RUNF which shall be replaced.
The <replacement strings> defined under command RUNF_SUBST shall form a matrix of character strings.
Number of columns in command RUNF_SUBST must correspond to number of components given under command RUNF_TEXT.
Number of rows in command RUNF_SUBST will correspond to number of cases to be run by program OPTI.
Please look under Examples.
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 RUNF_TEXT.
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 |
[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 further information regarding regular expression, see http://en.wikipedia.org/wiki/Regular_expression
Example #1
Search for a known line in the input data file.
RUNF_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.
RUNF_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.
RUNF_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 RUNF_OPTI
Declared= Character(100)*80 Default= Blank 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.
Stops further reading from the input data file.
Stops the execution in program OPTI after calculation number #istop.
Declared= Integer*4 Default= 99999Defines 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= BlankCreate 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= noIn case program OPTI is not suitable for your needs, there are alternatives:
1) Writing a 'for'-loop in a script:
E.g. you have many files with extension .XXX,
and you want to process them all in program PROG.
Then you can create a script called e.g. my_script.bat:
#!/bin/sh # Make a loop over all files having file extension .XXX # Environment variable "infile" will be set equal to the filenames. # One file at the time, in every loop. for infile in `echo *.XXX`; do # Set variable $ident to the basename of variable $infile ident=`basename $infile .XXX` # Create an input data file for program PROG, # by replacing all occurances of INFILE to $infile sed "s/INFILE/$infile/" Master.PROGf > $ident.PROGf # Launch program PROG: PROG $ident.PROGf # End of the loop done
Before launching your script you must create file Master.PROGf (where PROG is replaced by the name of your program). In file Master.PROGf you write the character string INFILE in all positions where you want the names of your files to be inserted.
Give the file execute permissions to the file by writing:
chmod a+x my_script.bat
Execute your script by writing:
./my_script.bat
2) Write a Makefile:
E.g. you have many input data files with extension .XXX,
that shall be translated into output data files with extension .YYY.
And it is only necessary to rerun the cases if the .XXX-file is newer than the .YYY-file
Then you can create a file named "Makefile":
SHELL = /bin/bash .SUFFIXES: MAKEFLAGS += --no-builtin-rules INFILES= $(shell ls *.XXX) OUTFILES= $(patsubst %.XXX,%.YYY,$(wildcard *.XXX)) all: $(OUTFILES) @echo @echo "Leaving file: Makefile" $(OUTFILES) : %.YYY : %.XXX Master.PROGf Makefile @echo @echo "Make $@ from $<" # # Create an input data file for program PROG sed -e "s/INFILE/$</" -e "s/OUTFILE/$@/" Master.PROGf > $(<:.XXX=.PROGf) # # Launch program PROG and send stdout to a file with extension .out PROG $(<:.XXX=.PROGf) 2>&1 | tee $(<:.XXX=.out)
Before launching "make" you must create file Master.PROGf (where PROG is replaced by the name of your program). In file Master.PROGf you write the character string INFILE in all positions where you want the names of your input data files to be inserted., and you write the character string OUTFILE in all positions where you want the names of your output data files to be inserted.
N.B. The commands in the Makefile must be prepended with a hard tab
Start the calculations by writing the command: make
Manual variation of conicity and speed
Evaluating all wheel and rail profiles in program KPF
Automatic optimization of primary- and secondary- dampers
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/tang_tirr.tsimf # Input data for sub_prog stop_after= 9999 # Stop the loop after XXX cases # q_sys = short # Send the jobs to a queue system load_limit= 100 # I.e. start all jobs immediately # # runf_text = 'kpf_[^ ]*', 'vkmh= *[^ ]*' runf_subst= 'kpf_uic_0.020', 'vkmh= 200', # Case #1 'kpf_uic_0.030', 'vkmh= 200', # Case #2 'kpf_uic_0.040', 'vkmh= 200', # Case #3 'kpf_uic_0.050', 'vkmh= 200', # Case #4 'kpf_uic_0.060', 'vkmh= 200', # Case #5 'kpf_uic_0.020', 'vkmh= 250', # Case #6 'kpf_uic_0.030', 'vkmh= 250', # Case #7 'kpf_uic_0.040', 'vkmh= 250', # Case #8 'kpf_uic_0.050', 'vkmh= 250', # Case #9 'kpf_uic_0.060', 'vkmh= 250', # Case #10 'kpf_uic_0.020', 'vkmh= 300', # Case #11 'kpf_uic_0.030', 'vkmh= 300', # Case #12 'kpf_uic_0.040', 'vkmh= 300', # Case #13 'kpf_uic_0.050', 'vkmh= 300', # Case #14 'kpf_uic_0.060', 'vkmh= 300', # Case #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/tang_tirr.tsimf > testfile.runf
Search expression #2:
sed -n 's/vkmh= *[^ ]*/vkmh= xxx/p' runf/tang_tirr.tsimf > testfile.runf
The nedit editor can also be used for testing your search expression. Please remember to check the Regular Expression toggle box in the Find popup menu.
## ## Input data for program OPTI ## ## opti_param manual_step sub_prog = kpf # Sub-program in the opti-loop read_runf = kpff/Master_different_profiles_i2kp0.kpff # Input data for sub_prog stop_after= 9999 # Stop the loop after XXX cases # q_sys = no # Do not send the jobs to a queue system q_sys = short # Send the jobs to a queue system load_limit= 100 # Don't start jobs if the CPU-load is over 80% # # runf_text = 'wheel_L' 'wheel_R' 'rail_L' 'rail_R' # The directories w_prof and r_prof and the file extension is already included in # kpff/Master_different_profiles_i2kp0.kpff. # Therefore the directories w_prof, r_prof and the file extensions must be removed from the filenames. runf_subst= ENS1002t30.0 ENS1002t30.0 Bdl416_1_km47_0422_L Bdl416_1_km47_0422_R ENS1002t30.0 ENS1002t30.0 Bdl416_1_km47_0434_L Bdl416_1_km47_0434_R ENS1002t30.0 . . . etc.
The table under command RUNF_SUBST can be created with the following UNIX-commands:
export NWHEEL=`ls -1 w_prof/*wheel | wc -l` ;# Number of wheel profiles in directory w_prof export NRAIL=`ls -1 r_prof/*rail | wc -l` ;# Number of rail profiles in directory r_prof del -q /tmp/w_prof.txt ls -1 w_prof/*.wheel | sed -e 's@^w_prof/@@' -e 's@.wheel$@@' | awk '{for(i=0;i<'$NRAIL';i++) print; print " "}' > /tmp/w_prof.txt del -q /tmp/r_prof.txt for ii in `seq 1 $NWHEEL`; do echo $ii ls -1 r_prof/*.rail | sed -e 's@^r_prof/@@' -e 's@.rail$@@' >> /tmp/r_prof.txt echo "" >> /tmp/r_prof.txt done pr -m -t /tmp/w_prof.txt /tmp/w_prof.txt /tmp/r_prof.txt /tmp/r_prof.txt | cc
After given the above commands in a terminal, paste the clipboard under command RUNF_SUBST above.
If there are different profiles on left and right side. Give the following commands:
export NWHEEL=`ls -1 w_prof/*_L_*wheel | wc -l` ;# Number of wheel profiles on the left side in directory w_prof export NRAIL=`ls -1 r_prof/*_L_*rail | wc -l` ;# Number of rail profiles on the left side in directory r_prof del -q /tmp/w_prof_L.txt ls -1 w_prof/*_L_*.wheel | sed -e 's@^w_prof/@@' -e 's@.wheel$@@' | awk '{for(i=0;i<'$NRAIL';i++) print; print " "}' > /tmp/w_prof_L.txt del -q /tmp/w_prof_R.txt ls -1 w_prof/*_R_*.wheel | sed -e 's@^w_prof/@@' -e 's@.wheel$@@' | awk '{for(i=0;i<'$NRAIL';i++) print; print " "}' > /tmp/w_prof_R.txt del /tmp/r_prof_L.txt for ii in `seq 1 $NWHEEL`; do echo $ii ls -1 r_prof/*_L_*.rail | sed -e 's@^r_prof/@@' -e 's@.rail$@@' >> /tmp/r_prof_L.txt echo "" >> /tmp/r_prof_L.txt done del /tmp/r_prof_R.txt for ii in `seq 1 $NWHEEL`; do echo $ii ls -1 r_prof/*_R_*.rail | sed -e 's@^r_prof/@@' -e 's@.rail$@@' >> /tmp/r_prof_R.txt echo "" >> /tmp/r_prof_R.txt done pr -m -t /tmp/w_prof_L.txt /tmp/w_prof_R.txt /tmp/r_prof_L.txt /tmp/r_prof_R.txt | cc
After given the above commands in a terminal, paste the clipboard under command RUNF_SUBST above.
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 damping coefficients in dampers 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/tang_tirr.tsimf # Input data for sub_prog stop_after= 9999 # Stop the loop after XXX cases # # # Test the search expression on expanded runf-file: # sed -n 's/(coupl) *(p_lin) *(cbl1) *([^ ]*) *([^ ]*)/\1 \2 \3 \4 xxx/p' x.exp2f # sed -n 's/(coupl) *(p_lin) *(cykb1) *([^ ]*) *([^ ]*)/\1 \2 \3 \4 xxx/p' x.exp2f # runf_text= '(coupl) *(p_lin) *(cbl1) *([^ ]*) *([^ ]*)', '(coupl) *(p_lin) *(cykb1) *([^ ]*) *([^ ]*)', # runf_opti= '\5', '\5', runf_max = 100e3 100e3 runf_min = 10e3 10e3 # # scal_opti = car_1b2.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.