# DATA # We first need to read in the proposals - they are in a csv file # The first 250 entries are for NIRCam, the next 250 for MIRI, the next 250 for NIRSpec, and the last 250 # are for NIRISS raw = readdlm("Witt_Data.csv",','); # NIRCam's Data NIRCamNames = raw[2:251,1]; NIRCamPositions = raw[2:251,2]; NIRCamExposures = raw[2:251,3]; NIRCamDistances = raw[2:251,4]; # MIRI's Data MIRINames = raw[252:501,1]; MIRIPositions = raw[252:501,2]; MIRIExposures = raw[252:501,3]; MIRIDistances = raw[252:501,4]; # NIRSpec's Data NIRSpecNames = raw[502:751,1]; NIRSpecPositions = raw[502:751,2]; NIRSpecExposures = raw[502:751,3]; NIRSpecDistances = raw[502:751,4]; # NIRISS's Data NIRISSNames = raw[752:1001,1]; NIRISSPositions = raw[752:1001,2]; NIRISSExposures = raw[752:1001,3]; NIRISSDistances = raw[752:1001,4]; # TOTAL TIME - This section is where we will calculate the maximum amount of time that we will have to make each observation # We will start by figuring out d (which is the distance across the field of view) # Side Note - since these angles are in arcminutes, I will times the number by pi/10800 (which will give us radians) # Side Note 2 - there are 9.461*10^12 km in one light year # NIRCam = 2.2' x 2.2' # MIRI = 1.88' x 1.27' - I'll just use the first angle to make it easier # NIRSpec = 3.4' x 3.4' # NIRISS = 2.2' x 2.2' # These distances will be in light years NIRCam_Distances = [] MIRI_Distances = [] NIRSpec_Distances = [] NIRISS_Distances = [] NIRCam_Times = [] MIRI_Times = [] NIRSpec_Times = [] NIRISS_Times = [] for n = 1:250 push!(NIRCam_Distances,(2*NIRCamDistances[n]*tan((2.2*(pi/10800)/2)))) push!(MIRI_Distances,(2*MIRIDistances[n]*tan((1.88*(pi/10800)/2)))) push!(NIRSpec_Distances,(2*NIRSpecDistances[n]*tan((3.44*(pi/10800)/2)))) push!(NIRISS_Distances,(2*NIRISSDistances[n]*tan((2.2*(pi/10800)/2)))) push!(NIRCam_Times, ((9.461*10^(12)*NIRCam_Distances[n])/30.18)*0.000277778) push!(MIRI_Times, ((9.461*10^(12)*MIRI_Distances[n])/30.18)*0.000277778) push!(NIRSpec_Times, ((9.461*10^(12)*NIRSpec_Distances[n])/30.18)*0.000277778) push!(NIRISS_Times, ((9.461*10^(12)*NIRISS_Distances[n])/30.18)*0.000277778) end # START TIME - This section will determine how early we can start taking an observation for each object NIRCam_StartTime = [] MIRI_StartTime = [] NIRSpec_StartTime = [] NIRISS_StartTime = [] for n = 1:250 push!(NIRCam_StartTime,((NIRCamPositions[n]*8760))/(2*pi)) push!(MIRI_StartTime,((MIRIPositions[n]*8760))/(2*pi)) push!(NIRSpec_StartTime,((NIRSpecPositions[n]*8760))/(2*pi)) push!(NIRISS_StartTime,((NIRISSPositions[n]*8760))/(2*pi)) end # Our version of distances for TSP - which will be in times # These arrays will be the times in between all of the objects NIRCamTimes = zeros(250,250) MIRITimes = zeros(250,250) NIRSpecTimes = zeros(250,250) NIRISSTimes = zeros(250,250) for row = 1:250 for col = 1:250 NIRCamTimes[row,col]=(NIRCam_StartTime[row]) - (NIRCam_StartTime[col]) MIRITimes[row,col] = (MIRI_StartTime[row]) - (MIRI_StartTime[col]) NIRSpecTimes[row,col] = (NIRSpec_StartTime[row]) - (NIRSpec_StartTime[col]) NIRISSTimes[row,col] = (NIRISS_StartTime[row]) - (NIRISS_StartTime[col]) end end # SCHEDULE 1 - NIRCam using JuMP m1 = Model() @variable(m1, NIRCamObjects[1:250,1:250], Bin) for row = 1:250 for col = 1:250 # The telescope must be able to have enough time for each exposure @constraint(m1, (NIRCamExposures[row])*NIRCamObjects[row,col] <= NIRCam_Times[row]) # There also must be no overlap - the exposure for one object must end before we start the next one @constraint(m1, (NIRCam_StartTime[row] + NIRCamExposures[row])*NIRCamObjects[row,col] <= NIRCam_StartTime[col]) end end for n = 1:250 # This will also make sure that there are no overlaps @constraint(m1, sum(NIRCamObjects[:,n]) <= 1) @constraint(m1, sum(NIRCamObjects[n,:]) <= 1) end # We also have to make sure that the observation times do not exceed our 365 days (8760 Hours) @constraint(m1, sum{(NIRCamObjects[k,n].*NIRCamExposures[k]), k = 1:250, n = 1:250} <= 8760) # Our objective is to maximize the number of objects we can observe @objective(m1, Max, sum(NIRCamObjects)) solve(m1) println(getObjectiveValue(m1)) # SCHEDULE 2 - MIRI using JuMP m2 = Model() @variable(m2, MIRIObjects[1:250,1:250], Bin) for row = 1:250 for col = 1:250 # The telescope must be able to have enough time for each exposure @constraint(m2, (MIRIExposures[row])*MIRIObjects[row,col] <= MIRI_Times[row]) # There also must be no overlap - the exposure for one object must end before we start the next one @constraint(m2, (MIRI_StartTime[row] + MIRIExposures[row])*MIRIObjects[row,col] <= MIRI_StartTime[col]) end end for n = 1:250 # This will also make sure that there are no overlaps @constraint(m2, sum(MIRIObjects[:,n]) <= 1) @constraint(m2, sum(MIRIObjects[n,:]) <= 1) end # We also have to make sure that the observation times do not exceed our 365 days (8760 Hours) @constraint(m2, sum{(MIRIObjects[k,n].*MIRIExposures[k]), k = 1:250, n = 1:250} <= 8760) # Our objective is to maximize the number of objects we can observe @objective(m2, Max, sum(MIRIObjects)) solve(m2) println(getObjectiveValue(m2)) # SCHEDULE 3 - NIRSpec using JuMP m3 = Model() @variable(m3, NIRSpecObjects[1:250,1:250], Bin) for row = 1:250 for col = 1:250 # The telescope must be able to have enough time for each exposure @constraint(m3, (NIRSpecExposures[row])*NIRSpecObjects[row,col] <= NIRSpec_Times[row]) # There also must be no overlap - the exposure for one object must end before we start the next one @constraint(m3, (NIRSpec_StartTime[row] + NIRSpecExposures[row])*NIRSpecObjects[row,col] <= NIRSpec_StartTime[col]) end end for n = 1:250 # This will also make sure that there are no overlaps @constraint(m3, sum(NIRSpecObjects[:,n]) <= 1) @constraint(m3, sum(NIRSpecObjects[n,:]) <= 1) end # We also have to make sure that the observation times do not exceed our 365 days (8760 Hours) @constraint(m3, sum{(NIRSpecObjects[k,n].*NIRSpecExposures[k]), k = 1:250, n = 1:250} <= 8760) # Our objective is to maximize the number of objects we can observe @objective(m3, Max, sum(NIRSpecObjects)) solve(m3) println(getObjectiveValue(m3)) # SCHEDULE 4 - NIRISS using JuMP m4 = Model() @variable(m4, NIRISSObjects[1:250,1:250], Bin) for row = 1:250 for col = 1:250 # The telescope must be able to have enough time for each exposure @constraint(m4, (NIRISSExposures[row])*NIRISSObjects[row,col] <= NIRISS_Times[row]) # There also must be no overlap - the exposure for one object must end before we start the next one @constraint(m4, (NIRISS_StartTime[row] + NIRISSExposures[row])*NIRISSObjects[row,col] <= NIRISS_StartTime[col]) end end for n = 1:250 # This will also make sure that there are no overlaps @constraint(m4, sum(NIRISSObjects[:,n]) <= 1) @constraint(m4, sum(NIRISSObjects[n,:]) <= 1) end # We also have to make sure that the observation times do not exceed our 365 days (8760 Hours) @constraint(m4, sum{(NIRISSObjects[k,n].*NIRISSExposures[k]), k = 1:250, n=1:250} <= 8760) # Our objective is to maximize the number of objects we can observe @objective(m4, Max, sum(NIRISSObjects)) solve(m4) println(getObjectiveValue(m4))