Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public void printStatistics(LinkedList<IProject> projects, String folder) {

public void createInterface(IProject mplProject, IFeatureProject featureProject, Collection<String> featureNames) {
final ArrayList<LongRunningMethod<?>> arguments = new ArrayList<>(1);
arguments.add(new SliceFeatureModel(featureProject.getFeatureModel(), featureNames, true));
arguments.add(new SliceFeatureModel(featureProject.getFeatureModelManager().getPersistentFormula(), featureNames, true));
FMCorePlugin.startJobs(arguments, StringTable.CREATE_INTERFACE, true);
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/de.ovgu.featureide.fm.core/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<classpathentry exported="true" kind="lib" path="lib/commons-math-2.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/splar.jar"/>
<classpathentry exported="true" kind="lib" path="lib/antlr-3.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.sat4j.core.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.ow2.sat4j.core-2.3.6.jar"/>
<classpathentry exported="true" kind="lib" path="lib/SPLCAT.jar"/>
<classpathentry exported="true" kind="lib" path="lib/org.sat4j.pb.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
Expand Down
2 changes: 1 addition & 1 deletion plugins/de.ovgu.featureide.fm.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.swt
Bundle-ClassPath: .,
lib/antlr-3.4.jar,
lib/org.sat4j.core.jar,
lib/org.ow2.sat4j.core-2.3.6.jar,
lib/org.sat4j.pb.jar,
lib/splar.jar,
lib/SPLCAT.jar,
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.List;

import org.sat4j.minisat.constraints.cnf.UnitClause;
import org.sat4j.minisat.core.Solver;
import org.sat4j.specs.IConstr;

Expand Down Expand Up @@ -74,6 +75,9 @@ public void removeClause(IConstr constr) {
}
if (constr != null) {
try {
if (constr instanceof UnitClause) {
solver.unset(constr.get(0));
}
solver.removeConstr(constr);
} catch (final Exception e) {
throw new RuntimeContradictionException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/
package de.ovgu.featureide.fm.core.analysis.cnf.solver;

import org.sat4j.minisat.core.Heap;
import org.sat4j.minisat.core.IPhaseSelectionStrategy;
import org.sat4j.minisat.orders.VarOrderHeap;
import org.sat4j.specs.ISolver;
Expand Down Expand Up @@ -48,7 +47,7 @@ public void init() {
}
phaseStrategy.init(nlength);
activity[0] = -1;
heap = new Heap(activity);
heap = createHeap(activity);
heap.setBounds(nlength);
nlength--;
for (int i = 0; i < nlength; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.prop4j.Node;

Expand All @@ -47,7 +48,7 @@ public abstract class AConstraint extends AFeatureModelElement implements IConst

protected final IPropertyContainer propertyContainer;

protected final List<IFeature> containedFeatureList = new ArrayList<>();
protected final List<String> containedFeatureList = new ArrayList<>();

protected Node propNode;
boolean featureSelected;
Expand All @@ -68,7 +69,7 @@ public abstract class AConstraint extends AFeatureModelElement implements IConst
public AConstraint(IConstraint oldConstraint, IFeatureModel featureModel, boolean copyId) {
super(oldConstraint, featureModel, copyId);
setNode(oldConstraint.getNode().clone());
description = oldConstraint.getDescription();
description = new String(oldConstraint.getDescription());
tags = new HashSet<>(oldConstraint.getTags());
propertyContainer = new MapPropertyContainer(oldConstraint.getCustomProperties());
if (oldConstraint instanceof AConstraint) {
Expand Down Expand Up @@ -106,7 +107,7 @@ public IPropertyContainer getCustomProperties() {
@Override
public Collection<IFeature> getContainedFeatures() {
synchronized (containedFeatureList) {
return new ArrayList<>(containedFeatureList);
return new ArrayList<>(containedFeatureList.stream().map(featureModel::getFeature).collect(Collectors.toList()));
}
}

Expand Down Expand Up @@ -136,8 +137,9 @@ public void setNode(Node node) {
synchronized (containedFeatureList) {
containedFeatureList.clear();
if (propNode != null) {
for (final String featureName : propNode.getContainedFeatures()) {
containedFeatureList.add(featureModel.getFeature(featureName));
final List<String> containedFeatureNames = propNode.getContainedFeatures();
for (final String containedFeatureName : containedFeatureNames) {
containedFeatureList.add(new String(containedFeatureName));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ private void parseArguments(List<String> args) {
break;
}
default: {
throw new IllegalArgumentException(arg);
throw new IllegalArgumentException("Unknown argument: " + arg);
}
}
} else {
throw new IllegalArgumentException(arg);
throw new IllegalArgumentException("Unknown value: " + arg);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public static void main(String[] args) {
System.err.println("No operation specified!");
return;
}
System.err.println(Arrays.asList(args));

final String functionName = args[0];

LibraryManager.registerLibrary(FMCoreLibrary.getInstance());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public int hashCode() {

protected AbstractJob(String name, int priority) {
super(name);
setPriority(priority);
setJobPriority(priority);
}

@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public int getValue() {

void schedule();

void setPriority(int priority);
void setJobPriority(int priority);

void setIntermediateFunction(Consumer<T> intermediateFunction);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ public void setTimeout(int timeout) {
this.timeout = timeout;
}

@Override
public void setJobPriority(int priority) {
setPriority(priority);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.List;
import java.util.function.Consumer;

import org.eclipse.core.runtime.jobs.Job;

import de.ovgu.featureide.fm.core.Logger;
import de.ovgu.featureide.fm.core.job.monitor.IMonitor;
import de.ovgu.featureide.fm.core.job.monitor.NullMonitor;
Expand Down Expand Up @@ -165,4 +167,23 @@ public void setStoppable(boolean stoppable) {
this.stoppable = stoppable;
}

@Override
public void setJobPriority(int priority) {
switch (priority) {
case Job.INTERACTIVE:
setPriority(Thread.MAX_PRIORITY);
break;
case Job.SHORT:
setPriority(Thread.NORM_PRIORITY);
break;
case Job.LONG:
case Job.BUILD:
case Job.DECORATE:
setPriority(Thread.MIN_PRIORITY);
break;
default:
throw new IllegalArgumentException(String.valueOf(priority));
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@
import de.ovgu.featureide.fm.core.analysis.cnf.solver.SimpleSatSolver;
import de.ovgu.featureide.fm.core.base.FeatureUtils;
import de.ovgu.featureide.fm.core.base.IConstraint;
import de.ovgu.featureide.fm.core.base.IFeature;
import de.ovgu.featureide.fm.core.base.IFeatureModel;
import de.ovgu.featureide.fm.core.base.IFeatureModelFactory;
import de.ovgu.featureide.fm.core.base.IFeatureStructure;
import de.ovgu.featureide.fm.core.base.impl.FMFactoryManager;
import de.ovgu.featureide.fm.core.base.impl.FeatureModel;
import de.ovgu.featureide.fm.core.io.manager.FeatureModelManager;
import de.ovgu.featureide.fm.core.job.monitor.IMonitor;
import de.ovgu.featureide.fm.core.localization.StringTable;

/**
* Create mpl interfaces.
* Slices a feature model while preserving as much of its hierarchy and cross-tree constrains as possible.
*
* @author Sebastian Krieter
* @author Marcus Pinnecke (Feature Interface)
Expand All @@ -57,28 +55,28 @@ public class SliceFeatureModel implements LongRunningMethod<IFeatureModel> {

private static final int GROUP_OR = 1, GROUP_AND = 2, GROUP_ALT = 3, GROUP_NO = 0;

private final FeatureModelFormula formula;
private final Collection<String> featureNames;
private final IFeatureModel featureModel;
private final Collection<String> featuresToKeep, featuresToRemove;
private final CNF cnfFormula;
private final IFeatureModel slicedFeatureModel;
private final IFeatureModelFactory factory;
private final boolean useSlicing;

private IFeatureModel slicedFeatureModel;
private boolean slicingNecesary;

public SliceFeatureModel(IFeatureModel featureModel, Collection<String> featureNames, boolean useSlicing) {
this(featureModel, featureNames, useSlicing, true);
this(new FeatureModelFormula(featureModel), featureNames, useSlicing);
}

public SliceFeatureModel(IFeatureModel featureModel, Collection<String> featureNames, boolean useSlicing, boolean usePersistentFormula) {
if (usePersistentFormula) {
formula = FeatureModelManager.getInstance(featureModel).getPersistentFormula();
this.featureModel = formula.getFeatureModel();
} else {
formula = FeatureModelManager.getInstance(featureModel).getVariableFormula();
this.featureModel = featureModel;
}
public SliceFeatureModel(FeatureModelFormula formula, Collection<String> featureNames, boolean useSlicing) {
final IFeatureModel featureModelObject = formula.getFeatureModel();
factory = FMFactoryManager.getInstance().getFactory(featureModelObject);
slicedFeatureModel = featureModelObject.clone();
cnfFormula = formula.getCNF();
featuresToKeep = featureNames;
featuresToRemove = new HashSet<>(FeatureUtils.getFeatureNames(featureModelObject));
featuresToRemove.removeAll(featuresToKeep);

this.useSlicing = useSlicing;
this.featureNames = featureNames;
}

@Override
Expand All @@ -90,27 +88,26 @@ public IFeatureModel execute(IMonitor<IFeatureModel> monitor) throws Exception {
monitor.checkCancel();
final CNF slicedFeatureModelCNF = sliceFormula(monitor.subTask(80));
monitor.checkCancel();
merge(FMFactoryManager.getInstance().getFactory(featureModel), slicedFeatureModelCNF, featureTree, monitor.subTask(18));
merge(factory, slicedFeatureModelCNF, featureTree, monitor.subTask(18));
}

return featureTree;
}

private CNF sliceFormula(IMonitor<?> monitor) {
monitor.setTaskName("Slicing Feature Model Formula");
final HashSet<String> removeFeatures = new HashSet<>(FeatureUtils.getFeatureNames(featureModel));
removeFeatures.removeAll(featureNames);
return LongRunningWrapper.runMethod(new CNFSlicer(formula.getCNF(), removeFeatures), monitor.subTask(1));
return LongRunningWrapper.runMethod(new CNFSlicer(cnfFormula, featuresToRemove), monitor.subTask(1));
}

private IFeatureModel sliceTree(IMonitor<?> monitor) {
monitor.setTaskName("Slicing Feature Tree");
monitor.setRemainingWork(2);
slicingNecesary = false;
slicedFeatureModel = featureModel.clone();

IFeatureStructure root = slicedFeatureModel.getStructure().getRoot();
final List<IConstraint> constraints = new ArrayList<>(slicedFeatureModel.getConstraints());
slicedFeatureModel.reset();

postOrderProcessing(root);
if (isToBeRemoved(root)) {
if ((root.getChildrenCount() == 1) && root.getFirstChild().isMandatory()) {
Expand All @@ -126,17 +123,9 @@ private IFeatureModel sliceTree(IMonitor<?> monitor) {
slicedFeatureModel.getStructure().setRoot(root);
monitor.step();

for (final IConstraint constaint : featureModel.getConstraints()) {
final Collection<IFeature> containedFeatures = constaint.getContainedFeatures();
boolean containsOnlyRemainingFeatures = !containedFeatures.isEmpty();
for (final IFeature feature : containedFeatures) {
if (!featureNames.contains(feature.getName())) {
containsOnlyRemainingFeatures = false;
break;
}
}
if (containsOnlyRemainingFeatures) {
slicedFeatureModel.addConstraint(constaint);
for (final IConstraint constraint : constraints) {
if (featuresToKeep.containsAll(constraint.getNode().getContainedFeatures())) {
slicedFeatureModel.addConstraint(constraint);
} else {
slicingNecesary = true;
}
Expand Down Expand Up @@ -311,7 +300,7 @@ private void toAnd(final IFeatureStructure parent) {
}

private boolean isToBeRemoved(final IFeatureStructure feat) {
return !featureNames.contains(feat.getFeature().getName());
return !featuresToKeep.contains(feat.getFeature().getName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ protected int addVariable(Object variable) throws NullPointerException {
}
int index = getIndexFromVariable(variable);
if (index == 0) {
index = getOracle().nextFreeVarId(false);
getOracle().newVar(index);
index = getOracle().newVar();
variableIndexes.put(variable, index);
indexVariables.put(index, variable);
}
Expand Down
1 change: 1 addition & 0 deletions plugins/de.ovgu.featureide.fm.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,4 @@ Export-Package: de.ovgu.featureide.fm.ui,
Bundle-ClassPath: .,
lib/org.abego.treelayout.core-1.0.3.jar
Automatic-Module-Name: de.ovgu.featureide.fm.ui
Import-Package: org.eclipse.core.runtime
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import static de.ovgu.featureide.fm.core.localization.StringTable.SELECT_THE_FEATURE_MODEL_FOR_THE_CURRENT_PROJECT;

import java.net.URL;
import java.util.Arrays;
import java.util.Optional;

Expand All @@ -30,6 +31,12 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -83,7 +90,13 @@ public static FMUIPlugin getDefault() {
}

public static Image getImage(String name) {
return getDefault().getImageDescriptor("icons/" + name).createImage();
final URL url = FileLocator.find(Platform.getBundle(PLUGIN_ID), new Path("icons/" + name), null);
if (url != null) {
return ImageDescriptor.createFromURL(url).createImage();
} else {
getDefault().getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Image not found: " + name));
return null;
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public Boolean execute(IMonitor<Boolean> monitor) throws Exception {
return true;
}
}, ANALYZE_FEATURE_MODEL);
analyzeJob.setPriority(Job.LONG);
analyzeJob.setJobPriority(Job.LONG);
LongRunningWrapper.startJob(analysisToken, analyzeJob);

}
Expand Down
Loading