Skip to content

Commit

Permalink
Display lambdas, add slider
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasz committed Dec 19, 2016
1 parent 6277f7a commit 2d52283
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/history/ExecutionHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public void addGeneration(Population pop){
this.generations.add(pop);
}
public Population getGeneration(int pos){
return generations.get(pos);
return generations.get(Integer.min(pos, generations.size()-1));
}

public ArrayList< ArrayList<ReferencePoint> > getLambdaDirectionsHistory() {
return lambdaGenerations;
}
public ArrayList<ReferencePoint> getLambdaDirections(int id){
return lambdaGenerations.get(id);
return lambdaGenerations.get(Integer.min(id,lambdaGenerations.size()-1));
}
public void addLambdas(ArrayList<ReferencePoint> lambdaDirections){
this.lambdaGenerations.add(lambdaDirections);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ else if (actionCommand.equals("hideAxis")) {
chart.getAxis(i).resetFilters();
}
this.chartFrame.repaint();
} else if (actionCommand.equals("setAllFiltersAsAxis")) {
ParallelCoordinatesChart chart = this.axis.getChart();
for (int i = 0; i < chart.getAxisCount(); i++) {
chart.getAxis(i).setFilterAsNewRange();
this.chartFrame.repaint();
}
this.chartFrame.repaint();
} else if (actionCommand.equals("reduceDistanceAllAxes")) {
ParallelCoordinatesChart chart = this.axis.getChart();
for (int i = 0; i < chart.getAxisCount(); i++) {
Expand Down
50 changes: 45 additions & 5 deletions src/org/xdat/data/DataSheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.xdat.exceptions.InconsistentDataException;

import core.Population;
import core.points.ReferencePoint;
import core.points.Solution;
import history.ExecutionHistory;

Expand Down Expand Up @@ -257,13 +258,10 @@ private void importData(int generationId, ProgressMonitor progressMonitor){
int idCounter = 1;
Population pop = ExecutionHistory.getInstance().getGeneration(generationId);

Design newDesign = new Design(idCounter++);
for (int i = 0; i < ExecutionHistory.getInstance().getNumObjectives(); i++) {
this.parameters.add(new Parameter("f" + (i+1), this));
newDesign.setValue(this.parameters.get(i), "0.0");
}
this.data.add(newDesign);
this.designIdsMap.put(newDesign.getId(), newDesign);
Design newDesign = new Design(idCounter++);

for(Solution s : pop.getSolutions()){
progressMonitor.setProgress(idCounter - 1);
Expand All @@ -274,6 +272,27 @@ private void importData(int generationId, ProgressMonitor progressMonitor){
this.data.add(newDesign);
this.designIdsMap.put(newDesign.getId(), newDesign);
}

for(ReferencePoint rp : ExecutionHistory.getInstance().getLambdaDirections(generationId)){
progressMonitor.setProgress(idCounter);
newDesign = new Design(idCounter++);
for (int i = 0; i < ExecutionHistory.getInstance().getNumObjectives(); i++) {
newDesign.setValue(this.parameters.get(i), String.valueOf(rp.getDim(i)));
}
this.data.add(newDesign);
this.designIdsMap.put(newDesign.getId(), newDesign);
}

Design zero = new Design(idCounter + 1);
Design one = new Design(idCounter + 2);
for (int i = 0; i < ExecutionHistory.getInstance().getNumObjectives(); i++) {
zero.setValue(this.parameters.get(i), "0.0");
one.setValue(this.parameters.get(i), "1.0");
}
this.data.add(zero);
this.data.add(one);
this.designIdsMap.put(zero.getId(), zero);
this.designIdsMap.put(one.getId(), one);

if (progressMonitor.isCanceled()) {
this.data = buffer;
Expand Down Expand Up @@ -423,7 +442,7 @@ public void updateData(int generationId, ProgressMonitor progressMonitor){

progressMonitor.setMaximum(ExecutionHistory.getInstance().getPopulationSize());

int idCounter = 1;
int idCounter = 0;
Population pop = ExecutionHistory.getInstance().getGeneration(generationId);

progressMonitor.setMaximum(pop.size());
Expand All @@ -445,6 +464,27 @@ public void updateData(int generationId, ProgressMonitor progressMonitor){
this.data.add(newDesign);
this.designIdsMap.put(newDesign.getId(), newDesign);
}

for(ReferencePoint rp : ExecutionHistory.getInstance().getLambdaDirections(generationId)){
progressMonitor.setProgress(idCounter);
newDesign = new Design(idCounter++);
for (int i = 0; i < ExecutionHistory.getInstance().getNumObjectives(); i++) {
newDesign.setValue(this.parameters.get(i), String.valueOf(rp.getDim(i)));
}
this.data.add(newDesign);
this.designIdsMap.put(newDesign.getId(), newDesign);
}

Design zero = new Design(idCounter + 1);
Design one = new Design(idCounter + 2);
for (int i = 0; i < ExecutionHistory.getInstance().getNumObjectives(); i++) {
zero.setValue(this.parameters.get(i), "0.0");
one.setValue(this.parameters.get(i), "1.0");
}
this.data.add(zero);
this.data.add(one);
this.designIdsMap.put(zero.getId(), zero);
this.designIdsMap.put(one.getId(), one);

if (progressMonitor.isCanceled()) {
this.data = buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ public ParallelCoordinatesContextMenu(Main mainWindow, ChartFrame chartFrame, Ax
resetAllFiltersMenuItem.setActionCommand("resetAllFilters");
resetAllFiltersMenuItem.addActionListener(cmd);
this.add(resetAllFiltersMenuItem);

// set all filters as new axis range
JMenuItem setAllFiltersAsRangeMenuItem = new JMenuItem("Set all filters as axis range");
setAllFiltersAsRangeMenuItem.setActionCommand("setAllFiltersAsAxis");
setAllFiltersAsRangeMenuItem.addActionListener(cmd);
this.add(setAllFiltersAsRangeMenuItem);

// increase distance
JMenuItem increaseDistanceAllAxesMenuItem = new JMenuItem("Increase spacing all axes ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ protected void buildPanel(JPanel parentPanel) {
this.activeDesignAlphaSlider.setEnabled(false);
}

this.generationsSlider = new JSlider(JSlider.HORIZONTAL, 0, ExecutionHistory.getInstance().getNumGenerations() - 1, 0);
this.generationsSlider = new JSlider(JSlider.HORIZONTAL, 0, ExecutionHistory.getInstance().getNumGenerations()-1, 0);

this.generationsSlider.addChangeListener(new ChangeListener() {

Expand Down

0 comments on commit 2d52283

Please sign in to comment.