OptaPlanner - Get n best solutions with equal score - optaplanner

We have a use-case where we need to return the "top-N-best-solutions" for a problem using OptaPlanner. Unlike pareto we are going to compare scores of similar entities. Going through the OptaPlanner docs and other questions here I see that there have been multiple mentions of a "hack" involving BestSolutionRecaller to achieve this behavior in the cases where the "bestSolutionChanged" listener will not be triggered for solutions with equal best scores.
So since it is still not officially supported yet, in the meantime wanted to know if the "hack" is still doable or has that been closed as well ? Is there any other way (a better one) by which we can achieve this result until it is officially supported by OptaPlanner (as part of Pareto scoring or other feature) ?
P.S.: Not sure if the approach involving BestSolutionRecaller is still valid as it was earlier mentioned in the official docs under pareto score support but seems to have been removed lately.
The use case/expectation is exactly similar to this existing question -
Get best 3 scores in Optaplanner?

As far as I know, the question and answer you point to is still the status quo.

Related

SCIP: Find a feasible but not optimal solution to a large LP

I asked this on the soplex mailing list, but no answer yet:
http://listserv.zib.de/pipermail/soplex/2022-August/000001.html
I tried scip, and it took 30sec. Maybe because it performs pre-solve.
Is there an easy way to achieve my objective:
Specify an initial solution (something that I have, which is better than a random init), and use the solver for a limited time to find a better feasible solution
https://math.stackexchange.com/questions/4510587/find-a-feasible-but-not-optimal-solution-to-a-large-lp
Reply from the mailing list:
http://listserv.zib.de/pipermail/soplex/2022-August/000002.html
To find only a feasible solution, you can just remove the objective function. This will terminate as soon as feasibility is attained. Then, you could plug in this solution as a starting basis - I don't think this is going to help much, though.

Difference between tf.nn.batch_normalization and tf.nn.batch_norm_with_global_normalization

I am trying to implement batch normalization using tensorflow and found this nice post. Both functions seem to take similar parameters yet it seems like people use the latter more.
Can they be used interchangeably? If not, what are the differences? (And why are there so many similar APIs in tensorflow? Another example would be tf.nn.softmax_cross_entropy_with_logits and tf.losses.softmax_cross_entropy. I tried both and they seem to work fine but I feel like maybe I'm missing something subtle here that can drastically change my train results.
I guess tf.nn.batch_normalization is better ,
tf.nn.batch_norm_with_global_normalization method is old version and will deprecate later
i think you'll find a better answer here

How can I decide when to use linear programming?

When I look at optimization problems I see a lot of options. One is linear programming. I understand in abstract terms how LP works, but I find it difficult to see whether a particular problem is suitable for LP or not. Are there any heuristics that can help guide this decision?
For example, the work described in Is there a good way to do this type of mining? took weeks before I saw how to structure the problem correctly. Is it possible to know "in advance" that problem could be solved by LP, without first seeing "how to phrase it"?
Is there a checklist I can use to decide whether a problem is suitable for LP? Is there a standard (readable) reference for this topic?
Heuristics (and/or checklists) to decide if the problem at hand is really a Linear Program.
Here's my attempt at answering, and I have also tried to outline how I'd approach this problem.
Questions that indicate that a given problem is suitable to be formulated as an LP/IP:
Are there decisions that need to be taken regularly, at different time intervals?
Are there a number of resources (workers, machines, vehicles) that need to be assigned tasks? (hours, jobs, destinations)
Is this a routing problem, where different "points" have to be visited?
Is this a location or a "layout" problem? (Whole class of Stock-cutting problems fall into this group)
Answering yes to these questions means that an LP formulation might work.
Commonly encountered LP's include: Resource allocation.: (Assignment, Transportation, Trans-shipment, knapsack) ,Portfolio Allocation, Job Scheduling, and network flow problems.
Here's a good list of LP Applications for anyone new to LPs or IPs.
That said, there are literally 1000s of different types of problems that can be formulated as LP/IP. The people I've worked with (researchers, colleagues) develop an intuition. They are good at recognizing that a problem is a certain type of an Integer Program, even if they don't remember the details, which they can then look up.
Why this question is tricky to answer:
There are many reasons why it is not always straightforward to know if an LP formulation will cut it.
There is a lot of "art" (subjectivity) in the approach to modeling/formulation.
Experience helps a lot. People get good at recognizing that this problem can be "likened" to another known formulation
Even if a problem is not a straight LP, there are many clever master-slave techniques (sub-problems), or nesting techniques that make the overall formulation work.
What looks like multiple objectives can be combined into one objective function, with an appropriate set of weights attached.
Experienced modelers employ decomposition and constraint-relaxation techniques and later compensate for it.
How to Proceed to get the basic formulation done?
The following has always steered me in the right direction. I typically start by listing the Decision Variables, Constraints, and the Objective Function. I then usually iterate among these three to make sure that everything "fits."
So, if you have a problem at hand, ask yourself:
What are the Decision Variables (DV)? I find that this is always a good place to start the process of formulation. How many types of DV's are there? (Which resource gets which task, and when should it start?)
What are the Constraints?
Some constraints are very readily visible. Others take a little bit of teasing out. The constraints have to be written in terms of your decision variables, and any constants/limits that are imposed.
What is the Objective Function?
What are the quantities that need to be maximized or minimized? Note: Sometimes, it is not clear what the objective function is. That is okay, because it could well be a constraint-satisfaction problem.
A couple of quick Sanity Checks once you think your LP formulation is done:
I always try to see if a trivial solution (all 0s or all big
numbers) is not part of the solution set. If yes, then the
formulation is most probably not correct. Some constraint is
missing.
Make sure that each and every constraint is "related"' to
the Decision Variables. (I occasionally find constraints that are
just "hanging out there." This means that a "bookkeeping constraint"
has been missed.)
In my experience, people who keep at it almost always develop the needed intuition. Hope this helps.

OOD / OOP Etudes / Code exercises

I've been searching the web for some time now. I am looking for small sample exercises for OOD practice (& for some internal TDD workshops).
If there is one single place, where this need is being served, please point me to it.. and close this question
Constraints:
Language-agnostic real world problem
Small : Something that takes an hour to two at max to solve (or has sub-parts that can fit this constraint).
Not Algorithm centred : Not be focussed on just solving a computational task. (There are multiple sites that serve this category.) Involve > 2 interacting entities.
Solved by multiple people, preferably yourself : Goodness verified. Links preferred. Please do not post something that may be a good exercise... subjective
Similar SO question 60109, but the answers dont meet my need here. I found that I've lost my touch (was thrashing ideas) with OOD after prolonged exposure to a day-job. Need to get it back..
Update: Are we collectively out of short OOP exercises ? I was hoping that I'd have a bunch to pick from. However my web-searches (this is a diff exercise in formulating the right search string) and the lack of responses here seem to indicate otherwise. Maybe I posted to SO at a bad time.. in which case bumping this thread for more responses.
http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata
http://schuchert.wikispaces.com/Monopoly%28r%29
Jeff Bay's Object Calisthenics. Following these will improve your OO skills.
Bill Wake's spreadsheet TDD challenge
Dave Thomas' CodeKata
Kindness,
Dan
From the AGPPnP book by Robert Martin aka UncleBob
CoffeeMaker Mark IV - Page 2 has the problem statement
Questionnaire Practice Problem
A problem I've worked on in a couple of different jobs is that of writing some generic, data-driven survey/questionnaire functionality. It's not majorly complex, but has enough interesting avenues to be a good OOD practice problem I think. It's definitely real-world and crops up in a lot of places.
You can start off thinking about how to structure a Survey. It is obviously made up of Questions, but do you also want Categories? Can a Question have subquestions? Can a subquestion have subquestions? How deep can you go?
A question probably needs to have potential Scores. What types of scores can you have? What types of questions can you have (multiple choice, multiple answer, freetext, etc.)?
Once you've got the basic business logic, you can also think about how you display a survey . Maybe you have a SurveyRenderer and a QuestionRenderer? How do you decide how to render different types of questions? (Maybe you use a Strategy pattern... as in this SO question.) How do you render a read-only version of the survey?
You can also think about persistence. How do you record responses to a blank questionnaire? How does your object graph of a survey get mapped into a database (or some other backing store), and vice versa?

Anybody using .netTiers?

I'm considering adopting .nettiers for a new project as it seems to provide a lot of functionality I could use.
Is anybody using it in anger (I'm getting the feeling it hasn't got the following it once had) and if so, what are your perceptions of it?
Also, I can't find any comparative performance metrics against things like SubSonic. Anybody have any strong feelings about its performance and scalability?
Many thanks
Tony
When I used NetTiers, I was very happy with it to an extent. You really need to learn the best ways to use it. There were definitely some weird bugs, things that had arbitrary limits and so forth. You have to be careful with it but it can definitely improve your productivity if you learn. I know CodeSmith has started putting more resoucres in it. The version 2.3 might be very solid. Although, the latest current stable version may be pretty solid, I haven't used it in awhile.
Honestly, at this point I prefer LLBLGen. I did try SubSonic a couple times. I didn't run into major bugs but I ended up switching, in both cases, to NetTiers. With SubSonic I felt that I was just typing out way too many string literals and it just didn't feel as mature as other alternatives.
Look at this. It provides you with a good X vs Y comparison between the two of them.
A Key point that i always revise when selecting a framework to work with is:
Will this Simplify, Make me more Productive, if you answer "Yes of course" to this, it doesnt matter what other benchmarks say, even if it's 10% slower in running than SubSonic or even faster, you should go with the framework you develop the fastest and most that you are the most comfy in.
I had some time this afternoon to run a head to head comparison between netTiers and SubSonic.
I used code generated using SubStage (part of the SubSonic 2.1 release) and I used RepositoryRecord as my base class.
I ran the same test against the same database using code generated by .netTiers 2.2
The test was a derivative of the one that Rob Conery used in his post:
http://blog.wekeroad.com/blog/subsonic-scaling/
When i say derivative, I mean I just wrote 100,000 records into the database.
I repeated each test on the same PC three times.
I found that .netTiers accomplished the task in 90 seconds.
Subsonic completed it in 104 seconds.
There was no more than a one second deviation from these averages.
Look at this. It provides you with a
good X vs Y comparison between the two
of them
Thanks - I've already read this post before, but it's over two years old and both projects have advanced a great deal since then.
Asking whether or not a framework will make me more productive or not is a very important consideration, but it's not the only one.
Another for me has to be "am I going to lose potential productivity gains because the framework I adopt is full of bugs, nasty to use, or just a PIA?" which is why I asked if people are using it in anger and what their experience is.
If .nettiers is 10% slower than subsonic, but gives me a whole bunch more features (such as better validation, business rule enforcement etc) then I can live with that. If its ten times slower, then I'd not consider it.
Many thanks
Tony