USAlgo.ClassBalance 1.0.4

dotnet add package USAlgo.ClassBalance --version 1.0.4                
NuGet\Install-Package USAlgo.ClassBalance -Version 1.0.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="USAlgo.ClassBalance" Version="1.0.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add USAlgo.ClassBalance --version 1.0.4                
#r "nuget: USAlgo.ClassBalance, 1.0.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install USAlgo.ClassBalance as a Cake Addin
#addin nuget:?package=USAlgo.ClassBalance&version=1.0.4

// Install USAlgo.ClassBalance as a Cake Tool
#tool nuget:?package=USAlgo.ClassBalance&version=1.0.4                

使用说明

获取SDK

获取最新Nuget包USAlgo.ClassBalance并安装。

install-package USAlgo.ClassBalance

代码集成

  1. 准备分班excel文件 样例excel文件请参考100_Data.xlsx
  2. 输入文件路径和分班设置数据
Fenban fenban = new Fenban();

// Excel文件本地路径
string filePath = @".\TestData\100_Data.xlsx"; 
// 分班设置 
CalcSetting calcSetting = new CalcSetting
{
    NumberClass = 4, //分班个数
    ColumnTypes = new ColumnTypeEnum[] { 
        ColumnTypeEnum.Ignore, //保留列:不参与计算
        ColumnTypeEnum.Name,  //名字列:字符串,不能为空
        ColumnTypeEnum.Gender, //性别列:字符串,取值男或女,不能为空
        ColumnTypeEnum.Score, ColumnTypeEnum.Score, ColumnTypeEnum.Score, //分数列:整数或浮点型(<=2位小数),不能为空
        ColumnTypeEnum.Preset, //预设班级列: 字符串,可为空, 值为数字(如1/2/3)会分到此班级, 值为字母(如a/b/c)且字母相同的会分到一个班级
        ColumnTypeEnum.Binding, //绑定列: 数字,相同数值代表必须在同一班级,可为空
        ColumnTypeEnum.Mutex, //互斥列: 数字,相同数值代表不能在同一班级,可为空
        ColumnTypeEnum.Balance, ColumnTypeEnum.Balance, ColumnTypeEnum.Balance // 均衡列:字符串,取值是,可为空
    },
    TopN = 10, //前n名均衡分配,0代表不启用
    LastN = 10, //后n名均衡分配,0代表不启用
    ScorePartition = 10, //分数分段统计均衡,适用于总分, 默认为10
    IsHomophonic = true, //是否开启同音同名分开, 默认开启
    FuzzyPinyin = new Dictionary<string, string>() //是否开启模糊音分开及模糊音定义
    {
        { "s", "sh"},
        { "c", "ch"},
        { "z", "zh"},
        { "f", "h"},
        { "l", "n"},
        { "r", "l"},
        { "an", "ang"},
        { "in", "ing"},
        { "uan", "uang"},
        { "en", "eng"},
        { "ian", "iang"}
    }
};
  1. 开始计算
// 基于数据量,计算时间1秒到120秒不等,请耐心等等
var output = fenban.Calc(filePath, calcSetting);

// 学生人数小于等于100时候,无需授权码。学生人数大于100时候,需要联系作者获取授权码并做为参数传入
//var output1 = fenban.Calc(filePath, calcSetting, user: "", authorizationCode: "");
  1. 输出分班结果并使用
Console.WriteLine($"描述信息: {output.CalcDescription}");
Console.WriteLine($"计算结果: {output.IsSuccessed}");
Console.WriteLine($"返回信息: {output.Message}");
Console.WriteLine($"计算用时: {output.CalcElapsedTime}秒");
Console.WriteLine($"详细结果: ");
// 输出结果包括统计数据、各班详细数据、预设班级分配数据、同音同名模糊音分配数据、平衡列分配数据、分数段分配数据
Console.WriteLine($"{JsonConvert.SerializeObject(output)}");
  1. 我们提供了样例代码,请参考样例代码

其他问题请联系

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.4 111 6/4/2024
1.0.3 116 5/21/2024