it.ssc.pl.milp.Tree Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsr331-ssc Show documentation
Show all versions of jsr331-ssc Show documentation
This is a JSR331 interface for SSC (Software for the Calculation of the Simplex) is a java library for solving linear programming problems v. 3.0.1.
SSC was designed and developed by Stefano Scarioli.
The newest version!
package it.ssc.pl.milp;
import java.util.HashMap;
class Tree {
private HashMap tree ;
public Tree() {
tree=new HashMap ();
}
public MilpManager getMilpBestUPMax() {
MilpManager milp_best=null;
for(MilpManager milp :tree.values()) {
if(milp_best==null) milp_best=milp;
else if(milp_best.getOptimumValue() < milp.getOptimumValue()) milp_best=milp;
}
deleteNode(milp_best);
return milp_best;
}
public MilpManager getMilpBestUPMin() {
MilpManager milp_best=null;
for(MilpManager milp :tree.values()) {
if(milp_best==null) milp_best=milp;
else if(milp_best.getOptimumValue() > milp.getOptimumValue()) milp_best=milp;
}
deleteNode(milp_best);
return milp_best;
}
public MilpManager getMilpBestUPNotDelete() {
MilpManager milp_best=null;
for(MilpManager milp :tree.values()) {
if(milp_best==null) milp_best=milp;
else if(milp_best.getOptimumValue() < milp.getOptimumValue()) milp_best=milp;
}
//deleteNode(milp_best);
return milp_best;
}
public MilpManager getMilpBestIdNotDelete() {
MilpManager milp_best=null;
for(MilpManager milp :tree.values()) {
if(milp_best==null) milp_best=milp;
else if(milp_best.getId() < milp.getId()) milp_best=milp;
}
//deleteNode(milp_best);
return milp_best;
}
public boolean isEmpty() {
return tree.isEmpty();
}
public void addNode(MilpManager milp) {
tree.put(milp.getId(), milp);
}
public void deleteNode(MilpManager milp) {
tree.remove(milp.getId());
}
public void deleteNodeWhitUPnotValideMax(double lb) {
/*
HashMap tree_clone=(HashMap)tree.clone();
for(ManagerMILP milp :tree_clone.values()) {
if(milp.getOptimumValue() <= lb) {
tree.remove(milp.getId());
//System.out.println("up SCADUTO - RIMOSSO PROBLEMA ID:"+milp.getId() +"z: "+milp.getUP() +" con LB:"+lb);
}
}
*/
tree.entrySet().removeIf(e -> e.getValue().getOptimumValue() <=lb);
}
public void deleteNodeWhitUPnotValideMin(double lb) {
/*
HashMap tree_clone=(HashMap)tree.clone();
for(ManagerMILP milp :tree_clone.values()) {
if(milp.getOptimumValue() <= lb) {
tree.remove(milp.getId());
//System.out.println("up SCADUTO - RIMOSSO PROBLEMA ID:"+milp.getId() +"z: "+milp.getUP() +" con LB:"+lb);
}
}
*/
tree.entrySet().removeIf(e -> e.getValue().getOptimumValue() >=lb);
}
}