np

Is the 0-1 Knapsack that each item has the same weight NP-complete?

白昼怎懂夜的黑 提交于 2019-12-11 00:57:20
问题 The 0-1 Knapsack problem is known as NP-complete. But if the weight for each item are the same, the problem is still NP-complete? 回答1: No, because you always just take whatever items are the most valuable. 来源: https://stackoverflow.com/questions/11249448/is-the-0-1-knapsack-that-each-item-has-the-same-weight-np-complete

Complete Weighted Graph and Hamiltonian Tour

笑着哭i 提交于 2019-12-09 16:46:47
问题 I ran into a question on a midterm exam. Can anyone clarify the answer? Problem A: Given a Complete Weighted Graph G, find a Hamiltonian Tour with minimum weight. Problem B: Given a Complete Weighted Graph G and Real Number R, does G have a Hamiltonian Tour with weight at most R? Suppose there is a machine that solves B. How many times can we call B (each time G and Real number R are given),to solve problem A with that machine? Suppose the sum of Edges in G up to M. 1) We cannot do this,

How to use numpy.all() or numpy.any()?

梦想与她 提交于 2019-12-07 20:04:57
问题 I am trying to search in a 2D numpy array for a specific value, the get_above method returns a list of coordinates above the character 'initial char' def get_above(current, wordsearch): list_of_current_coords = get_coords_current(current, wordsearch) #print(list_of_current_coords) length = len(list_of_current_coords) first_coords = [] second_coords = [] for x in range(length): second = list_of_current_coords[x][1] new_first = list_of_current_coords[x][0] - 1 first_coords.append(new_first)

Implementing a backtrack search with heuristic?

本秂侑毒 提交于 2019-12-07 01:22:49
问题 I'm getting quite interested in search algorithms and backtrack programming. For now, I have implemented Algorithm X (see my other post here: Determine conflict-free sets? ) to solve an exact cover problem. This works very well but I'm now interested in solving this with a more basic variant of backtracking. I just can't figure out how this can be done. The problem description is the same as before: Suppose you have a bunch of sets, whereas each set has a couple of subsets. Set1 = { (banana,

How to use numpy.all() or numpy.any()?

丶灬走出姿态 提交于 2019-12-06 05:02:06
I am trying to search in a 2D numpy array for a specific value, the get_above method returns a list of coordinates above the character 'initial char' def get_above(current, wordsearch): list_of_current_coords = get_coords_current(current, wordsearch) #print(list_of_current_coords) length = len(list_of_current_coords) first_coords = [] second_coords = [] for x in range(length): second = list_of_current_coords[x][1] new_first = list_of_current_coords[x][0] - 1 first_coords.append(new_first) second_coords.append(second) combined = [first_coords, second_coords] above_coords = [] for y in range

Implementing a backtrack search with heuristic?

限于喜欢 提交于 2019-12-05 05:05:17
I'm getting quite interested in search algorithms and backtrack programming. For now, I have implemented Algorithm X (see my other post here: Determine conflict-free sets? ) to solve an exact cover problem. This works very well but I'm now interested in solving this with a more basic variant of backtracking. I just can't figure out how this can be done. The problem description is the same as before: Suppose you have a bunch of sets, whereas each set has a couple of subsets. Set1 = { (banana, pineapple, orange), (apple, kale, cucumber), (onion, garlic) } Set2 = { (banana, cucumber, garlic),

NP-Complete VS NP-Hard

 ̄綄美尐妖づ 提交于 2019-12-04 14:23:54
I am trying to understand the difference between NP-Complete and NP-Hard. Below is my understanding An NP-Hard problem is one that is not solvable in polynomial time but can be verified in polynomial time. An NP-Complete problem is one that is in NP and is also NP-Hard. Is the above definition correct? If so, What about problems not In NP but NP-Hard. Wouldn't they be harder than NP-Complete problem, say they can only be solved and verified in exponential time? A NP problem (not NP-Hard problem) is a decision problem which can be verified in polynomial time. Maybe they are solvable in

How to find pattern groups in boolean array?

你离开我真会死。 提交于 2019-12-04 04:15:57
Given a 2D array of Boolean values I want to find all patterns that consist of at least 2 columns and at least 2 rows. The problem is somewhat close to finding cliques in a graph . In the example below green cells represent "true" bits, greys are "false". Pattern 1 contains cols 1,3,4 and 5 and rows 1 and 2. Pattern 2 contains only columns 2 and 4, and rows 2,3,4. Business idea behind this is finding similarity patterns among various groups of social network users. In real world number of rows can go up to 3E7, and the number of columns up to 300. Can't really figure out a solution other than

Is “house coloring with three colors” NP?

匆匆过客 提交于 2019-12-03 13:34:23
问题 Consider the problem described here (reproduced below.) Can some better known NP-complete problem be reduced to it? The problem: There are a row of houses. Each house can be painted with three colors: red, blue and green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color. You have to paint the houses with minimum cost. How would you do it? Note: The cost of painting house 1 red is different

What is fixed-parameter tractability? Why is it useful?

限于喜欢 提交于 2019-12-03 03:47:27
问题 Some problems that are NP-hard are also fixed-parameter tractable, or FPT. Wikipedia describes a problem as fixed-parameter tractable if there's an algorithm that solves it in time f(k) · |x| O(1) . What does this mean? Why is this concept useful? 回答1: To begin with, under the assumption that P ≠ NP, there are no polynomial-time, exact algorithms for any NP-hard problem. Although we don't know whether P = NP or P ≠ NP, we don't have any polynomial-time algorithms for any NP-hard problems. The