Transcript pps slides
c cie n tific o m p u tin g ADiCape in a large-scale industrial problem Monika Petera, Martin Bücker, Arno Rasch Institute for Scientific Computing RWTH Aachen University AD Workshop - Nice 2005 A A C H E N c cie n tific Optimization Problem o m p u tin g The Model: A system of differential and algebraic equations (DAE): Mx F ( x( p, t ), t ) where: x - set of state variables p - subset of parameters from x Goal: To minimize the objective function: at the final time t f AD Workshop - Nice 2005 min ( x( p, t ), p, t f ) p A A C H E N c cie n tific o m p u tin g Modeling languages A model can be written in a one of modeling languages, e.g. gPROMS, Modelica, and is usually represented as a system of mathematical equations An equation oriented approach does not make any assumptions about how to solve a model or what quantities are considered known and unknown. CapeML – A Common Model Exchange Language for Chemical Process Modeling designed for supporting the modeling process. CapeML is a neutral model exchange representation based on the XML standard. “CapeML – A Model Exchange Language for Chemical Process Modeling” - L.v.Wedel (TR May 2002) AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g A fragment of CapeML code <Equation> <BalancedEquation myID="V-0"> <Expression> <Term> <Factor> <FunctionCall fcn.name=“sin"> <Expression> <Term> <Factor> <VariableOccurrence definition="V-car-alpha“/> </Factor> </Term> </Expression> </FunctionCall> </Factor> </Term> </Expression> sin( alpha ) beta <Expression> <Term> <Factor> <VariableOccurrence definition="V-car-beta“/> </Factor> </Term> </Expression> </BalancedEquation> </Equation> AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g DyOS- Dynamic Optimization Software takes 90% of the computational time Process System Engineering RWTH Aachen University DAE ESO model server commercial CapeML ESO (Equation Set Object) - an internal representation of the computation tree. AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g The model of the Distillation Column The model consists of 3 submodels: • Swamp (1) • Condenser (1) • Tray (4) and a set of connecting equations. Condenser Tray 1 Tray 2 Vapour_outlet Liquid_inlet Tray 3 Swamp Tray 4 AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g Jacobian sparsity structure nV connecting equations # equations nF 206 nF Tray (4) Swamp Condenser # variables nV 410 # nonzeros nnz 919 1.1% AD Workshop - Nice 2005 A A C H E N c cie n tific Newton Step o m p u tin g state variables: xk 1 ( p) xk ( p) ( LU ) 1 F ( xk ( p)) LU- scaled system Jacobian matrix LU ( LU ) xk 1 ( p) F ( xk ( p)) F ( x0 ( p, t )) M x hj d xk ( p) sk ( p) dp d dp derivatives: F xk ( p ) ( LU ) sk 1 ( p ) xk ( p ) p F sk 1 ( p) sk ( p) ( LU ) sk ( p) xk ( p) 1 AD Workshop - Nice 2005 A A C H E N c cie n tific Integration Algorithm o m p u tin g Process System Engineering RWTH Aachen University ( F ( x0 , p)) x for j=1,...,jmax while convergence criterion not satisfied Compute A0 hj H / n j M hj for k=0,...,j-1 LU A0 Reuse LU decomposition xk 1 xk ( LU ) 1 F ( xk ( p )) sk 1 dF ( xk ( p )) sk ( LU ) sk dxk 1 M. Schlegel and W. Marquardt and R. Ehrig and U. Nowak: “Sensitivity Analysis of Linearly-implicit Differential-algebraic Systems by One-step Extrapolation” 2004 AD Workshop - Nice 2005 AD seeding with k s A A C H E N model server c ESO of DAE System o m p u tin g ESO cie n tific CapeML Modeling languages model.mo Transform to CapeML CapeML model.xml XML init_vars.xml ESO AD Workshop - Nice 2005 A A C H E N XSLT – Transform language c cie n tific o m p u tin g ADiCape is based on XSLT Transformation Language. On any XML-based language document eg. in CapeML, an XSLT stylesheet is applied, to generate new document. CapeML document XSLT processor transformed CapeML Stylesheet ADiCape consists of 2 XSLT Stylesheets (at the moment) AD Workshop - Nice 2005 A A C H E N c cie n tific ADiCape_var.xsl o m p u tin g XML init_vars.xml V v22 ... Temp ... v410 v1 gradients for the dF/dTemp g _ Temp[1] 0 ... Temp g _ Temp[22] 1 ... g _ Temp[410] 0 name="S.Temp" <Variable myID="V_m_S.Temp" name="S.Temp" varID="V_SWAMP_Temp" view=“ovar"> <Experiment number="1" initial_value="85" result_value="0"/> ADiCape_var.xs l dimension="410" index="22" <Vector name="S.g_Temp" varID="V_SWAMP_g_Temp" dimension="410" view=“ovar"> initial_value="1" <VectorVariable myID="V_m_S.g_Temp[22]" name="S.g_Temp[22]" index="22"> name="S.g_Temp" <Experiment number="1" initial_value="1" result_value="0"/> AD Workshop - Nice 2005 A A C H E N c cie n tific ADiCape o m p u tin g Modeling languages model.mo Transform to CapeML CapeML XML XSLT CapeML model.xml g_init_vars.xml ADiCape_eq g_model.xml XML XSLT init_vars.xml ADiCape_var ESO AD Workshop - Nice 2005 A A C H E N c cie n tific ADiCape_eq.xsl o m p u tin g Templates: <Equation> <BalancedEquation myID="V-0"> <xsl:template match="Equation"> chain rule ofdomain="V-g_i"/> differentiation: <Distribution <xsl:template match=“Expression"> <Expression> <xsl:template match=“FunctionCall"> <Term> f ( g ( x ))' f ' ( g ( x )) g ' ( x ) <xsl:template match="VariableOccurence"> <Factor> <Equation> <BalancedEquation myID="V-0"> <Expression> function intrinsic: <Term> <Factor> <FunctionCall fcn.name=“sin"> <Expression> <Term> <Factor> <VariableOccurrence definition="V-car-alpha“/> </Factor> </Term> </Expression> </FunctionCall> </Factor> </Term> </Expression> … f f' sin( expr) cos( expr) cos( expr) sin( expr) 1 ln( expr) (expr) ... ... <FunctionCall fcn.name=“cos"> <Expression> <Term> <Factor> differentiation of math-operations: <VariableOccurrence definition="V-car-alpha“/> </Factor> </Term> </Expression> </FunctionCall> </Factor> ' <Factor mul.op=“MUL”> <VariableOccurrence definition="V-car-g_alpha“/> 2 <DomainOccurrence domain=“V-g_i"/> </Factor> </Term> </Expression> A A C H E N … ( f g )' f ' g ' ( f g )' f 'g f g ' AD Workshop - Nice 2005 f f 'g f g ' g g c cie n tific ESO for the differentiated DAE o m p u tin g Modeling languages model.mo Transform to CapeML CapeML XML XSLT CapeML model.xml g_init_vars.xml ADiCape_eq g_model.xml XML XSLT init_vars.xml ADiCape_var g_ESO ESO AD Workshop - Nice 2005 A A C H E N c cie n tific XML ESO o m p u tin g ESO model server CapeML First derivatives original DAE ADiCape: ESO g_ESO Call Full Jacobian Jacobian times Matrix Call m_eso m_g_eso XML ESO get (F ) Call DyOS Sparse Jacobian matrices with known sparsity pattern: get (F ' ) do not calculate “zeros” cut down number of operations save space AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g Matrix compression BUT HOW ?? Sparsity aware seeding with CPR – Curtis-Powell-Reid graph-coloring method! AD Workshop - Nice 2005 A A C H E N c cie n tific Sparsity aware seeding o m p u tin g 206 = * 410 dF dx 13 dF seed dx seed AD Workshop - Nice 2005 13 A A C H E N c cie n tific o m p u tin g Compressed Full Jacobian size time full 206x410 55 min compressed 206x13 3.4 s factor 31.5 970 ?! AD Workshop - Nice 2005 2.8 GHz Pentium 4 512MB cash (31.52 970) A A C H E N c cie n tific Future Work o m p u tin g First derivatives original DAE ESO Second derivatives g_ESO Call Call m_eso m_g_eso XML ESO h_ESO change DyOS System: new Optimizer (IPOPT)* which uses 2nd derivatives change Integration Algorithm get (F ) Call DyOS get (F ' ) * A. Wächter and L. T. Biegler: “On the Implementation of a Primal-Dual Interior Point Filter Line Search Algorithm for Large-Scale Nonlinear Programming”, 2004 AD Workshop - Nice 2005 A A C H E N c cie n tific Second derivatives o m p u tin g xk 1 ( p ) xk ( p ) ( LU ) 1 F ( xk ( p )) ( LU ) xk 1 ( p ) F ( xk ( p )) ( LU ) sk 1 ( p ) J s F sk xk ( p ) d dp J d sT H s F 2F T ( LU ) d k 1 ( p) d k sk sk 2 xk ( p ) xk ( p) AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g Summary and Conclusions ADiCape is a source transformation tool employing the forward mode of AD written for CapeML language with Curtis-Powell-Reid method, calculation of a compressed sparse Jacobian brings space savings and considerable speed-up We expect DyOS integrator performance to considerably improve with the use of AD-generated derivatives With the new optimizer and precise AD second derivatives we hope to considerably cut down the number of iterations of the Integrator. AD Workshop - Nice 2005 A A C H E N c cie n tific o m p u tin g THANK YOU FOR YOUR ATTENTION ! AD Workshop - Nice 2005 A A C H E N