# Simulation Optimization for Complex Multi-Domain Physical Systems Based on Partial Resolving

^{*}

## Abstract

**:**

## 1. Introduction

#### 1.1. Modeling and Simulation Technology for Multi-Domain Physical System Based on Modelica

#### 1.2. Simulation Solving for a Modelica Model

#### 1.3. Parameter Optimization for a Modelica Model

#### 1.4. Method and Structure of This Work

## 2. Modeling and Simulation for a Modelica Model under MWorks

#### 2.1. Modeling Example

#### 2.2. Equations Generating and Sorting

- 〈B1〉
- G.p.v = 0;
- 〈B2〉
- C.n.v = G.p.v;
- 〈B3〉
- L.n.v = C.n.v;
- 〈B4〉
- VS.n.v = C.n.v;
- 〈B5〉
- VS.signalSource.outPort.signal = VS.signalSource.p_height;
- 〈B6〉
- VS.signalSource.y = VS.signalSource.outPort.signal;
- 〈B7〉
- VS.v = VS.signalSource.outPort.signal;
- 〈B8〉
- VS.v = VS.p.v-VS.n.v;
- 〈B9〉
- R1.p.v = VS.p.v;
- 〈B10〉
- R2.p.v = R1.p.v;
- 〈B11〉
- R1.v = R1.p.v-R1.n.v; 0 = R1.p.i + R1.n.i; R1.i = R1.p.i;R1.R * R1.i = R1.v; C.p.i + R1.n.i = 0; R1.n.v = C.p.v;0 = C.p.i + C.n.i; C.i = C.p.i; C.i = C.C *der(C.v);C.v = C.p.v-C.n.v;
- 〈B12〉
- R2.v = R2.p.v-R2.n.v; 0 = R2.p.i + R2.n.i; R2.i = R2.p.i;R2.R*R2.i = R2.v; L.v = L.p.v-L.n.v; 0 = L.p.i + L.n.i;L.i = L.p.i; L.L*der(L.i) = L.v; L.p.i + R2.n.i = 0;R2.n.v = L.p.v;
- 〈B13〉
- R1.p.i + R2.p.i + VS.p.i = 0;
- 〈B14〉
- VS.i = VS.p.i;
- 〈B15〉
- 0 = VS.p.i + VS.n.i;
- 〈B16〉
- C.n.i + G.p.i+L.n.i + VS.n.i = 0;
- 〈B17〉
- i0 = VS.p.i;

#### 2.3. Simulation

## 3. Parameter Optimization Process for a Modelica Model

#### 3.1. Criteria of State Variables

#### 3.2. Optimization Modeling for a Modelica Model with Multi-Cases

_{ij}denotes the ith object in the jth case. In order to achieve the same scale of different objective functions, a fixed demand value (d

_{ij}, $ij\in F$) is needed for each object in each case. A demand value has the same unit as its corresponding object, which denotes the designer’s preferences. Moreover, $\sum |{f}_{ij}/{d}_{ij}|$ is the overall object function of multi-objects of multi-cases.

find: {C.C, L.L}min: Difference (i0, Ij ), j = 1,2,3; dj = 1;s.t. settling-time (i0) < Tj, j = 1,2,3over-shoot(i0) ≤ Aj, j = 1,2,3cases: {R1.R, R2.R} = {20, 100; 50, 50; 100, 20}{T1, T2, T3} = {2, 3, 4}{A1, A2, A3} = {0, 0, 0}where C.C is the value of the capacitor C; L.L is the value of the inductance L; and i0 is the overall current of the circuit. There are three cases in the model with different case parameters R1.R and R2.R. I1, I2, I3 are three ideal current curves corresponding to the three cases, respectively, and they are given with a series of value-time pairs.

#### 3.3. Parameter Optimization Process

## 4. Partial Resolving Algorithm for a Modelica Model

#### 4.1. Solving Dependency Graph

**Definition**

**1.**

**Pre-blocks**of a block B is the blocks that are B’s parents or their parents, recursively.

**Post-blocks**of a block B is the blocks that are B’s children of their children, recursively.

**Definition**

**2.**

**B**in the solving dependency graph (SDG) is a set of coupling blocks and the edge$({B}_{1},{B}_{2})\in \overline{E}$indicates the data dependence between vertices B

_{1}and B

_{2}. That is, there exists at least one variable v in B

_{2}whose value is computed in B

_{1}. This type of variable (such as v) is called as computation variables in B

_{1}and is also known as reference variables in B

_{2}, i.e., B

_{1}is B

_{2}′s parent.

#### 4.2. Minimum Solving Graph

_{P}is the post-blocks of parameter par1, par2, par3, …; G

_{O}is the pre-blocks of objects obj1, obj2, obj3; and G

_{C}is the pre-blocks of constraints con1, con2, con3, …; then the minimum solving process is shown in Figure 6.

_{P}∩ (G

_{O}∪ G

_{C})

Algorithm 1. GetParPostBlocks |

Input: s_strPar – a set of parameters |

SDG – solving dependency graph |

Output: s_pBlks – set of post-blocks selected |

for each block b in SDG do begin |

if intersection of b.s_Par and s_strPar is null or b is in s_pBlks then continue; |

clear set s; |

s = GetSuccesor (b, SDG, s_pBlks); //get successors of b in SDG |

Add s to s_pBlks; //select s |

end for; |

**GetSuccessor**function (Algorithm 2) is passed with the set of blocks s_pBlks which have been selected:

Algorithm 2. GetSuccesor |

Input: b – the block |

SDG – solving dependency graph |

s_pBlks – set of blocks which has been selected |

Output: s_pSucBlks – set of blocks selected |

clear set s; |

s = b.s_children; |

for each block b1 in s do begin |

if b1 is in s_pBlks then continue; |

clear set s1; |

GetSuccesor ( b, SDG, s_pBlks); //call itself recursively |

Add b1 to s_ pSucBlks; |

end for; |

Algorithm 3. GetVarPreBlocks |

Input: s_strVar – a set of Variables |

SDG – solving dependency graph |

Output: s_pBlks – set of blocks selected |

for each block b in SDG do begin |

if intersection of b.s_Var and s_strVar is null or b is in s_pBlks then continue; |

clear set s; |

s = GetProccesor(b, SDG, s_pBlks); //Get Processors of b in SDG |

Add s to s_pBlks; //select s |

end for; |

**GetSuccessor**,

**Getsuccessor**function (Algorithm 4) is also passed with the set of blocks s_pBlks:

Algorithm 4. GetProccesor |

Input: b – the block |

SDG – solving dependency graph |

s_pBlks – set of blocks which has been determined |

Output: s_pProBlks – set of blocks |

clear set s; |

s = b.s_parents; |

for each block b1 in s do begin |

if b1 is in s_pBlks then continue; |

clear set s1; |

GetProccesor ( b, SDG, s_pBlks); //call itself recursively |

Add b1 to s_ pProBlks; |

end for; |

Algorithm 5. GetMSGBlocks //getting set of blocks in a MSG |

Input: s_pParBlks—set of post- blocks of parameters |

s_pVarBlks—set of pre-blocks of output variables appearing in the objective functions or constraints functions |

Output: s_pMSGBlks—set of blocks in a MSG |

for each block b in s_pParBlks do begin |

if b is in s_pParBlks then |

add b to s_pMSGBlks; |

end for |

Algorithm 6. GetSortedBlocks |

Input: s_pMSGBlks – set of blocks in a MSG |

Output: v_ pMSGBlks – vector of sets of blocks which are sorted |

while s_pMSGBlks in not null do begin |

for each block b in s_pMSGBlks do begin |

clear set s; |

if intersection of b.s_pParents and s_pMSGBlks is null then |

add b to s; |

end for; |

Algorithm 7: GenerateMSGSortedBlocks |

//generating minimum solving series of blocks in MSG |

InputSDG, s_pars, s_Vars |

Outputv_setMSGBlks |

Step1: s_pBlk1 = GetParPostBlocks (SDG, s_pars); |

Step2: s_pBlk2 = GetVarPreBlocks (SDG, s_Vars); |

Step3: s_pMSGBlks = GetMSGBlocks (s_pBlk1, s_pBlk2); |

Step4: v_pMSGBlks = GetSortedBlocks (s_pMSGBlks); |

#### 4.3. Optimization Iteration Process Based on Minimum Simulation

_{11}, B

_{13}, and B

_{17}. Accordingly, the consuming time of the optimization could be reduced by 45%. However, if we select the parameter VS.signalSource.p_height as tuners, its MSG then covers nearly all the blocks, except four blocks: B

_{1}, B

_{2}, B

_{3}, and B

_{4}. This means time of partial resolving is close to that of the full simulation.

## 5. Application

parameter Real upshift[:] = {25, 50, 70, 100} "upshift table,(km/h)";parameter Real downshift[:] = {20, 40, 60, 90} "downshift table,(km/h)";Modelica.Blocks.Interfaces.InPort vehicle_speed;Modelica.Blocks.Interfaces.OutPort requested_gear_number;Integer current_gear(start = 1);Integer speeds = size(upshift,1) + 1;Real next_upshift;Real next_downshift;initial algorithmcurrent_gear = 1;next_upshift = if current_gear < speeds then upshift[current_gear] else Modelica.Constants.inf;next_downshift = if current_gear > 1 then downshift[current_gear - 1] else -Modelica.Constants.inf;algorithmwhen vehicle_speed.signal[1] > next_upshift thencurrent_gear : = current_gear+1;next_upshift : = if current_gear<speeds then upshift[current_gear] else Modelica.Constants.inf;next_downshift : = if current_gear>1 then downshift[current_gear-1] else -Modelica.Constants.inf;end when;when vehicle_speed.signal [1] < next_downshift thencurrent_gear : = current_gear-1;next_upshift : = if current_gear<speeds then upshift[current_gear] else Modelica.Constants.inf;next_downshift : = if current_gear>1 then downshift[current_gear-1] else -Modelica.Constants.inf;end when;

find {gearRatio_1, gearRatio_2, gearRatio_3, gearRatio_4, gearRatio_5}min: fuelComsumption1.fuels.t. max (vehicle1.speed) <Vj, j = 1,2,3cases: three common shift strategies with different sets of table values ofupshiftanddownshift.{upshift1, upshift2, upshift3} = {{25, 50, 70, 100}, {30, 55, 80, 110}, {20, 45, 65, 95}}{downshift1, downshift2, downshift3} = {{20, 40, 60, 90}, {25, 50, 70, 100}, {15, 40, 60, 90}}{V1, V2, V3} = {90 km/h, 100 km/h, 110 km/h}

## 6. Conclusions

## Author Contributions

## Funding

## Conflicts of Interest

## References

- Fritzson, P. Principles of Object-oriented Modeling and Simulation with Modelica 2.1; IEEE Press: New York, NY, USA, 2003. [Google Scholar]
- Modelica Group. Available online: http://www.Modelica.org (accessed on 12 August 2008).
- Dymola—Dynamic Modeling Laboratory (Dynasim AB). Available online: http://www.dynasim.se/ (accessed on 26 September 2008).
- Ding, H.; Cao, K.Q.; Li, Y.L.; Ren, B. Modeling and Performance Simulation for AircraftHydraulic Energy System Based on Modelica and Dymola. Mach. Tool Hydraul.
**2010**, 7, 120–122+133. (In Chinese) [Google Scholar] - MathModelica. Available online: http://www.mathcore.com/products/mathModelica/ (accessed on 8 January 2009).
- Fritzson, P. MathModelica—An Object-Oriented Mathematical Modeling and Simulation Environment. Math. J.
**2006**, 10, 187–263. [Google Scholar] - The OpenModelica Project. Available online: http://www.openModelica.org (accessed on 11 July 2009).
- Fritzson, P. Model-based development of sustainable cyber-physical systems including requirement formalization using the openModelica model-based development toolkit. In Proceedings of the European Conference on Software Architecture Workshops, Copenhagen, Denmark, 28 November–2 December 2016. [Google Scholar]
- Ding, J.W. Research on Methods for Consistency Analysis and Reduction of Declarative Simulation Models. Ph.D. Thesis, Huazhong University of Science & Technology, Wuhan, China, 2006. (In Chinese). [Google Scholar]
- Wu, Y.Z.; Wu, M.F.; Chen, L.P. Study on the hybrid modeling platform based on Modelica language for complex machinery system. China Mech. Eng.
**2006**, 17, 2391–2396. (In Chinese) [Google Scholar] - Wu, Y.Z. Development of Hybrid Modeling Platform for Multi-domain Physical System. J. Comput.-Aided Des. Comput. Graph.
**2006**, 18, 120–124. (In Chinese) [Google Scholar] - Zhou, F.L.; Chen, L.P.; Wu, Y.Z.; Ding, J.W.; Zhao, J.J.; Zhang, Y.Q. MWorks: A Modern IDE for Modeling and Simulation of Multi-domain Physical Systems Based on Modelica. In Proceedings of the 5th International Modelica Conference, Vienna, Austria, 4–5 September 2006; pp. 725–732. [Google Scholar]
- Lamour, R.; März, R.; Tischendorf, C. Differential-Algebraic Equations: A Projector Based Analysis; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2013. [Google Scholar]
- Fritzson, P. Principles of Object-Oriented Modeling and Simulation with Modelica 3.3: A Cyber-Physical Approach; John Wiley & Sons: Hoboken, NJ, USA, 2014. [Google Scholar]
- Dehghan, M.A.; Talebi, G.; Shojaeifard, A. Lower bounds for generalized Hausdorff matrices and lower triangular matrices on the block weighted sequence space ℓ p (w, F). Linear Multilinear Algebra
**2014**, 62, 126–138. [Google Scholar] [CrossRef] - Ali, G.; Banagaaya, N.; Schilders, W.H.A.; Tischendorf, C. Index-aware model order reduction for differential-algebraic equations. Math. Comput. Model. Dyn. Syst.
**2014**, 20, 345–373. [Google Scholar] [CrossRef] - Mehrmann, V. Index concepts for differential-algebraic equations. In Encyclopedia of Applied and Computational Mathematics; Springer: Berlin/Heidelberg, Germany, 2015; pp. 676–681. [Google Scholar]
- Pop, A.; Sjölund, M.; Ashgar, A.; Fritzson, P.; Casella, F. Integrated Debugging of Modelica Models. Model. Identif. Control
**2014**, 35, 93–107. [Google Scholar] [CrossRef] - Secchi, A.R.; Laganier, F.S.; Morari, M. Dynamic process simulation using a concurrent differential and algebraic solver. Comput. Chem. Eng.
**1993**, 17, 467–472. [Google Scholar] [CrossRef] - Kewley, R.; Kester, N.; McDonnell, J. DEVS Distributed Modeling Framework-A parallel DEVS implementation via microservices. In Proceedings of the 2016 Symposium on Theory of Modeling and Simulation (TMS-DEVS), Pasadena, CA, USA, 3–6 April 2016; pp. 1–8. [Google Scholar]
- Kessler, C.; Fritzson, P.; Eriksson, M. NestStepModelica–Mathematical Modeling and Bulk-Synchronous Parallel Simulation. In International Workshop on Applied Parallel Computing; Springer: Berlin/Heidelberg, Germany, 2006; pp. 1006–1015. [Google Scholar]
- Lundvall, H.; Fritzson, P. Automatic Parallelization of Object Oriented Models Executed with Inline Solvers. In Proceedings of the European Parallel Virtual Machine/Message Passing Interface Users’ Group Meeting, Paris, France, 30 September–3 October 2007; Springer: Berlin/Heidelberg, Germany, 2007; pp. 365–372. [Google Scholar][Green Version]
- Adegoke, A.; Togo, H.; Traoré, M.K. A unifying framework for specifying DEVS parallel and distributed simulation architectures. Simulation
**2013**, 89, 1293–1309. [Google Scholar] [CrossRef] - Ko, D.H.; Lee, M.J.; Jang, W.H.; Krewer, U. Non-isothermal dynamic modelling and optimization of a direct methanol fuel cell. J. Power Sources
**2008**, 180, 71–83. [Google Scholar] [CrossRef] - William, F.F.; Paul, I.B. Dynamic optimization with state variable path constraints. Comput. Chem. Eng.
**1998**, 2, 1241–1256. [Google Scholar] - Huang, Y.J.; Reklaitis, G.V.; Venkatasubramanian, V. Model decomposition based method for solving general dynamic optimization problems. Comput. Chem. Eng.
**2002**, 26, 863–873. [Google Scholar] [CrossRef] - Logsdon, J.S.; Biegler, L.T. Decomposition strategies for large-scale dynamic optimization problems. Chem. Eng. Sci.
**1992**, 47, 851–864. [Google Scholar] [CrossRef] - Dynasim, A.B. User’s Manual Dymola 6 Additions; Dynasim AB: Lund, Sweden, 2006. [Google Scholar]
- Shang, Y. On the degree sequence of random geometric digraphs. Appl. Math. Sci.
**2010**, 4, 2001–2012. [Google Scholar] - Shang, Y. Inhomogeneous Long-Range Percolation on the Hierarchical Lattice. Rep. Math. Phys.
**2015**, 76, 53–61. [Google Scholar] [CrossRef] - Shang, Y. Resilient Multiscale Coordination Control against Adversarial Nodes. Energies
**2018**, 11, 1844. [Google Scholar] [CrossRef]

**Figure 2.**Simulation results of the circuit in Figure 1.

Block Number | Meaning |
---|---|

B1 | Grounding voltage block |

B2 | Capacitance voltage block |

B3 | Inductance voltage block |

B4 | Voltage source voltage block |

B5 | Voltage source output signal block |

B6 | Voltage source objective signal block |

B7 | The relation block on Voltage source voltage and Voltage source output signal |

B8 | Voltage source voltage relation block |

B9 | Voltage block on Resistance 1 (R1) |

B10 | Voltage block on Resistance 2 (R2) |

B11 | The relation block on R1, Capacitance, Voltage, and Current |

B12 | The relation block on R2, inductance, Voltage, and Current |

B13 | The Current relation block on Resistance 1, Resistance 2, Voltage source |

B14 | The Current block of Voltage source |

B15 | The Current relation block of Voltage source |

B16 | The Current relation block on Capacitance, Inductance, Grounding port, and Voltage source |

B17 | Trunk current block |

© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Hou, K.; Li, Y. Simulation Optimization for Complex Multi-Domain Physical Systems Based on Partial Resolving. *Processes* **2019**, *7*, 334.
https://doi.org/10.3390/pr7060334

**AMA Style**

Hou K, Li Y. Simulation Optimization for Complex Multi-Domain Physical Systems Based on Partial Resolving. *Processes*. 2019; 7(6):334.
https://doi.org/10.3390/pr7060334

**Chicago/Turabian Style**

Hou, Kexi, and Yaohui Li. 2019. "Simulation Optimization for Complex Multi-Domain Physical Systems Based on Partial Resolving" *Processes* 7, no. 6: 334.
https://doi.org/10.3390/pr7060334