diff --git a/ContinuousCode/3_Data4DM/Capability trap - Brad_V4_Ross-test.2mdl b/ContinuousCode/3_Data4DM/Capability trap - Brad_V4_Ross-test.2mdl new file mode 100644 index 0000000..9fd0cc0 --- /dev/null +++ b/ContinuousCode/3_Data4DM/Capability trap - Brad_V4_Ross-test.2mdl @@ -0,0 +1,339 @@ +{UTF-8} +Resources to Production IC= + 1400 + ~ hours/Week [0,4000,80] + ~ | + +Process Problems IC= + 0.4 + ~ [0,0.98,0.02] + ~ | + +Problem Introduction= + (Unattended Process Problem Level-Process Problems)/Avg Process Erosion Time + ~ + ~ 0.4/16*0.625*(Process Problems/0.4)^alpha + | + +alpha= + 1 + ~ [0,1,0.1] + ~ | + +additional desired throughput= + 300 + ~ [200,500,10] + ~ | + +Indicated Allocation to Production= + max(0,min(Available Time,Resource Gap+Resources to Production+pulse(time to impliment measure\ + ,shock duration)*Policy measure)) + ~ + ~ How many hours do you need to update production to fufill throughput gap + | + +shock duration= + 0 + ~ [0,100,4] + ~ | + +Policy measure= + 0 + ~ [-4000,0,100] + ~ | + +Resources to Improve Process= + Available Time-Resources to Production + ~ + ~ | + +time to impliment measure= + 0 + ~ [0,200,5] + ~ | + +Adjusting Allocation= + (Indicated Allocation to Production-Resources to Production)/Time to Adjust Allocation + ~ + ~ | + +Available Time= + 4000 + ~ hours/Week + ~ | + +Avg Process Erosion Time= + 32 + ~ Week + ~ | + +Defect Introduction= + Process Problems*Gross Process Throughput + ~ units/Week + ~ | + +Desired Throughput= + 900+additional desired throughput + ~ units/Week [300,1800,20] + ~ 900*1.2 + 900+STEP(180, 10 ) + 900+STEP(additional desired throughput,40) + | + +Gross Process Throughput= + Resources to Production*Productivity of Production Time + ~ units/Week + ~ | + +Net Process Throughput= + Gross Process Throughput-Defect Introduction + ~ units/Week + ~ | + +Net Productivity of Production Time= + Productivity of Production Time*(1-Process Problems) + ~ units/hour + ~ How much of the time are you being productive + | + +Problem Correction= + Problem Correction Effectiveness*(Process Problems/Time to Correct Problems) + ~ + ~ | + +Problem Correction Effectiveness= + Resources to Improve Process/Resources for Maximum Problem Correction + ~ + ~ | + +Process Problems= INTEG ( + min(1,Problem Introduction-Problem Correction), + Process Problems IC) + ~ units + ~ Dimensionless index from 0 to 1 + | + +Productivity of Production Time= + 1 + ~ units/hour + ~ | + +Resource Gap= + Throughput Gap/Net Productivity of Production Time + ~ hour/Week + ~ How many more hours would you really need to close throughput gap + | + +Resources for Maximum Problem Correction= + 4000 + ~ hours/Week + ~ | + +Resources to Production= INTEG ( + Adjusting Allocation, + Resources to Production IC + ) + ~ hours/Week + ~ | + +Throughput Gap= + Desired Throughput-Net Process Throughput + ~ units/Week + ~ | + +Time to Adjust Allocation= + 12 + ~ Week [1,12,1] + ~ | + +Time to Correct Problems= + 16 + ~ Week + ~ | + +Unattended Process Problem Level= + 0.9 + ~ + ~ | + +******************************************************** + .Control +********************************************************~ + Simulation Control Parameters + | + +FINAL TIME= + 500 + ~ Week + ~ The final time for the simulation. + | + +INITIAL TIME = 0 + ~ Week + ~ The initial time for the simulation. + | + +SAVEPER = + TIME STEP + ~ Week [0,?] + ~ The frequency with which output is stored. + | + +TIME STEP = 0.25 + ~ Week [0,?] + ~ The time step for the simulation. + | + +\\\---/// Sketch information - do not modify anything except names +V300 Do not put anything below this section - it will be ignored +*View 1 +$-1--1--1,0,|12||-1--1--1|-1--1--1|-1--1--1|-1--1--1|-1--1--1|96,96,100,0 +10,1,Process Problems,403,186,43,23,3,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +12,2,48,180,187,10,8,0,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,3,5,2,100,0,0,22,0,192,0,-1--1--1,,1|(229,187)| +1,4,5,1,4,0,0,22,0,192,0,-1--1--1,,1|(320,187)| +11,5,0,275,187,6,8,34,3,0,2,1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +10,6,Problem Introduction,275,218,58,23,40,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +12,7,48,624,186,10,8,0,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,8,10,1,100,0,0,22,0,192,0,-1--1--1,,1|(485,186)| +1,9,10,7,4,0,0,22,0,192,0,-1--1--1,,1|(575,186)| +11,10,0,530,186,6,8,34,3,0,2,1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +10,11,Problem Correction,530,217,49,23,40,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +10,12,Time to Correct Problems,646,141,50,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +10,13,Avg Process Erosion Time,187,97,69,23,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +10,14,Unattended Process Problem Level,123,259,73,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||255-128-0,0,0,0,0,0,0 +10,15,Defect Introduction,799,263,60,23,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,16,Productivity of Production Time,538,312,73,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,17,Gross Process Throughput,685,337,58,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,18,Net Process Throughput,798,435,64,23,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,19,Throughput Gap,758,546,58,23,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,20,Desired Throughput,883,499,58,23,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,21,Net Productivity of Production Time,744,650,80,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,22,Resource Gap,610,586,50,23,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,23,Indicated Allocation to Production,439,597,63,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,24,Time to Adjust Allocation,279,554,51,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,25,Available Time,149,590,47,23,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +10,26,Resources to Improve Process,360,386,56,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||0-128-64,0,0,0,0,0,0 +10,27,Problem Correction Effectiveness,381,283,69,31,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||0-128-64,0,0,0,0,0,0 +10,28,Resources for Maximum Problem Correction,182,342,72,40,8,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||0-128-64,0,0,0,0,0,0 +1,29,12,10,1,0,0,0,0,192,0,-1--1--1,,1|(566,143)| +1,30,28,27,1,0,0,0,0,192,0,-1--1--1,,1|(298,286)| +1,31,26,27,1,0,0,0,0,192,0,-1--1--1,,1|(368,334)| +1,32,25,26,1,0,0,0,0,192,0,-1--1--1,,1|(200,479)| +10,33,Resources to Production,496,478,56,31,3,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +12,34,48,333,476,10,8,0,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,35,37,34,100,0,0,22,0,192,0,-1--1--1,,1|(364,476)| +1,36,37,33,4,0,0,22,0,192,0,-1--1--1,,1|(418,476)| +11,37,0,391,476,6,8,34,3,0,2,1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +10,38,Adjusting Allocation,391,507,51,23,40,3,0,2,-1,0,0,0,0-0-0,0-0-0,|||128-0-0,0,0,0,0,0,0 +1,39,24,38,1,0,0,0,0,192,0,-1--1--1,,1|(334,501)| +1,40,23,38,1,0,0,0,0,192,0,-1--1--1,,1|(399,560)| +1,41,33,23,1,0,0,0,0,192,0,-1--1--1,,1|(517,553)| +1,42,22,23,1,0,0,0,0,192,0,-1--1--1,,1|(495,598)| +1,43,19,22,1,0,0,0,0,192,0,-1--1--1,,1|(696,567)| +1,44,21,22,1,0,0,0,0,192,0,-1--1--1,,1|(652,618)| +1,45,20,19,1,0,0,0,0,192,0,-1--1--1,,1|(813,546)| +1,46,18,19,1,0,0,0,0,192,0,-1--1--1,,1|(795,487)| +1,47,17,18,1,0,0,0,0,192,0,-1--1--1,,1|(775,357)| +1,48,15,18,1,0,0,0,0,192,0,-1--1--1,,1|(842,363)| +1,49,16,17,1,0,0,0,0,192,0,-1--1--1,,1|(615,334)| +1,50,33,17,1,0,0,0,0,192,0,-1--1--1,,1|(590,394)| +1,51,33,26,1,0,0,0,0,192,0,-1--1--1,,1|(423,386)| +1,52,27,11,1,0,0,0,0,192,0,-1--1--1,,1|(439,217)| +1,53,1,15,1,0,0,0,0,192,0,-1--1--1,,1|(540,70)| +1,54,33,37,1,0,0,0,0,192,0,-1--1--1,,1|(411,452)| +10,55,Productivity of Production Time,914,662,56,31,8,2,0,3,-1,0,0,0,128-128-128,0-0-0,|||128-128-128,0,0,0,0,0,0 +1,56,55,21,0,0,0,0,0,192,0,-1--1--1,,1|(0,0)| +10,57,Process Problems,905,584,56,22,8,2,0,3,-1,0,0,0,128-128-128,0-0-0,|||128-128-128,0,0,0,0,0,0 +1,58,57,21,0,0,0,0,0,192,0,-1--1--1,,1|(0,0)| +1,59,25,23,1,0,0,0,0,192,0,-1--1--1,,1|(251,610)| +1,60,17,15,1,0,0,0,0,64,0,-1--1--1,,1|(741,323)| +1,61,1,10,1,0,0,0,0,192,0,-1--1--1,,1|(482,153)| +12,62,0,1663,600,208,140,8,15,0,0,2,0,0,0,0,0,0,0,0,0 +Process Problems,Graph +12,63,0,1663,323,208,140,8,15,0,0,2,0,0,0,0,0,0,0,0,0 +Resources to Production,Graph +12,64,0,1248,601,208,140,8,15,0,0,2,0,0,0,0,0,0,0,0,0 +Net Process Throughput,Graph +12,65,0,1248,324,208,140,8,15,0,0,2,0,0,0,0,0,0,0,0,0 +Problem Correction,Graph +10,66,additional desired throughput,934,408,66,18,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,67,66,20,0,0,0,0,0,64,0,-1--1--1,,1|(0,0)| +10,68,FINAL TIME,982,88,41,22,8,2,0,3,-1,0,0,0,128-128-128,0-0-0,|||128-128-128,0,0,0,0,0,0 +10,69,Policy measure,507,708,45,23,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,70,69,23,0,0,0,0,0,192,0,-1--1--1,,1|(0,0)| +10,71,time to impliment measure,387,713,62,18,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,72,71,23,0,0,0,0,0,64,0,-1--1--1,,1|(0,0)| +10,73,shock duration,598,688,53,10,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,74,73,23,0,0,0,0,0,64,0,-1--1--1,,1|(0,0)| +1,75,1,5,1,0,0,0,0,192,0,-1--1--1,,1|(342,123)| +10,76,alpha,555,-97,21,10,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +10,77,Resources to Production IC,615,473,50,18,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,78,77,33,0,0,0,0,0,64,1,-1--1--1,,1|(0,0)| +10,79,Process Problems IC,405,72,46,18,8,3,0,0,-1,0,0,0,0,0,0,0,0,0 +1,80,79,1,0,0,0,0,0,64,1,-1--1--1,,1|(0,0)| +1,81,13,6,0,0,0,0,0,64,0,-1--1--1,,1|(0,0)| +1,82,14,6,0,0,0,0,0,64,0,-1--1--1,,1|(0,0)| +///---\\\ +:GRAPH Process_Problems +:TITLE Process_Problems +:SCALE +:VAR Process Problems + +:GRAPH Resources_to_Production +:TITLE Resources_to_Production +:SCALE +:VAR Resources to Production +:L<%^E!@ +1:currentvectorv1.vdfx +1:currentvectorv2.vdfx +4:Time +5:additional desired throughput +9:currentvectorv1 +19:100,0 +24:0 +25:2000 +26:2000 +60: +61:0 +62:0 +63:0 +64:0 +65:1 +66:0 +67:0 +68:0 +69:0 +70:1 +18:currentvectorv2.vsc +20:currentvectorv1.lst +15:0,0,0,0,0,0 +27:0, +34:0, +42:1 +72:0 +73:0 +35:Date +36:YYYY-MM-DD +37:2000 +38:1 +39:1 +40:2 +41:0 +95:0 +96:0 +97:0 +77:0 +78:0 +102:1 +93:0 +94:0 +92:0 +91:0 +90:0 +87:0 +75: +43: +103:8,8,8,3,8 +105:0,0,0,0,0,0,0,0,0,0 +104:Arial|14||0-0-0|0-0-0|-1--1--1|0-0-255|192-192-192|-1--1--1 diff --git a/ContinuousCode/3_Data4DM/Creating_spiral_graphs_DavidKeith_Method.m b/ContinuousCode/3_Data4DM/Creating_spiral_graphs_DavidKeith_Method.m new file mode 100644 index 0000000..f06c03e --- /dev/null +++ b/ContinuousCode/3_Data4DM/Creating_spiral_graphs_DavidKeith_Method.m @@ -0,0 +1,175 @@ +%Author: Ross Williams + + +%%%%Untested Assumptions/Potential Errors%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%USER INPUTS%%%%%%%%%%%%%%%%%%%%% +datafilename="currentvectorv1.xlsx"; %It must be an xlsx file + +%Smaller the numbers for both reduced data and reduce time will keep more of the data +Reducedata=2; %Define, of the total initial conditions you have, by what whole number factor do you want to reduce by. See "reducedarray" for how it affects the code +Reducetime=10; %Define how many time steps you want to skip. + + +Normalization=1; %If you want normalization, make it 1, else put 0 +MaxTimeSeries1=1; %For timeseries 1, used to normalize. +MaxTimeSeries2=4000; %For timeseries 2, used to normalize + + +xlabelname="Process Problems"; %This will the name for your time series 1 (x-axis). Do not include normalization to title (will automatically do it) +ylabelname="Resources for Production"; %This will the name for your time series 2 (y-axis). Do not include normalization to title (will automatically do it) +titlename="Phase Plot of Process Problems and Resources for Production";%This will make your title for the graph +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +%%%COMMENT OUT TO SAVE TIME ONCE RUN ONCE%%% +data=xlsread(datafilename); %Import data +data(1,:)=[]; %Remove Time Step Row. ONLY RUN ONCE AND THEN COMMENT OUT THIS LINE +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +howmuchdata=length(data); %Determines how much data you imported +array1=3:4:howmuchdata; %Array of rows for first time series +array2=4:4:howmuchdata; %Array of rows for 2nd time series +arraytot=cat(2,array1,array2); %concadenates arrays of rows for 1st and 2nd time series +arraytotsort=sort(arraytot); %sorts row order of concadenated time series + +timeseries=data(arraytotsort,:); %Extracts only time series from data + +array3=1:2:(howmuchdata/2); %Array of rows for 1st time series in "timeseries" matrix +array4=2:2:(howmuchdata/2); %Array of rows from 2nd time series in "timeseries" matrix + +if Normalization==1 +timeseries(array3,:)=timeseries(array3,:)./MaxTimeSeries1; %x-axis previously known as the 1st time series +timeseries(array4,:)=timeseries(array4,:)./MaxTimeSeries2; %y-axis previously known as the 2nd time series +xlabelname=strcat("Normalized ",xlabelname); +ylabelname=strcat("Normalized ",ylabelname); +end + +x=timeseries(array3,:); %x-axis previously known as the 1st time series +y=timeseries(array4,:); %y-axis previously known as the 2nd time series + + +minx=min(x(:,1)); %Locate min x value +miny=min(y(:,1)); %Locate min y value +maxx=max(x(:,1)); %Locate max x value +maxy=max(y(:,1)); %Locate max y value + + +%Create the data +MaxTSx=find(x(:,1)==maxx)*2-1; %Multiply by 2 as we'll need to extract data from real ts, not the x, and subtract 1 as it is x-series +MaxTSx_Yequivalent=MaxTSx+1; %Finds y time series that goes along with MaxTSx +MaxTSx_total=sort(cat(1,MaxTSx,MaxTSx_Yequivalent)); %Concatenates needed rows and sorts +xmax=timeseries(MaxTSx_total,:); %All ts data relevant for xmax + +MinTSx=find(x(:,1)==minx)*2-1; %Multiply by 2 as we'll need to extract data from real ts, not the x, and subtract 1 as it is x-series +MinTSx_Yequivalent=MinTSx+1; %Finds y time series that goes along with MinTSx +MinTSx_total=sort(cat(1,MinTSx,MinTSx_Yequivalent)); %Concatenates needed rows and sorts +xmin=timeseries(MinTSx_total,:); %All ts data relevant for xmin + +MaxTSy=find(y(:,1)==maxy)*2; %Multiply by 2 as we'll need to extract data from real ts and subtract 1 as it is x-series +MaxTSy_Xequivalent=MaxTSy-1; %Finds x time series that goes along with MaxTSy +MaxTSy_total=sort(cat(1,MaxTSy,MaxTSy_Xequivalent)); %Concatenates needed rows and sorts +ymax=timeseries(MaxTSy_total,:); %All ts data relevant for ymax + +MinTSy=find(y(:,1)==miny)*2; %Multiply by 2 as we'll need to extract data from real ts and subtract 1 as it is x-series +MinTSy_Xequivalent=MinTSy-1; %Finds x time series that goes along with MinTSy +MinTSy_total=sort(cat(1,MinTSy,MinTSy_Xequivalent)); %Concatenates needed rows and sorts +ymin=timeseries(MinTSy_total,:); %All ts data relevant for ymin + + +%Reduction of data +reducearrayX_x=1:2*Reducedata:size(xmax,1); %What x-rows from your time series from your xmin or xmax data +reducearrayY_x=1:2*Reducedata:size(ymax,1); %What x-rows from your time series from your ymin or ymax data + +reducearrayX_y=reducearrayX_x+1; %The associated y-rows from your time series from your xmin or xmax data +reducearrayY_y=reducearrayY_x+1; %The associated y-rows from your time series from your ymin or ymax data + +reducearrayX=sort(cat(2,reducearrayX_x,reducearrayX_y)); %Concatenating rows numbers and y-rows for xmin or xmax data +reducearrayY=sort(cat(2,reducearrayY_x,reducearrayY_y)); %Concatenating row numbers and y-rows for ymin or ymax data + +reducetimestep=1:Reducetime:size(timeseries,2); %Reduces timestep + +xmax_final=xmax(reducearrayX,reducetimestep); %Reducing amount of lines and timesteps for xmax +xmin_final=xmin(reducearrayX,reducetimestep); %Reducing amount of lines and timesteps for xmin +ymax_final=ymax(reducearrayY,reducetimestep); %Reducing amount of lines and timesteps for ymax +ymin_final=ymin(reducearrayY,reducetimestep); %Reducing amount of lines and timesteps for ymin + + +%Begin final attackrun for plotting +array5_xx=(1:2:size(xmax_final,1)); %Extract x time series data to plot for xmin and xmax +array6_xy=(2:2:size(xmax_final,1)); %Extract y time series data to plot for xmin and xmax + +array7_yx=(1:2:size(ymax_final,1)); %Extract x time series data to plot for ymin and ymax +array8_yy=(2:2:size(ymax_final,1)); %Extract y time series data to plot for ymin and ymax + +figure('Position',[10 10 1000 600],'Color','w'); %Create figure + +xmax_final_x=xmax_final(array5_xx,:); %Seperate out x time series data for xmax +xmax_final_y=xmax_final(array6_xy,:); %Seperate out y time series data for xmax + +for i=1:size(xmax_final_x,1) %Run through all xmax data + for j=1:(size(xmax_final_x,2)-1) + u=xmax_final_x(i,j+1)-xmax_final_x(i,j); %Velocity x and points to next point + v=xmax_final_y(i,j+1)-xmax_final_y(i,j); %Velocity y and points to next point + quiver(xmax_final_x(i,j),xmax_final_y(i,j),u,v,'Alignment','tail','Color','black'); %Plot all xmax data + hold on %Use the same graph + end + plot(xmax_final_x(i,j+1), xmax_final_y(i,j+1),'black.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + + +xmin_final_x=xmin_final(array5_xx,:); %Seperate out x time series data for xmin +xmin_final_y=xmin_final(array6_xy,:); %Seperate out y time series data for xmin + +for i=1:size(xmin_final_x,1) %Run through all xmin data + for j=1:(size(xmin_final_x,2)-1) + u=xmin_final_x(i,j+1)-xmin_final_x(i,j); %Velocity x and points to next point + v=xmin_final_y(i,j+1)-xmin_final_y(i,j); %Velocity y and points to next point + quiver(xmin_final_x(i,j),xmin_final_y(i,j),u,v,'Alignment','tail','Color','black'); %Plot all xmin data + hold on %Use the same graph + end + plot(xmin_final_x(i,j+1), xmin_final_y(i,j+1),'black.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + + +ymax_final_x=ymax_final(array7_yx,:); %Seperate out x time series data for ymax +ymax_final_y=ymax_final(array8_yy,:); %Seperate out y time series data for ymax + +for i=1:size(ymax_final_x,1) %Run through all ymax data + for j=1:(size(ymax_final_x,2)-1) + u=ymax_final_x(i,j+1)-ymax_final_x(i,j); %Velocity x and points to next point + v=ymax_final_y(i,j+1)-ymax_final_y(i,j); %Velocity y and points to next point + quiver(ymax_final_x(i,j),ymax_final_y(i,j),u,v,'Alignment','tail','Color','black'); %Plot all ymax data + hold on %Use the same graph + end + plot(ymax_final_x(i,j+1), ymax_final_y(i,j+1),'black.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + + +ymin_final_x=ymin_final(array7_yx,:); %Seperate out x time series data for ymin +ymin_final_y=ymin_final(array8_yy,:); %Seperate out y time series data for ymin + +for i=1:size(ymin_final_x,1) %Run through all ymin data + for j=1:(size(ymin_final_x,2)-1) + u=ymin_final_x(i,j+1)-ymin_final_x(i,j); %Velocity x and points to next point + v=ymin_final_y(i,j+1)-ymin_final_y(i,j); %Velocity y and points to next point + quiver(ymin_final_x(i,j),ymin_final_y(i,j),u,v,'Alignment','tail','Color','black'); %Plot all ymin data + hold on %Use the same graph + end + plot(ymin_final_x(i,j+1), ymin_final_y(i,j+1),'black.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + +if Normalization==1 +xlim([0 1]) +ylim([0 1]) +end +ylabel(ylabelname) %ylabel for graph +xlabel(xlabelname) %xlabel for graph +title(titlename) %title for graph diff --git a/ContinuousCode/3_Data4DM/Creating_spiral_graphs_Hesam_Method.m b/ContinuousCode/3_Data4DM/Creating_spiral_graphs_Hesam_Method.m new file mode 100644 index 0000000..14ccbf2 --- /dev/null +++ b/ContinuousCode/3_Data4DM/Creating_spiral_graphs_Hesam_Method.m @@ -0,0 +1,115 @@ +%Author: Ross Williams + +%Note: Coloring Function still needs work or it does work and I don't know why my data is wonked. + +%%%%Untested Assumptions/Potential Errors%%% +%What if a time series has a minimum not equal to 0. Unsure if I will need to adjust the code. +%I am not perfectly why I need to normalize velocities, but it definitely is needed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%USER INPUTS%%%%%%%%%%%%%%%%%%%%% +subtract=5; %Define the Position of how many time steps forward you want your arrow to be pointed towards +Reducedata=1; %Define, of the total initial conditions you have, by what whole number factor do you want to reduce by. See "reducedarray" for how it affects the code +MaxTimeSeries1=1; %For timeseries 1, used to normalize arrow position as well as arrow "velocities" +MaxTimeSeries2=4000; %For timeseries 2, used to normalize arrow position as well as arrow "velocities" +xlabelname="Process Problems"; %This will the name for your time series 1 (x-axis), and remember it will be normalized +ylabelname="Normalized Resources for Production"; %This will the name for your time series 2 (y-axis), and remember it will be normalized +titlename="Phase Plot of Process Problems and Normalized Resources for Production";%This will +datafilename="current12.xlsx"; %It must be an xlsx file +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%OPTIONAL USER INPUTS FOR GRAPH%%% +headWidth = 5;%Arrow head width +headLength = 9; %Arrow head length +LineLength = 0.01; %Put line lengths as close to 0 as possible. Else need to figure out how to normalize the line lengths,, 0.2 +ArrowAlignment = 'head'; %Where do you want +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%COMMENT OUT TO SAVE TIME ONCE RUN ONCE%%% +%data=xlsread(datafilename); %Import data +%data(1,:)=[]; %Remove Time Step Row. ONLY RUN ONCE AND THEN COMMENT OUT THIS LINE +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +howmuchdata=length(data); %Determines how much data you imported +array1=3:4:howmuchdata; %Array of rows for first time series +array2=4:4:howmuchdata; %Array of rows for 2nd time series +arraytot=cat(2,array1,array2); %concadenates arrays of rows for 1st and 2nd time series +arraytotsort=sort(arraytot); %sorts row order of concadenated time series + + + +timeseries=data(arraytotsort,:); %Extracts only time series from data +timeseriescol2=timeseries(:,[1,subtract]); %Extracts two columns of interest from time series +diff=timeseriescol2(:,2)-timeseriescol2(:,1); %Takes difference + +array3=1:2:(howmuchdata/2); %Array of rows for 1st time series in "timeseries" matrix and "diff" matrix +array4=2:2:(howmuchdata/2); %Array of rows from 2nd time series in "timeseries" matrix and "diff" matrix + + +x=timeseries(array3,1); %x-axis previously known as the 1st time series +y=timeseries(array4,1); %y-axis previously known as the 2nd time series + +diffx=diff(array3,1); %Find the difference in x-axis time series (x-axis previously known as the 1st time series) +diffy=diff(array4,1); %Find the difference in y-axis time series (y-axis previously known as the 2nd time series) + + +reducearray=1:Reducedata:(howmuchdata/4); %Takes a portion of all data that time series has. This line affects how many arrows come up. The max is the total amount of different initial conditions you have. +x_final=x(reducearray,1)./MaxTimeSeries1; %Reduces x-data and normalizes x-series +y_final=y(reducearray,1)./MaxTimeSeries2; %Reduces y-data and normalizes y-series +diffx_final=diffx(reducearray,1)./MaxTimeSeries1; %Reduces diffx-data and normalizes diffx-series +diffy_final=diffy(reducearray,1)./MaxTimeSeries2; %Reduces diffy-data and normalizes diffy-series + + + +%Plotting + + + +%Plot with blue arrows that we don't really care about +figure('Position',[10 10 1000 600],'Color','w'); %Just creates a plot setup; I stole this line from the web. +scale=1; %Plays with size of arrows. TBH, just keep it at 1 + +quiv=quiver(x_final,y_final,diffx_final*scale,diffy_final*scale,'AutoScale','off','Alignment',ArrowAlignment); %AutoScale I believe hurts this process, so I shut it off. +%Still recommended to further explore autoscale. Alignment=head means the head of the arrow will + + +ylabel(ylabelname) %ylabel for graph +xlabel(xlabelname) %xlabel for graph +title(titlename) %title for graph + + +%Plot with black arrows that we care about (I, Ross cares about) +figure('Position',[10 10 1000 600],'Color','w'); %Just creates a plot setup; I stole this line from the web. + + +%Making a graph with black/colored arrows (coloring is experimental atm) + +%Code to create black arrows found here: https://stackoverflow.com/questions/18776172/in-matlab-how-do-i-change-the-arrow-head-style-in-quiver-plot/18776822#18776822 + +U = quiv.UData; %Extracts diffx_final (x-velocity) data +V = quiv.VData; %Extracts diffy_final (y-velocity) data +X = quiv.XData; %Extracts x_final (x-position) data +Y = quiv.YData; %Extracts y_final (y-position) data + + + + +for i = 1:length(X) %For all points + ah = annotation('arrow',... + 'headStyle','cback1','color','black','HeadLength',headLength,'HeadWidth',headWidth,'LineWidth',0.01); %reformant arrow, color arrow, currently set as red spectrum + set(ah,'parent',gca); %Place arrow in current chart (tbh) I am unsure + set(ah,'position',[X(i,1) Y(i,1) LineLength*U(i,1) LineLength*V(i,1)]); %Place arrow here +end + +ylabel(ylabelname) %ylabel for graph +xlabel(xlabelname) %xlabel for graph +title(titlename) %title for graph + +%Not used brokenish idea: + +%slope=V./U; %used for color of arrows +%axSlope=max(abs(V./U)); %Used for colors arrows to normalize the values from [0,1] +%colorarrow=abs(slope(i)/maxSlope); %Calculate each color arrow value + +% ah = annotation('arrow','headStyle','cback1','color',[(1-colorarrow) 0 0],'HeadLength',headLength,'HeadWidth',headWidth,'LineWidth',0.01); %reformant arrow, color arrow, currently set as red spectrum \ No newline at end of file diff --git a/ContinuousCode/3_Data4DM/Creating_spiral_graphs_Ross_Method.m b/ContinuousCode/3_Data4DM/Creating_spiral_graphs_Ross_Method.m new file mode 100644 index 0000000..c61e7d4 --- /dev/null +++ b/ContinuousCode/3_Data4DM/Creating_spiral_graphs_Ross_Method.m @@ -0,0 +1,154 @@ +%Author: Ross Williams + +%%%%Untested Assumptions/Potential Errors%%% +%What if a time series has a minimum not equal to 0. Unsure if I will need to adjust the code. +%I am unsure why I need to normalize velocities. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%USER INPUTS%%%%%%%%%%%%%%%%%%%%% +datafilename="currentvectorv1.xlsx"; %It must be an xlsx file + + +Reducedata=1; %Define, of the total initial conditions you have, by what whole number factor do you want to reduce by. See "reducedarray" for how it affects the code +Reducetime=1; %Define how many time steps you want to skip. + + +Normalization=1; %If you want normalization, make it 1, else put 0 +MaxTimeSeries1=1; %For timeseries 1, used to normalize. +MaxTimeSeries2=4000; %For timeseries 2, used to normalize + + +xlabelname="Process Problems"; %This will the name for your time series 1 (x-axis). Do not include normalization to title (will automatically do it) +ylabelname="Resources for Production"; %This will the name for your time series 2 (y-axis). Do not include normalization to title (will automatically do it) +titlename="Phase Plot of Process Problems and Resources for Production";%This will make your title for the graph +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%COMMENT OUT TO SAVE TIME ONCE RUN ONCE%%% +%data=xlsread(datafilename); %Import data +%data(1,:)=[]; %Remove Time Step Row. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +howmuchdata=length(data); %Determines how much data you imported +array1=3:4:howmuchdata; %Array of rows for first time series +array2=4:4:howmuchdata; %Array of rows for 2nd time series +arraytot=cat(2,array1,array2); %concadenates arrays of rows for 1st and 2nd time series +arraytotsort=sort(arraytot); %sorts row order of concadenated time series + +timeseries=data(arraytotsort,:); %Extracts only time series from data + +array3=1:2:(howmuchdata/2); %Array of rows for 1st time series in "timeseries" matrix +array4=2:2:(howmuchdata/2); %Array of rows from 2nd time series in "timeseries" matrix + +if Normalization==1 +timeseries(array3,:)=timeseries(array3,:)./MaxTimeSeries1; %x-axis previously known as the 1st time series +timeseries(array4,:)=timeseries(array4,:)./MaxTimeSeries2; %y-axis previously known as the 2nd time series +xlabelname=strcat("Normalized ",xlabelname); +ylabelname=strcat("Normalized ",ylabelname); +end + +x=timeseries(array3,:); %x-axis previously known as the 1st time series +y=timeseries(array4,:); %y-axis previously known as the 2nd time series + + +minx=min(x(:,1)); %Locate min x value +miny=min(y(:,1)); %Locate min y value +maxx=max(x(:,1)); %Locate max x value +maxy=max(y(:,1)); %Locate max y value + + +%Create the data +MaxTSx=find(x(:,1)==maxx)*2-1; %Multiply by 2 as we'll need to extract data from real ts, not the x, and subtract 1 as it is x-series +MaxTSx_Yequivalent=MaxTSx+1; %Finds y time series that goes along with MaxTSx +MaxTSx_total=sort(cat(1,MaxTSx,MaxTSx_Yequivalent)); %Concatenates needed rows and sorts +xmax=timeseries(MaxTSx_total,:); %All ts data relevant for xmax + +MinTSx=find(x(:,1)==minx)*2-1; %Multiply by 2 as we'll need to extract data from real ts, not the x, and subtract 1 as it is x-series +MinTSx_Yequivalent=MinTSx+1; %Finds y time series that goes along with MinTSx +MinTSx_total=sort(cat(1,MinTSx,MinTSx_Yequivalent)); %Concatenates needed rows and sorts +xmin=timeseries(MinTSx_total,:); %All ts data relevant for xmin + +MaxTSy=find(y(:,1)==maxy)*2; %Multiply by 2 as we'll need to extract data from real ts and subtract 1 as it is x-series +MaxTSy_Xequivalent=MaxTSy-1; %Finds x time series that goes along with MaxTSy +MaxTSy_total=sort(cat(1,MaxTSy,MaxTSy_Xequivalent)); %Concatenates needed rows and sorts +ymax=timeseries(MaxTSy_total,:); %All ts data relevant for ymax + +MinTSy=find(y(:,1)==miny)*2; %Multiply by 2 as we'll need to extract data from real ts and subtract 1 as it is x-series +MinTSy_Xequivalent=MinTSy-1; %Finds x time series that goes along with MinTSy +MinTSy_total=sort(cat(1,MinTSy,MinTSy_Xequivalent)); %Concatenates needed rows and sorts +ymin=timeseries(MinTSy_total,:); %All ts data relevant for ymin + + +%Reduction +reducearrayX_x=1:2*Reducedata:size(xmax,1); %What x-rows from your time series from your xmin or xmax data +reducearrayY_x=1:2*Reducedata:size(ymax,1); %What x-rows from your time series from your ymin or ymax data + +reducearrayX_y=reducearrayX_x+1; %The associated y-rows from your time series from your xmin or xmax data +reducearrayY_y=reducearrayY_x+1; %The associated y-rows from your time series from your ymin or ymax data + +reducearrayX=sort(cat(2,reducearrayX_x,reducearrayX_y)); %Concatenating rows numbers and y-rows for xmin or xmax data +reducearrayY=sort(cat(2,reducearrayY_x,reducearrayY_y)); %Concatenating row numbers and y-rows for ymin or ymax data + +reducetimestep=1:Reducetime:size(timeseries,2); %Reduces timestep + +xmax_final=xmax(reducearrayX,reducetimestep); %Reducing amount of lines and timesteps for xmax +xmin_final=xmin(reducearrayX,reducetimestep); %Reducing amount of lines and timesteps for xmin +ymax_final=ymax(reducearrayY,reducetimestep); %Reducing amount of lines and timesteps for ymax +ymin_final=ymin(reducearrayY,reducetimestep); %Reducing amount of lines and timesteps for ymin + + +%Begin final attackrun for plotting +array5_xx=(1:2:size(xmax_final,1)); %Extract x time series data to plot for xmin and xmax +array6_xy=(2:2:size(xmax_final,1)); %Extract y time series data to plot for xmin and xmax + +array7_yx=(1:2:size(ymax_final,1)); %Extract x time series data to plot for ymin and ymax +array8_yy=(2:2:size(ymax_final,1)); %Extract y time series data to plot for ymin and ymax + + +figure('Position',[10 10 1000 600],'Color','w'); %Create figure + + +xmax_final_x=xmax_final(array5_xx,:); %Seperate out x time series data for xmax +xmax_final_y=xmax_final(array6_xy,:); %Seperate out y time series data for xmax + +for i=1:size(xmax_final_x,1) %Run through all xmax data + plot(xmax_final_x(i,:),xmax_final_y(i,:),'-'); %Plot all xmax data + hold on %Use the same graph + plot(xmax_final_x(i,size(xmax_final,2)), xmax_final_y(i,size(xmax_final,2)),'.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + + +xmin_final_x=xmin_final(array5_xx,:); %Seperate out x time series data for xmin +xmin_final_y=xmin_final(array6_xy,:); %Seperate out y time series data for xmin + +for i=1:size(xmin_final_x,1) %Run through all xmin data + plot(xmin_final_x(i,:),xmin_final_y(i,:),'-'); %Plot all xmin data + hold on %Use the same graph + plot(xmin_final_x(i,size(xmin_final,2)), xmin_final_y(i,size(xmin_final,2)),'.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + +ymax_final_x=ymax_final(array7_yx,:); %Seperate out x time series data for ymax +ymax_final_y=ymax_final(array8_yy,:); %Seperate out y time series data for ymax + +for i=1:size(ymax_final_x,1) %Run through all ymax data + plot(ymax_final_x(i,:),ymax_final_y(i,:),'-'); %Plot all ymax data + hold on %Use the same graph + plot(ymax_final_x(i,size(ymax_final,2)), ymax_final_y(i,size(ymax_final,2)),'.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + +ymin_final_x=ymin_final(array7_yx,:); %Seperate out x time series data for ymin +ymin_final_y=ymin_final(array8_yy,:); %Seperate out y time series data for ymin + +for i=1:size(ymin_final_x,1) %Run through all ymin data + plot(ymin_final_x(i,:),ymin_final_y(i,:),'-'); %Plot all ymin data + hold on %Use the same graph + plot(ymin_final_x(i,size(ymin_final,2)), ymin_final_y(i,size(ymin_final,2)),'.',MarkerSize=30); %Plot final point + hold on %Use the same graph +end + +ylabel(ylabelname) %ylabel for graph +xlabel(xlabelname) %xlabel for graph +title(titlename) %title for graph \ No newline at end of file