Question: Optimization routing matrix

I am trying to solve an optimization problem with several constraints and it is not working. The decision variables are the matrix entries.

 

Below is the code:

restart;
interface(displayprecision = 4): with( plots ):
with(linalg):with( Optimization );
[ImportMPS, Interactive, LPSolve, LSSolve, Maximize, Minimize,

NLPSolve, QPSolve]
f:=proc(x1,x2,x3,x4,x5,x6)
global lambda,mu,rho,Ls;
local eq,Lsq,g,P,n,IM,ImP,ImPi,c0,cb,Sol,i,j,t1,t2,fact,t3,t4,t5,Wq,W,Lq,L,Ws;
n:=7;
g:=array(1..n,[5,0,0,0,0,0,0]);
mu:=array(1..n,[10,5,5,5,5,5,5]);
P:=matrix([[0,x1,x2,0,0,0,0],[0,0,0,x3,x4,0,0],[0,0,0,0,0,x5,x6],
[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]]);
IM := array(identity, 1..n,1..n):
ImP:=evalm(IM-P):
ImPi:=inverse(ImP):
lambda:=evalm(g&*ImPi):
for i from 1 to n do
rho[i] := lambda[i]/mu[i]
od:
c0:=array(1..n,[1/2,0,0,0,0,0,0]);
cb:=array(1..n,[1/5,1/5,1/5,1/5,1/5,1/5,1/5]);
for i from 1 to n do
eq[i]:=(g[i]/lambda[i])*c0[i] + sum((lambda[j]/lambda[i])*P[j,i]*((P[j,i]*(rho[j]^2*cb[j] +(1-rho[j]^2)*cx[j] ))+ (1 -P[j,i])),j=1..n)
od:
Sol:=fsolve({eq[1]-cx[1]=0,eq[2]-cx[2]=0,eq[3]-cx[3]=0,eq[4]-cx[4]=0,eq[5]-cx[5]=0,eq[6]-cx[6]=0,eq[7]-cx[7]=0},{cx[1],cx[2],cx[3],cx[4],cx[5],cx[6],cx[7]}):
assign(Sol):cx:
for i from 1 to n do
t1:= -2*(1-rho[i])/(3*rho[i]):
t2:= ((1-cx[i])^2)/(cx[i]+cb[i]):
fact := exp(t1*t2):
if cx[i] >= 1 then
fact:=1:
else
fact:
fi:
t3:=rho[i]/(1-rho[i]):
t4:= (cx[i]+ cb[i])/2:
t5:=1/mu[i]:
Wq[i] := (t3*t4*t5*fact):
W[i] := Wq[i] + t5:
Lq[i] := lambda[i]*Wq[i]:
L[i] := lambda[i]*W[i]:
od:
Ls:=add(L[i],i=1..n);Lsq:=add(Lq[i],i=1..n):Ws:=Ls/add(g[i],i=1..n):
RETURN(Ls):
end proc:

# here are the constraint procedures to ensure the probability pairs sum to one

p1 := proc (x1, x2) x1+x2-1 end proc;
proc(x1, x2) ... end;
p2 := proc (x3, x4) x3+x4-1 end proc;
proc(x3, x4) ... end;
p3 := proc (x5, x6) x5+x6-1 end proc;
proc(x5, x6) ... end;

sol := Optimization:-NLPSolve(f, {p1}, {p2}, {p3}, 0 .. 1, 0 .. 1, 0 .. 1, 0 .. 1, 0 .. 1, 0 .. 1, initialpoint = [.5, .5, .5, .5, .5, .5]);


Error, (in Optimization:-NLPSolve) unexpected parameters: {p3}

It seems to say that the problem are the constraints but this seems odd.

 

 

Please Wait...