20220619

 

[begin transmission]

It's been five years since I've played NieR: Automata.
In those long five years much has happened.

I've lost a romantic partner.
I've regained my then-failing eyesight.
I've graduated from graduate school.
I've lost a close friend and mentor.
I've helped establish and maintained an online community.
I've made several new friends and helped many people.
I've lost dear friends and have harmed many people.
I've quit my job and ventured out to start a new one.
I've found a new love.
I've started my formal education again.
I've grown to accept aspects of myself.
I've purchased another home.
I've come to abhor aspects of myself.
I've lost touch w/ my online community.

While all of those of things happened, while all of those years passed, not a day has gone by that I haven't thought of that game. Truly, it holds a special and reverent place in my heart, for it's themes continue and will continue to grip me for the foreseeable future. I will never stop thinking about those red-haired twins and the concept of original sin. I will never stop thinking about an amusement park filled w/ machine lifeforms and Nietzsche's last man. I will never stop thinking about the eternal Hegelian nature that underlines the android-machine conflict. I will never stop thinking about the clash of telos versus authenticity that exists within 2B or the psychoanalytic nightmare that is 9S. These themes and ideas will always be relevant to me for all of time.

And, at this very moment, another important theme comes to mind. One that eluded me for so long until now. Namely, the theme of identity and self. "Okay, but Automata, like any work that deals w/ existentialism, is littered w/ themes of identity and self. What one do you mean in specific?". The idea that I'm referring to is the one that concerns memory and the formation of the self. Admittedly it's a common theme within sci-fi that has been done to death w/ various degrees of profundity, but it is in NieR: Automata that I found it to be somewhat lacking, even though I frustratingly felt that there was something more to it. It is only until now, w/ the aid of some timely information coming from my leisure reading, that a coherent synthesis of a new understanding has been formed on the matter.

As you may recall, the idea first presents itself not terribly far into the game. At the climax of the prologue 2B and 9S on the eve of defeat, activate a black box reaction, effectively destroying themselves and their Goliath-class adversaries in the process. There is so much emotional and sentimental build-up leading up to this moment that it seems out-of-place. I mean, death should be inconsequential to these androids, since their consciousness could readily be transferred to new bodies. Besides, didn't these two just meet moments before? Why do they care so much that the other dies? All of the dramatics only makes sense in the retrospect, after one has completed Route C/D and perhaps also after I outline my case. Anyway, soon thereafter 2B awakens in the Bunker and rendezvous w/ 9S, who has no recollection of the events that transpired in the prologue since there was not enough bandwidth for him to backup both his and 2B's memory to the Bunker. The cutscene that punctuates 2B and 9S's reunion admits 9S issuing a YoRHa salute w/ its accompanying maxim "Glory to Mankind.", w/ 2B responding in kind; the camera then cutting to her clenching fist as 9S wanders off blissfully unaware. What is the significance of this moment? Several interpretations exist, but one of them suggests that 2B is upset and angered by the fact that 9S does not remember the events of the mission that had happened mere hours prior. She is upset that 9S has lost his memories.

A second instance in which this theme manifests itself so readily and apparently is at the conclusion of Routes A and B. After Eve is slain, it is revealed that 9S became corrupted when he hacked into him during the battle; that's no good, as corrupted androids will begin to degrade until they're rendered inoperable or attack allies until they are completely and utterly destroyed. Resigning to his fate, 9S attempts to comfort a despairing 2B w/ a potential solution: "It's okay. I can always reload my backup data from the Bunker.", to which she replies "But you'll lose you. The you that exists at this very moment.". That's a bit cryptic, since the implications (memories as identity) are clear, but it isn't really elaborated on. Memories as identity...what does this even mean? Is this sentiment thrown into the dialogue to pay lip-service to that overdone sci-fi trope as an afterthought? Or is there more to the idea?

To get to the bottom of it all, we must (re)familiarize w/ the concept of Leibniz's Law. This law states, in short, that two things are identical if they share the same properties. So, for instance, if a person looks like your mother, speaks in the same manner as your mother, smells of the same perfume as your mother, occupies the same household as your mother, possesses the same employment as your mother, has you and your sibling as children just as your mother, that person is your mother. It seems like quite a trite little observation, doesn't it? It's so obvious that it hardly warrants being a distinct construct of philosophical thought. Well, let's make things more interesting then: let us apply Leibniz's Law to that of personal identity. If a person has your personal taste in music, has the same hair color, goes to the same school as you, occupies all the exact points of space as you, is comprised of all the same cells as you etc., then that person is you. However notice that all of these items are subject to change: your taste in music can change. Your hair color can change. The school you attend can change. You don't occupy all the exact points of space you did a moment ago. Every cell in your body is constantly dying and being replaced. So then, how can we say that you are really you? As you can see, if we apply Leibniz's Law to the realm of ontology, we get a conception of strict identity as well as something very reminiscent to a Ship of Theseus-type of situation arising. How is it that we can establish personal identity when the properties, both material and abstract, that ostensibly define us are ever-changing?

Enter psychological continuity. While Leibniz's Law establishes a strict criteria for identity, psychological continuity is far less exact, but is flexible enough to account for discontinuities. We can say that a person is themselves b/c they, for the most part, have the same personality, have the same style of thinking, have the same affinities, have the same memories etc. However, psychological continuity must be taken in conjunction w/ the aforementioned strict identity, since neither one is adequate in accounting for the self on its own. We only have access to psychological continuity in defining ourselves (remember, moment-by-moment it is not possible to strictly define you as your spatial/temporal position or even biology is constantly changing), but to other agents in the world you must be held accountable for yourself outside of your own head. This is where action and narrative take route.

While psychological continuity admits a sense of yourself to only yourself, it does no good in establishing towards others that you are your self, since they do not have access to that inner psychological phenomenon. Strict identity fails in conveying to others that you are your self since you cannot ever fulfill it's own strict criteria (the aforementioned spatial/temporal/biological problem). Thus, they only thing that is accessible to the outside world and other agents that inhabit it are your actions. These actions do not occur in isolation, but are part of a history that is comprised of several other actions. Now, it is tempting to say that one is able to abstract out and isolate any one action, for it is a single 'chainlink' in that history, but this is not true. An action undertaken by you only makes sense and only ever exists in the context of its history; conversely, that history only makes sense and only ever exists b/c of the actions that comprise it. You cannot have one w/o the other; there is a reciprocal kind of relationship where one defines the other.

"...where are you going w/ this 2B? I thought we were talking about Automata.". I am getting there, worry not, dear reader. There is one more point to address. Just as there exists a reciprocal relationship between action and history, there exists a similar reciprocal relationship between a person and their history. A person is not merely a single individual that can be abstracted from a history; they are the subject of a particular history that is unique to them. A person removed from the context of their history is a concept that is unintelligible, for there is always a person who have uniquely created a history for their own reasons. Similarly, a history cannot exist w/o some person creating it. This is why, several months ago, I grew frustrated in conversation with a particular someone when they asserted that they did not view themselves as the protagonist of their own life. Such an assertion is entirely nonsensical when considering the framework I have currently laid out. These three intimately related things--action, history, and personhood--form a unity: a narrative. This accounts for my original thesis mentioned in Post #20220507, that Being is necessarily dramatic in nature. Our lives follow a story-like structure, both phenomenologically and psychologically. 

If this framework is acceptable thus far, then it shouldn't be too absurd of a proposition to posit that any individual's narrative, complete w/ their own personhood, actions, and histories, are interlocked w/ those of others. Everyday, our persons encounter other persons and our histories intersect at individual actions, reciprocally adding yet another chainlink that carries w/ it some amount of significance. The people who you encounter and interact w/ then become characters within your life's narrative. Much as how actions cannot be abstracted from a history into isolation without losing intelligibility, the characters encountered only make sense when considering the context of your life; they are not merely a collection of persons encountered, but carry some significance. This being the case, then it becomes clear how a person's narrative, mediated via interpersonal interactions, can be shaped, formed, or even augmented by others. Going back to Automata, the latter is exemplified in the relationship between 2B and 9S. Yes, yes, in the case of 9S 2B lends meaning to his life, since she is the 'why' that gives him strength to bear any 'how'. It's all very romantic and something I find myself longing for on a disturbingly regular basis...though, that is a digression. That tangent aside, there is a more chilling aspect to the pair's relationship if we examine it from 2B's side.

In the later chapters of the game, it is revealed that 2B's true designation is 2E: YoRHa No. 2 Type E. She is an Execution-type, w/ the sole purpose of her creation being to execute 9S whenever he would come too close to the truth behind Project YoRHa. All overtly-romantic connotation aside, 9S's life downright GIVES meaning to 2B's. If 9S is out of the picture, what are the implications for 2B's life? It becomes meaningless. This is the basis for my assertion that 2B's circumstances are the exemplification of existential horror: fulfillment of her purpose (her telos) sees to it that that very purpose is destroyed. For all of the despair that the game means to inspire through the story of A2 and the events of the Pearl Harbor Descent (that the entire operation and subsequent sacrifice of her entire squadron was merely an attempt to collect combat data) and 9S's discovery that the entire machine-android conflict was commandeered to provide evolutionary pressure for N2, none is as awful as that inspired by 2B. It is terrifying to encounter malevolence out in the world, an external force that seeks to cause your ruin, but that is tacitly acknowledged and accepted to be part of the expected adversity that comes w/ life; it is downright horrific when it is unavoidable feature of your unique existence that you lead yourself to your own ruin--even moreso that you were expressly created JUST to end in ruin.

Now that we have established the intimacy and tethered nature of 2B and 9S's relationship, it becomes slightly clearer why 2B becomes upset at the 9S's loss of memories, or why she is seemingly so concerned at 9S's suggestion to reload his previously saved memories. To have 9S lose his memories is to lose 9S himself; there is no distinction between memories and identity, for we have established earlier that a life is a narrative that comprises integrally of personhood, actions, and history. That history, in turn, cannot be abstracted into singular actions w/o losing intelligibility. In other words, memories are not simply a recollection of events that have 'happened' to you. They are more than that, and they inform others of who you are as a person b/c of this loaded nature. If 9S were to lose his memory of, say, that time he was wandering around the shopping mall ruins and suggested buying 2B a t-shirt when the war was over, he doesn't just lose the recollection of that singular occurrence happening. He loses a part of his identity that informs others that he as a person cares enough about 2B to buy her a gift. Going further back conceptually, he loses a part of his identity that informs others that he is capable of caring, period. He loses a part of his identity that informs others that he considers other lives beyond his own as valuable. He loses a part of his identity that informs others that he thinks some things are worth valuing. This conceptual recursion can continue further, but I think you understand the point. The loss of even a single memory has further reaching consequences

Sure, you could retort that it is only one memory, that there are others that can indicate 9S is someone that cares enough about 2B to buy her a gift, is capable of caring, considers other lives valuable, etc. Plus at the very least 9S knows who he is b/c of that psychological continuity we defined earlier. But you must bear in mind that the backup data 9S was referring to was created a while back, so the amount of memories lost isn't exactly trivial. As for psychological continuity being adequate enough for at least providing the subject aspect of identity, that is no longer valid. In order to have psychological continuity, you have to be able to keep track of your psychological qualities such as personality, affinities, aversions, etc. across all of time. If 9S loses his memories, that introduces discontinuities into his subjective track of time, rendering that entire aspect of identity forfeit.

Either way you slice it, 9S losing his memories means losing 9S as a person. Perhaps what makes the situation even more desperate is the added fact that 2B's own narrative is contingent on 9S's narrative. On the modernist perspective, 2B loses meaning in life through loss of her authenticity--her self-prescribed desire to be romantically involved w/ 9S. On the other hand, on the heroic perspective, 2B loses meaning in life through loss of her telos--the purpose of her creation which is to kill 9S. Honestly...could you conceive of a more pitiable dilemma?

It's been five years since I've played NieR: Automata. In those long five years much has happened. So much of it has been difficult and awful, and much of it has been joyous and pleasant. All the same, these actions have become part of my history, and will go on to inform a narrative that will in turn form my identity both towards myself and others. In all honesty I wouldn't trade it for anything else if it were even possible. Make no mistake, that isn't to say I don't have any regrets or guilt. I do have my regrets--quite a few in fact--but there's little point in agonizing over them for long. Any agonizing that does occur, however, I consider well-deserved, earned, and fully accepted. Regret and guilt are indications of a life well-lived, where there was something substantial and important at stake, where a person was presented an opportunity to be courageous and do what they thought was right. Ultimately that person failed, by their very own determination, but I don't think anyone expected to make it out of this life always comfortable and agnostic of hardship. Not anyone who isn't absolutely idealistic or doing anything worthwhile, anyway. No, this narrative is uniquely mine; it ought to be a Sophoclean tragedy.

[end transmission]

20220515


 
Elapsed time: 00:02:13
Re-activation complete. A check of my body reveals various failures. Communication functions have been destroyed. I cannot contact my team or the bunker. I leave a draft of this message here as a log.


Elapsed time: 00:10:13
I verify the plan once more. Using my supposed destruction in this sortie as a guise, I sever all communication. I then pass beneath the abandoned factory and escape. Further analysis reveals that I took anti-air fire while in the flight unit, resulting in damage to my body. No matter—it can be repaired.


Elapsed time: 00:15:21
I'm cold. My sensory systems seem to be failing.


Elapsed time: 00:33:12
Noise has started to cloud my vision. Virus warnings appear frequently. It is unclear whether I am infected or if the system is in error.


Elapsed time: 00:33:21
Repairs are proceeding poorly, perhaps because I am flustered. Pursuers will come if I don't move soon. Was I wrong to attempt escape?


Elapsed time: 00:38:00
This can't continue. I can't stay here. I have to run... YoRHa squadron was wrong... I have to find somewhere safer... I'm scared. I'm so scared.


Elapsed time: 00:45:00
Painful. It hurts. Help. Why stop. Who am I? Wrong wrong wrong. I need to run...

It's just that...she was always such a hard ass, you know? To think she wanted to run away just... Ha ha!
And what a miserable way to die.
Serves her right for the way she used to heap abuse on me...
She always looked down on me because I wasn't a combat model, and now...

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