Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
more falafel please
Feb 26, 2005

forums poster

nolen posted:

Yeah, I can set the mode to passive then parse the IP and port that it returns. I guess I'm just confused about if I'm supposed to open another socket using that IP and port combination and then send my LIST and whatever commands over that socket instead of the control socket that's originally created.

If so, my way of doing it isn't working.

You still send all your commands over the control socket. The other socket you open is for data, so that's where the actual data will come from, and then you should get the response code over the control socket again.

Adbot
ADBOT LOVES YOU

_aaron
Jul 24, 2007
The underscore is silent.

tripwire posted:

Lets say I have reference_pop, and I do a bunch of ticks on 3 different cpus, ending up with result1, result2, result3.

If result1 has 4 new guys, that means compared to reference_pop its also MISSING 4 guys; however it might be missing a different set of people than result2 is; or they both could have removed exactly the same guys; or they both could have removed SOME of the same guys, but other different ones.

My unified population at the end somehow has to have the same number of people, so I even if I remove everyone who was removed in any of the results I still won't have enough room for all the new guys who replaced them (between the different resulting populations, some of the removed dudes overlap, but none of the new guys should overlap).

Do the "individuals" in result1, result2, and result3 still have a fitness value associated with them at the point you want to merge your stuff? If so, you could merge the three populations, remove non-unique members, sort the remainder by fitness, then trim from the bottom until you get down to your correct population size.

The big issue I can see with this is that it won't guarantee that a loser removed on one CPU won't be re-added to the population. But the only way that would happen is if there were a significant number of worse members from the other CPUs.

This terminology is getting a little confusing, so if you want me to try to clarify anything, just ask.

nolen
Apr 4, 2004

butts.

more falafel please posted:

You still send all your commands over the control socket. The other socket you open is for data, so that's where the actual data will come from, and then you should get the response code over the control socket again.

THANK YOU.

I finally got this working. Your explanation was exactly what I needed to know.

more falafel please
Feb 26, 2005

forums poster

I'm drawing a blank coming up with a Google string for it, but a while ago (maybe 6 months) on The Daily WTF, there was a post with the output of a tool (or maybe just a quick perl script) that took Java code and printed only the control structures and method declarations (with no identifiers), so you were got "code" that looked like:
code:
class
{
    void (int, int)
    {
        if ()
        {
            if ()
            else
        }
        switch ()
        {
            case:
            case:
        }
    }
}
etc. Anyone remember this?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
This? http://thedailywtf.com/Articles/Coding-Like-the-Tour-de-France.aspx

more falafel please
Feb 26, 2005

forums poster


Yeah, that's it... they didn't post the tool though. Nevermind. I'd like to do that same thing with some work code.

Scaevolus
Apr 16, 2007

more falafel please posted:

Yeah, that's it... they didn't post the tool though. Nevermind. I'd like to do that same thing with some work code.

Looks like that was done by hand, not by a tool.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Scaevolus posted:

Looks like that was done by hand, not by a tool.

That still means it was done by a tool though. :pwn:

6174
Dec 4, 2004
At work there is a problem with a printer. Basically when I try to print to it there are particular colors that will not work (specifically if Red is at 1.0 and Blue and Green are some combination of 0.0 or 1.0). Instead of trying to track down the bug in this stupid host-based driver I have to use, I was thinking it would be possible to write a small program to fix this (basically search and replace the bad colors to something that will print). Since I primarily need to print postscript files, which are plain-text documents, this seems like it should be straight forward. However I've got no real experience with Postscript. Is writing a filtering type program here really as simple as my mind thinks it is?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

6174 posted:

However I've got no real experience with Postscript. Is writing a filtering type program here really as simple as my mind thinks it is?

Postscript is a turing-complete programming language. You can't, in general, programatically replace some colors with others.

You could write a Postscript interpreter that parsed the document and produced a sequence of draw commands that produced the same document, but has a predictable interior structure. Then you would be able to post-filter those commands to remove colors you don't want. This may result in a massive increase in the size of the document.

Also, keep in mind that there are several different color spaces that Postscript operates in, and depending on where the bug is in your printer, you may have to handle them as well.

6174
Dec 4, 2004

ShoulderDaemon posted:

Postscript is a turing-complete programming language. You can't, in general, programatically replace some colors with others.

Hmm... So it seems that it might be a little more complicated than I had hoped. But what I do have going for me is almost all of the files I need to print are generated from the same program which should mean that it will use colors in a uniform manner (It is output from IDL). So I guess I'll make sure to check that it was created by IDL first (which is conveniently a comment at the top) and then proceed to replace colors with how IDL sets things up. Hopefully that will allow it to become doable without writing a whole Postscript interpreter. Of course this isn't ideal, but it sounds better than manually printing ~1000 files by copying them to another computer and printing them one by one (and then doing that same process whenever I have something to print).

edit: I just had a potential idea. Since Postscript being Turing complete is the big problem, would it be reasonable to leverage that by inserting some postscript code into the file that changes the colors?

6174 fucked around with this message at 23:16 on Jun 13, 2008

PostBot3000
Mar 11, 2007

"Universal health care and gun control: if it's good enough for the USSR and Nazi Germany it's good enough for the US!"
How different are Scheme and Common LISP? Similar like C++ and Java?

defmacro
Sep 27, 2005
cacio e ping pong

happylf posted:

How different are Scheme and Common LISP? Similar like C++ and Java?

The two big differences are namespaces and libraries. You'll see Scheme and Common Lisp referred to as Lisp-1 and Lisp-2 respectively. Lisp-1's have everything in one namespace (functions, variables, etc.) while a Lisp-2 has separate namespaces for the previously mentioned things. Because of this, Common Lisp code can get a little messy when you're dealing with function application. This paper explains the differences much more extensively.

Scheme is generally used as a teaching language because the language itself is very small. Common Lisp has a much more robust built-in library (this might be a good comparison between Java and C++ without the STL). I'd argue if you wanted to develop a 'serious' application, you'd want to use Common Lisp, but if you just want some experience with functional programming, Scheme would be a better choice.

There are some other minor differences between the two (syntax, Scheme can generally compile to C or binaries more easily than Common Lisp, etc.), but these are the biggest.

PostBot3000
Mar 11, 2007

"Universal health care and gun control: if it's good enough for the USSR and Nazi Germany it's good enough for the US!"
Thanks. ArsDigita has a course on SICP which uses Scheme. Seemed interesting, but since I'll be learning Common this semester I didn't want to confuse myself.

Pretend edit: http://www.aduni.org/courses/sicp/

Neslepaks
Sep 3, 2003

You can't really get confused by Scheme vs Common Lisp. Scheme is so small that you've quickly got a good grasp of it, and then you just have to learn the differences and the rest is CL.

Vanadium
Jan 8, 2005

Neslepaks posted:

You can't really get confused by Scheme vs Common Lisp. Scheme is so small that you've quickly got a good grasp of it, and then you just have to learn the differences and the rest is CL.

Is that not about the naive C vs C++ assumption?

Neslepaks
Sep 3, 2003

Vanadium posted:

Is that not about the naive C vs C++ assumption?

I have no idea what this means, but I don't think the comparison is similar on anything but a very superficial level (small/non-oo vs big/oo).

defmacro
Sep 27, 2005
cacio e ping pong

Neslepaks posted:

I have no idea what this means, but I don't think the comparison is similar on anything but a very superficial level (small/non-oo vs big/oo).

That's probably the only level that would really matter to a beginner.

Neslepaks
Sep 3, 2003

GT_Onizuka posted:

That's probably the only level that would really matter to a beginner.

But the discussion was whether or not learning Scheme and CL at the same time would be confusing. And I stand by my claim that it wouldn't, at least not in any degree approaching what it would be to learn C and C++ at the same time. :)

defmacro
Sep 27, 2005
cacio e ping pong

Neslepaks posted:

But the discussion was whether or not learning Scheme and CL at the same time would be confusing. And I stand by my claim that it wouldn't, at least not in any degree approaching what it would be to learn C and C++ at the same time. :)

Well, agreed in that case.

Lexical Unit
Sep 16, 2003

I've got a bash script that needs to test if a bunch of machines are up and able to be rshed into. So something like this:
code:
test_updown()
{
	HOST=$1
	UPDOWN="`rsh $HOST /bin/echo up 2>&1`"
	if [ ! "$UPDOWN" = "up" ]; then
		echo "error: could not connect to host $HOST" 1>&2
		exit 1
	fi
}
Which works fine when the rsh command either works or fails quickly. But sometimes rsh hangs indefinitely. I need a way to set a timeout that kills the rsh command if it doesn't return after some set time. Ideas?

Everything I find through google talks about running processes in parallel and then killing them if they hang with a timeout. But that's not what I want. test_updown() needs to be a blocking function that is guaranteed to return in a set time limit.



Edit: After some more searching I've found something that I think should work, but it's acting loving weird:
code:
test_updown()
{
	HOST=$1
	UPDOWN="`rsh $HOST /bin/echo up 2>&1`"
	if [ ! "$UPDOWN" = "up" ]; then
		echo "error: could not connect to host $HOST" 1>&2
		exit 1
	fi
}

test_timeout()
{
	HOST=$1
	TIMEOUT=$2

	rsh $HOST /bin/date 1>/dev/null 2>&1 &
	p=$!
	( sleep $TIMEOUT; kill -1 $p 1>/dev/null 2>&1 ) 1>/dev/null 2>&1 &
	k=$!
	wait $p
	exit=$?
	case $exit in
		129)
			exit 1
			;;
		*)
			kill $k
			return 0
			;;
	esac
}

test_everything()
{
	HOST=$1

	test_timeout $HOST 3
	test_updown
}
Now this only kinda works. If the rsh times out then we have a error and we shouldn't attempt to run test_updown(), so we exit. That's fine. And if the rsh immediately comes back with a error we don't time out, but we still have to call test_updown() because the return code from the rsh command we care about has been destroyed by calling other commands. The same for if rsh comes back with success immediately.

But in either of those cases where rsh returns immediately, we need to kill the timeout subshell process. The * case calls kill $k to do this, but it doesn't work. I can call jobs before and after that command and I can see that the loving command just doesn't work. I can't for the life of me figure out how to actually kill the subshell process. Wtf?


Edit again: Bah. Figured it out:
code:
		*)
			kill $k
[b]			wait $k 1>/dev/null 2>&1[/b]
			return 0
			;;

Lexical Unit fucked around with this message at 16:28 on Jun 17, 2008

bijou
Nov 4, 2005

by Fragmaster
Does anyone know why I cant get in to #cobol using my favorite IRC client, mibbit.com??

Vanadium
Jan 8, 2005

bijou posted:

Does anyone know why I cant get in to #cobol using my favorite IRC client, mibbit.com??

10:44 -!- 1 - #cobol: ban *!*@synIRC-F5376B42.mibbit.com [by rocketsauce, 14847 secs ago]

tef
May 30, 2004

-> some l-system crap ->

Vanadium posted:

10:44 -!- 1 - #cobol: ban *!*@synIRC-F5376B42.mibbit.com [by rocketsauce, 14847 secs ago]

Unbanned now. We should use the (eugh) unreal extentions to ban people by whois info for mibbit clients.

Safety Shaun
Oct 20, 2004
the INTERNET!!!1
Does anybody know of a quick and easy (and lite) web based rich text editor that I can use for a site I am making that will allow a businessman (and technophobe) post updates, with the ability to make crap like headers, bold, italic, tables, etc.

I would service you orally for a pointer.

Edit: PHP and MySQL

Zombywuf
Mar 29, 2008

Safety Shaun posted:

I would service you orally for a pointer.

code:
char *ptr;
Meet me behind the bike sheds.

No Safe Word
Feb 26, 2005

Zombywuf posted:

code:
char *ptr;
Meet me behind the bike sheds.

What color bike shed? I think it should be green. Discuss.

Aredna
Mar 17, 2007
Nap Ghost
I saw a link the other day to a website that provided a free web service for creating maps.

I'm 99% sure I saw it in these forums, or maybe this thread, but with search down I'll be damned if I haven't read 100 pages looking for it agail.

Your HILARIOUS
Mar 15, 2003
Moving question to mac thread...

Your HILARIOUS fucked around with this message at 18:05 on Jun 18, 2008

schnarf
Jun 1, 2002
I WIN.
I'm doing some audio code in fixed-point (this is for SDL). I need a way to multiply two fixed-point numbers, treating them as fractions. That is, I need to treat, for example, int, as having a range [-1, 1). If you're familiar with fixed-point conventions, I need to treat it as a Q1.31. One way I've thought of is:
code:
int fix_mpy(int a, int b) {
     return (a >> 16) * (b >> 16);
}
Is there any way to do it that preserves the precision a bit better?

schnarf fucked around with this message at 19:10 on Jun 18, 2008

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

schnarf posted:

Is there any way to do it that preserves the precision a bit better?

You could multiply them before shifting, then shift the result down by 32? You'll have to cast up to 64-bit integers first, I think.

schnarf
Jun 1, 2002
I WIN.

ShoulderDaemon posted:

You could multiply them before shifting, then shift the result down by 32? You'll have to cast up to 64-bit integers first, I think.
Right, I was thinking about that, but SDL is built for so many platforms, and some of them don't have 64-bit integers.

Edit: Yeah, basically I'm trying to figure out how to calculate only the upper 32 bits of the 64-bit result of a 32-bit multiplication.

schnarf fucked around with this message at 19:29 on Jun 18, 2008

Aredna
Mar 17, 2007
Nap Ghost

schnarf posted:

Right, I was thinking about that, but SDL is built for so many platforms, and some of them don't have 64-bit integers.

Edit: Yeah, basically I'm trying to figure out how to calculate only the upper 32 bits of the 64-bit result of a 32-bit multiplication.

Not exactly what you're looking for, but this has how to do it with 16 bit numbers getting a 32 bit result on a 16 bit machine. The algorithm is spelled out pretty well so even the the code is in Assembly you can probably apply it pretty easily to your situation.

http://www.8052.com/mul16.phtml

schnarf
Jun 1, 2002
I WIN.

Aredna posted:

Not exactly what you're looking for, but this has how to do it with 16 bit numbers getting a 32 bit result on a 16 bit machine. The algorithm is spelled out pretty well so even the the code is in Assembly you can probably apply it pretty easily to your situation.

http://www.8052.com/mul16.phtml
Awesome, that's pretty much exactly what I was looking for! Thanks!

magicalblender
Sep 29, 2007
My bash script looks very unusual and won't run anymore. The whole thing would break tables, so here's a representative snippet instead:
code:
MLH Z
pTU~IN"@@xI
?!l04vat:ݝK:mk
2 hK-3ÎUUfuqYv...
... And so on, for seventy more lines. What the heck is this stuff?

As to the cause, there are three prime suspects:
1. tar
2. the in-house script that I have no control over and have never fully understood
3. mischievous computer gremlins

What I'm hoping for, is that one of you will say, "Ah yes, this is a common and well-documented bug in the tar program. Simply run 'unmangle' on your source to get it back".
What I expect, is that the in-house script ruined my work and I didn't make a backup :saddowns:

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

magicalblender posted:

My bash script looks very unusual and won't run anymore. The whole thing would break tables, so here's a representative snippet instead:
code:
MLH Z
pTU~IN"@@xI
?!l04vat:ݝK:mk
2 hK-3ÎUUfuqYv...
... And so on, for seventy more lines. What the heck is this stuff?

Type "file name-of-script" and it'll tell you what the OS thinks the script is. If it's tarred or zipped or something, that should be a recognizable file format - if it just says "binary data" it's nothing the OS knows about.

Smugdog Millionaire
Sep 14, 2002

8) Blame Icefrog
I wrote a script in Ruby where I tried to do some Unix-style forking but it didn't run on my Windows machine. I found out that Windows doesn't support forking, but it must have something similar. What is it and how do I use it in Ruby?

JoeNotCharles
Mar 3, 2005

Yet beyond each tree there are only more trees.

Free Bees posted:

I found out that Windows doesn't support forking, but it must have something similar.

Ha ha ha. How naive.

covener
Jan 10, 2004

You know, for kids!

Free Bees posted:

I wrote a script in Ruby where I tried to do some Unix-style forking but it didn't run on my Windows machine. I found out that Windows doesn't support forking, but it must have something similar. What is it and how do I use it in Ruby?

Any API provided by your scripting language would be using CreateProcess/CreateProcessEX under the covers -- you shouldn't have to deal with that in your ruby code.

Adbot
ADBOT LOVES YOU

tripwire
Nov 19, 2004

        ghost flow

_aaron posted:

Do the "individuals" in result1, result2, and result3 still have a fitness value associated with them at the point you want to merge your stuff? If so, you could merge the three populations, remove non-unique members, sort the remainder by fitness, then trim from the bottom until you get down to your correct population size.

The big issue I can see with this is that it won't guarantee that a loser removed on one CPU won't be re-added to the population. But the only way that would happen is if there were a significant number of worse members from the other CPUs.

This terminology is getting a little confusing, so if you want me to try to clarify anything, just ask.
I think I've figured out a principled way of doing it as pseudocode, I just need help from someone more versed in either parallel python or pyprocessing on how to actually implement it now.

I thought about how/why this kind of "search" works. I think its most instructive to imagine a tree branching out from some point and trying to cover the most space as possible; its ultimately trying to find the point in this space which corresponds to a fit chromosome and to do that it has to travel through search space on the shoulders of slightly less fit chromosomes, testing the space around them for potential high quality chromosomes, but also drifting around to some extent. By covering a huge space, the chances of finding that magic point which corresponds to high fitness are higher.

So then, there is two essential things this algorithm does in a loop:
1. It stochastically explores/samples some area of "search space" neighboring an existing member of the population, to see how fit it is.
2. It deterministically updates the frontier of new sample points by removing the least fit member of the population.

The two actions are really just a formalization of the idea "throw stuff at the wall and see what sticks". If you are in a situation where getting new poo poo to throw is easy and cheap, then its not hard to see that the real paydirt (computationally) is in seeing which things actually stick. To make this conversation less painful, lets just call these two steps a "tick". If you perform a whole bunch of ticks serially, let's call that a "batch".

If you imagine the population as a scatterplot in search space, then over many batches it will travel to new areas, converge to narrow points, or diffuse in all directions quasi-uniformly depending on how savage the selection criteria is and how the fitness landscape looks at that point.
It is worth mentioning that on the current domain I'm testing this algorithm on, (bipedal walking), after letting evolution stabilize a bit, I can generally expect that 1 out of every 500 new individuals will be an improvement and displace someone in their population. If a batch consists of 10 ticks, thats a 2% chance that a given batch will actually add a useful new guy the population... HOWEVER, search doesn't just work by getting useful new guys, it also works by weening out lovely old guys. After a batch, a resulting population will either have removed a number of individuals in the original population, removed individuals that were newly added in the same tick, or some combination of the two.

So lets say we perform a batch thats 10 ticks long, and we do it on 5 different processors. After they are all done, you can have anywhere from 0 to a maximum of 5*10 new guys to choose from in the set of resulting populations, but odds are you'll be lucky to get one. The number of guys removed from the population prior to the batch is going to be equal or less than the number of newly added guys; for example two batches might remove the same guy to bring in two different improvements. Given this situation, its easy to just make a new guy, but actually weeding out a member of the original population is a lot harder (and more valuable!). Because of that I think removals should be incorporated from any batch that has them, but new guys should only be added while there is room for them (and maybe selected on merits, or randomly, to see if that is any better)

What I need to know now is how the resulting populations from concurrent batches can be distinguished.. normally a single-threaded algorithm, each chromosome keeps a unique identifier, but if its going to be in parallel the identifiers can (and WILL) have collisions.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply