20220507



[begin transmission]


It's always a curious thing to have a track--long since forgotten--not just make itself known, but assert itself in your ~2,300 item everyday playlist. The type of track that might elicit an unreasonably strong emotional response--a deep, enduring longing for past memories, a haughty, boisterous shift into unassailable confidence, or a slow decay into the darkest, thickest of despairs through which absolutely no light can shine through. All accompanied by the wonderfully intense bodily symptoms of frisson: goose bumps, chills, endogenous opioid release. Experiences like these are THE reason why I fully subscribe to the idea that music is the closest earthly approximate to the transcendent. It is in these experiences that our attention is yanked away from everyday banalities and forced to contend w/ whatever thoughts and emotions the melody and rhythm enjoin. There couldn't be a stronger case against the thesis that you are your own master. The interplay between consciousness and that Platonic realm of Forms is so mysteriously opaque that to suggest you are the sole proprietor of your own ideas and thoughts becomes a patently naive proposition if contemplated seriously for more than a minute.

In similarly mysterious fashion, the track cited above opens w/ a delicate arpeggiated piano chord that continues w/ sparse, ethereal, high-register notes, all against a backdrop of low-howling ambient wind and just-beyond-comprehension whispers of a forbidden nature. Low-register violin notes cut through the abstractions, giving the listener something to ground themselves on, something that feels very hometown-ish and familiar, even if only vaguely. Signaling the conclusion of the introduction, that very same violin engages in a short, ascending melodic run that is perfectly punctuated by a heavy piano chord; that final diminished chord informs you that this track is going to be fairly somber in tone, and that one had better be prepared to deal w/ weighty subject matter.

(As an aside, there's this neat little piano part where the chords solidly establish the dreamy 6/8 time signature in an ascending pattern. But again, that last diminished chord makes it feel unresolved--like climbing to the top only to falter at the final step)

And is it ever weighty subject matter...the lyrics in question weigh heavily on me to this very day b/c of their supremely ontological nature. They occur early in the track, in the first verse:
どうして罪があるのだろう
Why is there sin?
どうして罰があるのだろう
Why is there punishment?

It isn't a simple meditation on the existence of evil, although it is certainly part of the broader theme. No, this is an outright lamentation of a fundamental fact of existence. Why is there sin? Why is there punishment? I've elaborated on these questions in an earlier post, Post #20190709. However, there is more to this theme than I had ever realized. It is only in the rejoinder, found later in the track in the final chorus, that this becomes apparent:

罪があるのは諦めているから
Sin exists because I'm giving up.
罰があるのは求めすぎるから
Punishment exists because I want things too much.
What does this mean? None of this makes sense. Is this some error in translation? What does sin have to do w/ giving up, or punishment from wanting things? Why invoke the personal when contemplating fundamental aspects of Being? Maybe I've forgotten my phenomenologist roots, but there is no such thing as the exclusion of the personal self from Being. Necessarily, when contemplating existence, you have to invoke a subjectivity; the concept of existence becomes unintelligible w/o it. This profound philosophical fact is implicit when considering morality; if you accept that there is indeed a moral dimension to reality--that it is metaphysical fact--and that there is no such thing as morality w/o personal agency, then at the very least part of reality, specifically the moral, is contingent on subjectivity.

This moral, phenomenological stance is best embodied by the tradition of virtue ethics, and it is within this tradition that these lyrics begin to take on their perfectly sublime and coherent form. In order to address the answers offered in the rejoinder, first let us address the questions of 'what is sin?' and 'what is punishment?'. Immediately this invokes thoughts of a religious nature; a turn-off to some readers, I'm sure. However, we needn't invoke religion to explain sin: the roots of the term 'sin' lie in Greek thought, w/ the concept of hamartia. Hamartia, according to Aristotle, means to commit error, to fall short of one's objective, to miss the mark. If this notion of sin is acceptable, then the follow-up question of 'what is punishment?' is easily answerable. If punishment is thought to be the consequence of sin--and I believe this to be a reasonable, common assertion--then in the virtue ethical framework that very same punishment is the consequence of committing an error.

Okay. So now we have established that sin and punishment are equivalent to error and consequence. The more secular of readers may find themselves to be on simultaneously comfortable/uncertain footing here, as we have safely moved away from invoking appeals to religion, but we're now conceptualizing sin in a novel manner (those well-read in Christian theology will chuckle quietly to themselves, I'm sure). Substituting our conception of sin as error into the rejoinder, we obtain something like 'Error exists because I'm giving up'. This is fairly coherent: if you give up on your objectives, you will fall short of achieving your objectives. Recontextualizing this statement to further reflect the virtue ethical framework we've adopted, we must specify what exactly this 'objective' is. The objective, the telos of human life, according to Aristotle, is to live a good life--a life of flourishing and happiness. In order to live a good life, one must practice virtue, the cardinal four being those of Prudence, Temperance, Fortitude, and Justice. To give up on this objective of living a good life means to effectively fail at exercising virtue.

Keeping this conceptualization in mind, the following lyrics re: punishment makes sense if taken in the reverse. Wanting things too much is an indication of intemperance--the outright failure to practice the virtue of Temperance. To be more exact, this 'I want things too much' is the very embodiment of pleonexia: wanting more than one's share. And so, to embody pleonexia is to fail to exercise virtue, resulting in reaping the appropriate consequence of that error. That consequence is, in turn, conceptually the same as punishment.

Why must something as neutral and mechanistic as consequence be described w/ such colorful and dramatic language as 'punishment'? I've wondered the same question myself from time-to-time, and the more I learn, the more I've come to the conclusion that life is not as neutral or sterile as I may have originally thought. Every thought, action, and judgment that we make includes a tinge of morality to it. Everything we do presupposes some belief about others, ourselves, and reality: a sociology, an ontology, and a metaphysics, respectively. Each of these items carry with them either implicitly or explicitly a set of values that we behave in accordance to, whether we are fully aware of them or not. With regards to thought, action, and judgment we've only gotten used to believing that these things are divorced of moral value b/c that is the default mode of modern thinking that pervades everywhere. That there is such thing as an 'objective' view that we can exercise. It is codified in Hume's Ought/Is distinction, and is taken for granted as the basis for nearly everything we do and everything that we think. Why is consequence so dramatically embellished w/ language such as punishment? It isn't. It is punishment that is so sterilized w/ language such as consequence; the Greek dramatists and storytellers that came before them were not writing for entertainment's sake much as we do now. No, they were offering a description of Being, and the nature of Being is that it is necessarily dramatic. That is a large reason why NieR: Re[in]carnation was so resonant w/ me, b/c it expresses this fact so clearly and explicitly. Why, even neuropsychological research points that we are wired to interpret reality as a narrative.

Perhaps that is why literature, music, and art is so attractive to us as modernists yet it remains so personally elusive to us as to why. They point to truths that we have a vague recollection of, but have long since forgotten the words to bring them into the foreground of coherent, conscious thought and speech. Nevertheless, we feel it so deeply and unmistakably whenever it inspires frisson, render us wistfully nostalgic for the past, or encourage us to puff out our chests and march boldly into an uncertain future.

Everyone messes up at some point, everyone sins, everyone commits error, everyone falls short of virtue, and so everyone feels it when they're not living up to that telos Aristotle likes to talk so much about. Everyone has a personal stake in ethical behavior, and ethical behavior is not an optional proposition if one is concerned w/ living a good life. I've been intimately reminded of that fact fairly recently. It's what lead to this meditation on lyrics in the first place. I've been subject of pleonexia, I've been covetous of more than what is rightfully mine. I've demanded far too much from others in the way of my critical and judgmental nature. I've claimed to know more about others than I rightfully should. In short, my punishment exists because I want things too much.

[end transmission]

20220403

 

[begin transmission]

I've been struggling so desperately w/ seeing sin in others and my own self-righteousness. I think I may have fallen into a trap that is all too easy to give into--especially considering that there is a paradoxical tendency for humanity to, on one hand, create and nurture things. This entails the correction of any flaws or wrongdoing that one encounters, in hopes of fostering the good. In the other hand, there is also a natural tendency to destroy and assert oneself in a domineering manner.

Towards my better nature, I am still deeply concerned for you. I don't approve of your behavior; I truly don't think any of it will serve you well. It discourages any compassion and good will I may feel towards you, since your behavior indicates to me that you're not willing to extend that same compassion and good will towards others. It is a very strong, almost physiological reaction that I cannot ignore. The reason why I get on your case about it is not b/c I know you're better than that--part of the point here is that you're not--but b/c this sort of attitude is the kind of thing that ensures you're going to run into all sorts of trouble later down the line. And even worse still, these are character flaws that color your soul. Your soul in specific is something that I care about.

Maybe that last part was a bit too overdramatic; surely it was. But really. Think about it. Who you are as a person is substantially informed by the manner that you think. If you have thoughts like this, that is you as a person. Not as a student or a citizen of your country, or any other social role, but it is intrinsically part of your identity. Every single time you exercise that thought and deem it as acceptable, the deeper it integrates into you. Wouldn't it make sense to work towards clearing up your thoughts and polishing up your character? In short, I worry about you.

Towards my lesser nature, I can admit that I let ego get the best of me and forgot that I am really no better off than you are. Here I am judging you and condemning you for your sins. I can very well judge you for it--I recognize sin when I see it, not least in part b/c I perpetuate it myself--but I cannot condemn you for it. To condemn you for that would be to be like the scribes and Pharisee of today's readings. So...for the sake of trying to be everything I purport to believe in, in the interest of pursuing the Good, I need to exercise my compassion and simply let these kinds of things go. You know where you've trespassed, and in the cases that you're not aware, I will call them out to you. I will not, however, henceforth hold it against you.

[end transmission]

20220313


 
[begin transmission]

"She knows what a shitty person I am and she still smiles at me."

[end transmission]

20220306



 [begin transmission 6/? ]

Right. What has been covered so far?
Optimal control problem (OCP) statements, check. Cost functions, check. Coupled first-order ODE dynamics, check.
There are other parts of an OCP to cover (initial conditions, endpoints, constraints) but those are easy to explain.
Let's get back more into the theory of optimal control. Now that we have our OCP, what the heck do we do w/ it?

This will be the last theory-heavy post, I promise! I'm planning on providing a concrete example in the next one.


From Russia with Love: Pontryagin's Principle

Recall that we have our OCP stated in its canonical form, given as follows:

\begin{equation} \textit{State:} \quad \textbf{x}:= [x_1, x_2, ... x_n] \quad \textbf{x} \in \mathbb{R}^n \tag{1}\end{equation}
\begin{equation} \textit{Control:} \quad \textbf{u}:= [u_1, u_2, ... u_m] \quad \textbf{u} \in \mathbb{R}^m \tag{2}\end{equation}
\begin{equation} \textit{Minimize:} \quad J[x(\cdot), u(\cdot), t_f] = E[x(t_f), t_f] + \int_{t_0}^{t_f} F[x(t), u(t), t] dt \tag{3}\end{equation}
\begin{equation} \textit{Subject to:} \quad \dot x = f(x(t), u(t), t) \tag{4}\end{equation}
\begin{equation} \  \qquad x(t_0) = x^0 \tag{5}\end{equation}
\begin{equation} \quad t_0 = t^0 \tag{6}\end{equation}
\begin{equation} \quad \qquad e(x_f, t_f) = 0 \tag{7}\end{equation}
\begin{equation} \quad \qquad \qquad \qquad \qquad \qquad h(x(t), u(t), t) = h(x(t), u(t), t) \tag{8}\end{equation}

Remember what this gibberish reads in plain English? Given a set of state and control variables that evolve according to a specified set of dynamics, find the control variable trajectories that minimize/maximize the objective function such that all of the declared conditions are met and none of the constraints are violated. Where do we go from here? We apply Pontryagin's Principle in order to determine the necessary conditions that a set of control variable trajectories must fulfill in order to achieve optimality. Pontryagin's Principle does NOT solve the OCP for us!

"Er, alright...what are those conditions? And conditions in reference to what, exactly?"
Great questions to ask, really. I ask you to suspend all doubts and follow me as I pull mathematical abstractions out of thin air. It'll make sense in the end, I hope. Like, seriously, if you can keep up w/ all of this, please let me know so that I can put you to work. There's great potential within you.

The process of applying Pontryagin's Principle is best remembered by the mnemonic HAMVET. Often times it is not the mnemonic itself that makes it memorable, but the stupid story that accompanies it. I will never forget how amused and self-pleased my professor was when he told the class that if we ever forget Pontryagin's Principle, to recall the tragic Prince of Denmark, Hamlet. As if engineers know how or even have the time to read classic literature...Anyway, the mnemonic:

-Form the Hamiltonian.
-Derive the Adjoint Equations.
-Maximize the Hamiltonian.
-Determine the Hamiltonian Value Condition.
-Determine the Hamiltonian Evolution Equation.
-Determine the Transversality Condition.

Just as if we were engineering a cake, I'll walk you through each step of this recipe.


Form the Hamiltonian

What is the Hamiltonian? For those of you w/ expertise in Newtonian physics, it might sound familiar and even look familiar, but it's just a tiny bit different. In short, the Hamiltonian is a mathematical construct used to relate the dynamics to the cost function. In order to do so, we need to introduce the concept of costates. You can think of costates as the evil twin of our states (as in the states of our system, such as x-position, y-position, x-velocity, y-velocity, temperature, voltage, etc.). The states of our system occupy a space (space in a mathematical, geometrical/topological sense) that is said to be the primal space, whereas the costates occupy the dual space. These costates are absolutely essential in forming the Hamiltonian. Thankfully, they're easy to formulate. Suppose we have the following state vector:

\begin{equation} \textbf{x}= [x, y, z, v_x, v_y, v_z] \tag{9}\end{equation}

Then our costates are simply:

\begin{equation} \mathbf{\lambda}= [\lambda_x, \lambda_y, \lambda_z, \lambda_{vx}, \lambda_{vy}, \lambda_{vz}] \tag{10}\end{equation}

Lambda is the conventional Greek letter of choice to denote costates; the subscript is my personal preference, as some like to simply number them. Anyway, the important thing to note here is that, for every state you have, you need a corresponding costate. Easy. Now that we have the costate vector down, please accept the following definition for the Hamiltonian:

\begin{equation} H(\mathbf{\lambda}, \mathbf{x}, \mathbf{u}, t) = F(\mathbf{x}, \mathbf{u}, t) + \mathbf{\lambda}^T f(\mathbf{x}, \mathbf{u}, t) \tag{11} \end{equation}

The Hamiltonian is a function of the costate vector, the state vector, the control vector, and time. In order to construct it, you just take the running cost (the F part of Equation 3) and add it to the product of the costate vector and your dynamical equations (Equation 4). The little 'T' next to the costate vector is a transpose; it's a vector operation that just means to flip its dimensions. It's only there so that the multiplication of the costate vector and the dynamical equations can be done. For those of you that are particularly math savvy out there, you'll recognize this as a Lagrangian expression--except that the multipliers are not constants, but rather functions of time. If you don't recognize this, don't worry; I'm just trying to make it clear that this is all simply an extension of calculus of variations.

Okay! Great. Now we have constructed our Hamiltonian on which everything else is contingent on. Let us continue.


Derive the Adjoint Equations

The adjoint equations simply describe how each of the costates behave over time. Nearing a truism at this point, these are represented as differential equations. They are obtained by taking the partial derivative of the negative of the Hamiltonian w/ respect to each state variable:

\begin{equation} \dot{\mathbf{\lambda}} = \frac{- \partial{H}}{\partial{\mathbf{x}}} \tag{12} \end{equation}


Maximize the Hamiltonian

Generally speaking, a necessary condition to find an extremal (maximum or minimum point) of a function is to check its derivative and see if it is equal to zero. The Hamiltonian is no different; though, instead of taking its time derivative, we look at its partial derivative w/ respect to our control input. Why? Remember, as bolded and underlined above, the entire point of an OCP is to find the control variable trajectories that minimize/maximize the cost function! Minimizing/maximizing the Hamiltonian is the way that we minimize/maximize the cost function by proxy. Here is the condition, mathematically formalized:

\begin{equation} \frac{\partial{H}}{\partial{\mathbf{u}}} = 0 \tag{13} \end{equation}


Determine the Hamiltonian Value Condition

Alright, at this point I must address endpoint constraints. In Post #20211121, I believe I referred to them as endpoint conditions; these terms are used interchangeably, apologies for the confusion. In any case, the gist of any endpoint constraint/condition is to tell you the final value a state of your system must achieve at the final time tf. So, let us suppose we have a state variable for y-velocity, denoted as vy. Suppose we want our y-velocity to be 200 at the final time. Seems like all we have to do is write out an equation that's something like vyf = 200. Close, but in the canonical form of the OCP, things must be formatted a bit strangely:

\begin{equation} v_{yf} - 200 = 0 \tag{14} \end{equation}

Simple algebraic manipulation reveals that this is an equivalent mathematical expression. This is not w/o purpose; it is required that they are presented in this strange form, so that we can use them in constructing yet another Lagrangian expression: the endpoint Lagrangian:

\begin{equation} \bar{E}(\mathbf{\nu}, \mathbf{x_f}, t_f) = E(\mathbf{x_f}, t_f) + \mathbf{\nu}^T e(\mathbf{x_f}, t_f) \tag{15} \end{equation}

Looks very similar to the Hamiltonian, doesn't it? Only, instead of the running cost, dynamical equations, and costates, we use our endpoint cost (it's E, remember?), endpoint constraints given by the problem, and some dummy variable (here designated as nu). Don't panic about the dummy variable; it's not important. It is only used as a place-holder to tell us that we're agnostic about the endpoint of a particular state variable. Anyway, the endpoint Lagrangian is used to formulate some other optimality conditions that are part of Pontryagin's Principle. One of those being the Hamiltonian Value Condition.

The Hamiltonian Value Condition does nothing more than denote the final value that the Hamiltonian will achieve if subjected to a candidate optimal control solution (in other words, it is another endpoint constraint, only applied to the Hamiltonian rather than a state variable). Its mathematical definition is as follows:

\begin{equation} H[@t_f] = \frac{-\partial{\bar{E}}}{\partial{t_f}} \tag{16} \end{equation}


Determine the Hamiltonian Evolution Condition

Okay...this particular condition may seem a bit tautological, but hear me out. The Hamiltonian Evolution Condition is defined as:

\begin{equation} \frac{d\cal{H}}{dt} = \frac{\partial{H}}{\partial{t}} \tag{17} \end{equation}

The H you see here is our friend the Hamiltonian, the one that we formed. It's important to note that H is linear; according to the definition in Equation X, it is simply the dot product of our dynamical equations and our costate vector. The fancy, curly H is the minimized/maximized (optimized) Hamiltonian; it is the Hamiltonian achieved if one were to take the found, optimal control solution and plug it into H. If one were to do that, they'd quickly come to see that our Hamiltonian becomes non-linear. All that this condition is saying is that the Hamiltonian that we constructed should evolve across time (behave) just like the optimized Hamiltonian.


Determine the Transversality Conditions

Remember the endpoint Lagrangian we defined in Determining the Hamiltonian Value Condition? We invoke it once again in order to derive the Transversality Conditions. What these conditions reveal to us is the final value our costates must assume if our system is subjected to an optimal control. The conditions are defined as follows:

\begin{equation} \mathbf{\lambda}(t_f) = \frac{\partial{\bar{E}}}{\partial{\mathbf{x_f}}} \tag{18} \end{equation}

Once again, since we invoke the Endpoint Lagrangian (barred E from Equation 15), we involve that dummy variable nu. Do not fret over the inclusion of our dummy variable. They are simply a place holder to denote that we are agnostic about a particular endpoint condition--in this instance, an endpoint of one or more of our costates.

...now, are Karush-Kuhn-Tucker conditions worth addressing here? These are certainly part of Pontryagin's Principle, but they might be a bit too nitty-gritty for our current elaboration. I think we can safely gloss over them.


To Be Continued...

Now that we have successfully applied Pontryagin's Principle to obtain the necessary conditions for optimality, what do we do now? What are we left w/? Paradoxically, the application of Pontryagin's Principle takes our original 'simple' OCP and transforms it into what's known as a DAE BVP. That is, a Differential-Algebraic Equation Boundary Value Problem. These types of problems are notorious for turning what should be ostensibly straight forward problems and making them mathematically complicated.

"...what the f*ck? What was the whole point of this exercise then?". I know dear reader, I know. I share in your frustration. It's all testament to just how dizzyingly complex the natural world is. Often times phenomena that appear straight forward on the first take are, in reality, intricate little dances when you get down to the details of the matter. Fortunately, we're not left high and dry on our mission; there are several well-known methods within the realms of mathematical optimization that allow us to solve DAN BVPs--the most commonly used are what's known as shooting methods and collocation methods. These methods are not something you can enlist w/ mere pen-and-paper. These are methods that demand some serious, heavy-duty number crunching and thus can only be implemented in silico. Now, if you fully understand the mathematics behind these methods, there's absolutely nothing to stop you from coding up your own algorithms to solve these problems; however, it isn't quite necessary to do that. Tons of scientific computing languages and accompanying software packages have powerful optimizers--some of my favorites are NLopt, Acados, and GPOPS, w/ the latter two being specialized to handle OCPs. Each have their strengths and weaknesses when it comes to solving optimization problems, as they each enlist different mathematics to solve them.

Will we go into depth when it comes to these mathematics. God no. There is simply too much to cover there and we risk straying way too far off-topic. Plus, I will freely admit that when it comes to the mathematics behind these solvers, I'm approaching the limit of my knowledge--it's such a expansive, sprawling field and I am currently wandering deeply into myself (if anyone wants to talk about pseudospectral optimal control techniques w/ me, please message me!).

[end transmission 6/? ]

20220228

 


20220212

 The end of law is not to abolish or restrain, but to preserve and enlarge freedom.
John Locke. Second Treatise of Government. 1690.

20220205