Skip to content

Commit aefc4d5

Browse files
committed
Optimize active strat;
1 parent ad4c5e1 commit aefc4d5

1 file changed

Lines changed: 26 additions & 13 deletions

File tree

src/Theories/CTs/CSR2.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export default async function csr2(data: theoryData): Promise<simResult> {
1515
type theory = "CSR2";
1616

1717
type pubTable = {[key: string]: number};
18+
const lowboundsActive = [0.65, 0.15, 0.85, 0, 0];
19+
const highboundsActive = [1.45, 0.5, 1.8, 1.2, 1.2];
20+
21+
const lowboundsPassive = [0.65, 0.15, 0.85, 0, 0];
22+
const highboundsPassive = [2.85, 0.5, 3.3, 1.2, 1.2];
1823

1924
class csr2Sim extends theoryClass<theory> {
2025
recursionValue: number[];
@@ -27,6 +32,8 @@ class csr2Sim extends theoryClass<theory> {
2732
coasting: boolean[];
2833
bestRes: simResult | null;
2934
doContinuityFork: boolean;
35+
lowbounds: number[];
36+
highbounds: number[];
3037

3138
getBuyingConditions(): conditionFunction[] {
3239
const idlestrat = [true, true, true, true, true];
@@ -52,7 +59,7 @@ class csr2Sim extends theoryClass<theory> {
5259
() => this.variables[3].cost + l10(1.3) < this.variables[4].cost,
5360
true,
5461
];
55-
62+
5663
const conditions: Record<stratType[theory], (boolean | conditionFunction)[]> = {
5764
CSR2: idlestrat,
5865
CSR2PT: idlestrat,
@@ -64,10 +71,10 @@ class csr2Sim extends theoryClass<theory> {
6471
}
6572
getVariableAvailability(): conditionFunction[] {
6673
const conditions: conditionFunction[] = [
67-
() => true,
68-
() => true,
69-
() => true,
70-
() => true,
74+
() => true,
75+
() => true,
76+
() => true,
77+
() => true,
7178
() => this.milestones[1] > 0
7279
];
7380
return conditions;
@@ -88,12 +95,12 @@ class csr2Sim extends theoryClass<theory> {
8895
if (
8996
(
9097
(
91-
this.rho.value + l10(msCond * 0.5) > this.variables[3].cost
98+
this.rho.value + l10(msCond * 0.5) > this.variables[3].cost
9299
|| (this.rho.value + l10(msCond) > this.variables[4].cost && this.milestones[1] > 0)
93100
|| (this.curMult > 1 && this.rho.value + l10(2) > this.variables[1].cost)
94-
)
101+
)
95102
&& this.rho.value < Math.min(this.variables[3].cost, this.variables[4].cost)
96-
)
103+
)
97104
|| this.t > this.recursionValue[0]
98105
) {
99106
return q1priority;
@@ -158,14 +165,22 @@ class csr2Sim extends theoryClass<theory> {
158165
new Variable({ name: "n", cost: new ExponentialCost(50, 2 ** (Math.log2(256) * 3.346)), valueScaling: new LinearValue(1, 1)}),
159166
new Variable({ name: "c2", cost: new ExponentialCost(1e3, 10 ** 5.65), valueScaling: new ExponentialValue(2) }),
160167
];
161-
168+
162169
this.recursionValue = <number[]>data.recursionValue ?? [Infinity, 0];
163170
this.bestCoast = [0, 0];
164171

165172
this.forcedPubRho = Infinity;
166173
this.coasting = new Array(this.variables.length).fill(false);
167174
this.bestRes = null;
168175
this.doContinuityFork = true;
176+
if(this.strat.includes("XL")) {
177+
this.lowbounds = lowboundsActive;
178+
this.highbounds = highboundsActive;
179+
}
180+
else {
181+
this.lowbounds = lowboundsPassive;
182+
this.highbounds = highboundsPassive;
183+
}
169184
if (this.strat.includes("PT") && this.lastPub >= 500 && this.lastPub < 1499.5) {
170185
let newpubtable: pubTable = pubtable.csr2data;
171186
let pubseek = Math.round(this.lastPub * 16);
@@ -263,14 +278,12 @@ class csr2Sim extends theoryClass<theory> {
263278
return !this.coasting[id];
264279
}
265280
async confirmPurchase(id: number): Promise<boolean> {
266-
const lowbounds = [0.65, 0.15, 0.85, 0, 0];
267-
const highbounds = [2.85, 0.5, 3.3, 1.2, 1.2];
268281
if (this.forcedPubRho !== Infinity) {
269-
if (this.forcedPubRho - this.variables[id].cost <= lowbounds[id]) {
282+
if (this.forcedPubRho - this.variables[id].cost <= this.lowbounds[id]) {
270283
this.coasting[id] = true;
271284
return false;
272285
}
273-
if (this.forcedPubRho - this.variables[id].cost < highbounds[id]) {
286+
if (this.forcedPubRho - this.variables[id].cost < this.highbounds[id]) {
274287
let fork = this.copy();
275288
fork.coasting[id] = true;
276289
const forkres = await fork.simulate(super.getDataForCopy());

0 commit comments

Comments
 (0)