diff --git a/pom.xml b/pom.xml index 6298c173d2b4d859036608d1c5e826d618045912..8c1c573b5d73422d4530376eab8d301cbf9e0da8 100644 --- a/pom.xml +++ b/pom.xml @@ -25,17 +25,17 @@ <properties> <bundle.symbolicName>de.hhu.ba.yoshikoWrapper</bundle.symbolicName> <bundle.namespace>de.hhu.ba.yoshikoWrapper</bundle.namespace> - <cytoscape.api.version>3.6.0</cytoscape.api.version> + <cytoscape.api.version>3.7.2</cytoscape.api.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version> <osgi.api.version>4.2.0</osgi.api.version> </properties> <groupId>de.hhu.ba</groupId> - <artifactId>yoshikoWrapper</artifactId> - <version>0.1.5</version> + <artifactId>yoshikoStandalone</artifactId> + <version>0.1.1</version> - <name>YoshikoWrapper</name> + <name>YoshikoStandalone</name> <build> <plugins> @@ -43,7 +43,7 @@ <inherited>true</inherited> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> - <version>3.0</version> + <version>3.7.0</version> <configuration> <source>1.8</source> <target>1.8</target> @@ -121,6 +121,11 @@ <artifactId>org.osgi.core</artifactId> <version>${osgi.api.version}</version> </dependency> + <dependency> + <groupId>org.jgrapht</groupId> + <artifactId>jgrapht-core</artifactId> + <version>1.3.1</version> + </dependency> <dependency> <groupId>junit</groupId> diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index f34df8026716566d65a387afae841db54cfa564b..d1862a67d71841823a52278522ac68f08fc02950 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -51,7 +51,6 @@ import static org.cytoscape.work.ServiceProperties.COMMAND_NAMESPACE; import de.hhu.ba.yoshikoWrapper.core.ConfigurationManager; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; -import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.swing.components.MainPanel; import de.hhu.ba.yoshikoWrapper.taskFactories.CommandTaskFactory; import de.hhu.ba.yoshikoWrapper.taskFactories.YoshikoCommand; @@ -101,14 +100,6 @@ public class CyActivator extends AbstractCyActivator { //Set language according to settings -> Default to enUS LocalizationManager.switchLanguage(cm.getProperties().getProperty("locale", "enUS")); - //Attempt to find the Yoshiko lib in a previously stored location and load it - //TODO: Move into a separate handler to keep CyActivator clean - if (!YoshikoLoader.isLibraryLoaded()){ - String pathToYosh = cm.getProperties().getProperty("pathToYoshiko"); - if (pathToYosh != null && pathToYosh != "null") { - YoshikoLoader.loadLibrary(pathToYosh); - } - } //Register commands / CyRest //TODO: Group shared calls for better code readability / less lines of code TaskFactory commandTaskFactory_PERFORM_ALGORITHM = new CommandTaskFactory(YoshikoCommand.PERFORM_ALGORITHM); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java deleted file mode 100644 index 64d16b7924508984994bac10bcbe746078cb8839..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java +++ /dev/null @@ -1,118 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2017 Philipp Spohr - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - ******************************************************************************/ -package de.hhu.ba.yoshikoWrapper.core; - -import java.util.List; - -import org.cytoscape.model.CyColumn; -import org.cytoscape.model.CyEdge; -import org.cytoscape.model.CyNetwork; -import org.cytoscape.model.CyRow; -import org.slf4j.Logger; - -import de.hhu.ba.yoshikoWrapper.cytoUtil.NodeMap; -import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; -import de.hhu.ba.yoshikoWrapper.swig.LibraryInput; - -public class NetworkParser { - - //Symbolic Links - private static Logger logger = YoshikoLogger.getInstance().getLogger(); - - public static LibraryInput parseNetwork ( - CyNetwork net, - NodeMap nodeMap, - CyColumn weightColumn, - CyColumn permanentColumn, - CyColumn forbiddenColumn, - double deletionCostDefault - ) throws NetworkParsingException - { - //Create an empty instance / fetch C++ object pointer - LibraryInput generatedInput = new LibraryInput(); - if (net != null){ - //Create an empty full graph with a given size - generatedInput.setSize(net.getNodeCount()); - //Fetch edges - List<CyEdge> edges = net.getEdgeList(); - - //Loop over edges - for (CyEdge e : edges) { - - //Parse editing costs - double weight = deletionCostDefault; - - //Fetch entry and check if it exists - CyRow edgeEntry = net.getRow(e); - - //Check if there is a weight column defined, else skip - if (weightColumn != null){ - //Check if the column contains an entry for the respective edge - //It is possible, that there are missing entries - if (edgeEntry.get(weightColumn.getName(), weightColumn.getType()) != null){ - if (weightColumn.getType() == Integer.class) { - weight = 1.0*edgeEntry.get(weightColumn.getName(), Integer.class); - } - else if (weightColumn.getType() == Double.class) { - weight = edgeEntry.get(weightColumn.getName(), Double.class); - } - } - } - - //Parse Forbidden/Permanent markers - boolean forbidden = false; - boolean permanent = false; - - if (permanentColumn != null) { - //Additional check as it is not required to have a value in every row - if (edgeEntry.get(permanentColumn.getName(), Boolean.class) != null) { - permanent = (boolean)edgeEntry.get(permanentColumn.getName(), Boolean.class); - } - } - if (forbiddenColumn != null) { - //Additional check as it is not required to have a value in every row - if (edgeEntry.get(forbiddenColumn.getName(), Boolean.class) != null) { - forbidden = (boolean)edgeEntry.get(forbiddenColumn.getName(), Boolean.class); - } - } - - //Check for edges that are forbidden AND permanent -> Throw exception - if (forbidden && permanent) { - throw new NetworkParsingException(LocalizationManager.get("dualInfinityError")); - } - - logger.debug("Found Edge: "+edgeEntry.get("name", String.class)+ " with weight:"+weight); - - generatedInput.addEdge( - nodeMap.get(e.getSource()), - nodeMap.get(e.getTarget()), - weight, - permanent, - forbidden - ); - - } - } - return generatedInput; - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java deleted file mode 100644 index c556b9d2a906d896b01282bbe1aefaf26eab65a7..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParsingException.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.hhu.ba.yoshikoWrapper.core; - -/** - * Simple Exception that should be thrown when the CyNetwork combined with the given parameters can not be parsed in a meaningful WCE instance - * @author Philipp Spohr, Dec 12, 2017 - * - */ -@SuppressWarnings("serial") -public class NetworkParsingException extends Exception { - - private String msg; - - public NetworkParsingException(String msg) { - this.msg = msg; - } - - @Override - public String getMessage() { - return LocalizationManager.get("networkParsingException")+" "+msg; - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java index b027e2986c3adcf3ebebef10a727ae6d33eaf2fc..166d95fa6fea99dd36a3d259c42b1ab359b45377 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ParameterSet.java @@ -108,7 +108,7 @@ public class ParameterSet implements TunableValidator permanentColumn = new ListSingleSelection<CyColumn>(booleanColumns); //Don't select any columns by default - weightColumn.setSelectedValue(null); + weightColumn.setSelectedValue(numericColumns.get(1)); forbiddenColumn.setSelectedValue(null); permanentColumn.setSelectedValue(null); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/StatusInformer.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/StatusInformer.java deleted file mode 100644 index cbc49a77cbcdcc91e12c6a13e351ce872eb5bc53..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/StatusInformer.java +++ /dev/null @@ -1,84 +0,0 @@ -package de.hhu.ba.yoshikoWrapper.core; - -import java.awt.Window; - -import javax.swing.JOptionPane; - -import org.cytoscape.work.TaskMonitor; - -import de.hhu.ba.yoshikoWrapper.swig.CplexInformer; -import de.hhu.ba.yoshikoWrapper.swig.YoshikoState; -import de.hhu.ba.yoshikoWrapper.swing.SwingUtil; - -public class StatusInformer extends CplexInformer { - - private final Window statusWindow; - private final TaskMonitor taskMonitor; - - public StatusInformer(Window statusWindow, TaskMonitor taskMonitor) { - this.statusWindow = statusWindow; - this.taskMonitor = taskMonitor; - }; - - @Override - public boolean continueOnTimeout() { - try { - int result = JOptionPane.showConfirmDialog( - statusWindow, - LocalizationManager.get("continueTimeout"), - LocalizationManager.get("timeoutTitle"), - JOptionPane.YES_NO_OPTION, - JOptionPane.INFORMATION_MESSAGE - ); - if (result == JOptionPane.YES_OPTION) { - return true; - } - return false; - } - catch(Exception e) { - e.printStackTrace(); - return false; - } - } - - @Override - public void updateStatus(YoshikoState state, double value) { - if (state == YoshikoState.SOLVING_ILP){ - if (value <= 1.0) { - taskMonitor.setStatusMessage(LocalizationManager.get("currentGap")+": "+SwingUtil.twoDecimals.format(value)+"%"); - } - } - } - - @Override - public void updateStatus(YoshikoState state) { - //TODO: Might improve performance via HashMap but probably irrelevant - if (state == YoshikoState.REDUCTION_AC) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionAC")); - } - else if (state == YoshikoState.REDUCTION_CC) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionCC")); - } - else if (state == YoshikoState.REDUCTION_CR) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionCR")); - } - else if (state == YoshikoState.REDUCTION_HE) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionHE")); - } - else if (state == YoshikoState.REDUCTION_MR) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionMR")); - } - else if (state == YoshikoState.REDUCTION_PD) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionPD")); - } - else if (state == YoshikoState.REDUCTION_SN) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_reductionSN")); - } - - else if (state == YoshikoState.SOLVING_ILP) { - taskMonitor.setStatusMessage(LocalizationManager.get("status_solvingILP")); - } - } - - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java deleted file mode 100644 index 0777d464a22f62cd6bc0df0621913cf1dfce2cdc..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2017 Philipp Spohr - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - ******************************************************************************/ -package de.hhu.ba.yoshikoWrapper.core; - -import java.io.File; - - -import org.slf4j.Logger; - -import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; -import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; - -public class YoshikoLoader { - - public static final String REQUIRED_VERSION = "2.2.0"; - - private static boolean isLoaded; - - //Symbolic Links - private static Logger logger = YoshikoLogger.getInstance().getLogger(); - - public static void loadLibrary(String libPath) { - //Attempt to load from a previously stored path - File f = new File (libPath); - if (!f.exists()) { - logger.info("Could not load the Yoshiko-library from a previously saved path! You might need to set the path manually."); - return; - } - - try { - logger.info("Attempting to load library @: "+libPath); - //Verify version ending - if (!libPath.substring(0,libPath.lastIndexOf(".")).endsWith(REQUIRED_VERSION)) { - logger.info(LocalizationManager.get("libFail")+" "+REQUIRED_VERSION); - return; - } - //Perform actual loading - System.load(libPath); - - } - catch(UnsatisfiedLinkError e) { - //This might happen as Java doesn't unload native libs - //One such case might be reloading the Cytoscape app on-the-fly - logger.error(e.getMessage()); - } - LibraryInterface.setVerbosity(3); - //update cfg - CyCore.cm.getProperties().setProperty("pathToYoshiko", libPath); - isLoaded = true; - } - - //SETTER / GETTER - - public static boolean isLibraryLoaded() { - return isLoaded; - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java index 16bb1f782a56f19b1f2ec3584415e3e744614d71..ab22f2024ff9b50071db0d9ccf18770064853154 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/graphModel/YoshikoResult.java @@ -27,7 +27,6 @@ import java.util.HashMap; import org.cytoscape.model.CyNetwork; import de.hhu.ba.yoshikoWrapper.core.ResultList; -import de.hhu.ba.yoshikoWrapper.swig.SolutionFlags; /**Basic data class that represents a CES instance internally. By using this class the C++ resources can be freed upon retrieval. @@ -39,14 +38,13 @@ public class YoshikoResult{ private HashMap<Long,YoshikoSolution> solutions; - private SolutionFlags flags; private int id; - public YoshikoResult(CyNetwork net, SolutionFlags flags) { + public YoshikoResult(CyNetwork net) { solutions = new HashMap<Long,YoshikoSolution>(); this.originalGraph = net; - this.flags = flags; + ResultList.add(this); } @@ -62,9 +60,6 @@ public class YoshikoResult{ /** * @return the flags associated with this result */ - public SolutionFlags getFlags() { - return flags; - } public void addSolution(YoshikoSolution solution) { solutions.put(solution.getId(),solution); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/ClusterEditingSolutions.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/ClusterEditingSolutions.java deleted file mode 100644 index ae586e770de1d3b690605f796256845df2c7054e..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/ClusterEditingSolutions.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class ClusterEditingSolutions { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected ClusterEditingSolutions(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(ClusterEditingSolutions obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_ClusterEditingSolutions(swigCPtr); - } - swigCPtr = 0; - } - } - - public long getNumberOfClusters(long i) { - return LibraryInterfaceJNI.ClusterEditingSolutions_getNumberOfClusters(swigCPtr, this, i); - } - - public IntVector getCluster(long i, long k) { - return new IntVector(LibraryInterfaceJNI.ClusterEditingSolutions_getCluster(swigCPtr, this, i, k), false); - } - - public SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t getSolution(long i) { - return new SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t(LibraryInterfaceJNI.ClusterEditingSolutions_getSolution(swigCPtr, this, i), false); - } - - public long getNumberOfSolutions() { - return LibraryInterfaceJNI.ClusterEditingSolutions_getNumberOfSolutions(swigCPtr, this); - } - - public SolutionFlags getFlags() { - return new SolutionFlags(LibraryInterfaceJNI.ClusterEditingSolutions_getFlags(swigCPtr, this), true); - } - - public void setFlags(SolutionFlags f) { - LibraryInterfaceJNI.ClusterEditingSolutions_setFlags(swigCPtr, this, SolutionFlags.getCPtr(f), f); - } - - public void printSolution(long index) { - LibraryInterfaceJNI.ClusterEditingSolutions_printSolution(swigCPtr, this, index); - } - - public ClusterEditingSolutions() { - this(LibraryInterfaceJNI.new_ClusterEditingSolutions(), true); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/CoreAlgorithm.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/CoreAlgorithm.java deleted file mode 100644 index 53f898899dc96ded618242cbf87b4b061c5ec030..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/CoreAlgorithm.java +++ /dev/null @@ -1,51 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class CoreAlgorithm { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected CoreAlgorithm(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(CoreAlgorithm obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_CoreAlgorithm(swigCPtr); - } - swigCPtr = 0; - } - } - - public ClusterEditingSolutions run() { - long cPtr = LibraryInterfaceJNI.CoreAlgorithm_run(swigCPtr, this); - return (cPtr == 0) ? null : new ClusterEditingSolutions(cPtr, false); - } - - public void registerCplexInformer(CplexInformer informer) { - LibraryInterfaceJNI.CoreAlgorithm_registerCplexInformer(swigCPtr, this, CplexInformer.getCPtr(informer), informer); - } - - public void cancel() { - LibraryInterfaceJNI.CoreAlgorithm_cancel(swigCPtr, this); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/CplexInformer.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/CplexInformer.java deleted file mode 100644 index f9feb9b44ea8207324f4271c2e5d22141709b1e0..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/CplexInformer.java +++ /dev/null @@ -1,70 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class CplexInformer { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected CplexInformer(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(CplexInformer obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_CplexInformer(swigCPtr); - } - swigCPtr = 0; - } - } - - protected void swigDirectorDisconnect() { - swigCMemOwn = false; - delete(); - } - - public void swigReleaseOwnership() { - swigCMemOwn = false; - LibraryInterfaceJNI.CplexInformer_change_ownership(this, swigCPtr, false); - } - - public void swigTakeOwnership() { - swigCMemOwn = true; - LibraryInterfaceJNI.CplexInformer_change_ownership(this, swigCPtr, true); - } - - public void updateStatus(YoshikoState state) { - if (getClass() == CplexInformer.class) LibraryInterfaceJNI.CplexInformer_updateStatus__SWIG_0(swigCPtr, this, state.swigValue()); else LibraryInterfaceJNI.CplexInformer_updateStatusSwigExplicitCplexInformer__SWIG_0(swigCPtr, this, state.swigValue()); - } - - public void updateStatus(YoshikoState state, double value) { - if (getClass() == CplexInformer.class) LibraryInterfaceJNI.CplexInformer_updateStatus__SWIG_1(swigCPtr, this, state.swigValue(), value); else LibraryInterfaceJNI.CplexInformer_updateStatusSwigExplicitCplexInformer__SWIG_1(swigCPtr, this, state.swigValue(), value); - } - - public boolean continueOnTimeout() { - return (getClass() == CplexInformer.class) ? LibraryInterfaceJNI.CplexInformer_continueOnTimeout(swigCPtr, this) : LibraryInterfaceJNI.CplexInformer_continueOnTimeoutSwigExplicitCplexInformer(swigCPtr, this); - } - - public CplexInformer() { - this(LibraryInterfaceJNI.new_CplexInformer(), true); - LibraryInterfaceJNI.CplexInformer_director_connect(this, swigCPtr, swigCMemOwn, true); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/DoubleVector.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/DoubleVector.java deleted file mode 100644 index 3cc3bde8320fbc88eeef394849f194df8c56b101..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/DoubleVector.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class DoubleVector { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected DoubleVector(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(DoubleVector obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_DoubleVector(swigCPtr); - } - swigCPtr = 0; - } - } - - public DoubleVector() { - this(LibraryInterfaceJNI.new_DoubleVector__SWIG_0(), true); - } - - public DoubleVector(long n) { - this(LibraryInterfaceJNI.new_DoubleVector__SWIG_1(n), true); - } - - public long size() { - return LibraryInterfaceJNI.DoubleVector_size(swigCPtr, this); - } - - public long capacity() { - return LibraryInterfaceJNI.DoubleVector_capacity(swigCPtr, this); - } - - public void reserve(long n) { - LibraryInterfaceJNI.DoubleVector_reserve(swigCPtr, this, n); - } - - public boolean isEmpty() { - return LibraryInterfaceJNI.DoubleVector_isEmpty(swigCPtr, this); - } - - public void clear() { - LibraryInterfaceJNI.DoubleVector_clear(swigCPtr, this); - } - - public void add(double x) { - LibraryInterfaceJNI.DoubleVector_add(swigCPtr, this, x); - } - - public double get(int i) { - return LibraryInterfaceJNI.DoubleVector_get(swigCPtr, this, i); - } - - public void set(int i, double val) { - LibraryInterfaceJNI.DoubleVector_set(swigCPtr, this, i, val); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/IntVector.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/IntVector.java deleted file mode 100644 index e894d457075f9ade78a542d20b1990b1a445d38f..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/IntVector.java +++ /dev/null @@ -1,78 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class IntVector { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected IntVector(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(IntVector obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_IntVector(swigCPtr); - } - swigCPtr = 0; - } - } - - public IntVector() { - this(LibraryInterfaceJNI.new_IntVector__SWIG_0(), true); - } - - public IntVector(long n) { - this(LibraryInterfaceJNI.new_IntVector__SWIG_1(n), true); - } - - public long size() { - return LibraryInterfaceJNI.IntVector_size(swigCPtr, this); - } - - public long capacity() { - return LibraryInterfaceJNI.IntVector_capacity(swigCPtr, this); - } - - public void reserve(long n) { - LibraryInterfaceJNI.IntVector_reserve(swigCPtr, this, n); - } - - public boolean isEmpty() { - return LibraryInterfaceJNI.IntVector_isEmpty(swigCPtr, this); - } - - public void clear() { - LibraryInterfaceJNI.IntVector_clear(swigCPtr, this); - } - - public void add(int x) { - LibraryInterfaceJNI.IntVector_add(swigCPtr, this, x); - } - - public int get(int i) { - return LibraryInterfaceJNI.IntVector_get(swigCPtr, this, i); - } - - public void set(int i, int val) { - LibraryInterfaceJNI.IntVector_set(swigCPtr, this, i, val); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInput.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInput.java deleted file mode 100644 index a2c4e84c6933e82c13f6ca1f27feba03a50120f0..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInput.java +++ /dev/null @@ -1,58 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class LibraryInput { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected LibraryInput(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(LibraryInput obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_LibraryInput(swigCPtr); - } - swigCPtr = 0; - } - } - - public LibraryInput() { - this(LibraryInterfaceJNI.new_LibraryInput(), true); - } - - public void addEdge(long sourceID, long targetID, double cost) { - LibraryInterfaceJNI.LibraryInput_addEdge__SWIG_0(swigCPtr, this, sourceID, targetID, cost); - } - - public void addEdge(long sourceID, long targetID, double cost, boolean permanent, boolean forbidden) { - LibraryInterfaceJNI.LibraryInput_addEdge__SWIG_1(swigCPtr, this, sourceID, targetID, cost, permanent, forbidden); - } - - public void setSize(long id) { - LibraryInterfaceJNI.LibraryInput_setSize(swigCPtr, this, id); - } - - public void setDefaultInsertionCost(double cost) { - LibraryInterfaceJNI.LibraryInput_setDefaultInsertionCost(swigCPtr, this, cost); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInterface.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInterface.java deleted file mode 100644 index 227ab8a923211019d5bf0f831f9055addfadd5f1..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInterface.java +++ /dev/null @@ -1,33 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class LibraryInterface { - public static String getVersionString() { - return LibraryInterfaceJNI.getVersionString(); - } - - public static void setTimeLimit(int limit) { - LibraryInterfaceJNI.setTimeLimit(limit); - } - - public static void setThreadLimit(int limit) { - LibraryInterfaceJNI.setThreadLimit(limit); - } - - public static void setVerbosity(int level) { - LibraryInterfaceJNI.setVerbosity(level); - } - - public static CoreAlgorithm getRun(LibraryInput input, int nrOptimalSolutions, String rulesBitMask, double multiplicativeFactor, boolean useHeuristic, boolean separatePartitionCuts, boolean separateTriangles, int targetClusterCount) { - long cPtr = LibraryInterfaceJNI.getRun(LibraryInput.getCPtr(input), input, nrOptimalSolutions, rulesBitMask, multiplicativeFactor, useHeuristic, separatePartitionCuts, separateTriangles, targetClusterCount); - return (cPtr == 0) ? null : new CoreAlgorithm(cPtr, false); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInterfaceJNI.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInterfaceJNI.java deleted file mode 100644 index 49549a4b657af8b0dd0a8ef300f2319e92c77f75..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/LibraryInterfaceJNI.java +++ /dev/null @@ -1,99 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class LibraryInterfaceJNI { - public final static native long new_SolutionFlags(); - public final static native void SolutionFlags_totalCost_set(long jarg1, SolutionFlags jarg1_, double jarg2); - public final static native double SolutionFlags_totalCost_get(long jarg1, SolutionFlags jarg1_); - public final static native void SolutionFlags_timedOut_set(long jarg1, SolutionFlags jarg1_, boolean jarg2); - public final static native boolean SolutionFlags_timedOut_get(long jarg1, SolutionFlags jarg1_); - public final static native void SolutionFlags_ilpGenerated_set(long jarg1, SolutionFlags jarg1_, boolean jarg2); - public final static native boolean SolutionFlags_ilpGenerated_get(long jarg1, SolutionFlags jarg1_); - public final static native void SolutionFlags_optimal_set(long jarg1, SolutionFlags jarg1_, boolean jarg2); - public final static native boolean SolutionFlags_optimal_get(long jarg1, SolutionFlags jarg1_); - public final static native void SolutionFlags_reducedInstances_set(long jarg1, SolutionFlags jarg1_, int jarg2); - public final static native int SolutionFlags_reducedInstances_get(long jarg1, SolutionFlags jarg1_); - public final static native void SolutionFlags_solvedInstances_set(long jarg1, SolutionFlags jarg1_, int jarg2); - public final static native int SolutionFlags_solvedInstances_get(long jarg1, SolutionFlags jarg1_); - public final static native void SolutionFlags_lastGap_set(long jarg1, SolutionFlags jarg1_, double jarg2); - public final static native double SolutionFlags_lastGap_get(long jarg1, SolutionFlags jarg1_); - public final static native void delete_SolutionFlags(long jarg1); - public final static native long new_IntVector__SWIG_0(); - public final static native long new_IntVector__SWIG_1(long jarg1); - public final static native long IntVector_size(long jarg1, IntVector jarg1_); - public final static native long IntVector_capacity(long jarg1, IntVector jarg1_); - public final static native void IntVector_reserve(long jarg1, IntVector jarg1_, long jarg2); - public final static native boolean IntVector_isEmpty(long jarg1, IntVector jarg1_); - public final static native void IntVector_clear(long jarg1, IntVector jarg1_); - public final static native void IntVector_add(long jarg1, IntVector jarg1_, int jarg2); - public final static native int IntVector_get(long jarg1, IntVector jarg1_, int jarg2); - public final static native void IntVector_set(long jarg1, IntVector jarg1_, int jarg2, int jarg3); - public final static native void delete_IntVector(long jarg1); - public final static native long new_DoubleVector__SWIG_0(); - public final static native long new_DoubleVector__SWIG_1(long jarg1); - public final static native long DoubleVector_size(long jarg1, DoubleVector jarg1_); - public final static native long DoubleVector_capacity(long jarg1, DoubleVector jarg1_); - public final static native void DoubleVector_reserve(long jarg1, DoubleVector jarg1_, long jarg2); - public final static native boolean DoubleVector_isEmpty(long jarg1, DoubleVector jarg1_); - public final static native void DoubleVector_clear(long jarg1, DoubleVector jarg1_); - public final static native void DoubleVector_add(long jarg1, DoubleVector jarg1_, double jarg2); - public final static native double DoubleVector_get(long jarg1, DoubleVector jarg1_, int jarg2); - public final static native void DoubleVector_set(long jarg1, DoubleVector jarg1_, int jarg2, double jarg3); - public final static native void delete_DoubleVector(long jarg1); - public final static native long ClusterEditingSolutions_getNumberOfClusters(long jarg1, ClusterEditingSolutions jarg1_, long jarg2); - public final static native long ClusterEditingSolutions_getCluster(long jarg1, ClusterEditingSolutions jarg1_, long jarg2, long jarg3); - public final static native long ClusterEditingSolutions_getSolution(long jarg1, ClusterEditingSolutions jarg1_, long jarg2); - public final static native long ClusterEditingSolutions_getNumberOfSolutions(long jarg1, ClusterEditingSolutions jarg1_); - public final static native long ClusterEditingSolutions_getFlags(long jarg1, ClusterEditingSolutions jarg1_); - public final static native void ClusterEditingSolutions_setFlags(long jarg1, ClusterEditingSolutions jarg1_, long jarg2, SolutionFlags jarg2_); - public final static native void ClusterEditingSolutions_printSolution(long jarg1, ClusterEditingSolutions jarg1_, long jarg2); - public final static native long new_ClusterEditingSolutions(); - public final static native void delete_ClusterEditingSolutions(long jarg1); - public final static native long new_LibraryInput(); - public final static native void delete_LibraryInput(long jarg1); - public final static native void LibraryInput_addEdge__SWIG_0(long jarg1, LibraryInput jarg1_, long jarg2, long jarg3, double jarg4); - public final static native void LibraryInput_addEdge__SWIG_1(long jarg1, LibraryInput jarg1_, long jarg2, long jarg3, double jarg4, boolean jarg5, boolean jarg6); - public final static native void LibraryInput_setSize(long jarg1, LibraryInput jarg1_, long jarg2); - public final static native void LibraryInput_setDefaultInsertionCost(long jarg1, LibraryInput jarg1_, double jarg2); - public final static native void CplexInformer_updateStatus__SWIG_0(long jarg1, CplexInformer jarg1_, int jarg2); - public final static native void CplexInformer_updateStatusSwigExplicitCplexInformer__SWIG_0(long jarg1, CplexInformer jarg1_, int jarg2); - public final static native void CplexInformer_updateStatus__SWIG_1(long jarg1, CplexInformer jarg1_, int jarg2, double jarg3); - public final static native void CplexInformer_updateStatusSwigExplicitCplexInformer__SWIG_1(long jarg1, CplexInformer jarg1_, int jarg2, double jarg3); - public final static native boolean CplexInformer_continueOnTimeout(long jarg1, CplexInformer jarg1_); - public final static native boolean CplexInformer_continueOnTimeoutSwigExplicitCplexInformer(long jarg1, CplexInformer jarg1_); - public final static native void delete_CplexInformer(long jarg1); - public final static native long new_CplexInformer(); - public final static native void CplexInformer_director_connect(CplexInformer obj, long cptr, boolean mem_own, boolean weak_global); - public final static native void CplexInformer_change_ownership(CplexInformer obj, long cptr, boolean take_or_release); - public final static native long CoreAlgorithm_run(long jarg1, CoreAlgorithm jarg1_); - public final static native void CoreAlgorithm_registerCplexInformer(long jarg1, CoreAlgorithm jarg1_, long jarg2, CplexInformer jarg2_); - public final static native void CoreAlgorithm_cancel(long jarg1, CoreAlgorithm jarg1_); - public final static native void delete_CoreAlgorithm(long jarg1); - public final static native String getVersionString(); - public final static native void setTimeLimit(int jarg1); - public final static native void setThreadLimit(int jarg1); - public final static native void setVerbosity(int jarg1); - public final static native long getRun(long jarg1, LibraryInput jarg1_, int jarg2, String jarg3, double jarg4, boolean jarg5, boolean jarg6, boolean jarg7, int jarg8); - - public static void SwigDirector_CplexInformer_updateStatus__SWIG_0(CplexInformer jself, int state) { - jself.updateStatus(YoshikoState.swigToEnum(state)); - } - public static void SwigDirector_CplexInformer_updateStatus__SWIG_1(CplexInformer jself, int state, double value) { - jself.updateStatus(YoshikoState.swigToEnum(state), value); - } - public static boolean SwigDirector_CplexInformer_continueOnTimeout(CplexInformer jself) { - return jself.continueOnTimeout(); - } - - private final static native void swig_module_init(); - static { - swig_module_init(); - } -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t.java deleted file mode 100644 index 5f06b6495c6f94fcc62edbe282f5dec04e779d58..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t.java +++ /dev/null @@ -1,26 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t { - private transient long swigCPtr; - - protected SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t(long cPtr, @SuppressWarnings("unused") boolean futureUse) { - swigCPtr = cPtr; - } - - protected SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t() { - swigCPtr = 0; - } - - protected static long getCPtr(SWIGTYPE_p_std__vectorT_std__vectorT_int_t_t obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -} - diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/SolutionFlags.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/SolutionFlags.java deleted file mode 100644 index cff40e0f4503b1a95f04f3283073d82bb8482a02..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/SolutionFlags.java +++ /dev/null @@ -1,98 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public class SolutionFlags { - private transient long swigCPtr; - protected transient boolean swigCMemOwn; - - protected SolutionFlags(long cPtr, boolean cMemoryOwn) { - swigCMemOwn = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr(SolutionFlags obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } - - protected void finalize() { - delete(); - } - - public synchronized void delete() { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - LibraryInterfaceJNI.delete_SolutionFlags(swigCPtr); - } - swigCPtr = 0; - } - } - - public SolutionFlags() { - this(LibraryInterfaceJNI.new_SolutionFlags(), true); - } - - public void setTotalCost(double value) { - LibraryInterfaceJNI.SolutionFlags_totalCost_set(swigCPtr, this, value); - } - - public double getTotalCost() { - return LibraryInterfaceJNI.SolutionFlags_totalCost_get(swigCPtr, this); - } - - public void setTimedOut(boolean value) { - LibraryInterfaceJNI.SolutionFlags_timedOut_set(swigCPtr, this, value); - } - - public boolean getTimedOut() { - return LibraryInterfaceJNI.SolutionFlags_timedOut_get(swigCPtr, this); - } - - public void setIlpGenerated(boolean value) { - LibraryInterfaceJNI.SolutionFlags_ilpGenerated_set(swigCPtr, this, value); - } - - public boolean getIlpGenerated() { - return LibraryInterfaceJNI.SolutionFlags_ilpGenerated_get(swigCPtr, this); - } - - public void setOptimal(boolean value) { - LibraryInterfaceJNI.SolutionFlags_optimal_set(swigCPtr, this, value); - } - - public boolean getOptimal() { - return LibraryInterfaceJNI.SolutionFlags_optimal_get(swigCPtr, this); - } - - public void setReducedInstances(int value) { - LibraryInterfaceJNI.SolutionFlags_reducedInstances_set(swigCPtr, this, value); - } - - public int getReducedInstances() { - return LibraryInterfaceJNI.SolutionFlags_reducedInstances_get(swigCPtr, this); - } - - public void setSolvedInstances(int value) { - LibraryInterfaceJNI.SolutionFlags_solvedInstances_set(swigCPtr, this, value); - } - - public int getSolvedInstances() { - return LibraryInterfaceJNI.SolutionFlags_solvedInstances_get(swigCPtr, this); - } - - public void setLastGap(double value) { - LibraryInterfaceJNI.SolutionFlags_lastGap_set(swigCPtr, this, value); - } - - public double getLastGap() { - return LibraryInterfaceJNI.SolutionFlags_lastGap_get(swigCPtr, this); - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/YoshikoState.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swig/YoshikoState.java deleted file mode 100644 index b588da06abdab6a93a0eab2cd3ac276c51617c0b..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swig/YoshikoState.java +++ /dev/null @@ -1,63 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 3.0.8 - * - * Do not make changes to this file unless you know what you are doing--modify - * the SWIG interface file instead. - * ----------------------------------------------------------------------------- */ - -package de.hhu.ba.yoshikoWrapper.swig; - -public final class YoshikoState { - public final static YoshikoState PARSING_INPUT = new YoshikoState("PARSING_INPUT", 0); - public final static YoshikoState REDUCTION_AC = new YoshikoState("REDUCTION_AC", 1); - public final static YoshikoState REDUCTION_CR = new YoshikoState("REDUCTION_CR", 2); - public final static YoshikoState REDUCTION_CC = new YoshikoState("REDUCTION_CC", 3); - public final static YoshikoState REDUCTION_PD = new YoshikoState("REDUCTION_PD", 4); - public final static YoshikoState REDUCTION_HE = new YoshikoState("REDUCTION_HE", 5); - public final static YoshikoState REDUCTION_MR = new YoshikoState("REDUCTION_MR", 6); - public final static YoshikoState REDUCTION_SN = new YoshikoState("REDUCTION_SN", 7); - public final static YoshikoState SOLVING_HEURISTIC = new YoshikoState("SOLVING_HEURISTIC", 8); - public final static YoshikoState SOLVING_ILP = new YoshikoState("SOLVING_ILP", 9); - public final static YoshikoState PROCESS_SOLUTION = new YoshikoState("PROCESS_SOLUTION", 10); - - public final int swigValue() { - return swigValue; - } - - public String toString() { - return swigName; - } - - public static YoshikoState swigToEnum(int swigValue) { - if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue) - return swigValues[swigValue]; - for (int i = 0; i < swigValues.length; i++) - if (swigValues[i].swigValue == swigValue) - return swigValues[i]; - throw new IllegalArgumentException("No enum " + YoshikoState.class + " with value " + swigValue); - } - - private YoshikoState(String swigName) { - this.swigName = swigName; - this.swigValue = swigNext++; - } - - private YoshikoState(String swigName, int swigValue) { - this.swigName = swigName; - this.swigValue = swigValue; - swigNext = swigValue+1; - } - - private YoshikoState(String swigName, YoshikoState swigEnum) { - this.swigName = swigName; - this.swigValue = swigEnum.swigValue; - swigNext = this.swigValue+1; - } - - private static YoshikoState[] swigValues = { PARSING_INPUT, REDUCTION_AC, REDUCTION_CR, REDUCTION_CC, REDUCTION_PD, REDUCTION_HE, REDUCTION_MR, REDUCTION_SN, SOLVING_HEURISTIC, SOLVING_ILP, PROCESS_SOLUTION }; - private static int swigNext = 0; - private final int swigValue; - private final String swigName; -} - diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/LibraryPanelFactory.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/LibraryPanelFactory.java deleted file mode 100644 index 72ab8aa22857806d19527a5db76de5192f774d85..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/LibraryPanelFactory.java +++ /dev/null @@ -1,120 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2017 Philipp Spohr - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - ******************************************************************************/ -package de.hhu.ba.yoshikoWrapper.swing; - -import java.awt.Desktop; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.net.URI; - -import javax.swing.GroupLayout; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.GroupLayout.Alignment; - - -import org.cytoscape.util.swing.BasicCollapsiblePanel; - -import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; -import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; -import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; -import de.hhu.ba.yoshikoWrapper.swing.components.LibStatusPanel; - -public class LibraryPanelFactory{ - - - public static BasicCollapsiblePanel createLibraryPanel() { - final BasicCollapsiblePanel ret = new BasicCollapsiblePanel(LocalizationManager.get("libraryPanel")); - - final LibStatusPanel libStatusPanel; - final JButton searchLibButton; - final JButton getYoshiko; - - //SWING COMPONENT INITIALIZATION - libStatusPanel = new LibStatusPanel(); - searchLibButton = new JButton(LocalizationManager.get("resolveLibPath")); - - libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded()); - - searchLibButton.setEnabled(!YoshikoLoader.isLibraryLoaded()); - - searchLibButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - final JFileChooser c = new JFileChooser(); - int returnVal = c.showOpenDialog(ret); - if (returnVal == JFileChooser.APPROVE_OPTION) { - YoshikoLoader.loadLibrary(c.getSelectedFile().getAbsolutePath()); - } - libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded()); - searchLibButton.setEnabled(!YoshikoLoader.isLibraryLoaded()); - } - }); - - getYoshiko = new JButton(LocalizationManager.get("getYoshiko")); - getYoshiko.addActionListener(new ActionListener() { - - @Override - public void actionPerformed(ActionEvent e) { - // TODO: Far Future: Fetch Yoshiko and auto-compile - Desktop desktop = Desktop.getDesktop(); - if (desktop != null){ - if(desktop.isSupported(Desktop.Action.BROWSE)) { - try { - desktop.browse(URI.create("https://github.com/spqrPh/yoshiko")); - } catch (Exception ex) { - YoshikoLogger.getInstance().getLogger().info("Can't access desktop browser!"); - ex.printStackTrace(); - } - } - } - } - - }); - - SwingUtil.addAll(ret, - libStatusPanel, - searchLibButton, - getYoshiko - ); - - //Layout - GroupLayout layout = new GroupLayout(ret.getContentPane()); - - layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING,true) - .addComponent(libStatusPanel) - .addComponent(searchLibButton) - .addComponent(getYoshiko) - ); - - layout.setVerticalGroup(layout.createSequentialGroup() - .addComponent(libStatusPanel) - .addComponent(searchLibButton) - .addComponent(getYoshiko) - ); - - - ret.getContentPane().setLayout(layout); - - return ret; - } -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LibStatusPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LibStatusPanel.java deleted file mode 100644 index 719915e834f5047260cf69cc982fb8b84f7a8775..0000000000000000000000000000000000000000 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/LibStatusPanel.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (C) 2017 Philipp Spohr - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - ******************************************************************************/ -package de.hhu.ba.yoshikoWrapper.swing.components; - -import java.awt.Color; - -import javax.swing.JLabel; -import javax.swing.JPanel; - -import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; -import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; -import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; -import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader; -/** - * Simple JPanel visually representing whether or not the Yoshiko Lib is loaded and showing some basic info - * - */ -@SuppressWarnings("serial") -public class LibStatusPanel extends JPanel { - - final JLabel yoshikoVersionLabel; - - public LibStatusPanel() { - yoshikoVersionLabel = new JLabel(); - this.add(yoshikoVersionLabel); - } - - /** - * Adjusts the style accordingly by changing its color and updating its text - */ - public void setStyle(boolean libraryLoaded) { - if(libraryLoaded) { - yoshikoVersionLabel.setText(LocalizationManager.get("yoshVersion")+" "+YoshikoLoader.REQUIRED_VERSION+"("+LibraryInterface.getVersionString()+")"); - yoshikoVersionLabel.setForeground(GraphicsLoader.yoshikoGreen); - } - else { - yoshikoVersionLabel.setText(LocalizationManager.get("noLibTitle")); - yoshikoVersionLabel.setForeground(Color.RED); - } - } - -} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java index b8277bc372c9f538336b697bbd04340ce1112096..8d2ddfbab332f3a914a46b5fd137c4545005430e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/MainPanel.java @@ -47,24 +47,24 @@ import javax.swing.JScrollPane; import javax.swing.LayoutStyle; import javax.swing.ScrollPaneConstants; +import de.hhu.ba.yoshikoWrapper.taskFactories.CommandTaskFactory; +import de.hhu.ba.yoshikoWrapper.taskFactories.YoshikoCommand; +import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; import org.cytoscape.model.CyNetwork; import org.cytoscape.util.swing.BasicCollapsiblePanel; -import org.cytoscape.work.AbstractTask; import org.cytoscape.work.TaskIterator; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.core.ParameterSet; -import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.cytoUtil.CommandExecutor; import de.hhu.ba.yoshikoWrapper.cytoUtil.GraphAnalyzer; import de.hhu.ba.yoshikoWrapper.help.HelpLinks; import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader; -import de.hhu.ba.yoshikoWrapper.swing.LibraryPanelFactory; import de.hhu.ba.yoshikoWrapper.swing.SwingUtil; -import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask; +import org.cytoscape.work.TaskManager; /**This class describes the Swing Panel that the user interacts with in cytoscape * @@ -91,7 +91,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { private final LanguageSwitcherPanel langPanel; private final BasicCollapsiblePanel langWrapper; - private final BasicCollapsiblePanel libraryPanel; //Those don't work really as collapsible panels and cause glitches which forces the workaround of wrapping them //Probably someone used getClass() == instead of instanceof so extending BasicCollapsiblePanel is sadly not possible @@ -137,12 +136,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { langWrapper = new BasicCollapsiblePanel(LocalizationManager.get("switchLanguage")); langWrapper.add(langPanel); - libraryPanel = LibraryPanelFactory.createLibraryPanel(); - //If no library is loaded yet the obvious panel should be showing up - if (!YoshikoLoader.isLibraryLoaded()) { - libraryPanel.setCollapsed(false); - } - ecPanel = new EditCostPanel(); ecPanelWrapper = new BasicCollapsiblePanel(LocalizationManager.get("editingCostPanel")); ecPanelWrapper.add(ecPanel); @@ -162,7 +155,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { //Add components to the scrollable part of the main panel SwingUtil.addAll(scrollableContent, langWrapper, - libraryPanel, ecPanelWrapper, reductionWrapper, opWrapper @@ -217,7 +209,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { scrollLayout.setHorizontalGroup(scrollLayout.createParallelGroup(Alignment.LEADING,true) .addComponent(langWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) - .addComponent(libraryPanel,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(ecPanelWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(reductionWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) .addComponent(opWrapper,DEFAULT_SIZE, DEFAULT_SIZE,DEFAULT_SIZE) @@ -236,7 +227,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { scrollLayout.setVerticalGroup(scrollLayout.createSequentialGroup() .addComponent(langWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) - .addComponent(libraryPanel,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(ecPanelWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(reductionWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) .addComponent(opWrapper,DEFAULT_SIZE,DEFAULT_SIZE,PREFERRED_SIZE) @@ -287,18 +277,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { ); } - //Annotation: Currently Cytoscape is really weird concerning directed/undirected edges - //There is an API function isDirected() for edges but all edges are directed - //I'll leave this commented out until CS makes sense - -// if (GraphAnalyzer.isDirected(networkToBeProcessed)) { -// JOptionPane.showMessageDialog( -// null, -// LocalizationManager.get("directedGraphWarning"), -// LocalizationManager.get("optionpane_title"), -// JOptionPane.WARNING_MESSAGE -// ); -// } //SWING BLACK MAGIC Window noWindow = null; @@ -311,30 +289,16 @@ public class MainPanel extends JPanel implements CytoPanelComponent { statusWindow.setAlwaysOnTop(false); //SWING BLACK MAGIC - if (YoshikoLoader.isLibraryLoaded()){ - AbstractTask yoshiko = new AlgorithmTask( - popupLevel, - fetchParameters(networkToBeProcessed) - ); - /** - * Don't queue multiple runs at once because that will get messy - */ - if (!iterator.hasNext()) { - iterator.append(yoshiko); + CommandTaskFactory commandTaskFactory = new CommandTaskFactory(YoshikoCommand.PERFORM_ALGORITHM); + TaskIterator taskIterator = commandTaskFactory.createTaskIterator(); - CyCore.dialogTaskManager.setExecutionContext(statusWindow); - CyCore.dialogTaskManager.execute(iterator); - - } - } - else { - JOptionPane.showMessageDialog( - null, - LocalizationManager.get("noLibTitle"), - LocalizationManager.get("noLibMessage"), - JOptionPane.ERROR_MESSAGE - ); + try { + CyCore.runAndWait(taskIterator); + } catch (InterruptedException ex) { + ex.printStackTrace(); } + + System.out.println(); } }; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java index d276d08c05343ca9a817a6aeeb697059abd0867f..9d39b11d65d0212a18d43bff3806c3f73413d8f4 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/ResultPanel.java @@ -125,34 +125,6 @@ NetworkAboutToBeDestroyedListener marker = new BasicCollapsiblePanel(LocalizationManager.get("solutionMarker")); marker.setLayout(new BoxLayout(marker,BoxLayout.Y_AXIS)); - JLabel costLabel = new JLabel(LocalizationManager.get("cost")+" "+result.getFlags().getTotalCost()); - marker.add(costLabel); - - if (result.getFlags().getIlpGenerated()) { - //TODO: Move to MarkerPanel for better codestyle - //Optional Markers - - if(result.getFlags().getOptimal()) { - JLabel optimalLabel; - optimalLabel = new JLabel(LocalizationManager.get("optimal")); - optimalLabel.setForeground(GraphicsLoader.yoshikoGreen); - marker.add(optimalLabel); - } - else { - JLabel optimalLabel; - optimalLabel = new JLabel(LocalizationManager.get("notOptimal")); - optimalLabel.setForeground(Color.RED); - marker.add(optimalLabel); - marker.add(new JLabel(result.getFlags().getSolvedInstances()+"/"+result.getFlags().getReducedInstances()+" "+LocalizationManager.get("redSolved"))); - marker.add(new JLabel(LocalizationManager.get("lastInstanceGap")+" "+(int)(100*result.getFlags().getLastGap())+"%")); - } - - if (result.getFlags().getTimedOut()) { - marker.add(new JLabel(LocalizationManager.get("timeoutMarker"))); - } - marker.setCollapsed(false); - } - this.add(marker); destroyButton = new JButton(LocalizationManager.get("discardSolution")); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java index 3d0d53fb7412c0e7905c422f419a78718ce20882..65c4a5e0a3f019cff91d7e1f2c8a63569fbe0f3a 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java @@ -22,16 +22,10 @@ package de.hhu.ba.yoshikoWrapper.tasks; import java.awt.Window; -import java.util.Properties; -import javax.swing.SwingUtilities; - -import org.cytoscape.application.swing.CytoPanel; -import org.cytoscape.application.swing.CytoPanelComponent; -import org.cytoscape.application.swing.CytoPanelName; -import org.cytoscape.application.swing.CytoPanelState; -import org.cytoscape.model.CyColumn; -import org.cytoscape.model.CyNode; +import de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm.YoshikoAlgoritmController; +import org.cytoscape.model.CyNetwork; +import org.cytoscape.model.CyTable; import org.cytoscape.work.AbstractTask; import org.cytoscape.work.ContainsTunables; import org.cytoscape.work.ObservableTask; @@ -41,20 +35,9 @@ import org.slf4j.Logger; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; -import de.hhu.ba.yoshikoWrapper.core.NetworkParser; import de.hhu.ba.yoshikoWrapper.core.ParameterSet; -import de.hhu.ba.yoshikoWrapper.core.StatusInformer; -import de.hhu.ba.yoshikoWrapper.cytoUtil.GraphAnalyzer; -import de.hhu.ba.yoshikoWrapper.cytoUtil.NodeMap; -import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoCluster; import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult; -import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoSolution; import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; -import de.hhu.ba.yoshikoWrapper.swig.ClusterEditingSolutions; -import de.hhu.ba.yoshikoWrapper.swig.CoreAlgorithm; -import de.hhu.ba.yoshikoWrapper.swig.IntVector; -import de.hhu.ba.yoshikoWrapper.swig.LibraryInput; -import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; import de.hhu.ba.yoshikoWrapper.swing.components.ResultPanel; @@ -77,13 +60,6 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab @ContainsTunables public ParameterSet parameterSet = null; - - - //Temps, pointing to and need to be freed in C++ - private LibraryInput c_input; - private ClusterEditingSolutions c_result; - private CoreAlgorithm c_algorithm; - private ResultPanel resultPanel; private YoshikoResult result; @@ -92,7 +68,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab /** * Default constructor, creates a new AlgorithmTask * @param statusWindow The Window in which the status-bar is to be shown, can be null - * @param net The network that is to be clustered + // * @param net The network that is to be clustered * @param parameterSet The parameter set specifying the clustering mode */ public AlgorithmTask( @@ -106,6 +82,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab @Override public void run(TaskMonitor taskMonitor) throws Exception { + CyNetwork networkToBeProcessed = CyCore.cy.getCurrentNetwork(); //TODO: Improve setProgress values @@ -118,15 +95,13 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab throw new Exception("CoreAlgorithm called on a net that is NULL!"); //TODO: Localize } - //Set time limit - LibraryInterface.setTimeLimit(parameterSet.timeLimit); - if (parameterSet.disableMultiThreading) { - LibraryInterface.setThreadLimit(1); - } - else { - LibraryInterface.setThreadLimit(0); - } + YoshikoAlgoritmController yoshikoAlgoritmController = new YoshikoAlgoritmController(parameterSet); + yoshikoAlgoritmController.controllAlgorithm(); + + CyTable table = networkToBeProcessed.getDefaultEdgeTable(); + +/* //Create a node map to identify nodes and eges in the solution NodeMap nodeMap = new NodeMap(parameterSet.net); taskMonitor.setProgress(0.1); @@ -136,15 +111,6 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab CyColumn permanentColumn = parameterSet.getPermanentColumn(); CyColumn forbiddenColumn = parameterSet.getForbiddenColumn(); - //Generate an c_input instance from the network - c_input = NetworkParser.parseNetwork( - parameterSet.net, - nodeMap, - weightColumn, - permanentColumn, - forbiddenColumn, - parameterSet.defaultDeletionCost - ); taskMonitor.setProgress(0.2); boolean containsRealValues = GraphAnalyzer.containsRealValues( @@ -155,90 +121,19 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab parameterSet.defaultInsertionCost, parameterSet.defaultDeletionCost); - //Suggest reduction rules - if (parameterSet.suggestReduction) { - parameterSet.reductionRulesBitMask = GraphAnalyzer.suggestReductionRules(containsRealValues, parameterSet.useHeuristic); - } - //Set the default value for insertion cost - c_input.setDefaultInsertionCost(parameterSet.defaultInsertionCost); - - System.out.print(parameterSet.toString()); //TODO: Move to debug logger - - //Call Yoshiko <<< Algorithm is performed here - c_algorithm = LibraryInterface.getRun(c_input, - parameterSet.solCount, - parameterSet.reductionRulesBitMask, - parameterSet.snrMultFactor, - parameterSet.useHeuristic, - parameterSet.usePartitionCuts, - parameterSet.useTriangleCuts, - parameterSet.clusterCount - ); - c_algorithm.registerCplexInformer(new StatusInformer(statusWindow,taskMonitor)); - - c_result = c_algorithm.run(); + System.out.print(parameterSet.toString()); //TODO: Move to debug logger taskMonitor.setProgress(0.9); - checkForInvalidSolutions(c_result); - - long numberOfSolutions = c_result.getNumberOfSolutions(); - - taskMonitor.setStatusMessage("Found: "+numberOfSolutions+" solutions!"); //TODO: Localize - - result = new YoshikoResult(parameterSet.net,c_result.getFlags()); - - //Loop over (multiple) solutions - for (long i=0;i<numberOfSolutions;i++) { - - taskMonitor.setStatusMessage("Processing solution "+(i+1)+" of "+numberOfSolutions); - - YoshikoSolution solution = new YoshikoSolution(result,i); - - String columnName = SOLUTION_COLUMN_PREFIX+(i+1); + taskMonitor.setStatusMessage("Found: "+"okkkkkkkkkkkkk solutions!"); //TODO: Localize - parameterSet.net.getDefaultNodeTable().deleteColumn(columnName); - parameterSet.net.getDefaultNodeTable().createColumn(columnName, String.class, false); - //Fetch number of clusters in the solution - long numberOfClusters = c_result.getNumberOfClusters(i); - - //Loop over clusters - for (long k=0;k<numberOfClusters;k++) { - //Create java instance - YoshikoCluster cluster = new YoshikoCluster(solution,k); - - - taskMonitor.setStatusMessage("Processing clusters "+(k+1)+" of "+numberOfClusters); - - IntVector clusterVector = c_result.getCluster(i, k); - - long sizeOfCluster = clusterVector.size(); - for (int l=0;l<sizeOfCluster;l++) { //Unsafe mismatch int long - //taskMonitor.setStatusMessage("Processing node "+(l+1)+ " of "+sizeOfCluster); - int nodeID = clusterVector.get(l); - CyNode node = nodeMap.indexOf(nodeID); //<<< Another int/long conversion - cluster.addNode(node); - - parameterSet.net.getRow(node).set(columnName, ""+(k+1)); //Add Cluster ID in table (Remove in final version?) - } - //Register clusters with solution for further reference - solution.addCluster(cluster); - } - //Sort clusters by size, descending as the biggest clusters are usually the most relevant - //solution.sortClusters(YoshikoCluster.lessThanComparator); - //Register solution with c_result for further reference - result.addSolution(solution); - } taskMonitor.setProgress(0.99); - //At this point the C++ objects can be freed, in case that the algorithm terminates beforehand they need to be cleaned-up elsewhere - c_algorithm.delete(); - c_input.delete(); - c_result.delete(); + //Generate solutionsPanel resultPanel = new ResultPanel(result); @@ -261,54 +156,10 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab } ); //eastPanel.getThisComponent().revalidate(); - +*/ } - /** - * Simple helper function that analyzes C++ results and identifies solutions that are not usable or meaningful - * @param result The ClusterEditingSolutions object generated in C++ by a Yoshiko run - * @throws Exception Throws an exception if the result is not usable - */ - private void checkForInvalidSolutions(ClusterEditingSolutions result) throws Exception { - //TODO: Feasible might be the wrong word here - if (result == null) { - //There was no c_result object generated at all - throw new Exception(LocalizationManager.get("noFeasible")); - } - - if (result.getNumberOfSolutions() == 0) { - //The c_result object is empty - throw new Exception(LocalizationManager.get("noFeasible")); - } - if (result.getNumberOfSolutions() == 1) { - //The c_result doesn't contain any clusters - if (result.getNumberOfClusters(0) == 0) { - throw new Exception(LocalizationManager.get("noFeasible")); - } - } - - } - @Override - public void cancel() { - //Free C++ resources - if (c_algorithm != null) { - //System.out.println("Deleting CoreAlgorithm instance!"); - c_algorithm.cancel(); - c_algorithm.delete(); - } - if (c_input != null) { - c_input.delete(); - } - if (c_result != null) { - c_result.delete(); - } - //Delete (incomplete) c_result panel - if (resultPanel != null) { - resultPanel.deleteResult(); - } - super.cancel(); - } @SuppressWarnings("unchecked") @Override diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/BinaryHeap.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/BinaryHeap.java new file mode 100644 index 0000000000000000000000000000000000000000..a9156e409187bf8fb31c8585aa5dc1f281c5f3e1 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/BinaryHeap.java @@ -0,0 +1,130 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +import java.util.*; + +public class BinaryHeap { + ArrayList<Double> list = new ArrayList(); + HashMap<Integer, YoshikoEdge> map = new HashMap<>(); + + public BinaryHeap(){ + list.add(Double.NEGATIVE_INFINITY); + map.put(0, null); + } + + public void add(YoshikoEdge edge){ + + list.add(edge.maxIcfIcp); + map.put(list.size()-1, edge); + + checkParent(list.size()-1); + } + + public void add(Set<YoshikoEdge> edgeSet){ + for(YoshikoEdge edge : edgeSet){ + add(edge); + } + } + + public void remove(YoshikoEdge edge){ + int index = getIndexFromValue(edge); + + if (index < 0){ + //Die Kante wurde bereits auf "forbidden" gesetzt + return; + } + + map.replace(index, map.get(map.size()-1)); + map.remove(map.size()-1); + + list.set(index, list.get(list.size()-1)); + list.remove(list.size()-1); + } + + public void remove(Set<YoshikoEdge> edgeSet){ + for (YoshikoEdge edge : edgeSet){ + remove(edge); + } + } + + public YoshikoEdge popMax(){ + double maxVal = Double.NEGATIVE_INFINITY; + for (Double i : list){ + if (i > maxVal){ + maxVal = i; + } + } + + int index = list.indexOf(maxVal); + + YoshikoEdge e = map.get(index); + + map.replace(index, map.get(map.size()-1)); + map.remove(map.size()-1); + + list.set(index, list.get(list.size()-1)); + list.remove(list.size()-1); + + return e; + } + + + + public void checkUptatedNode(YoshikoEdge edge){ + int index = getIndexFromValue(edge); + + checkParent(index); + checkChild(index); + } + + public int size(){ + return list.size()-1; + } + + private void checkParent(int index){ + int parentIndex = index / 2; + if (list.get(index) < list.get(parentIndex)){ + swap(index, parentIndex); + + checkParent(parentIndex); + } + } + + private void checkChild(int index){ + int childIndex = index * 2; + if (list.size()-1 < childIndex){ + return; + }else if(list.size()-1 == childIndex){ + + }else if (list.get(childIndex) < list.get(childIndex+1)){ + childIndex++; + } + + if (list.get(index) > list.get(childIndex)){ + swap(index, childIndex); + + checkChild(childIndex); + } + } + + private void swap(int index, int parentIndex){ + double tmpVal = list.get(index); + list.set(index, list.get(parentIndex)); + list.set(parentIndex, tmpVal); + + YoshikoEdge tmpEdge = map.get(index); + map.replace(index, map.get(parentIndex)); + map.replace(parentIndex, tmpEdge); + } + + private int getIndexFromValue(YoshikoEdge edge){ + for (Map.Entry<Integer, YoshikoEdge> entry : map.entrySet()) { + if (entry.getKey() == 0){ + //Der erste DummyEintrag im Heap soll ignoriert werden + } + else if (entry.getValue().equals(edge)) { + return entry.getKey(); + } + } + return -1; + } +} \ No newline at end of file diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/ClusteringAlgorithm.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/ClusteringAlgorithm.java new file mode 100644 index 0000000000000000000000000000000000000000..f4cbd5a2e354103d9b52e76ffb2f0a88f4aac6cc --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/ClusteringAlgorithm.java @@ -0,0 +1,335 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +import java.util.Set; + + +public class ClusteringAlgorithm { + + private YoshikoGraph g; + private BinaryHeap bHeap; + private double clusteringCost; + + public void runAlgorithm(YoshikoGraph g){ + this.g = g; + clusteringCost = 0; + + bHeap = new BinaryHeap(); + + initializeQueue(); + + //workHeap(); + System.out.println(clusteringCost); + } + + private void initializeQueue(){ + bHeap = new BinaryHeap(); + + Set<YoshikoEdge> edgeSet = g.edgeSet; + Set<Long> nodeSet = g.nodeSet; + + calculateIcf(nodeSet, edgeSet); + System.out.println(); + /*calculateIcp(nodeSet, edgeSet); + calculateMaxIcpIcf(edgeSet); + + addAllNotForbidden(edgeSet);*/ + } +/* + private void addAllNotForbidden(Set<MyDefaultWeightedEdge> edgeSet){ + for (MyDefaultWeightedEdge e : edgeSet){ + if(g.getEdgeWeight(e) != Double.NEGATIVE_INFINITY){ + bHeap.add(e); + } + } + } +*/ + private void calculateIcf(Set<Long> nodeSet, Set<YoshikoEdge> edgeSet){ + int i=0; + for (YoshikoEdge edge : edgeSet){ + System.out.println(i); + i++; + double icf = 0; + + if (edge.weight>0){ + icf = edge.weight; + } + + for (long v : nodeSet){ + long v1 = edge.source; + long v2 = edge.target; + if ((v == v1)||v == v2){ + continue; + } + if (g.getEdge(v, v1).weight > 0 && g.getEdge(v, v2).weight > 0) { + icf = icf + Math.min(g.getEdge(v, v1).weight, g.getEdge(v, v2).weight); + } + } + edge.icf = icf; + } + } +/* + private void calculateIcp(Set<Long> vertexSet, Set<YoshikoEdge> edgeSet){ + for (YoshikoEdge edge : edgeSet){ + double icp = 0; + + if (g.getEdgeWeight(edge) < 0){ + icp = -(g.getEdgeWeight(edge)); + } + + for (Long v : vertexSet){ + MyVertex v1 = g.getEdgeSource(edge); + MyVertex v2 = g.getEdgeTarget(edge); + if (v.equals(v1)||v.equals(v2)){ + continue; + } + + if (g.getEdgeWeight(g.getEdge(v, v1)) > 0 && g.getEdgeWeight(g.getEdge(v, v2)) < 0) { + icp = icp + Math.min(g.getEdgeWeight(g.getEdge(v, v1)), -g.getEdgeWeight(g.getEdge(v, v2))); + }else if (g.getEdgeWeight(g.getEdge(v, v1)) < 0 && g.getEdgeWeight(g.getEdge(v, v2)) > 0) { + icp = icp + Math.min(-g.getEdgeWeight(g.getEdge(v, v1)), g.getEdgeWeight(g.getEdge(v, v2))); + } + edge.icp = icp; + } + } + } + + private void calculateMaxIcpIcf(Set<YoshikoEdge> edgeSet){ + for (YoshikoEdge edge : edgeSet){ + edge.calculateMaxIcfIcp(); + } + } + + private void workHeap(){ + while (bHeap.size() > 0){ + System.out.println(bHeap.size()); + MyDefaultWeightedEdge e = bHeap.popMax(); + + if (e.icf >= e.icp){ + if(g.getEdgeWeight(e) < 0){ + clusteringCost -= g.getEdgeWeight(e); + } + makeEdgePermanent(e); + } + else{ + if(g.getEdgeWeight(e) > 0){ + clusteringCost += g.getEdgeWeight(e); + } + makeEdgeForbidden(e); + } + } + } + + private void makeEdgePermanent(MyDefaultWeightedEdge e){ + substactInfluenceOfVerticesOnIcfIcp(e); + + MyVertex mergedVertex = mergeVertexes(e); + calculateNewEdgesIcfIcp(mergedVertex); + + addInfluenceOfVertexOnIcfIcp(mergedVertex); + + System.out.println("perm"); + } + + private MyVertex mergeVertexes(MyDefaultWeightedEdge e){ + MyVertex p1 = g.getEdgeSource(e); + MyVertex p2 = g.getEdgeTarget(e); + + MyVertex mergedVertex = new MyVertex(p1, p2); + g.addVertex(mergedVertex); + + Set<MyVertex> vSet = g.vertexSet(); + + for (MyVertex v : vSet) { + if ((v.equals(p1))||(v.equals(p2))||(v.equals(mergedVertex))){ + continue; + } + + MyDefaultWeightedEdge p1Edge = g.getEdge(p1, v); + double p1EdgeWeight = g.getEdgeWeight(p1Edge); + + MyDefaultWeightedEdge p2Edge = g.getEdge(p2, v); + double p2EdgeWeight = g.getEdgeWeight(p2Edge); + + MyDefaultWeightedEdge newEdge = g.addEdge(mergedVertex, v); + g.setEdgeWeight(newEdge, p1EdgeWeight+p2EdgeWeight); + } + + bHeap.remove(g.outgoingEdgesOf(p1)); + g.removeVertex(p1); + + bHeap.remove(g.outgoingEdgesOf(p2)); + g.removeVertex(p2); + + return mergedVertex; + } + + private void calculateNewEdgesIcfIcp(MyVertex mergedVertex){ + Set<Long> vertexSet = g.vertexSet(); + Set<YoshikoEdge> newEdgesSet = g.outgoingEdgesOf(mergedVertex); + + calculateIcf(vertexSet, newEdgesSet); + calculateIcp(vertexSet, newEdgesSet); + calculateMaxIcpIcf(newEdgesSet); + + for(YoshikoEdge edge : newEdgesSet){ + if (g.getEdgeWeight(edge) == Double.NEGATIVE_INFINITY){ + continue; + } + bHeap.add(edge); + } + + } + + private void substactInfluenceOfVerticesOnIcfIcp(MyDefaultWeightedEdge e){ + MyVertex p1 = g.getEdgeSource(e); + MyVertex p2 = g.getEdgeTarget(e); + + Set<MyDefaultWeightedEdge> edgeSet = g.edgeSet(); + for (MyDefaultWeightedEdge edge : edgeSet){ + MyVertex v1 = g.getEdgeSource(edge); + MyVertex v2 = g.getEdgeTarget(edge); + + if (v1.equals(p1)||v1.equals(p2)||v2.equals(p1)||v2.equals(p2)){ + continue; + } + + //Subtraiere Einfluss des Dreiecks v1p1v2 auf icf + MyDefaultWeightedEdge ux = g.getEdge(v1, p1); + MyDefaultWeightedEdge vx = g.getEdge(v2, p1); + + if (g.getEdgeWeight(ux) > 0 && g.getEdgeWeight(vx) > 0){ + edge.icf -= Math.min(g.getEdgeWeight(ux), g.getEdgeWeight(vx)); + } + + //Subtraiere Einfluss des Dreiecks v1p2v2 auf icf + ux = g.getEdge(v1, p2); + vx = g.getEdge(v2, p2); + + if (g.getEdgeWeight(ux) > 0 && g.getEdgeWeight(vx) > 0){ + edge.icf -= Math.min(g.getEdgeWeight(ux), g.getEdgeWeight(vx)); + } + + //Subtraiere Einfluss des Dreiecks v1p1v2 auf icp + ux = g.getEdge(v1, p1); + vx = g.getEdge(v2, p1); + + if (g.getEdgeWeight(ux) > 0 && g.getEdgeWeight(vx) < 0){ + edge.icp -= Math.min(g.getEdgeWeight(ux), -g.getEdgeWeight(vx)); + }else if (g.getEdgeWeight(ux) < 0 && g.getEdgeWeight(vx) > 0){ + edge.icp -= Math.min(-g.getEdgeWeight(ux), g.getEdgeWeight(vx)); + } + + //Subtraiere Einfluss des Dreiecks v1p2v2 auf icp + ux = g.getEdge(v1, p2); + vx = g.getEdge(v2, p2); + + if (g.getEdgeWeight(ux) > 0 && g.getEdgeWeight(vx) < 0){ + edge.icp -= Math.min(g.getEdgeWeight(ux), -g.getEdgeWeight(vx)); + }else if (g.getEdgeWeight(ux) < 0 && g.getEdgeWeight(vx) > 0){ + edge.icp -= Math.min(-g.getEdgeWeight(ux), g.getEdgeWeight(vx)); + } + + edge.maxIcfIcp = Math.max(edge.icf, edge.icf); + } + } + + private void addInfluenceOfVertexOnIcfIcp(MyVertex mergedVertex) { + Set<MyDefaultWeightedEdge> edgeSet = g.edgeSet(); + + for (MyDefaultWeightedEdge edge : edgeSet){ + MyVertex v1 = g.getEdgeSource(edge); + MyVertex v2 = g.getEdgeTarget(edge); + + if (v1.equals(mergedVertex)||v1.equals(mergedVertex)){ + continue; + } + + //Addiere Einfluss des Dreiecks v1-MergedVertex-v2 auf icf + MyDefaultWeightedEdge ux = g.getEdge(v1, mergedVertex); + MyDefaultWeightedEdge vx = g.getEdge(v2, mergedVertex); + + if (g.getEdgeWeight(ux) > 0 && g.getEdgeWeight(vx) > 0){ + edge.icf += Math.min(g.getEdgeWeight(ux), g.getEdgeWeight(vx)); + } + + + //Addiere Einfluss des Dreiecks v1-MergedVertex-v2 auf icp + ux = g.getEdge(v1, mergedVertex); + vx = g.getEdge(v2, mergedVertex); + + if (g.getEdgeWeight(ux) > 0 && g.getEdgeWeight(vx) < 0){ + edge.icp += Math.min(g.getEdgeWeight(ux), -g.getEdgeWeight(vx)); + }else if (g.getEdgeWeight(ux) < 0 && g.getEdgeWeight(vx) > 0){ + edge.icp += Math.min(-g.getEdgeWeight(ux), g.getEdgeWeight(vx)); + } + + } + } + + private void makeEdgeForbidden(MyDefaultWeightedEdge e){ + editInfluenzeOfForbiddenEdge(e); + + g.setEdgeWeight(e, Double.NEGATIVE_INFINITY); + bHeap.remove(e); + System.out.println("rm"); + } + + private void editInfluenzeOfForbiddenEdge(MyDefaultWeightedEdge forbiddenEdge){ + MyVertex x1 = g.getEdgeSource(forbiddenEdge); + MyVertex x2 = g.getEdgeTarget(forbiddenEdge); + + Set<MyDefaultWeightedEdge> v1EdgeSet = g.outgoingEdgesOf(x1); + for (MyDefaultWeightedEdge edge : v1EdgeSet){ + MyVertex v1 = x1; + MyVertex v2 = g.getEdgeTarget(edge); + if (v2.equals(v1)){ + v2 = g.getEdgeSource(edge); + } + if (v1.equals(x2)||v2.equals(x2)){ + continue; + } + + MyDefaultWeightedEdge edge2 = g.getEdge(v2, x2); + + if (g.getEdgeWeight(forbiddenEdge)>0 && g.getEdgeWeight(edge2) > 0){ + edge.icf -= Math.min(g.getEdgeWeight(forbiddenEdge), g.getEdgeWeight(edge2)); + edge.icp += g.getEdgeWeight(edge2); + } + + if (g.getEdgeWeight(forbiddenEdge) > 0 && g.getEdgeWeight(edge2) < 0){ + edge.icp -= Math.min(g.getEdgeWeight(forbiddenEdge), -g.getEdgeWeight(edge2)); + } else if (g.getEdgeWeight(forbiddenEdge) < 0 && g.getEdgeWeight(edge2) > 0){ + if (g.getEdgeWeight(forbiddenEdge)*(-1) < g.getEdgeWeight(edge2)){ + edge.icp += g.getEdgeWeight(edge2)+g.getEdgeWeight(forbiddenEdge); + } + } + } + + Set<MyDefaultWeightedEdge> v2EdgeSet = g.outgoingEdgesOf(x2); + for (MyDefaultWeightedEdge edge : v2EdgeSet){ + MyVertex v1 = x2; + MyVertex v2 = g.getEdgeTarget(edge); + if (v2.equals(v1)){ + v2 = g.getEdgeSource(edge); + } + if (v1.equals(x1)||v2.equals(x1)){ + continue; + } + + MyDefaultWeightedEdge edge2 = g.getEdge(v2, x1); + + if (g.getEdgeWeight(forbiddenEdge)>0 && g.getEdgeWeight(edge2) > 0){ + edge.icf -= Math.min(g.getEdgeWeight(forbiddenEdge), g.getEdgeWeight(edge2)); + edge.icp += g.getEdgeWeight(edge2); + } + + if (g.getEdgeWeight(forbiddenEdge) > 0 && g.getEdgeWeight(edge2) < 0){ + edge.icp -= Math.min(g.getEdgeWeight(forbiddenEdge), -g.getEdgeWeight(edge2)); + } else if (g.getEdgeWeight(forbiddenEdge) < 0 && g.getEdgeWeight(edge2) > 0){ + if (g.getEdgeWeight(forbiddenEdge)*(-1) < g.getEdgeWeight(edge2)){ + edge.icp += g.getEdgeWeight(edge2)+g.getEdgeWeight(forbiddenEdge); + } + } + } + }*/ +} \ No newline at end of file diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/GraphTranslator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/GraphTranslator.java new file mode 100644 index 0000000000000000000000000000000000000000..ad87b23f871b3ea9d1f92b060b9e818046cb86f9 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/GraphTranslator.java @@ -0,0 +1,101 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer; +import de.hhu.ba.yoshikoWrapper.CyActivator; +import de.hhu.ba.yoshikoWrapper.core.ParameterSet; +import org.cytoscape.model.*; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class GraphTranslator { + private CyNetwork network; + private ParameterSet parameterSet; + + private double deletionCostDefault; + private double insertionCostDefault; + + CyColumn weightColumn; + + public GraphTranslator(ParameterSet parameterSet){ + this.parameterSet = parameterSet; + this.network = parameterSet.net; + this.weightColumn = parameterSet.getWeightColumn(); + this.deletionCostDefault = parameterSet.defaultDeletionCost; + this.insertionCostDefault = parameterSet.defaultInsertionCost; + } + + public YoshikoGraph translateGraph(){ + YoshikoGraph g = this.makeGraph(); + this.makeGraphComplete(g); + return g; + } + + private YoshikoGraph makeGraph(){ + YoshikoGraph g = new YoshikoGraph(); + + List<CyNode> nodeList = network.getNodeList(); + List<CyEdge> edgeList = network.getEdgeList(); + + for (CyNode n : nodeList){ + g.addNode(n.getSUID()); + } + + for (CyEdge e : edgeList){ + YoshikoEdge yoshikoEdge = new YoshikoEdge(e.getSource().getSUID(), e.getTarget().getSUID(), this.extractValue(e), e.getSUID().intValue()); + g.addEdge(yoshikoEdge); + } + + return g; + } + + private YoshikoGraph makeGraphComplete(YoshikoGraph g){ + Set<Long> nodeSet = g.getNodeSet(); + Set<Long> usedINodes = new HashSet<>(); + + Set<YoshikoEdge> edgesToAdd = new HashSet<>(); + int edgeID = 1; + for (long i : nodeSet){ + usedINodes.add(i); + for (long j : nodeSet){ + if (!usedINodes.contains(j)){ + YoshikoEdge e = new YoshikoEdge(i, j, insertionCostDefault, -edgeID); + if (!g.containsEdge(e)){ + edgesToAdd.add(e); + System.out.println(edgeID); + edgeID++; + } + } + } + } + + + g.addEdge(edgesToAdd); + return g; + } + + private double extractValue(CyEdge edge){ + //Parse editing costs + double weight = deletionCostDefault; + + //Fetch entry and check if it exists + CyRow edgeEntry = network.getRow(edge); + + //Check if the column contains an entry for the respective edge + //It is possible, that there are missing entries + if (weightColumn != null){ + if (edgeEntry.get(weightColumn.getName(), weightColumn.getType()) != null){ + if (weightColumn.getType() == Integer.class) { + weight = 1.0*edgeEntry.get(weightColumn.getName(), Integer.class); + } + else if (weightColumn.getType() == Double.class) { + weight = edgeEntry.get(weightColumn.getName(), Double.class); + } + } + + } + return weight; + } + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/MyDefaultWeightedEdge.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/MyDefaultWeightedEdge.java new file mode 100644 index 0000000000000000000000000000000000000000..aea98ea831af0b8ae01b556e6a71f6592324b0d4 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/MyDefaultWeightedEdge.java @@ -0,0 +1,8 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +import org.jgrapht.Graph; +import org.jgrapht.graph.DefaultWeightedEdge; + + +public class MyDefaultWeightedEdge extends DefaultWeightedEdge{ +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoAlgoritmController.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoAlgoritmController.java new file mode 100644 index 0000000000000000000000000000000000000000..35d6bcc848c741874dc93a2905d5dfead6816690 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoAlgoritmController.java @@ -0,0 +1,37 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +import de.hhu.ba.yoshikoWrapper.core.CyCore; +import de.hhu.ba.yoshikoWrapper.core.ParameterSet; +import org.cytoscape.model.CyEdge; +import org.cytoscape.model.CyNetwork; +import org.cytoscape.model.CyNode; +import org.cytoscape.model.CyTable; +import org.jgrapht.Graph; +import org.jgrapht.graph.SimpleWeightedGraph; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +public class YoshikoAlgoritmController { + + private CyNetwork network; + private ParameterSet parameterSet; + + public YoshikoAlgoritmController(ParameterSet parameterSet){ + this.parameterSet = parameterSet; + this.network = parameterSet.net; + } + + public void controllAlgorithm(){ + GraphTranslator translator = new GraphTranslator(parameterSet); + YoshikoGraph graph = translator.translateGraph(); + + ClusteringAlgorithm clusteringAlgorithm = new ClusteringAlgorithm(); + clusteringAlgorithm.runAlgorithm(graph); + + System.out.println(); + } + + +} \ No newline at end of file diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoEdge.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoEdge.java new file mode 100644 index 0000000000000000000000000000000000000000..9fef387cd73633ca1003ac12f8023dab2d968396 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoEdge.java @@ -0,0 +1,36 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +public class YoshikoEdge implements Comparable{ + int id; + long source; + long target; + double weight; + + double icf; + double icp; + double maxIcfIcp; + + public YoshikoEdge(long source, long target, Double weight, int id){ + this.source = source; + this.target = target; + this.weight = weight; + this.id = id; + } + + public void calculateMaxIcfIcp(){ + if (icp >icf ){ + maxIcfIcp = icp; + } else { + maxIcfIcp = icf; + } + } + + @Override + public int compareTo(Object o) { + if (o==this){ + return 0; + } + YoshikoEdge e = (YoshikoEdge) o; + return this.id - e.id; + } +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoGraph.java b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoGraph.java new file mode 100644 index 0000000000000000000000000000000000000000..cc70d3ae0561b5556d2a033922ecbb701ec77443 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/yoshikoAlgorithm/YoshikoGraph.java @@ -0,0 +1,82 @@ +package de.hhu.ba.yoshikoWrapper.yoshikoAlgorithm; + +import org.cytoscape.model.CyNode; + +import java.util.HashSet; +import java.util.Set; +import java.util.TreeSet; + +public class YoshikoGraph { + Set<Long> nodeSet; + Set<YoshikoEdge> edgeSet; + + public YoshikoGraph(){ + this.nodeSet = new HashSet<>(); + this.edgeSet = new TreeSet<>(); + } + + public void addNode(long node){ + nodeSet.add(node); + } + + public void addEdge(YoshikoEdge edge){ + edgeSet.add(edge); + } + + public void addEdge(Set<YoshikoEdge> edges){ + for (YoshikoEdge e : edges){ + edgeSet.add(e); + } + } + + public void addEdge(long n1, long n2, double value, int id){ + nodeSet.add(n1); + nodeSet.add(n2); + + YoshikoEdge edge = new YoshikoEdge(n1, n2, value, id); + edgeSet.add(edge); + } + + public boolean containsNode(CyNode node){ + return nodeSet.contains(node); + } + + public boolean containsEdge(YoshikoEdge edge){ + + return edgeSet.contains(edge); + } + + public boolean containsEdge(long n1, long n2){ + for(YoshikoEdge e : edgeSet){ + if (n1 == (e.source)){ + if (n2 == (e.target)){ + return true; + } + }else if (n2 == (e.source)){ + if (n1 == (e.target)){ + return true; + } + } + } + return false; + } + + public Set<Long> getNodeSet(){ + return nodeSet; + } + + public YoshikoEdge getEdge(long n1, long n2){ + for(YoshikoEdge e : edgeSet){ + if (n1 == (e.source)){ + if (n2 == (e.target)){ + return e; + } + }else if (n2 == (e.source)){ + if (n1 == (e.target)){ + return e; + } + } + } + return null; + } +}