# Can’t Fool Me: Adversarially Robust Transformer for Video Understanding

###### Abstract

Deep neural networks have been shown to perform poorly on adversarial
examples. To address this, several techniques have been proposed to increase
robustness of a model for image classification tasks. However, in video
understanding tasks, developing adversarially robust models is still
unexplored. In this paper, we aim to bridge this gap. We first show that
simple extensions of image based adversarially robust models slightly improve
the worst-case performance. Further, we propose a temporal attention
regularization scheme in Transformer to improve the robustness of attention
modules to adversarial examples. We illustrate using a large-scale video data
set YouTube-8M that the final model (A-ART) achieves close to non-adversarial
performance on its adversarial example set. We achieve 91% GAP on adversarial
examples, whereas baseline Transformer and simple adversarial extensions
achieve 72.9% and 82% respectively, showing significant improvement in
robustness over the state-of-the-art.

Index Terms—  Video classification, adversarial training, model robustness,
self-attention models

##  1 Introduction

Deep neural networks have achieved state-of-the-art in several machine
learning tasks, e.g., image classification [1] [2], video and audio
understanding [3], [4], [5], natural language understanding [6], graph
learning and reinforcement learning [7], [8]. However, it has been shown that
due to high dimensionality, even simplest of models are vulnerable to
adversarial examples [9] with imperceptible changes to input examples [10, 11,
12]. [13] showed it for videos where the trained model fails to detect the
correct class of a perturbed video. For a threat model, they generated the
adversarial perturbations in an iterative way by maximising the cross-entropy
loss between the model’s output for a perturbed video and its ground-truth
label. They additionally minimize the $L_{21}$ norm of the perturbations so
that the perturbed video is semantically close to the original video. This
ensured that visually similar videos had different model outputs.

Adversarial training has been proposed in several key tasks such as image
classification to make the model robust to such adversarial changes. For
example, in [11, 14], the authors propose a way of computing the adversarial
counterparts of images while training and adding an extra loss regularization
that forces the model to correctly classify them or make their predictions
close to that of the original image.

However, for video understanding, the research of adversarially robust model
needs further exploration. Moving from image to video classification adds
several challenges to the task. First, the temporal dimension increases the
overall size of the input, in turn increasing the model capacity required to
make accurate predictions making it more susceptible to adversarial attacks.
Secondly, the number of possible tags increase due to the variations in
sequence. For e.g., a leaf falling from tree can be tagged as nature but the
reverse could indicate science-fiction elements in the video.

We study the effect of adversarial training on video classification task using
a popular deep learning model, Transformer [15], henceforth referred as Non-
Adversarially Robust Transformer (Non-ART). For adversarial robustness
training, we focus on two major approaches: learning using output space (ART
using $\mathcal{L}_{out,Adv}$) and learning using attention-map space (A-ART
using $\mathcal{L}_{(out,att),Adv}$). We first perform a simple extension
(ART) of traditional adversarial loss used in images [14] to videos and show
that it improves the adversarial robustness to a certain extent. We study the
effect of ART in the attention space and show it does not produce an
adversarially robust attention space. Based on this, we propose a temporal
attention regularization approach (A-ART) and show that it has a large impact
on the adversarial robustness of the trained Transformer model.

We show extensive experiments on a large-scale video data set YouTube-8M on
original test set (average performance) as well as adversarial test set
(worst-case performance). Further, to showcase generalization, we perform
similar experiments on Finance and Arts & Entertainment verticals within
YouTube-8M. We show that we achieve close to average performance on
adversarial test set on YouTube-8M using our approach. On original and
adversarial test sets, our model (A-ART) achieves 92% GAP and 91% GAP
respectively. A-ART has a gain of 18% in GAP on adversarial test set when
compared with the baseline Non-ART and a gain of 9.1% when compared with ART.

##  2 Adversarial Transformer

In this section, we show how the loss function of a Transformer-based video
classification model can be changed for more robust learning. We plan to
address the vulnerability of deep learning based video classification models
to adversarial examples. We denote the training set with $L$ data points as
$\\{X_{i},y_{i}\\},i=1,..,L$, where $X_{i}\in\mathbb{R}^{T\times D}$
represents the frame-wise feature representation of video $i$ and
$y_{i}\in\mathbb{R}^{K}$ represents the ground-truth labels. $K$ is the number
of classes. We represent the video classification model’s output vector of
probabilities for the point $X_{i}$ as $\theta(X_{i})$.
$l(\theta(X_{i}),y_{i})$ is the loss for the data point $X_{i}$ which we
consider to be cross-entropy loss in our multi-class scenario.

$\mathcal{L}_{CE}=\frac{1}{L}\sum_{i=1}^{L}l(y_{i},\theta(X_{i}))$ (1)

However, such models would be susceptible to adversarial examples hurting the
generalizability of the model.

###  2.1 Adversarial regularization

To address the above limitation, we add a regularization term minimizing the
loss for adversarial counterparts in the output space of the training samples
as proposed in [14].

$\displaystyle\mathcal{L}_{out,Adv}$ $\displaystyle=$
$\displaystyle\mathcal{L}_{CE}+\alpha*\frac{1}{L}\sum_{i=1}^{L}l(y_{i},\theta(X_{i}+R_{i}))$
(2) $\displaystyle R_{i}$ $\displaystyle=$
$\displaystyle\arg\max_{R_{i}:\|R_{i}\|_{2}\leq\epsilon}l(y_{i},\theta(X_{i}+R_{i}))$
(3)

The loss function is approximated to behave linearly around the input $X_{i}$
to get the perturbation term which can be easily calculated using
backpropagation.

$R_{i}\approx\epsilon\frac{G_{i}}{\|G_{i}\|_{2}},where\
G_{i}=\nabla_{X_{i}}l(y_{i},\theta(X_{i}))$ (4)

Note, this method is closely related to fast gradient sign method (FGSM) [11]
where $\infty$-norm is considered in equation 3. We compute the gradient of
the loss with respect to the features from video and audio modalities to get
the corresponding adversarial perturbations. Note that, we train the model to
be invariant to adversarial samples within the $\epsilon$ ball (see sec
3.2.3). Hence, optimizing this loss function has two hyper-parameters to tune,
$\alpha$ and $\epsilon$. We refer to the model trained with
$\mathcal{L}_{out,Adv}$ as Adevrsarially Robust Transformer (ART).

###  2.2 Attention-map regularization

Fig. 1: Attention map generated by Non-ART (left) and ART (right) models.

Figure 1 illustrates attention map generated for a sample video and its
adversarial counterpart by Non-ART (model trained with $\mathcal{L}_{CE}$) and
ART model. We observe that even though the attention maps are close, for many
frames the differences are still significant. But intuitively, the attention-
map being generated in the self-attention blocks should also be invariant to
adversarial examples. Towards that goal, we add a regularization term in our
loss function to enforce this condition. For a given input, we average over
the attention maps $A_{m}$ generated by each head to get the attention map
$A\in\mathbb{R}^{T\times T}$ for that input. The corresponding attention map
generated using the adversarial example is denoted by $A^{adv}$. We minimize
the Frobenius norm of the difference between the attention maps and average
over the mini-batch in which case the loss function becomes

$\mathcal{L}_{(out,att),Adv}=\mathcal{L}_{out,Adv}+\beta_{Fr}*\frac{1}{L}\sum_{i=1}^{L}\|A_{i}-A^{adv}_{i}\|_{Fr}\\\
$

We refer to the model trained with $\mathcal{L}_{(out,att),Adv}$ as Attention-
Adversarially Robust Transformer (A-ART)

##  3 Experiments

| Test | Adversarial Test
---|---|---
Metrics |  Non-ART, $\mathcal{L}_{CE}$ |  ART, $\mathcal{L}_{out,Adv}$ |  A-ART, $\mathcal{L}_{(out,att),Adv}$ | $Gain_{Test}$ |  Non-ART, $\mathcal{L}_{CE}$ |  ART, $\mathcal{L}_{out,Adv}$ |  A-ART, $\mathcal{L}_{(out,att),Adv}$ | $Gain_{Adv}$
GAP |  91.97$\pm$0.02 |  92.38$\pm$0.02 |  92.00$\pm$0.02 | +0.03 |  72.89$\pm$0.04 |  81.97$\pm$0.02 |  91.04$\pm$0.02 | +18.15
PERR |  89.73$\pm$0.04 |  89.94$\pm$0.04 |  89.64$\pm$0.04 | -0.09 |  71.89$\pm$0.03 |  80.35$\pm$0.03 |  88.58$\pm$0.01 | +16.69
Hit@1 |  94.76$\pm$0.05 |  94.87$\pm$0.04 |  94.80$\pm$0.03 | +0.04 |  81.74$\pm$0.02 |  88.22$\pm$0.02 |  93.99$\pm$0.02 | +12.25
Table 1: Overall performance (in percentages) of Non-ART, ART and A-ART models for video categorization task on our YouTube-8M test sets. Each column represents the results for a training paradigm defined by the architecture and the loss function used. We present the mean and standard deviation obtained for five non-overlapping partitions of the entire test set. | Test | Adversarial Test
---|---|---
Metrics |  Non-ART, $\mathcal{L}_{CE}$ |  ART, $\mathcal{L}_{out,Adv}$ |  A-ART, $\mathcal{L}_{(out,att),Adv}$ | $Gain_{Test}$ |  Non-ART, $\mathcal{L}_{CE}$ |  ART, $\mathcal{L}_{out,Adv}$ |  A-ART, $\mathcal{L}_{(out,att),Adv}$ | $Gain_{Adv}$
GAP | 93.93 | 94.12 | 94.14 | +0.21 | 74.88 | 84.38 | 88.54 | +13.66
PERR | 93.47 | 93.72 | 93.57 | +0.10 | 78.40 | 85.60 | 88.25 | +9.85
Hit@1 | 97.21 | 97.32 | 97.33 | +0.01 | 87.38 | 92.16 | 93.95 | +6.57
Table 2: Overall performance (in percentages) of baselines and different variations of our proposed model for video categorization task on Arts & Entertainment, largest vertical of YT8M. | Test | Adversarial Test
---|---|---
Metrics |  Non-ART, $\mathcal{L}_{CE}$ |  ART, $\mathcal{L}_{out,Adv}$ |  A-ART, $\mathcal{L}_{(out,att),Adv}$ | $Gain_{Test}$ |  Non-ART, $\mathcal{L}_{CE}$ |  ART, $\mathcal{L}_{out,Adv}$ |  A-ART, $\mathcal{L}_{(out,att),Adv}$ | $Gain_{Adv}$
GAP | 79.13 | 79.07 | 79.86 | +0.73 | 54.50 | 65.08 | 71.48 | +16.98
PERR | 80.59 | 83.85 | 82.25 | +1.66 | 64.77 | 70.89 | 75.50 | +10.73
Hit@1 | 87.70 | 92.31 | 90.77 | +3.07 | 69.25 | 74.77 | 85.60 | +16.35
Table 3: Overall performance (in percentages) of baselines and different
variations of our proposed model for video categorization task on Finance,
smallest vertical of YT8M.

###  3.1 Experimental-setup

We use YouTube-8M dataset for our experiments which consists of frame-wise
video and audio features for approximately 5 million videos extracted using
Inception v3 and VGGish respectively followed by PCA [16]. We use the
hierarchical label space with 317 classes, a further modification of 431
categories (see [17]). We use binary cross-entropy loss to train our models.
We evaluate our models using the three metrics mentioned in [18]: (i) Global
Average Precision (GAP), (ii) Precision at Equal Recall Rate (PERR), and (iii)
Hit@1. Our training set consists of approximately 4 million videos. We use
64000 videos from the official development set for validation and use the rest
as test set. Our baseline Transformer model consists of a single layer of
multi-head attention with 8 attention heads for each of audio and video
modalities. For training we used Adam optimizer, with an initial learning rate
of 0.0002 and batch size of 64. We compute validation set GAP every 10000
iterations and perform early-stopping with patience of 5. We also use it for
learning-rate scheduler that decreases the learning rate by a factor of 0.1
with patience of 3.

###  3.2 Results

We present results for video categorization using a baseline Transformer
encoder with and without the proposed regularization terms. Based on
validation set results, the value of $\epsilon$ and $\alpha$ for adversarial
training was set to be $0.5$ and $1$ respectively. $\beta_{Fr}$ was set to
$0.001$. We first analyze the effect of attention map regularization on ART’s
performance on the test set consisting of original samples as well as
adversarial samples generated using the perturbations computed as in equation
4. Then we perform hyper-parameter analysis of the models trained
adversarially. Finally, we highlight the robustness of A-ART to adversarial
perturbations computed using the DeepFool method [12].

####  3.2.1 Performance on original and adversarial samples

From Table 1, we see that adversarial regularisation improves the performance
of Non-ART model when classifying the original samples in test set. This shows
that adversarial regularization can improve the generalizability of a model.
A-ART and ART seem to perform similarly on the original test set. Next, we
investigate the robustness of models to adversarial samples. Given a test
sample and a trained model, we generate the corresponding adversarial
perturbation using the FGSM based method (equation 4). We observe that A-ART
consistently and significantly outperforms ART highlighting the importance of
attention-map resgularization to improve the adversarial robustness of
Transformer based models.

Hence, while A-ART performs similarly as ART on the original test samples, it
significantly improves the adversarial robustness of the model.

####  3.2.2 Attention Map Regularization

Fig. 2: Attention profile generated by ART (left) and A-ART (right) for a test
sample and its adversary.

In Figure 2, we compare the attention profiles being generated for a sample in
test set and its adversarial counterpart by trained ART and A-ART models. We
observe that that attention generated by A-ART is more robust to adversarial
perturbations and the attention profiles of the original sample and its
adversarial counterpart overlap to a great extent. On the other hand, ART
exhibits more variations in the attention profiles as a result of adversarial
perturbations to the input. Another thing to notice from the figure is that
the maximum attention being given to any frame reduces by an order of
magnitude when trained using A-ART model. In other words, the attention map
generated by A-ART is smoother enforcing the temporal coherence property which
has been shown to help video classification model performance [19, 20].

For the test set videos, we computed the mean square error (MSE) between the
attention-maps obtained for the original video and its adversarial counterpart
using ART and A-ART. Then we averaged it over the entire test set. We note
that our proposed model, A-ART drastically reduced the average MSE from
$4\times 10^{-5}$ obtained using ART to $3\times 10^{-8}$. This ensures that
A-ART has learnt to not to be fooled by perturbations in the adversarial
example and has almost similar attention-map for both the original and
perturbed video.

####  3.2.3 Hyperparameter Tuning

Fig. 3: Validation GAP for models with cross-entropy loss and adversarial
loss: neighborhood radius $\epsilon$ was varied with $\alpha=1$(left) and
$\alpha$ was varied with $\epsilon=0.5$ (right).

We aim to understand the impact of the two hyper-parameters $\epsilon$ and
$\alpha$ on the model performance by perturbing one of them, while keeping the
other constant. By altering $\epsilon$ , we aim to understand the impact of
smoothing radius around the data-points on the model performance and
perturbing $\alpha$ impacts the weight of the adversarial loss on the overall
optimization. The plots comparing the validation GAP for different values of
hyper-parameters is shown in Figure 3. First, the value of $\alpha$ was kept
fixed at 1 and $\epsilon$ was varied. For lower values of $\epsilon$, ART
model show an improvement over Non-ART model peaking at $\epsilon=0.5$. As we
increase the value of $\epsilon$, the model’s performance starts
deteriorating. This is expected since $\epsilon$ defines the neighborhood
around an input feature vector over which the conditional distribution is
smoothed. Increasing the radius of this neighborhood forces our model to learn
smoother functions that cannot capture the complexity of the conditional
distribution function thereby decreasing its performance on the validation
set. Similarly, as we increase the adversarial loss weight $\alpha$, the
performance increases, peaks at $1$ and starts reducing as the relative weight
of classification goes down.

####  3.2.4 Adversarial Robustness

Moosavi et.al [12] proposed a simple and accurate method for computing the
robustness of different classifiers to adversarial perturbations. Given a data
sample and a trained model, their method computes the minimum perturbation
$r_{tot}$ that can be added to the sample so that the model predicts it
incorrectly. Then a statistic $\rho_{tot}$ is computed by dividing the norm of
$r_{tot}$ by the norm of actual features. To fool an adversarially robust
model, it would require a greater amount of perturbation to be added to the
features. This means $\rho_{tot}$ should be higher for a more robust model. We
compute $\rho_{tot}$ using our trained models and YT8M test set samples and
show the results in Fig 4. It can be seen clearly that A-ART improves the
adversarial robustness of ART.

Fig. 4: Average Robustness for all models. Our proposed model A-ART is more
robust to adversarial examples than both ART and non-ART base model.

##  4 Conclusion

This paper presents two approaches to train adversarially robust Transformer
model: (i) ART, an extension of image-based adversarially robust model for
videos and (ii) A-ART, an approach to further improve robustness of attention
space as well as output space. We show that ART and A-ART perform better than
Non-ART on test set. Moreover, compared to Non-ART and ART, A-ART shows an
exceptional gain of 18% and 9% respectively in robustness to adversarial
examples generated using FGSM based method. We also show enhanced robustness
of A-ART to adversarial perturbations generated using DeepFool. We also
observed that the attention-map generated by A-ART is more robust to
adversarial perturbations. In future, we plan to investigate the robustness of
intermediate embeddings so that they can be used to improve other video
understanding tasks. We also plan to extend A-ART to raw video datasets to
train and qualitatively evaluate on more realistic adversarial examples.

## References

  * [1] Shaoqing Ren Kaiming He, Xiangyu Zhang and Jian Sun,  “Deep residual learning for image recognition,”  in Proceedings of the IEEE conference on computer vision and pattern recognition, 2016, pp. 770–778.
  * [2] Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, et al.,  “An image is worth 16x16 words: Transformers for image recognition at scale,”  arXiv preprint arXiv:2010.11929, 2020.
  * [3] Bin Yang Wenjie Luo and Raquel Urtasun,  “Fast and furious: Real time end-to-end 3d detection, tracking and motion forecasting with a single convolutional net,”  in Proceedings of the IEEE conference on Computer Vision and Pattern Recognition, 2018, pp. 3569–3577.
  * [4] Yanping Huang Esteban Real, Alok Aggarwal and Quoc V. Le,  “Regularized evolution for image classifier architecture search,”  in Proceedings of AAAI Conference on Artificial Intelligence (AAAI), 2019, pp. 0–0.
  * [5] Du Tran, Heng Wang, Lorenzo Torresani, and Matt Feiszli,  “Video classification with channel-separated convolutional networks,”  in Proceedings of the IEEE/CVF International Conference on Computer Vision, 2019, pp. 5552–5561.
  * [6] Kenton Lee Jacob Devlin, Ming-Wei Chang and Kristina Toutanova,  “Bert:pre-training of deep bidirectional transformers for language understanding,”  arXiv preprint arXiv:1810.04805, 2018.
  * [7] Barret Zoph and Quoc Le,  “Neural architecture search with reinforcement learning,”  in International Conference on Learning Representations (ICLR), 2017, pp. 0–0.
  * [8] Jonathon Shlens Barret Zoph, Vijay Vasudevan and Quoc V. Le,  “Learning transferable architectures for scalable image recognition,”  in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018, pp. 0–0.
  * [9] Carlini N. and Wagner D,  “Adversarial examples are not easily detected: Bypassing ten detection methods,”  in Proceedings of the 10th ACM Workshop on Artificial Intelligence and Security, 2017, pp. 3–14.
  * [10] Christian Szegedy, Wojciech Zaremba, Ilya Sutskever, Joan Bruna, Dumitru Erhan, Ian Goodfellow, and Rob Fergus,  “Intriguing properties of neural networks,”  arXiv preprint arXiv:1312.6199, 2013.
  * [11] Ian Goodfellow, Jonathon Shlens, and Christian Szegedy,  “Explaining and harnessing adversarial examples,”  in International Conference on Learning Representations, 2015.
  * [12] Seyed-Mohsen Moosavi-Dezfooli, Alhussein Fawzi, and Pascal Frossard,  “Deepfool: a simple and accurate method to fool deep neural networks,”  in Proceedings of the IEEE conference on computer vision and pattern recognition, 2016, pp. 2574–2582.
  * [13] Xingxing Wei, Jun Zhu, Sha Yuan, and Hang Su,  “Sparse adversarial perturbations for videos,”  in Proceedings of the AAAI Conference on Artificial Intelligence, 2019, vol. 33, pp. 8973–8980.
  * [14] Takeru Miyato, Shin-ichi Maeda, Masanori Koyama, and Shin Ishii,  “Virtual adversarial training: a regularization method for supervised and semi-supervised learning,”  IEEE transactions on pattern analysis and machine intelligence, vol. 41, no. 8, pp. 1979–1993, 2018.
  * [15] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin,  “Attention is all you need,”  arXiv preprint arXiv:1706.03762, 2017.
  * [16] Sami Abu-El-Haija, Nisarg Kothari, Joonseok Lee, Paul Natsev, George Toderici, Balakrishnan Varadarajan, and Sudheendra Vijayanarasimhan,  “Youtube-8m: A large-scale video classification benchmark,”  arXiv preprint arXiv:1609.08675, 2016.
  * [17] Saurabh Sahu, Palash Goyal, Shalini Ghosh, and Chul Lee,  “Cross-modal non-linear guided attention and temporal coherence in multi-modal deep video models,”  in Proceedings of the 28th ACM International Conference on Multimedia, 2020, pp. 313–321.
  * [18] Joonseok Lee, Walter Reade, Rahul Sukthankar, George Toderici, et al.,  “The 2nd youtube-8m large-scale video understanding challenge,”  in Proceedings of the European Conference on Computer Vision (ECCV) Workshops, 2018, pp. 0–0.
  * [19] De-An Huang, Vignesh Ramanathan, Dhruv Mahajan, Lorenzo Torresani, Manohar Paluri, Li Fei-Fei, and Juan Carlos Niebles,  “What makes a video a video: Analyzing temporal information in video understanding models and datasets,”  in Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, 2018, pp. 7366–7375.
  * [20] Hossein Mobahi, Ronan Collobert, and Jason Weston,  “Deep learning from temporal coherence in video,”  in Proceedings of the 26th Annual International Conference on Machine Learning, 2009, pp. 737–744.


T2AcmrTempora-TLF

# A behavioural approach to port-controlled systems

Jonas Kirchhoff

(03.06.2024)

#### Abstract

We give insight in the structure of port-Hamiltonian systems as control
systems in between two closed Hamiltonian systems. Using the language of
category theory, we identify systems with their behavioural representation and
view a port-control structure with desired structural properties on a given
closed system as an extension of this system which itself may be embedded in a
“larger” closed system. The latter system describes the nature of the ports
(e.g. Hamiltonian, metriplectic etc.). This point of view allows us to
describe meaningful port-control structures for a large family of systems,
which is illustrated with Hamiltonian and metriplectic systems.

#### Keywords

port-Hamiltonian systems, metriplectic system, behavioural theory, categorical
systems theory.

Corresponding author: Jonas Kirchhoff
Jonas Kirchhoff
Institut für Mathematik, Technische Universität Ilmenau, Weimarer Straße 25,
98693 Ilmenau, Germany
E-mail<EMAIL_ADDRESS>

Jonas Kirchhoff thanks the Technische Universität Ilmenau and the Freistaat
Thüringen for their financial support as part of the Thüringer
Graduiertenförderung.

##  1 Introduction

Port-controlled systems, in particular port-Hamiltonian systems, have been
extensively studied since their introduction more than thirty years ago. This
vast theory covers finite-dimensional electro-mechanical systems [JvdS14,
MU23], infinite-dimensional systems [JZ12] and has been extended to
thermodynamic systems, see e.g. [RMS13, RLG22, MvdS19], However, the
assignement of a port-structure does appear to be rather ad-hoc instead of
following a well-defined procedure. In the present paper, a behavioural point
of view is offered, where port-controlled systems are the behaviours that
realise a certain class of choices of extensions of given closed models.

The paper is organised as follows. In section 2, we recall the behavioural
theory of Jan Willems, see [PW97]. We demonstrate that instead of following
the original definition, the continuous machines of [SSV20] present more
properties of solutions of dynamical systems, in particular differential
equations. In section 3, we define port-controlled systems with given
interface and demonstrate this with Hamiltonian and metriplectic systems in
section 4.

##  2 Behaviours and continuous machines

The original definition of a dynamical system in the behavioural framework is
the following.

######  Definition 2.1 ([PW97, Def. 1.3.1]).

A dynamical system is a triple $\Sigma=(\mathbb{T},\mathbb{W},\mathfrak{B})$
of a time axis $\mathbb{T}\subseteq\mathbb{R}$, a signal space $\mathbb{W}$
and a behaviour $\mathfrak{B}\subseteq\mathbb{W}^{\mathbb{T}}$ of curves in
the signal space.

In particular, trajectories of a dynamical system must necessarily be defined
on the whole time axis. A particular class of dynamical systems are the
dynamical systems which are given by differential equations, where the time
axis is a nontrivial interval and a typical choice of behaviour is the set of
all maximal solutions. Here, a solution is a differentiable curve, defined on
an open interval, which fulfils the differential equation on each point; and a
maximal solution is a solution which may not be extended to a larger interval
on the time axis. As an example, the set $\mathfrak{B}_{0}$ of all maximal
solutions of

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x=x^{2},\qquad x(0)=x_{0},$ (2.1)

where $x_{0}$ is allowed to vary arbitrarily in $\mathbb{R}$, contains
precisely the functions

$\displaystyle
x(\cdot;x_{0}):\left(-\frac{1}{\left|x_{0}\right|},\frac{1}{\left|x_{0}\right|}\right)\to\mathbb{R},\quad
t\mapsto\frac{1}{\frac{1}{x_{0}}-t}$

and the constant zero function. Each (not necessarily maximal) solution of
(2.1) is the restriction of a maximal solution to a smaller interval. In
particular, these solutions are not defined on the whole time axis
$\mathbb{R}$, and there exists no
$\left\\{0\right\\}\subsetneqq\mathbb{T}\subseteq\mathbb{R}$ so that all (not
necessarily maximal) solutions of (2.1) may be defined on $\mathbb{T}$. Thus,
$\mathfrak{B}_{0}$ is not a behaviour in the strict sense of Definition 2.1.
This may be resolved by replacing the time axis by a “suitable collection”
$(\mathbb{T}_{i})_{i\in I}$ of time axes; the behaviour then becomes a family
$\mathfrak{B}_{i}\in\mathbb{W}^{\mathbb{T}_{i}}$, $i\in I$.

A second property of solutions of differential equations that is not captured
by the general Definition 2.1, is that restrictions of (not necessarily
maximal) solutions of a differential equation are (in general not maximal)
solutions. This means that there exist “restriction functions”
$\varphi_{i,j}:\mathfrak{B}_{i}\to\mathfrak{B}_{j}$ for “suitable” time axes
$\mathbb{T}_{i},\mathbb{T}_{j}$; in particular, there must be a well-chosen
relation between $\mathbb{T}_{i},\mathbb{T}_{j}$. A first choice for time axes
in the case of a differential equation is the set of all open, nonempty
intervals, with $\mathfrak{B}_{I}$ being the set of all curves defined on $I$
which solve our differential equation. A quite natural choice for the
restriction functions in this case is the the usual restriction of functions
to smaller intervals, i.e. $\varphi_{I,J}$ exists if, and only if, $J\subseteq
I$, and then $\varphi_{I,J}(x)=x|_{J}$. Then, it becomes clear that a
“suitable collection” of time axes must be a “well-chosen” category, and the
behaviour is a presheaf over this category. Recall the formal definition.

######  Definition 2.2.

A small category $\mathcal{C}$ consists of the data

  * •

a set $\mathrm{Ob}_{\mathcal{C}}$ of objects

  * •

for each $x,y\in\mathrm{Ob}_{\mathcal{C}}$ a (possibly empty) set
$\mathrm{Hom}_{\mathcal{C}}(x,y)$ of morphisms

  * •

an operation
$\circ:\mathrm{Hom}_{\mathcal{C}}(y,z)\times\mathrm{Hom}_{\mathcal{C}}(x,y)\to\mathrm{Hom}_{\mathcal{C}}(x,z)$

so that $\circ$ is associative and admits a unit, i.e. for all
$x\in\mathrm{Ob}_{\mathcal{C}}$ there exists
$1_{x}\in\mathrm{Hom}_{\mathcal{C}}(x,x)$ so that, for all
$y\in\mathrm{Ob}_{\mathcal{C}}$, $\varphi\in\mathrm{Hom}_{\mathcal{C}}(x,y)$
and $\psi\in\mathrm{Hom}(y,x)$, $\varphi\circ 1_{x}=\varphi$ and
$1_{x}\circ\psi=\psi$. The opposite category $\mathcal{C}^{\mathrm{op}}$ is
the category with
$\mathrm{Ob}_{\mathcal{C}^{\mathrm{op}}}:=\mathrm{Ob}_{\mathcal{C}}$ and
$\mathrm{Hom}_{\mathcal{C}^{\mathrm{op}}}(x,y):=\mathrm{Hom}_{\mathcal{C}}(y,x)$
for all $x,y\in\mathrm{Ob}_{\mathcal{C}}$. A functor
$F:\mathcal{C}\to\mathcal{C}^{\prime}$ between (small) categories
$\mathcal{C}$ and $\mathcal{C}^{\prime}$ consists of the data

  * •

for all $x\in\mathrm{Ob}_{\mathcal{C}}$, an object
$F(x)\in\mathrm{Ob}_{\mathcal{C}^{\prime}}$

  * •

for each $\varphi\in\mathrm{Hom}_{\mathcal{C}}(x,y)$, a morphism
$F(\varphi)\in\mathrm{Hom}_{\mathcal{C}^{\prime}}(F(x),F(y))$

so that $F(\psi\circ\varphi)=F(\psi)\circ F(\varphi)$ and $F(1_{x})=1_{F(x)}$.
The functors $F:\mathcal{C}^{\mathrm{op}}\to\mathcal{C}^{\prime}$ are called
presheaves over $\mathcal{C}$ with values in $\mathcal{C}^{\prime}$.

######  Remark 2.3.

In particular, the presheaves over a small category $\mathcal{C}$ with values
in a category $\mathcal{C}^{\prime}$ are the objects of the category
Psh($\mathcal{C}$,$\mathcal{C}^{\prime}$), see [KS06, Definition 17.1.3]. A
morphism of presheaves $\mathcal{F}$ and $\mathcal{G}$ consists is a family
$\varphi_{x}\in\mathrm{Hom}_{\mathcal{C}^{\prime}}(\mathcal{F}(x),\mathcal{G}(x))$,
$x\in\mathrm{Ob}_{\mathcal{C}}$, so that the diagram

${\mathcal{F}(x)}$${\mathcal{G}(x)}$${\mathcal{F}(y)}$${\mathcal{G}(y)}$$\scriptstyle{\varphi_{x}}$$\scriptstyle{\mathcal{F}(\psi)}$$\scriptstyle{\mathcal{G}(\psi)}$$\scriptstyle{\varphi_{y}}$

is commutative for all $x,y\in\mathrm{Ob}_{\mathcal{C}}$ and each
$\psi\in\mathrm{Hom}_{\mathcal{C}}(y,x)$.

######  Example 2.4.

The open intervals containing zero are the objects of a category $\mathcal{C}$
whose morphisms are the inclusions, i.e.
$\mathrm{Hom}_{\mathcal{C}}(I,J)=\left\\{\mathrm{id}_{I}\right\\}$ whenever
$I\subseteq J$, and otherwise $\mathrm{Hom}_{\mathcal{C}}(I,J)=\emptyset$. Let
$f:\mathbb{R}^{1+n}\to\mathbb{R}^{n}$ be a continuous function and put, for
all $I\in\mathrm{Ob}_{\mathcal{C}}$,

$\displaystyle\mathfrak{B}_{f,0}(I):=\left\\{x\in\mathcal{C}^{1}(I,\mathbb{R}^{n})\,\big{|}\,\forall
t\in I:\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=f(t,x(t))\right\\},$

and, for all $I,J\in\mathrm{Ob}_{\mathcal{C}}$ with $J\subseteq I$ and
$x\in\mathfrak{B}_{f,0}(I)$, $\varphi_{I,J}(x):=x|_{J}$. Since
differentiability and continuity are by definition local properties,
$x|_{J}\in\mathfrak{B}_{f,0}(J)$ and therefore the data
$(\mathfrak{B}_{f,0}(I),\varphi_{I,J})_{J\subseteq
I\in\mathrm{Ob}_{\mathcal{C}}}$ are the data of a presheaf with values in the
category of sets. This presheaf is the behaviour of the initial value problem

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x=f(t,x),\qquad x(0)=x_{0}$

with free initial state $x_{0}$.

One property of solutions of a differential equation
$\tfrac{\mathrm{d}}{\mathrm{d}t}x=f(t,x)$ is that solutions that agree on
overlap of their domains may be glued together to a single solution. This is
formalised in the notion of a sheaf on a Grothendieck site. Informally111The
formal definition using sieves may be found e.g. in [KS06, chapter 16]., the
latter is a category with a choice of covering families of maps corresponding
to open coverings in the category of open sets on a topological space; and a
sheaf is a presheaf so that families of elements locally defined on a covering
family, whose restrictions coincide on common, may be globally extended. Then,
a natural choice of coverings on the interval category of Example 2.4 are
coverings by increasing families of open subintervals and gluing of solutions
is just the choice of the solution defined on the largest element of the
covering family. A different category of intervals whose sheaves much better
capture the more intricate property that solutions defined on compact
intervals $[a,b]$ and $[b,c]$ may be glued together whenever they coincide on
$b$, was suggested in [SSV20].

######  Definition 2.5 ([SSV20, Definition 3.1.1]).

The category Int of continuous intervals consists of the following data:

  * •

$\mathrm{Ob_{\textbf{Int}}}:=\mathbb{R}_{\geq 0}$

  * •

$\mathrm{Hom}_{\mathrm{\textbf{Int}}}(a,b):=[0,b-a]$ for all
$a,b\in\mathbb{R}_{\geq 0}$, where $[0,-x]:=\emptyset$ for all
$x\in\mathbb{R}_{\geq 0}$,

  * •

$x\circ y:=x+y$ for all $x\in\mathrm{Hom}_{\mathrm{\textbf{Int}}}(b,c)$ and
$y\in\mathrm{Hom}_{\mathrm{\textbf{Int}}}(a,b)$, $0\leq a\leq b\leq c$.

A continuous interval sheaf $(\mathcal{F}(a),\varphi_{a,b,x})_{0\leq b\leq
a,0\leq x\leq a-b}$ is a presheaf over Int with values in Set so that, for all
$0\leq\tau\leq t$ and $x,y\in\mathcal{F}(t)$,

$\displaystyle\varphi_{t,\tau,0}(x)=\varphi_{t,\tau,0}(x)\leavevmode\nobreak\
\wedge\leavevmode\nobreak\
\varphi_{t,t-\tau,\tau}(x)=\varphi_{t,t-\tau,\tau}(y)$

implies that $x=y$ and, for all $x_{1}\in\mathcal{F}(\tau)$ and
$x_{2}\in\mathcal{F}(t-\tau)$ with

$\displaystyle\varphi_{t-\tau,0,0}(x_{2})=\varphi_{\tau,0,\tau}(x_{1})$

there exists $x_{0}\in\mathcal{F}_{t}$ so that

$\displaystyle x_{1}=\varphi_{t,\tau,0}(x_{0})\leavevmode\nobreak\
\wedge\leavevmode\nobreak\ \varphi_{t,t-\tau,\tau}(x_{0}).$

We illustrate this definition with the realisation of differential equations
as continuous interval sheaves. This realisation is ever so slightly different
than the one given in [SSV20, Proposition 5.1.2] where the realisation of a
time-varying differential equation as time-invariant differential equation was
used.

######  Example 2.6.

Let $f:\mathbb{R}^{1+n}\to\mathbb{R}^{n}$ be a continuous function and define,
for each $\tau\in\mathbb{R}_{\geq 0}$, $\mathfrak{B}_{f}(\tau)$ as the set

$\displaystyle\left\\{(x,\vartheta)\in\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathbb{R}\,\left|\,\begin{array}[]{l}\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=f(t-\vartheta,x(t))\\\
\text{for all}\leavevmode\nobreak\ t\in[0,\tau]\end{array}\right.\right\\};$

$\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n}):=\left\\{x|_{[0,\tau]}\,\big{|}\,x\in\mathcal{C}^{1}((-\varepsilon,\tau+\varepsilon),\mathbb{R}^{n}),\varepsilon>0\right\\}$.
Define further, for $0\leq t_{0}\leq t_{1}$ and $0\leq\tau\leq t_{1}-t_{0}$,

$\displaystyle\varphi_{t_{1},t_{0},\tau}:\mathfrak{B}_{f}(t_{1})\to\mathfrak{B}_{f}(t_{0}),\
(x,\vartheta)\mapsto(t\mapsto x(t+\tau),\vartheta-\tau);$

using the definition of $\mathfrak{B}_{f}(t_{0})$, it is evident that
$\varphi_{t_{1},t_{0},\tau}$ is well-defined. Then, the first property of a
sheaf is evident, and, for all $0\leq\tau\leq t$,
$(x_{1},\vartheta_{1})\in\mathfrak{B}_{f}(\tau)$ and
$(x_{2},\vartheta_{2})\in\mathfrak{B}_{f}(t-\tau)$ fulfil
$\varphi_{t-\tau,0,0}(x_{2},\vartheta_{2})=\varphi_{\tau,0,\tau}(x_{1},\vartheta_{1})$
if, and only if, $\vartheta_{2}=\vartheta_{1}-\tau$ and
$x_{2}(0)=x_{1}(\tau)$. Define

$\displaystyle z:[0,t]\to\mathbb{R}^{n},\qquad\text{
т}\mapsto\begin{cases}x_{1}(\text{т}),&\text{т}\in[0,\tau],\\\
x_{2}(\text{т}-\tau),&\text{т}\in[\tau,t].\end{cases}$

Since $x_{1}(\tau)=x_{2}(0)$, $z$ is continuous, and since $f$ is continuous,
$z$ is continuously differentiable with

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}z(\text{т})=\tfrac{\mathrm{d}}{\mathrm{d}t}x(\text{т})=f(\text{т}-\vartheta_{1},x(\text{т})=f(\text{т}-\vartheta_{1},z(\text{т}))$

for all $\text{т}\in[0,\tau]$, and

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}z(\text{т})=\tfrac{\mathrm{d}}{\mathrm{d}t}x_{2}(\text{т}-\tau)$
$\displaystyle=f(\text{т}-\tau-\vartheta_{2},x_{2}(\text{т}-\tau))$
$\displaystyle=f(\text{т}-\vartheta_{1},z(\text{т}))$

for all $\text{т}\in[\tau,t]$. This shows that
$(z,\vartheta_{1})\in\mathfrak{B}_{f}(t)$ with
$\varphi_{t,\tau,0}((z,\vartheta_{1}))=(x_{1},\vartheta_{1})$ and
$\varphi_{t,t-\tau,\tau}((z,\vartheta_{1}))=(x_{2},\vartheta_{2})$. Therefore,
$\mathfrak{B}_{f}$ is a continuous interval sheaf. This sheaf may be viewed as
the sheaf of all solutions of the differential equation

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x=f(t,x),$ (2.2)

where a solution $x:[t_{0},t_{1}]\to\mathbb{R}^{n}$, $t_{1}\geq t_{0}$, is a
continuously differentiable function which fulfils (2.2) for all
$t\in[t_{0},t_{1}]$. Such a solution corresponds then to
$(x(\cdot+t_{0}),t_{0})\in\mathfrak{B}_{f}(t_{1}-t_{0})$, and conversely each
$(x,\vartheta)\in\mathfrak{B}_{f}(\tau)$ corresponds to the solution
$x(\cdot-\vartheta)\in\mathcal{C}^{1}([\vartheta,\vartheta+\tau])$ of (2.2).

We may now give a behavioural definition of a continuous dynamical system,
where “continuous” just means continuous time.

######  Definition 2.7.

A continuous dynamical system is a continuous interval sheaf $\mathfrak{B}$.

######  Remark 2.8.

In Willems’ original framework, properties of a dynamical system, e.g.
linearity, can be translated in properties of the corresponding behavioural
model: A system is linear if, and only if, the signal space is linear. The
same description is possible in terms of continuous interval sheaves. A linear
continuous dynamical system is a continuous interval sheaf $\mathfrak{B}$ with
values in the category Vect of vector spaces.

To deal with systems with input and output, Schultz et al. introduce a
continuous machine as follows.

######  Definition 2.9.

A continuous machine is a tuple
$(\mathfrak{B},\mathfrak{E},\mathfrak{A},\varphi)$ of continuous interval
sheaves $\mathfrak{B},\mathfrak{E},\mathfrak{A}$ and a sheaf morphism
$\varphi:\mathfrak{B}\to\mathfrak{A}\times\mathfrak{E}$, where
$(\mathfrak{A}\times\mathfrak{E})(t)=\mathfrak{A}(t)\times\mathfrak{E}(t)$ for
all $t\in\mathbb{R}_{\geq 0}$

######  Example 2.10.

Let $f\in\mathcal{C}(\mathbb{R}^{1+n+m},\mathbb{R}^{n})$,
$g\in\mathcal{C}(\mathbb{R}^{1+n+m},\mathbb{R}^{p})$ and consider the
nonlinear input-state-output system

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)$
$\displaystyle=f(t,x,u(t)),$ (2.3) $\displaystyle y(t)$
$\displaystyle=g(t,x(t),u(t)),$

where the control $u$ is a continuous function with values in
$\mathbb{R}^{m}$, and define
$\mathfrak{B}_{f,g}(\tau)\subseteq\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathcal{C}([0,\tau],\mathbb{R}^{m})\times\mathbb{R}$,
for all $\tau\in\mathbb{R}_{\geq 0}$, as the set

$\displaystyle\left\\{(x,u,\vartheta)\,\big{|}\,\forall
t\in[0,\tau]:\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=f(t-\tau,x(t),u(t))\right\\},$

and put, similiarly to Example 2.6 for all $0\leq t_{0}\leq t_{1}$ and
$0\leq\tau\leq t_{1}-t_{0}$,

$\displaystyle\varphi_{t_{1},t_{0},\tau}^{\mathfrak{B}}:\mathfrak{B}_{f,g}(t_{1})$
$\displaystyle\to\mathfrak{B}_{f,g}(t_{0}),$ $\displaystyle(x,u,\vartheta)$
$\displaystyle\mapsto(t\mapsto x(t+\tau),t\mapsto u(t+\tau),\vartheta-\tau).$

Analogously, we define
$\mathfrak{A}(\tau):=\mathcal{C}([0,\tau],\mathbb{R}^{m})\times\mathbb{R}$ and
$\mathfrak{E}:=\mathcal{C}([0,\tau],\mathbb{R}^{p})\times\mathbb{R}$ with
restriction morphisms

$\displaystyle\varphi_{t_{1},t_{0},\tau}^{\mathfrak{A}}(u,\vartheta)$
$\displaystyle:=(t\mapsto u(t+\tau),\vartheta-\tau),$
$\displaystyle\varphi_{t_{1},t_{0},\tau}^{\mathfrak{E}}(y,\vartheta)$
$\displaystyle:=(t\mapsto y(t+\tau),\vartheta-\tau).$

Analogously to Example 2.6, it is straightforward to verify that
$\mathfrak{E},\mathfrak{A},\mathfrak{B}$ are continuous interval sheaves.
Define the function

$\displaystyle\varphi:\mathfrak{B}\to\mathfrak{A}\times\mathfrak{E},\qquad(x,u,\vartheta)\mapsto\big{(}(g(\cdot-\vartheta,x,u),\vartheta),(u,\vartheta)\big{)}.$

It is evident that $\varphi$ is a morphism of continuous interval sheaves, so
that $(\mathfrak{B},\mathfrak{E},\mathfrak{A},\varphi)$ is a continuous
interval machine. This machine is equivalent to the control system (2.3) in
the sense that there is the one-to-one correspondence between solutions of
(2.3), i.e. curves
$(x,u,y)\in\mathcal{C}^{1}([t_{0},t_{1}],\mathbb{R}^{n})\times\mathcal{C}([t_{0},t_{1}],\mathbb{R}^{m})\times\mathcal{C}([t_{0},t_{1}],\mathbb{R}^{p})$
which fulfil (2.3) pointwise, and elements
$(x(\cdot+t_{0}),u(\cdot+t_{0}),t_{0})\in\mathfrak{B}_{f,g}(t_{1}-t_{0})$.

The morphism $\varphi_{\mathfrak{E}}$ may be viewed as the “input map” and
$\varphi_{\mathfrak{A}}$ as the “output map” of a given continuous machine.
Note, however, that there is no explicit notion of a “state” of a continuous
interval sheaf which differs from “input” and “output”, nor is it required
that the input and output differ at all. The authors of [SSV20] argue
additionally that the notions of “input” and output are completely arbitrary
and symmetric so that there is no fixed notion of input and output of a
continuous machine. More precisely, one might think of the morphism $\varphi$
as an arbitrary “reading” on the system, whose results may, or may not, be
used to manipulate the system by choosing convenient subsystems. Therefore, it
might be argued that the theory of continuous machine is in the spirit of the
behavioural theory of Willems.

##  3 Port-based modelling

###  3.1 Motivation

The idea is very simple indeed and may be illustrated with the following
example. Consider a simple planar mass-spring system consisting of a single
ideal spring with spring constant $k\in\mathbb{R}_{>0}$, which may be
contracted and stretched along a single axis, and a single point mass $m>0$
which is attached to the spring. This system is assumed to be in a vacuum with
no external forces. Then, the standard Hamiltonian model using Hooke’s Law is

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}\begin{pmatrix}x\\\
p\end{pmatrix}$ $\displaystyle=\begin{bmatrix}0&1\\\
-1&0\end{bmatrix}\begin{bmatrix}k&0\\\
0&\frac{1}{m}\end{bmatrix}\begin{pmatrix}x\\\ p\end{pmatrix}.$

The most simple way of interaction with this system is to impose a force on
the point mass. This may be viewed as adding a second spring “on the opposite
side” of the point mass with time-varying spring constant $\kappa$, which is
allowed to take arbitrary real values; since this is a thought-experiment, we
do not care about the physical existence of such a spring. This configuration
is sketched in Figure 1.

$k$$m$$\kappa(t)$$\upsilon(t)$$x(t)$ Figure 1: extended mass-spring-system

Then, we get the family of closed models for the extended mass-spring system

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}\begin{pmatrix}x\\\ p\\\
\upsilon\end{pmatrix}$ $\displaystyle=\begin{bmatrix}0&1&0\\\ -1&0&1\\\
0&-1&0\end{bmatrix}\begin{bmatrix}k&0&0\\\ 0&\frac{1}{m}&0\\\
0&0&\kappa(t)\end{bmatrix}\begin{pmatrix}x\\\ p\\\ \upsilon\end{pmatrix}$

where $\upsilon$ denotes the “elongation” of our second spring. When we then
add the “readings” $u:=\kappa v$ and
$y:=-\tfrac{\mathrm{d}}{\mathrm{d}t}\upsilon$, then we see that the port-
Hamiltonian system

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}\begin{pmatrix}x\\\
p\end{pmatrix}$ $\displaystyle=\begin{bmatrix}0&1\\\
-1&0\end{bmatrix}\begin{bmatrix}k&0\\\
0&\frac{1}{m}\end{bmatrix}\begin{pmatrix}x\\\
p\end{pmatrix}+\begin{bmatrix}0\\\ 1\end{bmatrix}u$ $\displaystyle y$
$\displaystyle=\begin{bmatrix}0\\\ 1\end{bmatrix}^{\top}\begin{bmatrix}k&0\\\
0&\frac{1}{m}\end{bmatrix}\begin{pmatrix}x\\\ p\end{pmatrix}$

emerges from our model systems. We may alternatively identify trajectories
whose curves $x,p$ coincide of model systems with parameters $\kappa,\upsilon$
and $\kappa^{\prime},\upsilon^{\prime}$ whenever
$\kappa\upsilon=\kappa^{\prime}\upsilon^{\prime}$. This identification gives a
subsystem, from which also the port-Hamiltonian system after definition of
$u,y$ emerges.

###  3.2 Formalisation

First, we need to establish a notion of a subsystem of a given machine. It is
intuitive to say that a system contains a second system as a subsystem if the
behaviour of the latter can be embedded into the behaviour of the former. In
the language of Category theory, embeddings are particular morphisms,
monomorphism. Morphisms of machines are straightforwardly defined using
morphisms of sheaves as follows.

######  Definition 3.1.

Let $\mathcal{M}=(\mathfrak{B},\mathfrak{E},\mathfrak{A},\varphi)$,
$\mathcal{M}^{\prime}=(\mathfrak{B}^{\prime},\mathfrak{E}^{\prime},\mathfrak{A}^{\prime},\varphi^{\prime})$
be continuous machines. A triple $\Phi=(\beta,\eta,\alpha)$ is a morphism of
continuous machines if either of the diagrammata

${\mathfrak{B}}$${\mathfrak{B}^{\prime}}$${\mathfrak{E}}$${\mathfrak{E}^{\prime}}$${\mathfrak{A}}$${\mathfrak{A}^{\prime}}$$\scriptstyle{\beta}$$\scriptstyle{\varphi_{\mathfrak{E}}}$$\scriptstyle{\varphi_{\mathfrak{A}}}$$\scriptstyle{\varphi_{\mathfrak{E}^{\prime}}}$$\scriptstyle{\varphi_{\mathfrak{A}^{\prime}}}$$\scriptstyle{\eta}$$\scriptstyle{\alpha}$${\mathfrak{B}}$${\mathfrak{B}^{\prime}}$${\mathfrak{E}}$${\mathfrak{A}^{\prime}}$${\mathfrak{A}}$${\mathfrak{E}^{\prime}}$$\scriptstyle{\beta}$$\scriptstyle{\varphi_{\mathfrak{E}}}$$\scriptstyle{\varphi_{\mathfrak{A}}}$$\scriptstyle{\varphi_{\mathfrak{E}^{\prime}}}$$\scriptstyle{\varphi_{\mathfrak{A}^{\prime}}}$$\scriptstyle{\eta}$$\scriptstyle{\alpha}$

whose arrows are morphisms of Int-sheaves, is commutative; we write
$\Phi:\mathcal{M}\to\mathcal{M}^{\prime}$.

######  Remark 3.2.

The two possibilities of machine morphisms as families of morphisms
$(\mathfrak{B}\to\mathfrak{B}^{\prime},\mathfrak{E}\to\mathfrak{E}^{\prime},\mathfrak{A}\to\mathfrak{A}^{\prime})$
and
$(\mathfrak{B}\to\mathfrak{B}^{\prime},\mathfrak{E}\to\mathfrak{A}^{\prime},\mathfrak{A}\to\mathfrak{E}^{\prime})$
reflect the ambiguity of the choice of the sheafes $\mathfrak{A}$ and
$\mathfrak{E}$. For example, an input-state-output system (2.3) has the
realisation as continuous machine of Example 2.10, where the projection onto
$\mathfrak{A}$ selects the input and the projection onto $\mathfrak{E}$
selects the output of a trajectory; $\varphi_{\mathfrak{A}}$ may be
interpreted as the input map and $\varphi_{\mathfrak{E}}$ as the output map.
The exchange of input and output map may be interpreted as exchanging the
problem of determining an output for an exlpicit differential equation, given
by an input function, to the inverse control problem of determining an input
which produces a given output. The formal equivalence of these problems is
reflected in the the isomorphy of the machines
$(\mathfrak{B},\mathfrak{E},\mathfrak{A},\varphi_{\mathfrak{E}}\oplus\varphi_{\mathfrak{A}})$
and
$(\mathfrak{B},\mathfrak{A},\mathfrak{E},\varphi_{\mathfrak{A}}\oplus\varphi_{\mathfrak{E}})$.

Now, the notion of a subsystem reveals itself.

######  Definition 3.3.

Let $\mathcal{M}=(\mathfrak{B},\mathfrak{E},\mathfrak{A},\varphi)$,
$\mathcal{M}^{\prime}=(\mathfrak{B}^{\prime},\mathfrak{E}^{\prime},\mathfrak{A}^{\prime},\varphi^{\prime})$
be continuous machines. $\mathcal{M}$ is a subsystem of $\mathcal{M}^{\prime}$
if, and only if, there exists a monomorphism
$\Phi:\mathcal{M}\hookrightarrow\mathcal{M}^{\prime}$.

Lastly, we need a notion of a closed system. Intuitively, a system is closed,
when there is no interaction between the system with any surroundings; in
particular, there are no “readings”, or “measurements” on the system.
Recalling the interpretation of the morphism
$\mathfrak{B}\to\mathfrak{A}\times\mathfrak{E}$ of a continuous machine as
“measurements”, the following definition presents itself.

######  Lemma 3.4.

Each constant presheaf over Int with values in Set is a continuous interval
sheaf. In particular, all constant continuous interval sheaves are isomorphic.

###### Proof.

Let $x$ be a set with identity morphism $1_{x}$. Put
$\mathcal{X}\in\mathrm{Fct}(\mathrm{\textbf{Int}}^{\text{op}},\mathcal{C})$ as
the constant functor that assigns $x$ to each interval object and $1_{x}$ to
each interval morphism. To see that this is indeed a sheaf, observe that each
$t\in\mathrm{Ob_{\textbf{Int}}}=\mathbb{R}_{\geq 0}$ admits at least one
nonempty covering, namely $(0,t)$, and hence the first sheaf property is
fulfilled; the second property is obviously true. Thus, $\mathcal{X}$ is a
continuous interval sheaf. Per definitionem, a constant sheaf is a sheaf that
is isomorphic to the sheafification of a constant presheaf. Since constant
presheaves are sheaves, each constant sheaf is isomorphic to a constant
presheaf; and constant presheaves are evidently isomorphic. Therefore, all
constant sheaves are indeed isomorphic. ∎

Now, we may describe a port-control structure for a closed system, which has
certain desired properties, as follows.

######  Definition 3.5.

Let $\mathfrak{B}_{0}$ and $\mathfrak{B}$ be continuous interval sheaves and
let $A:\mathfrak{B}_{0}\hookrightarrow\mathfrak{B}$ be a monomorphism of
sheaves so. Choose continuous interval sheaves
$\mathfrak{A},\mathfrak{E}^{\prime}$ and a morphism
$\varphi:\mathfrak{B}\to\mathfrak{A}\times\mathfrak{E}$. A continuous machine
$(\mathfrak{B}^{\prime},\mathfrak{A}^{\prime},\mathfrak{E}^{\prime},\varphi^{\prime})$
is a port-controlled $\mathfrak{B}_{0}$-system with
$(\mathfrak{B},\mathfrak{A},\mathfrak{E},\varphi)$-interface if there exist a
constant continuous interval sheaf $\mathfrak{O}$, a continuous interval sheaf
$\mathfrak{A}_{0}$ and monomorphisms $(A,\Phi_{1},\Phi_{2}),\Psi,\Xi$ of
continuous machines so that the following diagram is commutative:

${(\mathfrak{B}_{0},\mathfrak{O},\mathfrak{A}_{0},\varphi)}$${(\mathfrak{B},\mathfrak{A},\mathfrak{E},\varphi)}$${(\mathfrak{B}^{\prime},\mathfrak{A}^{\prime},\mathfrak{E}^{\prime},\varphi^{\prime})}$$\scriptstyle{(A,\Phi_{1},\Phi_{2})}$$\scriptstyle{\Psi}$$\scriptstyle{\Xi}$

######  Remark 3.6.

The choice of $\mathfrak{A}$ and $\mathfrak{E}$ and the projection $\varphi$
may be interpreted as the (arbitrary) choice of port-variables in the
originally closed system $\mathfrak{B}$. The original system, to which we
strive to assign a port-structure, is a closed subsystem of $\mathfrak{B}$.
The choice of the subsystem
$(\mathfrak{B}^{\prime},\mathfrak{A}^{\prime},\mathfrak{E}^{\prime},\varphi^{\prime})$
may be viewed as eliminating certain more or less undesired configurations of
port-variables or unnecessary “states” of the enclosing model $\mathfrak{B}$.
An example would be our motivating mass spring system, and we include in the
model system a totally unrelated system, e.g. a blinking lamp, which is not
needed nor desired for our particular choice of port-Hamiltonian system.
Eliminating this system from the model system is a specific choice of
subsystem
$(\mathfrak{B}^{\prime},\mathfrak{A}^{\prime},\mathfrak{E}^{\prime},\varphi^{\prime})$.

##  4 Applications

###  4.1 Port-Hamiltonian systems on Euclidean space

Port-Hamiltonian systems on the Euclidean space are systems which have the
form

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x$
$\displaystyle=(J(x)-R(x))\nabla H(x)+B(x)u$ (4.1) $\displaystyle y$
$\displaystyle=B(x)^{\top}\nabla H(x),$

where $J,R\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{n\times n})$ with
$J(\cdot)=-J(\cdot)^{\top}$ and $R(\cdot)=R(\cdot)^{\top}\geq 0$, and
$H\in\mathcal{C}^{1}(\mathbb{R}^{n},\mathbb{R})$. These systems may be viewed
as a particular choice of port-structure for a dissipative Hamiltonian system
modelled by

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x=(J(x)-R(x))\nabla H(x).$

Put as $\mathfrak{B}_{0}$ the behaviour of Example 2.6 with $f=(J-R)\nabla H$,
i.e.
$\mathfrak{B}_{0}(\tau)\subseteq\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathbb{R}$
is the set

$\displaystyle\left\\{(x,\vartheta)\,\big{|}\,\forall
t\in[0,\tau]:\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=(J(x(t))-R(x(t)))\nabla
H(x(t))\right\\}.$

Note that, due to time-invariance of the system, the time-shift parameter
$\vartheta$ may be omitted; this would, however, complicate the following
construction. Define the continuous matrix fields

$\displaystyle\mathcal{J}:\mathbb{R}^{n+m}$
$\displaystyle\to\mathbb{R}^{(n+m)\times(n+m)},\qquad(x,\zeta)\mapsto\begin{bmatrix}J(x)&B(x)\\\
-B(x)^{\top}&0\end{bmatrix},$ $\displaystyle\mathcal{R}:\mathbb{R}^{n+m}$
$\displaystyle\to\mathbb{R}^{(n+m)\times(n+m)},\qquad(x,\zeta)\mapsto\begin{bmatrix}R(x)&0\\\
0&0\end{bmatrix}$

and put as $\mathfrak{B}$ the behaviour of the collection of dissipative
Hamiltonian systems with structure matrices $\mathcal{J}$ and $\mathcal{R}$
whose Hamiltonian function may be decomposed into the direct sum of $H$ and an
auxiliary, possibly time-varying, Hamiltonian function
$H_{\alpha}\in\mathcal{C}^{0,1}([0,\tau]\times\mathbb{R}^{m},\mathbb{R}))$,
i.e. $H_{\alpha}$ is continuous in the first and continuously differentiable
in the last $m$ entries. This yields
$\mathfrak{B}(\tau)\subseteq\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathbb{R}\times\mathcal{C}^{0,1}([0,\tau]\times\mathbb{R}^{m},\mathbb{R})$
as the set

$\displaystyle\left\\{(\xi,\vartheta,H_{\alpha})\left|\\!\begin{array}[]{l}\begin{array}[]{cl}\tfrac{\mathrm{d}}{\mathrm{d}t}\xi(t)=&\mathcal{J}(\xi(t))\nabla(H\oplus
H_{\alpha}(t-\vartheta,\cdot))(\xi(t))\\\ &-\mathcal{R}(\xi(t))\nabla(H\oplus
H_{\alpha}(t-\vartheta,\cdot))(\xi(t))\end{array}\\\ \text{for
all}\leavevmode\nobreak\ t\in[0,\tau]\end{array}\right.\\!\\!\right\\}$

With the restriction morphisms

$\displaystyle\varphi^{\mathfrak{B}}_{t_{1},t_{0},\tau}(\xi,\vartheta,H_{\alpha}):=(t\mapsto\xi(t+\tau),\vartheta-\tau,H_{\alpha}(\cdot+\tau,\cdot))$

for all $0\leq t_{0}\leq t_{1}$ and $0\leq\tau\leq t_{1}-t_{0}$,
$\mathfrak{B}$ becomes a continuous interval sheaf which admits the embedding
$A:\mathfrak{B}_{0}\hookrightarrow\mathfrak{B}$

$\displaystyle
A(x,\vartheta):=\left(\left(x,-\int_{0}^{\cdot}B(x(w))^{\top}\nabla
H(x(w))\,\mathrm{d}w\right),\vartheta,0\right).$

A direct calculation yields for all $(x,\vartheta)\in\mathfrak{B}_{0}(\tau)$
and $\zeta:=-\int_{0}^{\cdot}B(x(w))^{\top}\nabla
H(x(w))\in\mathcal{C}^{1}([0,\tau],\mathbb{R}^{m})$ and for all
$t\in[0,\tau]$,

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}\begin{pmatrix}x\\\
-\int_{0}^{\cdot}B(x(w))^{\top}\nabla H(x(w))\,\mathrm{d}w\end{pmatrix}(t)$
$\displaystyle\quad=\begin{pmatrix}(J(x(t))-R(x(t)))\nabla H(x(t))\\\
-B(x(t))^{\top}\nabla H(x(t))\end{pmatrix}$
$\displaystyle\quad=\left(\mathcal{J}-\mathcal{R}\right)(x(t),\zeta(t))\nabla(H\oplus
0(t-\vartheta,\cdot))(x(t),\zeta(t))$

and hence $A$ is indeed well-defined; $A$ is a monomorphism since each
$A_{\tau}:\mathfrak{B}_{0}(\tau)\to\mathfrak{B}(\tau)$ is by construction
injective. The images of the morphisms of sheaves

$\displaystyle\varphi_{\mathfrak{A}}:\mathfrak{B}\to\mathcal{C}(\cdot,\mathbb{R}^{m})\times\mathbb{R},$
$\displaystyle\qquad(\xi,\vartheta,H_{\alpha})\mapsto(\mathrm{d}p_{2}(\nabla(H\oplus
H_{\alpha}))\circ\xi,\vartheta),$
$\displaystyle\varphi_{\mathfrak{E}}:\mathfrak{B}\to\mathcal{C}(\cdot,\mathbb{R}^{m})\times\mathbb{R},\
(\xi,\vartheta,H_{\alpha})\mapsto\left(-\tfrac{\mathrm{d}}{\mathrm{d}t}p_{2}\circ\xi,\vartheta\right),$

where $p_{2}:\mathbb{R}^{n+m}\to\mathbb{R}^{m}$ is the Cartesian projection
onto the second component bear the structure of continuous interval sheaves
$\mathfrak{A}$ and $\mathfrak{B}$. Then, we have a continuous machine
$(\mathfrak{B},\mathfrak{A},\mathfrak{E},(\varphi_{\mathfrak{A}},\varphi_{\mathfrak{B}}))$.
Define
$\varphi_{\mathfrak{A}_{0}}:\mathfrak{B}_{0}\to\mathcal{C}(\cdot,\mathbb{R}^{m})\times\mathbb{R}$
as the pullback of $\varphi_{\mathfrak{A}}$ under $A$, i.e.
$\varphi_{\mathfrak{A}_{0}}:=\varphi_{\mathfrak{A}}\circ A$, and let
$\mathfrak{A}_{0}$ the image of $\varphi_{\mathfrak{A}_{0}}$, which is a
sheaf. Let further $\mathfrak{O}$ be the continuous interval sheaf that
assigns each interval the set $\left\\{0\right\\}$. By construction of $A$, we
see that the projection
$\varphi_{\mathfrak{O}}:\mathfrak{B}_{0}\to\mathfrak{O}$ is exactly
$\varphi_{\mathfrak{E}}\circ A$ and hence
$(A,\mathrm{id}_{\mathfrak{A}_{0}},\mathrm{id}_{\mathfrak{E}_{0}})$, where
$\mathrm{id}_{\mathfrak{A}_{0}}:\mathfrak{A}_{0}\hookrightarrow\mathfrak{A}$
and
$\mathrm{id}_{\mathfrak{E}_{0}}:\mathfrak{E}_{0}\hookrightarrow\mathfrak{E}$
denote the canonical embeddings, is a monomorphism of continuous machines.
Recall from Example 2.10 that a representation of the input-state-output
system (4.1) as a continuous machine is
$(\widehat{\mathfrak{B}},\widehat{\mathfrak{A}},\widehat{\mathfrak{E}},(\varphi_{\widehat{\mathfrak{A}}},\varphi_{\widehat{\mathfrak{E}}}))$
with
$\widehat{\mathfrak{B}}(\tau)\subseteq\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathcal{C}([0,\tau],\mathbb{R}^{m})\times\mathbb{R}$
given as the set

$\displaystyle\left\\{(x,u,\vartheta)\,\left|\,\forall
t\in[0,\tau]:\begin{array}[]{cl}\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=&J(x(t))\nabla
H(x(t))\\\ &-R(x(t))\nabla H(x(t))\\\
&+B(x(t))u(t)\end{array}\right.\right\\}$

and $\widehat{\mathfrak{A}}$ and $\widehat{\mathfrak{E}}$ given as the images
of the projections

$\displaystyle\varphi_{\widehat{\mathfrak{A}}}:\widehat{\mathfrak{B}}$
$\displaystyle\to\mathcal{C}(\cdot,\mathbb{R}^{m})\times\mathbb{R},\quad(x,u,\vartheta)\mapsto(u,\vartheta),$
$\displaystyle\varphi_{\widehat{\mathfrak{E}}}:\widehat{\mathfrak{B}}$
$\displaystyle\to\mathcal{C}(\cdot,\mathbb{R}^{m})\times\mathbb{R},\quad(x,u,\vartheta)\mapsto(B(x(t))^{\top}\nabla
H(x(t)),\vartheta).$

We show that
$(\widehat{\mathfrak{B}},\widehat{\mathfrak{A}},\widehat{\mathfrak{E}},(\varphi_{\widehat{\mathfrak{A}}},\varphi_{\widehat{\mathfrak{E}}}))$
fits into the diagram

${(\mathfrak{B}_{0},\mathfrak{A}_{0},\mathfrak{O},\varphi)}$${(\mathfrak{B},\mathfrak{A},\mathfrak{E},\xi)}$${(\widehat{\mathfrak{B}},\widehat{\mathfrak{A}},\widehat{\mathfrak{E}},\psi)}$$\scriptstyle{(A,\mathrm{id}_{\mathfrak{A}_{0}},\mathrm{id}_{\mathfrak{E}_{0}})}$$\scriptstyle{\Psi}$$\scriptstyle{\Xi}$

where $\varphi:=\varphi_{\mathfrak{A}_{0}}\oplus\varphi_{\mathfrak{O}}$,
$\psi:=\varphi_{\widehat{\mathfrak{A}}}\oplus\varphi_{\widehat{\mathfrak{E}}}$
and $\xi:=\varphi_{\mathfrak{A}}\oplus\varphi_{\mathfrak{E}}$ To this end,
define the embeddings
$\Psi=(A,\mathrm{id}_{\mathfrak{A}_{0}},\mathrm{id}_{\mathfrak{E}_{0}})$ and
$\Xi=(\Xi_{0},\Xi_{1},\Xi_{2})$ as

$\displaystyle{\small\Xi_{0}(x,u,\vartheta):=\left(\left(x,-\int_{0}^{\cdot}B(x(w))^{\top}\nabla
H(x(w))\,\mathrm{d}w\right)\vartheta,u(\cdot)^{\top}\right)}$

and $\Xi_{1}$ and $\Xi_{2}$ the canonical embedding of
$\widehat{\mathfrak{A}}\subseteq\mathfrak{A}$ and
$\widehat{\mathfrak{A}}\subseteq\mathfrak{A}$, respectively. This shows that
$(\widehat{\mathfrak{B}},\widehat{\mathfrak{A}},\widehat{\mathfrak{E}},(\varphi_{\widehat{\mathfrak{A}}},\varphi_{\widehat{\mathfrak{E}}}))$
is a port-controlled dissipative Hamiltonian system with time-varying
Hamiltonian interface.

###  4.2 Metriplectic systems

Metriplectic systems are an extension of Hamiltonian systems to incorporate
dissipative effects due to irreversible generation of entropy. They are used
as models for systems in fluid dynamics and thermodynamics, see e.g. [Mor84].
In their most simple, finite-dimensional incarnation, metriplectic systems are
given as follows.

######  Definition 4.1.

The dynamical system $M(J,G,H,S)$ given by the differential equation

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x=J(x)\nabla H(x)+G(x)\nabla
S(x),$ (4.2)

where $J,G\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{n\times n})$ fulfil
$J(x)=-J(x)^{\top}$ and $G(x)=G(x)^{\top}\geq 0$ for all $x\in\mathbb{R}^{n}$,
and $H,S\in\mathcal{C}^{1}(\mathbb{R}^{n},\mathbb{R})$ are subject to the
noninteraction condition

$\displaystyle\forall x\in\mathbb{R}^{n}:J(x)\nabla S(x)=G(x)\nabla H(x)=0.$
(4.3)

Analogously to Hamiltonian systems, we propose a straightforward definition of
port-controlled metriplectic systems using the behavioural framework. A
representation of the behaviour of the metriplectic system (4.2)
$\mathfrak{B}_{0}$ so that
$\mathfrak{B}_{0}(\tau)\subseteq\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathbb{R}$
is

$\displaystyle\left\\{(x,\vartheta)\,\big{|}\,\forall
t:\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=J(x)\nabla H(x(t))+G(x(t))\nabla
S(x(t))\right\\}.$

Let
$\widetilde{J},\widetilde{G}\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{m\times
m})$ and $B,A\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{n\times m}$, and define

$\displaystyle\mathcal{J}:\mathbb{R}^{n+m}$
$\displaystyle\to\mathbb{R}^{(n+m)\times(n+m)},\qquad(x,\zeta)\mapsto\begin{bmatrix}J(x)&B(x)\\\
-B(x)^{\top}&\widetilde{J}(x)\end{bmatrix},$
$\displaystyle\mathcal{G}:\mathbb{R}^{n+m}$
$\displaystyle\to\mathbb{R}^{(n+m)\times(n+m)},\qquad(x,\zeta)\mapsto\begin{bmatrix}G(x)&A(x)\\\
A(x)^{\top}&\widetilde{G}(x)\end{bmatrix}.$

Additionally, it is assumed that $\widetilde{J},\widetilde{G},A$ and $B$ are
chosen so that $\mathcal{J}$ is pointwise antisymmetric and $\mathcal{G}$ is
pointwise symmetric and positive semidefinite. We define $\mathfrak{B}$ as the
behaviour of all metriplectic systems with structure matrices $\mathcal{J}$
and $\mathcal{R}$ whose Hamiltonian and entropy functions admit a
decomposition into the direct sum of $H$ and a time-varying auxiliary
Hamiltonian function
$H_{\alpha}\in\mathcal{C}^{0,1}([0,\tau]\times\mathbb{R}^{m},\mathbb{R}))$,
and $S$ and
$S_{\alpha}\in\mathcal{C}^{0,1}([0,\tau]\times\mathbb{R}^{m},\mathbb{R}))$,
respectively. We put, for each $\tau\in\mathbb{R}_{\geq 0}$,
$\mathfrak{B}(\tau)\subseteq\mathcal{C}^{1}([0,\tau],\mathbb{R}^{n})\times\mathbb{R}\times\mathcal{C}^{0,1}([0,\tau]\times\mathbb{R}^{m},\mathbb{R})\times\mathcal{C}^{0,1}([0,\tau]\times\mathbb{R}^{m},\mathbb{R})$
as the set of all $(\xi,\vartheta,H_{\alpha},S_{\alpha})$ with

$\displaystyle\forall
t\in[0,\tau]:\begin{array}[]{cl}\tfrac{\mathrm{d}}{\mathrm{d}t}\xi(t)=&\mathcal{J}(\xi(t))\nabla(H\oplus
H_{\alpha}(t-\vartheta,\cdot))(\xi(t))\\\
&+\mathcal{G}(\xi(t))\nabla(S+S_{\alpha}(t-\vartheta,\cdot))(\xi(t)),\end{array}$

and $\widetilde{J}(\cdot)\nabla(H\oplus
H_{\alpha})(\cdot)=\widetilde{G}(\cdot)\nabla(S\oplus S_{\alpha})(\cdot)\equiv
0$, and define the canonical restriction morphisms so that $\mathfrak{B}$ is a
continuous interval sheaf. In particular, $\mathfrak{B}$ admits the embedding
$A:\mathfrak{B}_{0}\hookrightarrow\mathfrak{B}$

$\displaystyle A(x,\vartheta)$
$\displaystyle:=\Big{(}\Big{(}x,-\int_{0}^{\cdot}B(x(w))^{\top}\nabla H(x(w))$
$\displaystyle\qquad+A(x(w))^{\top}\nabla
S(x(w))\,\mathrm{d}w\Bigg{)},\vartheta,0,0\Big{)};$

a direct calculation yields that $A$ is indeed a well-defined monomorphism.
Define the projections

$\displaystyle\varphi_{\mathfrak{A}}(\xi,\vartheta,H_{\alpha},S_{\alpha}):=(\mathrm{d}p_{2}(\nabla(H\oplus
H_{\alpha}))\circ\xi,\mathrm{d}p_{2}(\nabla(S\oplus
S_{\alpha}))\circ\xi.\vartheta),$
$\displaystyle\varphi_{\mathfrak{E}}(\xi,\vartheta,H_{\alpha},S_{\alpha}):=\left(-\tfrac{\mathrm{d}}{\mathrm{d}t}p_{2}\circ\xi,\vartheta\right),$

and equip their images $\mathfrak{A}$ and $\mathfrak{B}$ with the canonical
structure of a continuous interval sheaf so that $\varphi_{\mathfrak{A}}$ and
$\varphi_{\mathfrak{B}}$ are sheaf-morphisms, which gives a continuous machine
$(\mathfrak{B},\mathfrak{A},\mathfrak{E},(\varphi_{\mathfrak{A}},\varphi_{\mathfrak{E}}))$.
Choosing the particular auxiliary Hamiltonians that are induced by continuous
curves in the dual space, we get the behaviour $\widetilde{\mathfrak{B}}$,
with, for each $\tau\in\mathbb{R}_{\geq 0}$, by
$(x,u,\tau,\vartheta)\in\widetilde{\mathfrak{B}}(\tau)$ if, and only if,

$\displaystyle\forall
t\in[0,\tau]:\begin{array}[]{cl}\tfrac{\mathrm{d}}{\mathrm{d}t}x(t)=&J(x(t))\nabla
H(x(t))+G(x(t))\nabla S(x(t))\\\ &+B(x(t))u(t)+A(x(t))\tau(t),\end{array}$

and $B(\cdot)\tau=G(\cdot)u\equiv 0$, $B(\cdot)^{\top}\nabla
S(\cdot)-\widetilde{J}(\cdot)\tau\equiv 0$, and $A(\cdot)^{\top}\nabla
H(\cdot)+\widetilde{G}(\cdot)u\equiv 0$ This behaviour admits an analogous
embedding $\Xi_{0}$, which allows us to pull back the projections
$\varphi_{\mathfrak{A}}$ and $\varphi_{\mathfrak{B}}$ giving a morphism of
continuous machines
$\Xi:(\widetilde{\mathfrak{B}},\widetilde{\mathfrak{A}},\widetilde{\mathfrak{E}},\widetilde{\varphi})\hookrightarrow(\mathfrak{B},\mathfrak{A},\mathfrak{E},(\varphi_{\mathfrak{A}},\varphi_{\mathfrak{E}}))$.
Then, we can complete the diagram

${(\mathfrak{B}_{0},\mathfrak{A}_{0},\mathfrak{O},\varphi)}$${(\mathfrak{B},\mathfrak{A},\mathfrak{E},\xi)}$${(\widetilde{\mathfrak{B}},\widetilde{\mathfrak{A}},\widetilde{\mathfrak{E}},\widetilde{\varphi})}$$\scriptstyle{(A,\mathrm{id}_{\mathfrak{A}_{0}},\mathrm{id}_{\mathfrak{E}_{0}})}$$\scriptstyle{\Psi}$$\scriptstyle{\Xi}$

analogously to the Hamiltonian case. This gives us that the continuous machine
$(\widetilde{\mathfrak{B}},\widetilde{\mathfrak{A}},\widetilde{\mathfrak{E}},\widetilde{\varphi})$
is a port-controlled metriplectic system with time-varying metriplectic
interface. When we choose the matrix fields $A$ and $B$ so that additionally
the strong noninteraction condition $B(\cdot)^{\top}\nabla
S(\cdot)=A(\cdot)^{\top}\nabla H(\cdot)\equiv 0$ is fulfilled, then we get the
following class of input-state-output systems.

######  Definition 4.2.

A port-metriplectic system is a control system

$\displaystyle\tfrac{\mathrm{d}}{\mathrm{d}t}x$ $\displaystyle=J(x)\nabla
H(x)+G(x)\nabla S(x)+B(x)u+A(x)\tau$ (4.4) $\displaystyle y$
$\displaystyle=B(x)^{\top}\nabla H(x)-A(x)^{\top}\nabla
S(x)-\widetilde{J}(x)u-\widetilde{G}(x)\tau$

where $J,R\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{n\times n})$ with
$J(\cdot)^{\top}=-J(\cdot)$ and $G(\cdot)^{\top}=G(\cdot)$,
$A,B\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{n\times m})$,
$\widetilde{J},\widetilde{G}\in\mathcal{C}(\mathbb{R}^{n},\mathbb{R}^{m\times
m})$ with $\widetilde{J}(\cdot)=-\widetilde{J}(\cdot)^{\top}$ and

$\displaystyle\begin{bmatrix}G(\cdot)&A(\cdot)\\\
A(\cdot)^{\top}&\widetilde{G}(\cdot)\end{bmatrix}\geq 0,$

and $S,H\in\mathcal{C}^{1}(\mathbb{R}^{n},\mathbb{R})$ and
$u,\tau\in\mathcal{C}(\mathbb{R},\mathbb{R}^{m})$ so that

$\displaystyle J\partial S=G\partial H=B\tau=Au\equiv 0$

and

$\displaystyle B(\cdot)^{\top}\nabla S(\cdot)=A(\cdot)^{\top}\nabla
H(\cdot)=\widetilde{J}(\cdot)\tau=\widetilde{G}(\cdot)u\equiv 0.$

##  5 Conclusion

A general approach of assigning port-control structures to a general
behavioural dynamical system was presented. The versatility of this approach
has been demonstrated with examples.

## References

  * [JvdS14] Dimitri Jeltsema and Arjan van der Schaft.  Port-Hamiltonian systems theory: An introductory overview.  In Foundations and Trends in Systems and Control, volume 1, pages 173–378. now Publishers Inc., 2014.
  * [JZ12] Birgit Jacob and Hans Zwart.  Linear Port-Hamiltonian Systems on Infinite-dimensional Spaces.  Operator Theory: Advances and Applications. Birkhäuser, Basel, 2012.
  * [KS06] Masaki Kashiwara and Pierre Shapira.  Categories and Sheaves.  Grundlehren der mathematischen Wissenschaften. Springer-Verlag, Berlin, Heidelberg, 2006.
  * [Mor84] Philip J. Morrison.  Bracket formulation for irreversible classical fields.  Physics Letters A, 100(8):423–427, 1984.
  * [MU23] Volker Mehrmann and Benjamin Unger.  Control of port-hamiltonian differential-algebraic systems and applications.  Acta Numerica, 32:395–515, 2023.
  * [MvdS19] Bernhard Maschka and Arjan van der Schaft.  Port-thermodynamic systems and the assignement of their structure by feedback.  58th Conference on Decision and Control, pages 8067–8072, 2019\.
  * [PW97] Jan Willem Polderman and Jan C. Willems.  Introduction to Mathematical Systems Theory.  Springer Verlag, London, Heidelberg, New York, 1997.
  * [RLG22] H. Ramirez and Y. Le Gorrec.  An overview on irreversible port-hamiltonian systems.  Entropy, 24(10), 2022.
  * [RMS13] Hector Ramirez, Bernhard Maschke, and Daniel Sbarbaro.  Irreversible port-Hamiltonian systems: A general formulation of irreversible processes with application to the cstr.  Chemical Engineering Science, 89:223–234, 2013.
  * [SSV20] Patrick Schultz, David I. Spivak, and Christina Vasilakopoulou.  Dynamical Systems and Sheaves.  Applied Categorical Structures, 28:1–57, 2020.