My Partners and me, we are trying to optimize frequency process...
What we want to simplify our problem as much as possible in a JTree
.
As you can see, each node
or leaf
has a numResampleOperations
involved per node/leaf.
L -> Increment or multiplication
M -> Decrement or division
How do we calculate the values?
Target = Source*L/M
numResampleOperations = filterSize * Source * Integer.max(L, M);
We want to obtain only one value per frequency shown in the JTextField, removing not needed branch.
For this example we used only 5 ordered Target
frequencies (only integers value are allowed), but can grow until 50 frequency values.
The JTree must preserve at least one per included Target
frequency of 150Hz, at least one of 160Hz, .., 210Hz.
The highest priority is to have the minimum sum involved of numResampleOperations
How remove not needed branchs (those whose sum is very high
), nodes or leafs, with the guarantee of having at least one (frequency required on JTextField), but the sum of all numResampleOperations
is minimum?
What do you suggest to us?
We starting with Generate List with Combination of Subset of List, Java
But due to the dimensions the solution is not viable.
EDIT 1
my class
public class NodeResample {
private int incrementL;
private int decrementM;
private int sampleRateSource;
private int sampleRateTarget;
private double maxPassFreq;
private Integer filterSize;
private Integer numResampleOperations;
public NodeResample(int incrementL, int decrementM, int sampleRateSource, int sampleRateTarget, double maxPassFreq, Integer filterSize, Integer numResampleOperations) {
this.incrementL = incrementL;
this.decrementM = decrementM;
this.sampleRateSource = sampleRateSource;
this.sampleRateTarget = sampleRateTarget;
this.maxPassFreq = maxPassFreq;
this.filterSize = filterSize;
this.numResampleOperations = numResampleOperations;
}
public int getIncrementL() {
return incrementL;
}
public void setIncrementL(int incrementL) {
this.incrementL = incrementL;
}
public int getDecrementM() {
return decrementM;
}
public void setDecrementM(int decrementM) {
this.decrementM = decrementM;
}
public int getSampleRateSource() {
return sampleRateSource;
}
public void setSampleRateSource(int sampleRateSource) {
this.sampleRateSource = sampleRateSource;
}
public int getSampleRateTarget() {
return sampleRateTarget;
}
public void setSampleRateTarget(int sampleRateTarget) {
this.sampleRateTarget = sampleRateTarget;
}
public double getMaxPassFreq() {
return maxPassFreq;
}
public void setMaxPassFreq(double maxPassFreq) {
this.maxPassFreq = maxPassFreq;
}
public Integer getFilterSize() {
return filterSize;
}
public void setFilterSize(Integer filterSize) {
this.filterSize = filterSize;
}
public Integer getNumResampleOperations() {
return numResampleOperations;
}
public void setNumResampleOperations(Integer numResampleOperations) {
this.numResampleOperations = numResampleOperations;
}
@Override
public String toString() {
return "NodeResample{" + "L=" + incrementL + ", M=" + decrementM
+ ", Source=" + sampleRateSource + ", Target=" + sampleRateTarget
+ ", filterSize=" + filterSize + ", numResampleOperations=" + numResampleOperations + "} ";
}
}
Now , I noticed that certain branches are essential, for example the First (Top)
branch that includes the 210
, because no other branch of the tree includes it.
First, I need a code to find the branch that includes that value (200)
'or the cheapest'. Add the found branch to another Target JTree.
Some code for this part?
I also noticed that other branches still have the value of 200
, however, the cost of adding another branch is greater than continuing to use the first 'essential' branch, since this is only adding two nodes
, whose sum is less than adding another branch.
Second, I need to know the value of these two nodes numResampleOperations -> (267960 + 1091720)
, and the values another branches, to do comparison and add the best option to the another Target JTree. Some code for this part?
See Question&Answers more detail:
os