我需要一个解释(
This commit is contained in:
parent
b4b9c4d739
commit
a7f0468507
@ -23,6 +23,7 @@ simd = []
|
|||||||
opt-level = 3
|
opt-level = 3
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
debug = false
|
debug = true
|
||||||
|
strip = false
|
||||||
lto = true
|
lto = true
|
||||||
overflow-checks = false
|
overflow-checks = false
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
use crate::name::{Namer, TeamNamer};
|
use crate::{evaluate::NamerEvaluater, name::{Namer, TeamNamer}};
|
||||||
|
|
||||||
use std::{io::Write, path::PathBuf};
|
use std::{io::Write, path::PathBuf};
|
||||||
|
|
||||||
use base16384::Base16384Utf8;
|
use base16384::Base16384Utf8;
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use tracing::{info, warn};
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
pub fn show_name(namer: &Namer) -> String {
|
pub fn show_name(namer: &Namer) -> String {
|
||||||
format!(
|
format!(
|
||||||
@ -59,6 +59,7 @@ pub fn cacl(config: CacluateConfig, id: u64, outfile: &PathBuf) {
|
|||||||
let mut start_time = std::time::Instant::now();
|
let mut start_time = std::time::Instant::now();
|
||||||
let mut k: u64 = 0;
|
let mut k: u64 = 0;
|
||||||
let mut get_count: u32 = 0;
|
let mut get_count: u32 = 0;
|
||||||
|
let xuping = crate::evaluate::xuping::XuPing1_3_1::new(5000.0);
|
||||||
// 提前准备好 team_namer
|
// 提前准备好 team_namer
|
||||||
let team_namer = TeamNamer::new(&config.team).unwrap();
|
let team_namer = TeamNamer::new(&config.team).unwrap();
|
||||||
|
|
||||||
@ -68,9 +69,20 @@ pub fn cacl(config: CacluateConfig, id: u64, outfile: &PathBuf) {
|
|||||||
let prop = namer.get_property();
|
let prop = namer.get_property();
|
||||||
|
|
||||||
if (prop + config.prop_allow as f32) > config.prop_expect as f32 {
|
if (prop + config.prop_allow as f32) > config.prop_expect as f32 {
|
||||||
get_count += 1;
|
|
||||||
let name = gen_name(i as u64);
|
let name = gen_name(i as u64);
|
||||||
let full_name = format!("{}@{}", name, config.team);
|
let full_name = format!("{}@{}", name, config.team);
|
||||||
|
// 虚评
|
||||||
|
// if crate::evaluate::xuping::XuPing1_3_1::evaluate(&namer) {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
let xu = crate::evaluate::xuping::XuPing1_3_1::evaluate(&namer);
|
||||||
|
|
||||||
|
debug!("Id:{:>15}|{:>5}|{}|{}", i, full_name, xu, show_name(&namer));
|
||||||
|
if xu < 5000.0 {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_count += 1;
|
||||||
info!("Id:{:>15}|{}|{}", i, full_name, show_name(&namer));
|
info!("Id:{:>15}|{}|{}", i, full_name, show_name(&namer));
|
||||||
// 写入 (写到最后一行)
|
// 写入 (写到最后一行)
|
||||||
match std::fs::OpenOptions::new()
|
match std::fs::OpenOptions::new()
|
||||||
|
@ -5,13 +5,19 @@ mod model20;
|
|||||||
use crate::evaluate::NamerEvaluater;
|
use crate::evaluate::NamerEvaluater;
|
||||||
use crate::name::Namer;
|
use crate::name::Namer;
|
||||||
|
|
||||||
pub struct XuPing1_3_1;
|
pub struct XuPing1_3_1 {
|
||||||
|
pub limit: f64,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl XuPing1_3_1 {
|
||||||
|
pub fn new(limit: f64) -> Self { Self { limit } }
|
||||||
|
}
|
||||||
|
|
||||||
impl NamerEvaluater for XuPing1_3_1 {
|
impl NamerEvaluater for XuPing1_3_1 {
|
||||||
const NAME: &'static str = "虚评";
|
const NAME: &'static str = "虚评";
|
||||||
const VERSION: &'static str = "1.3.1";
|
const VERSION: &'static str = "1.3.1";
|
||||||
fn evaluate(name: &Namer) -> f64 { eval::predict_13(name) }
|
fn evaluate(name: &Namer) -> f64 { eval::predict_13(name) }
|
||||||
fn check(&self, name: &Namer) -> bool { eval::predict_13(name) > 0.0 }
|
fn check(&self, name: &Namer) -> bool { eval::predict_13(name) > self.limit }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct XuPing2_0_1015;
|
pub struct XuPing2_0_1015;
|
||||||
|
@ -5,6 +5,8 @@ use std::simd::f64x64;
|
|||||||
#[cfg(feature = "simd")]
|
#[cfg(feature = "simd")]
|
||||||
use std::simd::num::SimdFloat;
|
use std::simd::num::SimdFloat;
|
||||||
|
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
use crate::evaluate::xuping::model13 as xuping13;
|
use crate::evaluate::xuping::model13 as xuping13;
|
||||||
use crate::name::Namer;
|
use crate::name::Namer;
|
||||||
|
|
||||||
@ -14,20 +16,21 @@ pub fn predict_13(name: &Namer) -> f64 {
|
|||||||
memset(st + 8, 0, 35 * sizeof(int));
|
memset(st + 8, 0, 35 * sizeof(int));
|
||||||
for (int i = 0; i < 16; i++)
|
for (int i = 0; i < 16; i++)
|
||||||
if (context::freq[i]) st[context::skill[i] + 8] = context::freq[i]; */
|
if (context::freq[i]) st[context::skill[i] + 8] = context::freq[i]; */
|
||||||
// 长度取 64, 方便simd填充
|
|
||||||
let mut st: [f64; 64] = [0.0; 64];
|
|
||||||
for i in 0..7 {
|
|
||||||
st[i] = name.name_prop[i] as f64;
|
|
||||||
}
|
|
||||||
for i in 0..16 {
|
|
||||||
if name.skl_freq[i] != 0 {
|
|
||||||
st[name.skl_id[i] as usize + 8] = name.skl_freq[i] as f64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// use simd
|
// use simd
|
||||||
#[cfg(feature = "simd")]
|
// #[cfg(feature = "simd")]
|
||||||
|
#[cfg(not(feature = "simd"))]
|
||||||
{
|
{
|
||||||
|
let mut st: [f64; 64] = [0.0; 64];
|
||||||
|
// 长度取 64, 方便simd填充
|
||||||
|
for i in 0..7 {
|
||||||
|
st[i] = name.name_prop[i] as f64;
|
||||||
|
}
|
||||||
|
for i in 0..16 {
|
||||||
|
if name.skl_freq[i] != 0 {
|
||||||
|
st[name.skl_id[i] as usize + 8] = name.skl_freq[i] as f64;
|
||||||
|
}
|
||||||
|
}
|
||||||
// 先准备数据
|
// 先准备数据
|
||||||
let mut target = [0_f64; 989];
|
let mut target = [0_f64; 989];
|
||||||
target[0..43].copy_from_slice(&st[0..43]);
|
target[0..43].copy_from_slice(&st[0..43]);
|
||||||
@ -45,28 +48,44 @@ pub fn predict_13(name: &Namer) -> f64 {
|
|||||||
let simd_module = simds.as_simd_mut::<64>();
|
let simd_module = simds.as_simd_mut::<64>();
|
||||||
let simd_target = target.as_simd_mut::<64>();
|
let simd_target = target.as_simd_mut::<64>();
|
||||||
// 前面多出来的
|
// 前面多出来的
|
||||||
for i in 0..simd_module.0.len() {
|
for i in 0..simd_module.0.len() - 1 {
|
||||||
sum += simd_module.0[i] * simd_target.0[i];
|
sum += simd_module.0[i] * simd_target.0[i];
|
||||||
}
|
}
|
||||||
|
debug!("sum = {}", sum);
|
||||||
// 主! 体!
|
// 主! 体!
|
||||||
let mut tmp = f64x64::splat(0.0);
|
let mut tmp = f64x64::splat(0.0);
|
||||||
for i in 0..simd_module.1.len() {
|
for i in 0..simd_module.1.len() - 1 {
|
||||||
tmp += simd_module.1[i] * simd_target.1[i];
|
tmp += simd_module.1[i] * simd_target.1[i];
|
||||||
}
|
}
|
||||||
sum += tmp.reduce_sum();
|
sum += tmp.reduce_sum();
|
||||||
|
debug!("sum = {}", sum);
|
||||||
// 后面多出来的
|
// 后面多出来的
|
||||||
for i in 0..simd_module.2.len() {
|
for i in 0..simd_module.2.len() - 1 {
|
||||||
sum += simd_module.2[i] * simd_target.2[i];
|
sum += simd_module.2[i] * simd_target.2[i];
|
||||||
}
|
}
|
||||||
|
debug!("sum = {}", sum);
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "simd"))]
|
// #[cfg(not(feature = "simd"))]
|
||||||
|
#[cfg(feature = "simd")]
|
||||||
{
|
{
|
||||||
|
let mut st: [f64; 43] = [0.0; 43];
|
||||||
|
// 长度取 64, 方便simd填充
|
||||||
|
for i in 0..7 {
|
||||||
|
st[i] = name.name_prop[i] as f64;
|
||||||
|
}
|
||||||
|
for i in 0..16 {
|
||||||
|
if name.skl_freq[i] != 0 {
|
||||||
|
st[name.skl_id[i] as usize + 8] = name.skl_freq[i] as f64;
|
||||||
|
}
|
||||||
|
}
|
||||||
let mut cnt = 0;
|
let mut cnt = 0;
|
||||||
for i in 0..43 {
|
for i in 0..43 {
|
||||||
sum += st[i] * MODEL[cnt];
|
sum += st[i] * xuping13::MODULE[cnt];
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
|
}
|
||||||
|
for i in 0..43 {
|
||||||
for j in i..43 {
|
for j in i..43 {
|
||||||
sum += st[i] * st[j] * MODEL[cnt];
|
sum += st[i] * st[j] * xuping13::MODULE[cnt];
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ impl Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tracing_subscriber::fmt::init();
|
tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).init();
|
||||||
let mut cli_arg = Command::parse();
|
let mut cli_arg = Command::parse();
|
||||||
|
|
||||||
// 将数据量处理成可被 thread_count 整除
|
// 将数据量处理成可被 thread_count 整除
|
||||||
|
Loading…
Reference in New Issue
Block a user