且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动力学方程问题

更新时间:1970-01-01 07:59:24

似乎您有2个选择开始逻辑流程.

1.)使用某种枚举类型,并允许用户通过CombBox单选按钮进行选择,然后单击按钮.询问您的用户他们想要什么.根据选择,您可以设置枚举供以后使用

Seems you have 2 options to start your logic flow.

1.) Use some enum type and allow the user to select via CombBox radio button, button click. Ask your users what they want. Depending on the selection you set the enum for later use

public enum CalculationType : int
{
    LargeDeposit = 1,
    SmallDeposit = 2
}


注意:我被设为int类型的枚举.这将使您能够将类型转移到后端并从中注销. (SQL不在乎对象类型,仅在乎具体数据).


2.)使用对象类型和接口.


Note: I am made the enum of int type. This will alow you to transfer the type to the backend and key off of it. (SQL does not care about object types, only concrete data).


2.) Use object types and interfaces.

public interface IAccount
{
   IResult Calculate();
}

public class LargeDepositAccount : IAccount
{
   public IResult Calculate()
   {
        //Access the appropriate back end data and calaulate
        // or access the apprpriate SPROC and return the calculation
   }
}

public class SmallDepositAccount : IAccount
{
    public IResult Calculate()
   {
        //Access the appropriate back end data and calaulate
        // or access the apprpriate SPROC and return the calculation
   }

}



如果您的客户需要定期更改实际公式,则需要与他们一起探讨他们如何建立论坛.我看到过围绕将配置文件解析为公式而构建的库,或者您对某些注释的建议是允许它们将其存储在Excel中.
您确实必须与该客户一起工作.他们想如何更新公式以及他们对系统的了解程度如何.

这是一篇包含方程式解析器的文章
带有图形的方程式计算器 [用于从Excel快速通过/检索数据的组件 [ MEF [ 这实际上取决于您的客户对他们如何与系统交互的期望.

祝您好运:)



If your client needs to change the actual formulas regularily you will need to work with them on how they want to build the forumula. I have seen libraries built around parsing config files into formulas or as some comments to you have suggested allow them to store it in Excel.
You really have to work with the client on that one. How to they want to update the formulas and what level of the system understanding do they have.

Here is an article that has an equation parser included
Equation Calculator with Graphing[^]

Here is an article on talking to excel
Component for Fast Pass/Retrieve Data from Excel[^]

Note: I am sure there are many other articles on doing the same (maybe even better). I just did a quick CP search and thats what came up. Again, you really need to ask your client how they want to input the formulas. If they are hoping you come up with a suggestion they give them a few options and ask them which they would prefer.

On the other hand, if your client is adding formulas then you could use injection. Take a look at MEF[^] and follow option 2. This will allow your client to build new "AccountTypes" and inject them into your system with out touching any base code.
It really depends on your clients expection of how they interact with the system.

Good luck:)


您需要做的第一件事就是使问题形式化.

我的意思是理解一般情况并使用一些严谨的语言来描述它;可以是英语,并且可以毫无歧义地使用,可以是数学公式,可以是一组可供选择的允许概括的示例.

您当前的问题陈述无法被利用.

根据您的发言,我可以猜测您保持了帐户余额并考虑了变动.这些可以是一次性的,也可以是定期的.在这种情况下,可以通过提供变动的日期,金额和期间(即数字列表)来描述帐户的整个历史记录.

月0,-1000000,一次
第1个月,+ 100000,一次
第2个月,+ 50000,每月18次

转换为三个记录:
The first thing you need to do is to formalize the problem.

I mean understand the general case and describe it using some rigourous language; can be English used in a non-ambiguous way, can be mathematical formulas, can be a well chosen set of examples that allow generalization.

You current problem statement cannot be exploited.

From what you say, I can guess that you maintain an account balance, and consider movements. These can be one-time or periodic. If this is the case, the whole history of an account could be described by providing the dates, amounts and periods of the movements, i.e. a list of numbers.

Month 0, - 1000000, once
Month 1, + 100000, once
Month 2, + 50000, 18 times, monthly

Translates to three records:
0, -1000000,  1, 0<br />
1,  +100000,  1, 0<br />
2,   +50000, 18, 1