ElmerParam Manual. Copyright. 1 Introduction. 2 General overview. Erik Edelmann and Peter Råback CSC IT Center for Science.

Hasonló dokumentumok
Széchenyi István Egyetem

Mapping Sequencing Reads to a Reference Genome

Construction of a cube given with its centre and a sideline

Proxer 7 Manager szoftver felhasználói leírás

SQL/PSM kurzorok rész

Using the CW-Net in a user defined IP network

USER MANUAL Guest user

Miskolci Egyetem Gazdaságtudományi Kar Üzleti Információgazdálkodási és Módszertani Intézet. Hypothesis Testing. Petra Petrovics.

(NGB_TA024_1) MÉRÉSI JEGYZŐKÖNYV

Computer Architecture

On The Number Of Slim Semimodular Lattices

Az Open Data jogi háttere. Dr. Telek Eszter

Miskolci Egyetem Gazdaságtudományi Kar Üzleti Információgazdálkodási és Módszertani Intézet Nonparametric Tests

Angol Középfokú Nyelvvizsgázók Bibliája: Nyelvtani összefoglalás, 30 kidolgozott szóbeli tétel, esszé és minta levelek + rendhagyó igék jelentéssel

discosnp demo - Peterlongo Pierre 1 DISCOSNP++: Live demo

Basic Arrays. Contents. Chris Wild & Steven Zeil. May 28, Description 3

Adatbázis-kezelés ODBC driverrel

Miskolci Egyetem Gazdaságtudományi Kar Üzleti Információgazdálkodási és Módszertani Intézet. Nonparametric Tests. Petra Petrovics.

Utasítások. Üzembe helyezés

Correlation & Linear Regression in SPSS

Cluster Analysis. Potyó László

Create & validate a signature

EN United in diversity EN A8-0206/419. Amendment

ELEKTRONIKAI ALAPISMERETEK ANGOL NYELVEN

T Á J É K O Z T A T Ó. A 1108INT számú nyomtatvány a webcímen a Letöltések Nyomtatványkitöltő programok fülön érhető el.

Statistical Inference

Csatlakozás a BME eduroam hálózatához Setting up the BUTE eduroam network

Cloud computing. Cloud computing. Dr. Bakonyi Péter.

Contact us Toll free (800) fax (800)

Cloud computing Dr. Bakonyi Péter.

16F628A megszakítás kezelése

Lopocsi Istvánné MINTA DOLGOZATOK FELTÉTELES MONDATOK. (1 st, 2 nd, 3 rd CONDITIONAL) + ANSWER KEY PRESENT PERFECT + ANSWER KEY

Statistical Dependence

Supporting Information

AZ ACM NEMZETKÖZI PROGRAMOZÓI VERSENYE

Website review acci.hu

Phenotype. Genotype. It is like any other experiment! What is a bioinformatics experiment? Remember the Goal. Infectious Disease Paradigm

ANGOL NYELV KÖZÉPSZINT SZÓBELI VIZSGA I. VIZSGÁZTATÓI PÉLDÁNY

Judas 1 1 Judas 6. Judas

Tudományos Ismeretterjesztő Társulat

Ültetési és öntözési javaslatok. Planting and watering instructions

Hogyan használja az OROS online pótalkatrész jegyzéket?

Société Réaliste / Ocular Braces

BKI13ATEX0030/1 EK-Típus Vizsgálati Tanúsítvány/ EC-Type Examination Certificate 1. kiegészítés / Amendment 1 MSZ EN :2014

3. MINTAFELADATSOR KÖZÉPSZINT. Az írásbeli vizsga időtartama: 30 perc. III. Hallott szöveg értése

OLYMPICS! SUMMER CAMP

ANGOL NYELV KÖZÉPSZINT SZÓBELI VIZSGA I. VIZSGÁZTATÓI PÉLDÁNY

Személyes adatváltoztatási formanyomtatvány- Magyarország / Personal Data Change Form - Hungary

Tájékoztató a évi határon átnyúló pénzügyi fogyasztói jogviták rendezésével összefüggő és egyéb nemzetközi tevékenységről

Cashback 2015 Deposit Promotion teljes szabályzat

ENROLLMENT FORM / BEIRATKOZÁSI ADATLAP

SOPHOS simple + secure. A dobozba rejtett biztonság UTM 9. Kókai Gábor - Sophos Advanced Engineer Balogh Viktor - Sophos Architect SOPHOS

ELEKTRONIKAI ALAPISMERETEK ANGOL NYELVEN

Genome 373: Hidden Markov Models I. Doug Fowler

Intézményi IKI Gazdasági Nyelvi Vizsga

Számítógépes Hálózatok GY 8.hét

STUDENT LOGBOOK. 1 week general practice course for the 6 th year medical students SEMMELWEIS EGYETEM. Name of the student:

ELEKTRONIKAI ALAPISMERETEK ANGOL NYELVEN

(Asking for permission) (-hatok/-hetek?; Szabad ni? Lehet ni?) Az engedélykérés kifejezésére a következő segédigéket használhatjuk: vagy vagy vagy

Miskolci Egyetem Gazdaságtudományi Kar Üzleti Információgazdálkodási és Módszertani Intézet Factor Analysis

Minta ANGOL NYELV KÖZÉPSZINT SZÓBELI VIZSGA II. Minta VIZSGÁZTATÓI PÉLDÁNY

EBBEN A VIZSGARÉSZBEN A VIZSGAFELADAT ARÁNYA

Smaller Pleasures. Apróbb örömök. Keleti lakk tárgyak Répás János Sándor mûhelyébõl Lacquerware from the workshop of Répás János Sándor

Teszt topológia E1/1 E1/0 SW1 E1/0 E1/0 SW3 SW2. Kuris Ferenc - [HUN] Cisco Blog -

Lexington Public Schools 146 Maple Street Lexington, Massachusetts 02420

Csima Judit április 9.

3. MINTAFELADATSOR EMELT SZINT. Az írásbeli vizsga időtartama: 30 perc. III. Hallott szöveg értése

There is/are/were/was/will be

INDEXSTRUKTÚRÁK III.

Materiális javak - az Oracle Database tárgyi emlékei az elmúlt 25 évből. HOUG Konferencia Siófok Kovács József, John Milton Kft.

FÖLDRAJZ ANGOL NYELVEN

Bevezetés a kvantum-informatikába és kommunikációba 2015/2016 tavasz

Az egészségügyi munkaerő toborzása és megtartása Európában

General information for the participants of the GTG Budapest, 2017 meeting

Budapest By Vince Kiado, Klösz György

Adattípusok. Max. 2GByte

KIEGÉSZÍTŽ FELADATOK. Készlet Bud. Kap. Pápa Sopr. Veszp. Kecsk Pécs Szomb Igény

Correlation & Linear Regression in SPSS

Adattípusok. Max. 2GByte

ELEKTRONIKAI ALAPISMERETEK ANGOL NYELVEN

Flight Tool V2. Basic setting. The interface is as follow when running the software: A szoftver felülete:

Készítette: Szabóné Nacsa Rozália

Word and Polygon List for Obtuse Triangular Billiards II

Személyes adatváltoztatási formanyomtatvány - Magyarország / Personal Data Change Form - Hungary

A jövedelem alakulásának vizsgálata az észak-alföldi régióban az évi adatok alapján

Rezgésdiagnosztika. Diagnosztika

Tavaszi Sporttábor / Spring Sports Camp május (péntek vasárnap) May 2016 (Friday Sunday)

This document has been provided by the International Center for Not-for-Profit Law (ICNL).

TestLine - Angol teszt Minta feladatsor

ELEKTRONIKAI ALAPISMERETEK ANGOL NYELVEN

Adatbázisok 1. Rekurzió a Datalogban és SQL-99

Ensemble Kalman Filters Part 1: The basics

KELER KSZF Zrt. bankgarancia-befogadási kondíciói. Hatályos: július 8.

fátyolka tojásgy jtœ lap [CHRegg] összeszereléséhez

Kiegészítők telepítése Installing Addons

Előszó.2. Starter exercises. 3. Exercises for kids.. 9. Our comic...17

Tudományos Ismeretterjesztő Társulat

Website review mozogjotthon.com

Unit 10: In Context 55. In Context. What's the Exam Task? Mediation Task B 2: Translation of an informal letter from Hungarian to English.

SQL/PSM tárolt modulok rész

Átírás:

ElmerParam Manual Erik Edelmann and Peter Råback CSC IT Center for Science December 19, 2018 Copyright This document is licensed under the Creative Commons Attribution-No Derivative Works 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/. 1 Introduction ElmerParam is a simple tool for parametrized computation for software that uses ASCII-format input and output les. It was primarily designed to be used with Elmer, but can easily be used with other software packages as well. The parametrized approach is particularly useful for optimization purposes. ElmerParam exists both as a standalone program and as a library with bindings for C, Fortran, R and Matlab. In this document, the following designations are used: [whatever] whatever is optional. A B either A xor B. ${ELMER_HOME} Environment variable supposed to be set to the directory where Elmer (including ElmerParam) was installed. ElmerParam (in normal font) The ElmerParam package. ElmerParam (this font) The standalone ElmerParam program. 2 General overview ElmerParam acts a layer between computational programs such as Elmer- Solver and programs that wants to call the computational programs as func- 1

Caller Function result Parameters Command file: ElmerParam Input File = Whatever.sif Execute = ElmerSolver Output File = Yahoo.dat Yahoo.dat.model Whatever.sif.model Yahoo.dat Whatever.sif ElmerSolver Figure 1: ElmerParam as a layer between ElmerSolver and a program that wants to call ElmerSolver as function of some parameters. tions of some parameters. It provides functions which take real and/or integer parameters as arguments, and return a scalar or vector of real output values: or f :R n Z m R f :R n Z m R k where n is the number of real parameters, m the number of integer parameters, and k the length of the return vector. These functions are from the caller's point of view black boxes and therefore no information about the case is provided. This information is instead provided in a set of les read by ElmerParam. The most important le is a ElmerParam command le, which contains the commands to run the computation programs. A typical command le will create input les with parameter values for the computation program, execute the computation program, and read parameter values from it's output les. The input les are created and output les interpreted with the help of template (model) les. Simple calculations specied in the MATC language can be performed by ElmerParam itself (see section 3.1.2). 2

In addition to computation parameters, ElmerParam can also be given a special tag parameter. The tag can be expanded not only in the input les, but also be used in the command le. It can be used to give unique names to all the input and output les, which can be important when running several instances of ElmerParam in parallel. 3 ElmerParam Files ElmerParam routines need a number of dierent les with information on the problem to be solved. The ELMERPARAM_STARTINFO le has a xed name and has only one line, the name of the ElmerParam command le. ElmerParam command le is the le containing the execution instructions needed for the evaluation of the function return value. Each case needs a set of model les that are generalized versions of the input and output les. In the model les the parameters are given in brackets. For example the rst real valued parameter is inserted where <!R1!> occurs. Input le models are used to create input les for the computation of, for example, ElmerGrid or ElmerSolver. Output le models are used to read result information from the output le. 3.1 ElmerParam command le The ElmerParam command le includes some simple statements that are run in the order of appearance. The general form of a statement is Command = argument Commands are case insensitive. Lines starting with #,! or * are ignored. A statement can be split onto several lines by putting a '\' as the last character on a line. <!T!> in an argument will be expanded to the value of the tag parameter. 3.1.1 Commands: Comment = string Echo string to stdout. 3

Echo = True False Turn ECHO on o. If `on', all commands are echoed to stdout when executed. `On' by default. Matc = True False Turn MATC support on o. Has to be `on' if you use MATC expressions. Requires that ElmerParam was compiled with MATC support. O by default. Input File = fname1 [Using fname2] Create the le fname1 from the model le fname2. If no model le name is given, the name fname1.model is assumed. Execute = cmd Execute the shell command cmd. Usually this would be the computation part, or mesh generation if using parametrized mesh generation. Output Files = fname1 [Using fname2] Read parameters from the output le fname1 using the model le fname2. If fname2 isn't given, fname1.model is assumed. Save File = fname Save history data of all the computations in le fname. If this keyword is active all the input parameters and the function return value are saved to a line that is appended in the given le. $<expression> Use MATC to evaluate the MATC expression <expression>. See section 3.1.2 for more. Below is a simple example of a ElmerParam command le. # # This comment will be ignored. # Comment = ElmerOptim routine Echo = True Input File = OptimTemp2.sif Execute = ElmerSolver Output File = cost.dat Save File = evals.dat 4

3.1.2 MATC extension The ElmerParam includes the MATC language written by Juha Ruokolainen that may be used, for example, to evaluate the values of the parameters. The MATC extensions are by default not evaluated and the variable MATC need to be set True to activate the library. In MATC, the real parameters are stored in a vector called R, integer paremeters in the vector I, and the function result in the vector O. Thus, Rn can be accessed through R(n), and so on. Below is an example command le that shows how the MATC library may be used. Comment = Testing routine MATC = True $ apu1 = R(0) + R(1) $ apu2 = sin(apu1) $ R(1) = apu2 $ I(0) = 5 $ I(1) = sum(i(2:4)) $ O = R(0) + R(1) + I(0) 3.2 Model les 3.2.1 Creating Input les When creating an input le, ElmerParam simple copies the contents of the model le, expanding parameter references where they occur. A parameter reference in the model le has the form <!ParamSpec[^]!> where ParamSpec can be: T The tag parameter Xn Parameter of type 'X' and index n. X(n:m) A vector of parameters from Xn to Xm. X A vector of all parameters of type 'X' Here `X' can be `R' for real, or `I' for integer. Note that indexing starts at 0; thus the rst real parameter will be R0, the second R1, and so on. An optional transpose operator ^ after the ParamSpec denotes that it is a column vector (vectors are by default row vectors.). If a line contains a column vector, it will be repeated n times, where n is the lentgh of the vector, with the i:th 5

vector component at the i:th copy of the line. If a line contains more than one columns, they have better be of the same length, or the vicious Yeti will eat your computer. Example: if the model le looks like r = <!R0!> i = <!I!> Temperature = Variable Coordinate 2 Real <!R(1:19)^!> <!R(20:38)^!> End and I = [ 1, 2, 3 ], R0 = 1.0, R(1:19) = [ 0.0, 0.2, 0.4... ], and R(20:38) = [ 1.0, 2.0, 3.0,... ] the input le becomes r = 1.0 i = 1 2 3 Temperature = Variable Coordinate 2 Real 0.0 1.0 0.2 2.0 0.4 3.0...... End 3.2.2 Reading Output les When reading parameter values from an output le using a model le, Elmer- Param will skip everything in the output le except those places where there is a parameter reference in the model le, in which case ElmerParam reads values from these places in the output le into the specied parameters. The parameter references for output les has the same general form as for input les, where ParamSpec in this case can be Xn X(n:m) X The n:th parameter of type 'X'. A vector of parameters from Xn to Xm. A vector of all parameters of type 'X' where `X' can be `R' for real, `I' for integer, or 'O' (uppercase 'o') for function result. For example, if the model le looks like 6

r = <!R!> i = <!I0!> y = <!O(0:4)^!> <!O(5:9)^!> and the output le is r = 1.0 2.0 3.0 i = 6 y = 1.0 6.0 2.0 7.0 3.0 8.0 4.0 9.0 5.0 10.0 ElmerParam will read [ 1.0, 2.0, 3.0 ] into R(0:2) (assuming the number of real parameters is 3), 6 into I0, and [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0 ] into O(0:9). 4 Interfaces 4.1 Standalone program ElmerParam [inputfile [outputfile [tag]]] inputfile: Name of le containing input parameters (use '-' or leave empty for stdin). It shall have the following format: [nr R0 R1... [ni I0 I1... [nfun]]] If nfun is absent, 1 will be assumed. Example: Three real parameters, no integer parameters, and 3 output parameters: 7

3 1.0 2.0 3.0 0 3 outputfile: Name of le where output parameters will be written in a column (use '-' or leave empty for stdout). tag: Optional tag parameter. 4.2 C interface #include <elmerparam.h> double elmer_param(int nr, const double *xr, int ni, const int *xi, const char *tag) void elmer_param_vec(int nfun, double *fun, int nr, const double *xr, int ni, const int *xi, const char *tag) nfun fun nr xr ni xi tag Return value Number of output parameters. (elmer_param_vec only) Array of output parameters, corresponds to O(0:nfun-1) in the ElmerParam input les. Must be big enough to hold nfun values. (elmer_param_vec only.) Number of real parameters. Array of real parameters, corresponds to R(0:nr-1) in the ElmerParam input les. (Use NULL for no real parameters.) Number of integer valued parameters. Array of integer parameters, corresponds to I(0:ni-1) in the ElmerParam input les. (Use NULL for no integer parameters.) Tag parameter. (Use NULL for no tag.) Scalar output parameter, corresponds to O (or O0) in the ElmerParam input les. (elmer_param only.) To compile a C code that calls elmer_param(), add 8

-I${ELMER_HOME}/include to the compiler ags. For linking, add -L${ELMER_HOME}/lib -lelmerparam -lmatc -lm to the linker ags. (-lmatc can be omitted if ElmerParam was compiled without MATC support). 4.3 Fortran interface use elmerparam interface elmer_param function elmer_param_scal (xr, xi, tag) result(y) double precision, optional, intent(in) :: xr(:) integer, optional, intent(in) :: xi(:) character(*), optional, intent(in) :: tag double precision :: y end function elmer_param_scal function elmer_param_vec (nfun, xr, xi, tag) result(y) integer, intent(in) :: nfun double precision, optional, intent(in) :: xr(:) integer, optional, intent(in) :: xi(:) character(*), optional, intent(in) :: tag double precision :: y(nfun) end function elmer_param_vec end interface elmer_param 9

nfun Length of return vector (elmer_param_vec only). xr Array of real parameters, corresponds to R(0:size(xr)- 1) in the ElmerParam input les. xi Array of integer parameters, corresponds to I(0:size(xi)-1) in the ElmerParam input les. tag Tag parameter. Return value elmer_param_scal: Scalar output parameter, corresponds to O (or O0) in the ElmerParam input les. elmer_param_vec: nfun Output parameters, corresponds to O(1:nfun) in the ElmerParam input les. To compile a Fortran code that USEs elmerparam, add -I${ELMER_HOME}/include to the compiler ags. You'll have to replace -I with whatever option your compiler uses to tell where to look for *.mod les. This varies from one compiler to another check the documentation of your compiler 1. Also note that you have to use the same compiler that was used to compile ElmerParam. For linking, add -L${ELMER_HOME}/lib -lelmerparamf -lelmerparam -lmatc -lm to the linker ags. (-lmatc can be omitted if ElmerParam was compiled without MATC support). 4.4 R interface library("elmerparam") elmer_param <- function(xr = NULL, xt = NULL, xi = NULL, tag = "", nfun = 1) xr Array of real parameters, corresponds to R(0:length(xr)-1) in the ElmerParam input les. xi Array of integer parameters, corresponds to I(0:length(xi)-1) in the ElmerParam input les. tag Tag parameter. nfun Return value Length of return vector. Vector of output parameters, corresponds to O(0:nfun- 1) in the ElmerParam input les. 1 Most compilers uses -I; among the exceptions are Sun f95 which uses -M. 10

Note: Unless the package was installed in the default R library tree, you have to tell R where to nd it. This can be done two ways; either using the lib.loc argument to library(): library("elmerparam", lib.loc="/where/to/find/it/lib/r") or by setting the environment variable "R_LIBS" to "/where/to/find/it/lib/r", where "/where/to/find/it" in both cases typically would be $ELMER_HOME. 4.5 Matlab interface path(path, '/where/to/find/it/lib') elmer_param(xr, xt, xi, tag, nfun) Arguments are the same as for the R interface. Arguments xr, xi and tag can be a zero length vectors ([ ]), and arguments at the end of the argument list can be omitted. If nfun is omitted, a value of 1 is assumed. Again, /where/to/find/it, would typically be $ELMER_HOME. 5 Example: the Rosenbrock function (Note: More examples can be found in the examples/ directory in the source distribution of ElmerParam.) Let's assume we have a computation program called rosenbrock that reads values for x 1 and x 2 from stdin, calculates the Rosenbrock function z = (1 x 1 ) 2 + 100(x 2 x 2 1) 2 and writes the result to stdout. The implementation of rosenbrock is not important; it can be written in any language, as long as it can be run from the command line as a stand alone program. For an implementation in awk, see code listing 1. To run rosenbrock via ElmerParam we need to create these les: 1. costfunction.epc, an ElmerParam model le with the following contents: Input file = xvalues Execute = rosenbrock < xvalues > zval Output file = zval 11

Listing 1 An awk implementation of rosenbrock #!/bin/awk -f BEGIN{ } getline; x = $1 y = $2 print (1-x)^2 + 100*(y - x^2)^2 2. ELMERPARAM_STARTINFO, to tell the name of the command le. The contents of ELMERPARAM_STARTINFO is thus simply costfunction.epc 3. xvalues.model, a model le used to instruct ElmerParam to write <!R0!> and <!R1!> to xvalues: <!R0!> <!R1!> 4. zval.model, a model le to tell ElmerParam how to extract the function value from the le zval: <!O!> 5.1 Optimize using R To nd the minimum of the rosenbrock function in R using the function optim, start up R and type the commands: > library("elmerparam") > optim(c(0,0), elmer_param)... $par [1] 0.9999564 0.9999085 $value 12

[1] 3.72849e-09 $counts function gradient 169 NA $convergence [1] 0 $message NULL The yielded result x min = (0.9999564, 0.9999085) with z min = 3.72849e 09 is very close to the expected result x min = (1.0, 1.0) with z min = 0. 5.2 Optimize using APPSPACK; standalone program APPSPACK 2 is an optimization package designed to be used to optimize functions dened using external computation programs, and is thus very well suited to be use with Elmer via ElmerParam. We have no ambitions to provide a complete APPSPACK manual here, only a simple example is given. Please see the APPSPACK web page for more information on APPSPACK. APPSPACK comes in two avors; a serial version, and a MPI parallel version. Their usage is very similar, and we'll cover both. APPSPACK needs a standalone program to evaluate the cost function; for this we can use ElmerParam directly. For the serial version of APPSPACK the tag parameter doesn't matter, but for the MPI version it's important. To use it, we have to make some small modications to the ElmerParam command le costfunction.epc: Input file = xvalues.<!t!> Using xvalues.model Execute = rosenbrock < xvalues.<!t!> > zval.<!t!> Output file = zval.<!t!> Using zval.model # Clean up afterwards: Execute = rm xvalues.<!t!> zval.<!t!> No other ElmerParam les needs changes. Finally, an input le for APPSPACK is needed. For this case, we use a le named appspack_input.apps: 2 http://software.sandia.gov/appspack/ 13

# SAMPLE APPSPACK INPUT FILE @ "Linear" "Upper" vector 2 100 100 "Lower" vector 2-100 -100 "Scaling" vector 2 1 1 @@ @ "Evaluator" "Executable Name" string "ElmerParam" @@ @ "Solver" "Debug" int 3 "Initial X" vector 2 0 0 "Step Tolerance" double 1.0e-5 @@ With this, we can run APPSPACK with the command > mpirun -n 2 /usr/local/bin/appspack_mpi appspack_input.apps for the MPI version, or > appspack_serial appspack_input.apps for the serial version, yielding the result Final State: Step Converged Final Min: f=5.290e-10 x=[ 1.000e-00 1.000e-00 ] \ step=1.000e-05 tag=27176 state=evaluated Success: 11251 Again, the result is correct (albeit at 11257 function evaluations, it's not very ecient. Increasing the Step Tolerance in appspack_input.apps reduces the numer of function evaluations, but also the accuracy.) 14