Hi, everybody. Thank you to Paula for organizing this and giving me the opportunity to speak. And so this is the title of my topic that was given to me by Paula, how to use concourse CI to deliver Bosch releases. And so that's what I'll be talking about nominally. I say nominally because this is Bosch Day. This may be the one conference where people actually want to see tons of YAML. You're going to be disappointed. So I will try to substantially talk about Bosch and concourse, but I took some liberties to go a little bit meta to start with and then talk about why we arrived at some of the conclusions we've done on some of our teams around how we deliver Bosch releases and how we use concourse. A little bit about me. I'm a product manager at Pivotal. Some of the products I manage, CF release, etcd release, console release, and Bosch bootloader. Previously, I was an engineer working on Diego, ops manager in Bosch. So what are we going to talk about? Why software in the first place? Going real meta on you. Complexity versus simplicity. Testable, discoverable contracts. Complexity in the Bosch ecosystem. And then some of the recommended practices around Bosch and concourse that we've arrived at. All right, so what are some reasons. I won't claim to be comprehensive here, but what are some reasons why we do things with machines in the first place? One obvious reason, automate physical labor. Using machines, we can do things faster, more consistently, at higher scales, and more reproducibly. The things we just can't do physically, or if you get a human to do them enough times, there's going to be a lot of defects. People throw out their backs. You can only build skyscrapers so high before you start to need some sort of machine. We can also use, especially, software to automate cognitive labor. I like this term that Martin Ford used in his CF keynote, cognitive labor. I think it describes a lot of what we're trying to solve for when we build software. You guys can probably recognize that this is an XKCD comic. And we try to solve for the same sorts of problems, speed, consistency, scale, and reproducibility. The crux is complex cognitive tasks are hard to do well. Let me dive into what I mean by some of those terms. Complex, meaning many pieces, unclear interactions, and requiring implicit knowledge. Cognitive tasks, such as doing taxes, deploying software, CF push. When my mom and dad ask me what I do, I say I build software for people who build software. Because we have the same problems as the people whom we're building software for. Provisioning servers is hard, and getting it right, doing it the same way every time is hard. One of my favorite stories is the story of night capital. If you don't know it, just Google it. It's a great story in human error and things that could have been automated when provisioning servers makes you lose $400 million in half an hour. But if you think about provisioning a web server for your app and scaling it up, it's all these many pieces, unclear interactions, requiring implicit knowledge. How do you teach the next person on your team to do this? All kind of are the reasons why we love CF push and Bosch deploy. And they're hard to do well, right? Just like what I had previously. Doing it fast, consistently, at scale, reproducibly. There are many more reasons than this about why we build software. There are complexity, solving for complexity is just one of them. And there are many different sources of complexity and many ways to deal with them. But one approach or one sort of rule of thumb to keep in mind when building anything is having testable, discoverable contracts. So instead of having, you know, when you have to do your taxes, there's just all these forms and nobody knows how to do taxes, let's be real. What's nice about something like TurboTax is it provides you a very clear interaction.  So it provides interactions that let you do what you're trying to do and nothing else. It asks the consumer for input required for those interactions and nothing more, right? It's very clear, like just fill out this line and this line, all those other blank spots in these forms, you don't have to fill them out. Are you missing something? It'll tell you exactly what you're missing and where you can get that thing. And provide the output that the solution is supposed to provide and nothing else. Don't confuse people with other noise. And I say people, but I use the term consumers here because I'll get to it in a second. So everything you see up here, these first three bullets, this is a contract. This is the interaction I'm gonna provide. These are the inputs you need to give me and this is the output and the side effects I'm gonna create for you. So this is a way, what's key is the and no more, right? Make it clean and simple. But one risk about doing this kind of thing is maybe you've just shoved the complexity somewhere else, right? Maybe you've simplified one thing by making just something else more complex. The example I have here is, we all know and love concourse. And concourse is a side project. Originally it was a Alex Sriracha side project. But we're probably all familiar with some other Alex Sriracha side projects, which solved some problems and made something simpler. But I think a lot of people have had to fight with the additional complexity it's created in just another place. So making these contracts testable and discoverable and making it clear to people to understand how you're supposed to use something and how it might work is key to not just shoving the complexity somewhere else and creating just a different problem. And so on the previous slide, I used the term consumers to try to keep it general because this problem crops up not just in a user-facing product, products and services, but also between the services that we care about are services that are deployed as distributed systems, right? This is Bosch Day. But between the system components themselves, you wanna keep those contracts clean and simple. And going down a level between the processes running on a particular component in your system and even further down, down to your modules, objects and functions, right? So just down to the level of your code. And this has quite direct parallels to the stuff we build in the Bosch ecosystem. So going back a slide, user-facing products and services, that's your Bosch deployment. The distributed system components, those are your Bosch instance groups. Bosch releases and jobs, those are your processes and the business logic source code, right? Your release slash source, that's your source code. And so these design concerns happen at every layer, right?  One thing I wanna highlight here is I made it a point to separate Bosch deployments and Bosch releases as separate concerns. And that's gonna be a theme I come back to a little later. So in addition to these four things here, also that the test pipelines themselves can potentially suffer from complexity, right? If you're trying to deliver something, you're delivering it using concourse with your own test pipelines and those things themselves can get quite complex. If you have to ramp up a new team member and they can't make heads or tails of how anything gets built in your system, that can be a big problem. And concourse goes a long way to solving that, excuse me, right? With older systems, Jenkins and GoCD, where really the MO for interacting with them was clicking around in a GUI, after you've clicked around, that information is lost and you can try to export the XML and check it in somewhere, but it's not, that's kind of an afterthought. Whereas with concourse, there's only one way to do it and it's declaratively in your pipeline config. Still, those things can get complex and there can still be hidden assumptions and unknown moving parts and unseen dependencies and that sort of thing. So I'm gonna talk about some of the recommended practices that we've come up on for dealing with these sorts of things. So one is no snowflake environments.    And that's, I'm kind of speaking about how we've done things on Cloud Foundry historically, right? Our initial environments for integrating Cloud Foundry, one of the main environments is called A1. That thing was set up years ago before Cloud Formation was really a thing and it was all done by clicking around. Now nobody wants to touch that thing. Nobody knows how it got there. Nobody knows what's in it. Nobody knows whether you can remove stuff from it. So it's a snowflake and it leads to lots of fear in the development process. So one of the recommended practices is to not snowflake any environment that you use in your CI. Rather, what I'd recommend is to automate the provisioning of your environments in your CI and actually have CI run that build continuously. Prove that you can idempotently recreate your environment at any time, right? Anytime, anything goes wrong. You know, worst case scenario, blow it away and recreate it from scratch. Click a button and bring it back. And separate your per environment config resources. So let me show you one of our pipelines. So this is our mega CI. I won't get into the history of the name mega CI, but the infrastructure team that works on console and its ED release, the environment that that team's concourse itself is deployed to, is deployed by this job and I'm not gonna click it right now, but in theory, I could click it and it should just know up, right? It should just see that none of the AWS resources have changed so it won't touch anything there. Nothing has changed in the Bosch configuration that we're using to deploy that concourse so it should just end after a few seconds of know hopping. So being able to reproducibly create your environments having no snowflakes was one of the points I mentioned and the other one was separating out your environment config. So we've come upon a pattern that we like quite a bit which is to have separate repos for every environment. So if you're by environment, I sort of mean, if you think about AWS, it's a VPC with whatever subnets and load balancers and stuff that you need, right? So if you, for example, if you're testing a release or deployment and you wanna test it on AWS and vSphere and OpenStack, then you might have an OpenStack environment and a vSphere environment and an AWS environment and your concourse itself may live in a separate environment because you wanna have a different life cycle for the things you're actually testing and deploying from to concourse itself. So what we've done is we've separated out any private credentials, SSH keys, just configuration parameters that are specific to an environment. We've extracted that into its own resource so that if a credential gets leaked, if we ever need to rotate, repave, and repair this environment, it's totally encapsulated in one thing and it's not gonna leak into anything else. We, as a team, can comfortably blow this away without affecting any other teams. So this is also, this came out of the history that we had on Cloud Foundry of having all our credentials and all our environments in one big repo. And a lot of these things have come from the fact that Cloud Foundry has just grown a lot over the last three, four years. A lot of these problems, complexity is a human problem. So a lot of things that we've had to solve is how do we scale this thing up to now a foundation with so many teams and so many contributing organizations and members wanting to iterate independently. It used to be easy to just have lots of stuff in one repo, but that doesn't scale anymore. So separating these things out is the pattern that we've come upon here. So a couple of the other recommended practices. Test your task scripts. So what we do in our concourse pipelines is, by the way, it's probably a bit late to say this, but I'm gonna assume everybody knows what a Bosch job is and a concourse task is, et cetera. If not, sorry. So you're gonna have your concourse pipelines, your pipeline has many jobs, your jobs will have many puts and gets and also some tasks. And your tasks are, you have a task, YAML, which sort of tells concourse the basic setup of your task, what Docker image should run on top of, what parameters does it need as input, what resources does it need as input, or rather what things on the file system. And then you have an actual task script itself, which, if it's simple, it should be bash, but if it's complicated, don't write it in bash. Whatever you do though, if you make it at all, if it's at all complex, test it. People usually don't think to test their test scripts, but you should. If anything is sufficiently complex, you should think of your test scripts as a tool that you're using. And if you're building a tool, you should test your tool because. I'll give you an example. An example? I don't know if I have an example offhand. So, I'll show you the pipeline actually. It has, let me, I'll get to it in a second. So test your task scripts and build your own task images. So one thing that we, another sort of one shared thing that we had for all the teams that sort of broke down once we started to scale up the teams quite a bit was, we had this one massive bloated Docker image called runtime CI, which had multiple versions of Ruby in it. It had a bash RC in it. It had, God knows what else in it. You don't need two versions of Ruby to get cloned and do some JQ or something like that, right? When you have no idea what your tasks actually depend on, that can put you in a scary place, right? So build your own task images. Don't rely on external dependencies for them. It's not that hard to build a task images for your bash tasks. Keep them clean and simple and build them in concourse, build them in CI. So let me show you this one. So this is our pipeline for our CI itself. So the things that CI itself needs, the tasks and the Docker images, this is the pipeline that actually builds those images and also tests its own tasks. So we have this mega CI unit tests job. And this will test, I guess we have tests for different sorts of manifest generation things. I haven't looked at this in a while. But any sort of code that we have that's sufficiently complex in our concourse tasks themselves, we've written Ginkgo tests for them. You can look at the repo to get more details. And then we have our Docker images. And we wrestled for a while on what's the right level of granularity for our Docker images. Should you have a different Docker image for every single job? Should you have one monolithic Docker image? Or something in between? And we landed on something that, I think, worked out really nicely, which is something in between. We have a really lightweight minimal Docker image, which just has bare bones, my curl and WGIT and Git and stuff like that. Then we have a Golang Docker image which builds on top of that because we do a lot of goes. So being able to build and test go things. Then we have a deployment Docker image. So this will, it's only here that we actually have some Ruby. So we have Ruby, the Bosch CLI, Bosch init, those sorts of things. And then because we test some stuff in Bosch light, we have a Vagrant Docker image. Otherwise, there's no reason to have Vagrant in all your Docker images. Okay, moving on with this. Manage Bosch jobs with real programs. So what I mean by that is your Bosch jobs. Questions? Yeah, so the VM itself? The VM itself, are you talking about when building the Docker image? When we use that? No, no, no. So we just use Vagrant with the AWS provider to bring up a Bosch light elsewhere. I was actually gonna mention something here. I've never used it myself so I didn't wanna write it as a recommended practice but I know Dmitri's been working on essentially a Bosch light Docker image. And so this would be, rather than you having an image with Vagrant in it where you use to spin up an AWS VM somewhere else using Vagrant so that you get Bosch light running in it and you can deploy to that, you get a Docker image that itself is running Bosch light and has the Bosch CLI in there. So we could, we might actually start to switch to that. If we wanna replicate our like, we can deploy this thing to Bosch light bills, we can just do that inside the Docker image. That'll be pretty sweet. I don't know if it's, he can't hear. I can see him, but we can ask him at some point whether it's legit or not. Yeah, you got a question for him, you can ask him. Bosch light as a Bosch deployment? Okay, instead of using Vagrant, do you have a Bosch light Bosch release? That's cool. Okay, that's cool. Many options in the Bosch ecosystem. Yeah, yeah. So, manage Bosch jobs with real programs. This is the story of CONFAB and console release that we learned the hard way. So most people have Bosch jobs. Just realized I wasn't anywhere near the mic the whole time. Most people have Bosch jobs. Is that better? Was I like inaudible the whole time? All right, okay. I don't wanna hear myself, actually. So most people have Bosch jobs. And in your Bosch jobs, you have your spec that defines all the properties you're gonna use. And then you tend to have two types of things in your templates. You tend to have executables, right? CTL scripts, CTL.sh.erb. If it ends with .sh.erb, it's not a real program. And then you probably have some yaml.erb. And if what you're building is sufficiently simple, you might be able to get away with using that erb to do a little bit of logic and dump that into your yaml or dump that into your bash. And then maybe your bash is simple enough that it's simple and it's not likely to cause you problems.  They have to be orchestrated quite gingerly, right?  Trying to get, I was waiting for the announcement. All right, thank you. Trying to get that right in bash.erb is a nightmare. So do yourself a favor and don't do that. There's no reason to do that. You can write programs in real languages like Go which you can test and compile them and use that program to orchestrate the start, whatever logic you need around actually starting up your underlying business logic process, right? So this is like, everybody has business logic. You have console as a binary or if you're writing Cloud Controller, you have the Cloud Controller app itself. And then you have this mysterious contract with Bosch, right? Where there's a monophile and you get some stuff thrown into your ERB context and you have some helpers. And rather than putting a logic in there where you're never gonna test it because you can't test it, just dump all the data into, dump the data that it gives you into a raw file and delegate to some program that you can unit test to actually take all that stuff, unmartial all that data and do all the ifs and else's that you need to do in a tested way. So manage them with real programs and like I just said, unit test and system test that logic. So when you build that program, the one we have for console, we call it CONFAB, unit test it and then system test it. So if you claim that you can scale up and scale down and continue to provide a service, you should have system test for that. I'm running short on time, yeah, all right. Keep releases small enough to be used with hand-editable example manifests and validate those manifests in CI. If your release is so big that it's hard to do that, think of that release as a deployment and think about delivering that deployment separately from delivering the releases, the smaller releases that should be composing that deployment. In the interest of time, there's a pipeline you can click on it in the slides and ask me more details later. I'm gonna move on to some of the other practices. Cut your final releases in CI. If you want to do acceptance on this before you cut the release or you need to get input from several of the members in the foundation before you cut a release, you probably want to do this process manually. If it's something that is small and can move fast like console release, D-release, just cut the final release at the end of your pipeline. No snowflake buckets. So creating a final release means uploading final release assets to a bucket. That bucket should show up as a snowflake. Have CI, I'd importantly create that bucket with the right IM users. Separate pipeline configs from params. This is a really nice pattern that we've come upon of having all our pipeline, all our pipeline yaml in public repositories with mustache templating that fly supports and all the private credentials in a separate location. You could either put them in vault or last pass or just in a private repo. This helps makes how your pipelines work totally discoverable even to the public, which is really nice. Strive to make all your jobs public. This is something we really try to strive for on the CF release pipelines. And so you can see we actually test that all our jobs are publicly viewable. Separate the process of creating the release from deploying it and testing it. If you're gonna be deploying your releases to multiple different environments to test that it works on different IISs or in different configurations, build it early so you're not wasting time building a release over and over again. Separate your deploy and test so that if the test fails you can just rerun the test if necessary rather than having to rerun the whole thing and leverage a lot of the Bosch specific concourse resources that are available to you. Bosch IO stem cells releases and deployments. Here are some resources so you can see our release repos. You can look at our pipelines and look at the pipeline configs and how we've laid them out. If you wanna get in touch with me, email is probably the best way. There's a Twitter handle. I'm pretty active on the mailing list so you can ask questions there if you think they're more general audience appropriate. I have a website and a few GitHub's that's my work GitHub. There's Slack too. Awesome, thank you very much. I think we have time for one question while I work out where the next speaker is. Oh, he's dashing to the front. Any one single question, anyone? It's in the console release. It's a separate package. The source of theirs. Is it useful to anyone else in the console universe or is it specifically? It's specifically to glue the contract between Bosch and running the actual console process. So it's not useful to anyone who's not in the Bosch console universe. It actually, it figures out all the, it renders all the config templates that console needs. It determines when to actually start console and what the parameters. And then it actually just exits and leaves the console process running. It writes the PID file when console's ready and then it itself exits and you get the PID file of the console process. Great, thank you very much. Thank you.


And if you recall the problems with the original Langevin equation were that it was inconsistent with stationarity of the output process and moreover the white noise assumption probably led to this inconsistency. We have to check this out and we also found that the power spectrum did not go to 0 fast enough and you ended up with the fact that physical quantities like mean square accelerations were infinite. So we also had some issues with causality which was rather subtle. We made this assumption that the velocity is not correlated to the noise at later times but what happens at equal times? We are not rather vague about this. So we need to fix all these problems and for that we imposed, we introduced this generalized Langevin equation and what I am going to show today is that it solves these problems. It is completely consistent. It is a consistent way of describing the velocity of a Brownian particle in terms of some memory of frequency dependent friction and it also provides correct consistent answers to this problem at stationarity with causality and so on and so forth. Let us see now systematically how this goes. So generalized Langevin equation and we looked at it in the case of a single velocity component of a Brownian particle. This equation said m v dot of t plus m times an integral from minus infinity to t dt prime some memory kernel t minus t prime v of t prime was equal to the noise on the right hand side whatever that was and right now I am just going to say it is a noise and that is it. We are not going to specify anything about it except to say it is a stationary noise. So some eta of t stationary noise with the average value equal to 0. That is it. That is the only assumption. We have to see in a consistent way what kind of statistics are tenable for this noise. Then if we took averages we computed the mobility of the particle. So we said that the average value of the velocity per unit applied force when I apply an external force this thing becomes plus f external of t. So this is the generalized Langevin equation and we said that the average velocity to first order in the external force in this case it is a linear equation so it is actually an exact relation. This quantity divided by f external for constant external force the limit in which t tends to infinity this quantity tends to what was called the mobility of the particle. The static mobility of the particle at 0 frequency. The dynamic mobility is the steady state response that you get when the force is sinusoidal with some fixed frequency some given frequency omega. So in that case we discovered that v tilde of omega average namely the Fourier component of the velocity at that frequency at which you are pushing the system divided by per unit force so this was f tilde of omega. That is the component of the external force corresponding to frequency omega. This quantity here was equal to the dynamic mobility and we had in our model we computed this quantity simply by taking Fourier transforms on both sides. There are some niceties about taking Fourier transforms of a random function I slurred over those niceties but one can make this rigorous the result is perfectly correct and this turns out to be 1 over m times if you recall gamma bar of omega minus i omega but this is the one sided Fourier transform of the memory kernel which is defined for non negative values of its argument. So that is the place to which we had got. Gamma bar of omega is equal to an integral from 0 to infinity dt into the i omega t gamma of t. The assumption is the memory kernel is such that dies down as t tends to infinity in such a way that this integral converges. If it does not then you have to take Laplace transforms and then analytically continue to minus i omega or something like that in the Laplace transform variable. So this is the place we had up to which we had come. Now the question is in linear response theory we know we have a formula for the mobility. We are applying a perturbation which essentially couples via the variable X and we are measuring the average velocity V. So in the formalism of linear response theory this quantity A is X and the quantity B is V, the velocity. So we should have compatibility with the formula which we get from linear response theory and the question is is that consistent with this model or not. So we need to make sure that the model correctly reproduces that expression, the general formula. Then we can assert that these two are consistent with each other. So I want to emphasize again that the general formula we have for the mobility from linear response theory is that mu of omega, so from linear response theory, mu of omega is just the same as chi of X V of omega and we are looking at a classical particle. So this quantity is equal to the Fourier transform, this is equal to integral 0 to infinity dt e to the i omega t phi X V of t. So it is a generalized susceptibility and the question is what is phi X V of t equal to and this is classical. If you recall it is equal to beta times the expectation value, the equilibrium expectation value of A dot with B, so this is X dot of 0 with V of t in equilibrium but of course this is V of 0. So linear response theory says on general grounds that this fellow had better be equal to 1 over k Boltzmann t integral from 0 to infinity dt e to the i omega t V of 0 V of t but V is supposed to be a stationary random variable in thermal equilibrium. So this would be some V of t0 V of t0 plus t, t0 is arbitrary completely because if V is a stationary random variable then this correlation function is a function only of the time difference of the two arguments and it is just a function of t. So this much the general linear response theory says independent of any Langevin model, okay, that is what we found in general in the classical case. Now the question is is the generalized Langevin equation compatible with this or not, can we derive this or not? So what we have to show is the expression you get for the mobility here in the generalized Langevin equation. So this is, this is equal to 1 over M gamma bar of omega minus i omega and the question is, is this equal to this quantity here in the same model? If it is then I assert that these two are compatible with each other, okay. So you see the logic in the generalized Langevin equation model we explicitly found the mobility which is computing the response straight away and we discovered by taking Fourier transforms or whatever, we discovered that it is equal to this. On the other hand general linear response theory says it should be equal to that. So we need to go back to the Langevin equation, compute this quantity and see if it is integral from 0 to infinity multiplied by this gives you this and if it does we are done. So let us see if this is true. Now the way to do this is as follows. First of all the B must turn out to be a stationary process and we must be able to show that quite rigorously and we will see that it consistently turns out to be 1, okay. So let us start since I am anticipating myself, since it will turn out that this V is a stationary process namely this correlator is only a function of t, let us start, let us take a shortcut, let us start with the Langevin equation at time t0 plus t, whatever be t0, okay. So I have m V dot of t0 plus t plus m integral from minus infinity to t0 plus t and let us break that up into 2 pieces for a reason which will become clear. Let us break it up into t0 t0 plus t dt prime gamma of t0 plus t minus t prime V of t prime equal to on the right hand side the noise at time t0 plus t because that is the instant at which I am writing my equation down minus the piece that I took away from here. So it is minus m integral minus infinity up to t0 dt prime gamma of t0 plus t minus t prime V of t prime, okay. So I have split the force in the the frictional force into 2 pieces, one depends on the velocity history after my initial time t0 whatever it is and the other is past history from way back when whenever and let us give this a name. So let us call this thing by definition some H, it is a kind of noise because this is a random variable, this is a random variable which is imposed from outside. So let us call it some H and what is it a function of? It has got to be a function of t0 as well as t separately. So since t0 plus t appears here and t0 appears here separately, let us write it out in that form, let me call it t0 plus t t0, it is a function of both and I define this H in this fashion here.  So in particular I want the correlator V of t0, V of t0 plus t equilibrium average to be independent of t0. So in particular if I take dot, if I take derivatives on both sides V of t0, V dot of t0 must be 0 at the same instant. So if I left multiply by V of t0 here, I get m V of t0, V dot of t0 plus t and let us left multiply on both sides and take full averages. There is no external force, so everything is in equilibrium and let us multiply this by e to the power i omega t and in this way integrate from 0 to infinity with respect to t. I have to do the same thing everywhere but the reason for my splitting it up till t0 is that if I set t equal to 0, this integral vanishes out here and then I am guaranteed that V of t0, V dot of t0 is actually 0 provided V of t0 is not correlated with this provided. So let us impose that, impose causality by the condition of t0 h of t0 plus t0 equilibrium equal to 0 for all t greater than 0. Impose it, I am going to impose it from outside. Nively you would have said V of t0 with eta of t0 plus t it should be 0, that is causality says the force at a later time cannot affect the velocity at an earlier time but that is not consistent, that is the important thing. It turns out it is not consistent and you will see why. On the other hand we do not know this condition is going to work but it has one merit. If I do that then straight away if I multiply by V of t0 here and set t equal to 0 then this integral vanishes, this becomes V of t0 with V dot of t0 and that is equal to 0, it constructs automatically. So stationarity is imposed, it is automatically satisfied provided I can get away with this condition. At the moment it is an artifact, we have to see what its consequences are. Is this clear? The reason why I am doing this? You could have split it anywhere, you could have from its minus infinity up to this point, you could have split the integral anywhere but I can only split it at one point in order to maintain the fact that I want this, I require by stationarity, it is required and this condition, this imposition is going to achieve that once I break the integral of t0, oh by the way I should say right from the beginning in this equation itself, t is positive, t is positive. So when I say t0 plus t I mean an instant later than t0 always, t greater than equal to 0, I can take the limit t going to 0 but from above always, yes, yes, yes, yes, we will see, we will see. So it looks like we, the noise and the velocity are mixed up in some complicated way, we will see, we will see what happens, we will see, it should not contain any memory, okay, we will see what happens as we go along but right now the motivation as to why I am doing this is very simple, I want that stationarity and that is achieved automatically if this integral runs from t0 to t0 plus t because if I set t equal to 0 this integral vanishes, okay. But it looks like I am paying a stiff price for it because I am going to impose this which as he rightly points out means that if I multiply, if I take this term, multiply by v of t0 and multiply by v of t0 here and take averages, these two are related to each other, we will see. So meanwhile let us see what happens here. If I take this average here, by construction this condition has been imposed, so left multiplying by v of t0 taking averages and integrating respect to t with this weight factor says this term plus m times integral from 0 to infinity dt integral t0 to t0 plus t dt prime gamma of t0 plus t minus t prime, this is a lot of algebra but it is worth looking at it carefully to see what happens. So you have v of t0, v of t prime, average equilibrium multiplied by e to the i omega t and that must be equal to 0 because by construction v of t0 multiplying by h of t0 plus t average is 0 by assumption. So this term plus that term must be equal to 0, okay. Well let us do this integral. By the way this equal to 0 means m is removed, it is gone and this plus that is 0. Now what does this give us? Well this is d over dt here because this dot I can take to act on t, it is derivative with respect to t and so I do integration by parts, right. The first term gives me v of t0, v of t0 plus t average equilibrium times e to the i omega t at t equal to 0 and t equal to infinity. That is the first term and then minus since it is integration by parts, the derivative with respect to t of this guy which is minus i omega times that, so minus i omega integral 0 to infinity dt e to the i omega t times v of t0, v of t0 plus t equilibrium. So that is this portion gone plus this double integral and I now need to simplify this double integral so let me erase the board here, let me do it up here. I will just retain this term, this integral, let me see what it does, okay. First step of course the obvious thing to do is to change variables from t prime to t prime minus t0, clearly that is a sensible thing to do because this thing here will then become 0, okay. So let us put t1 equal to t0, t1 is t prime minus t0, okay. There are several ways of doing this, t prime is, alright, let us see where it gets us. So this integral becomes integral 0 to infinity dt integral from where to where 0 and then t prime is t0 plus t, so it is t, 0 to t and then is the dt prime is dt1, more plus signs, gamma of what, t, t minus t1 that is this portion and then v of 0, v of t prime, t prime is t0 plus t, t prime is t1 plus t1, sorry, t0 plus t1 equilibrium, e to the i omega t that still remains as it is, that is the integral. I need to somehow get this integral e to the i omega t to act here somehow, right. So the thing to do is to interchange the orders of integration and what does this become if I interchange the order of integration, 0 to infinity t and for each value of t, t1 goes up to t, so if I interchange right now t1 is less than t, so t is greater than t1, so this will become integral 0 to infinity dt1 integral t1 to infinity dt, gamma of t minus t1, v of t0, v of t0 plus t1 equilibrium e to the i omega t. Now let us put t minus t1 equal to tau because that is the obvious thing to do, okay, right. So can we get rid of this? The first two terms gave us this, so we must keep this, let us keep the last part of it, just this integral is being simplified and let us put t minus equal to tau, so dt equal to dt for a fixed t1, so this is equal to integral 0 to infinity dt1 integral 0 to infinity again d tau, gamma of tau, so you see, finally you have ended up with the memory kernel and integral and then this remains as it is, v of t0, v of t0 plus t1 equilibrium and then e to the i omega, t is t1 plus tau. So there is an e to the i omega t1, e to the i omega tau, so let us bring the e to the i omega tau here and this integral was just e to the i omega t1, let me bring that there and then this completely factors, integral 0 to infinity d tau, e to the i omega tau, gamma of tau, totally factors out and what did we call this? We call this gamma bar of omega, the one sided Fourier transform of this, the weighted with e to the i omega tau, this integral was gamma bar of omega, so function of omega alone, right.  So it says this, so it says this times gamma bar of omega minus i omega of this integral, times this integral with a plus sign is equal to 0, but what is this integral? This term here, if you put in t equal to infinity, this becomes v of t0, v of infinity, that of course decorrelates your equilibrium, this t going to infinity, this becomes a product of averages and the average velocity is 0. So the upper limit is 0, this therefore goes away, minus whatever happens at the lower limit, that is equal to 0, right. At the lower limit, e to the i omega t is 1, as t is 0, this becomes v of t0 because t is 0, therefore you get a square, v squared of t0 in equilibrium and there was a minus sign. So I move it to the other side and this is equal to that. So this fellow divided by gamma bar of omega minus i omega is equal to this integral, but v squared in equilibrium is k t over m, that is the Maxwellian distribution. So this is k Boltzmann t over m, now let us retain the m here, I put 1 here and remove the k t to this side, 1 over k Boltzmann, but this is what we call mu of omega. So we have actually established directly from the Langevin equation that the mobility on the one hand is given by this, on the other hand it is the same equation says, it is also equal to this integral weighted, this correlation function weighted with e to the i omega t integrated from 0 to infinity, which is with the 1 over k t, which is exactly the linear response theory formula, okay. So the model is consistent with linear response theory, this is sometimes called the first fluctuation dissipation theory. It is different from the equation, capital gamma is 2 little gamma m k t that we got, that is the second fluctuation dissipation theorem, we will come back to that, we will come back to that. So this is just a, in that sense the formula for the generalized susceptibility in terms of the correlation function from which comes inside the response function is in fact the first fluctuation dissipation theorem. So this is one way of saying it is to say that chi A B of omega equal to integral 0 to infinity d t e to the i omega t phi A B but remember that phi A B in general was equal to beta times A dot of 0 semi colon B of tau of t in equilibrium. This is sometimes called the first, in a sense it is just a definition but it is more than that. It says the actual response function is given by this equilibrium expectation value and that is the consequence of all the dynamics that we went through both classically and quantum mechanically. Recall what this fellow was, it was just a product of these 2 operators, these 2 quantities in the classical case, in the quantum case it stood for integral 1 over beta d lambda etc etc. That is the exact formula but whatever it is it is some correlation function and this is completely consistent with that. So the assumption we made that V of t naught is correlated, uncorrelated with H of t naught plus t comma t naught that has led to stationarity being recovered, being maintained and the fact that the first fluctuation dissipation theorem which comes out of linear response theory is satisfied. What we need to do now is to go back and say alright we made this assumption about V and H, some correlator was equal to 0, what happens to that? What does that lead to? So let us see where it gets us and it will lead to a little bit of a surprise, not too surprising. It will turn out that it is no longer consistent to make A tau of t white noise, it will not be delta correlated noise at all but it has some finite correlation time and we will see what happens. So let us go back and examine the consequence of saying that V of t naught H of t naught plus t t naught equilibrium is equal to 0 implies that V of t naught A tau of t naught plus t equilibrium, this is the first term in this H and then there was a minus something so we are saying this equal to 0 so that is equal to m times an integral from minus infinity up to time t naught dt gamma of t naught plus t minus t prime V of t prime V of t naught equilibrium. So making this assumption is equivalent to saying this. Now what is the first thing we can do here? It is clear that you can immediately change variables here so that I get rid of this t naught here. So let us do that. Let us put t 1 equal to t naught minus t prime. So this implies that this quantity here is equal to m times integral so t prime equal to t naught minus t naught. So if t prime is t naught, t 1 is 0 and if t prime is minus infinity, t 1 is infinity and then there is a minus sign in the Jacobian. So this is 0 to infinity dt 1 gamma of t naught t minus t prime minus t naught what do we get? T naught plus t minus t prime so it is minus t naught plus t 1. So it is t plus t 1 gamma of t plus t 1. Correlation V of t prime but t prime is t naught minus t 1 V of t naught. We can simplify this a little bit because we know this is stationary. This process is stationary. We have explicitly checked it out now. So I can shift time arguments in this. What should I do? Add t 1 to both sides right. So this is equal to therefore V of t naught for whatever t naught you like, 8 of t naught plus t for positive values of t or non-negative we can take the limit as t goes to 0 from above equilibrium must be equal to m times an integral from 0 to infinity dt 1 gamma of t 1 plus t times correlation V of t naught V of t naught. We could choose t naught to be 0 it does not matter just as this is independent of t naught 2 stationary. So you can put t naught equal to 0 and then you get V of 0 V of t 1 that is the correlator gamma t 1 plus t integrated over t 1 must be equal to this. In particular in particular we can also it says for consistency it says for consistency you have no choice but to say that this V is indeed correlated with the noise via this formula. So this is true for all t greater than 0 and the coupling is happening because of the memory kernel here. So if you let t go to 0 from above so let t 0 from above then it says that V of t naught at any time 8 of t naught namely the velocity at any time the output process at any time multiplied by the input noise at the same time and you take the average value this quantity is not 0. But there is a correlation between the 2 which is precisely given by the integral of the memory kernel. So this is M times an integral from 0 to infinity d t 1 gamma of t 1 and then velocity here is V of t naught t naught plus t 1 so you could as well write it as V of 0 V of t 1 in equilibrium and you can in fact remove this integration variable call it t. It has to be so. So it says this random force is not all that random. You specify whatever random force you like stationary, stationary random force whatever you like then the only consistent way to describe the motion of this particle is to say that there is this correlation otherwise you violate the stationarity principle. So this at instance equal instance of time there is a correlation. So this maintains causality that is the whole point. This is the way causality is imposed in this model for consistency. Yes, exactly. So it is intricately linked. What is it you are doing? It is not any random force. It is the random force on this particle. So there is a characteristic of the particle that has come in and it is not surprising. It is not surprising at all for the following reason. Go back to the original Langevin equation. I have not yet come to the first second fluctuation dissipation theorem which I will in a second but it is not surprising because after all when you say m b dot so this was the original Langevin equation.  We wrote this as square root of gamma times eta of t but this was unit delta, unit correlation delta function as the correlation. Then one would think look this is completely arbitrarily specified. This is a property of the medium but the two are related. You know that is not independent of each other. You know gamma must be equal to 2 m gamma k Boltzmann t and we also discovered that even though you started by saying when we took averages that v was uncorrelated with eta at the same instant of time, after you computed things you discovered that was not really true. That v of t naught, eta of t naught was not 0 identically. But even this is the coupling between gamma and t naught. Exactly. So there is a coupling back here. So this is the consistency condition. There is a reaction on the medium. Yes, yes but that, that is because this one is also sitting here all the way up. So this is the only way in which you can have this consistency. It is a backward correlation because this t is increasing out here. No, no it looks counter intuitive but it is not. It is completely consistent. So this separation we had in our minds that this random force is, I said it very glibly that this random force is due to molecules that won't get affected by the motion of this particle and so on but it is affected. It is the random force on this particle and it has got to be self-consistently determined. You will see this more dramatically in a second. So there is a coupling. There is indeed a coupling but we are trying to make this coupling consistent with causality, stationarity and so on. So this is, this is a relation which says that the velocity and the force and so-called random force at the same instant of time are not uncorrelated with each other. The equal time correlation is some integral. This is a number by the way. It is a pure number because it has got no dependence on anything. It is a pure number and that is the value of this guy. In a sense it is measuring the strength of this but now let us see it in a more dramatic way. You could do the following now. You could say alright, let us start with, let us turn this around and start with, so let us keep that aside. So we note that there is a correlation between the V and A to keep that in mind and now let us turn this around and say what was the definition of this H of, H of t0 plus t, t0 was equal to A to of t0 plus t minus M and integral from minus infinity up to time t0 dt prime gamma of t0 plus t0 plus t minus t prime V of t prime, okay. That was my definition here. Now let us multiply this by H of t0 with t0. Just as I pre-multiplied by V of t0, I multiply with H of t0. When I found the velocity autocorrelation, I took V of t0 plus t or V dot from that matter from the Langevin equation pre-multiplied by V of t0 and took averages. Now I want to find the correlation of the noise with itself. So I have H of t0 plus t and H of t0 multiplied on this side. That is equal to this term here but out here for this term, this fellow here, I can substitute from the Langevin equation. I have done so for this quantity so it must be multiplied by H of t0 t0 on this side. But what is this fellow, this guy here? I go back to the Langevin equation and it is equal to M times V of t0 V dot plus M times an integral from t0 to what? t0. That portion went away. So it is M times V0 dot M times V of t0. I play the same trick as before. I take this, so I take averages like that over this whole thing, substituting this for that in here, multiply by e to the i omega t and integrate over t from 0 to infinity. But all the quantities on the right hand side, I do the same manipulations as before, integrate by parts, use this relation between V and Eta because that is going to be important, right? And simplify. This is a slightly messier calculation on the previous one. There are going to be terms proportional to M squared, etc. I have simplified the whole thing. Use the fact that we already know what mu of omega is. We know the integral over the velocity correlation is mu of omega, right? And that is 1 over gamma bar of omega minus i omega with an M. So use that and finally after simplification, after which I am going to leave to you, you get the following result. You get M times gamma bar of omega equal to 1 over k Boltzmann t, integral 0 to infinity dt h of t0 t0 e to the i omega t. That looks like a fluctuation. It looks like one of these theorems. It says the one-sided Fourier transform of some correlator is some, this time not the mobility but the memory kernel itself on this side. But you can say now look that is not quite, it is not simple enough because this still involves the velocity. It does not involve the noise Eta alone. This h is not a stationary noise. That is why you need both arguments here. But if you use the properties of this correlator which you derived from this equation, then one can show that this quantity is exactly equal to Eta of t0, Eta of t0 plus t. No, it is equal to it. It is equal, period. This portion is exactly equal to this. So you end up with this relation which says gamma bar of omega equal to 1 over mk Boltzmann t, integral 0 to infinity dt e to the i omega t, Eta of t0 Eta of t0 plus t. This is the second fluctuation theorem. Just for comparison, let us write the first one down. The first one was mu of omega equal to 1 over m, sorry, 1 over k t, integral 0 to infinity dt e to the i omega t, the output process, v of t0. So the dynamic mobility which measures the response of the system to an external force in linear response theory is this one sided Fourier transform of this correlator, the output process. On the other hand, this is specific to the Langevin model. This was general in linear response theory because in the Langevin model, we explicitly find a model for the velocity and solve the equation of motion, random equation. It says that the correlation of the force, stationary force is not arbitrary but it must be related to the friction kernel, the memory kernel in this fashion. This is the equivalent of the fluctuation dissipation theorem, the capital gamma, etc. Because how do you recover that? By saying that this memory kernel is just a delta function, then this gamma bar, this gamma of t minus t prime is just delta of t minus t prime times a constant gamma. This fellow would become gamma out here. This would be a delta function but half a delta function because you are integrating 0 to infinity.  But this is the general version of it. And what is the big lesson it is telling us? It is saying that nice in this generalized model, this eta here is stationary fine but it cannot be delta correlated because if it is delta correlated, there can be no omega dependence. And then this side is omega dependent. So it is not consistent. So this is immediately telling you that the moment you introduce a memory kernel, the noise cannot consistently be white noise. It has got to be colored noise. There is a correlation time. And what is that correlation time? You define the correlation time by putting omega equal to 0 here, right? And then dividing by the mean square value or whatever it is. So it gives you a quantity of dimensions time. And that in this case is just the memory kernel. So little gamma of t, little gamma of t dt from 0 to infinity is going to specify for your correlation time. Yes, yes, exactly. Yeah, it says in this generalized model you cannot independently, just as in the original model you cannot independently specify little gamma, the friction constant and the strength of the white noise. You cannot independently do it. In exactly the same way the more general statement is you cannot specify the memory kernel and the random forces correlation independently. They are related in this fashion. It is a consistency check on the model. And when that is satisfied, so you now in model building you do what you like. You tell me a random force which is stationary. I then say that it is consistent with the Langema equation with a specific memory kernel, not any old memory kernel. On the other hand in modeling empirically if you discover that this friction is modeled by a memory kernel which is maybe an exponential or some function of time decreasing function, that fixes for you the correlation of the noise. The manner in which this correlation behaves, it fixes for you through these relationships here. And that is what is more generally done. It depends on the model building that you have in mind. So you could say alright this thing here is exponentially correlated with some correlation time tau, single exponentially correlated. That is the first thing you do. It is a Markov process. We will assume it is Gaussian. We will assume it is stationary. And now you say it is not delta correlated but exponentially correlated, maybe an on-steen or unbacked process, maybe. Then it has a correlation which is exponential in time that fixes for you the memory kernel. It fixes gamma bar of omega and from which you can find what sort of gamma of t you should have had in order to have this. So that is an interesting exercise, simple exercise. Take this to be an exponentially correlated, e to the minus t over tau. Then figure out what is this guy going to be. And therefore what is gamma of t going to be? That would be the simplest model in this instance. So this kind of brings us to an end to this part of the program. We will, there are some loose ends to be tied up. I will mention them to the extent that I can remember. We will talk about them tomorrow and then go on from there.


Welcome to the network engineering video blog. I am your host Michael Crane. Okay, so in this video we're going to Be adding a link between Our routers, so if you remember in the previous video I Showed you how to add these routers are actually WPF controls in the code but we have a Routers, but the one thing we didn't have was we weren't able to create a link and In this video, we're going to do that. We're going to add our link in between Our routers and you would think that'd be pretty simple adding a link between this. It's just a matter of drawing a line between these two nodes right here these two routers, but If you think about it first you have to tell WPF Which two points you want to draw a line to the start and end point right and you also have to You know and that means finding the coordinates of the routers and and that sort of stuff Let's just go ahead and add a link. We'll take a look at it. All right, so we're going to add a link You're going to go from router zero to router one. All right, and there it is All right, don't think I didn't implement the editor delete yet. No Another thing so and that's that's fine and Danny looks pretty good, right? But another thing is is you want the link to be able to follow the route around If you move it Right, and I know it's not any kind of a real-time graphics animation, but but it's a star, right? And and especially if this got a bunch of links on it. You probably don't want to try updating all the links In real time that's probably be kind of CPU intensive, but I don't know. Well, we'll give it a shot later That'll be in a future video But anyway, so this is what we're going to do today is we're going to add our our router link Okay, okay, we're to start That's a good question So let's look at the go I'm gonna go ahead and fire up the GUI so we can look at it real quick okay, so In the past at previous video, we're able to draw these two routers and When we drew a link it just kind of popped up a line over here in the corner and now Now we can add a link between our two routers. So, you know what I had to do to create this is I created a class called link dot XAML and go take a look at that and Move him off to the side over here All right, and that this this File wasn't in this in the last video, so this is no there's nothing to dip it with in other words and and this is The way you create any other user controlled like I showed you in last video I did change the default layout from grid to canvas and I'm just drawing a line and And and that's it's a shapes object. You can see a system windows shapes line and I named it and I I Stroke it and gave it a thickness and and gave it coordinates. This is X1 Y1 is your left side coordinate if you will and X2 Y2 or your Right side coordinates. It doesn't have to be that way. It's just the way I have it set up And then I added a context menu. So when you right-click on The line like I showed earlier or on the link I should say You get the menu, right? And Yes, you have to be real good about pointing to right-click on that line We might have to fix that later, but that's in the future. So anyway, this is the the new file and And that for the link and I don't think I oh, yeah, I did add some code Some code behind whatever you want to call it some implementation code I Added a couple or four public properties It just basically says what type of link it is right now is just set to link It's got an index that I give it to keep track of it and it's got originating node and terminating node and I just call them node a and no b and this is just a standard Constructor right there and it's nothing special. Here's the Constructure where you just pat this is the one we're gonna use mainly. Yeah, you just say, you know new Line with our new link with A and B nodes, right? And you notice everything's generic. There's a reason the reason I'm doing that is, you know, what we don't want to make a link class for every Router and man switch there is in a network. We would be a mess So we need to make a base or a parent node object that has you know basic stuff And so anyway, I'm keeping everything generic And then it draws a link Okay, and then I put a little comment in here what it's doing is first is gonna get the location of each node It's actually in the router This this function right here is actually in the router class We'll get to that later.  Where is it? linkxml Yeah, I'm sorry the line coordinates on the canvas and he's gonna just update x1 x2 y1 and y2 with the The coordinates passed back to him from get location, right? and He's just gonna dump out the What he's done you can kind of see that right here Okay Okay, so since we're looking at file new files that we added. Let's let's go ahead and The other the other thing we had to add was this this link editor class and This is that menu that you saw when I was adding the link and Let's see we can look at the The code behind And this is just an oh by the way. Yeah, so this is this is not a control. This is actually a separate window okay, and This this actually I'd just scratch my head with this one for a while cuz I was like well Let's see, you know do you you come in here and you do you? You know, I'm kind of like so you do an ad and the new item and You want to do WPF and you know our goal is to do WPF all the time So you got you know, you have a window or page or use control or some of this other stuff And I was like well gosh, you know, I I just want a menu And I want to pop up dialogue Box right and you know, so there's no dialogue box in here, right? And I believe windows forms. Yeah, so so you used to have a dialogue box All right, and and that's not there anymore. So I was kind of scratching my head gone. Well so if we go over here to Windows forms and controls equivalent, right? Now I was like, okay, so what's the equivalent for a dialogue box and As you can see There's there's doesn't even list it. So that was kind of not very helpful So I I did some poking around and and I found That's right here. So this is in the windows presentation foundation application development and It's like basically how do you do a dialogue box in WPF so So you can you can read this all if I remember I'll put the link for this up and Under the video and the notes, but you can just Google dialogue boxes for WPF and probably you'll find this immediately. So anyway, I just followed this right here and and and I went People that do windows forms programming every day might Might be yelling at me. Well, this is pretty simple. I I didn't remember it It's been years since I've done any forms programming. But anyway, um The goal is with a dialogue box Let me start this As you probably know is Is you want it to basically? oops See, oh, that's actually a perfect example. You see how they It won't let me do anything until I finish adding This link and so it locks it up and and this way if I if I actually kill this program It will kill this dialogue box and and usually with a when you're creating a window This is a this is a root object It actually is a separate program. You can spawn a completely separate program that way if I killed the Mogwai You know canvas or main form this thing would still be running and and I didn't want that so so the key to Making the main program wait is you make the main program The owner let me see if I can find it down here in this example. It might be easier just to show you In the code. Yeah, here it is right here. So it says dialogue owner equals me so in the main window right here So this is add link. Okay, so you can see that I Constantiate a link editor object right from the link editor class and then I assign the link editor to basically the main window right and Then I just show the dialogue And then I wait for the the return value. All right, so Oh Gosh, I don't know should I go ahead and finish looking at we can looking at look at this real quick We'll come back to this All right, so we're we're at the link editor. So So we pull up this dialogue and and this is the XML for it. It is a window, right? but it is being pulled up from the main window as a dialogue box which Which gives it a dependency on the main window. So anyway, we can look at the this is the layout of it It's it's pretty simple. It just just a box. It has a couple list boxes it looks list box in it and Okay, and cancel button and the code behind for that is is that pretty simple it? it populates the The list items with the node names that's what you saw earlier when it said router 1 router 2 and I'll show you where this collection nodes is at here in a minute and The cancel doesn't really do anything. It just says a dialogue sets a dialogue result defaults. All right this okay It first it checks to see if it's valid. There's a function down here It verifies is that that you have selected two endpoints and here's the Message box that it pulls up saying you must collect two Endpoints and it's it and so it returns false or true and it says if it's not valid Then just return or if it's valid then it comes down and dumps this Debug message and says the dialogue result to true. Right. So the last file we added was this module globals and And this is a dumping ground for me to put Stuff that I want all classes to have access to and so I just call it a globals mod globals and you can't call it globals because There's already a class called globals and visual basic so I'll look at this guy real quick and There's just two things in them. It's both my collections. It's a collection for nodes and a collection for links And you can see this is generic and that's on purpose for in the future when we make a Apparent class for our Cisco routers and switches and stuff like that They'll basically be Categorized as a node So right Okay, that was very interesting. Let's see what else So, okay, so that's all the files that That we added all the new files Let's go look at the files. They change We'll just start from the top here. Cisco router node Window on the left here is the original Window on the right or that is the new new one or the changes And we'll just go down and look at them real quick. It's kind of like doing a code review if you've ever done Okay so you can see I Did a little reformatting of the use of the of this little bit to make it easier for me to read I did add this this mouse mouse up Subroutine and in the code behind and I also added this canvas left in canvas top and And I'll show you that here in a in a second Well, I might show it to you now because I think that's all the changes in the in the XAML file so yeah, so let's go look at the The code bind for it Okay, there's a boatload of changes in this one so we'll just Wow, I guess we'll just start from the top and work our way down so Here's the the old class that mouse location porn origin and translation point I have changed this and I'm no longer using translate transforms. I'll show you that here in a minute. I Did add a couple public properties in This class right here one is to tell it. It's a router and that's Also thinking ahead towards the future when So when I create a Cisco router node in the future, it's gonna pull up a generic node You know, it's gonna inherit The properties from the generic node So we'll have to know what type of node it is and it's gonna be a router Index is just to keep track of it on the canvas Well, these just got moved around a little bit. Here's mouse location and point origin I didn't think I added those they just got moved around a little bit And I also added this Boolean is moved and we'll look at why that's there In a minute. I did I just commented out This Transpoint is translate transform. I let that in there So and if people want to use that instead of the new way I did it they all they have to do is comment it out and comment The new stuff I put in here out Okay, hope that makes sense Now I added a initialization to point origin Yeah, it looks like I just removed this this copy constructor here because I don't know we can add it back later. I guess I guess if you wanted to you could probably work. Okay, I Mean it what is for is if you go like add router, right? You got this router you right click on it You can say copy right, and it just It could copy everything in here and make a duplicate of itself And I guess that might be okay if it initializes a whole bunch of other Other properties inside there in the future, but we'll add that back in the future if we need it I I just removed it for right now I Did add this new function that I showed you earlier this get location. I Basically just let's get let's get back to this. I'll show you this in a second Let's see. We'll keep going down Send command see Oh, I added a delete node Or I worked on the delete node. I I don't think it works Gosh, I actually don't remember. I don't think it does This Delete nope no, it doesn't work and the reason why is I'm gonna have to I Believe they call it bubble up an event to the main window to tell it to remove it from The main window and yeah, we'll go over this when we we do that that'll we'll have to Do it another video on on bubbling up events up and down the The tree I forget what it's called Okay, so I Commented out all this translate transform stuff. So if you remember in In the previous video. I told you it took me a long time to figure out how to do How to move this this router around right? I was or this note around drag it around and in different parts of the canvas the problem came when I was trying to do this this get Location thing and as you can see I started doing some code and and mucking around with it a little bit and And so this kind of sent me poking around and you know, I started to put this together and this would probably work You know, this is what I kind of figured out right I was like But I really didn't like it when I was doing this originally which got me to writing this this Translate transfer translate transform code in the first place was let me see if I can find it here is So you go to Router All right click on this guy. So you go to layout. Oh, okay, so it's already said so to see this top Left, okay, so it says gets or sets of a there represents a distance between left side of an element and left side of his parent canvas And I had actually looked at that Originally, but let's look at let's look at the link I don't think I've initialized that. Yeah, let's go look it. I don't know if this is gonna be the same or not Yeah, yeah, see here we go. So And I was originally looking at this it had it had these things set to auto and I'm like What does that mean? And so I assumed that it was automatically being updated from somewhere And and that's what sent me down the path of doing this these this translate Transform stuff. Yeah, so that's what sent me down the path of doing this this translate Transform and and I left all that original code in here because like I said it would probably it would work He could make it work, but I didn't like having to to get the middle of it You actually had to call this render transform operation create a point using the the XY coordinates and then then you had to go through and then You know calculate the middle and all this other fun stuff and it was just it just was ugly I didn't like it. I was like, yeah, this doesn't look right and as I was when I was trying to figure out how to get the the center of my node without using the width and height or the The the height in the in the left, which is basically the top left corner, which is 0 0 or xy I ran across Someone saying well, yeah, you just got to initialize the the top left to Whatever value you want and then that auto thing just goes away. I'm not sure what auto does I I've yet to figure that out. So yeah, so when I I put that in the xaml And I just initialize it to 1010 So I just kind of moves it off the corner of the canvas a little bit and then when I want to move I say You know canvas You know get the left left and top and calculate the middle point Let's go back into our diff here So yeah, so I just commented out all this translate transform stuff. It's basically the same if you look at it I just set the the top left to the difference of the mouse location minus the point origin Which is exactly what I did here and I also set this is move Boolean And we'll get to that here in a second and then yeah So this last part is a new sub routine It's called on the mouse up event and it we can you can just read this as if the node has been moved We need to redraw the links right and we're gonna have clean this up This I just threw this in there real quick, you know, it says if moved if is moved equals true basically And just redraws all the links in the collection of links. Which is not a problem if you only have One or two links, but you know you start getting a bunch of links and that could be You know I could take some time so this needs to be cleaned up But we'll make it more efficient in the future. So Last thing is a main window shouldn't be too many changes in here That's the only thing I changed as I added this comment And let's see. Are we done with our I Think that's that was only diff in there. So let's go look at the code behind Oh, I did add some code in here. Okay So when I do this canvas children add which is the same as right here in the old code It actually returns the index value on the canvas and it's unique so So I just used it as the The node index so I can keep track of it and also used it in the name of the router. I Just called it router underscore index number So I give the router a unique name and I don't know did we look at that property in the router node? I Don't remember Yeah, um, oh, no, that's right cuz name is actually a built-in Property for a control. So I'll just type it in here somewhere. So we do You see control oops you see Node dot Okay, so this is the user can you see stands for user control Then you come down here and who were Name name name name. Here we go name Yeah, so it's built into the ah, that's what I was looking for framework element And it's just identifying element for this user control, right? Well, let's see here Back to what we were doing So, yeah, so I'm just giving it a name I display the name of the router and the ad in the link editor this z-index right here is I should have kept that thing running So this z-index right here Let's see a next right here. That's um, when I first added this link right it was It was actually on top of the router and the reason why is because you have to provision the routers or add the routers before You you add the link right because otherwise it won't know where to draw the link to and if I move this So you can see now the router is on top of that that line that line actually is drawn all the way to the middle of the router here and That's that's a z-index. It's just it's just moving the router node to the top of the pile so to speak So that it's just going to put it on top of the the link which has a z-index of zero which is default All right, and then I add the router there are new router that we instantiated right here to the collection and And I am searching I searched through the if I need to get the router's name or find the router I just I use the name of the router right Okay, and that's a searchable key in the collection Debug statement and Yep added more debug stuff Okay, so there's a bunch of changes in the ad link. Yeah, so this is what I was saying earlier So originally I was just from the main window. I was just kind of drawing drawing this line real quick But you know, that's not really in the true model view controller Architecture anyway, so yeah, so to keep with the the spirit of the WPF and the MVC Model I took this out and I created the the the link class that I showed earlier Sorry, I removed this old code and added this and we can look at it real quick. It's just got a local variable index Here's our new link editor that I showed you earlier and I set the owner to the main window. I Did a show dialogue And it says if not dialogue editor dialogue result then return If it read if the dialogue result is false. So if we come from the link editor Let me where's the code behind here if you hit cancel you get the dialogue result is false or I Guess that's it Because it's not valid. It's gonna just return the user back to the dialogue So yeah, so if you hit cancel or if you x out actually x out is the same thing as cancel So anyway, if he gets Yeah, so what he's saying if if the dialogue result from the link editor is false Then then just skip all this other code because there's nothing to do, right? Okay, but if it returns true then he's gonna continue on he's gonna go get the a node the be low node from the selected items and the link editor gooey and Then he's and this is just getting the names, right and then he's going to go get the objects By the name so he's gonna go get both the nodes He's just gonna create a new link and pass in the and B node Which we looked at earlier in the link class, right? And he's gonna put that new link on the canvas store that index value And he's gonna give it a name Our link index property. I mean in the name, okay? And then he's gonna add the link to his collection and pass the name in as it's searchable key Well that My friends is it? I hope all this is making sense, and I'm not going too fast I know I kind of bounce all over But anyway, if you have any questions or comments, I'll leave them in the the comments under the video I'll try to answer them the best I can. I hope you liked this video If you do give it a big thumbs up that helps and hit the subscribe button. That really helps And I'll see you next time


So I'm just walking down to the law school now, which is in the heart of the legal precinct. Right behind me here is the High Court. Pretty exciting. So the things to think about when approaching the University of Auckland law degree is not only to think about a potential legal future for you or potentially what a challenge this degree might be to undertake, think about all of the great transferable skills that you'll acquire, which almost too many to list. So if the going gets tough and you're feeling a little bit overwhelmed, don't worry, we've all been there. What's most important is just remember why you're here. The first year of uni, and especially your first semester, is always going to be a little bit tough at times. I personally like to take some time away from all of my studies and all of the intense necessities of what's going on academically and just take a walk or go through the city, sit in a park or something like that, because there's so much greenery around and it can really help to refresh you in the middle of this hustling, bustling CBD. A couple more things to remember about your law degree, and especially part one, is that you shouldn't compare yourself to what everyone else seems to be doing. Don't worry about what grades other people are getting, and instead focus on how you yourself can do well. Yes, it's going to seem like there are 10,000 cases and you're going to be a little bit daunted by the whole thing, but just remember, it is daunting, but it's doable and you will pull through. Just keep your focus and remember why you're here.


Time for another recap. I am happy that we are now approaching the end of this course, and we have in this process learned quite a lot of new things. We started with some very basic concepts about Islamic banking and finance. We covered quite a number of important contracts being used in Islamic banking and finance in different parts of the world. And of course, we went into details of Islamic modes of financing and we attempted to distinguish between an Islamic contract and an Islamic mode of finance. And we said that an Islamic contract is a singular contract. While an Islamic mode of finance is a composite structure which may involve quite a number of Islamic contracts. Then we moved on to some Islamic banking and finance markets to see how these Islamic contracts and Islamic modes of financing are being implemented in different segments of Islamic banking and finance industry. So there has been a lot of learning in this course and I hope that you have actually learned quite a lot of things out of these lectures and of course by watching videos, reading and accumulating information from around you. Assessment is always a good idea. Self-assessment helps you to see where you stand in terms of your understanding of a discipline. In this case, we adopted a quiz-based assessment approach for you so that after a certain time in this learning process, you should have an idea what is the level of your understanding of Islamic modes of finance, their applications in different contexts and some general knowledge. So today, we shall be continuing with our quiz with one question, four answers, only one of them is correct and you have to pick up the correct one, write it down and see whether your answer is correct. If not, you should be by now a bit worried about your level of understanding of Islamic banking and finance, especially your knowledge of Islamic modes of finance. This is our question today. The most recent addition to Takaful models is a murabha-based Islamic microfinance, b. Mudarbha-based model, c. Waqf-based model, d. Takaful ta'avuni. So we have four answers, one of them is correct and you have to pick up your correct answer. I would be trying to pick up my correct answer. I normally do this thing by way of a random choice and in most cases previously my choice has been correct. So I hope that today I would be picking up the correct answer as well. If I go for murabha-based Islamic microfinance, my guess would be anything to do with murabha cannot be a recent one because murabha has been in application in Islamic banking and finance for a very long time. So if anything was going to be pioneered, murabha would have been one of the first choices to be picked up. So I would not like to go for murabha-based Islamic microfinance. Mudarbha-based model, that could be a choice. Waqf-based model, that could be another one and Takaful ta'avuni. Now Takaful ta'avuni is something I have not heard of and if I have not heard of, you must have not heard of it either. So I would like to go for Waqf-based model and let us see if this is correct. This is absolutely correct. When we studied different models of Takaful, we studied a mudarbha-based model, we studied a wakala-based model, we studied a hybrid model which would involve wakala and mudarbha. Then at the end we mentioned that in Pakistan a new model has been introduced which is based on the institution of Waqf. Now Waqf was used in the context of Takaful because the Sharia scholars in Pakistan deemed that the use of Takaful is more appropriate in the context of donations. Remember when we studied Takaful, we argued that the major or the most fundamental contract in Takaful is donation. In case of conventional insurance, the most fundamental contract or document is the policy. We mentioned that in case of conventional insurance, you pay a price to buy a document along with whatever is written in it and that document would entitle you to different benefits. In case of Takaful, however, you donate certain amounts of money in the case of Waqf-based model into Waqf and because you are part of this community of donors, you should expect some benefits out of it. So the correct answer is Waqf-based Takaful model. A is wrong for obvious reasons. I would not highlight all the reasons but common sense suggests that the question was about Takaful and the answer in A was about Islamic microfinance. So anyone who was not in type C of the students would have picked it up. B is also wrong because Modarba-based Takaful model was actually the first one to be used in the Takaful industry. D is wrong as well because Takaful Tawuni is practiced in Saudi Arabia and this is not the first model of Takaful. When we were covering the topic of Takaful, I did not explicitly mention the use of Islamic insurance in Saudi Arabia. The scholars in Saudi Arabia take a view that conventional insurance is more or less good. It is okay from Sharia viewpoint as long as there are no interest related activities, if there is no gambling and if there is no excessive error in the transaction. So their view is that if the money received by the insurance company is not invested in interest based securities, then it should be okay. Secondly, they say that the uncertainty or error which is presented as an argument by the critics of insurance, this is not valid. This is their view and they say that there has never been an intention of the policy buyers to gamble. It is actually to protect themselves from something bad happening. And this is why they say that in Arabic we use the word atta-mean for insurance which is actually satisfaction or sense of protection. It is from aman, ta-mean and atta-mean atta-awuni is basically cooperative. And they would say as long as there is a legal requirement there, as long as 10% of the profits of the insurance company are distributed amongst the policy holders, we would deem this practice to be Islamic or Sharia compliant.


That's gonna be an either the best or my life or the worst who's with me. I know it was the worst. Oh nevermind the best


A player's on the bench, specifically George Hill. They seem perplexed, Chandler. Is this, is this just not normal? I mean, yeah, this is a guy that's been right-handed his entire career and he's taking elbow jumpers with his left hand. I mean, Hill looks like somebody literally just took a dump right next to him. Like that's the face you make when something smells awful. It's pretty fascinating that this guy straight up was right-handed and now he's left-handed and is, you know, 10th or whatever near it is in the league. I respect him making the change.  This is, I mean, it's kind of psychotic to keep doing the same thing over and over again. So respect to him, you can see the players. I love it.