supporting case with no variables
Change-Id: I7a3baf4757d6f9be75195683e285a060a158394e
This commit is contained in:
parent
122a1d0f9c
commit
9fbf5be9fc
@ -9,6 +9,7 @@ import eu.nebulous.utilityevaluator.converter.NodeCandidateConverter;
|
|||||||
import eu.nebulous.utilityevaluator.model.Application;
|
import eu.nebulous.utilityevaluator.model.Application;
|
||||||
import eu.nebulous.utilityevaluator.model.NodeCandidateDTO;
|
import eu.nebulous.utilityevaluator.model.NodeCandidateDTO;
|
||||||
import eu.nebulous.utilityevaluator.model.VariableDTO;
|
import eu.nebulous.utilityevaluator.model.VariableDTO;
|
||||||
|
import eu.nebulous.utilityevaluator.model.VariableType;
|
||||||
import eu.nebulous.utilityevaluator.regression.SimpleCostRegression;
|
import eu.nebulous.utilityevaluator.regression.SimpleCostRegression;
|
||||||
import eu.nebulouscloud.exn.core.Publisher;
|
import eu.nebulouscloud.exn.core.Publisher;
|
||||||
import eu.nebulouscloud.exn.core.SyncedPublisher;
|
import eu.nebulouscloud.exn.core.SyncedPublisher;
|
||||||
@ -47,8 +48,15 @@ public class UtilityEvaluatorController {
|
|||||||
}
|
}
|
||||||
List<NodeCandidateDTO> convertedNodeCandidates = NodeCandidateConverter.convertToDtoList(nodeCandidates);
|
List<NodeCandidateDTO> convertedNodeCandidates = NodeCandidateConverter.convertToDtoList(nodeCandidates);
|
||||||
List<VariableDTO> componentVariables = application.getVariables().get(component);
|
List<VariableDTO> componentVariables = application.getVariables().get(component);
|
||||||
SimpleCostRegression regression = new SimpleCostRegression(component, convertedNodeCandidates, componentVariables);
|
|
||||||
application.getCostPerformanceIndicators().put(component, regression);
|
if (componentVariables.stream().filter(var -> var.getType().equals(VariableType.CPU) || var.getType().equals(VariableType.RAM)).findAny().isPresent()){
|
||||||
|
SimpleCostRegression regression = new SimpleCostRegression(component, convertedNodeCandidates, componentVariables);
|
||||||
|
application.getCostPerformanceIndicators().put(component, regression);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.warn("There are no variables for component {} = it is not possible to create any cost performance indicator!", component);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class PerformanceIndicatorSendingService {
|
|||||||
|
|
||||||
String componentNameValidAMPL=component.replaceAll("/", "_").substring(1);
|
String componentNameValidAMPL=component.replaceAll("/", "_").substring(1);
|
||||||
|
|
||||||
String piName = "cost_pi"+componentNameValidAMPL;
|
String piName = "cost_pi_"+componentNameValidAMPL;
|
||||||
|
|
||||||
ObjectNode pi = performanceIndicators.addObject();
|
ObjectNode pi = performanceIndicators.addObject();
|
||||||
//ObjectNode pi = performanceIndicators.withObject(piName);
|
//ObjectNode pi = performanceIndicators.withObject(piName);
|
||||||
|
@ -79,7 +79,7 @@ public class NodeCandidateConverter {
|
|||||||
usedNodeParameters.add(node.getCpu());
|
usedNodeParameters.add(node.getCpu());
|
||||||
break;
|
break;
|
||||||
case RAM:
|
case RAM:
|
||||||
usedNodeParameters.add(Long.valueOf(node.getRam()).intValue());
|
usedNodeParameters.add(Long.valueOf(node.getRam()).intValue());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log.debug("Variable type {} is not usable in cost performance indicators", variable.getType());
|
log.debug("Variable type {} is not usable in cost performance indicators", variable.getType());
|
||||||
|
@ -10,10 +10,7 @@ import eu.nebulous.utilityevaluator.model.VariableDTO;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/* TODO: comments
|
|
||||||
this class looks good, except that the coefficient should be filtered based on the variables
|
|
||||||
|
|
||||||
*/
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SimpleCostRegression {
|
public class SimpleCostRegression {
|
||||||
|
|
||||||
@ -25,11 +22,14 @@ public class SimpleCostRegression {
|
|||||||
|
|
||||||
public SimpleCostRegression(String componentName, List<NodeCandidateDTO> nodeCandidates, List<VariableDTO> variables){
|
public SimpleCostRegression(String componentName, List<NodeCandidateDTO> nodeCandidates, List<VariableDTO> variables){
|
||||||
this.componentName = componentName;
|
this.componentName = componentName;
|
||||||
|
|
||||||
this.regression = new OLSMultipleLinearRegression();
|
this.regression = new OLSMultipleLinearRegression();
|
||||||
|
//double[][] argumentsForRegression = NodeCandidateConverter.convertListToDoubleArray (nodeCandidates, variables);
|
||||||
regression.newSampleData(convertPricesToArray(nodeCandidates), NodeCandidateConverter.convertListToDoubleArray (nodeCandidates, variables));
|
regression.newSampleData(convertPricesToArray(nodeCandidates), NodeCandidateConverter.convertListToDoubleArray (nodeCandidates, variables));
|
||||||
log.info("Data for component {} was loaded", componentName);
|
log.info("Data for component {} was loaded", componentName);
|
||||||
this.coefficients = regression.estimateRegressionParameters();
|
this.coefficients = regression.estimateRegressionParameters();
|
||||||
log.info("Coefficients: {}", coefficients);
|
log.info("Coefficients: {}", coefficients);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double[] convertPricesToArray(List<NodeCandidateDTO> nodeCandidates) {
|
private static double[] convertPricesToArray(List<NodeCandidateDTO> nodeCandidates) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user