cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus-examples/src/main/java/org/cloudsimplus/examples/autoscaling/VerticalVmCpuScalingExample.java
private VerticalVmScaling createVerticalPeScaling() {
        //The percentage in which the number of PEs has to be scaled
        final double scalingFactor = 0.1;
        VerticalVmScaling verticalCpuScaling = new VerticalVmScalingSimple(Processor.class, scalingFactor);

        /* By uncommenting the line below, you will see that instead of gradually
         * increasing or decreasing the number of PEs, when the scaling object detect
         * the CPU usage is above or below the defined thresholds,
         * it will automatically calculate the number of PEs to add/remove to
         * move the VM from the over or underload condition.
        */
        //verticalCpuScaling.setResourceScaling(new ResourceScalingInstantaneous());

        /* Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression.
         * It is just an example which scales the resource twice the amount defined by the scaling factor
         * defined in the constructor.
         *
         * Realize that if the setResourceScaling method is not called, a ResourceScalingGradual will be used,
         * which scales the resource according to the scaling factor.
         * The lower and upper thresholds after this line can also be defined using a Lambda Expression.
         */
        verticalCpuScaling.setResourceScaling(vs -> 2*vs.getScalingFactor()*vs.getAllocatedResource());

        verticalCpuScaling.setLowerThresholdFunction(this::lowerCpuUtilizationThreshold);
        verticalCpuScaling.setUpperThresholdFunction(this::upperCpuUtilizationThreshold);

        return verticalCpuScaling;
    }
/**
     * Creates a {@link VerticalVmScaling} for scaling VM's CPU when it's under or overloaded.
     *
     * <p>Realize the lower and upper thresholds are defined inside this method by using
     * references to the methods {@link #lowerCpuUtilizationThreshold(Vm)}
     * and {@link #upperCpuUtilizationThreshold(Vm)}.
     * These methods enable defining thresholds in a dynamic way
     * and even different thresholds for distinct VMs.
     * Therefore, it's a powerful mechanism.
     * </p>
     *
     * <p>
     * However, if you are defining thresholds in a static way,
     * and they are the same for all VMs, you can use a Lambda Expression
     * like below, for instance, instead of creating a new method that just returns a constant value:<br>
     * {@code verticalCpuScaling.setLowerThresholdFunction(vm -> 0.4);}
     * </p>
     *
     * @see #createListOfScalableVms(int)
     */
Creates a  VerticalVmScaling for scaling VM's CPU when it's under or overloaded.
Realize the lower and upper thresholds are defined inside this method by using
references to the methods  #lowerCpuUtilizationThreshold(Vm)
and  #upperCpuUtilizationThreshold(Vm).
These methods enable defining thresholds in a dynamic way
and even different thresholds for distinct VMs.
Therefore, it's a powerful mechanism.


However, if you are defining thresholds in a static way,
and they are the same for all VMs, you can use a Lambda Expression
like below, for instance, instead of creating a new method that just returns a constant value:
verticalCpuScaling.setLowerThresholdFunction(vm -> 0.4);



Creates a VerticalVmScaling for scaling VM ' s CPU when it ' s under or overloaded . Realize the lower and upper thresholds are defined inside this method by using references to the methods #lowerCpuUtilizationThreshold ( Vm ) and #upperCpuUtilizationThreshold ( Vm ) . These methods enable defining thresholds in a dynamic way and even different thresholds for distinct VMs . Therefore it ' s a powerful mechanism . However if you are defining thresholds in a static way and they are the same for all VMs you can use a Lambda Expression like below for instance instead of creating a new method that just returns a constant value : verticalCpuScaling . setLowerThresholdFunction ( vm - > 0 . 4 ) ;
private VerticalVmScaling createVerticalPeScaling() {
        final double scalingFactor = 0.1;
        VerticalVmScaling verticalCpuScaling = new VerticalVmScalingSimple(Processor.class, scalingFactor);
        /* By uncommenting the line below, you will see that instead of gradually
         * increasing or decreasing the number of PEs, when the scaling object detect
         * the CPU usage is above or below the defined thresholds,
         * it will automatically calculate the number of PEs to add/remove to
         * move the VM from the over or underload condition.
        */
        /* Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression.
         * It is just an example which scales the resource twice the amount defined by the scaling factor
         * defined in the constructor.
         *
         * Realize that if the setResourceScaling method is not called, a ResourceScalingGradual will be used,
         * which scales the resource according to the scaling factor.
         * The lower and upper thresholds after this line can also be defined using a Lambda Expression.
         */
        verticalCpuScaling.setResourceScaling(vs -> 2*vs.getScalingFactor()*vs.getAllocatedResource());
        verticalCpuScaling.setLowerThresholdFunction(this::lowerCpuUtilizationThreshold);
        verticalCpuScaling.setUpperThresholdFunction(this::upperCpuUtilizationThreshold);
        return verticalCpuScaling;
    }
private VerticalVmScaling createVerticalPeScaling ( ) { final double scalingFactor = 0.1 ; VerticalVmScaling verticalCpuScaling = new VerticalVmScalingSimple ( Processor . class , scalingFactor ) ; /* By uncommenting the line below, you will see that instead of gradually
         * increasing or decreasing the number of PEs, when the scaling object detect
         * the CPU usage is above or below the defined thresholds,
         * it will automatically calculate the number of PEs to add/remove to
         * move the VM from the over or underload condition.
        */ /* Different from the commented line above, the line below implements a ResourceScaling using a Lambda Expression.
         * It is just an example which scales the resource twice the amount defined by the scaling factor
         * defined in the constructor.
         *
         * Realize that if the setResourceScaling method is not called, a ResourceScalingGradual will be used,
         * which scales the resource according to the scaling factor.
         * The lower and upper thresholds after this line can also be defined using a Lambda Expression.
         */ verticalCpuScaling . setResourceScaling ( vs -> 2 * vs . getScalingFactor ( ) * vs . getAllocatedResource ( ) ) ; verticalCpuScaling . setLowerThresholdFunction ( this :: lowerCpuUtilizationThreshold ) ; verticalCpuScaling . setUpperThresholdFunction ( this :: upperCpuUtilizationThreshold ) ; return verticalCpuScaling ; }
Creates a {@link VerticalVmScaling} for scaling VM's CPU when it's under or overloaded.
Creates a { @link VerticalVmScaling } for scaling VM ' s CPU when it ' s under or overloaded .
//The percentage in which the number of PEs has to be scaled //verticalCpuScaling.setResourceScaling(new ResourceScalingInstantaneous());