Linear Program to find line that best fits a set of points
up vote
0
down vote
favorite
Given a set of points $(x1,y1),(x2,y2),...,(xn,yn)$ the following is supposed to be a linear program that finds a line$ $ax+by=c that minimizes $max|ax_i+by_i-c|$.
Let $z=max|ax_i+by_i-c|$
This implies $zge|ax_i+by_i-c|$
or $-zle ax_i+by_i-cle z$
The LP is:
Maximize : -z
subject to:
1) $-z-ax_i-by_i+c le 0$
2) $-z+ax_i+by_i-c le 0$
3) $z,a,b,c ge 0$
I don't understand why this is correct since:
1) the coefficient of z in the objective function is negative which would mean the max value is achieved at $z=0$
2) $a,b,c ge 0$. Rewriting the line as $y=-frac{a}{b}x+c$
we see that this means that we are restricting ourselves to lines of -ve slope.
So, this can't be right either.
I'm looking on clarification on what I'm missing?
linear-programming
add a comment |
up vote
0
down vote
favorite
Given a set of points $(x1,y1),(x2,y2),...,(xn,yn)$ the following is supposed to be a linear program that finds a line$ $ax+by=c that minimizes $max|ax_i+by_i-c|$.
Let $z=max|ax_i+by_i-c|$
This implies $zge|ax_i+by_i-c|$
or $-zle ax_i+by_i-cle z$
The LP is:
Maximize : -z
subject to:
1) $-z-ax_i-by_i+c le 0$
2) $-z+ax_i+by_i-c le 0$
3) $z,a,b,c ge 0$
I don't understand why this is correct since:
1) the coefficient of z in the objective function is negative which would mean the max value is achieved at $z=0$
2) $a,b,c ge 0$. Rewriting the line as $y=-frac{a}{b}x+c$
we see that this means that we are restricting ourselves to lines of -ve slope.
So, this can't be right either.
I'm looking on clarification on what I'm missing?
linear-programming
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Given a set of points $(x1,y1),(x2,y2),...,(xn,yn)$ the following is supposed to be a linear program that finds a line$ $ax+by=c that minimizes $max|ax_i+by_i-c|$.
Let $z=max|ax_i+by_i-c|$
This implies $zge|ax_i+by_i-c|$
or $-zle ax_i+by_i-cle z$
The LP is:
Maximize : -z
subject to:
1) $-z-ax_i-by_i+c le 0$
2) $-z+ax_i+by_i-c le 0$
3) $z,a,b,c ge 0$
I don't understand why this is correct since:
1) the coefficient of z in the objective function is negative which would mean the max value is achieved at $z=0$
2) $a,b,c ge 0$. Rewriting the line as $y=-frac{a}{b}x+c$
we see that this means that we are restricting ourselves to lines of -ve slope.
So, this can't be right either.
I'm looking on clarification on what I'm missing?
linear-programming
Given a set of points $(x1,y1),(x2,y2),...,(xn,yn)$ the following is supposed to be a linear program that finds a line$ $ax+by=c that minimizes $max|ax_i+by_i-c|$.
Let $z=max|ax_i+by_i-c|$
This implies $zge|ax_i+by_i-c|$
or $-zle ax_i+by_i-cle z$
The LP is:
Maximize : -z
subject to:
1) $-z-ax_i-by_i+c le 0$
2) $-z+ax_i+by_i-c le 0$
3) $z,a,b,c ge 0$
I don't understand why this is correct since:
1) the coefficient of z in the objective function is negative which would mean the max value is achieved at $z=0$
2) $a,b,c ge 0$. Rewriting the line as $y=-frac{a}{b}x+c$
we see that this means that we are restricting ourselves to lines of -ve slope.
So, this can't be right either.
I'm looking on clarification on what I'm missing?
linear-programming
linear-programming
edited Nov 17 at 19:57
asked Nov 16 at 22:55
user137481
1,7582920
1,7582920
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
1) $z=0$ is a perfect match, so indeed that is optimal.
2) the part $z,a,b,c=0$ is obviously wrong. You should not constrain these variables (although you could add $zgeq 0$ without changing the formulation), and constraint $b=1$ as a normalization.
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
add a comment |
up vote
1
down vote
Consider the problem of $$max -z$$
where $$-z+1 le 0$$
$$-z-1 le 0$$
$$z ge 0$$
Having the coefficient of $z$ being negative in your constraint doesn't mean that $z=0$. In fact $z=0$ is not feasible for the first costraint. My constraints sets is actually equivalent to $z ge 1$.
Also, there is no sign constraint on $a,b,c$.
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
1) $z=0$ is a perfect match, so indeed that is optimal.
2) the part $z,a,b,c=0$ is obviously wrong. You should not constrain these variables (although you could add $zgeq 0$ without changing the formulation), and constraint $b=1$ as a normalization.
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
add a comment |
up vote
1
down vote
accepted
1) $z=0$ is a perfect match, so indeed that is optimal.
2) the part $z,a,b,c=0$ is obviously wrong. You should not constrain these variables (although you could add $zgeq 0$ without changing the formulation), and constraint $b=1$ as a normalization.
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
1) $z=0$ is a perfect match, so indeed that is optimal.
2) the part $z,a,b,c=0$ is obviously wrong. You should not constrain these variables (although you could add $zgeq 0$ without changing the formulation), and constraint $b=1$ as a normalization.
1) $z=0$ is a perfect match, so indeed that is optimal.
2) the part $z,a,b,c=0$ is obviously wrong. You should not constrain these variables (although you could add $zgeq 0$ without changing the formulation), and constraint $b=1$ as a normalization.
edited Nov 17 at 20:11
answered Nov 17 at 1:52
LinAlg
7,6141520
7,6141520
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
add a comment |
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
Apologies, I made a typo. I meant $z, a, b, c ge 0$. But, $a, b ge 0$ means that we are restricting our solution to lines with -ve slope. That does not sound right.
– user137481
Nov 17 at 3:10
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
As well, given that $z=0$ is already optimal, the LP will simply terminate. In that case, what are the values of $a$ and $b$ that result in $z = 0$?
– user137481
Nov 17 at 3:25
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
@user137481 $z=0$ is probably infeasible, unless you can find a matching pair $(a,b)$.
– LinAlg
Nov 17 at 17:52
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
If I understand you correctly, there should be no non-negativity constraints on $a$ and $c$. However, since the line we are looking for is $ax+by=c$, $b$ must be strictly greater than zero. Could you tell me how we express such a constraint? Thanks.
– user137481
Nov 17 at 20:01
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
@user137481 you cannot have strict inequalities in linear optimization, but you can set $b=1$, since $a$ and $c$ can simply rescale. That also avoids all coefficients from becoming close to $0$ (which in turn reduces $z$).
– LinAlg
Nov 17 at 20:11
add a comment |
up vote
1
down vote
Consider the problem of $$max -z$$
where $$-z+1 le 0$$
$$-z-1 le 0$$
$$z ge 0$$
Having the coefficient of $z$ being negative in your constraint doesn't mean that $z=0$. In fact $z=0$ is not feasible for the first costraint. My constraints sets is actually equivalent to $z ge 1$.
Also, there is no sign constraint on $a,b,c$.
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
add a comment |
up vote
1
down vote
Consider the problem of $$max -z$$
where $$-z+1 le 0$$
$$-z-1 le 0$$
$$z ge 0$$
Having the coefficient of $z$ being negative in your constraint doesn't mean that $z=0$. In fact $z=0$ is not feasible for the first costraint. My constraints sets is actually equivalent to $z ge 1$.
Also, there is no sign constraint on $a,b,c$.
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
add a comment |
up vote
1
down vote
up vote
1
down vote
Consider the problem of $$max -z$$
where $$-z+1 le 0$$
$$-z-1 le 0$$
$$z ge 0$$
Having the coefficient of $z$ being negative in your constraint doesn't mean that $z=0$. In fact $z=0$ is not feasible for the first costraint. My constraints sets is actually equivalent to $z ge 1$.
Also, there is no sign constraint on $a,b,c$.
Consider the problem of $$max -z$$
where $$-z+1 le 0$$
$$-z-1 le 0$$
$$z ge 0$$
Having the coefficient of $z$ being negative in your constraint doesn't mean that $z=0$. In fact $z=0$ is not feasible for the first costraint. My constraints sets is actually equivalent to $z ge 1$.
Also, there is no sign constraint on $a,b,c$.
answered Nov 17 at 3:48
Siong Thye Goh
93.1k1462114
93.1k1462114
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
add a comment |
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
You're right. There should be no sign constraints (i.e. non-negativity constraints) on $a$, $b$ or $c$. However, given that the equation of the line is $ax+by=c$ this means we cannot have $b=0$. Could you tell me how you express such a constraint?
– user137481
Nov 17 at 20:06
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3001736%2flinear-program-to-find-line-that-best-fits-a-set-of-points%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown