Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
7 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Find all possible combinations subject to a condition?

Posted 9 years ago

Hello! I am trying to find all possible ways to obtain p3[1] from the following list of constraints:

p2[1] = p1[1] + p1[2],

p2[2] = p1[3] + p1[4],

p2[3] = p1[5] + p1[6],

p2[4] = p1[7] + p1[8],

p3[1] = p2[1] + p2[2],

p3[2] = p2[3] + p2[4],

p4[1] = p3[1] + p3[2]

Let's say p3[1] can be written as p2[1]+p2[2], p1[1]+p1[2]+p2[2] and so on... Reduce seems to give me some of it, but I have to put in the quantifiers one by one myself. FrobeniusSolve is similar but only works for actual numbers. Is there a better/programmatic way to obtain all possible expressions equivalent to p3[1]? Thanks a lot!

POSTED BY: Stuart Griffith
7 Replies
POSTED BY: Neil Singer

Stuart,

Just curious -- did this work? did it do what you wanted?

Regards

POSTED BY: Neil Singer

Stuart,

I suspected that the scaling would be a problem with my brute force approach. The number of subsets grows rapidly. I was not sure if you planned on extending this to larger problems. I believe there may be a more intelligent way to get a list of viable subsets of variables. I'll think about that...

Regards

POSTED BY: Neil Singer
POSTED BY: Stuart Griffith

Ok let's use a simplified case as an example.

There are 4 pixels. We can measure them in three ways, bins of 1 (x[1], x[2], x[3], x[4]), bins of 2 (y[1], y[2]) and bins of 4 (z[1]). I want to find all possible way to get y[1]. Here is my code attempting to find the solutions:

Reduce[{y[1] == x[1] + x[2], y[2] == x[3] + x[4], 
  z[1] == x[1] + x[2] + x[3] + x[4]}, {y[1]}]

x[3] == -x[4] + y[2] && x[1] == -x[2] - y[2] + z[1] && 
 y[1] == -y[2] + z[1]

Reduce[{y[1] == x[1] + x[2], y[2] == x[3] + x[4], 
  z[1] == x[1] + x[2] + x[3] + x[4]}, {y[1], y[2]}]

x[1] == -x[2] - x[3] - x[4] + z[1] && y[1] == -x[3] - x[4] + z[1] && 
 y[2] == x[3] + x[4]

So we get these two:

y[1] == -y[2] + z[1]
y[1] == -x[3] - x[4] + z[1]

This seems like a stupid way to do so. Is there anyway to programmatically list all possible ways to get y[1] from other terms? In addition, I would like to extend to the case of higher terms, like 8 pixels having bins of 1,2,4,8, and so on. Can I write a for loop to write those equations?

Thanks in advance!

POSTED BY: Stuart Griffith

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST Please post you code.

POSTED BY: EDITORIAL BOARD

It would be easier to help if you post what you have done.

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard