Finding the smallest solution set, if one exists (n multipliers)

流过昼夜 提交于 2019-12-08 13:23:44

问题


Note: This is the n-multipliers variation of this problem.

Given a set A, consisting of decimal values between 0.0 and 1.0, find the set B, such that each b in B is a set consisting of decimal values between 0.0 and 1.0, such that for each a in A, there is a set of unique values where a is the product of a subset of elements in B.

For example, given

$ A = [0.125, 0.25, 0.5, 0.75, 0.9]

A possible (but probably not smallest) solution for B is

$ B = solve(A)
$ print(B)
[[0.25, 0.5, 0.75, 0.9], [etc.], [etc.]]

This satisfies the initial problem, because A[0] == B[0] * B[1], A[1] == B[1], etc., which allows us to recreate the original set A. The length of B is smaller than that of A, but I’m guessing there are smaller answers as well. However, assuming that B could not be reduced beyond 4 values, the correct solution to this problem would be a set of solutions.

I assume that the solution space for B is large, if not infinite. If a solution exists, how would a smallest set B be found?


Notes:

  • This appears to fit nicely into a constraint satisfaction problem, but I've been unable to figure out how it would be formatted.
  • We're not limited by the values in A. B can consist of any set of values, whether or not they exist in A.
  • There's no limit that only two values from B can be used. If you had A = [0.125, 0.25, 0.5, 1.0], then a valid answer for B could be [0.5, 1.0]. Meaning, A == [ B[0]*B[0]*B[0], B[0]*B[0], B[0]*B[1], B[1]*B[1] ]
  • Since floating point math is generally problematic, rational numbers are probably a good idea.
  • The lower limit of solutions in B would be |B| ≥ log2(|A| + 1) since we can have at most 2^|B| - 1 non-empty subsets of B. (Credit to גלעד ברקן for this.)

来源:https://stackoverflow.com/questions/56909614/finding-the-smallest-solution-set-if-one-exists-n-multipliers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!