$$ \dot{S} = -\frac{\beta SI}{N}\\ \dot{I} = \frac{\beta SI}{N} - \gamma I\\ \dot{R} = \gamma I\\ S + I + R = N $$

We know, that $N$, the total population is a constant. Thus, we can take our Hamiltonian function to be $H=S+I+R=N$

Is this the right way??

Hamiltonian structure of compartmental epidemiological models

Hamiltonian structure of compartmental epidemiological models

Exact closed-form solution of a modified SIR model

Suppose our state $x_t=(S,I,R)$ and we want to achieve the desired state $x^* = (S^,I^,R^)$, then if we consider Bregman divergence over $H$ as the current loss between $(x_t,x^)$ then

$$ c_t(x_t,x^) = \Delta_H (x_t,x^) = H(x_t) - H(x^) - \nabla H(x^)^T(x_t-x^)\\ H(x_t) = H(x^) = N\\ \nabla H(x^*) = \begin{bmatrix} 1\\ 1\\ 1 \end{bmatrix} $$

Thus,

$$ c_t(x_t,x^) = -(x_t-x^) $$

The loss essentially boils down to the negative of $L_1$ norm.

However, there is one more $H$ that is conserved,

$$ H = -R -\frac{\gamma}{\beta}\log(S) $$