Buggy code:
public static final String FUNCTIONALITY2TIER_FILE_NAME = "functionalityChain2Tier.xml" ; public List < File > createAdaptationModelAndRules ( String basePath , String space4cloudSolutionPath , String functionalityToTierPath , String space4cloudPerformancePath , int optimizationWindowLenght , int timestepDuration , String suffix , Map < String , Double > functionalityDemands ) throws Exception { { if ( ( basePath == null ) || ( ( basePath . trim ( ) . length ( ) ) == 0 ) ) throw new RuntimeException ( "The<seq2seq4repair_space>base<seq2seq4repair_space>path<seq2seq4repair_space>parameter<seq2seq4repair_space>is<seq2seq4repair_space>null<seq2seq4repair_space>or<seq2seq4repair_space>not<seq2seq4repair_space>valid!" ) ; if ( ( suffix == null ) || ( ( suffix . trim ( ) . length ( ) ) == 0 ) ) throw new RuntimeException ( "The<seq2seq4repair_space>suffix<seq2seq4repair_space>parameter<seq2seq4repair_space>is<seq2seq4repair_space>null<seq2seq4repair_space>or<seq2seq4repair_space>not<seq2seq4repair_space>valid!" ) ; File basePathFolder = ConfigManager . getPathToFile ( basePath ) . toFile ( ) ; if ( ( ! ( basePathFolder . exists ( ) ) ) || ( ! ( basePathFolder . isDirectory ( ) ) ) ) throw new RuntimeException ( ( ( "The<seq2seq4repair_space>base<seq2seq4repair_space>path<seq2seq4repair_space>(" + basePath ) + ")<seq2seq4repair_space>doesn't<seq2seq4repair_space>refer<seq2seq4repair_space>to<seq2seq4repair_space>a<seq2seq4repair_space>correct<seq2seq4repair_space>folder." ) ) ; if ( space4cloudSolutionPath == null ) space4cloudSolutionPath = Paths . get ( basePathFolder . toString ( ) , String . format ( AdaptationModelBuilder . SOLUTION_FILE_NAME , suffix ) ) . toString ( ) ; if ( space4cloudPerformancePath == null ) space4cloudPerformancePath = Paths . get ( basePathFolder . toString ( ) , String . format ( AdaptationModelBuilder . PERFORMANCE_FILE_NAME , suffix ) ) . toString ( ) ; if ( functionalityToTierPath == null ) functionalityToTierPath = Paths . get ( basePathFolder . getParent ( ) , AdaptationModelBuilder . FUNCTIONALITY2TIER_FILE_NAME ) . toString ( ) ; File f = new File ( space4cloudPerformancePath ) ; if ( ( ! ( f . exists ( ) ) ) && ( ! ( f . isFile ( ) ) ) ) throw new RuntimeException ( "Performance<seq2seq4repair_space>file<seq2seq4repair_space>not<seq2seq4repair_space>found!" ) ; f = new File ( space4cloudSolutionPath ) ; if ( ( ! ( f . exists ( ) ) ) && ( ! ( f . isFile ( ) ) ) ) throw new RuntimeException ( "Solution<seq2seq4repair_space>file<seq2seq4repair_space>not<seq2seq4repair_space>found!" ) ; f = new File ( functionalityToTierPath ) ; if ( ( ! ( f . exists ( ) ) ) && ( ! ( f . isFile ( ) ) ) ) throw new RuntimeException ( "Functionality2Tier<seq2seq4repair_space>file<seq2seq4repair_space>not<seq2seq4repair_space>found!" ) ; if ( optimizationWindowLenght < 0 ) optimizationWindowLenght = AdaptationModelBuilder . DEFAULT_OPTIMIZATION_WINDOW_LENGTH ; if ( timestepDuration < 0 ) timestepDuration = AdaptationModelBuilder . DEFAULT_TIMESTEP_DURATION ; } AdaptationModelBuilder . logger . info ( "Reading<seq2seq4repair_space>the<seq2seq4repair_space>input<seq2seq4repair_space>files<seq2seq4repair_space>and<seq2seq4repair_space>preparing<seq2seq4repair_space>the<seq2seq4repair_space>results..." ) ; ObjectFactory factory = new ObjectFactory ( ) ; List < Tier > tiersInFunctionalityToTier = AdaptationModelBuilder . parseFunctionalityToTierFile ( functionalityToTierPath ) . getTier ( ) ; Performance p = AdaptationModelBuilder . parsePerformancesFile ( space4cloudPerformancePath ) ; List < Seff > performance = p . getSeffs ( ) . getSeff ( ) ; List < it . polimi . modaclouds . qos_models . schema . Performance . Tiers . Tier > tiersPerformance = p . getTiers ( ) . getTier ( ) ; MonitoringRulesHelper rulesHelper = new MonitoringRulesHelper ( ) ; Containers model = factory . createContainers ( ) ; model . setSpeedNorm ( 1200 ) ; model . setOptimizationWindowsLenght ( optimizationWindowLenght ) ; model . setTimestepDuration ( timestepDuration ) ; try { ResourceModelExtension solution = ( ( ResourceModelExtension ) ( XMLHelper . deserialize ( new FileInputStream ( space4cloudSolutionPath ) , ResourceModelExtension . class ) ) ) ; for ( ResourceContainer tier : solution . getResourceContainer ( ) ) { ApplicationTier newTier = factory . createApplicationTier ( ) ; Map < String , String > functionalityNameToId = new HashMap < String , String > ( ) ; CloudResource resource = this . dbHandler . getCloudResource ( tier . getProvider ( ) , tier . getCloudElement ( ) . getServiceName ( ) , tier . getCloudElement ( ) . getResourceSizeID ( ) ) ; for ( it . polimi . modaclouds . qos_models . schema . Performance . Tiers . Tier t : tiersPerformance ) { if ( t . getId ( ) . equals ( tier . getId ( ) ) ) { newTier . setId ( t . getName ( ) ) ; } } for ( Tier t : tiersInFunctionalityToTier ) { if ( t . getId ( ) . equals ( tier . getId ( ) ) ) { List < Functionality > functionalities = t . getFunctionality ( ) ; for ( Functionality f : functionalities ) { it . polimi . modaclouds . qos_models . schema . Functionality toAdd = factory . createFunctionality ( ) ; toAdd . setId ( f . getName ( ) ) ; Double demand = functionalityDemands . get ( f . getId ( ) ) ; if ( demand == null ) toAdd . setDemand ( 0.0 ) ; else <START_BUG> toAdd . setDemand ( ( demand * 1000 ) ) ; <END_BUG> functionalityNameToId . put ( f . getName ( ) , f . getId ( ) ) ; newTier . getFunctionality ( ) . add ( toAdd ) ; } } } this . setResponseTimeThresholds ( performance , newTier , functionalityNameToId ) ; boolean existingContainer = false ; Container toUpdate = null ; double capacity = this . getResourceCapacity ( resource , model . getSpeedNorm ( ) ) ; for ( Container c : model . getContainer ( ) ) { if ( ( c . getCapacity ( ) ) == capacity ) { existingContainer = true ; toUpdate = c ; } } if ( ! existingContainer ) { Container toAdd = factory . createContainer ( ) ; toAdd . setId ( ( ( "capacity" + capacity ) + "Container" ) ) ; toAdd . setCapacity ( capacity ) ; toAdd . setProcessingRate ( this . getProcessingRate ( resource ) ) ; toAdd . setNCore ( this . getNCore ( resource ) ) ; toAdd . setMaxReserved ( 0 ) ; toAdd . setOnDemandCost ( this . getResourceOnDemandCost ( resource , tier . getCloudElement ( ) . getLocation ( ) . getRegion ( ) ) ) ;

Fix:
toAdd . setDemand ( demand ) ;