Skip to main content
Commonmark migration
Source Link

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

###Edit:

Edit:

I had trouble finding a small example that wasn't trivial, but I finally did. Here's one:

Solve[{{-1 + Abs[q2 (-(7/4) + t1)], q1, -1 + Abs[q1 (-(7/4) + t2)], 3 + q2} == 0,
       {t1, t2} >= 7/4},
      {t1, t2, q1, q2}]

The kind of output that I want (I don't care if it's not unique; I can deal with that):

{{t1 -> 25/12, t2 -> Indeterminate, q1 -> 0, q2 -> -3}}

The output that I get, but don't want:

{}

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

###Edit:

I had trouble finding a small example that wasn't trivial, but I finally did. Here's one:

Solve[{{-1 + Abs[q2 (-(7/4) + t1)], q1, -1 + Abs[q1 (-(7/4) + t2)], 3 + q2} == 0,
       {t1, t2} >= 7/4},
      {t1, t2, q1, q2}]

The kind of output that I want (I don't care if it's not unique; I can deal with that):

{{t1 -> 25/12, t2 -> Indeterminate, q1 -> 0, q2 -> -3}}

The output that I get, but don't want:

{}

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

Edit:

I had trouble finding a small example that wasn't trivial, but I finally did. Here's one:

Solve[{{-1 + Abs[q2 (-(7/4) + t1)], q1, -1 + Abs[q1 (-(7/4) + t2)], 3 + q2} == 0,
       {t1, t2} >= 7/4},
      {t1, t2, q1, q2}]

The kind of output that I want (I don't care if it's not unique; I can deal with that):

{{t1 -> 25/12, t2 -> Indeterminate, q1 -> 0, q2 -> -3}}

The output that I get, but don't want:

{}
Post Reopened by Mr.Wizard
added 113 characters in body
Source Link
user541686
  • 1.3k
  • 7
  • 19

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

Right now I'm reformulating the problem as an optimization problem and using ArgMin to minimize the norm of the error vector###Edit:

I had trouble finding a small example that wasn't trivial, but I'm wonderingI finally did. Here's one:

Solve[{{-1 + Abs[q2 (-(7/4) + t1)], q1, -1 + Abs[q1 (-(7/4) + t2)], 3 + q2} == 0,
       {t1, t2} >= 7/4},
      {t1, t2, q1, q2}]

The kind of output that I want (I don't care if there is a faster/better way, sinceit's not unique; I imaginecan deal with that):

{{t1 -> 25/12, t2 -> Indeterminate, q1 -> 0, q2 -> -3}}

The output that I Solve is presumably already doing some of the required work regardlessget, andbut ArgMin is a bit overkill and too slow.don't want:

{}

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

Right now I'm reformulating the problem as an optimization problem and using ArgMin to minimize the norm of the error vector, but I'm wondering if there is a faster/better way, since I imagine Solve is presumably already doing some of the required work regardless, and ArgMin is a bit overkill and too slow.

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

###Edit:

I had trouble finding a small example that wasn't trivial, but I finally did. Here's one:

Solve[{{-1 + Abs[q2 (-(7/4) + t1)], q1, -1 + Abs[q1 (-(7/4) + t2)], 3 + q2} == 0,
       {t1, t2} >= 7/4},
      {t1, t2, q1, q2}]

The kind of output that I want (I don't care if it's not unique; I can deal with that):

{{t1 -> 25/12, t2 -> Indeterminate, q1 -> 0, q2 -> -3}}

The output that I get, but don't want:

{}
Post Closed as "Not suitable for this site" by Daniel Lichtblau, MarcoB, user9660, RunnyKine, Öskå
Source Link
user541686
  • 1.3k
  • 7
  • 19

How to tell Solve[] to satisfy as many constraints as it can?

Is there any way to tell Solve (or something similar) to return values for variables that solved as many constraints as it happened to satisfy?

Right now I'm reformulating the problem as an optimization problem and using ArgMin to minimize the norm of the error vector, but I'm wondering if there is a faster/better way, since I imagine Solve is presumably already doing some of the required work regardless, and ArgMin is a bit overkill and too slow.