-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAcoAllInstancesMultipleThreadsParameterVariations.kt
75 lines (62 loc) · 2.97 KB
/
AcoAllInstancesMultipleThreadsParameterVariations.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import helpers.ConfigChooser
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import shared.Instance
import java.util.concurrent.Executors
import java.util.concurrent.ThreadLocalRandom
import java.util.concurrent.ThreadPoolExecutor
import kotlin.math.pow
fun main() {
val logger: Logger = LogManager.getLogger("main")
val timeLimitMarker = "5m"
val exportNames = (1..6).associateWith { "res-$timeLimitMarker-i$it" }
val instances = (1..6).associateWith { Instance.fromInstanceId(it) }
val baseConfigs = (1..6).associateWith { ConfigChooser.getConfig(it, timeLimitMarker) }
val executor = Executors.newFixedThreadPool(6) as ThreadPoolExecutor
while (true) {
if (executor.queue.size > 50) {
Thread.sleep(60 * 1000)
continue
}
for (instanceId in 1..6) {
val exportName = exportNames[instanceId]!!
val instance = instances[instanceId]!!
val baseConfig = baseConfigs[instanceId]!!
executor.execute {
val cAlpha = baseConfig.deepCopy()
cAlpha.ant.alpha = ThreadLocalRandom.current().nextInt(0, 21).toDouble() / 10
searchWithExports(instance, cAlpha, "$exportName-alpha", logger, cAlpha.ant.alpha)
}
executor.execute {
val cBeta = baseConfig.deepCopy()
cBeta.ant.beta = ThreadLocalRandom.current().nextInt(0, 21).toDouble() / 10
searchWithExports(instance, cBeta, "$exportName-beta", logger, cBeta.ant.beta)
}
executor.execute {
val cCount = baseConfig.deepCopy()
cCount.ant.count = ThreadLocalRandom.current().nextInt(1, 11) * 10
searchWithExports(instance, cCount, "$exportName-count", logger, cCount.ant.count)
}
executor.execute {
val cq0 = baseConfig.deepCopy()
cq0.ant.q0 = ThreadLocalRandom.current().nextInt(0, 11).toDouble() / 10
searchWithExports(instance, cq0, "$exportName-q0", logger, cq0.ant.q0)
}
executor.execute {
val cRho = baseConfig.deepCopy()
cRho.ant.rho = ThreadLocalRandom.current().nextInt(0, 21).toDouble() * 4 / 100
searchWithExports(instance, cRho, "$exportName-rho", logger, cRho.ant.rho)
}
executor.execute {
val cTau = baseConfig.deepCopy()
cTau.antColony.tauZero = 10.0.pow(ThreadLocalRandom.current().nextInt(-8, 0).toDouble())
searchWithExports(instance, cTau, "$exportName-tau", logger, cTau.antColony.tauZero)
}
executor.execute {
val cTheta = baseConfig.deepCopy()
cTheta.ant.theta = ThreadLocalRandom.current().nextInt(0, 11).toDouble() / 10
searchWithExports(instance, cTheta, "$exportName-theta", logger, cTheta.ant.theta)
}
}
}
}