Menu assignment : Minimise dishes for a day - optaplanner

I am solving a menu assignment problem using optaplanner.
I have many "slots" in a day and each slot gets assigned a "product". Each product contains a few "dishes". Some products share common dishes.
Now, each distinct dish requires preparation time which I want to minimise. How can I write a constraint to minimise the number of dishes used in a day?


Tax Engine Examples

We create point of sale software for the mac, and are looking to revamp our tax engine. It's pretty simple now, with taxes consisting of a name, code and rate that can be applied to every product individually. While this is good enough for some people, we've had lots of requests to handle more advanced situations. Some examples are US City/County sales tax, Canadian compound (stacked) taxes, French ecotax and NYC luxury tax.
We've identified most of the characteristics that these taxes have and are leaning towards a sort of rule-engine based implementation. We don't have to support every case out there, but we want to be able to extend it if needed (to avoid another rewrite).
We're looking for advise from people who built something like this before, or examples of projects that try to solve the same in an elegant way.
I would recommend a set of database tables and joins.
Jurisdiction: list of states, counties, countries, cities, etc.
Product: obvious
Store: list of locations you sell from
StoreJurisdiction(StoreID, JurisdictionID): the list of Jurisdictions the store is
responsible to collect taxes for
ProductTaxCode(ProductID int, TaxCodeID int): the type of product for the purposes of taxes: basic, luxury, etc.
JurisdictionTaxCodeRate(JurisdictionID, TaxCodeID, InterestRate, RateType): for each applicable combination of Jurisdiction and Tax Code, provide the tax rate to be applied, and the type of rate (compound, simple, etc.).
To find the list of taxes to apply, all you need is an INNER JOIN of the store, its jurisdictions, the jurisdictiontaxcoderates for those Jurisdictions, and the product's tax codes.
You could define ProductTaxCode as a View so all products receive a default TaxCode unless a special one is provided. By abstracting TaxCode, you can have the same metadata about a product ("Food" for instance) apply to different regions in different ways. If a particular jurisdiction has its own definition of "food", you just add a jurisdiction-specific code and apply it to products as needed.
This may require some tweaking for Internet purchases, wholesale purchases, and other situations where the sale is somehow exempt from taxes or the customer is responsible for remitting them. It would also need tweaking for situations where the customer's location, rather than the store, decides the tax rate.
Other tweaks: here in Texas, for instance, we have a "tax-free" weekend where state and local taxes are not collected on some classes of products where the individual item's sale price is less than $100. The idea is to provide cheaper school supplies, clothing, etc. for children heading off to school for a new year. This sort of tweak could be implemented by having a date range table for each JurisdictionTaxCodeRate going off in the future as far as they can be planned.
My suggestion would be to use database tables for what they are good for (storing values) and rules for what they are good for (business logic). I would certainly not put things like tax rates or lists of jurisdictions in rules - those should be in tables. What I would use a rules engine for is defining the logic that determines which rate to apply to which transactions. So, for instance, if I buy a set of products online from a company based in State X that ships from State Y to three different locations, what tax rates apply to which parts of the transaction?
This combination of rules and database tables is very common - the rules make sure you look up the right things while the tables aid in reporting etc. For instance, the California DMV did this with vehicle registration fees - all the various fees are stored in a database while the rules that determine which fee applies to which car are managed in a rulebase.
If you try and put everything in rules you will not be able to report well and if you try and put everything in database tables you will end up with dozens of tables to manage all the exceptions and corner cases.
Here is an example of a "home rule" city in the Denver, CO metropolitan area:
You, as a retailer, may also need to send the tax payments to different locations. For cities that are not "home rule" cities (which is a special term that probably only applies to Colorado, but then probably every state has some equally special term like it), you'll send all the tax payments to the state who will then deal them out to the relevant parties. Colorado has a feature where there are "special tax districts" that are permitted to collect sales taxes for certain benefits (on the example link, RTD is the public transportation district, and "Invesco Field" is the stadium where the Denver Broncos play).
To expand upon Mr Tallent's answer on this thread, you'll need to also include in the Jurisdiction table some way of representing that the taxes may go to different places.

Odoo production lot grading and displaying of onhand and reserved qtys

We are a used electronics wholesaler and have the following situation and would like to know the best way for Odoo to handle it:
A used electronic is taken in, at that time the grade and condition are unknown. The these two characteristics as well as others will be set through testing and grading operations. I would like to avoid each item going through several manufacturing processes to achieve the final product attributes, as the number of sku's our company handles is high, and setting up manufacturing rules for each movement is hard if not impossible.
My initial thought was to add the info to the production lots along with a unique serial number to identify each. The trouble I am running into with that approach is, while each item becomes unique through testing and serialization, our customers buy items based on general characteristics. So our sales staff needs to know what items are Onhand and what is reserved within a section criteria. So I need a way to quickly display that we have
30 Garmin vivoactive 3's in stock
10 untested
10 grade A and fully functional units
5 Grade B Functional units
5 Grade A Nonfunctional units
So that when a customer customer wants 6 fully functional, we are going to send him the Grade B's first, and complete the order with the A's
We need to allocate the inventory in a generic sense not down to the specific items. The intent of allocation is not to assign a specific item to a pick but to stop us from overselling items, we don't always pick items immediately, and want to make sure we have the items available for fulfillment.
We will invoice and track individual items once they are pulled, but our pickers will just go grab the first 6 phones that met the criteria. 5 Bs and 1 A. They will then scan those items to the pick.
I am hoping for a straight forward Odoo approach to this situation and want to avoid using product variants if possible. Any suggestions?
I can suggest you use categories. You can add the products one by one independently of the "state", and then assign them to some category. Each category will represent a state. After that, you only need to know how many products by category you have. (Maybe you have to do that small module). I hope will be some useful.

Time schedule algorithm [closed]

I have been trying for some time solve a scheduling problem for an App that I used to work at. This problem is as follows...
First time the list gets populated:
will look at all contacts that a user has made “Active” in the Contacts list.
For each, it should look at their selected contact frequency (e.g. x days, x weeks, x months.)
will compare their “last contact date” with today’s date. For any contact where the difference between these dates is greater than their assigned contact frequency, the person is a candidate to be added to the Agent list.
The order of how people will appear on the Agent list should adhere to the following rules:
Contacts with longest gap between last contact are higher on the list
Contacts marked as Favorite go to the top of the list
isApp users take priority
From this list of “candidates”, the algorithm should then also review contact history for each. For contacts with the following assigned contact frequency, follow these rules
Every x Days – Do not take history into account. Just add when they’re past due
Every x Weeks – if contact already within the last 3 days, do not show, and skip to the next time they will be up for contacting.
Every x Months – if contact already within the last 7 days, do not show, and skip to the next time they will be up for contacting.
Every x Year – if contacted in the last month, do not show, and skip to the next time they will be up for contacting.
Create a data set array that includes all the contacts. Add filters for the contacts for example "active". Set a period for contacts to differentiate according to gaps. Create a default category and add all the contact in it so then you can iterate to skip contacts from last 7 days or so. Once you have a default array you can always create another list with desired features. In this case the same list will be processed with four conditions such as required in last 4 your lines. This solution is generic for any platform. Once you have the code then you can apply pre-build algorithms. You can use to refine your logic. Hope this helps. If not then paste your code.

Sequential and Causal Consistency

For a unique item sales database, if we use sequential consistency, we can guarantee that for example that unique item never gets double sold to different people. Does causal consistency guarantee us that?
If there are some sales which started/ended at the same time does the disrupt the system?
Since the items are unique, we can only sell one of each item.
thank you
Causual consistency guarantees you that if two events are causually related, that everyone will agree on the order that they occurred. It allows disagreement about the ordering of events which are not causually related (or "simultaneous").
Two attempts to purchase an item that are performed by different nodes in the system are probably not going to be causually related - buyer B almost certainly does not try to buy the item because he has seen that buyer A has already bought it. In a causually-consistent system, this means the two events are simultaneous, and different nodes in the system may disagree about their relative ordering - A may believe that her purchase attempt came first and succeeded, and B may believe the same thing.
You can force the two purchase attempts to be causually related with a bit of extra eventual-ness. Instead of having buyers directly purchase the item, have them write a record indicating their desire to purchase the item. Designate a single node to be "owner" of the item. Whenever it sees a desire-to-purchase record, it reads the item's current state and - if it's available - sells it to the given purchaser. Purchasers watch the item to see if it was sold to them or to someone else.
This establishes an ordering between the two events: either the owner sees A's record first and sells it to her, or sees B's record first and sells it to him. The two events aren't causually related so other nodes may see the records in the opposite order, but that's fine - their opinions don't count, only the owner's does. The owner's second read (which should see that item has already been sold) is causually related to its earlier write that marked the item sold since they're executed on the same node, so we're guaranteed that it'll only sell the item once.

How do I model a fact with start/end dates to relate to a daily measure?

So I have a Sales Cube with Sales By Item By Day.
I want to bring in Bookings/Orders and compare those to the sales to see if we are booking the right numbers.
The bookings fact is a single record with an OnDate, OffDate, Quantity, Item.
I want to be able to select a given week, show sales for that week and any bookings that were in effect for that week.
My current configuration is to have a many-to-many relationship with the Date dimension. I created a view that takes my bookings and generates a record for every day between on and off. As you can imagine, this is a large table, and will get larger in production.
With this I still have to set my SaleDate, OnDate, and OffDate filters explicitly which gets cumbersome when browsing the cube.
Is there a better way to be handling this?
Here is an shot of my DSV to help see what I have set up.