Items tagged with constraint constraint Tagged Items Feed

I have a linear problem with 4 variables (p0, p1,p2, p3) and a list of inequality constraints (shown below).  I would like to plot a polyhedral in 3 dimensions (p1,p2, p3 and omitting p0) showing the region that satisfies the inequalities.  That is, something similar to plots[inequal] but in 3d.  Any pointers would be appreciated.

/* Constraints */
+p0 <= 60;
-p0 +p1 >= 4;
-p0 +p2 >= 5;
-p0 +p3 >= -12;
+p0 -p2 >= -33;
+p1 -p2 >= -36;
+p2 <= 67;
-p2 +p3 >= -35;
+p0 -p3 >= 2;
+p1 -p3 >= 0;
+p2 -p3 >= 11;
+p3 <= 57;
+p0 -p1 >= -7;
+p1 <= 43;
-p1 +p2 >= 0;
-p1 +p3 >= -9;

 

Hi all,

Hope all to be in good health.

I have written following program to obtain minimum  under som constraints but it doesn't work due to some unknown error.

can any one help me?

Program1.mws

 

best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

Hello, 

     I an trying to plot a function of a single variable, which is an implicit function of another variable, i.e. I want to plot F(x(t)), given that x and t are related through the implicit constraint equation f(x,t) = 0. Is there any plot stuctures in Maple that would easily let me do this? I tried implicit plot but this seems insufficient. 

     As an example, consider plotting F = x + x^2 subject to f = x + sin(x) + ln (t) = 0. I could also write this as  a function subject o a differential constraint, as is f = diff(x(t), t) + 1/t + (diff(x(t), t))*cos(x(t)) = 0 and try to use some sort of implicit DE plotting routine. 

     Any ideas?

Thanks!

I've got a set

E:={(x,y,z): x^2+y^2=-2*z-x, z^2+y^2=1} and need to find points of E which have minimal or maximal distance from (0,0,0). I've set up the Lagrangian as F:=sqrt(x^2+y^2+z^2) + L1(x^2+y^2+2z+x)+L2(z^2+y^2-1)

and consequently obtained the equations:

x/sqrt(x^2+y^2+z^2) + 2*x*L1+L1=0

y/sqrt(x^2+y^2+z^2) + 2*y*L1+2*y*L2=0

z/sqrt(x^2+y^2+z^2)+2*L1+2*L2*z=0

for which I've set up
eqn1,eqn2,eqn3 as the three equations and vars:=x,y,z

and used solve() but I'm not getting the right answer( I need to first express x,y,z in terms of L1, L2 and then get values for L1 and L2 by substituting in the constraints and eventually get values of x,y,z.)

How should I implement that?

Hi all,

I have lots of contstraint equations group and I want to fund a group of parameters which can fit them. 

For example, these are a simple constraint eqqations group:
eqs:{x1>0, x2>0 x1<1000, x2<1000, x1+x2>300,x1+x2<700}

Through SolveTools library, I can determine whether there is a group of parameters.


with(SolveTools[Inequality]);

LinearMultivariateSystem({x1 > 0, x1+x2 > 300, x2 < 1000, x1+x2 < 700, x2 > 0*x1 and 0*x1 < 1000}, [x1, x2]);

{[{x1 <= 300, 0 < x1}, {x2 < -x1 + 700, 300 - x1 < x2}],[{300 < x1, x1 < 700}, {0 < x2, x2 < -x1 + 700}]}

 

Then, if I want to find a group of parameter a group of parameters (ex, x1=300, x2=200 in this case), how should I do?

Hello,

      I would like to solve a system of 9 nonlinear equations, with the constraints on all 9 variables to be that they are nonnegative. How can I do this?

My code is below - I am trying NLPSolve and have tried solve, but am getting stuck.

with(Optimization);

restart; eq1 := 531062-S/(70*365)-(.187*(1/365))*(H+C+C1+C2)*S/N = 0;eq2 := (4/365*(T+C))*S/N-(.187*(1/365))*(H+C+C1+C2)*T/N-(1/(70*365)+1/(5*365))*T = 0; eq3 := (.187*(1/365))*(H+C+C1+C2)*S/N-(4/365)(T+C)*H/N-(1/(70*365)+1/(4*365))*H = 0; eq4 := (.187*(1/365))*(H+C+C1+C2)*T/N+(4/365*(T+C))*H/N-(1/(70*365)+3/(8*365)+.2*(1/365)+.1)*C = 0; eq5 := .1*C-(1/(70*365)+1/(4*365)+1/60+.5)*C1 = 0; eq6 := (1/60)*C1-(1/(70*365)+1/(4*365)+1/210+.5)*C2 = 0; eq7 := .5*C1-(1/(70*365)+1/60+0.1e-2)*CT1 = 0; eq8 := .5*C2-(1/(70*365)+1/210+(1/9)*(0.1e-2*7))*CT2+(1/60)*CT1 = 0; eq9 := N-S-T-H-C-C1-C2-CT1-CT2 = 0; soln := NLPSolve({eq1, eq2, eq3, eq4, eq5, eq6, eq7, eq8, eq9}, {C, C1, C2, CT1, CT2, H, N, S, T}, assume = nonnegative);

Hi,

On page 32 (PDF)

 

Two different results were obtained using the Global optimization.

Log likelihood does not differ much. BUT the estimates vary a lot, such as mu[p].

tmp.mw

tmp.pdf

 

When I tried to use one of the answer from a particular run, I get the HFLOATING error, see picture.

So how reliable is this? Could there be a better way to optimize this ?

 

Thanks!

 

As an additional note, if I have Matlab R2014a, could I use Matlab to optimize the target function? DO I need to purchase a seperate addon?

 

Hi all 

I have the following segment of maple program which belongs to time delay systems dynamic. here C=X-X0-G.Z-X.Dtau.P+X.Dtau.Z-U.P, is a matrix(vector) which comes from reordering the system terms and my goal is to minimizing J:=X.E.Transpose(X)+U.E.Transpose(U), subject to constraint C=0, but i don't know how to do so.

I will be so grateful if anyone can guide me

best wishes

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department


restart:
with(Optimization):
with(LinearAlgebra):
macro(LA= LinearAlgebra):
L:=1:  r:=2:  tau:= 1:
interface(rtablesize= 2*r+1):

Z:= Matrix(
     2*r+1, 2*r+1,
     [tau,
      seq(evalf((L/(2*(iz-1)*Pi))*sin(2*(iz-1)*Pi*tau/L)), iz= 2..r+1),
      seq(evalf((L/(2*(iz-1-r)*Pi))*(1-cos(2*(iz-1-r)*Pi*tau/L))), iz= r+2..2*r+1)
      ],
     scan= columns,
     datatype= float[8]
);
                        
Dtau00:= < 1 >:
Dtau01:= Vector[row](r):
Dtau02:= Vector[row](r):
Dtau10:= Vector(r):
Dtau20:= Vector(r):

Dtau1:= LA:-DiagonalMatrix([seq(evalf(cos(2*i*Pi*tau/L)), i= 1..r)]):
Dtau2:= LA:-DiagonalMatrix([seq(evalf(sin(2*i*Pi*tau/L)), i= 1..r)]):
Dtau3:= -Dtau2:
Dtau4:= copy(Dtau1):

Dtau:= < < Dtau00 | Dtau01 | Dtau02 >,
         < Dtau10 | Dtau1  | Dtau2  >,
         < Dtau20 | Dtau3  | Dtau4  > >;
 
P00:= < L/2 >:
P01:= Vector[row](r):
P02:= Vector[row](r, j-> evalf(-L/j/Pi), datatype= float[8]):
P10:= Vector(r):
P20:= Vector(r, i-> evalf(L/2/i/Pi)):
P1:= Matrix(r,r):
P2:= LA:-DiagonalMatrix(P20):
P3:= LA:-DiagonalMatrix(-P20):
P4:= Matrix(r,r):

P:= < < P00 | P01 | P02 >,
      < P10 | P1  | P2  >,
      < P20 | P3  | P4  > >;

interface(rtablesize=2*r+1):    # optionally
J:=Vector([L, L/2 $ 2*r]):      # Matrix([[...]]) would also work here

E:=DiagonalMatrix(J);

X:=  Vector[row](2*r+1,symbol=a);
U:=Vector[row](2*r+1,symbol=b);

X0:= Vector[row](2*r+1,[1]);
G:=Vector[row](2*r+1,[1]);
C:=simplify(X-X0-G.Z-X.Dtau.P+X.Dtau.Z-U.P);

Z := Matrix(5, 5, {(1, 1) = 1., (1, 2) = 0., (1, 3) = 0., (1, 4) = 0., (1, 5) = 0., (2, 1) = 0., (2, 2) = 0., (2, 3) = 0., (2, 4) = 0., (2, 5) = 0., (3, 1) = 0., (3, 2) = 0., (3, 3) = 0., (3, 4) = 0., (3, 5) = 0., (4, 1) = 0., (4, 2) = 0., (4, 3) = 0., (4, 4) = 0., (4, 5) = 0., (5, 1) = 0., (5, 2) = 0., (5, 3) = 0., (5, 4) = 0., (5, 5) = 0.})

Dtau := Matrix(5, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 0, (2, 2) = 1., (2, 3) = 0, (2, 4) = 0., (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1., (3, 4) = 0, (3, 5) = 0., (4, 1) = 0, (4, 2) = -0., (4, 3) = -0., (4, 4) = 1., (4, 5) = 0, (5, 1) = 0, (5, 2) = -0., (5, 3) = -0., (5, 4) = 0, (5, 5) = 1.})

P := Matrix(5, 5, {(1, 1) = 1/2, (1, 2) = 0, (1, 3) = 0, (1, 4) = -.318309886100000, (1, 5) = -.159154943000000, (2, 1) = 0, (2, 2) = 0, (2, 3) = 0, (2, 4) = .1591549430, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (3, 5) = 0.7957747152e-1, (4, 1) = .1591549430, (4, 2) = -.159154943000000, (4, 3) = 0, (4, 4) = 0, (4, 5) = 0, (5, 1) = 0.7957747152e-1, (5, 2) = 0, (5, 3) = -0.795774715200000e-1, (5, 4) = 0, (5, 5) = 0})

E := Matrix(5, 5, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = 0, (2, 2) = 1/2, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1/2, (3, 4) = 0, (3, 5) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1/2, (4, 5) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 1/2})

X := Vector[row](5, {(1) = a[1], (2) = a[2], (3) = a[3], (4) = a[4], (5) = a[5]})

U := Vector[row](5, {(1) = b[1], (2) = b[2], (3) = b[3], (4) = b[4], (5) = b[5]})

X0 := Vector[row](5, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

G := Vector[row](5, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0})

C := Vector[row](5, {(1) = 1.500000000*a[1]-2.-.1591549430*a[4]-0.7957747152e-1*a[5]-.5000000000*b[1]-.1591549430*b[4]-0.7957747152e-1*b[5], (2) = a[2]+.1591549430*a[4]+.1591549430*b[4], (3) = a[3]+0.7957747152e-1*a[5]+0.7957747152e-1*b[5], (4) = a[4]+.3183098861*a[1]-.1591549430*a[2]+.3183098861*b[1]-.1591549430*b[2], (5) = a[5]+.1591549430*a[1]-0.7957747152e-1*a[3]+.1591549430*b[1]-0.7957747152e-1*b[3]})

(1)

J:=X.E.Transpose(X)+U.E.Transpose(U);

J := a[1]^2+(1/2)*(a[2]^2)+(1/2)*(a[3]^2)+(1/2)*(a[4]^2)+(1/2)*(a[5]^2)+b[1]^2+(1/2)*(b[2]^2)+(1/2)*(b[3]^2)+(1/2)*(b[4]^2)+(1/2)*(b[5]^2)

(2)

Minimize(J,{C=0});






Error, (in Optimization:-NLPSolve) invalid arguments

 

#XP:=-.015+X[1]+add(X[l+1]*f1(l)+X[r+l+1]*f2(l), l= 1..r):
#plot([XP,T1], t= 0..1);#,legend= "Solution Of x(t) with r=50"):

 

 

 

 

 

 

Download work1.mwswork1.mws

Hi all

In matlab software we have a command namely fmincon which minimizes any linear/nonlinear algebric equations subject to linear/nonlinear constraints.

Now my question is that: what is the same command in maple?or how can we minimize linear/nonlinear function subject to linear/nonlinear constraints in maple?

thanks a lot

Mahmood   Dadkhah

Ph.D Candidate

Applied Mathematics Department

I need to maximize two multivariate objective functions (f(x1,y1,z1,t1) and g(x2,y2,z2,t2)) with inequality and nonnegativity constraints (x1, x2>0 and y1, z1, t1, y2, z2, t2 >=0). I am looking for parametric not numerical solutions.


What is the best way to find the solution to such a problem using maple?

Birthday_LP.mw

I am attempting to solve the following using C.Loves Logicproblem package. But i do not know how to tell it either/or constaints. being a circular arrangement might also throw a spanner in the works.

Alans Birthday Logic Problem

It is Alan’s birthday and he is having a party. Seven other people will attend: Amy, Brad, Beth, Charles, Debbie, Emily and Frances.

Everyone will sit around the circular dining table. The seating arrangement must meet the following conditions:

• Amy and Alan sit together

• Brad and Beth sit together

• Charles sits next to either Debbie or Emily

• Frances sits next to Debbie

• Amy and Alan do not sit next to either Brad or Beth

• Brad does not sit next to Charles or Frances

• Debbie and Emily do not sit next to each other

• Alan does not sit next to either Debbie or Emily

• Amy does not sit next to Charles

Arrange the guests around the table to meet all of the conditions listed above.

restart:

Vars:= [Name,PN]:

Name:= [Alan,Amy, Brad, Beth, Charles, Debbie, Emily,Frances]:

PN:=[$1..8]:

Cons:= [NextTo(Amy,Alan,PN),NextTo(Brad,Beth,PN),NextTo(Charles,Debbie,PN),NextTo(Charl es,Emily,PN),NextTo(Frances,Debbie,PN),Rel(NotNextTo,Amy,Brad,PN),Rel(NotNextTo, Amy,Beth,PN),Rel(NotNextTo,Alan,Brad,PN),Rel(NotNextTo,Alan,Beth,PN),Rel(NotNext To,Brad,Charles,PN),Rel(NotNextTo,Brad,Frances,PN),

Rel(NotNextTo,Debbie,Emily,PN),Rel(NotNextTo,Alan,Debbie,PN),Rel(NotNextTo,Alan,Emily,PN),

Rel(NotNextTo,Amy,Charles,PN)]:

read "LogicProblem.mpl";

Birthday:= LogicProblem(Vars):

with(Birthday):

 

 

Following previous question at

http://www.mapleprimes.com/questions/149581-Improve-Algorithm-Dsolve

and also

http://www.mapleprimes.com/questions/149243-BVP-With-Constraining-Integrals

I wrote the following code

***********************

restart:

gama1:=0:


phi0:=0.00789:


rhocu:=2/(1-zet^2)*int((1-eta)*rho(eta)*c(eta)*u(eta),eta=0..1-zet):

eq1:=diff(u(eta),eta,eta)+1/(mu(eta)/mu1[w])+((1/(eta-1)+1/mu(eta)*(mu_phi*diff(phi(eta),eta)))*diff(u(eta),eta)):
eq2:=diff(T(eta),eta,eta)+1/(k(eta)/k1[w])*(2/(1-zet^2)*rho(eta)*c(eta)*u(eta)/(p2*10000)+( (a[k1]+2*b[k1]*phi(eta))/(1+a[k1]*phi1[w]+b[k1]*phi1[w]^2)*diff(phi(eta),eta)-k(eta)/k1[w]/(1-eta)*diff(T(eta),eta) )):
eq3:=diff(phi(eta),eta)-phi(eta)/(N[bt]*(1-gama1*T(eta))^2)*diff(T(eta),eta):
mu:=unapply(mu1[bf]*(1+a[mu1]*phi(eta)+b[mu1]*phi(eta)^2),eta):
k:=unapply(k1[bf]*(1+a[k1]*phi(eta)+b[k1]*phi(eta)^2),eta):
rhop:=3880:
rhobf:=998.2:
cp:=773:
cbf:=4182:
rho:=unapply(  phi(eta)*rhop+(1-phi(eta))*rhobf ,eta):
c:=unapply(  (phi(eta)*rhop*cp+(1-phi(eta))*rhobf*cbf )/rho(eta) ,eta):
mu_phi:=mu1[bf]*(a[mu1]+2*b[mu1]*phi(eta)):

a[mu1]:=39.11:
b[mu1]:=533.9:
mu1[bf]:=9.93/10000:
a[k1]:=7.47:
b[k1]:=0:
k1[bf]:=0.597:
zet:=0.5:
#phi(0):=1:
#u(0):=0:
phi1[w]:=phi0:
N[bt]:=0.2:
mu1[w]:=mu(0):
k1[w]:=k(0):

eq1:=subs(phi(0)=phi0,u(0)=0,eq1):
eq2:=subs(phi(0)=phi0,u(0)=0,eq2):
eq3:=subs(phi(0)=phi0,u(0)=0,eq3):

p:=proc(pp2) global res,F0,F1,F2:
if not type([pp2],list(numeric)) then return 'procname(_passed)' end if:
res := dsolve({eq1=0,subs(p2=pp2,eq2)=0,eq3=0,u(0)=0,u(1-zet)=0,phi(0)=phi0,T(0)=0,D(T)(0)=1}, numeric,output=listprocedure):
F0,F1,F2:=op(subs(res,[u(eta),phi(eta),T(eta)])):
evalf(2/(1-zet^2)*Int((1-eta)*(F1(eta)*rhop+(1-F1(eta))*rhobf)*( F1(eta)*rhop*cp+(1-F1(eta))*rhobf*cbf )/(F1(eta)*rhop+(1-F1(eta))*rhobf)*F0(eta),eta=0..1-zet))-pp2*10000:
end proc:


s1:=Student:-NumericalAnalysis:-Secant(p(pp2),pp2=[6,7],tolerance=1e-6);

                   HFloat(6.600456858832996)

p2:=%:



ruu:=evalf(2/(1-zet^2)*(Int((1-eta)*F0(eta),eta=0..1-zet))):
phb:=evalf(2/(1-zet^2)*(Int((1-eta)*F0(eta)*F1(eta),eta=0..1-zet))) / evalf(2/(1-zet^2)*(Int((1-eta)*F0(eta),eta=0..1-zet))) :
TTb:=evalf(2/(1-zet^2)*(Int((1-eta)*F2(eta),eta=0..1-zet))):
rhouu:=evalf(2/(1-zet^2)*(Int((1-eta)*(F1(eta)*rhop+(1-F1(eta))*rhobf)*F0(eta),eta=0..1-zet))):
with(plots):
res(parameters=[R0,R1]):
odeplot(res,[[eta,u(eta)/ruu],[eta,phi(eta)/phb],[eta,T(eta)/TTb]],0..zet);

 

*************************************

as you can see at the second line of the code, the value of phi0:=0.00789. however, I want to modify the code in a way that phi0 is calculated with the following addition constraint

evalf(2/(1-zet^2)*(Int((1-eta)*F0(eta)*F1(eta),eta=0..1-zet))) / evalf(2/(1-zet^2)*(Int((1-eta)*F0(eta),eta=0..1-zet)))-0.02=0

I would be most grateful if you could help me in this problem.

Thanks for your attention in advance

Amir

In MapleSim, it is possible to constrain a rigid body in a multibody system to an arbitrary constraint? 

Similarly to how a mass at the end of a simple pendulum can only move along a circle defined by the length of the pendulum, I was hoping to constrain one to a shape like an ellipse or sine wave.  I could then give it initial velocities and see how it would move along the shape over time.

I'd like to be able to define this constraint with an equation. ...

Hi all,

First of all, I would like to mention that I'm new to Maple, so please excuse my lack of knowledge.

I have a rather complicated expression, let us call it expr, and I have a constraint equation, let us call it constr = 0. I would like to simplify expr knowing that constr = 0.

Stupid example:

expr: 2*x+4*y+3

constr: x+2*y = 0

In that case:

expr = 2*(x+2*y)+3 = 2*0+3 = 3

How can I do that?

Thanks a lot.

Hello, I'm creating a rolling thin disk (rolling without slip) in the MapleSim, the model like the picture below (Fig. 1).

 

       ...

1 2 Page 1 of 2