Message Boards Message Boards

0
|
8872 Views
|
7 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Solve system of linear Diophantine equations with conditions

Posted 9 years ago

Hi everyone, I would like to ask your help in the following problem, I want to find nonnegative solutions for a system of linear Diophantine equations using some conditions on the constant terms. For example, in the following linear system the variables are $x,y_1,y_2,z_1,z_2,w$, and $n,a,b,c_1,c_2$ are nonnegative integers: $$x+w =a $$

$$ y_1+y_2+nw=b$$

$$y_1+w-z_1=c_1$$

$$y_2+w-z_2=c_2$$

and we have the next conditions for the constants: $$0\leq b-an, \;\; 0\leq a-c_1, \;\; 0\leq a-c_2, \;\; \mbox{and} \;\; 0\leq b-c_1-c_2.$$ I tried to use FindInstance[ ] but I had mistakes even if I don't try to write the conditions for the integers $n,a,b,c_1,c_2$:

FindInstance[ x + w == a && y1 + y2 + n w == b && y1 + w - z1 == c1 && y2 + w - z2 == c2 && 0 <= x && 0 <= y1 && 0 <= y2 && 0 <= w && 0 <= z1 && 0 <= z2, {x, y1, y2, w, z1, z2}, Integers]

FindInstance::exvar: "The system contains a nonconstant expression a independent of variables {x,y1,y2,w,z1,z2}"

If I try to add the conditions for the constants, then I obtain the same mistake.

Thanks.

POSTED BY: Juan Frias
7 Replies

Seems to me you are trying to use FindInstance to find a symbolic instance. I don't think it does that.

POSTED BY: Frank Kampas
Posted 9 years ago

Thank you for your comment, I didn't know Thread. That was a problem with FindInstance, such constraints for the constants made the mistake. I just try with Thread before FindInstance and the mistake remains, but before Solve and considering only the linear system everything works fine. Indeed, I didn't use SetAttributes and requiring integer solutions, in the conditional expression obtained appears the hypothesis that $a,b,c_1,c_2,n$ are integer numbers.

POSTED BY: Juan Frias
Posted 9 years ago

Hi. I think you are missing some constraints.

const = Thread[ {a, b, n, c1, c2, b - a*n, a - c1, a - c2, b - c1 - c2} >= 0 ]
POSTED BY: Dana DeLouis
Posted 9 years ago

Sure, I attached the notebook. I'm sorry, I got lost among all the calculations and attempts that I did: Solve works if I write the conditions for the constants, and in the solution some of them has assigned values in terms of other constants.

Now, I am trying to obtain a solution using the conditions for the constants and the condition that the solution is nonnegative.

Attachments:
POSTED BY: Juan Frias

That's interesting. Could you attach your notebook? I'd like to see exactly how that worked.

POSTED BY: Frank Kampas
Posted 9 years ago

Thank you for your comment. I obtain the following using Solve: If I try to write the conditions on the constant I obtain the same mistake as in FindInstance. Now, if I don't write the conditions for the constants, then I obtain a solution but some of the constants $n,a,b,c_1, c_2$ has assigned values. However, using SetAttributes[{n,a,b,c1,c2}, Constant] and only writting the conditions for the constants, the mistake was fixed and I obtain conditional expressions in terms of $n,a,b,c_1,c_2$.

Edit: Solve works writing only the conditions for the constants, and in the solution some of them has assigned values in terms of other constants.

POSTED BY: Juan Frias

I think it's complaining about b, c1 and c2, which are not variables or numbers. Since your equations are all linear, try Solve or Reduce.

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

Group Abstract Group Abstract