我正在尝试使用微软解算器基础,这样我就可以从一组位置中选择3个最分散的位置.我为我的模型添加了两个目标,一个确保选择3个位置,另一个确保它们是3个最分散的位置.
static void Main(string[] args)
{
Location candidate1 = new Location(0, 43.432, -79.432);
Location candidate2 = new Location(1, 43.0, -79.0);
Location candidate3 = new Location(2, 23.0, 29.0);
Location candidate4 = new Location(3, 43.0, -79.0);
Location candidate5 = new Location(4, 43.0, -79.0);
Location[] candidates = {candidate1, candidate2, candidate3, candidate4, candidate5};
SolverContext solver = new SolverContext();
Model model = solver.CreateModel();
model.Name = "LocationModel";
Set items = new Set(Domain.Any, "candidates");
Decision take = new Decision(Domain.Boolean, "candidate", items);
model.AddDecision(take);
Parameter locations = new Parameter(Domain.RealNonnegative, …Run Code Online (Sandbox Code Playgroud)