|
Thanks, it makes complete sense, as the guy said below I doubt I'll be able to do what I want here. It would explain why Notepad is the only thing that I can get to function correctly, not a big deal was just wanting to fool around with it haha. Thanks for all your input, Daves.
|
|
|
|
|
You don't embed an exe in your program.
You can send it out along with your package and call it from your own executable.
|
|
|
|
|
I have created a genetic algorithmic program, but when it comes to doing the crossover or mutation probability I am having to do this by hard coding the function. So My default crossover is a 70% chance of the method body running depending on the result of a random generation, I am using a random number between 1 and 10, storing 7 numbers in an array and checking if they are 8, 9 or 10 is selected then the method body does not run.
Here is my code:
for (int i = 0; i < 7; i++)
{
pc[i] = random3.Next(1, 11);
}
int n = random3.Next(0, 7);
if ((pc[n] != 8) && (pc[n] != 9) && (pc[n] != 10))
{
label58.Text = "YES!";
}
else
{
label58.Text = "NO!";
}
I would like a better way to do this so I can choose a percentage probability by asking the user to enter a percentage. In real life the mutation probability is around 0.001, when it comes to this, I am having issues figuring out the best way to do this.
I would greatly appreciate your advice.
|
|
|
|
|
Why don't you just check if pc[n] >= 8? Unless I'm missing something. You can also input the percentage and check for pc[n] >= nThreshold or whatever.
|
|
|
|
|
I need to do something 70% of the time so generating a random number between 1-10, if a number was between 1 and 7 including 7 then do the code. So for 0.001% would I generate a numbers between 1-1000 and if the number 1 is selected then do the code?
Thanks!
|
|
|
|
|
Yeah, if you generate a number 1-10 and only run at <= 7, that'll be 70% of the time assuming the random number generator has an even distribution.
|
|
|
|
|
I think your referring to normal Gaussian distribution, see here you should be able to rework that code to C#
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan
That's what machines are for.
Got a problem?
Sleep on it.
|
|
|
|
|
May I suggest...
Pseudo-code...
static void function1 (MyObject o) {
...function operating on o...
}
static void function2 (MyObject o) {
...function doing some other operation on o, or no-op even...
}
void ProbabilityFunction () {
loop {
if (randomNumber < 0.7) {
function1(o);
} else {
function2(o);
}
}
}
Take that pattern and expand it.
BTW, your mistake here is assuming this is more complicated than it is. You have a simple decision, with only two branches - that's the trivial IF situation. Always break down your problem to the simplest possible thing. I think you missed the fact that all you're doing here is a simple IF-ELSE, and there's NOTHING in the ELSE.
Are you planning to have more than two possible functions? Because then, yeah, you need something more complicated, and to be honest, I was hoping you were asking about that. There is a known pattern for that - where you have between 3 and millions of possible functions. When you only have two, it's an IF-ELSE.
|
|
|
|
|
hi,
How can I change the button shape to circle in c#?
help me :]
thanks
nofar
|
|
|
|
|
Trivial in WPF. Quite a bit of work in Winforms. Which are you using?
|
|
|
|
|
i think is winForm,
I use the interface of vb.net
|
|
|
|
|
Look into learning WPF. ONce you know it, it is much easier to do things like that. WinForms is primative in comparison, and has not really changed much since VB 6.0 (dark ages).
|
|
|
|
|
For WinForms, you can simulate it easily by using a PictureBox and hooking the Click event.
What UI are you targetting? C# can be used for WinForms, WPF, ASP.NET, SilverLight, even Gtk.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
But the picture will not be rounded,
I use the interface of vb.net
|
|
|
|
|
Use a picture of a round button and a transparent background
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What an "AquaButton", e.g. A Simple AquaButton[^]? They are rounded rectangles, but changing them into circles should not be too complicated.
|
|
|
|
|
Hello All,
My Problem
Currently I am working on a project(C#,WinForm), where my requirement is to collect GPS data in my application like (Latitude,Longitude,Altitude,Speed,Satellites).
For getting above GPS data, I have a Garmin USB Device. Now problem is, How I can capture the GPS Device data into my application.
What I have done
I installed Garmin USB Driver, Franson GPS Client Gate.
Question
What library I should use? Has anyone faced same problem? please share.
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
You should get the documetation for the device from Garmin; they are most likely to know the answer.
Use the best guess
|
|
|
|
|
Do you need the data "online"? If not, you could configure the device to log the data to a file on its memory card and then import that file.
|
|
|
|
|
my sttring bulilder string would be like this:
StringBuilder sb = new StringBuilder();
sb.Append("hi friends hi");
i want to check the count of "hi" in the sb
so my final output would be like this.
Count is 2.
how to do that.
thank u
SUBIN
|
|
|
|
|
Probably not very efficient:
Get the string by calling ToString(). Split by space to get an arry of words. You can then use Distinct to get unique words and/or Select to get a specific word
|
|
|
|
|
Something like this?
StringBuilder sb = new StringBuilder();
sb.Append("hi friends hi");
Console.WriteLine("Count is " + "".ToString().Split(new []{" "}, StringSplitOptions.RemoveEmptyEntries).
Where(w => w.Equals("hi", StringComparison.CurrentCultureIgnoreCase)).Count();
Andreas Johansson
Senior software developer at Tieto Sweden
|
|
|
|
|
|
Yeah that's how I would do it, but copying your homework from Google is frowned upon. I think the OP should work to understand what the problem is, a method for solving it, and then the code for that method. Skipping to the last part won't help you pass the class.
|
|
|
|
|
Jasmine2501 wrote: Skipping to the last part won't help you pass the class.
That's why more and more companies are giving a coding-test when applying for a job. If the OP wants to cheat, he'll find that he has been cheated soon enough, owning a degree and not being able to use it
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|