@@ -0,0 +1,2869 @@
+package at.ac.tuwien.dsg.salam.composer.algorithm;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.apache.commons.math3.distribution.UniformRealDistribution;%0Aimport org.apache.commons.math3.random.MersenneTwister;%0A%0Aimport at.ac.tuwien.dsg.salam.common.model.ComputingElement;%0Aimport at.ac.tuwien.dsg.salam.composer.Composer;%0Aimport at.ac.tuwien.dsg.salam.composer.model.ConstructionGraph;%0Aimport at.ac.tuwien.dsg.salam.composer.model.Solution;%0Aimport at.ac.tuwien.dsg.salam.composer.model.SolutionComponent;%0A%0Apublic class PriorityDistribution implements ComposerAlgorithmInterface %7B%0A%0A    private static final int SEED_SELECTOR = 1001;%0A    private static UniformRealDistribution distSelector = new UniformRealDistribution(new MersenneTwister(SEED_SELECTOR), 0, 1);%0A    private ConstructionGraph cons;%0A    private Composer composer;%0A%0A    @Override%0A    public void init(String configFile, ConstructionGraph cons, Composer composer) %7B%0A        this.cons = cons;%0A        this.composer = composer;%0A    %7D%0A%0A    @Override%0A    public Solution solve() %7B%0A        Solution solution = new Solution();%0A        List%3CComputingElement%3E selectedElements = new ArrayList%3CComputingElement%3E();%0A        for (int i=1; i%3Ccons.getComponentList().size()-1; i++) %7B%0A            ArrayList%3CSolutionComponent%3E components = cons.getComponentList().get(i);%0A            // sum up priorities%0A            int prioritySum = 0;%0A            for (SolutionComponent comp: components) %7B%0A                int priority = (int)comp.getAssignee().getProvider().getProperties().getValue(%22assignment_priority%22, 1);%0A                prioritySum += priority;%0A            %7D%0A            // repeat until we have an element that has not been selected%0A        %09int retry = 0;%0A        %09SolutionComponent chosenComp = null;%0A            do %7B%0A            %09double chosen = distSelector.sample() * prioritySum;%0A            %09int pos = 0;%0A            %09for (SolutionComponent comp: components) %7B%0A            %09%09int priority = (int)comp.getAssignee().getProvider().getProperties().getValue(%22assignment_priority%22, 1);%0A            %09%09pos += priority;%0A            %09%09if (chosen %3C= pos) %7B%0A            %09%09%09chosenComp = comp;%0A            %09%09%09break;%0A            %09%09%7D%0A            %09%7D%0A            %09if (chosenComp==null) %7B%0A            %09%09System.out.println(chosen);%0A            %09%09System.out.println(prioritySum);%0A            %09%7D%0A            %7D while (retry++%3C20 && (chosenComp==null %7C%7C selectedElements.contains(chosenComp.getAssignee().getProvider())));%0A            %0A            selectedElements.add(chosenComp.getAssignee().getProvider());%0A            solution.addSolutionComponent(chosenComp);%0A        %7D%0A%0A        // measure objective values%0A        ArrayList%3CSolution%3E solutionList = new ArrayList%3CSolution%3E();%0A        solutionList.add(solution);%0A        composer.calculateObjectiveValues(solutionList);%0A%0A        return solution;%0A    %7D%0A%0A%7D%0A

Add new composition algorithm: fair distribution with priority.