Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jon Shahen
vagabond
Commits
8a6c9c09
Commit
8a6c9c09
authored
May 22, 2016
by
Jonathan Shahen
Browse files
Commit before Bug Hunt on CNF Reduction
parent
664f3fca
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/vagabond/VagabondInstance.java
View file @
8a6c9c09
...
...
@@ -25,7 +25,6 @@ import vagabond.reduction.ilp.ReduceToILP;
import
vagabond.reduction.ilp.RunSolverILP
;
import
vagabond.reduction.nomad.ReduceToNomad
;
import
vagabond.reduction.nomad.RunSolverNomad
;
import
vagabond.results.ResultsManager
;
import
vagabond.results.StatisticsManager
;
import
vagabond.singleton.VagabondSettings
;
import
vagabond.testing.PlacementMapExamples
;
...
...
@@ -112,13 +111,17 @@ public class VagabondInstance {
EpochHistory
epochHistory
=
new
EpochHistory
(
settings
.
slidingWindow
);
// IMPORTANT: add the placementMap to the EpochHistory before starting the reductions
epochHistory
.
add
(
placementMap
);
// STATS
stats
.
initialPM
=
placementMap
;
stats
.
initialCCIL
=
epochHistory
.
get
(
0
);
if
(
logger
.
isLoggable
(
FINE
))
{
logger
.
fine
(
"Summation of Client-to-Client Information Leakage (Z variable):\n"
+
epochHistory
.
_sumOfInformationLeakage
);
}
// Results Initial Placement
settings
.
results
=
new
ResultsManager
();
settings
.
results
.
initialPlacement
=
placementMap
;
settings
.
results
.
initialCCIL
=
epochHistory
.
get
(
0
);
...
...
@@ -204,7 +207,7 @@ public class VagabondInstance {
}
/* Timing */
timing
.
toggleTimer
(
tp
+
"VagabondInstance::main()::epochLoop::reduce"
);
// ###
// ###
###############################################################################
/* Timing */
timing
.
toggleTimer
(
tp
+
"VagabondInstance::main()::epochLoop::load"
);
// Load the Solver + Error checking
...
...
@@ -214,7 +217,7 @@ public class VagabondInstance {
+
reduction
.
toString
());
}
/* Timing */
timing
.
toggleTimer
(
tp
+
"VagabondInstance::main()::epochLoop::load"
);
// ###
// ###
###############################################################################
/* Timing */
timing
.
toggleTimer
(
tp
+
"VagabondInstance::main()::epochLoop::run"
);
// Run The Solver
...
...
@@ -222,7 +225,7 @@ public class VagabondInstance {
EpochHistory
newEpochHistory
=
runSolver
.
run
();
/* Timing */
timing
.
toggleTimer
(
tp
+
"VagabondInstance::main()::epochLoop::run"
);
// ###
// ###
###############################################################################
// ERROR CHECKING for getting the new result
if
(
newEpochHistory
==
null
)
{
throw
new
Exception
(
...
...
@@ -242,6 +245,11 @@ public class VagabondInstance {
/* Timing */
stats
.
addEpochTime
(
timing
.
stopTimer
(
tp
+
"VagabondInstance::main()::epochLoop::totalTime"
));
// STATS
stats
.
listTIL
.
add
(
epochHistory
.
get
(
0
).
getSumInformationLeak
());
stats
.
listMCCIL
.
add
(
epochHistory
.
get
(
0
).
getMaxInformationLeak
());
stats
.
listMovesPerEpoch
.
add
(
epochHistory
.
_latestNumberOfMoves
);
// Must be after the STATS
if
(
settings
.
reductionAlgorithm
==
VagabondOptionString
.
REDUCTION_NOMAD
)
{
logger
.
info
(
"Exiting the EPOCH LOOP because Nomad does its own EPOCH LOOP."
);
...
...
@@ -255,13 +263,19 @@ public class VagabondInstance {
*/
/* Timing */
timing
.
stopTimer
(
"VagabondInstance::main()::epochLoop::total"
);
/* Timing */
timing
.
stopTimer
(
"totalTime"
);
/* Timing */
stats
.
totalTime
=
timing
.
stopTimer
(
"totalTime"
);
logger
.
info
(
timing
.
toString
());
logger
.
info
(
"Writing Timing Results to "
+
settings
.
getTimingFile
().
getAbsolutePath
());
timing
.
writeOut
(
settings
.
getTimingFile
(),
true
);
// Fill up the stats manager
stats
.
finalPM
=
epochHistory
.
_latestPlacementMap
;
stats
.
finalCCIL
=
epochHistory
.
get
(
0
);
stats
.
eh
=
epochHistory
;
// Write out all the stats
stats
.
writeOut
(
settings
.
getStatsFile
());
// Results Final Placement
settings
.
results
.
finalPlacement
=
epochHistory
.
_latestPlacementMap
;
...
...
@@ -477,6 +491,20 @@ public class VagabondInstance {
settings
.
randomSeed
=
Integer
.
valueOf
(
value
);
}
value
=
prop
.
getProperty
(
VagabondOptionString
.
TESTNAME
.
toString
(),
null
);
if
(
value
!=
null
)
{
logger
.
info
(
"[OPTION] Setting the test name to: "
+
value
);
settings
.
stats
.
testName
=
value
;
}
value
=
prop
.
getProperty
(
VagabondOptionString
.
TESTCOMMENT
.
toString
(),
null
);
if
(
value
!=
null
)
{
logger
.
info
(
"[OPTION] Setting the test comments to: "
+
value
);
settings
.
stats
.
comments
=
value
;
}
// ################################################
// Check for any missing settings values
if
(!
mustContain
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"The settings file must contain these additional settings: "
+
mustContain
.
toString
());
}
...
...
@@ -708,7 +736,6 @@ public class VagabondInstance {
}
else
{
logger
.
fine
(
"[OPTION] Default Line String Used"
);
}
}
private
void
setupResultOptions
(
CommandLine
cmd
,
Options
options
)
{
...
...
src/vagabond/VagabondOptionString.java
View file @
8a6c9c09
...
...
@@ -2,6 +2,7 @@ package vagabond;
import
java.util.ArrayList
;
import
vagabond.results.StatisticsManager
;
import
vagabond.testing.PlacementMapExamples
;
/**
...
...
@@ -163,6 +164,18 @@ public enum VagabondOptionString {
* @vagabond.category Settings File Property
*/
REDUCTION
(
"reduction"
),
/**
* [Settings File Property] Any comments that should be recorded in the STATS file
* @vagabond.category Settings File Property
* @see StatisticsManager#comments
*/
TESTCOMMENT
(
"comment"
),
/**
* [Settings File Property] The name of the test to be recorded in the STATS file
* @vagabond.category Settings File Property
* @see StatisticsManager#testName
*/
TESTNAME
(
"name"
),
// Placement Algorithms
/**
...
...
src/vagabond/pieces/ClientToClientInformationLeakage.java
View file @
8a6c9c09
...
...
@@ -27,6 +27,8 @@ public class ClientToClientInformationLeakage {
private
int
_maxInformationLeak
=
-
1
;
private
ClientToClientKey
_maxInformationLeakKey
=
null
;
private
Integer
sumInformationLeak
=
null
;
/**
* Calculates the sum for each client on each machine here
* @param place the PlacementMap that holds where VMs are stored
...
...
@@ -117,24 +119,15 @@ public class ClientToClientInformationLeakage {
}
/**
* Calculates the <R,NC> information leakage
*/
private
void
calculateRNC_ClientToClientInfoLeak
()
{
// TODO Create this method
}
/**
* Calculates the <NR,C> information leakage
* Get the Client To Client Information Leakage that is stored; O(1) look up.
* @param clientID1 the normal client ID
* @param clientID2 the potential adversary client ID
* @return the stored information leakage from clientID1 to clientID2
*/
private
void
calculateNRC_ClientToClientInfoLeak
()
{
// TODO Create this method
}
public
Integer
get
(
Integer
clientID1
,
Integer
clientID2
)
{
if
(
clientID1
==
null
||
clientID2
==
null
)
{
throw
new
IllegalArgumentException
(
"Client ID cannot be null"
);
}
/**
* Calculates the <NR,NC> information leakage
*/
private
void
calculateNRNC_ClientToClientInfoLeak
()
{
// TODO Create this method
return
_matrix
.
getOrDefault
(
new
ClientToClientKey
(
clientID1
,
clientID2
),
0
);
}
/**
...
...
@@ -162,15 +155,22 @@ public class ClientToClientInformationLeakage {
}
/**
* Get the Client To Client Information Leakage that is stored; O(1) look up.
* @param clientID1 the normal client ID
* @param clientID2 the potential adversary client ID
* @return the stored information leakage from clientID1 to clientID2
* Calculates or returns the stored Sum/Total Information Leakage
* @return sum/total information leakage
*/
public
I
nt
eger
get
(
Integer
clientID1
,
Integer
clientID2
)
{
if
(
clientID1
==
null
||
clientID2
==
null
)
{
throw
new
IllegalArgumentException
(
"Client ID cannot be null"
)
;
}
public
i
nt
getSumInformationLeak
(
)
{
if
(
sumInformationLeak
!=
null
)
{
return
sumInformationLeak
;
}
return
_matrix
.
getOrDefault
(
new
ClientToClientKey
(
clientID1
,
clientID2
),
0
);
int
sum
=
0
;
for
(
Integer
c0
:
_clientIDs
)
{
for
(
Integer
c1
:
_clientIDs
)
{
sum
+=
get
(
c0
,
c1
);
}
}
sumInformationLeak
=
sum
;
return
sum
;
}
/**
...
...
@@ -335,14 +335,24 @@ public class ClientToClientInformationLeakage {
return
sb
.
toString
();
}
public
int
getSumInformationLeak
()
{
int
sum
=
0
;
for
(
Integer
c0
:
_clientIDs
)
{
for
(
Integer
c1
:
_clientIDs
)
{
sum
+=
get
(
c0
,
c1
);
}
}
/**
* Calculates the <R,NC> information leakage
*/
private
void
calculateRNC_ClientToClientInfoLeak
()
{
// TODO Create this method
}
return
sum
;
/**
* Calculates the <NR,C> information leakage
*/
private
void
calculateNRC_ClientToClientInfoLeak
()
{
// TODO Create this method
}
/**
* Calculates the <NR,NC> information leakage
*/
private
void
calculateNRNC_ClientToClientInfoLeak
()
{
// TODO Create this method
}
}
src/vagabond/pieces/EpochHistory.java
View file @
8a6c9c09
...
...
@@ -19,7 +19,7 @@ public class EpochHistory {
public
ClientToClientInformationLeakage
_sumOfInformationLeakage
=
null
;
public
Integer
_slidingWindow
=
null
;
public
Integer
_
n
umberOfMoves
=
null
;
public
Integer
_
latestN
umberOfMoves
=
null
;
public
EpochHistory
(
Integer
slidingWindow
)
{
logger
=
VagabondSettings
.
getInstance
().
getLogger
();
...
...
@@ -40,7 +40,9 @@ public class EpochHistory {
add
(
tmp
);
if
(
_latestPlacementMap
!=
null
)
{
_numberOfMoves
=
_latestPlacementMap
.
countNumberOfMoves
(
placementMap
);
_latestNumberOfMoves
=
_latestPlacementMap
.
countNumberOfMoves
(
placementMap
);
}
else
{
_latestNumberOfMoves
=
0
;
}
_latestPlacementMap
=
placementMap
;
}
...
...
src/vagabond/reduction/cnfsat/RunSolverCNFSAT.java
View file @
8a6c9c09
...
...
@@ -20,7 +20,6 @@ public class RunSolverCNFSAT implements RunSolver {
public
String
tp
=
"Epoch_Unknown"
;
public
static
Logger
logger
;
String
solverloc
;
String
cnfloc
;
// OLD VALUE = new String("/home/tripunit/Desktop/instance.cnf");
ReduceToCNFSAT
_r
=
null
;
...
...
@@ -137,7 +136,7 @@ public class RunSolverCNFSAT implements RunSolver {
+
StringUtils
.
leftPad
(
mid
+
""
,
(
int
)
Math
.
floor
(
Math
.
log10
(
hi
))
+
1
,
"0"
);
/*TIMING*/
timing
.
toggleTimer
(
tp
+
"RunSolverCNFSAT::run::binarySearch::loopVal::"
+
searchVal
);
// System.out.println("mid = "+mid); System.out.flush();
logger
.
info
(
"
mid = "
+
mid
);
logger
.
info
(
"
[CNF Solver] Binary Search mid = "
+
mid
+
"; high="
+
hi
+
"; low="
+
lo
);
try
{
constraintInfoLeakUb
(
c
,
le
,
band
,
s
,
nclientpairs
,
mid
,
wirestoand
,
orignoutputs
);
...
...
@@ -153,7 +152,7 @@ public class RunSolverCNFSAT implements RunSolver {
if
(
mid
<
hi
&&
EACH_DECISION_INSTANCE_TIMEOUT
>
0
&&
!
p
.
waitFor
(
EACH_DECISION_INSTANCE_TIMEOUT
,
TimeUnit
.
SECONDS
))
{
// Treat this as unsat
p
.
destroyForcibly
();
p
.
destroyForcibly
();
lo
=
mid
+
1
;
/*TIMING*/
timing
.
toggleTimer
(
tp
+
"RunSolverCNFSAT::run::binarySearch::exec::"
+
searchVal
);
continue
;
...
...
src/vagabond/results/StatisticsManager.java
View file @
8a6c9c09
package
vagabond.results
;
import
java.io.*
;
import
java.util.ArrayList
;
import
vagabond.pieces.*
;
...
...
@@ -16,7 +17,6 @@ public class StatisticsManager {
public
EpochHistory
eh
;
public
ArrayList
<
Long
>
epochTimes
=
new
ArrayList
<>();
public
Long
avgEpochTime
=
null
;
public
ArrayList
<
Integer
>
listTIL
=
new
ArrayList
<>();
public
ArrayList
<
Integer
>
listMCCIL
=
new
ArrayList
<>();
public
ArrayList
<
Integer
>
listMovesPerEpoch
=
new
ArrayList
<>();
...
...
@@ -25,10 +25,26 @@ public class StatisticsManager {
public
String
comments
=
""
;
// Calculated
private
Long
avgEpochTime
=
null
;
public
StatisticsManager
()
{
startDTStr
=
VagabondSettings
.
getCurrentDateTimeStr
();
}
public
void
writeOut
(
File
statsFile
)
throws
IOException
{
FileWriter
stats
=
new
FileWriter
(
statsFile
,
true
);
// NEVER OVERWRITE STATS!
if
(!
statsFile
.
exists
())
{
stats
.
write
(
getCSVHeader
());
stats
.
write
(
"\n"
);
}
stats
.
write
(
getCSVStatsLine
());
stats
.
write
(
"\n"
);
stats
.
close
();
}
public
String
getCSVHeader
()
{
StringBuilder
sb
=
new
StringBuilder
(
1000
);
...
...
src/vagabond/singleton/VagabondSettings.java
View file @
8a6c9c09
...
...
@@ -86,9 +86,13 @@ public class VagabondSettings {
*/
public
String
timingFile
=
"vagabond.timing.csv"
;
/**
* The file name of the results
results
file to write out; SHOULD be stored under the folder {@link #logFolder}.
* The file name of the results file to write out; SHOULD be stored under the folder {@link #logFolder}.
*/
public
String
resultsFile
=
"vagabond.results.txt"
;
/**
* The file name of the stats file to write out; SHOULD be stored under the folder {@link #logFolder}.
*/
public
String
statsFile
=
"vagabond.stats.csv"
;
/**
* The IBM OPL file for the minimize the <b>MAX</b> Client to Client Information Leakage
* @see #getIlpOplFile()
...
...
@@ -474,6 +478,10 @@ public class VagabondSettings {
return
new
File
(
logFolder
+
File
.
separator
+
resultsFile
);
}
public
File
getStatsFile
()
{
return
new
File
(
logFolder
+
File
.
separator
+
statsFile
);
}
/**
* Function to return the file path of the Settings.ini file that Nomad is expecting to be filled before running.
* @return File object to the Nomad settings.ini file
...
...
tests/bugTest.txt
0 → 100644
View file @
8a6c9c09
# I am a comment
numberOfMachines=3
numberOfMachineSlots=3
numberOfClients=4
numberOfVMsPerClient=2
fillInEmpty=false
numberOfEpochs=10
slidingWindow=5
placement=randomPlacement
reduction=ilp
migrationBudget=3
# OPTIONAL: Can Comment these lines out
seed=12
name=CNFSimple
comment=Just a simple test to show that something works
\ No newline at end of file
tests/simpletestCNF.properties
View file @
8a6c9c09
...
...
@@ -10,4 +10,6 @@ placement=randomPlacement
reduction
=
cnf
migrationBudget
=
3
# OPTIONAL: Can Comment these lines out
seed
=
12
\ No newline at end of file
seed
=
12
name
=
CNFSimple
comment
=
Just a simple test to show that something works
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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