Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gpucloudsim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LPDS
gpucloudsim
Commits
84fec2db
Commit
84fec2db
authored
Apr 29, 2011
by
Anton Beloglazov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UtilizationModelStochastic has been updated to optionally set a random seed
parent
163c51e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
Host.java
...es/cloudsim/src/main/java/org/cloudbus/cloudsim/Host.java
+1
-1
UtilizationModelStochastic.java
...ava/org/cloudbus/cloudsim/UtilizationModelStochastic.java
+30
-1
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/Host.java
View file @
84fec2db
...
...
@@ -456,7 +456,7 @@ public class Host {
*
* @return the VM scheduler
*/
p
rotected
VmScheduler
getVmScheduler
()
{
p
ublic
VmScheduler
getVmScheduler
()
{
return
vmScheduler
;
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/UtilizationModelStochastic.java
View file @
84fec2db
...
...
@@ -14,7 +14,9 @@ import java.io.ObjectInputStream;
import
java.io.ObjectOutputStream
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Random
;
// TODO: Auto-generated Javadoc
/**
* The UtilizationModelStochastic class implements a model, according to which
* a Cloudlet generates random CPU utilization every time frame.
...
...
@@ -23,6 +25,9 @@ import java.util.Map;
* @since CloudSim Toolkit 2.0
*/
public
class
UtilizationModelStochastic
implements
UtilizationModel
{
/** The random generator. */
private
Random
randomGenerator
;
/** The history. */
private
Map
<
Double
,
Double
>
history
;
...
...
@@ -32,6 +37,12 @@ public class UtilizationModelStochastic implements UtilizationModel {
*/
public
UtilizationModelStochastic
()
{
setHistory
(
new
HashMap
<
Double
,
Double
>());
setRandomGenerator
(
new
Random
());
}
public
UtilizationModelStochastic
(
long
seed
)
{
setHistory
(
new
HashMap
<
Double
,
Double
>());
setRandomGenerator
(
new
Random
(
seed
));
}
/* (non-Javadoc)
...
...
@@ -43,7 +54,7 @@ public class UtilizationModelStochastic implements UtilizationModel {
return
getHistory
().
get
(
time
);
}
double
utilization
=
Math
.
random
();
double
utilization
=
getRandomGenerator
().
nextDouble
();
getHistory
().
put
(
time
,
utilization
);
return
utilization
;
}
...
...
@@ -95,4 +106,22 @@ public class UtilizationModelStochastic implements UtilizationModel {
ois
.
close
();
}
/**
* Sets the random generator.
*
* @param randomGenerator the new random generator
*/
public
void
setRandomGenerator
(
Random
randomGenerator
)
{
this
.
randomGenerator
=
randomGenerator
;
}
/**
* Gets the random generator.
*
* @return the random generator
*/
public
Random
getRandomGenerator
()
{
return
randomGenerator
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment