## How do i perform optimization on a function that c...

I am trying to call an optimization function for a set of operations where the object function contains integrals. i get this error when i try to do the optimization, i actually want to optimize a cost function, this is the error i get: Error, (in Optimization:-NLPSolve) integration range or variable must be specified in the second argument, got 1. = 4 .. 7

here is my work:

a2 := 18;
b2 := 5;
a1 := 3;
b1 := 2.5;
ci := 0.05;
cr := 1;
cf := 10;
p := 0.1;
L := 0.5;
S := 3;
T := 10;
cud := 50;
co := 0.02;
tr := 0.006;
ti := 0.0014;
tf := 0.014;
K := 2;
A := 2;
M := 7;
f01 := x -> b1*(x/a1)^(b1 - 1)*exp(-(x/a1)^b1)/a1;
f02 := x -> b2*(x/a2)^(b2 - 1)*exp(-(x/a2)^b2)/a2;
fx := x -> p*f01(x) + (1 - p)*f02(x);
fh := h -> L*exp(-L*h);
Fh := h -> 1 - exp(-L*h);

P1_1 := (K, A, M) -> sum(int(fx(x)*(1 - Fh(i*A - x)), x = (i - 1)*A .. i*A), i = 1 .. K);
L1_1 := (K, A, M) -> sum((i*A + tr + i*ti)*P1_1(K, A, M), i = 1 .. K);
C1_1 := (K, A, M) -> sum((ci*i + cr)*P1_1(K, A, M), i = 1 .. K);
NULL;
P2_1 := (K, A, M) -> sum(int(fh(h)*fx(x), [h = 0 .. i*A - x, x = (i - 1)*A .. i*A]), i = 1 .. K);
L2_1 := (K, A, M) -> sum((tf + (i - 1)*ti)*int((x + h)*fh(h)*fx(x), [h = 0 .. i*A - x, x = (i - 1)*A .. i*A]), i = 1 .. K);
C2_1 := (K, A, M) -> sum(((i - 1)*ci + cf)*P2_1(K, A, M), i = 1 .. K);
P3_1 := (K, A, M) -> int(fh(h)*fx(x), [h = 0 .. M - x, x = A*K .. M]);
L3_1 := (K, A, M) -> (K*ti + tf)*int((x + h)*fh(h)*fx(x), [h = 0 .. M - x, x = A*K .. M]);
C3_1 := (K, A, M) -> (K*ci + cf)*P3_1(K, A, M);
P4_1 := (K, A, M) -> int(fx(x)*(1 - Fh(M - x)), x = A*K .. M);
L4_1 := (K, A, M) -> (K*ti + tr + M)*int(fx(x)*(1 - Fh(M - x)), x = A*K .. M);
C4_1 := (K, A, M) -> (K*ci + cr)*int(fx(x)*(1 - Fh(M - x)), x = A*K .. M);
P5_1 := (K, A, M) -> int(fx(x), x = M .. infinity);
L5_1 := (K, A, M) -> (K*ti + tr + M)*int(fx(x), x = M .. infinity);
C5_1 := (K, A, M) -> (K*ci + cr)*int(fx(x), x = M .. infinity);
Ptotal_1 := (K, A, M) -> P1_1(K, A, M) + P2_1(K, A, M) + P3_1(K, A, M) + P4_1(K, A, M) + P5_1(K, A, M);
Ptotal_1(K, A, M);
evalf(Ptotal_1(K, A, M));
Ltotal_1 := (K, A, M) -> L1_1(K, A, M) + L2_1(K, A, M) + L3_1(K, A, M) + L4_1(K, A, M) + L5_1(K, A, M);
evalf(Ltotal_1(K, A, M));
Ctotal_1 := (K, A, M) -> C1_1(K, A, M) + C2_1(K, A, M) + C3_1(K, A, M) + C4_1(K, A, M) + C5_1(K, A, M);
Cost_rate_1 := (K, A, M) -> Ctotal_1(K, A, M)/Ltotal_1(K, A, M);
integralOF := int(Cost_rate_1(K, A, M), x = 1 .. 2);
evalf(integralOF);
0.2759938793

MTBOF := Ltotal_1(K, A, M)/(P2_1(K, A, M) + P3_1(K, A, M));
evalf(MTBOF);
159.4642167

rd := 1/MTBOF;
ro := 1/M + rd;
const1 := 0 <= K;
const2 := K*A <= M;
const3 := M <= 20;
const4 := 0 <= A;
const5 := 0 <= M;
totalconstr := {const1, const2, const3, const4, const5};

optimized_cost := Optimization:-Minimize(integralOF, totalconstr);
Error, (in Optimization:-NLPSolve) integration range or variable must be specified in the second argument, got 1. = 4 .. 7
NULL;

please, i need assitance urgently.. thanks

## In my current worksheet mine.mw how do I automatic...

In my current worksheet mine.mw how do I automatically print/show the filename " mine.mw"

## convert a list with nested ordered sets to a set w...

I have list say like this

[(0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8), (8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)]

I want to convert it to

{{0,1},{1,2},{1,10},{2,3},.........}

And print the ouput to a file

This I want the output as

Graph({{0,1},{1,2},{1,10},{2,3},.........})

So that i can save the graph

like that all the order pairs in the above list

I have given one list above here

But if I have a list of lists like this below

[[(0, 1), (1, 2), (1, 10), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8), (8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)], [(0, 10), (1, 2), (1, 9), (2, 3), (3, 4), (4, 5), (4, 9), (5, 6), (6, 7), (7, 8), (8, 9), (10, 11), (11, 12), (11, 16), (12, 13), (13, 14), (14, 15), (15, 16)],.......]

Like this their will be many say n element then I need to a list as

[{{0,1},{1,2},{1,10},......}, {{0,10},......}, ....]

I ask for a list of graphs as I want the first graph in the first place only , second in the second place only.

Kind help

## How to solve PDE with regular derivatives as coeff...

I would appreciate any help to solve the following Partial Differential Equation, which is a mix of partial and regular derivatives as coefficients.

How to solve it with/without initial conditions?

## Plot Problem - What is happening at f(0)/...

What is happening at f(0)?

Look at PlotProblem.mw

## Ploting in pdsolve numerically...

Dear Users,
I hope you are doing well. The following is the code to solve a nonlinear PD equation numerically and I plotted the graphs for T(y,t) sucessfully.

restart; with(plots); PDE1 := Pr*(diff(T(y, t), t)-Ree*(diff(T(y, t), y))) = (1+Nr*(T(y, t)+1)^3)*(diff(T(y, t), y, y))+3*Nr*(T(y, t)+1)^2*(diff(T(y, t), y))^2; ICandBC := {T(1, t) = 1, T(y, 0) = 1, (D[1](T))(0, t) = T(0, t)}; Ree := .1; Pr := 6.2; HA1 := [0, 1, 10]; AA := [red, green, blue, cyan, purple, black];
printlevel := 2; for i to nops(HA1) do Nr := op(i, HA1); print("Nr = ", %); PDE[i] := {PDE1}; pds[i] := pdsolve(PDE[i], ICandBC, numeric, spacestep = 1/200, timestep = 1/100); PlotsT[i] := pds[i]:-plot[display](T(y, t), t = 1, linestyle = "solid", labels = ["y", "u"], color = op(i, AA), numpoints = 800) end do;
display([`\$`(PlotsT[j], j = 1 .. nops(HA1))], size = [1000, 600], axes = boxed, labels = [x, (convert("T", symbol))(x, T)], labelfont = ["Times", 14, Bold], labeldirections = [horizontal, vertical], axesfont = ["Arial", 14, Bold], thickness = 3)

I want to plot the graphs for (1+Nr*(T(y, t)+1)^3)*(diff(T(y, t), y)), at t = 1. Also want to plot diff(T(y, t), y) at y = 0 and y = 1 against Nr. Kindly help me in this matter.

## Writing an explanatory paragrah I want to use an a...

Writing an explanatory paragrah i want to use an approximately equal symbol. How can I do this? The palette has lots of symbols but not what in latex would be done with \approx

## Why does solve work with a system of equations, bu...

I just tried to solve a very simple system of equations using solve but depending on how I write the system the command does out give any output.

 (1)

Solution with pencil and paper

=

=

Check this solution

 (2)

 (3)

Notice that if I define I__cm then there is no solution being shown. I can rename I__cm to something else like y, still no output. Then in the second system I simply sub I__cm into the equation that has this variable, and it works.

So what's going on here? Why doesn't the first use of solve work?

## How to read smiles file using quantum chemistry to...

How to read the topological structure of chemical from a SMILES file in Maple

As I want only the physical structure of the molecule

Like in molecular data it gives the bonds of topology {1,2} like the structure it gives

As SMILES can give 2D structure to me

Kind help how to do

## Burger's PDE Solution...

My following code:

restart;
PDE := diff(u(x, t), t) + u(x, t)*diff(u(x, t), x) - 0.1*diff(diff(u(x, t), x), x) = 0;
IC := u(x, 0) = sin(x);
BC := [u(0, t) = u(2*Pi, t)];
pds := {BC, IC, PDE};
ds := {pds, t = 0 .. 10, x = 0 .. 2*Pi};
p := pdsolve(ds, numeric);
u := rhs(p[1]);
u(x, t);

producing following 2 errors, don't know how to handle?

Error, (in anonymous procedure called from pdsolve/numeric) invalid terms in sum: 0 .. 10
Error, invalid input: rhs received p[1], which is not valid for its 1st argument, expr

## barycentre of 3 weighted points...

How to make this program more effective ?

A := [-3, 1, 2];
B := [-2, -1, 1];
C := [0, 3, -3];
A := [-3, 1, 2]

B := [-2, -1, 1]

C := [0, 3, -3]

alpha[1] := 2;#weight
alpha[2] := -1;
alpha[3] := 1;
alpha[1] := 2

alpha[2] := -1

alpha[3] := 1

x[1] := A[1];
x[2] := B[1];
x[3] := C[1];
x[1] := -3

x[2] := -2

x[3] := 0

y[1] := A[2];
y[2] := B[2];
y[3] := C[2];
y[1] := 1

y[2] := -1

y[3] := 3

z[1] := A[3];
z[2] := B[3];
z[3] := C[3];
z[1] := 2

z[2] := 1

z[3] := -3

sum(alpha[i], i = 1 .. 3);
2

xG := sum(alpha[i]*x[i], i = 1 .. 3)/sum(alpha[i], i = 1 .. 3);
xG := -2

yG := sum(alpha[i]*y[i], i = 1 .. 3)/sum(alpha[i], i = 1 .. 3);
yG := 3

zG := sum(alpha[i]*z[i], i = 1 .. 3)/sum(alpha[i], i = 1 .. 3);
zG := 0
Thank you.

## Trouble trying to follow on a least squares video...

Hello everybody!

Since least squares is not fully understood by me all that well, and the way my Dutch book throws me into the deep whitout really showing how things are done, i decided to look for some videos on Least Squares in Maple on YouTube. Well, i did found one, but then this happened. "Error, (in sum) summation variable previously assigned, second argument evaluates to 1 = 1 .. 5" I just want to go further with the video, but now im stuck and i have no clue how to go on.

https://youtu.be/8zh73UrJW6M?t=948 This is the video at the moment the part where i get stuck is shown.

I really like these sort of videos while they really do help out. I think its great.

This is my maple worksheet:

 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >
 (5)
 >
 >
 >
 (6)
 >
 >
 >
 >
 >
 (7)
 >
 >
 >
 (8)
 >
 (9)
 >
 (10)
 >
 >

Thank you very much!

Greetings,

The Function

## Execute an entire worksheet in a loop?...

Is there a way to execute an entire worksheet for a list of values of a parameter.
Sometimes executing in the standard loop can be cumbersome given you have to add catch statements for errors to prevent the loop from stopping.

## How to get polynomial expression...

Hi,

I'm not able to find a way to bring an equation into it's "polynomial" form:

I'd like this expression in the form of:

c1*v^3+c2*v^2+c1*v+c0 = 0

where c1...c4 are my coefficients

How can I do that?