In JuMP 0.18 we could do solve(model, relaxation=true).
There isn't this option in !optimize, so how can I get a relaxed solution?
Related
In RGui terminal, I just typed
ptm = proc.time()
ptm
The result is like
user system elapsed
0.21 0.87 50.32
So, it takes 50.32 seconds? I did nothing. What is the time unit for elapsed ?
Many thanks if someone can help it or forward this to some expert.
The time unit of all these three numbers is second.
elapsed is the time counted from the RGui terminal session starts. So if we type the code again, it can be found the elapsed time will always grow larger, it is accumulative.
In my Luis app i have an intent "goodbyeIntent" with examples "goodbye", "thanks" and "ciao". There is another intent containing lots of examples and, of course, the None-intent.
When i test the app i get the following predictions:
goodbye: 0.97 (goodbyeIntent)
ciao: 0.97 (goodbyeIntent)
thanks: 0.97 (goodbyeIntent)
Although i would have expected scores of 1.00 these results seems to be ok.
Now when i test the app with a word or sentence that is different from all examples of goodbyeIntent, let's say "this is a test", luis nevertheless predicts goodbyIntent with a very high score.
In this case i would have expected the None-Intent to be predicted.
Can someone explain this behavior?
I have what I think to be an optimization problem that I have already solved. I think, however, that there might be a more robust solution which I don't quite know how to implement. Maybe someone here has some ideas.
Problem Description
I need to pair events from two separate recordings. An event has a name, a time t at which it occurred and an amplitude a with the constraint that the next event occurs at t_next = t + a. The two recordings should produce events at the same time and amplitude, but there are recording errors to deal with like drift.
The task is to group the same events into pairs of 2.
Here is an example:
Event Name t a t a
39770 155648.16 41.96 154726.4 41.75
39780 155690.12 42.01 154768.15 41.78
39790 155732.13 41.24 154809.94 41.13
39800 154851.06 5.74
39810 155773.37 1.55
39815 155774.03 1.55
39820 155774.92 3.75
39830 155778.67 0.65
39840 155779.32 22.35 154856.81 22.24
39850 155801.67 1.36 154879.04 1.27
39855 155802.4 1.36 154879.66 1.27
39860 155803.04 12.79 154880.31 12.74
As you can see, the t and a values are not exactly the same within a pair (same row), so I have to work with tolerances. Sometimes, you have events in recording 1 what you don't have in recording 2 and vice verse. So how can I pair them?
Idea For Solution
I was thinking of a "rubberband" approach somehow. Basically, you group the events by amplitude within the allowed tolerance such that you maximize the number of paired up events. But I'm not sure how to deal with missing events in one recording vs the other. Somehow, I have to ignore them and I'm not sure how to best do that without this problem exploding due to exorbitant combinations to try.
Has anyone come across this kind of problem and knows a robust solution for it?
I'm trying to process a bunch of csv files and return data frames in R, in parallel using mclapply(). I have a 64 core machine, and I can't seem to get anymore that 1 core utilized at the moment using mclapply(). In fact, it is a bit quicker to run lapply() rather than mclapply() at the moment. Here is an example that shows that mclapply() is not utilizing more the cores available:
library(parallel)
test <- lapply(1:100,function(x) rnorm(10000))
system.time(x <- lapply(test,function(x) loess.smooth(x,x)))
system.time(x <- mclapply(test,function(x) loess.smooth(x,x), mc.cores=32))
user system elapsed
0.000 0.000 7.234
user system elapsed
0.000 0.000 8.612
Is there some trick to getting this working? I had to compile R from source on this machine (v3.0.1), are there some compile flags that I missed to allow forking? detectCores() tells me that I indeed do have 64 cores to play with...
Any tips appreciated!
I get similar results to you, but if I change rnorm(10000) to rnorm(100000), I get significant speed up. I would guess that the additional overhead is canceling out any performance benefit for such a small scale problem.
I've been trying to dig into what the time-hogs are in some R code I've written, so I'm using Rprof. The output isn't yet very helpful though:
> summaryRprof()
$by.self
self.time self.pct total.time total.pct
"$<-.data.frame" 2.38 23.2 2.38 23.2
"FUN" 2.04 19.9 10.20 99.6
"[.data.frame" 1.74 17.0 5.54 54.1
"[.factor" 1.42 13.9 2.90 28.3
...
Is there some way to dig deeper and find out which specific invocations of $<-.data.frame, and FUN (which is probably from by()), etc. are actually the culprits? Or will I need to refactor the code and make smaller functional chunks in order to get more fine-grained results?
The only reason I'm resisting refactoring is that I'd have to pass data structures into the functions, and all the passing is by value, so that seems like a step in the wrong direction.
Thanks.
The existing CRAN package profr and proftools are useful for this. The latter can use Rgraphviz which isn't always installable.
The R Wiki page on profiling has additional info and a nice script by Romain which can also visualize (but requires graphviz).
Rprof takes samples of the call stack at intervals of time - that's the good news.
What I would do is get access to the raw stack samples (stackshots) that it collects, and pick several at random and examine them. What I'm looking for is call sites (not just functions, but the places where one function calls another) that appear on multiple samples. For example, if a call site appears on 50% of samples, then that's what it costs, because its possible removal would save roughly 50% of total time. (Seems obvious, right? But it's not well known.)
Not every costly call site is optimizable, but some are, unless the program is already as fast as possible.
(Don't be distracted by issues like how many samples you need to look at. If something is going to save you a reasonable fraction of time, then it appears on a similar fraction of samples. The exact number doesn't matter. What matters is that you find it. Also don't be distracted by graph and recursion and time measurement and counting issues. What matters is, for each call site you see, the fraction of stack samples that show it.)
Parsing the output that Rprof generates isn't too hard, and then you get access to absolutely everything.