 # Problem solving linear program

When I run the .m file second time, it does not execute. I am sorry for my poor English, please look at my picture. my code

the first time I run it. I do some change to my code

``````clear all
clc
c = [30,40,50];
A = [ 6, 8, 9;
9, 6,20;
1, 2, 3];
b = [72,114,20]';
lb = [ 2, 0, 0]';
[x,f,s,e] = glpk (c, A, b, lb);

f
x
``````

Output:

``````glp_simplex: unable to recover undefined or non-optimal solution
f =  NA
x =

NA
NA
NA
``````

My understanding of the question is, why can no solution be found with the given lower bound `lb`.

Therefore look at the given system of constraints `Ax = b` (standard format for glpk).

Matrix `A` has full rank, thus there is only a single point permitted by your constraints

``````>> rank (A)
ans = 3
>> A \ b
ans =

1.8500
3.2250
3.9000
``````

If you now tell glpk to not permit this only possible point with `lb = [ 2, 0, 0]';` then your LP becomes infeasible to solve However, if you define your LP contraints to be fulfilled by inequalities, for example

minimize c^{T}x, subject to Ax \geq b,

``````clear all
clc
c = [30,40,50];
A = [ 6, 8, 9;
9, 6,20;
1, 2, 3];
b = [72,114,20]';
lb = [ 2, 0, 0]';
ub = inf(3,1);
ctype = "LLL";
#vartype = "CCC";
#s = -1;
[x,f,s,e] = glpk (c,A,b,lb,ub,ctype);

f
x
``````

Output:

``````f = 380
x =

2.0000
3.0000
4.0000
``````

Because

``````>> (A*x)'
ans =

72   116    20

>> b'
ans =

72   114    20

>> (A*x)' >= b'
ans =

1  1  1
``````

and the LP problem is feasible again It looks like your script file name is `a.m`. That means you can call it with `a` at the command prompt.
On first execution, the script creates a variable with the name `a`. Variables always shadow scripts or functions. So, when you call `a` the next time, you’ll see the current value of the variable `a`.

Type `clear a` to remove the variable `a` from the current scope. After that, you should be able to call the script `a` again.
But I would recommend, you rename your script file to something different that doesn’t clash with variable names you use.

Thanks for your help, I am a beginner in Operational Research and not familar with GLPK.
This week we studied integral linear programming and we were asked to draw branch with software.

Thanks, it worked