Integer Linear Programming
>A:=[10,8;9,11]; A:=1/A;
>b:=ones(rows(A),1);
>x:=0:0.1:15; y:=(b-A[:,1]*x)/A[:,2];
>plot2d(x,y,a=0,b=20,c=0,d=20); insimg;

>xa:=feasibleArea(A,b); ...
>plot2d(xa[1],xa[2],filled=1,style="/",outline=1,add=1); insimg(antialiased=0);

>c:=[1,1]
[ 1 1 ]
>e:=-ones(size(b))
-1
-1
>{xs1,r,i}:=simplex(A,b,c,e,max=1); xs1,
7.10526315789
2.31578947368
>fracprint(xs1);
135/19
44/19
>intsimplex(A,b,c,max=1)
9
0
>intsimplex(A,b,c,i=[2],max=1)
7.36363636364
2
>load incidence
Functions to create incidence matix for a graph, and
to solve resistance potential in a graph. For a demo
load the Resitance.en notebook.
For more information use "help incidence.e" or see the
user menu.
>n:=6; M:=id(n*n)+makeRectangleIncidence(n,n);
>A:=M_id(n*n);
>b:=ones(rows(A),1);
>c:=ones(1,cols(A));
>e:=-ones(rows(A),1);
>xs1:=intsimplex(A,b,c,max=1);
>format(4,0); (redim(xs1',[n,n])), longformat;
1 0 0 1 0 0
0 0 0 0 0 1
0 1 0 0 0 0
0 0 0 1 0 0
1 0 0 0 0 1
0 0 1 0 0 0
>size(b)
[ 72 1 ]
>load lpsolve
LPSOLVE package (ported by Peter Notebaert), and ilpsolve() routine.
The full documentation is available on
http://lpsolve.sourceforge.net/5.5/Euler.htm
>n:=12; M:=id(n*n)+makeRectangleIncidence(n,n); ...
>A:=M_id(n*n); ...
>b:=ones(rows(A),1); ...
>c:=ones(1,cols(A)); ...
>e:=-ones(rows(A),1); ...
>xs1:=ilpsolve(A,b,c,e,max=1); ...
>format(4,0); (redim(xs1',[n,n])), longformat;
1 0 0 1 0 0 1 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 1
0 1 0 0 1 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0
1 0 0 1 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 0 1 0 0 0
0 1 0 0 1 0 0 0 0 0 1 0
0 0 0 0 0 0 1 0 0 0 0 0
1 0 0 1 0 0 0 0 1 0 0 1
0 0 0 0 0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 1 0 0
1 0 0 0 1 0 0 1 0 0 0 1
>x=random(100,1); y=random(100,1);
>d=1/100; M=random(100,100)<d; M=max(M,M'); M=setdiag(M,0,1);
>{xc,yc}=getGraph(x|y,M); ...
>plot2d(x,y,a=0,b=1,c=0,d=1,points=true); plot2d(xc,yc,add=true); ...
>insimg;

>A:=M_id(100); ...
>b:=ones(rows(A),1); ...
>c:=ones(1,cols(A)); ...
>e:=-ones(rows(A),1); ...
>xs1:=ilpsolve(A,b,c,e,max=1);
>i=nonzeros(xs1'); ...
>plot2d(x[i],y[i],a=0,b=1,c=0,d=1,points=true,color=red,style="[]#",add=true); ...
>insimg;

Examples Homepage