[1]
The civil war in 2011 that split Sudan in two has since left many refugee settlements across Africa with an influx of people from the waring state. Due to their adjacent borders, many of these people from Sudan fled to Udandan refugee settlements. A number of challenges emerge from the governing and controlling of the settlment camps due to the amount of people with diverse backgrounds. One particular debate that we will focus on in this project is dispute resolution strategies.
Throughout this assignment, we focus on three dispute resolution strategies within the camp. There are several assumptions we need to make in order to model this data. First, we assume that the initial population of the camp is 1500 people. We assume that 500 people abide by only one of three dispute resolution strategies. Next, we assume that when a dispute erupts, the dispute is resolved by only one of these strategies and the disputer whose position was not chosen converts to supporting the other dispute resolution strategy. Also, there are only two people involved in the actual dispute. Now that we have these assumptions, let's talk about what exactly these three dispute resolution strategies look like.
The first dispute resolution strategy is called arbitration. This involves total control from an outside party who must not be involved in the dispute. In this solution, the outside party decides the outcome and consequences of the dispute while the disputers do not have a say. The second dispute resolution strategy is called mediation. Mediation allows for the disputers to resolve the dispute on their own while employing an outside source for guidance during the resolution. The last strategy is called negotiation. Negotiation involves only the two disputers resolving the fight and does not involve any outside sources helping to resolve the situation.
In this project, we will observe these three dispute resolution strategies and attempt to model them for Ugandan refugee camps by creating 3 different possible scenarios (discussed below). We consider multiple parameters including population growth. We then analyze the costs for each scenario and for each dispute resolution strategy. Finally, we look at the affect of Malaria incidences and deaths on the population of each dispute resolution strategy groups.
Figure 1. Refugees in Northern Uganda [5]
There are initially 500 people that prefer each of the three dispute resolution strategies. The values that were chosen to represent the fraction of disputes between one strategy and another that were resolved with only one of the strategies in question were decided on using the following logic. The fraction of people, k, that choose to have interactions with different people is 50%. This number is chosen based on how we operate in our own lives. While a lot of time is spent interacting with familiar faces, we do spend about half our lives interacting with people we don't know. Based off this, we decided to set the fraction of people who interact with others outside their own groups to be 50%, or 0.5. The following scenarios outline possible reasons that one strategy might be preferred over the other strategy.
Scenario 1: Negotiation suggests there is an expectation that the two disputers will figure out the issue between themselves. Contrarily, arbitration gives no power to the disputers and leaves the resolution process up to an outside source. Since there is not a lot of middle ground between these two strategies, we will declare the fraction of disputes between negotiators and arbitrators resolved with negotiation, n_NA, and the fraction of disputes between negotiators and arbitrators resolved with arbitration, a_NA, equal to 0.5, or 50%. Next, we can look at the negotiation strategy in opposition with the mediation strategy. The mediation strategy is a less invasive strategy than the arbitration method, in that it allows the disputing parties to resolve conflict amongst themselves with the help of outside sources. People who prefer negotiation strategies would be more inclined to compromise with this system. Therefore, we declare the fraction of disputes between negotiators and mediators resolved with negotiation, n_NM, to be 0.4 or 40% and the fraction of disputes between negotiators and mediators resolved with mediation, m_NM, to be 0.6 or 60%. By the same logic, we believe that those in support of arbitration would still want guidance as to how to resolve the dispute, but might be willing to compromise with those in support of mediation. Though since guidance doesn’t provide an absolute standard on the behavior of disputers, we feel that those in favor of arbitration would feel more strongly to stick to their preferred method. That being said, we declare the fraction of disputes between mediators and arbitrators resolved with arbitration, a_MA, to be 0.65 or 65% and the fraction of disputes between mediators and arbitrators resolved with mediation, m_NA, would be 0.35, or 35%.
Scenario 2: Similar to the first scenario, the strategies of negotiation and arbitration seem nearly opposite. Since both of the disputing parties would most likely be just as stubborn to maintain their own strategy, we will still declare n_NA to be 0.5, or 50%, and a_NA to also be 0.5, or 50%. Next, while there is a chance that the mediation population would be more inclined to stick to their own preference, there is the possibility that those who prefer negotiation would want to avoid bringing outside people into conflict. In this case, we can declare that n_NM is 0.55, or 55% and m_NM is 0.45, or 45%. Lastly since arbitration gives no independence to the disputers, mediators might be very adamant about sticking to their own negotiation method. Therefore, we can declare a_MA to be 0.55, or 55%, and m_NA to be 0.45, or 45%.
Scenario 3: Finally, we might have the possibility that all methods are just as likely to be the resolving strategies in a dispute. In this case, each fraction would be 0.5 or 50%.
Our first task is to approximate the population of these three groups over time based on the four scenarios that are outlined above. We can do this by using a first order method, called Euler's Method, and a higher order method called Heun's Method. We will begin with Euler's Method.
From this course, we take Euler’s equation to be
In our scenarios, we have the functions N(t), A(t), and M(t) which represent the number of people who prefer the negotiation strategy, arbitration strategy, and mediation strategy, respectively, at time t. We know the following initial conditions, since each population starts at 500 people at time t = 1.
Also, we are given the following differential equations for each of these functions.
Lastly, we are given a step size of 1 month. Now, we have all the necessary pieces to use Euler’s equation. Applying Euler’s equation, we obtain the following equations.
We will now execute the first 2 months by hand. First, we have that t = 1. As we mentioned above, the following equations apply.
As t increases, we must implement Euler’s equation for all three population functions as follows. Note that the fraction values are from scenario 1 which is explained in part 1 of this project.
Now, we can use a code to iterate through many months in order to see how the total population divides amongst the three disputing strategies at the end of the runtime for our simulation. The pseudo-code for the Euler function is as follows.
FUNCTION myApprox = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1; % Step size is 1 month
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst; % Initial population = 500
Mt(1, 1) = MtFirst; % Initial population = 500
At(1, 1) = AtFirst; % Initial population = 500
FOR month = 1:1:(runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + (Nt' (month) * step) % Implement Euler's Method for Nt
Mt(month + 1, 1) = Mt(month, 1) + (Mt ' (month) * step) % Implement Euler's Method for Mt
At(month + 1, 1) = At(month, 1) + (At ' (month) * step) % Implement Euler's Method for At
END FOR
myApprox = [Nt Mt At];
END FUNCTION
The runtime chosen for this simulation is 100, which means that it runs for 100 months and tracks the population in each group. This is an appropriate amount of time because we can see that each function reaches steady state and we are able to evaluate when this happens in relation to other functions. Refer to the MATLAB code in the bottom of Part 1 which calculates the first order Euler’s equation for the first model for 4 different scenarios.
Heun's Method is a higher order approximation that we will use to estimate the population of the three dispute resolution groups after 100 months for all four scenarios outlined above. Heun's Method essentially makes a predictive value of x that it then inputs into a higher order function to estimate the function values as x is iterating through its values. Perhaps this is explained better by the equations below that were obtained from Dr. Henslee's lecture slides.[2]
The first equation you see above is what we call the predictor step. The "predictor stage" is then used as an input of the function in the second equation which we call the "corrector stage". Below, we will run through the same sample calculation as we previously looked at with Euler's Method but this time we will implement Heun's Method. Below, we observe Heun's method for the first month of the simulation. The first equation above is used first.
Then, we use the predictor variables in the next equation.
This is just one example of the population over a month. By using the following pseudo-code, we can find the population changes over the entire population.
FUNCTION myApprox = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1; % Step size is 1 month
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
month = 1;
WHILE (month <= runTime - 1)
PNt(month + 1, 1) = Nt(month, 1) + (Nt' (month) * step)
PMt(month + 1, 1) = Mt(month, 1) + (Mt ' (month) * step)
PAt(month + 1, 1) = At(month, 1) + (At ' (month) * step)
Nt(month + 1, 1) = Nt(month, 1) + ((f ' (month)+ f ' (PNt(month + 1, 1))/2) * step) % Implement Heun's Method for Nt
Mt(month + 1, 1) = Mt(month, 1) + ((f ' (month)+ f ' (PMt(month + 1, 1))/2) * step) % Implement Heun's Method for Mt
At(month + 1, 1) = At(month, 1) + ((f ' (month)+ f ' (PAt(month + 1, 1))/2) * step) % Implement Heun's Method for At
month++
END
myApprox = [Nt Mt At];
END
The following six graphs represent the populations for each refugee preference in the camp for a time duration of 100 months. The graphs are given for each of the three scenarios and show the model using Euler's equation and Heun's equation.
Figure 1: Population of three resolution strategies over a 100 month simulation modelled using Euler's approximation for scenario 1.
Figure 2: Population of three resolution strategies over a 100 month simulation modelled using Heun's approximation for scenario 1.
Figure 3: Population of three resolution strategies over a 100 month simulation modelled using Euler's approximation for scenario 2.
Figure 4: Population of three resolution strategies over a 100 month simulation modelled using Heun's approximation for scenario 2.
Figure 5: Population of three resolution strategies over a 100 month simulation modelled using Euler's approximation for scenario 3.
Figure 6: Population of three resolution strategies over a 100 month simulation modelled using Heun's approximation for scenario 3.
A tradeoff of using a higher order function is that although it may converge faster than a lower value, it may converge at the wrong value.
Round off error is not that important in this context. Round off error originates from the fact computers can only retain a fixed number of significant figures during a calculation. The discrepancy introduced by this omission of significant figures is called round-off error. In this context, round-off error is not that important due to the fact you cannot have a fraction of a person.
Approximate error is not as important in this particular problem context because the stopping criterion that we used is so small. Since we are quantifying the error in population, when we introduce error, we are saying that our answer might be incorrect by a fraction of a person. Since “a fraction of a person” is not really a variable in real life, our answer will technically be over or underestimating the real outcome of any event that would occur. Therefore, while it is important to maintain certainty and accuracy in our final whole number answer, it is not as pressing to minimize the stopping criterion any further.
An error metric that is significant in deciding between using Euler's and Heun's approximation is truncation error. Truncation error is the error that results when cutting off values in measurements. In our case, we want to compare the truncation error seen in Euler's and the truncation error seen in Heun's methods. The following equation is used to find truncation error for both methods.
First, let's observe a sample calculation of the truncation error for Euler's method. We begin by differentiating the function at each month. Starting with Euler's we use the following function to differentiate.
For the first scenario for negotiation, this results in a value of -15.8426 for the first month. Then, we plug this value into the truncation error equation to find the error at this point.
Next, we consider Heun's method as follows.
We differentiate the following to use as the function in the truncation error equation.
When we differentiate this equation for the first month of the first scenario for negotiation, we obtain a value of -7.9213. We use this in the error equation as follows.
We use the code at the bottom of this section to iterate through the entire 100 months of the simulation in order to compare the error between these two methods.
The following plots represent the truncation error over the entire simulation for each scenario and each resolution strategy group. The plots are displayed such that it is easy to see that Heun's method has much less error than Euler's method
Figure 7: Truncation error for Euler's Method for scenario 1
Figure 8: Truncation error for Heun's Method for scenario 1
Figure 9: Truncation error for Euler's Method for scenario 2
Figure 10: Truncation error for Heun's Method for scenario 2
Figure 11: Truncation error for Euler's Method for scenario 3
Figure 12: Truncation error for Heun's Method for scenario 3
Heun's Method is a higher order approximation as compared to Euler's method. Heun's, as you can see in the plots above, converge to a value much faster than Euler's Method with a lot less error. These plots above represent truncation error, which is a major source of error when conducting measurements. Since Heun's has less error and converges to a value quicker than Euler's Method, we declare Heun's to be the better method for this approximation.
In the first part of this project, we observe three different scenarios of how the population of three dispute resolution strategists changes over time. It is assumed that each of the three populations begins at 500 people and the changes in these values is observed for 100 months. We approximate the population of each group using two different method. The first is Euler's method and the second is a higher order method called Heun's method. We evaluate the error of these methods using truncation error.
From the results above, we can conclude the following regarding the three strategies we are choosing to observe. For strategy 1, the population of the arbitration group after 100 months will converge to a value 1225 people for Heun's method. This means that this population will have increased from 33.33% of the total population to 81.67%. The population of the mediation group after 100 months converges to 0 people. Thus, the percent of the population in support of this strategy decreases from 33.33% to 0%. Lastly, the population of people in support of negotiation is 275 after 100 months which means it's presence in the total population decreased from 33.33% to 18.33%. For strategy 2, the population of arbitrators and negotiators are the same throughout the 100 months. The values of this population are both 750 people at the end of 100 months which means they both make up 50% of the population after this time. The mediation group population decreases from 33.33% to 0% after 100 months. Lastly for strategy 3, the population of each group starts at 500 and ends at 500. This means that there was no change throughout the 100 months. We can conclude that this is a result of there being an equal chance that any one of the strategies will be chosen.
The reason that each scenario's results are dramatically different from one another is because of the parameter values we assigned in the begininning of this project. The parameter values defined how the function would look because they determine what happens to the population over time and what the steady state of the population would eventually be, as we see after 100 months. For the first scenario, the values we chose were all 0.5, 0.65, 0.35, 0.6, and 0.4. These values affected the result because the fraction of disputes ending in arbitration tended to be higher than those ending in negotiation which were higher than those ending in mediation. This is reflected in the results since when the system is at steady state, it is evident that most of the population is arbitration followed by negotiation then mediation. Likewise, the parameter values that were chosen for the second scenario were 0.5, 0.55, and 0.45 where mediation was the least likely to be chosen and arbitration and negotiation were equally as likely to be chosen. This is also reflected in the plot since the steady state ends with half the population being arbitrators and the other half negotiators. Lastly, in scenario 3, we observe the case in which all disputes have a 50% chance of ending in any of the three resolutions. Therefore, over time, the values will stay equal to one another which is represented in our plot.
Between Euler's approximation and Heun's approximation, Heun's method proved to have less error. This result is explicitly seen in the error analysis section where the truncation error is much less for Heun's method than Euler's method. This suggests that Heun's method converges to a value more quickly than Euler's, implying that it shaves off more doubt each time an iteration is made. Euler's approximation is a first order approximation while Heun's is a second order approximation. Heun's uses a predictor value as seen in the numerical approach. This predictor value increases accuracy by more accurately estimating the function at each input.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EGR 312 Final Model 1 Code
% Katherine Reiss and Bridget Barsanti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;
%% DECLARE VARIABLES'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NtFirst = 500; % population that prefers the negotiation strategy at time 1
AtFirst = 500; % population that prefers the arbitration strategy at time 1
MtFirst = 500; % population that prefers the mediation strategy at time 1
P_tot = 1500; % total population
k = 0.5;
runTime = 100; % How long this simulation will go for (in months)
months = 1:1:runTime;
%% PLOTTING HEUN'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns1 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Heuns1Nt = Heuns1(:, 1);
Heuns1Mt = Heuns1(:, 2);
Heuns1At = Heuns1(:, 3);
%% Plot Scenario 1
figure(1)
plot(months, Heuns1Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 1 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns2 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Heuns2Nt = Heuns2(:, 1);
Heuns2Mt = Heuns2(:, 2);
Heuns2At = Heuns2(:, 3);
%% Plot Scenario 2
figure(2)
plot(months, Heuns2Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 2 using Heun Approximation"]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns4 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Heuns4Nt = Heuns4(:, 1);
Heuns4Mt = Heuns4(:, 2);
Heuns4At = Heuns4(:, 3);
%% Plot Scenario 3
figure(3)
plot(months, Heuns4Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 3 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% PLOTTING EULER'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler1 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Euler1Nt = Euler1(:, 1);
Euler1Mt = Euler1(:, 2);
Euler1At = Euler1(:, 3);
%% Plot Scenario 1
figure(4)
plot(months, Euler1Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 1 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler2 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Euler2Nt = Euler2(:, 1);
Euler2Mt = Euler2(:, 2);
Euler2At = Euler2(:, 3);
%% Plot Scenario 2
figure(5)
plot(months, Euler2Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 2 using Euler Approximation"]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler4 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Euler4Nt = Euler4(:, 1);
Euler4Mt = Euler4(:, 2);
Euler4At = Euler4(:, 3);
%% Plot Scenario 3
figure(6)
plot(months, Euler4Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 3 using Euler Approximation"]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Heun's Method
function higherOrder = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1;
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
month = 1;
while (month <= runTime - 1)
NtP(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))))*step;
MtP(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))))*step;
AtP(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))))*step;
Nt(month + 1, 1) = Nt(month, 1) + (((((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + ...
(n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1)))))...
+ (((k / P_tot) * ((n_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) + (n_NM*NtP(month + 1, 1)*MtP(month + 1, 1))...
- (a_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) - (m_NM*NtP(month + 1, 1)*MtP(month + 1, 1))))))./2).*step;
Mt(month + 1, 1) = Mt(month, 1) + (((((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + ...
(m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1)))))...
+ (((k / P_tot) * ((m_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) + (m_MA*MtP(month + 1, 1)*AtP(month + 1, 1)) ...
- (n_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) - (a_MA*MtP(month + 1, 1)*AtP(month + 1, 1))))))./2).*step;
At(month + 1, 1) = At(month, 1) + (((((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + ...
(a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1)))))...
+ (((k / P_tot) * ((a_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) + (a_MA*MtP(month + 1, 1)*AtP(month + 1, 1)) ...
- (n_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) - (m_MA*MtP(month + 1, 1)*AtP(month + 1, 1))))))./2).*step;
month = month + 1;
end
higherOrder = [Nt Mt At];
end
%% Euler's Method
function simulation = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
for month = 1:1:(runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))))*step;
Mt(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))))*step;
At(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))))*step;
end
simulation = [Nt Mt At];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EGR 312 Final Truncation Error
% Katherine Reiss and Bridget Barsanti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;
%% DECLARE VARIABLES'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
NtFirst = 500; % population that prefers the negotiation strategy at time 1
AtFirst = 500; % population that prefers the arbitration strategy at time 1
MtFirst = 500; % population that prefers the mediation strategy at time 1
P_tot = 1500; % total population
k = 0.5;
runTime = 100; % How long this simulation will go for (in months)
months = 1:1:runTime;
%% PLOTTING HEUN'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns1 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Heuns1Nt = Heuns1(:, 1);
Heuns1Mt = Heuns1(:, 2);
Heuns1At = Heuns1(:, 3);
Heuns1_Nt_R1 = Heuns1(:, 4);
Heuns1_Mt_R1 = Heuns1(:, 5);
Heuns1_At_R1 = Heuns1(:, 6);
%% Scenario 1 Error Plot
figure(1)
plot(months, Heuns1_Nt_R1, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1_Mt_R1, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1_At_R1, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
xlim([3 100]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
title('Truncation Error for Scenario 1 using Heuns Method');
ylabel('Truncation Error');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns2 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Heuns2Nt = Heuns2(:, 1);
Heuns2Mt = Heuns2(:, 2);
Heuns2At = Heuns2(:, 3);
Heuns2_Nt_R1 = Heuns2(:, 4);
Heuns2_Mt_R1 = Heuns2(:, 5);
Heuns2_At_R1 = Heuns2(:, 6);
%% Scenario 2 Error Plot
figure(2)
plot(months, Heuns2_Nt_R1, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2_Mt_R1, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2_At_R1, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
xlim([3 100]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
title('Truncation Error for Scenario 2 using Heuns Method');
ylabel('Truncation Error');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns4 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Heuns4Nt = Heuns4(:, 1);
Heuns4Mt = Heuns4(:, 2);
Heuns4At = Heuns4(:, 3);
Heuns4_Nt_R1 = Heuns4(:, 4);
Heuns4_Mt_R1 = Heuns4(:, 5);
Heuns4_At_R1 = Heuns4(:, 6);
%% Scenario 3 Error Plot
figure(3)
plot(months, Heuns4_Nt_R1, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4_Mt_R1, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4_At_R1, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
xlim([3 100]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
title('Truncation Error for Scenario 3 using Heuns Method');
ylabel('Truncation Error');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% PLOTTING EULER'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler1 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Euler1Nt = Euler1(:, 1);
Euler1Mt = Euler1(:, 2);
Euler1At = Euler1(:, 3);
Euler1_Nt_R1 = Euler1(:, 4);
Euler1_Mt_R1 = Euler1(:, 5);
Euler1_At_R1 = Euler1(:, 6);
%% Scenario 1 Error Plot
figure(4)
plot(months, Euler1_Nt_R1, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1_Mt_R1, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1_At_R1, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
xlim([2 100]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
title('Truncation Error for Scenario 1 using Eulers Method');
ylabel('Truncation Error');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler2 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Euler2Nt = Euler2(:, 1);
Euler2Mt = Euler2(:, 2);
Euler2At = Euler2(:, 3);
Euler2_Nt_R1 = Euler2(:, 4);
Euler2_Mt_R1 = Euler2(:, 5);
Euler2_At_R1 = Euler2(:, 6);
%% Scenario 2 Error Plot
figure(5)
plot(months, Euler2_Nt_R1, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2_Mt_R1, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2_At_R1, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
xlim([2 100]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
title('Truncation Error for Scenario 2 using Eulers Method');
ylabel('Truncation Error');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler4 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot);
Euler4Nt = Euler4(:, 1);
Euler4Mt = Euler4(:, 2);
Euler4At = Euler4(:, 3);
Euler4_Nt_R1 = Euler4(:, 4);
Euler4_Mt_R1 = Euler4(:, 5);
Euler4_At_R1 = Euler4(:, 6);
%% Scenario 3 Error Plot
figure(6)
plot(months, Euler4_Nt_R1, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4_Mt_R1, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4_At_R1, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
xlim([2 100]);
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
title('Truncation Error for Scenario 3 using Eulers Method');
ylabel('Truncation Error');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 16);
%% Higher Order Method: Heun's
function higherOrder = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1;
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
dNt = zeros(runTime, 1);
dMt = zeros(runTime, 1);
dAt = zeros(runTime, 1);
other_dNt = zeros(runTime, 1);
other_dMt = zeros(runTime, 1);
other_dAt = zeros(runTime, 1);
DNt = zeros(runTime, 1);
DMt = zeros(runTime, 1);
DAt = zeros(runTime, 1);
R1_Nt = zeros(runTime, 1);
R1_Mt = zeros(runTime, 1);
R1_At = zeros(runTime, 1);
month = 1;
while (month <= runTime - 2)
NtP(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))))*step;
MtP(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))))*step;
AtP(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))))*step;
dNt(month, 1) = ((k / P_tot) * ((n_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) + (n_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) - (a_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) - (m_NM*NtP(month + 1, 1)*MtP(month + 1, 1))));
dMt(month, 1) = ((k / P_tot) * ((m_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) + (m_MA*MtP(month + 1, 1)*AtP(month + 1, 1)) - (n_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) - (a_MA*MtP(month + 1, 1)*AtP(month + 1, 1))));
dAt(month, 1) = ((k / P_tot) * ((a_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) + (a_MA*MtP(month + 1, 1)*AtP(month + 1, 1)) - (n_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) - (m_MA*MtP(month + 1, 1)*AtP(month + 1, 1))));
Nt(month + 1, 1) = Nt(month, 1) + (((((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + ...
(n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1)))))...
+ (((k / P_tot) * ((n_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) + (n_NM*NtP(month + 1, 1)*MtP(month + 1, 1))...
- (a_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) - (m_NM*NtP(month + 1, 1)*MtP(month + 1, 1))))))./2).*step;
Mt(month + 1, 1) = Mt(month, 1) + (((((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + ...
(m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1)))))...
+ (((k / P_tot) * ((m_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) + (m_MA*MtP(month + 1, 1)*AtP(month + 1, 1)) ...
- (n_NM*NtP(month + 1, 1)*MtP(month + 1, 1)) - (a_MA*MtP(month + 1, 1)*AtP(month + 1, 1))))))./2).*step;
At(month + 1, 1) = At(month, 1) + (((((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + ...
(a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1)))))...
+ (((k / P_tot) * ((a_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) + (a_MA*MtP(month + 1, 1)*AtP(month + 1, 1)) ...
- (n_NA*NtP(month + 1, 1)*AtP(month + 1, 1)) - (m_MA*MtP(month + 1, 1)*AtP(month + 1, 1))))))./2).*step;
other_dNt(month + 1, 1) = (k / P_tot) * ((n_NA*NtP(month + 2, 1)*AtP(month + 2, 1)) + (n_NM*NtP(month + 2, 1)*MtP(month + 2, 1))...
- (a_NA*NtP(month + 2, 1)*AtP(month + 2, 1)) - (m_NM*NtP(month + 2, 1)*MtP(month + 2, 1)));
other_dMt(month + 1, 1) = (k / P_tot) * ((m_NM*NtP(month + 2, 1)*MtP(month + 2, 1)) + (m_MA*MtP(month + 2, 1)*AtP(month + 2, 1)) ...
- (n_NM*NtP(month + 2, 1)*MtP(month + 2, 1)) - (a_MA*MtP(month + 2, 1)*AtP(month + 2, 1)));
other_dAt(month + 1, 1) = (k / P_tot) * ((a_NA*NtP(month + 2, 1)*AtP(month + 2, 1)) + (a_MA*MtP(month + 2, 1)*AtP(month + 2, 1)) ...
- (n_NA*NtP(month + 2, 1)*AtP(month + 2, 1)) - (m_MA*MtP(month + 2, 1)*AtP(month + 2, 1)));
DNt(month + 1, 1) = ((dNt(month, 1) + (other_dNt(month, 1)))./2);
DMt(month + 1, 1) = ((dMt(month, 1) + (other_dMt(month, 1)))./2);
DAt(month + 1, 1) = ((dAt(month, 1) + (other_dAt(month, 1)))./2);
R1_Nt(month + 1, 1) = (DNt(month, 1) ./ 2).*(step.^2);
R1_Mt(month + 1, 1) = (DMt(month, 1) ./ 2).*(step.^2);
R1_At(month + 1, 1) = (DAt(month, 1) ./ 2).*(step.^2);
month = month + 1;
end
higherOrder = [Nt Mt At R1_Nt R1_Mt R1_At];
end
%% Euler's Method Part 1
function simulation = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt_R1 = zeros(runTime, 1);
R1_Nt(1, 1) = 1;
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
for month = 1:1:(runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))))*step;
Mt(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))))*step;
At(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))))*step;
dNt(month, 1) = ((k / P_tot) * ((n_NA*Nt(month + 1, 1)*At(month + 1, 1)) + (n_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) - (a_NA*Nt(month + 1, 1)*At(month + 1, 1)) - (m_NM*Nt(month + 1, 1)*Mt(month + 1, 1))));
dMt(month, 1) = ((k / P_tot) * ((m_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) + (m_MA*Mt(month + 1, 1)*At(month + 1, 1)) - (n_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) - (a_MA*Mt(month + 1, 1)*At(month + 1, 1))));
dAt(month, 1) = ((k / P_tot) * ((a_NA*Nt(month + 1, 1)*At(month + 1, 1)) + (a_MA*Mt(month + 1, 1)*At(month + 1, 1)) - (n_NA*Nt(month + 1, 1)*At(month + 1, 1)) - (m_MA*Mt(month + 1, 1)*At(month + 1, 1))));
R1_Nt(month+1, 1) = (dNt(month, 1) ./ 2).*(step.^2);
R1_Mt(month+1, 1) = (dMt(month, 1) ./ 2).*(step.^2);
R1_At(month+1, 1) = (dAt(month, 1) ./ 2).*(step.^2);
end
simulation = [Nt Mt At R1_Nt R1_Mt R1_At];
end
We now consider the change experienced within the models as incoming population changes the amount of people in support of each scenario. Below, we have the raw data for each dispute resolution type.
Figure 13: Raw data for incoming negotiators
Figure 14: Raw data for incoming mediators
Figure 15: Raw data for incoming arbitrators
Based on observation alone, it seems that the incoming population of negotiators follows a linear trend, the incoming population of arbitrators follows a sinusoidal trend, and the incoming population of mediators follows a saturation growth model trend. Now, we can fit these models to see if they correctly correspond to these assumptions. For the first model, I used a guess and check method outlined in the pseudocode. I was checking the R_sqaured value as I was checking to see that I can come up with the most accurate result. This proved to be an effective method based on both observation and the error calculations. Next, I used a resource to find a method for saturation growth rate models [3]. This method proved to be very affective. It involved creating inverses of the variables x and y and finding the coefficients of the new fit based on these variables. The final function produced a curve that very closely related to the raw data. Lastly, the linear model in the third plot was made by creating metrics of the sum of data sets and the mean values, then these values were used to find the coefficients of the new curve. The error measurements were conducted and are explained in the error analysis part of this section.
This section outlines the results of part 2. The first plot below shows the sinusoidal model used to fit the data for the incoming arbitrators observed.
FUNCTION arbitration_fit = sinusoidal(x, y)
FIND peaks > 25.5
avgHeight = MEAN(peaks);
C1 = avgHeight - mean(y);
FIND the period, T, of the sinusoidal curve
w0 = (2.*pi)./T;
theta = T - 2 * x(peaks(1,1)); %Guess and check
Find coefficients:
A1 = C1.*(cos(theta));
B1 = -C1.*(sin(theta));
arbitration_fit = mean(y) + A1.*cos(w0.*x) + B1*(sin(w0.*x));
END FUNCTION
Figure 16: Incoming Arbitrators data with sinusoidal fit
Note that the sinusoidal model above was found using a guess and check method. This method produced the most accurate results according to the error analysis that is outlined in this section. Further, the following plot represents the data of the incoming mediators observed with a saturation growth rate model fit.[3]
Figure 17: Incoming Arbitrators data with saturation growth fit
FUNCTION mediation_fit = SGRModel(month, func)
n = LENGTH(month);
inv_n = n.^(-1);
i_func = SUM((1./func));
i_month = SUM(1./month);
i_month_2 = SUM((1./month).^2);
i_month_func = SUM((1./func).*(1./month));
mean_func = inv_n .* SUM(func);
a0 = (i_n.*inv_func.*i_month_2 - i_n.*i_month.*i_month_func)./(i_month_2 - i_n.*i_month.*i_month);
a1 = ((i_month_func) - (i_n.*i_month.*i_func))/(i_month_2-(i_n.*v_month.*i_month));
a = 1./a0;
b = a1.*a;
mediation_fit = a .* (month./(month+b));
END FUNCTION
The last plot below represents the data of the incoming negotiators observed with a linear model.
FUNCTION linAnswer = linearModel(xi, yi)
n = LENGTH(xi);
sum_xi = SUM(xi);
sum_yi = SUM(yi);
sum_xiXyi = SUM(xi.*yi);
sum_xiSquared = SUM(xi.^2);
mean_xi = MEAN(xi);
mean_yi = MEAN(yi);
a1 = ((n.*sum_xiXyi) - (sum_xi.*sum_yi)) ./ ((n.*sum_xiSquared) - (sum_xi).^2);
a0 = mean_yi - (a1.*mean_xi);
linAnswer = a0 + a1.*xi;
END FUNCTION
Figure 18: Incoming Arbitrators data with linear fit
From observation, the fits accurately estimate the patterns of the raw data. The only exception would be for mediation since the fit tends to increase more rapidly towards higher x values as compared to the data. We can see just how accurate our models are in the error analysis as follows.
To estimate the accuracy or precision of our curve fitting to the data, we use three measures of error. The first is the sum of squares of residuals, the next one is standard error, and the last one is an R-squared value.
The sum of squared residuals is a statistical technique to measure the amount of variance in a data set as it estimates variance in the residuals. The equation is shown below:
where yi is the ith value fo the variable to be predicted
y is the predicted value of y
n is the upper limit of summation
The R2 value, or the coefficient of determination, is a statistical measurement that examines how differences in one variable can be explained by the difference in a second variable, when predicting the outcome of a given event. Essentially, it assesses how strong the linear relationship is between two variables. It is a value between 0.0 and 1.0, where a value of 1.0 indicates a perfect fit and is a thus reliable for future forecasts, while a value of 0.0 would indicate that the model fails to accurately model the data at all.
Where St is the total sum of squares and SR is the sum of squared residuals.
Where yi is the ith value of the variable to be predicted
y̅ is the average value of y
n is the upper limit of summation
The Standard Error of the Estimate is a measure of variation of an observation made around the computed regression line. It is used to check the accuracy of predictions made with the regression line. The smaller the value of a standard error of estimates the closer are the dots to the regression line and better is the estimate based on the equation of the line.
Where Sr is the sum of squared residuals
n is the upper limit of summation
The tables below consist of four time periods and places and their respective sum of square residuals, coefficient of determination, and standard error – separated into two tables by model.
Since calculating the error would involve running through the entire simulation, we use a MATLAB code to find the error within our fits. The pseudocode for this MATLAB script can be found below.
FUNCTION error(x, y, y_fit)
Sum_Squares_Residuals = SUM((y - y_fit).^2)
Sum_Squares_Total = SUM(y_fit - MEAN(y)).^2)
R_Squared = (Sum_Squares_Total - Sum_Squares_Residuals)./Sum_Squares_Total
Standard_Error = SQRT(Sum_Squares_Residuals ./(LENGTH(x) - 2))
END FUNCTION
Table 1: Error analysis for curve fits
From the table, it is evident that the models do a good job of explaining the data set due to the larger R2 values and smaller standard error values. Again, the coefficient of determination R2 assesses the percentage variation in y is explained by x variables – so the larger, the stronger the relationship; the smaller the value of a standard error of estimates the closer are the dots to the regression line and better is the estimate based on the equation of the line. The sum of squares of residuals are larger but this is to be expected with larger sets of data. Other errors that could have been considered but were not calculated were errors made in the data collection as well as round-off errors in the measurements for the curve fitting methods.
These three models do good job capturing the incoming trends, as seen in the graphs with the line of best fit as well as the error analysis metrics that were calculated. The negotiator data appeared linear, and it was clear that a linear model would best fit this data set. The mediator data was curved and saturation growth rate proved to best fit this data set. The arbitrator data was cyclical and a sinusoidal model was the proper line of best fit.
Among these three models, the Negotiation Fit Model was the best, as it has the largest R2 value and smallest Sum of Squares of Residuals and Standard Error.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EGR 312 Final - Creating models to fit data
% Katherine Reiss and Bridget Barsanti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Setup
clear all;
clc;
%% Variables defined in given problem statement
% num_month = The number of months that have passed (t)
% Arb_obs = The number of incoming arbitrators observed (Ain)
% Med_obs = The number of incoming mediators (Min)
% Neg_obs = The number of incoming negotiators observed (Nin)
%% Load data
load PopulationGrowth.mat;
%% Plotting Raw Data
figure(1)
plot(num_month, Arb_obs, '*', 'Color', [0.5 0.8 0.4]);
title('Incoming Arbitrators Observed');
ylabel('Incoming Population');
xlabel('Months Passed');
grid on
box on
set(gca, 'FontSize', 16);
arb_fit = sinusoidal(num_month, Arb_obs);
hold on
plot(num_month, arb_fit, 'k', 'linewidth', 1.2);
legend('Raw Data', 'Sinusoidal Model');
figure(2)
plot(num_month, Med_obs, '*', 'Color', [0.5 0.7 0.9]);
title('Incoming Mediators Observed');
ylabel('Incoming Population');
xlabel('Months Passed');
grid on
box on
set(gca, 'FontSize', 16);
med_fit = SGRModel(num_month, Med_obs);
hold on
plot(num_month, med_fit, 'k', 'linewidth', 1.2);
legend('Raw Data', 'Saturation Growth Rate Model');
figure(3)
plot(num_month, Neg_obs, '*', 'Color', [0.8 0.7 0.9]);
title('Incoming Negotiators Observed');
ylabel('Incoming Population');
xlabel('Months Passed');
grid on
box on
set(gca, 'FontSize', 16);
neg_fit = linearModel(num_month, Neg_obs); % linear fit
hold on
plot(num_month, neg_fit, 'k', 'linewidth', 1.2);
legend('Raw Data', 'Linear Model');
%% Linear Model
%% FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function linAnswer = linearModel(xi, yi)
n = length(xi);
sum_xi = sum(xi);
sum_yi = sum(yi);
sum_xiXyi = sum(xi.*yi);
sum_xiSquared = sum(xi.^2);
mean_xi = mean(xi);
mean_yi = mean(yi);
a1 = ((n.*sum_xiXyi) - (sum_xi.*sum_yi)) ./ ((n.*sum_xiSquared) - (sum_xi).^2);
a0 = mean_yi - (a1.*mean_xi);
linAnswer = a0 + a1.*xi;
end
function med_fit = SGRModel(num_month, Med_obs) % Created with the help of reference [3]
n = length(num_month);
inv_n = n.^(-1);
inv_Med_obs = sum((1./Med_obs));
inv_num_month = sum(1./num_month);
inv_num_month_2 = sum((1./num_month).^2);
inv_num_month_Med_obs = sum((1./Med_obs).*(1./num_month));
mean_Med_obs = inv_n .* sum(Med_obs);
a0 = (inv_n.*inv_Med_obs.*inv_num_month_2 - inv_n.*inv_num_month.*inv_num_month_Med_obs)./(inv_num_month_2 - inv_n.*inv_num_month.*inv_num_month);
a1 = ((inv_num_month_Med_obs) - (inv_n.*inv_num_month.*inv_Med_obs))/(inv_num_month_2-(inv_n.*inv_num_month.*inv_num_month));
a = 1./a0;
b = a1.*a;
med_fit = a .* (num_month./(num_month+b));
end
function arb_fit = sinusoidal(num_month, Arb_obs)
n = length(num_month);
A0 = mean(Arb_obs, 'all');
peaks = find(Arb_obs > 25.5);
avgHeight = mean(Arb_obs(peaks));
C1 = avgHeight - A0;
T = mean(num_month((peaks(length(peaks)) - peaks(length(peaks)-1))), num_month(peaks(length(peaks)-1) - peaks(length(peaks)-2)));
w0 = (2.*pi)./T;
theta = T - 2 * num_month(peaks(1,1));
A1 = C1.*(cos(theta));
B1 = -C1.*(sin(theta));
arb_fit = A0 + A1.*cos(w0.*num_month) + B1*(sin(w0.*num_month));
end
So far, we have looked at the outcome of the three scenarios in terms of what the population of 1500 people would look like by the end of 100 months. We have shown the distribution of people amongst the dispute resolution groups that would result from the scenario's parameters. However, this is not necessarily an accurate representation of what is really happening in the camps. The exact population of the camp is always changing. We now consider these cases during a 100 month simulation where the population of each group of people fluctuates over time due to incoming supporters of that group. Now, in order to approximate the models for each scenario, we can implement Euler's method and Heun's method again. This time, we use model 2 instead of model 1. Model 2 takes into consideration the population curves that we had found in part 2. Though we implement both models here, it would only be necessary to implement Heun's because is a more accurate approximation, as explained in part 1.
Using Euler's equation again,
we can find the same results as we had in part one but using a different model. This model will take into consideration the population increase throughout the simulation that we looked at in part two. The initial conditions stay the same so the following is true.
For model 2, we are given the following differential equations.
Implementing Euler's equation with a step size of 1 month, we obtain the following equations.
Below is a sample calculation that finds the population for each group after one month in the simulation.
In order to find these values for each scenario for the entire duration of the simulation, we can use a code. The pseudocode that was used can be found in this section.
FUNCTION myApprox = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1; % Step size is 1 month
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst; % Initial population = 500
Mt(1, 1) = MtFirst; % Initial population = 500
At(1, 1) = AtFirst; % Initial population = 500
FOR month = 1:1:(runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((Nt' (month) + curveFit)* step) % Implement Euler's Method for Nt
Mt(month + 1, 1) = Mt(month, 1) + ((Mt ' (month) + curveFit) * step) % Implement Euler's Method for Mt
At(month + 1, 1) = At(month, 1) + ((At ' (month) + curveFit) * step) % Implement Euler's Method for At
END FOR
myApprox = [Nt Mt At];
END FUNCTION
We begin again by observing the following equations that we have for model 2.
Note that the initial conditions stay the same, so each population starts with 500 people at month 1. Heun's Method finds two solutions. The first one is a prediction for the independent variable and the next one uses this prediction to estimate the next value of the dependent variable. The equations for Heun's Method are as follows.
First, we can find the predictor value with the first equation.
Now, we use this predictor value in the second equation as follows.
We can continue this pattern until we have iterated through the entire 100 months of the simulation. We use the pseudo-code below to do so.
FUNCTION myApprox = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1; % Step size is 1 month
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
month = 1;
WHILE (month <= runTime - 1)
PNt(month + 1, 1) = Nt(month, 1) + ((Nt' (month) + curveFit)* step)
PMt(month + 1, 1) = Mt(month, 1) + ((Mt ' (month) + curveFit) * step)
PAt(month + 1, 1) = At(month, 1) + ((At ' (month) + curveFit) * step)
Nt(month + 1, 1) = Nt(month, 1) + (((f ' (month)+ f ' (PNt(month + 1, 1) + curveFit))/2) * step) % Implement Heun's Method for Nt
Mt(month + 1, 1) = Mt(month, 1) + (((f ' (month)+ f ' (PMt(month + 1, 1) + curveFit))/2) * step) % Implement Heun's Method for Mt
At(month + 1, 1) = At(month, 1) + (((f ' (month)+ f ' (PAt(month + 1, 1) + curveFit))/2) * step) % Implement Heun's Method for At
month++
END
myApprox = [Nt Mt At];
END
The following 6 plots represent the populations of dispute resolution strategists over a 100 month simulation for 3 different scenarios using both Euler's approximation and Heun's approximation. All of these plots are created from model 2 which considers an incoming population for each strategy.
Figure 19: Population for each strategy preferences over 100 months using Euler's Method for scenario 1
Figure 20: Population for each strategy preferences over 100 months using Heun's Method for scenario 1
Figure 21: Population for each strategy preferences over 100 months using Euler's Method for scenario 2
Figure 22: Population for each strategy preferences over 100 months using Heun's Method for scenario 2
Figure 23: Population for each strategy preferences over 100 months using Euler's Method for scenario 3
Figure 24: Population for each strategy preferences over 100 months using Heun's Method for scenario 3
To understand the error analysis for this section, please refer to part 1's error analysis. Note that it was not necessary to use both Euler's and Heun's methods for this problem but it is interesting to see how the larger truncation error of Euler's is represented in these plots by deviating from the solutions we see in Heun's method. Further, the error that we obtain from the part 2 curve fittings must also be considered in this section since we use those fits in our models. To refer to that error analysis, see section 2. Possible sources of error that could have come elsewhere including the error in taking the data we use in model 2 or truncation errors that are present as we calculate model 2. Though we do not show these calculations here, they correspond to those in part 1.
Given the new model simulations, each scenario presents different trends regarding the evolution of conflict resolution strategies in this camp. In Scenario 1, arbitration strategy had the most growth followed by negotiation, while mediation decreased over time. In Scenario 2, negotiation had the most growth at the end of the simulation period closely followed by arbitration, while mediation decreased over time. In Scenario 3, all three strategies increased over time, mediation had the largest growth followed by negotiation, then arbitration.
It is important to include population growth in the model as the incoming population can have a large impact on the evolution of conflict over time.
Many assumptions were made in developing this model regarding model formulation, parameter values, fitted regression models, and approximations. The parameter values assigned in the beginning of the project defined how the function would look because they determine what happens to the population over time. Therefore, this remains extremely impactful regarding the outcome of the models.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EGR 312 Final Model 2
% Katherine Reiss and Bridget Barsanti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;
%% Load data
load PopulationGrowth.mat;
%% Curve fitting
arb_fit = sinusoidal(num_month, Arb_obs);
med_fit = SGRModel(num_month, Med_obs);
neg_fit = linearModel(num_month, Neg_obs);
%% Parameters
NtFirst = 500; % population that prefers the negotiation strategy at time 1
AtFirst = 500; % population that prefers the arbitration strategy at time 1
MtFirst = 500; % population that prefers the mediation strategy at time 1
P_tot = 1500; % total population
k = 0.5;
runTime = 100; % How long this simulation will go for (in months)
months = 1:1:runTime;
%% PLOTTING HEUN'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns1 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit);
Heuns1Nt = Heuns1(:, 1);
Heuns1Mt = Heuns1(:, 2);
Heuns1At = Heuns1(:, 3);
figure(1)
plot(months, Heuns1Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 1 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns2 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit);
Heuns2Nt = Heuns2(:, 1);
Heuns2Mt = Heuns2(:, 2);
Heuns2At = Heuns2(:, 3);
figure(2)
plot(months, Heuns2Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 2 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns4 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit);
Heuns4Nt = Heuns4(:, 1);
Heuns4Mt = Heuns4(:, 2);
Heuns4At = Heuns4(:, 3);
figure(3)
plot(months, Heuns4Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 3 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% PLOTTING EULER'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler1 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit);
Euler1Nt = Euler1(:, 1);
Euler1Mt = Euler1(:, 2);
Euler1At = Euler1(:, 3);
figure(4)
plot(months, Euler1Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 1 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler2 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit);
Euler2Nt = Euler2(:, 1);
Euler2Mt = Euler2(:, 2);
Euler2At = Euler2(:, 3);
figure(5)
plot(months, Euler2Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 2 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler4 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit);
Euler4Nt = Euler4(:, 1);
Euler4Mt = Euler4(:, 2);
Euler4At = Euler4(:, 3);
figure(6)
plot(months, Euler4Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 3 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function linAnswer = linearModel(xi, yi)
n = length(xi);
sum_xi = sum(xi);
sum_yi = sum(yi);
sum_xiXyi = sum(xi.*yi);
sum_xiSquared = sum(xi.^2);
mean_xi = mean(xi);
mean_yi = mean(yi);
a1 = ((n.*sum_xiXyi) - (sum_xi.*sum_yi)) ./ ((n.*sum_xiSquared) - (sum_xi).^2);
a0 = mean_yi - (a1.*mean_xi);
linAnswer = a0 + a1.*xi;
n = length(yi);
neg_Sr = sum((yi - linAnswer).^2);
neg_St = sum((yi - mean(yi)).^2);
neg_R2 = ((neg_St - neg_Sr)./(neg_St));
neg_SE = sqrt(neg_Sr./(n-2));
disp('Negotiator:');
disp('sum of residuals');
disp(neg_Sr);
disp('standard error');
disp(neg_SE);
disp('st');
disp(neg_St);
disp('r squared');
disp(neg_R2);
end
function med_fit = SGRModel(num_month, Med_obs)
n = length(num_month);
inv_n = n.^(-1);
inv_Med_obs = sum((1./Med_obs));
inv_num_month = sum(1./num_month);
inv_num_month_2 = sum((1./num_month).^2);
inv_num_month_Med_obs = sum((1./Med_obs).*(1./num_month));
mean_Med_obs = inv_n .* sum(Med_obs);
a0 = (inv_n.*inv_Med_obs.*inv_num_month_2 - inv_n.*inv_num_month.*inv_num_month_Med_obs)./(inv_num_month_2 - inv_n.*inv_num_month.*inv_num_month);
a1 = ((inv_num_month_Med_obs) - (inv_n.*inv_num_month.*inv_Med_obs))/(inv_num_month_2-(inv_n.*inv_num_month.*inv_num_month));
a = 1./a0;
b = a1.*a;
med_fit = a .* (num_month./(num_month+b));
med_Sres = sum((Med_obs - med_fit).^2);
med_SStot = sum((med_fit - mean_Med_obs).^2);
med_R2 = ((med_SStot - med_Sres)./(med_SStot));
med_SE = sqrt(med_Sres./(n-2));
disp('Mediator:');
disp('Sum of squares residual');
disp(med_Sres);
disp('Sum of squares total');
disp(med_SStot);
disp('R^2');
disp(med_R2);
disp('Mediator SE');
disp(med_SE);
end
function arb_fit = sinusoidal(num_month, Arb_obs)
n = length(num_month);
A0 = mean(Arb_obs, 'all');
peaks = find(Arb_obs > 25.5);
avgHeight = mean(Arb_obs(peaks));
C1 = avgHeight - A0;
T = mean(num_month((peaks(length(peaks)) - peaks(length(peaks)-1))), num_month(peaks(length(peaks)-1) - peaks(length(peaks)-2)));
w0 = (2.*pi)./T;
theta = T - 2 * num_month(peaks(1,1));
A1 = C1.*(cos(theta));
B1 = -C1.*(sin(theta));
arb_fit = A0 + A1.*cos(w0.*num_month) + B1*(sin(w0.*num_month));
arb_Sres = sum((Arb_obs - arb_fit).^2);
arb_SStot = sum((arb_fit - A0).^2);
arb_R2 = ((arb_SStot - arb_Sres)./(arb_SStot));
arb_SE = sqrt(arb_Sres./(n-2));
disp('arbitration SSR');
disp(arb_Sres);
disp('St');
disp(arb_SStot);
disp('R2');
disp(arb_R2);
disp('se');
disp(arb_SE);
end
%% Euler's Method for Model 2
function simulation = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit)
step = 1;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
for month = 1:1:(runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))) + neg_fit(month, 1))*step;
Mt(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))) + med_fit(month, 1))*step;
At(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))) + arb_fit(month, 1))*step;
end
simulation = [Nt Mt At];
end
%% Heun's Method for Model 2
function higherOrder = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit)
step = 1;
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
month = 1;
while (month <= runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))) + neg_fit(month, 1))*step;
Mt(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))) + med_fit(month, 1))*step;
At(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))) + arb_fit(month, 1))*step;
Nt(month + 1, 1) = Nt(month, 1) + (((((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) -...
(a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))) + neg_fit(month, 1)))+(((k / P_tot) * ...
((n_NA*Nt(month + 1, 1)*At(month + 1, 1)) + (n_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) - (a_NA*Nt(month + 1, 1)*At(month + 1, 1))...
- (m_NM*Nt(month + 1, 1)*Mt(month + 1, 1))) + neg_fit(month, 1))))./2).*step;
Mt(month + 1, 1) = Mt(month, 1) + (((((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - ...
(n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))) + med_fit(month, 1)))+(((k / P_tot) * ...
((m_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) + (m_MA*Mt(month + 1, 1)*At(month + 1, 1)) - (n_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) -...
(a_MA*Mt(month + 1, 1)*At(month + 1, 1))) + med_fit(month, 1))))./2).*step;
At(month + 1, 1) = At(month, 1) + (((((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) -...
(n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))) + arb_fit(month, 1)))+(((k / P_tot) * ...
((a_NA*Nt(month + 1, 1)*At(month + 1, 1)) + (a_MA*Mt(month + 1, 1)*At(month + 1, 1)) - (n_NA*Nt(month + 1, 1)*At(month + 1, 1)) -...
(m_MA*Mt(month + 1, 1)*At(month + 1, 1))) + arb_fit(month, 1))))./2).*step;
month = month + 1;
end
higherOrder = [Nt Mt At];
end
The refugee camp managers must ensure they have sufficient funding for every member of the camp. Monthly cost per person varies monthly due to changes in demand for water and electricity. The table below provides monthly cost estimates:
Table 2: Monthly cost estimates
First, the monthly operating costs over the duration of 100 months was plotted, as shown in Figure 26 in the results section. Next, the monthly operating cost was calculated by each scenario.
The total cost over time T is calculated using the integral below:
The total cost for each scenario was calculated through Simpson's Rule. One way to obtain an accurate estimate of an integral is to use the higher-order polynomials to connect the points. For example, if there is an extra point between f(a) and f(b), the three points can be connected with a parabola as shown below.
Figure 25
After integration and algebraic manipulation, the following formula results:
where h=(b-a)/2. This is known as Simpson's 1/3 rule. Simpson's 1/3 Rule was applied to find the total operating costs for the full 100 months for each scenario. The results are in Table 4 in the results section below.
We chose to use Simpson’s Rule as our numerical integration method due to the fact it is a more accurate estimate of an integral (compared to trapezoidal rule) because it uses a higher order polynomials to connect points.
The following sample calculation uses the total population and monthly cost at 0, 50, and 100 months for Scenario 1. The step size in this example is 50 months but in the numerical approach a step size of 1 month was used.
Costs associated with injuries and property damage are higher for some groups compared to others, as indicated in the table below.
Table 3: Additional monthly costs
Cost of Damage and Injuries depend on the Negotiator, Mediator and Arbitrator Populations and their respective unit costs.
Again, total cost from damage and injuries for each scenario was calculated using Simpson's Rule. This is shown in Table 5 in the results section below.
Again, we chose to use Simpson’s Rule as our numerical integration method due to the fact it is a more accurate estimate of an integral (compared to trapezoidal rule) because it uses a higher order polynomials to connect points.
The following sample calculation uses the total population and additional monthly costs at 0, 50, and 100 months for Scenario 1. The step size in this example is 50 months but in the numerical approach a step size of 1 month was used.
The following plot represents the monthly cost for each month of the simulation.
Figure 26: Monthly cost per month of the simulation
Next, the following three plots represent the monthly operating costs per month of the simulation for the 3 scenarios
Figure 27: Monthly cost per month for scenario 1
Figure 28: Monthly cost per month for scenario 2
Figure 29: Monthly cost per month for scenario 3
Finally, these three plots represent the costs of damages and injuries per month for each scenario.
Table 4: Total Operating Costs for 100 Months
Figure 30: Costs of damage and injury per month for scenario 1
Figure 31: Costs of damage and injury per month for scenario 2
Figure 32: Costs of damage and injury per month for scenario 3
Table 5: Total Additional Costs from Damage and Injuries
From the plots, it is evident that as time goes on and the population grows, the cost increases as well. However, it is hard to limit the size of the refugee camps as you want to help as many people as possible. It is interesting to note that the Negotiator Population is the most expensive, with damage and injury costs of $270 per person, compared to Mediators and Arbitrator populations with a cost of $70 per person. I would suggest the refugee camp leaders look into this discrepancy - why Negotiators exceed their peers in costs by $200, and try to fix what the problem is.
This could be formulated as an optimization function as a way to minimize costs. Constraints could be set on factors that would affect operating costs. For example, the amount of electricity used could be limited. However, a factor like water would be harder to limit as water is essential for a variety of things, such as hydration, hygiene, etc.
Other costs beyond this table may include resources such as food, water, clothing, and malaria nets. Refugee camp managers could use the models here for long term planning and decision making. Throughout the year, monthly costs fluctuate due to the fact demands for water and electricity vary seasonally. Looking ahead, they need to budget less for the summer months and more for the winter months.
Set up monthly cost array for 100 months
Establish population variables for each scenario
Calculate Monthly Operating Costs for each scenario
for i=1:100
monthlyOC=totalPop(i)*monthlyCost(i)
Plot number of months vs. Monthly Operating Cost
Using Simpson's Rule, Calculate Total Cost
Function Simp13m(h,n,f)
sum=f(0)
DOFOR i=1,n-2,2
sum=sum+4*f(i)+2*f(i+1)
END DO
sum=sum+4*f(n-1)+f(n)
Simp13m=h*sum/3
END Simp13m
Introduce Additional Monthly Cost Variables
Calculate Damage and Injury for Each Scenario
for i=1:100
DamageInjuryNeg=HeunsNegotiators(i)*NegotiatorCosts
Plot DamageInjury Negotiators, Mediators, Arbitrators vs. number of months
Calculate Total Cost from Damage and Injury Using Simpson's Rule
%% Part 4
% Set Up Monthly Cost array for 100 months
monthlyCost=[400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375; 300; 290; 325; 340; 345; 370; 395; 410;
400; 450; 475; 375];
% Plot 100 months vs. monthly cost
figure(1)
plot(num_month, monthlyCost,'linewidth', 2)
xlabel("Months");
ylabel("Cost ($)");
title("Monthly Cost")
grid on
box on
set(gca, 'FontSize', 14);
%Establish population variables
for i=1:100
totalPop1(i)=Heuns1Nt(i)+Heuns1Mt(i)+Heuns1At(i); %Scenario 1
totalPop2(i)=Heuns2Nt(i)+Heuns2Mt(i)+Heuns2At(i); %Scenario 2
% totalPop3(i)=Heuns3Nt(i)+Heuns3Mt(i)+Heuns3At(i); %Scenario 3
totalPop4(i)=Heuns4Nt(i)+Heuns4Mt(i)+Heuns4At(i); %Scenario 4
end
% Calculate Monthly Operating Costs for Four Scenarios
for i=1:100
monthlyOC1(i)=totalPop1(i)*monthlyCost(i);
monthlyOC2(i)=totalPop2(i)*monthlyCost(i);
% monthlyOC3(i)=totalPop3(i)*monthlyCost(i);
monthlyOC4(i)=totalPop4(i)*monthlyCost(i);
end
%Scenario 1
figure(2)
plot(num_month,monthlyOC1,'linewidth', 2)
xlabel("Months");
ylabel("Monthly Cost");
title("Scenario 1 Monthly Operating Cost");
grid on
box on
set(gca, 'FontSize', 14);
%Scenario 2
figure(3)
plot(num_month,monthlyOC2,'linewidth', 2)
xlabel("Months");
ylabel("Monthly Cost");
title("Scenario 2 Monthly Operating Cost");
grid on
box on
set(gca, 'FontSize', 14);
%Scenario 3
%figure(4)
%plot(num_month,monthlyOC3)
%xlabel("Months");
%ylabel("Monthly Cost");
%title("Scenario 3");
%Scenario 4
figure(5)
plot(num_month,monthlyOC4,'linewidth', 2)
xlabel("Months");
ylabel("Monthly Cost");
title("Scenario 3 Monthly Operating Cost");
grid on
box on
set(gca, 'FontSize', 14);
% Calculate total cost
totalCost1=Simpson13(1,100,monthlyOC1)
totalCost2=Simpson13(1,100,monthlyOC2)
%totalCost3=Simpson13(1,100,monthlyOC3)
totalCost4=Simpson13(1,100,monthlyOC4)
% Now Introduce Additional Monthly Costs
NegotiatorCosts=150+120;
MediatorCosts=45+25;
ArbitratorCosts=20+50;
%damage and injury negotiators
for i=1:100
DINeg1(i)=Heuns1Nt(i).*NegotiatorCosts;
DINeg2(i)=Heuns2Nt(i).*NegotiatorCosts;
% DINeg3(i)=Heuns3Nt(i).*NegotiatorCosts;
DINeg4(i)=Heuns4Nt(i).*NegotiatorCosts;
end
%damage and injury mediators
for i=1:100
DIMed1(i)=Heuns1Mt(i).*MediatorCosts;
DIMed2(i)=Heuns2Mt(i).*MediatorCosts;
% DIMed3(i)=Heuns3Mt(i).*MediatorCosts;
DIMed4(i)=Heuns4Mt(i).*MediatorCosts;
end
%damage and injury arbitrators
for i=1:100
DIArb1(i)=Heuns1At(i).*ArbitratorCosts;
DIArb2(i)=Heuns2At(i).*ArbitratorCosts;
% DIArb3(i)=Heuns3At(i).*ArbitratorCosts;
DIArb4(i)=Heuns4At(i).*ArbitratorCosts;
end
%Scenario 1 Costs
figure(6)
plot(num_month,DINeg1,'Color', [0.8 0.7 0.9], 'linewidth', 2)
hold on
plot(num_month,DIMed1,'Color', [0.5 0.7 0.9], 'linewidth', 2)
hold on
plot(num_month,DIArb1,'Color', [0.5 0.8 0.4], 'linewidth', 2)
grid on
box on
title('Scenario 1 Damage& Injury Costs');
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Costs($)');
xlabel('Months');
set(gca, 'FontSize', 14);
%Scenario 2 Costs
figure(7)
plot(num_month,DINeg2,'Color', [0.8 0.7 0.9], 'linewidth', 2)
hold on
plot(num_month,DIMed2,'Color', [0.5 0.7 0.9], 'linewidth', 2)
hold on
plot(num_month,DIArb2,'Color', [0.5 0.8 0.4], 'linewidth', 2)
grid on
box on
title('Scenario 2 Damage & Injury Costs');
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Costs ($)');
xlabel('Months');
set(gca, 'FontSize', 14);
%Scenario 3 Costs
%figure(8)
%plot(num_month,DINeg3,'Color', [0.8 0.7 0.9], 'linewidth', 2)
%hold on
%plot(num_month,DIMed3,'Color', [0.5 0.7 0.9], 'linewidth', 2)
%hold on
%plot(num_month,DIArb3,'Color', [0.5 0.8 0.4], 'linewidth', 2)
%grid on
%box on
%title('Scenario 3 Damage & Injury Costs');
%legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
%ylabel('Costs ($)');
%xlabel('Months');
%set(gca, 'FontSize', 14);
%Scenario 4 Costs
figure(9)
plot(num_month,DINeg4,'Color', [0.8 0.7 0.9], 'linewidth', 2)
hold on
plot(num_month,DIMed4,'Color', [0.5 0.7 0.9], 'linewidth', 2)
hold on
plot(num_month,DIArb4,'Color', [0.5 0.8 0.4], 'linewidth', 2)
grid on
box on
title('Scenario 3 Damage & Injury Costs');
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Costs ($)');
xlabel('Months');
set(gca, 'FontSize', 14);
%Combine New Costs By Scenarios
for i=1:100
DIScenario1(i)=DINeg1(i)+DIMed1(i)+DIArb1(i);
DIScenario2(i)=DINeg2(i)+DIMed2(i)+DIArb2(i);
% DIScenario3(i)=DINeg3(i)+DIMed3(i)+DIArb3(i)
DIScenario4(i)=DINeg4(i)+DIMed4(i)+DIArb4(i);
end
% Calculate Total Cost from Damage and Injuries Using Simpsons
DITotalCost1=Simpson13(1,100,DIScenario1)
DITotalCost2=Simpson13(1,100,DIScenario2)
%DITotalCost3=Simpson13(1,100,DIScenario3)
DITotalCost4=Simpson13(1,100,DIScenario4)
% Simpson Rule Function
function Simp13m = Simpson13(h, n, f)
sum = 0;
for i = 1:n - 2:2
sum = sum + 4 * f(i) + (2 * f(i + 1));
end
sum = sum + 4 * f(n-1) + f(n);
Simp13m = h * sum / 3;
end
For the alternative approach of this project, we have decided to discuss the affect of malaria on the population of each dispute resolution strategies. We can assume that people in the camps that have malaria either leave the camp to get medical attention or stay in the camp and do not participate in dispute. Either way, the population of strategists that are actively taking part in using their resolution strategies will decrease with increasing malaria patients. Due to the lack of resources in the camp, we observe an increasing amount of people with malaria over time. Therefore, we have created a hypothetical observation of outgoing population in the camps as seen in the three plots below. These plots have been fitted with a linear model. We took into consideration the percentage of people within Ugandan refugee camps that have malaria. [4] The value comes out to be about 31% of the population. This is reflected in our data as we created the outgoing population from taking about a third of the incoming population.
Figure 33: Outgoing negotiators observed
Figure 34: Outgoing Mediators observed
Figure 35: Outgoing Arbitrators Observed
Now, in order to implement this new parameter in our model, we need to negate the linear fits observed and consider this in our approximations. Since we have seen Heun's to be a more accurate approximation, we will use this approximation to model our data. First, we can take our model 3 to be the following.
Now, we implement Heun's approximation as follows.
Below is a sample calculation using Heun's approximation for model 3. We start by finding the predictor values as follows.
Finally, we use the second part of Heun's Method to approximate our value for month 2 in the simulation.
The following pseudocode allows us to iterate through the entire simulation and obtain the results that are seen later in this section. Note that the linear fit pseudocode was already given in part 2 of this assignment. This same process was used to fit a curve to the outgoing population data.
FUNCTION myApprox = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot)
step = 1; % Step size is 1 month
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
month = 1;
WHILE (month <= runTime - 1)
PNt(month + 1, 1) = Nt(month, 1) + ((Nt' (month) + curveFit)* step)
PMt(month + 1, 1) = Mt(month, 1) + ((Mt ' (month) + curveFit) * step)
PAt(month + 1, 1) = At(month, 1) + ((At ' (month) + curveFit) * step)
Nt(month + 1, 1) = Nt(month, 1) + (((f ' (month)+ f ' (PNt(month + 1, 1) + incoming - outgoing))/2) * step) % Implement Heun's Method for Nt
Mt(month + 1, 1) = Mt(month, 1) + (((f ' (month)+ f ' (PMt(month + 1, 1) + incoming - outgoing))/2) * step) % Implement Heun's Method for Mt
At(month + 1, 1) = At(month, 1) + (((f ' (month)+ f ' (PAt(month + 1, 1) + incoming - outgoing)/2) * step) % Implement Heun's Method for At
month++
END
myApprox = [Nt Mt At];
END
Below are the figures that we obtain from implementing Heun's approximation on the data.
Figure 36: Alternative approach for scenario 1 using Heun's method
Figure 37: Alternative approach for scenario 2 using Heun's method
Figure 38: Alternative approach for scenario 3 using Heun's method
Though we are able to simulate a simple version of this model, it might not be the case that the outgoing population is linear. A lot of research would need to be conducted to model the raw data of the outgoing population due to malaria cases. Also, we make assumptions in this approach including that all people with malaria are no longer involved in the populations of resolution strategies. This would not necessarily be the case depending on the severity of their situations. Further, there are other reasons why refugees would leave the camps. These are all parameters we would need to consider to properly perform this analysis. With the resources available to us, however, we could only conduct the approach to a certin extent.
A topic that we talk about continuously in this course is character virtue. We have discussed many character virtues inluding creativity, practical wisdom, intellectual humility, curiosity, and resiliance. In creating conflict resolution, we would conclude that the three most important character virtues to exhibit in the process would be creativity, intellectual humility, and practical wisdom.
First, creativity must be exhibited when working to model dispute resolution strategies because an engineer must think about and come up with scenarios and the affects external variables have on population. Without creativity, only a portion of these variables would be considered and the model would not reflect the reality of the situation. Next, the engineers working with the dispute resolution strategy models would need to exhibit intellectual humility. This character virtue involves the recognition of being wrong and understanding what they could do to improve their work or iterate their solutions. Without this virtue, the engineer would not conduct a thorough iteration process, resulting in an inaccurate model. Lastly, practical wisdom involves engineers applying their work to areas which would benefit the population being affected. Since modelling and working with dispute resolution strategies involve working with people, it is especially important in this situation to exhibit practical wisdom. Without practical wisdom, the engineer would not properly consider the affect of their work on the population in question. In turn, their work would not be beneficial for the population, which would make their involvement in the project pointless.
In this project, we attempted to exhibit these three character virtues. If we had not exhibited curiousity, we would not have considered the correct parameters in creating the different scenarios. Without exhibiting intellectual humility, we would not have admitted to mistakes and improved our work, which would have resulted in mistakes in our work. Lastly, without exhibiting practical wisdom, we would have not been able to consider aspects of the strategies and the populations that are necessary in modelling the resolutions. Overall, our work would have been inaccurate and useless since we would lack these vital aspects.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EGR 312 Final - Alternative Approach Curve Fitting
% Katherine Reiss and Bridget Barsanti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Setup
clear all;
clc;
%% Load data
load PopulationGrowth.mat;
%% Manipulating data to create outgoing data
malariaCases = 35823 / 115215;
Med_obs2 = (Neg_obs .* malariaCases);
Arb_obs2 = (Neg_obs .* malariaCases);
Neg_obs2 = (Neg_obs .* malariaCases);
Arb_obs = linearModel(num_month, Arb_obs2);
Med_obs = linearModel(num_month, Med_obs2);
Neg_obs = linearModel(num_month, Neg_obs2);
%% Plotting Raw Data
figure(1)
plot(num_month, Arb_obs, '*', 'Color', [0.5 0.8 0.4]);
title('Outgoing Arbitrators Observed');
ylabel('Outgoing Population');
xlabel('Months Passed');
grid on
box on
set(gca, 'FontSize', 16);
arb_fit = linearModel(num_month, Arb_obs);
hold on
plot(num_month, arb_fit, 'k', 'linewidth', 1.2);
legend('Raw Data', 'Linear Model');
figure(2)
plot(num_month, Med_obs, '*', 'Color', [0.5 0.7 0.9]);
title('Outgoing Mediators Observed');
ylabel('Outgoing Population');
xlabel('Months Passed');
grid on
box on
set(gca, 'FontSize', 16);
med_fit = linearModel(num_month, Med_obs);
hold on
plot(num_month, med_fit, 'k', 'linewidth', 1.2);
legend('Raw Data', 'Linear Model');
figure(3)
plot(num_month, Neg_obs, '*', 'Color', [0.8 0.7 0.9]);
title('Outgoing Negotiators Observed');
ylabel('Outgoing Population');
xlabel('Months Passed');
grid on
box on
set(gca, 'FontSize', 16);
neg_fit = linearModel(num_month, Neg_obs); % linear fit
hold on
plot(num_month, neg_fit, 'k', 'linewidth', 1.2);
legend('Raw Data', 'Linear Model');
%% Linear Model
function linAnswer = linearModel(xi, yi)
n = length(xi);
sum_xi = sum(xi);
sum_yi = sum(yi);
sum_xiXyi = sum(xi.*yi);
sum_xiSquared = sum(xi.^2);
mean_xi = mean(xi);
mean_yi = mean(yi);
a1 = ((n.*sum_xiXyi) - (sum_xi.*sum_yi)) ./ ((n.*sum_xiSquared) - (sum_xi).^2);
a0 = mean_yi - (a1.*mean_xi);
linAnswer = a0 + a1.*xi;
n = length(yi);
neg_Sr = sum((yi - linAnswer))^2;
disp('Negotiation sum of square of residuals');
disp(neg_Sr);
neg_SE = sqrt(neg_Sr./(n-2));
disp('Negotiation Standard Error');
disp(neg_SE);
neg_St = sum((yi - mean(yi)))^2;
disp('Negotiation St');
disp(neg_St);
neg_R2 = (neg_St - neg_Sr) ./ neg_St;
disp('Negotiation R2');
disp(neg_R2);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EGR 312 Final: Alternative Approach
% Katherine Reiss and Bridget Barsanti
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all;
clc;
%% Load data
load PopulationGrowth.mat;
malariaCases = 35823 / 115215; % from reference [4]
%% Curve fitting
arb_fit = sinusoidal(num_month, Arb_obs);
med_fit = SGRModel(num_month, Med_obs);
neg_fit = linearModel(num_month, Neg_obs);
Med_obs2 = -(Neg_obs .* malariaCases);
Arb_obs2 = -(Neg_obs .* malariaCases);
Neg_obs2 = -(Neg_obs .* malariaCases);
arb_fit2 = linearModel(num_month, Arb_obs2);
med_fit2 = linearModel(num_month, Med_obs2);
neg_fit2 = linearModel(num_month, Neg_obs2);
%% Parameters
NtFirst = 500; % population that prefers the negotiation strategy at time 1
AtFirst = 500; % population that prefers the arbitration strategy at time 1
MtFirst = 500; % population that prefers the mediation strategy at time 1
P_tot = 1500; % total population
k = 0.5;
runTime = 100; % How long this simulation will go for (in months)
months = 1:1:runTime;
%% Scenario 1
%% PLOTTING HEUN'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns1 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2);
Heuns1Nt = Heuns1(:, 1);
Heuns1Mt = Heuns1(:, 2);
Heuns1At = Heuns1(:, 3);
figure(1)
plot(months, Heuns1Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns1At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 1 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns2 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2);
Heuns2Nt = Heuns2(:, 1);
Heuns2Mt = Heuns2(:, 2);
Heuns2At = Heuns2(:, 3);
figure(2)
plot(months, Heuns2Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns2At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 2 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Heuns4 = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2);
Heuns4Nt = Heuns4(:, 1);
Heuns4Mt = Heuns4(:, 2);
Heuns4At = Heuns4(:, 3);
figure(3)
plot(months, Heuns4Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Heuns4At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 3 using Heun Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% PLOTTING EULER'S %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Scenario 1
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.4; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.6; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.65; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.35; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler1 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2);
Euler1Nt = Euler1(:, 1);
Euler1Mt = Euler1(:, 2);
Euler1At = Euler1(:, 3);
figure(4)
plot(months, Euler1Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler1At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 1 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 2
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.55; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.45; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.55; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.45; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler2 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2);
Euler2Nt = Euler2(:, 1);
Euler2Mt = Euler2(:, 2);
Euler2At = Euler2(:, 3);
figure(5)
plot(months, Euler2Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler2At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 2 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% Scenario 3
n_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with negotiation
a_NA = 0.5; % fraction of disputes between negotiators and arbitrators resolved with arbitration
n_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with negotiation
m_NM = 0.5; % fraction of disputes between negotiators and mediators resolved with mediation
a_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with arbitration
m_MA = 0.5; % fraction of disputes between mediators and arbitrators resolved with mediation
Euler4 = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2);
Euler4Nt = Euler4(:, 1);
Euler4Mt = Euler4(:, 2);
Euler4At = Euler4(:, 3);
figure(6)
plot(months, Euler4Nt, 'Color', [0.8 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4Mt, 'Color', [0.5 0.7 0.9], 'linewidth', 2);
hold on
plot(months, Euler4At, 'Color', [0.5 0.8 0.4], 'linewidth', 2);
hold on
title(["Refugee Preferences of Resolution Strategies over Time","for Scenario 3 using Euler Approximation"])
legend('Negotiation Strategy', 'Mediation Strategy', 'Arbitration Strategy');
ylabel('Population');
xlabel('Months');
grid on
box on
set(gca, 'FontSize', 14);
%% FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function linAnswer = linearModel(xi, yi)
n = length(xi);
sum_xi = sum(xi);
sum_yi = sum(yi);
sum_xiXyi = sum(xi.*yi);
sum_xiSquared = sum(xi.^2);
mean_xi = mean(xi);
mean_yi = mean(yi);
a1 = ((n.*sum_xiXyi) - (sum_xi.*sum_yi)) ./ ((n.*sum_xiSquared) - (sum_xi).^2);
a0 = mean_yi - (a1.*mean_xi);
linAnswer = a0 + a1.*xi;
end
function med_fit = SGRModel(num_month, Med_obs)
n = length(num_month);
inv_n = n.^(-1);
inv_Med_obs = sum((1./Med_obs));
inv_num_month = sum(1./num_month);
inv_num_month_2 = sum((1./num_month).^2);
inv_num_month_Med_obs = sum((1./Med_obs).*(1./num_month));
mean_Med_obs = inv_n .* sum(Med_obs);
a0 = (inv_n.*inv_Med_obs.*inv_num_month_2 - inv_n.*inv_num_month.*inv_num_month_Med_obs)./(inv_num_month_2 - inv_n.*inv_num_month.*inv_num_month);
a1 = ((inv_num_month_Med_obs) - (inv_n.*inv_num_month.*inv_Med_obs))/(inv_num_month_2-(inv_n.*inv_num_month.*inv_num_month));
a = 1./a0;
b = a1.*a;
med_fit = a .* (num_month./(num_month+b));
end
function arb_fit = sinusoidal(num_month, Arb_obs)
A0 = mean(Arb_obs, 'all');
peaks = find(Arb_obs > -4);
avgHeight = mean(Arb_obs(peaks));
C1 = avgHeight - A0;
T = 37;
w0 = (2.*pi)./T;
theta = T - 2 * num_month(peaks(1,1));
A1 = C1.*(cos(theta));
B1 = -C1.*(sin(theta));
arb_fit = A0 + A1.*cos(w0.*num_month) + B1*(sin(w0.*num_month));
end
%% Euler's Method for Model 2
function simulation = Eulers(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2)
step = 1;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
for month = 1:1:(runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))) + neg_fit(month, 1) + neg_fit2(month, 1))*step;
Mt(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))) + med_fit(month, 1) + med_fit2(month, 1))*step;
At(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))) + arb_fit(month, 1) + arb_fit2(month, 1))*step;
end
simulation = [Nt Mt At];
end
%% Heun's Method for Model 2
function higherOrder = Heuns(NtFirst, AtFirst, MtFirst, n_NA, a_NA, n_NM, m_NM, a_MA, m_MA, runTime, k, P_tot, arb_fit, med_fit, neg_fit, arb_fit2, med_fit2, neg_fit2)
step = 1;
NtP = zeros(runTime, 1);
MtP = zeros(runTime, 1);
AtP = zeros(runTime, 1);
NtP(1, 1) = NtFirst;
MtP(1, 1) = MtFirst;
AtP(1, 1) = AtFirst;
Nt = zeros(runTime, 1);
Mt = zeros(runTime, 1);
At = zeros(runTime, 1);
Nt(1, 1) = NtFirst;
Mt(1, 1) = MtFirst;
At(1, 1) = AtFirst;
month = 1;
while (month <= runTime - 1)
Nt(month + 1, 1) = Nt(month, 1) + ((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))) + neg_fit(month, 1) + neg_fit2(month, 1))*step;
Mt(month + 1, 1) = Mt(month, 1) + ((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - (n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))) + med_fit(month, 1) + med_fit2(month, 1))*step;
At(month + 1, 1) = At(month, 1) + ((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) - (n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))) + arb_fit(month, 1) + arb_fit2(month, 1))*step;
Nt(month + 1, 1) = Nt(month, 1) + (((((k / P_tot) * ((n_NA*Nt(month, 1)*At(month, 1)) + (n_NM*Nt(month, 1)*Mt(month, 1)) -...
(a_NA*Nt(month, 1)*At(month, 1)) - (m_NM*Nt(month, 1)*Mt(month, 1))) + neg_fit(month, 1) + neg_fit2(month, 1)))+(((k / P_tot) * ...
((n_NA*Nt(month + 1, 1)*At(month + 1, 1)) + (n_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) - (a_NA*Nt(month + 1, 1)*At(month + 1, 1))...
- (m_NM*Nt(month + 1, 1)*Mt(month + 1, 1))) + neg_fit(month, 1) + neg_fit2(month, 1))))./2).*step;
Mt(month + 1, 1) = Mt(month, 1) + (((((k / P_tot) * ((m_NM*Nt(month, 1)*Mt(month, 1)) + (m_MA*Mt(month, 1)*At(month, 1)) - ...
(n_NM*Nt(month, 1)*Mt(month, 1)) - (a_MA*Mt(month, 1)*At(month, 1))) + med_fit(month, 1) + med_fit2(month, 1)))+(((k / P_tot) * ...
((m_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) + (m_MA*Mt(month + 1, 1)*At(month + 1, 1)) - (n_NM*Nt(month + 1, 1)*Mt(month + 1, 1)) -...
(a_MA*Mt(month + 1, 1)*At(month + 1, 1))) + med_fit(month, 1) + med_fit2(month, 1))))./2).*step;
At(month + 1, 1) = At(month, 1) + (((((k / P_tot) * ((a_NA*Nt(month, 1)*At(month, 1)) + (a_MA*Mt(month, 1)*At(month, 1)) -...
(n_NA*Nt(month, 1)*At(month, 1)) - (m_MA*Mt(month, 1)*At(month, 1))) + arb_fit(month, 1) + arb_fit2(month, 1)))+(((k / P_tot) * ...
((a_NA*Nt(month + 1, 1)*At(month + 1, 1)) + (a_MA*Mt(month + 1, 1)*At(month + 1, 1)) - (n_NA*Nt(month + 1, 1)*At(month + 1, 1)) -...
(m_MA*Mt(month + 1, 1)*At(month + 1, 1))) + arb_fit(month, 1) + arb_fit2(month, 1))))./2).*step;
month = month + 1;
end
higherOrder = [Nt Mt At];
end
[1] “In Uganda, a Refugee Camp Becomes a City.” n.d. The World from PRX. Accessed April 27, 2021. https://www.pri.org/stories/2019-05-09/uganda-refugee-camp-becomes-city.
[2] Professor Henslee's Class Slides
[3] “NON-LINEAR REGRESSION SATURATION GROWTH CURVE.” n.d., 2.
[4] “4afaccca9.Pdf,” accessed May 14, 2021, https://www.unhcr.org/en-my/4afaccca9.pdf.
[5] EGR 312 Final Project Handout