Minggu, 03 Juli 2011

Linear programming

Linear programming (LP, or linear optimization) is a mathematical method for determining a way to achieve the best outcome (such as maximum profit or lowest cost) in a given mathematical model for some list of requirements represented as linear relationships. Linear programming is a specific case of mathematical programming (mathematical optimization).

More formally, linear programming is a technique for the optimization of a linear objective function, subject to linear equality and linear inequality constraints. Its feasible region is a convex polyhedron, which is a set defined as the intersection of finitely many half spaces, each of which is defined by a linear inequality. Its objective function is a real-valued affine function defined on this polyhedron. A linear programming algorithm finds a point in the polyhedron where this function has the smallest (or largest) value if such point exists.

Linear programs are problems that can be expressed in canonical form:


where x represents the vector of variables (to be determined), c and b are vectors of (known) coefficients and A is a (known) matrix of coefficients. The expression to be maximized or minimized is called the objective function (cTx in this case). The equations Ax ≤ b are the constraints which specify a convex polytope over which the objective function is to be optimized. (In this context, two vectors are comparable when every entry in one is less-than or equal-to the corresponding entry in the other. Otherwise, they are incomparable.)

Linear programming can be applied to various fields of study. It is used most extensively in business and economics, but can also be utilized for some engineering problems. Industries that use linear programming models include transportation, energy, telecommunications, and manufacturing. It has proved useful in modeling diverse types of problems in planning, routing, scheduling, assignment, and design.

Standard form is the usual and most intuitive form of describing a linear programming problem. It consists of the following four parts:
A linear function to be maximized
e.g.
Problem constraints of the following form
e.g.

Non-negative variables
e.g.

Non-negative right hand side constants


The problem is usually expressed in matrix form, and then becomes:


Other forms, such as minimization problems, problems with constraints on alternative forms, as well as problems involving negative variables can always be rewritten into an equivalent problem in standard form.

#include <stdio.h>
#include <math.h>

float a, c, b, F_a, F_c, F_b, tol;
int max_iter;
float f(float x)
{
return ((x*x)*x) + (x*x)- (3*x) – 3;
}

void main ()
{
int it;
float epsilon;
printf(” METODE REGULASI FALSI”);
printf(“\n”);
printf(“Contoh Soal\n”);
printf(“3*x*x – 2*x – 5 \n\n”);
printf(“Masukkan Batas Bawah :”);
scanf(“%f”,&a);
printf(“Masukkan Batas Atas :”);
scanf(“%f”,&b);
printf(“Masukkan Toleransi Error :”);
scanf(“%f”,&tol);

it = 0;
F_a = f(a);
F_b = f(b);
if(F_a * F_b > 0) printf(” Nilai F(a) x F(b) > 0\n”);
else
{
printf(“\n”);
printf(” I a f(a) b f(b) c f(c)\n\n”);
do
{
it = it +1;
c = a – F_a * (b-a) / (F_b – F_a);
F_c = f(c);
printf(“%2d %7.5f %7.5f %7.5f %7.5f %7.5f %7.2e\n\n”,it, a, F_a, b, F_b, c,fabs(F_b-F_a)/2);
epsilon = fabs(c-a);
if(F_a * F_c <=0){ b = c; F_b = F_c; }
else
{
a=c;
F_a=F_c;
}
}

while(epsilon > tol);
if(epsilon <=tol)
{
printf(“\n”);
printf(“\n”);
printf(“Toleransi terpenuhi\n”);
printf(“\n”);
printf(“Hasil akhir=%g\n\n\n”,c);

}

else
printf(“Toleransi tidak terpenuhi\n”);
}

}

Tidak ada komentar:

Posting Komentar