All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.ssc.pl.milp.TreeV3 Maven / Gradle / Ivy

Go to download

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.ArrayList;
import java.util.PriorityQueue;


import it.ssc.pl.milp.ObjectiveFunction.TARGET_FO;
import it.ssc.pl.milp.util.MILPThreadsNumber;

 final class TreeV3 {
	private PriorityQueue queue ;
	private TARGET_FO target;

	public TreeV3(TARGET_FO target) {
		this.target=target;
		if (target==TARGET_FO.MAX) queue = new PriorityQueue((e,o) ->  e.compareTo(o));
		else queue = new PriorityQueue((e,o) ->  -e.compareTo(o));
	}
	
	public MilpManager getMilpBestUP() { 
		return queue.poll();
	}
	
	public ArrayList getMilpBestUP(MILPThreadsNumber threadNumber) { 
		int num_lp=0;
		ArrayList list_best=new ArrayList ();
		while(!queue.isEmpty() && num_lp!=threadNumber.getNumLp()) { 
			list_best.add(queue.poll());
			num_lp++;
		}
		return list_best;
	}
	
	public boolean isEmpty() { 
		return queue.isEmpty();
	}
	
	public void addNode(MilpManager milp) {
		queue.add(milp);
	}
	
	
	public void deleteNodeWhitUPnotValide(double lb) {
		if (target==TARGET_FO.MAX) queue.removeIf(e -> e.getOptimumValue() <=lb);
		else queue.removeIf(e -> e.getOptimumValue() >=lb);
	}
	
	/*
	
	public void deleteNodeWhitUPnotValide(double lb,double tollerance) {
		if (target==TARGET_FO.MAX) queue.removeIf(e -> e.getOptimumValue() <=(lb+tollerance));
		else queue.removeIf(e -> e.getOptimumValue() >=(lb-tollerance));
	}
	 * 
	 */
	
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy