根据排列C#进行决策 [英] Decision making depending on permutations C#

查看:87
本文介绍了根据排列C#进行决策的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我有一个形式,其中有很多组合框,我希望对它们的值的每个不同的组合进行决策".我尝试使用决策树,但无法实现.如果没有很多其他",我该如何做这个决策过程,这太疯狂了.

问候,

Dear all,

I have a form in which there are many comboboxes, I have like for each different set of permutations of their values a "decision" is to be made. I tried to use a decision tree but couldn''t implement it. How can I do this decision making process without many "if else", it would be crazy.

Regards,

推荐答案

它可能对您有帮助,

C#中的策略方法或Switch语句 [ ^ ]

希望对您有所帮助:)
It might help you,

Strategy method or Switch statement in C#[^]

Hope it helps :)


是的,决策树不会对您有太大帮助.您不应该一直使用众所周知的结构,有时您需要使用自己的大脑. :-)

这根本不是排列,但我可以理解.这只是所有不同选项的组合.

您应该创建一个选项空间.空间的尺寸应为多个控件.让我们假设(也许有些简化)所有选项都由复选框,单选框组以及列表或组合Boxistes表示.每组单选框,每个单独的列表或组合框以及每个单独的复选框将代表一个特殊的尺寸.将它们全部计数(单选框组将其计为一个),以获取空间的总尺寸.在每个维度中,您都有最终的点数:每个复选框2个点,根据其他每种情况下选择项的数量,有几个点.假设您有N维空间.

好的,现在将其简单地表示为等级N和每个方向上适当数量的点(选项)的数组
ArrayType [,,,,],其中逗号的数量等于N−1.选项组合的总数将是每个维度中选项数目的乘积.

现在,问题是:什么数组? ArrayType是什么类型?我的回答是:这将是一个代理实例数组.您可以创建多个具有相同签名的方法(取决于应用程序,但一个参数应为多维点,即多维数组中的位置).您可以创建几种方法.您将创建委托实例,并将相同的实例放入某些数组元素中,将其他实例放入其他实例中,具体取决于选项的工作方式.该点(多维索引)将一次描述所有选项.

请在我的CodeProject文章中看到与我有些相似的想法:
动态方法调度器 [枚举类型不枚举!解决.NET和语言限制 [ ^ ].

—SA
Yes, decision tree won''t help you much. You should not use well-known structures all the time, sometimes you need to use your own brain. :-)

This is not permutations at all, but I can get the idea. This is just the combination of all different options.

You should create an options space. The dimension of the space should be a number of control. Let''s assume, perhaps with some simplification, that all options are represented by check boxes, groups of radio boxes, and list or combo boxistes. Each group of radio boxes, each individual list or combo box and each individual check box will represent a special dimensions. Count them all (a radio box group counts as one) to get the total dimension of the space. In each dimension, you have final number of points: two for each check box, and several points depending on the number of choice items in each of the other cases. Let''s say, you have N-dimensional space.

OK, now represent it simply as an array of the rank N and appropriate number of points (options) in each direction
ArrayType [,,,,] where number of commas is equal to N−1. Total number of option combinations will be a product of numbers of options in each dimensions.

Now, the question is: the array of what? What would be the type ArrayType? My answer is: it will be an array of delegate instances. You can create several method with the same signature (depending on application, but one parameter should be a multi-dimensional point, that is, a position in your multi-dimensional array). You can create several methods; you will create delegate instances and put identical instances in some array elements, different instances in others, depending on how options work. The point (multi-dimensional index) will describe all options at once.

Please see my somewhat similar idea in my CodeProject article:
Dynamic Method Dispatcher[^].

For another related construct, please see my design of a finite-state machine in another article, pay attention for the referenced chapter (3.6 Cartesian Square):
Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^].

—SA


这篇关于根据排列C#进行决策的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆