Efficiently blocking invalid solutions [closed] - optaplanner

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
What's the best way to block invalid solutions in Optaplanner? I know you can provide a negative hard score with HardSoftScore, but it might still take a long time exploring invalid solutions before arriving at a valid one.
For example, if you're seeing how many packages will fit in a truck, if the sum size of all packages exceeds the capacity of the truck, you don't want to explore any solutions in that space at all.

I think this runs counter to the way Optaplanner is expected to work, in which you have a lot of bad solutions and slowly converge towards a good solution. Veto'ing solutions doesn't give Optaplanner any information on why that solution was vetoed, and also it's possible that a better solution can only be found after traversing though a vetoable solution.
Instead, consider whether your score constraints are causing a score trap. Instead of using a fixed -1 hard score for a vetoable solution, have a score that's proportional to how bad that solution is.
In my example, this means instead of marking overcapacity solutions as hard -1, I should instead penalize them proportional to how over capacity they are, using the matchWeigher form of penalize.

Related

should I create a counter column? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
Optimization was never one of my expertise. I have users table. every user has many followers. So now I'm wondering if I should use a counter column in case that some user has a million followers. So instead of counting a whole table of relations, shouldn't I use a counter?
I'm working with SQL database.
Update 1
Right now I'm only writing the way I should build my site. I haven't write the code yet. I don't know if I'll have slow performance, that's why I'm asking you.
You should certainly not introduce a counter right away. The counter is redundant data and it will complicate everything. You will have to master the additional complexity and it'll slow down the development process.
Better start with a normalized model and see how it works. If you really run into performance problems, solve it then then.
Remember: premature optimization is the root of all evils.
It's generally a good practice to avoid duplication of data, such as summarizing one data point in another data's table.
It depends on what this is for. If this is for reporting, speed is usually not an issue and you can use a join.
If it has to do with the application and you're running into performance issues with join or computed column, you may want to consider summary table generated on a schedule.
If you're not seeing a performance issue, leave it alone.

Can early testing lead to premature optimization? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
One school of thought that I usually hear is to Test early, test often, may it be usability testing or any other kind.
Another statement, which is also generally believed to be true: Premature optimization is the root of all evil
That leaves me a bit confused. Should I test early? If I find and fix a problem, is that optimization? Also, is it premature? Should I just use early testing to identify the problems, and then fix them later on?
Please give some guidance regarding these statements.
How do I know if I'm optimizing prematurely?
Optimizing prematurely probably means that you should fix design and/or coding 'issues' at an early stage. If you wait with this, more code will be added and it will be more complicated (and at least time consuming) to improve those issues.
The result is that you - as positive side effects - reduce the number of bugs, not only by optimizing but also later.
You know when you are optimizing prematurely when you improve the structure (either code or design), without changing functionality. For this regression testing can be used:
Run tests, all should be ok
Improve code/design
Run tests, all should be ok
Of course this only works when you have very good regression tests.
If you mean performance optimmizing, this is completely different and I would advice not to do any performance optimizing unless you run into problems performance wise, or when you know beforehand performance might be an issue. And if the last case is true, it should be part of the design.

NSDictionary vs NsArray [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I was asked in an interview what structure I would use to store 100 names: an NSDictionary or NSArray and why.
What is the best answer?
He said he wants to figure out whether a name exists.
This is an open ended question, and the interviewer is probably more interested in your thought process and the questions you ask. The short answer IMO is NSArray if you just need to enumerate objects. NSDictionary if you need to lookup objects by a key. And NSSet when you just need to check membership. Of course this all varies depending on the amount of items, and how they are being used. With 100 items, it is probably 6 one, 1/2 dozen the other. And more a matter of readability and understandability in the code.
Read this old, but not outdated article for an excellent look at the performance considerations of each collection. http://www.cocoawithlove.com/2008/08/nsarray-or-nsset-nsdictionary-or.html
I think this has some good explanations of the two even though it's more focused on the performance aspect https://stackoverflow.com/a/10545362/1415348
It's really ends up being more open ended b/c it depends on what you might want to do with the data.
And now that it's edited with more info about how they want to use it I'd agree with Hot Licks, NSSet would be best for that. It has the method containsObject to determine existence in the set. NSSet Class Reference
The best answer is to ask more questions to clarify the requirements.
What kind of names?
What languages and locales?
How will they be used?
Will they change or be static?
Is there a storage or performance concern?
And so on.
In all likelihood the goal was to find out how you think about design.
Even if they didn't answer further questions they probably expected at least some reasoning provided for using various data structures where you illustrate how they can be used and why they make sense.
I seriously doubt they expected a one word response

Site I manage does not get good ranking in Google [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
A site I just started to manage is not banned in Google because I can find the domain in the index, but it gets extremely poor ranking -- almost nowhere to be found.
Does anyone know of a good method for determining how and/or why a site gets a poor ranking in Google. The site I have has been around for a while and is very rich with content relative to "youth sports". Yet you can hardly find it in the Google.
Sorry for asking this question here, but if you have ever posted anything to the Google Help and User forums you;ll find you get no responses or assistance. SO is the only place I can ever get exceptional and timely help.
There is no way to tell for sure as no one knows exactly how pages are ranked. However, we do have a pretty good idea of what many of the ranking factors are so we can be sure do them to help our chances of ranking well. This question at Pro Webmasters is a good start. So is this answer. Once you're sure you got the basics down you need to promote your website in the hopes of getting quality links to your pages. But if you don't have quality content (and what you call quality content may not be what Google and others call quantity content) you're not going to stand much of a chance of ranking well.
Did you use any dirty tricks like white text on white background to contain some false keywords etc.? Google continually discovers these tricks and penalizes them. Cheating doesn't pay off. I don't tell this is your case, but I just want to warn against it, in general.

Project's documentation when dealing with lots of business-logic rules. How to organize it? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I'm working on quite complicated project, in terms of business-logic quantity and quantity of components.
Each developer mostly works on "his own" component. I understand that this isn't very cross-functional, but it is impossible to know every components' details.
Team sostav changes from time to time. So we have situations when one person have to work on "other person's component". And this can be on periodic basement, so you can come back to the issue a month later - in that moments you can ask component business-logic's owner the same questions again and again, because you simply can forget some tiny but important details a month later.
This situation is annoying sometimes.
We have daily stand-up meetings, when person tells about what he has done and going to do.
We have project's wiki F.A.Q. page - we extract the most frequently asked questions.
What do you think about the problem?
And how would you recommend us to solve it?
given the component nature I'd go with:
1.) A framework document specifying the applications purpose, setup, requirements etc.
2.) Module documents for each component in a common format and indexed by name.
Look at the http://docs.python.org for a good example of general docs and http://docs.python.org/modindex.html for a good example of module/component docs
Oh, and daily meetings are generally bad, they take up a lot of time and answers get forgotten. Newcomers or sick people miss the meetings and have to be re-briefed. It's 100x better to write it all down and keep a paper/email trail unless discussion/feedback is required.