Need to create a Rules Engine

curiouswebster
curiouswebster used Ask the Experts™
on
I need to perform a complex optimization which includes verifying at each small step that all rules have been complied with. Any ideas about how to code these rules?

The rules will not include string matches, instead involving tings like the maximum deliervy run size a given driver is allowed to be given. Or, the type of vehicle needed for pickups from a given store location.

So the rules will tend to be simple math tests, sometimes including the creation of score which reflects how compliant a delivery run is with all rules.

Any suggestion how to handle this?

I guess each rule could be an object, and the RulesList can be dynamically loaded to include certain rules, based on the values is a database, for example.

Any ideas come to mind how to deal with this? I could create an IRule interface to enforce the creation of required functions in all objects which implement that interface.

Any suggestions?

Thanks,
newbieweb

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Developer
Commented:
You might be interested in open source rule engines. They exist for different platforms. Have a look, e.g.:

http://csharp-source.net/open-source/rule-engines
Miguel OzSenior Software Engineer
Top Expert 2009
Commented:
For .NET 3.0 or later, you can use the Rules Engine of Windows Workflow Foundation without having to use Workflow.
http://blogs.microsoft.co.il/blogs/bursteg/archive/2007/08/09/WF-Rules-Engine-without-Workflow.aspx

A nice link about rule engines:
http://www.martinfowler.com/bliki/RulesEngine.html
curiouswebsterSoftware Engineer

Author

Commented:
I like the sound of using WWF rather than open source. Actualy I tried to install the open source one, but find a huge number of Java files.

I do plan on building a simple version of my rules engine, then add the use of an ORM to persist rules and allow them to be configured via a public facing website. Does WWF stil make sense considering this plan of mine?

Or do I need to control that a customer rules enginer would provide me.

Miguel OzSenior Software Engineer
Top Expert 2009
Commented:
Yes, your plan seems OK to me. It is easier to get tempted to imagine a big system. I will start small and have my rules, requirements and  unit test implemented first.
I will use a facade pattern to hide the complexity of my rule engine or if I need to change my rule engine. As long as your interface application - rule engine is well defined you can start simple and make it complex afterwards.
curiouswebsterSoftware Engineer

Author

Commented:
thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial