defining linear equations in Java - java

I am trying to implement a paper and I am facing problem while representing linear equations mentioned in the paper. I am using LPsolve (linear problem solver) to solve the equations. But not able to represent some equations in Java so that LPSOLVE can resolve. Anyone with expertise in this please do help me.
paper i am trying to implement is http://www.cs.cmu.edu/~dshahaf/kdd2010-shahaf-guestrin.pdf and equations are mentioned in section 2.2.1

Based on what I can tell, you seem to have trouble figuring out o implementing some functions that would represent how certain mathematical functions work. It doesn't sound like you've run into an error, so I'll write down a few tips I can think of.
First off, check if the functions you are looking for already exist in the basic library by taking a look in the documentation. Maybe it doesn't state it exactly like you want, but perhaps some of the functionality is there.
http://lpsolve.sourceforge.net/5.5/Java/docs/api/
If you can't find everything you want, then you've got two options. One is to program the functions you desire yourself, and the other is to use another fleshed out Java library such as Colt which has many features.
http://dst.lbl.gov/ACSSoftware/colt/

Related

Scanning texts for specific words

I want to create an algorithm that searches job descriptions for given words (like Java, Angular, Docker, etc). My algorithm works, but it is rather naive. For example, it cannot detect the word Java if it is contained in another word (such as JavaEE). When I check for substrings, I have the problem that, for example, Java is recognized in the word JavaScript, which I want to avoid. I could of course make an explicit case distinction here, but I'm more looking for a general solution.
Are there any particular techniques or approaches that try to solve this problem?
Unfortunately, I don't have the amount of data necessary for data-driven approaches like machine learning.
Train a simple word2vec language model with your whole job description text data. Then use your own logic to find the keywords. When you find a match, if it's not an exact match use your similar words list.
For example you're searching for Java but find also javascript, use your word vectors to find if there is any similarity between them (in another words, if they ever been used in a similar context). Java and JavaEE probably already used in a same sentence before but java and javascript or Angular and Angularentwicklung been not.
It may seems a bit like over-engineering, but its not :).
I spent some time researching my problem, and I found that identifying certain words, even if they don't match 1:1, is not a trivial problem. You could solve the problem by listing synonyms for the words you are looking for, or you could build a rule-based named entity recognition service. But that is both error-prone and maintenance-intensive.
Probably the best way to solve my problem is to build a named entity recognition service using machine learning. I am currently watching a video series that looks very promising for the given problem. --> https://www.youtube.com/playlist?list=PL2VXyKi-KpYs1bSnT8bfMFyGS-wMcjesM
I will comment on this answer when I am done with my work to give feedback to those who are facing the same problem.

Discrete Wavelet Transform (DWT) and Stationary Wavelet Transform (SWT) in Java

I want to apply DWT and SWT to images in Java but can't find code, pseudocode or libraries for that. Until now, I only found existing code in other languages like C, C++ or Python but I need it in Java and I'm not able to change the code from one to another language on my own.
Does anyone know a library or another way I could use to solve this problem?
Thanks in advance!
Detailed description of the problem:
I want to apply DWT or SWT to an image and then do some further calculations with specific DWT/SWT subbands e.g. applying Discrete Cosine Function (DCT) to the LL-subband. If possible, I want to work with BufferedImages.

Parsing and Solving a Formula in Java SE 8

Disclaimer: Not Homework
I've written very basic calculator parsers in Java using tokenizers, but I have recently started writing a problem to help me understand chemistry. As I began writing more and more formulas, it became increasingly apparent that the complexity required to solve for each equation is almost more tedious than mastery of the equations themselves. Take the equation PV = nRT, how could I write a parser that would allow me to input all know variables and solve if it was solvable? I can do the logic behind solvability, but here are a few requirements:
must be able to solve for any unknown variable.
parsing should be capable for formulas of any size (ex: I want to implement more than one formula, such as π = MRT and formulas of increasing complexity, and only want to have to define them once.)
Once again this is purely for my enjoyment and to be used as a learning tool. Any help would be appreciated, as searching Google and StackOverflow for this problem have given me either vague or inapplicable answers.
As you have posted no code I will speak my thoughts.
I used to have an hp48G calculator which had a library with many formulas covering different areas.
Instead of parsing a single line, you had to choose through menus which was the formula to apply, then the calculator would ask for each parameter separately, and apply it to the formula to provide the result.
If you follow this approach, and helped with java's interfaces I think you can do something like you are asking.

Is there any software for testing sequences for non-randomness in Java?

I looking for a program or library in Java capable of finding non-random properties of a byte sequence. Something when given a huge file, runs some statistical tests and reports if the data show any regularities.
I know three such programs, but not in Java. I tried all of them, but they don't really seem to work for me (which is quite surprising as one of them is by NIST). The oldest of them, diehard, works fine, but it's a bit hard to use.
As some of the commenters have stated, this is really an expert mathematics problem. The simplest explanation I could find for you is:
Run Tests for Non-randomness
Autocorrelation
It's interesting, but as it uses 'heads or tails' to simplify its example, you'll find you need to go much deeper to apply the same theory to encryption / cryptography etc - but it's a good start.
Another approach would be using Fuzzy logic. You can extract fuzzy associative rules from sets of data. Those rules are basically implications in the form:
if A then B, interpreted for example "if 01101 (is present) then 1111 (will follow)"
Googling "fuzzy data mining"/"extracting fuzzy associative rules" should yield you more than enough results.
Your problem domain is quite huge, actually, since this is what data/text mining is all about. That, and statistical & combinatorial analysis, just to name a few.
About a program that does that - take a look at this.
Not so much an answer to your question but to your comment that "any observable pattern is bad". Which got me thinking that randomness wasn't the problem but rather observable patterns, and to tackle this problem surely you need observers. So, in short, just set up a website and crowdsource it.
Some examples of this technique applied to colour naming: http://blog.xkcd.com/2010/05/03/color-survey-results/ and http://www.hpl.hp.com/personal/Nathan_Moroney/color-name-hpl.html

Easiest to code algorithm for Rubik's cube?

What would be a relatively easy algorithm to code in Java for solving a Rubik's cube. Efficiency is also important but a secondary consideration.
Perform random operations until you get the right solution. The easiest algorithm and the least efficient.
The simplest non-trivial algorithm I've found is this one:
http://www.chessandpoker.com/rubiks-cube-solution.html
It doesn't look too hard to code up. The link mentioned in Yannick M.'s answer looks good too, but the solution of 'the cross' step looks like it might be a little more complex to me.
There are a number of open source solver implementations which you might like to take a look at. Here's a Python implementation. This Java applet also includes a solver, and the source code is available. There's also a Javascript solver, also with downloadable source code.
Anthony Gatlin's answer makes an excellent point about the well-suitedness of Prolog for this task. Here's a detailed article about how to write your own Prolog solver. The heuristics it uses are particularly interesting.
Might want to check out: http://peter.stillhq.com/jasmine/rubikscubesolution.html
Has a graphical representation of an algorithm to solve a 3x3x3 Rubik's cube
I understand your question is related to Java, but on a practical note, languages like Prolog are much better suited problems like solving a Rubik's cube. I assume this is probably for a class though and you may have no leeway as to the choice of tool.
You can do it by doing BFS(Breadth-First-Search). I think the implementation is not that hard( It is one of the simplest algorithm under the category of the graph). By doing it with the data structure called queue, what you will really work on is to build a BFS tree and to find a so called shortest path from the given condition to the desire condition. The drawback of this algorithm is that it is not efficient enough( Without any modification, even to solver a 2x2x2 cubic the amount time needed is ~5 minutes). But you can always find some tricks to boost the speed.
To be honest, it is one of the homework of the course called "Introduction of Algorithm" from MIT. Here is the homework's link: http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-006-introduction-to-algorithms-fall-2011/assignments/MIT6_006F11_ps6.pdf. They have a few libraries to help you to visualize it and to help you avoid unnecessary effort.
For your reference, you can certainly look at this java implementation. -->
Uses two phase algorithm to solve rubik's cube. And have tried this code and it works as well.
One solution is to I guess simultaneously run all possible routes. That does sound stupid but here's the logic - over 99% of possible scrambles will be solvable in under 20 moves. This means that although you cycle through huge numbers of possibilities you are still going to do it eventually. Essentially this would work by having your first step as the scrambled cube. Then you would have new cubes stored in variables for each possible move on that first cube. For each of these new cubes you do the same thing. After each possible move check if it is complete and if so then that is the solution. Here to make sure you have the solution you would need an extra bit of data on each Rubiks cube saying the moves done to get to that stage.

Categories