Skip to content

Commit

Permalink
一些小的优化;准备全面迁移到数据后端到int、降低精度到秒级并优化整个框架
Browse files Browse the repository at this point in the history
  • Loading branch information
Funny-ppt committed Mar 22, 2024
1 parent 3991f58 commit bb687af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
13 changes: 1 addition & 12 deletions InfrastSim/TimeDriven/WebHelper/Enumerate/EnumResult.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
namespace InfrastSim.TimeDriven.WebHelper.Enumerate;
internal struct EnumResult {
public EnumResult(OpEnumData[] comb, int init_size, in Efficiency eff, in Efficiency extra_eff) {
this.comb = comb;
this.init_size = init_size;
this.eff = eff;
this.extra_eff = extra_eff;
}

public OpEnumData[] comb { get; set; }
public int init_size { get; set; }
public Efficiency eff { get; set; }
public Efficiency extra_eff { get; set; }
internal record struct EnumResult(OpEnumData[] comb, int init_size, Efficiency eff, Efficiency extra_eff) {
}
20 changes: 9 additions & 11 deletions InfrastSim/TimeDriven/WebHelper/Enumerate/EnumerateContext.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using InfrastSim.Algorithms;
using InfrastSim.TimeDriven.WebHelper.Enumerate;
using System.Collections;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Text.Json;
using System.Threading.Channels;

namespace InfrastSim.TimeDriven.WebHelper;
namespace InfrastSim.TimeDriven.WebHelper.Enumerate;
internal class EnumerateContext {
static readonly List<int> primes = EularSieve.Resolve((1 << 24) - 1);
const int MOD = 16777213;
Expand Down Expand Up @@ -34,7 +32,7 @@ Efficiency TestMany(Simulator simu, IEnumerable<OpEnumData> datas) {
simu.FillTestOp();
}
}
bool ValidateResult(Simulator simu, in EnumResult result) {
bool ValidateResult(Simulator simu, EnumResult result) {
if (result.eff.IsZero()) return false;
if (result.init_size == 1) return true;

Expand Down Expand Up @@ -112,7 +110,7 @@ public IOrderedEnumerable<EnumResult> EnumerateImpl(JsonDocument json) {
.Where(v => ValidateResult(simu1, v))
.OrderByDescending(v => v.eff.GetScore());
}
static Simulator InitSimulator(in JsonElement elem) {
static Simulator InitSimulator(JsonElement elem) {
var simu = new Simulator();
foreach (var prop in elem.EnumerateObject()) {
simu.SetFacilityState(prop.Name, prop.Value);
Expand All @@ -128,12 +126,12 @@ static int GetGroupId(OpEnumData[] comb) {
return (comb.Length << 24) | (int)f;
}

struct Frame {
public OpEnumData[] comb = null!;
public BitArray uset = null!;
public int gid;
public int init_size;
public Efficiency base_eff;
readonly struct Frame {
public OpEnumData[] comb { get; init; } = null!;
public BitArray uset { get; init; } = null!;
public int gid { get; init; }
public int init_size { get; init; }
public Efficiency base_eff { get; init; }

public Frame(OpEnumData[] comb, Efficiency base_eff, int ucnt) {
this.comb = comb;
Expand Down

0 comments on commit bb687af

Please sign in to comment.