Adds first experimental GIPS sequence MdVNE algorithm

This commit is contained in:
Maximilian Kratz 2023-11-17 10:54:38 +01:00
parent 20cd83ac39
commit a7440eb11c
5 changed files with 162 additions and 1 deletions

1
.gitignore vendored
View file

@ -136,5 +136,6 @@ examples/model.xmi
# Current workaround (need to copy src-gen from gips-examples into this repository)
org.emoflon.gips.gipsl.examples.mdvne/
org.emoflon.gips.gipsl.examples.mdvne.migration/
org.emoflon.gips.gipsl.examples.mdvne.seq/
*.lp

View file

@ -0,0 +1,67 @@
package examples.algorithms;
import java.util.Set;
import algorithms.AbstractAlgorithm;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import algorithms.gips.VneGipsSeqAlgorithm;
import facade.ModelFacade;
import model.SubstrateNetwork;
import model.VirtualNetwork;
/**
* Runnable example for the VNE GIPS algorithm implementation.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public class VneGipsSeqAlgorithmExampleTwoNodesOneLink {
/**
* Main method to start the example. String array of arguments will be ignored.
*
* @param args Will be ignored.
*/
public static void main(final String[] args) {
// Setup
// ModelFacadeConfig.MIN_PATH_LENGTH = 1;
// ModelFacadeConfig.MAX_PATH_LENGTH = 2;
AlgorithmConfig.obj = Objective.TOTAL_COMMUNICATION_OBJECTIVE_C;
// GlobalMetricsManager.startRuntime();
// Substrate network = two tier network
ModelFacade.getInstance().addNetworkToRoot("sub", false);
ModelFacade.getInstance().addServerToNetwork("s1", "sub", 10, 10, 10, 0);
// Virtual network = one tier network
ModelFacade.getInstance().addNetworkToRoot("virt", true);
ModelFacade.getInstance().addServerToNetwork("vsrv1", "virt", 1, 1, 1, 0);
ModelFacade.getInstance().addSwitchToNetwork("vsw1", "virt", 0);
ModelFacade.getInstance().addLinkToNetwork("vl1", "virt", 1, "vsrv1", "vsw1");
// ModelFacade.getInstance().addLinkToNetwork("vl1", "virt", 1, "vsw1", "vsrv1");
ModelFacade.getInstance().validateModel();
final SubstrateNetwork sNet = (SubstrateNetwork) ModelFacade.getInstance().getNetworkById("sub");
final VirtualNetwork vNet = (VirtualNetwork) ModelFacade.getInstance().getNetworkById("virt");
// Create and execute algorithm
final AbstractAlgorithm algo = VneGipsSeqAlgorithm.prepare(sNet, Set.of(vNet));
algo.execute();
// GlobalMetricsManager.stopRuntime();
ModelFacade.getInstance().validateModel();
// Save model to file
ModelFacade.getInstance().persistModel();
System.out.println("=> Execution finished.");
// Time measurements
// System.out.println("=> Elapsed time (total): " + GlobalMetricsManager.getRuntime().getValue() / 1_000_000_000
// + " seconds");
System.exit(0);
}
}

View file

@ -12,3 +12,6 @@ rsync -a --progress --stats ../../gips-examples/$MDVNE_PROJECT_NAME/src-gen ../$
rm -rf ../$MDVNE_PROJECT_NAME.migration/src-gen
rsync -a --progress --stats ../../gips-examples/$MDVNE_PROJECT_NAME.migration/src-gen ../$MDVNE_PROJECT_NAME.migration
rm -rf ../$MDVNE_PROJECT_NAME.seq/src-gen
rsync -a --progress --stats ../../gips-examples/$MDVNE_PROJECT_NAME.seq/src-gen ../$MDVNE_PROJECT_NAME.seq

View file

@ -21,4 +21,5 @@ Export-Package: algorithms,
algorithms.simple
Bundle-Vendor: Real-Time Systems Lab - TU Darmstadt
Import-Package: org.emoflon.gips.gipsl.examples.mdvne,
org.emoflon.gips.gipsl.examples.mdvne.migration
org.emoflon.gips.gipsl.examples.mdvne.migration,
org.emoflon.gips.gipsl.examples.mdvne.seq

View file

@ -0,0 +1,89 @@
package algorithms.gips;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.emoflon.gips.gipsl.examples.mdvne.seq.MdvneGipsIflyeAdapter;
import algorithms.AbstractAlgorithm;
import algorithms.AlgorithmConfig;
import algorithms.AlgorithmConfig.Objective;
import facade.ModelFacade;
import model.SubstrateNetwork;
import model.VirtualNetwork;
/**
* GIPS-based VNE algorithm implementation with sequences.
*
* @author Maximilian Kratz {@literal <maximilian.kratz@es.tu-darmstadt.de>}
*/
public class VneGipsSeqAlgorithm extends AbstractAlgorithm {
/**
* Algorithm instance (singleton).
*/
private static VneGipsSeqAlgorithm instance;
/**
* Constructor that gets the substrate as well as the virtual network.
*
* @param sNet Substrate network to work with.
* @param vNets Set of virtual networks to work with.
*/
public VneGipsSeqAlgorithm(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
super(sNet, vNets);
}
@Override
public boolean execute() {
// Check if correct objective is used
if (AlgorithmConfig.obj != Objective.TOTAL_COMMUNICATION_OBJECTIVE_C) {
throw new UnsupportedOperationException(
"The VNE GIPS algorithm can only be used with the total communication cost C.");
}
// TODO: Time measurement
final ResourceSet model = ModelFacade.getInstance().getResourceSet();
final boolean gipsSuccess = MdvneGipsIflyeAdapter.execute(model);
return gipsSuccess;
}
/**
* Initializes a new instance of the GIPS-based VNE algorithm.
*
* @param sNet Substrate network to work with.
* @param vNets Set of virtual networks to work with.
* @return Instance of this algorithm implementation.
*/
public static VneGipsSeqAlgorithm prepare(final SubstrateNetwork sNet, final Set<VirtualNetwork> vNets) {
if (sNet == null || vNets == null) {
throw new IllegalArgumentException("One of the provided network objects was null.");
}
if (vNets.size() == 0) {
throw new IllegalArgumentException("Provided set of virtual networks was empty.");
}
if (instance == null) {
instance = new VneGipsSeqAlgorithm(sNet, vNets);
}
instance.sNet = sNet;
instance.vNets = new HashSet<>();
instance.vNets.addAll(vNets);
return instance;
}
/**
* Resets the algorithm instance.
*/
public void dispose() {
MdvneGipsIflyeAdapter.resetInit();
if (instance == null) {
return;
}
instance = null;
}
}