• 6 Posts
  • 181 Comments
Joined 2 years ago
cake
Cake day: June 5th, 2023

help-circle


  • The diagram is pretty good but your interpretation is not quite right, especially for NP-complete and NP-hard.

    NP-hard means “at least as hard as all problems in NP”, proven by the fact that any single NP-hard problem can be used to solve the entire class of all NP problems.

    NP-complete means “at least as hard as all problems in NP and itself also in NP”, so the intersection between NP and NP-hard.

    The thing about P = NP or P != NP is something different. We don’t know if P and NP are the same thing or not, we don’t have a proof in either direction. We only know that P is at least a subset of NP. If we could find a P solution for any NP-hard problem, we would know that P = NP. That would have massive consequences for cryptography and cyber-security because modern encryption relies on the assumption that encrypting something with a key (P) is easier than guessing the key (NP).

    On the other hand, at some point we might find a mathematical proof that we can never find a P solution to an NP-hard problem which would make P != NP. Proving that something doesn’t exist is usually extremely hard and there is the option that even though P != NP we will never be able to prove it and are left to wonder for all eternity.



  • Alright, part 2, let’s get to NP.

    Knowing that P means “in polynomial time”, you might be tempted to think that NP means “in non-polynomial time” and while that kind of goes in the right direction, it means “in non-deterministic polynomial time”. Explaining what non-deterministic calculations are would be a bit too complicated for an ELI5, so let’s simplify a bit. A regular computer must make all decisions (for example which way to turn when calculating a shortest route between two points) based on the problem input alone. A non-deterministic computer can randomly guess. For judging complexity, we look at the case where it just happens to always guesses right. Even when guessing right, such a computer doesn’t solve a problem immediately because it needs to make a number of guesses that depends on the input (for example the number of road junctions between our points). NP is the class of problems that a non-deterministic computer can solve in polynomial Time (O(n^a) for any a).

    Obviously, we don’t really have computers that always guess right, though quantum computers can get us a bit closer. But there are three important properties that let us understand NP problems in terms of regular computers:

    1. a non-deterministic computer can do everything a regular computer can do (and more), so every problem that’s part of P is also part of NP.
    2. every problem that takes n guesses with x options for each guess can be simulated on a regular computer in O(x^n) steps by just trying all combinations of options and picking the best one. With some math, we can show that this is also true if we don’t have n but O(n^a) guesses. Our base x might be different, but we can always find something with n in the exponent.
    3. While finding a solution on a regular computer may need exponential time, we can always check if a solution is correct in polynomial time.

    One important example for a problem in NP is finding the prime factors of a number which is why that is an important basic operation in cryptography. It’s also an intuitive example for checking the result being easy. To check the result, we just need to multiply the factors together and see if we get our original number. Okay, technically we also need to check if each of the factors we get is really prime but as mentioned above, that’s also doable in polynomial time.

    Now for the important thing: we don’t know if there is some shortcut that lets us simulate NP problems on a regular computer in polynomial time (even with a very high exponent) which would make NP equal to P.

    What we do know is that there are some special problems (either from NP or even more complex) where every single problem from NP can be rephrased it as a combination of that special problem plus some extra work that’s in P (for example converting our inputs and outputs to/from a format that fits L). Doing this rephrasing is absolutely mind-bending but there are clever computer scientists who have found a whole group of such problems. We call them NP-hard.

    Why does this help us? Because finding a polynomial-time solution for just a single NP-hard problem would mean that by definition we can solve every single problem from NP by solving this polynomial-time NP-hard problem plus some polynomial-time extra work, so polynomial-time work overall. This would instantly make NP equal to P.

    This leaves us with the definition of NP-complete. This is simply the class of problems that are both NP-hard and themselves in NP. This definition is useful for finding out if a problem is NP-hard but I think I’ve done enough damage to your 5-year-old brain.



  • They are classes that describe how hard a problem is.

    Imagine trying to explain to someone how fast you can do something, for example sorting a list. The simplest way would be saying “I can do that in two seconds” but that’s not very helpful because it depends on how fast your computer is. A better way would be to express it as a number of steps: “I can do that in 10000 steps”. For this ELI5 explanation the exact definition of what a step is doesn’t matter that much, it could be a single CPU instruction or a comparison between two items in the list.

    That gets you a bit closer but obviously, how complex sorting a list is, depends on the list: how long is it and how scrambled is it? Short lists are faster to sort than long ones and lists that are already (almost) sorted are usually fasterto sort than ones in reverse or completely random order. For that you can say “In the worst case, I can sort a list in three times the number of items squared, no matter the initial order”. When writing that down, we call the number of items n, so the total work is 3 * n^2. The bigger n gets, the less the constant factor matters, so we can leave it out and instead write O(n^2). This is, what people call “Big O notation” and it’s the reason why I said the exact definition of a step doesn’t matter that much. As long as you don’t get it too wrong, different step definitions just change the constant that we’re ignoring anyway. Oh and by the way, O(n^2) for sorting lists isn’t that great, good algorithms can reach O(n*log(n)) but I didn’t want to throw logarithms at you right away.

    Now we get close to understanding what P is. It’s the class of all problems that can be solved in “polynomial” time, so O(n^a) for any number a. Note that only the highest exponent is relevant. With some work we could prove that for example O(n^3 + n^2 + n) is equivalent to O(n^3). Examples of problems in n are sorting, route planning and finding out if a number is prime.

    I’m running out of time because I have some errands to run, maybe someone else can explain NP (nondeterministic polynomial time). If not, I’ll add a follow up later today.




  • Servers not having the same content in their “all” feeds is not a bug, it’s by design. The design philosophy for Mastodon (and I’d say the fediverse as a whole) is to let the users curate their own feeds instead of showing them everything or algorithmically guessing what they might be interested in. Servers will only receive posts from accounts that at least one of this server’s accounts is subscribed to. Having every post federate to every server even if nobody there is interested in those posts would be a waste of resources.

    Yes, that makes discovery of new content significantly harder but that’s the tradeoff for being able to host your own small instance without the need for a super powerful server. I can run my instance that serves just a couple of users on a 10-year-old server that runs a dozen other things at the same time. We see the stuff we’re interested in and don’t have to spend disk space, processing power and network bandwidth on content none of us will ever read and neither do we have to spend those resources on sending our posts to other instances where nobody will read them.





  • They don’t owe you anything. Not sex, not a kiss, not a hug, not a second date, not even a smile. If the date goes well, you will get some or even all of those but if you try to force them, you will get nothing. Sure it can be disappointing if you put in a lot of effort and get nothing back but you will have to live with that. Sometimes people just aren’t compatible and sometimes a date just goes wrong because of a weird coincidence.

    Be nice, even if the date doesn’t go as you wanted. Open communication goes a long way and chances are that the person you’re talking to is just as insecure as you are. Explain (not accuse) why you don’t think this situation will work out. If you’re lucky, you can turn the conversation around. If not, at least you’re ending the date in a civil way. That also (and especially) applies to talking on online dating platforms. Sometimes you can tell just from a conversation that things won’t go anywhere. Way too many people just drop the conversation and move on which can feel pretty rude. Be nice, explain what’s up, give them a friendly goodbye and then move on.

    Those rules apply to both sides. You don’t owe them anything either, especially if they get rude. You should still try to be friendly in case there is a misunderstanding but try to get yourself out of an uncomfortable situation before it gets worse. Your safety is still priority number one.

    Edit: some more

    Don’t expect a relationship to last. Chances are it won’t. But this isn’t as pessimistic of a tip as you might expect. Even a single day of joy can be worth it if you manage your expectations. I’ve had a relationship crash and burn after seven years, I’ve had ones that lasted a couple of months and I’ve had someone ghost me after the second date. And still, all of them gave me amazing memories that I wouldn’t want to miss and they helped me grow as a person. Allow things to grow on their own and enjoy the process. Maybe you will marry that person. Maybe you’ll date them for a few months or years. Maybe you will never get past second base but stay platonic friends. Maybe you will spend the most amazing day of your life with them and then never see them again because you accidentally spilled something over their favorite t-shirt.


  • Sure. I use it as a structured place to keep notes on anything that may be important later, not specifically tasks:

    • Important people in my life (friends and family) with a short bio, where we met, favorite food, allergies, ideas what I could get them for their birthdays, links to their social media profiles, plans for shared vacations, maybe a few photos.
    • Recipes from all kinds of sources. If they are from a video or one of those “scroll past three pages of sentimental nonsense” sites, I summarize them and translate them into German with metric units.
    • Lists with interesting links about 3D printing, software development and so on. Keeping these in a wiki instead of just my browser’s bookmarks list allows me to better categorize them and add notes.
    • A list of open questions and project ideas that I can’t research right now like “Where is the best place to get custom printed LEGO minifigs?” and “Why do the zfs drives in my home server sometimes have problems waking up from sleep?”
    • Lists of interesting products/books/movies/… that I might buy/read/watch/… at some point
    • Some writing stuff: D&D campaigns, short stories, diary-like entries
    • A list of all computers in my household with hardware specs, operating system and so on

    All of those get put into categories and the categories are displayed on the main page via the categorytree plugin. The nice thing about having a wiki is that you have a lot of options for linking or embedding related content while still keeping it somewhat organized.



  • dfyx@lemmy.helios42.detoExplain Like I'm Five@lemmy.worldELI5: ipv6
    link
    fedilink
    English
    arrow-up
    7
    ·
    edit-2
    1 month ago

    Just because you have IPv6 enabled doesn’t mean you don’t have IPv4. Both can coexist on the same network and the same device so your router can be 192.168.0.1 and some IPv6 address at the same time.

    On top of that, many routers can be reached by a well-known hostname or domain, depending on their manufacturer. For example, AVM Fritz!Box routers (extremely popular in Germany) automatically resolve http://fritz.box to their own IP address no matter what that IP address is.

    In the end, read the manual or the sticker on the device, same as you would have to do with IPv4 to figure out which subnet it is configured with.


  • I’ll give it a shot. Not quite ELI5 but “Explain like I know what a phone number is”. For the most important answer, see the last paragraph.

    IP addresses are a bit like phone numbers. To send data to some computer, your computer attaches that number and sends the data packet on its way. With IPv4, an address is four bytes long, usually represented as four numbers from 0-255 separated with dots. That gives us a bit under 4.3 billion possible addresses which seemed enough when the system was invented and larger organizations could even reserve entire address ranges and some ranges got reserved for special purposes (for example, all 127.x.x.x addresses mean “send this to myself” while 192.168.x.x and 10.x.x.x are meant for local, non-public networks). Reserving these ranges is convinient when you need multiple machines connected to the internet but is very inefficient as these ranges need to be a power of two in size (256 is common), so you may get more addresses than you need and the rest stays unused.

    The first solution was “Network Address Translation” (NAT). Basically, every household or organization gets a single public IPv4 address and every device on your network has a private address. On outgoing connections, your router replaces the (private) sender address with its public address and remembers which private address belongs to that connection so it can correctly forward any replies. For incoming connections, the router needs a list of rules to tell it what to do. For example something like “Everything on port 80 goes to 192.168.0.42”. This worked for a while as most people make only outgoing connections and even many organizations can simply decide locally what to do with an incoming connection based on the received data so they wouldn’t need multiple addresses.

    After a while, it was clear that even with this workaround we would run out of addresses sooner or later. Providers tried giving their customers a different address every time they connected to the internet so they could reuse the address for someone else when the customer disconnected. This worked well when people only connected when they needed it but these days we’re usually online 24/7.

    So in the end, the only solution was to add more addresses. For our current needs, doubling the length would be more than enough but to be on the safe side, it was decided to quadruple the address length to a total of 16 bytes. This gives us about 340 undecillion unique addresses. Still not enough to give a unique address to every atom in the universe, not even enough for every atom on earth but still a lot. We can give every human an address range many times larger than the total address space of IPv4.

    Does this mean that NAT is dead or that all your devices are visible from outside your network? Absolutely not. It means you can do that if you want. If your provider gives you a large address range, you can give each of your devices a different one and tell your router to forward everything. But you can also still use a single public address and/or tell your router to apply certain rules for what to do with incoming connections. There are also still address ranges that are meant purely for local use, equivalent to what 192.168.x.x and 10.x.x.x were in IPv4.