-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual method.py
171 lines (106 loc) · 4.17 KB
/
manual method.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 15 12:25:28 2022
@author: iainh
"""
import os
import datetime
import math
import pandas as pd
from ortools.sat.python import cp_model
from Solver.CPModel_SC import CPModel_SC_data
from Solver.HintFunctions import CreateManHint, AddHint#, CreateManHint_SwitchingConstraint
from utils import readwrite
'''
ideintification of intervals and initial values
'''
full_horizon = 21000
interval_size = 21000
b = 0
c = b + interval_size
hint = 1
switchtime =1
affix = "iss/60s_30d/G40/"
switching_constraint = 1
dt = 60
hot_start =0# defines whether it should start from data already partially optimised
num_interval = math.ceil(full_horizon/interval_size)
file_affix = "60s_30d_pol_"
# used to define how long it takes to process each dataset
FLOP_to_proc = 1000
FLOPS_available = 100 # giga flops
obs_dataset_mem = int( 150e3/100 )# in 0.1 kB
obs_rate = 100 # used to allow the observations to be processed in parts while remaining integers
pro_rate = math.ceil(FLOP_to_proc/FLOPS_available) # rate at which the system can process a dataset
pro_dataset_mem = int(300 /100) # in 0.1 kB
down_rate_mem = 320 # in 0.1 kB per second
down_rate = int(down_rate_mem/pro_dataset_mem) # the number of processed dataset units the satellite can downlink per second
down_dataset_mem = int(down_rate_mem/down_rate)
memory_storage = int( 64e7) # 64GB total memory in 0.1kB
all_action = range(4)
all_sats = range(66)
all_shifts = range(full_horizon)
all_interval = range(num_interval)
all_mod_shifts = range(interval_size)
memory= 0
num_obs = 0
num_pro= 0
num_down= 0
#making the dataframe to output the schedule
#schedtemp = [[] for a in range(9)]
schedule_out_titles = ['Observing', 'Processing', 'downlinking', 'idling', 'num observed', 'num processed', 'num downlinked', 'memory used (kB)', 'Satellite targeted']
current_time = datetime.datetime.now()
month = str(current_time.month)
day = str(current_time.day)
hour = str(current_time.hour)
minute = str(current_time.minute)
time_now = "_M" + month + "_D" +day +"_H" + hour + "_min" + minute
path = "./results/" + affix + "iainLaptopManual"
path = path +time_now
os.mkdir(path)
path = path+ "/"
#read in if a illuminator is in view
data = pd.read_csv("Data/" + affix +"/Illuminator view data log.csv")
temp = data.values.tolist()
any_ilum_list = temp[b:c]
#read in the downlink data times
data = pd.read_csv("Data/" + affix +"/Communications Data log.csv")
temp= data.values.tolist()
datals = temp[b:c]
# chages downlink from list of lists to 1D list
gnd_stat_list = [datals[i][0] for i in range(0, len(datals))]
# reads in which illuminators are visible
data = pd.read_csv("Data/" + affix +"/Avg objects Detection log.csv")
temp = data.values.tolist()
ilum_value_list = temp[b:c]
for s in all_mod_shifts:
for sat in all_sats:
ilum_value_list[s][sat] = math.floor(ilum_value_list[s][sat]*10000)
(hint_shifts, hint_target_ilum,Log ) = CreateManHint(any_ilum_list,ilum_value_list, gnd_stat_list, all_action,all_mod_shifts, all_sats, obs_dataset_mem, obs_rate, pro_dataset_mem,
pro_rate, down_rate, memory, memory_storage, num_obs,num_pro, dt, switching_constraint)
'''
write values out to files
'''
scheduleWrite = [[0 for a in range(9)] for s in all_mod_shifts]
target_ilum_val_inv = [[0 for sat in all_sats] for s in all_mod_shifts]
for s in all_mod_shifts:
for a in all_action:
if hint_shifts[a][s] == 1:
scheduleWrite[s][a] = 1
for i in range(4):
multi =1
if i ==3:
multi = 0.1
scheduleWrite[s][i+4] = Log[i][s]
for sat in all_sats:
if hint_target_ilum[sat][s] == 1:
scheduleWrite[s][8] = sat
target_ilum_val_inv[s][sat] = 1
ind = [i for i in range(b,c)]
if b == 0:
scheduleout= pd.DataFrame(scheduleWrite,index = ind, columns=schedule_out_titles)
else:
dftemp = pd.DataFrame(scheduleWrite,index = ind, columns=schedule_out_titles)
scheduleout= scheduleout.append(dftemp)
name = "Alt_scheduleraw_up_to_shift %i" % (c)
readwrite.df_to_xlsxOut(scheduleout,schedule_out_titles, name, path)