j. smith

15 Reputation

2 Badges

20 years, 192 days

MaplePrimes Activity


These are questions asked by

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.

 

 

I am trying to find the optimal routing probabilities in a Maple procedure where the Mean Value Analysis is used to compute the queueing values. The Maple code is below. It first tries to compute the visit ratios where the probability routing values are the decision variables. There is one specified constraint on the sum of the probability decision variables.

 

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

NLPSolve, QPSolve]
f:=proc(x1,x2,x3)
global T,lambda,nq,u;
local i,j,pop,Sum;
n:=3;N:=2;M:=3;
#
# Gauss-Seidel iterations
#
A:=Matrix([[1,-x1,-x2],[0,1,-x3],[0,0,1]]);
b:= Vector([1,0,0]);
v := IterativeApproximate(LinearAlgebra:-Transpose(A), b, initialapprox = Vector([1, 3/4, 3/4]), tolerance = 10^(-3), maxiterations = 20, stoppingcriterion = relative(infinity), method = gaussseidel);
mu:=array(1..n,[2.0,1.0,1.0]);
nq:=array(1..M,[0,0,0]);# must initialize queue lengths
for i from 1 to N do

pop:=i;
for j from 1 to M do # mean waiting times
T[j]:=t[j]*(1 + nq[j]) od;
Sum := 0.0;
for j from 1 to M do # mean cycle time
Sum := Sum + v[j]*T[j] od;
for j from 1 to M do #compute the throughputs
lambda[j] := (v[j]*pop)/Sum od;
for j from 1 to M do #compute the queue lengths
nq[j]:= lambda[j]*T[j] od;
for j from 1 to M do #compute the utilizations
u[j]:= lambda[j]*t[j] od;
od;
RETURN(lambda[1]);
end proc;


proc(x1, x2, x3) ... end;

 

sol := Optimization:-NLPSolve(f, {}, {proc (x1, x2, x3) options operator, arrow; x1+x2+x3-5/3 end proc}, 0 .. 1, 0 .. 1, 0 .. 1, initialpoint = [.75, .25, .6667], assume = nonnegative); 1;


Error, (in Optimization:-NLPSolve) non-numeric result encountered

 

I am not sure why I get the error message

 

 

I am trying to solve a matrix system to find the relative arrival rates of a queueing network using Gauss-Seidel.The maple commands are below:

restart;
with(Student[NumericalAnalysis]); with(LinearAlgebra);

A := Matrix([[1, -.333, -.333, -.333], [0, 1, -.333, -.333], [0, -.333, 1, -.333], [0, -.333, -.333, 1]]);

IsDefinite(A, 'query' = 'positive_semidefinite');

true

b := Vector([1, 1, 1, 1]);


IterativeApproximate(A, initialapprox = Vector([1, 1, 1, 1]), tolerance = 10^(-3), maxiterations = 20, stoppingcriterion = relative(infinity), method = gaussseidel);


Error, (in Student:-NumericalAnalysis:-IterativeApproximate) check that the augmented matrix has the correct dimensions

I do not understand this error as the matrix is 4x4 as shown. Can anyone see where I went wrong?

 

I am trying to solve an optimization problem but I am getting an error message which does not make sense.

 

I have a procedure file called f. The decsiion vector is x[1..4]. and returns the objective function value Ls.

I then specify the constraints as a set and ask it to optimize

constraints:={x[1]+x[2]+x[3]+x[4]=65,x[1]<=20,x[2]<=15,x[3]<=20,x[4]<=15};

sol := NLPSolve( f,constraints, assume=nonnegative,minimize);

Error, (in Optimization:-NLPSolve) constraints must be specified as a set or list of procedures

 

This error makes no sense to me. Can anyone help?

Page 1 of 1