vie_charlie

63 Reputation

10 Badges

9 years, 93 days

MaplePrimes Activity


These are replies submitted by vie_charlie

MJC_efficiency_calcu.mw

Hi Acer,

Thanks for taking the time!  really appreciated the insightful and comprehensive response!

I've been looking at my codes and really don't know where exactly it is crying for help.  When i program I usually keep my codes as concise as possible at the first run thru.  To run something like the NLPSolve for my purpose, it takes some where in the order of tens of mins to half an hour.  Are there big items that you can point right away to get me started?

The optimization has done fine before any streamlining efforts for both of my functions: PEffSQ and PEffLim.  HOwever, with the one thing I manage to found to streamline the codes, it's giving me problem.

I've tried to change my definition of fLim from

fLim := proc (egx, egy)::float; local ans, sx, fop, flim, j; sx := SX(egx, egy); fop := seq(evalf(subs(sx, subs(Eg1 = egx, Eg2 = egy, EV), -F0(i)*exp(x[i])*x[i])), i = 1 .. n); flim := fop[1]; for j to n do if abs(fop[j]/A) < abs(flim/A) then flim := fop[j] end if end do; ans := flim/A end proc

to

fLim := proc (egx, egy)::float; local ans, sx, fop, flim, j; sx := SX(egx, egy); fop := {seq(evalf(subs(sx, subs(Eg1 = egx, Eg2 = egy, EV), -F0(i)*exp(x[i])*x[i])), i = 1 .. n)}; ans := fop[n]/A end proc

This is the error msg i'm getting at the optimization line:

Error, (in Optimization:-NLPSolve) invalid subscript selector

The idea is, instead of running an if statement for finding the smallest absolute value from the list of fop, I've made use of a set which sequences numbers in order instrinsically.  NOTE that all values in fop should be negative. I really would appreciate some pointers as I've been looking at it for a few days already.  I've upload my file again for your convenience.

Many thanks agaain!!!

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

MJC_efficiency_calcu.mw

Hi Acer,

Thanks for taking the time!  really appreciated the insightful and comprehensive response!

I've been looking at my codes and really don't know where exactly it is crying for help.  When i program I usually keep my codes as concise as possible at the first run thru.  To run something like the NLPSolve for my purpose, it takes some where in the order of tens of mins to half an hour.  Are there big items that you can point right away to get me started?

The optimization has done fine before any streamlining efforts for both of my functions: PEffSQ and PEffLim.  HOwever, with the one thing I manage to found to streamline the codes, it's giving me problem.

I've tried to change my definition of fLim from

fLim := proc (egx, egy)::float; local ans, sx, fop, flim, j; sx := SX(egx, egy); fop := seq(evalf(subs(sx, subs(Eg1 = egx, Eg2 = egy, EV), -F0(i)*exp(x[i])*x[i])), i = 1 .. n); flim := fop[1]; for j to n do if abs(fop[j]/A) < abs(flim/A) then flim := fop[j] end if end do; ans := flim/A end proc

to

fLim := proc (egx, egy)::float; local ans, sx, fop, flim, j; sx := SX(egx, egy); fop := {seq(evalf(subs(sx, subs(Eg1 = egx, Eg2 = egy, EV), -F0(i)*exp(x[i])*x[i])), i = 1 .. n)}; ans := fop[n]/A end proc

This is the error msg i'm getting at the optimization line:

Error, (in Optimization:-NLPSolve) invalid subscript selector

The idea is, instead of running an if statement for finding the smallest absolute value from the list of fop, I've made use of a set which sequences numbers in order instrinsically.  NOTE that all values in fop should be negative. I really would appreciate some pointers as I've been looking at it for a few days already.  I've upload my file again for your convenience.

Many thanks agaain!!!

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

@mois 

 

Hi Sergey,

I've downloaded your DirectSearch Package and the example ran fine.

As for my codes, there could be a bit of complication.  I've received the following error.  Any suggestions?

 

Error, (in FeasiblePoint) invalid input: Im expects 1 argument, but received 0

thanks!

@mois 

 

Hi Sergey,

I've downloaded your DirectSearch Package and the example ran fine.

As for my codes, there could be a bit of complication.  I've received the following error.  Any suggestions?

 

Error, (in FeasiblePoint) invalid input: Im expects 1 argument, but received 0

thanks!

MJC_efficiency_calcu.mw

Pagan,  here's the code.  there are only mininal documentations ... hope it's not too confusing.

thanks and look forward to your feedbacks.

Yours sincerely,

Charles

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

MJC_efficiency_calcu.mw

Pagan,  here's the code.  there are only mininal documentations ... hope it's not too confusing.

thanks and look forward to your feedbacks.

Yours sincerely,

Charles

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

Will/Pagan,

Thanks!

It's miracle!  After the similar lesson i've learnt from plotting PEffSQ, I did try Pagan's first 2 suggestions with the function "maximize" rather than "Maximize" as I didn't recognize there was a difference. 

Secondly, I would like to ask whether

>Optimization:-Maximize(PEffSQ, initialpoint = [2.3, 1.4]);

is more efficient than

>with(Optimization): 

>Maximize(PEffSQ, initialpoint = [2.3, 1.4]);

Thridly, Maximize seems to be able to evaluate based on Pagan's suggestion.  But this is the output:

> PEffSQ(2.31, 1.41); PEffSQ(2.3, 1.4); PEffSQ(2.29, 1.39); PEffLim(2.3, 1.4); Maximize(('PEffSQ')(eg1, eg2), {2 >= eg2, 3 >= eg1, 1 <= eg2, 1.5 <= eg1}, initialpoint = {eg1 = 2.3, eg2 = 1.4}, variables = [eg1, eg2]);
                          48.32357435
                          48.32038135
                          48.31404806
                          39.02174290
Warning, no iterations performed as initial point satisfies first-order conditions
 [48.3203805780850999, [eg1 = HFloat(2.3), eg2 = HFloat(1.4)]]

 There is definitely a higher value in PEffSQ than PEffSQ(2.3,1.4) which is the initial point of the Maximize call.  Any suggestions as to how i can get Maximize to do better search for the Max value.  the function is smooth and should only have 1 optimun in the range specified.

thanks again!

Charles

 

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

Will/Pagan,

Thanks!

It's miracle!  After the similar lesson i've learnt from plotting PEffSQ, I did try Pagan's first 2 suggestions with the function "maximize" rather than "Maximize" as I didn't recognize there was a difference. 

Secondly, I would like to ask whether

>Optimization:-Maximize(PEffSQ, initialpoint = [2.3, 1.4]);

is more efficient than

>with(Optimization): 

>Maximize(PEffSQ, initialpoint = [2.3, 1.4]);

Thridly, Maximize seems to be able to evaluate based on Pagan's suggestion.  But this is the output:

> PEffSQ(2.31, 1.41); PEffSQ(2.3, 1.4); PEffSQ(2.29, 1.39); PEffLim(2.3, 1.4); Maximize(('PEffSQ')(eg1, eg2), {2 >= eg2, 3 >= eg1, 1 <= eg2, 1.5 <= eg1}, initialpoint = {eg1 = 2.3, eg2 = 1.4}, variables = [eg1, eg2]);
                          48.32357435
                          48.32038135
                          48.31404806
                          39.02174290
Warning, no iterations performed as initial point satisfies first-order conditions
 [48.3203805780850999, [eg1 = HFloat(2.3), eg2 = HFloat(1.4)]]

 There is definitely a higher value in PEffSQ than PEffSQ(2.3,1.4) which is the initial point of the Maximize call.  Any suggestions as to how i can get Maximize to do better search for the Max value.  the function is smooth and should only have 1 optimun in the range specified.

thanks again!

Charles

 

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

Hi,  I've been looking for a soln for my problem and found this thread quite relevant.

Here's what i have is

PEffSQ := proc (Egx, Egy) if Egy <= Egx then 100*evalf(subs(subs(Eg1 = Egx, Eg2 = Egy, EV), SX(Egx, Egy), PCellMax/PInc)) end if end proc

and then I tried to run this maximize

maximize(PEffSQ(eg1, eg2), initialpoint = {eg1 = 2.3, eg2 = 1.4}, variable = [eg1, eg2])

And just like the problem i have with plotting values from this procedure, i have the following error:

Error, (in PEffSQ) cannot determine if this expression is true or false: eg2 <= eg1

Any suggestions?

Thanks in advance!

 

How much of the 2*Pi*h*fw*(int(v^3/(exp(hv/kTs)-1), v = 0 .. infinity))/c^2 can we harnest?

Page 1 of 1