Approximation is sometimes only way to make something reasonable.
What is the problem:
When you are adding new transformation you need to describe for which plug-ins it should be applied.
Now simple approach is taken - choose the first one found. The problem is that it can return strange errors when you will add new pattern which also matches other plug-in.
We've been talking how to deal with that and most reasonable approach is to find most specific pattern that matches resource name. But as we need fast solution we decide use something that have chance to work better than simple "choose first" approach.
First take all matches and choose the best one of them. What choose the best means ? Choose most specialized pattern.
From my observation seems that patterns are rather simple and choose the "longest pattern" strategy should work in most cases.
So ? Choose the exact name or the longest pattern.
I am far from claiming that this solution is working in all cases. In fact there are thousand of examples it's not. But it gives you answer when you will find some unexpected result and want to check which pattern was applied.
A bit of this... a bit of that. About and around programmer's daily problems, solutions, and struggles.
Monday, May 26, 2008
Tuesday, May 6, 2008
Long May weekend
Since I disabled weather cast plug-in in Firefox whether is nice. So it was during the long weekend. As previously I tend to travel on these days I did similar thing this year. The difference is that previously it had been hiking and this time it was swan :)
Here you will find some photos.
Here you will find some photos.
Product Customization
Monday, May 5, 2008
Simple(x) Problem
Imagine you have following a problem. There are some people which needs access to some resources (lets make it students and beer problem). There are some dorms where students are located and shops which stores specific amount of this golden drink. As students are very lazy mammal they can access only this shops that are not very distanced.
We must provide each student with a bear. How to organize delivery?
This is typical resources allocation problem with constrains.
All students must be served. We can translate this problem and treat our students as resources. Let Xi be a number of bears per i'th dorm, Yj number of bears in j'th shop. Let also xij be number of bears for i'th dorm from j'th shop.
Then we can describe our problem as maximization problem of following function
The constrains are following:
For each j:
which means that we cannot give more bears than we have in j shop.
For each i:
which means that all students from i'th dorm must be served.
The only problem is that for some reason this cannot be solved using OpenOffice solver on my laptop (probably not ideal openSuse configuration ;) ). So please use something more comercial :D
Sometimes working at the university also means solving quite daily life problems ;)
We must provide each student with a bear. How to organize delivery?
How to deal with such a problem ?
Is there an optimal solution ?
This is typical resources allocation problem with constrains.
All students must be served. We can translate this problem and treat our students as resources. Let Xi be a number of bears per i'th dorm, Yj number of bears in j'th shop. Let also xij be number of bears for i'th dorm from j'th shop.
Then we can describe our problem as maximization problem of following function
SUM(xij)
- where we take into consideration only such a xij where j'th shop can be reached from i'th dorm.The constrains are following:
For each j:
SUMi(xij)
<= Yjwhich means that we cannot give more bears than we have in j shop.
For each i:
SUMj(xij)
= Xiwhich means that all students from i'th dorm must be served.
The only problem is that for some reason this cannot be solved using OpenOffice solver on my laptop (probably not ideal openSuse configuration ;) ). So please use something more comercial :D
Sometimes working at the university also means solving quite daily life problems ;)
Subscribe to:
Posts (Atom)