Skip to content

Commit

Permalink
BUG: mistake message when empty minerlist
Browse files Browse the repository at this point in the history
UPDATE: now reward shows up directly
UPDATE: 32.72 bins/channel instead of 30 bins/channel
  • Loading branch information
NeutrinoLiu committed Feb 18, 2022
1 parent bce14d9 commit 87841db
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/com/example/decentspec_v3/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class Config {
public static final int BAUD_RATE = 115200;

// ML related
public static final int ML_TASK_INTERVAL = 1000; // check the condition per 5s
public static final int ML_TASK_INTERVAL = 5000; // check the condition per 5s
public static final boolean LIMIT_TRAIN_SIZE = true;
public static final int MAX_LOCAL_SET_SIZE = 5000; // too large the size will lead to too long time training
public static final boolean USE_DUMMY_DATASET = false; // use local GPS_power.dat
Expand Down
17 changes: 14 additions & 3 deletions app/src/main/java/com/example/decentspec_v3/FLWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,23 @@ public void run() {
public void run() {
while (!Thread.currentThread().isInterrupted()) {
try {
TrainingPara mTPara;
// REMOTE ready: new global available
TrainingPara mTPara = mTrigger.getNewGlobal();
if (mTrigger.wifiReady())
updateReward();
else {
Thread.sleep(ML_TASK_INTERVAL);
continue;
}
if (mTrigger.chargerReady())
mTPara = mTrigger.getNewGlobal();
else {
Thread.sleep(ML_TASK_INTERVAL);
continue;
}
// LOCAL ready: wifi, battery, and local files
SampleFile dataFile = mTrigger.getDataset(mTPara); // TODO change it to file list instead fo a single file
if (dataFile != null && mTPara != null) {
if (dataFile != null) {
/* use this file to make a local train */
oneLocalTraining(dataFile, mTPara);
// end of one time training
Expand Down Expand Up @@ -179,7 +191,6 @@ private void oneLocalTraining(SampleFile file, TrainingPara mTrainingPara) {
}
// end of ML cycle =================================================================
updateNumbers();
updateReward();
cleanup();
}

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/java/com/example/decentspec_v3/MyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public static String genConfigData(int configIndex) {
int bandwidth = SAMPLE_PARA_BD[configIndex];
return String.format("%s\n\r1\n\r%d\n\r%d\n\r%d\n\r%s\n\r", SAMPLE_START_SIGNAL, center_freq, bandwidth, SAMPLE_RATE_INTERVAL, SAMPLE_END_SIGNAL);
}
public static double[] powerMerge(double[] small_bins, int merge_per_bins) {
if (merge_per_bins == 0)
public static double[] powerMerge(double[] small_bins, double bins_per_merge) {
if (bins_per_merge == 0)
return null;
int len = small_bins.length;
double[] merged_bins = new double[len / merge_per_bins];
for (int i = 0; i < len; i = i + merge_per_bins) {
if ((len - i) >= merge_per_bins) {
merged_bins[i / merge_per_bins] = merge(Arrays.copyOfRange(small_bins, i, i + merge_per_bins));
double[] merged_bins = new double[(int)(len / bins_per_merge)];
for (double i = 0; i < len; i = i + bins_per_merge) {
if ((len - (int)i) >= (int)bins_per_merge) {
merged_bins[(int)(i / bins_per_merge)] = merge(Arrays.copyOfRange(small_bins, (int) Math.round(i), (int) Math.round(i + bins_per_merge)));
}
}
return merged_bins;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ private Pair<double[], double[]> tvMultiPreprocess(double[] doubleList, Training
inList = Arrays.copyOfRange(doubleList, 0, 2);
if (inList[0] == 0.0 || inList[1] == 0.0)
return null;
double[] outListResource = Arrays.copyOfRange(doubleList, 3, 30 * 8 + 3);
outList = MyUtils.powerMerge(outListResource, 30);
double[] outListResource = Arrays.copyOfRange(doubleList, 3, 256 + 3);
outList = MyUtils.powerMerge(outListResource, 30.72);
return standardize(inList, outList, tp);
}
private Pair<double[], double[]> ltePreprocess(double[] doubleList, TrainingPara tp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void onErrorResponse(VolleyError error) {
});
HTTPQueue.add(stringRequest);
join();
return tp.MINER_LIST.size() != 0;
return responded;
}

public double fetchReward(String myId) {
Expand Down

0 comments on commit 87841db

Please sign in to comment.