Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
Oh... right... ~., ((] , -. {~ {.@I.@(-. +./"1@e. {:@]))^:(<:@#@[) ,:@{.) |."1 edges 2 1 3 17 18 19 20 21 22 14 15 16 23 26 25 24 13 12 11 10 9 8 7 6 5 4 Or, closing the loop (,{.)~., ((] , -. {~ {.@I.@(-. +./"1@e. {:@]))^:(<:@#@[) ,:@{.) |."1 edges 2 1 3 17 18 19 20 21 22 14 15 16 23 26

Re: [Jprogramming] Wiki: Energy Usage Analysis

2016-08-25 Thread 'Bo Jacoby' via Programming
Hi! When you have got positive numbers only, then first take the logarithm, because whatever calculation you make you never want negative values. Next multiply by 100 because the accuracy of the measurements is around 1 percent. Next round to integer values because the fractional part is uninter

Re: [Jprogramming] determine the cycle

2016-08-25 Thread R.E. Boss
I share this talent: 2 is not adjacent to 3 was what I meant. R.E. Boss > -Original Message- > From: Programming [mailto:programming-boun...@forums.jsoftware.com] > On Behalf Of Raul Miller > Sent: donderdag 25 augustus 2016 23:21 > To: Programming forum > Subject: Re: [Jprogramming] d

Re: [Jprogramming] Wiki: Energy Usage Analysis

2016-08-25 Thread dhkelly
I would suggest that you could get away with samples taken at longer intervals. You won't lose useful information as none of the major appliances including the air conditioner should draw a startup peak power for over 6 seconds and what you really need is the increase in load over a longer tim

[Jprogramming] Wiki: Energy Usage Analysis

2016-08-25 Thread Joe Bogner
I posted an article that looks at some data I captured using a whole-home energy monitor. I also posted the data. I put up a challenge for anyone who wants to take a stab at it. http://code.jsoftware.com/wiki/User:Joe_Bogner/EnergyUsageAnalysis How often does the air conditioner or clothes dryer

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
That should not matter. The cycle does not have a specific beginning or ending - it's a cycle. It does not even have a specific direction. (The original example had the same vertex in it twice, to represent that. If you want that, do (, {.) to that result.) Thanks, -- Raul On Thu, Aug 25, 2016

Re: [Jprogramming] Jolf

2016-08-25 Thread David Lambert
This nqueens solution tries all ^~n possibilities by placing queens rank by rank, filtering out impossible solutions as it goes, and finally converting layouts to anagram index. Performance is far superior to filtering all !n full layouts as it solves n=12 in half minute (on this computer). I

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
It seems I hadn’t fully understood the fact that the graph consisted of one and only one cycle. Thus my first solution is a little overkill for this problem, as it should work on any graph. Here’s another shorter one, probably similar to yours: cycle=: >@{:@(sol&>/@]^:(<:@#@[) (}. ; {.)) sol=:

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
I think the 2 at the beginning of your solution (1 _2_ 3 17 …) should be at the end. Cheers, Louis > On 25 Aug 2016, at 23:21, Raul Miller wrote: > > I am more than willing to believe that I have been careless and made a > mistake. I'm actually pretty talented at making mistakes. > > That sai

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
I am more than willing to believe that I have been careless and made a mistake. I'm actually pretty talented at making mistakes. That said, it looks to me as if 2 is adjacent to 4: 2{edges 2 4 Is there something about this that I am missing? Thanks, -- Raul On Thu, Aug 25, 2016 at 2:19 PM

Re: [Jprogramming] determine the cycle

2016-08-25 Thread R.E. Boss
You should swap the first two numbers of your solution, since 2 is not adjacent to 4. It's more or less what I came up with, be it explicit. ;{.(3 :('''x y''=.y'; '(y-.t{y);~ x,({:x)-.~y{~t=.1 i.~ y e.~"1 {:x'))^:(#@>@{:) ({.;}.) edges 1 2 4 5 6 7 8 9 10 11 12 13 24 25 26 23 16 15 14 22 21 20

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Roger Shepherd
Pardon the interruption, but are you taking advantage of the well known depth first search, rooted tree growing search that produces a complete basis for all cycles in a connected graph? From there you can go on to various exchange system (matroids) if you've a mind to. There's a lot of work done a

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
Oops, I represented the vertices incorrectly ({."1 would only be valid if the edges were directed). Here's a fix: ~., ((] , -. {~ {.@I.@(-. +./"1@e. {:@]))^:(<:@#@[) ,:@{.) edges 1 2 3 17 18 19 20 21 22 14 15 16 23 26 25 24 13 12 11 10 9 8 7 6 5 4 This is the same core implementation, but thi

Re: [Jprogramming] determine the cycle

2016-08-25 Thread 'Jon Hough' via Programming
I think it depends on the definition of "cycle". A simple cycle is usually defined to be a cycle that never crosses itself. So in that case, your cycle is not simple. (and you could keep appending itself to itself ad infinitum, so is pretty pointless to consider non-simple cycles) By the way, th

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
I was just wondering if 1 2 4 6 5 3 2 1 is considered a cycle since 2 is traversed twice. I would think not. Louis > On 25 Aug 2016, at 13:42, R.E. Boss wrote: > > It's not a directed cycle > > (1+i.26) /:~"1|: ({.,#)/.~ , edges > 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 2

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
As usual, a minor typo: Since cl finds only the shortest cycles (which are all the same length), I added and >@ to the first {:”1. That’s why the result is unboxed. However cls deliberately doesn’t have this, as its results may be of different lengths. Here they are again in case I copied the wr

Re: [Jprogramming] determine the cycle

2016-08-25 Thread 'Jon Hough' via Programming
Raul, your solution seems to miss out some vertices and duplicates others. On Thu, 8/25/16, Raul Miller wrote: Subject: Re: [Jprogramming] determine the cycle To: "Programming forum" Date: Thursday, August 25, 2016, 9:07 PM Best I can come up

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Louis de Forcrand
Got this: cl=: [: {:"1 ] ([: ; lp&.>/"1)@]^:(*./@:~: {:@>@{:"1)^:_ lp lp=: [ ((-. (,: |.)@(_2&{.)) ; ])"2 1 ] ,"1 0 {:"1@[ {~ {:@] I.@:= {."1@[ Not particularly elegant or concise, but it works (G -: edges): ((, |."1) G) cl 1 1 2 4 5 6 7 8 9 10 11 12 13

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
Best I can come up with is {."1 ((] , -. {~ {.@I.@(-. +./"1@e. {:@]))^:(<:@#@[) ,:@{.) edges 1 3 17 18 18 20 20 21 22 14 15 16 23 26 25 13 12 11 11 10 9 7 6 5 4 2 Change {.@I. to {:@I. if you want things in the other order. -- Raul

Re: [Jprogramming] determine the cycle

2016-08-25 Thread R.E. Boss
It's not a directed cycle (1+i.26) /:~"1|: ({.,#)/.~ , edges 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 R.E. Boss > -Original Message- > From: Programming [mailto:programming-boun...@for

Re: [Jprogramming] determine the cycle

2016-08-25 Thread Raul Miller
That is not a cycle. (1+i.26) -. {."1 edges 8 19 24 -- Raul On Thu, Aug 25, 2016 at 6:13 AM, R.E. Boss wrote: > Given the edges in a graph which is a cycle, like >edges > 1 2 > 3 1 > 2 4 > 4 5 > 5 6 > 6 7 > 7 8 > 9 8 > 10 9 > 11 10 > 11 12 > 12 13 > 14 15 > 15 16 > 17

[Jprogramming] determine the cycle

2016-08-25 Thread R.E. Boss
Given the edges in a graph which is a cycle, like edges 1 2 3 1 2 4 4 5 5 6 6 7 7 8 9 8 10 9 11 10 11 12 12 13 14 15 15 16 17 3 18 17 18 19 20 19 20 21 21 22 22 14 16 23 13 24 25 24 26 25 23 26 Vertices of the graph are represented by >:i.26 Question is how to determine in an