Adept Scientific - English
The world's best software for research, science and engineering.
flag arrow
clearclear
 

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKusdedksvnofi
Home
Products
Training
Consultancy
 Buy Online
Downloads
Education
Support
My Adept
International |  About Us |  Contact Us |  Press Room |  Jobs


The Next Steps

• Ask us a question
• Maple Product Tour
• Buy Maple Now
• View Maple Pricing
• Find out about Online Training
• Download a Brochure
• Request a Brochure
• Download a Demo
• Request a Demo
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 11 Professional
Maple 11 Academic
Maple 11 Student Use
Recorded Online Seminars
FREE Training Resources


MapleNet
Maple T.A.
MapleConnect
BlockImporter for Simulink
BlockBuilder for Simulink
Maple Toolboxes
Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

View Maple 10 in Action
Product Comparison Chart

Latest Information

New Features: Professional
New Features: Academic
The Maple Reporter
The Maple Reporter Online
Numerical Algorithms Group
(NAG)


Service & Support

Maple 10 Training Videos
MaplePrimes, blogs, forums
Elite Maintenance Program
Application Centre
Powertools
Maple User Group (MUG)
Join the Maple User Group
(MUG)

Search the Knowledge Base
Technical Support request

List Archives >  Maple User Group List Archive >  Archive by date >  This Month By Date >  This Month By Topic

[MUG] Optimize tryhard

Search email archive for  

[MUG] Optimize tryhard
Author: Moore, Brian    Posted: Tue, 26 Nov 2002 11:28:57 -0500

>> From: "Moore, Brian" "Brian.Moore"

I'm looking for information on the algorithm used in the optimize with
tryhard option in the codegen package.
I would also be very interested in other general packages developed for
converting a Maple expression in efficient code (similar to the optimize
tryhard). Actually, the optimize tryhard seems to generate very efficient
code, but it takes a long time to generate the code.

Does anyone have some information concerning this topic ?

Thanks,

Brian Moore
Canadian Space Agency
6767 route de l'Aeroport, Saint-Hubert
Quebec, Canada J3Y 8Y9
email: "Brian.Moore"

[MUG] Re: Optimize tryhard
Author: Maple User Group    Posted: Fri, 29 Nov 2002 09:10:55 -0500

>> From: Maple User Group "maple_gr"

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: Gaston Gonnet "gonnet"
Date: Wed, 27 Nov 2002 17:53:49 +0100 (MET)
To: "maple-list"
Subject: Optimize tryhard

Yes, I have some information about tryhard, I have coded it some
time ago. I coded it because I was doing molecular dynamics at
the time, and that requires hundreds of hours of computation, hence
optimization time is not very relevant, but quality of the optimization
is.

optimize/tryhard is unique to that piece of code, all the rest of
codegen or Maple do not utilize it.

I never had the time to write a paper about it.... apologies....

Is there anything in particular you would like to know about it?

Best wishes, Gaston Gonnet.


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Wed, 27 Nov 2002 18:11:28 -0500 (EST)
From: Carl Devore "devore"
To: "maple-list"
Subject: Optimize tryhard



On Tue, 26 Nov 2002, Moore, Brian wrote:
> I'm looking for information on the algorithm used in the optimize with
> tryhard option in the codegen package.

It is all in procedures `codegen/optimize/tryhard/frontend` and its
subsidiaries. Just read the procedures with showstat.

> Actually, the optimize tryhard seems to generate very efficient code,
> but it takes a long time to generate the code.

Yeah, it is pretty good. With a tiny bit of tweaking, it can also be used
as an expression simplifier. For lengthy algebraic number expressions, it
often gives significantly more simplification than the other
simplification commands. Here is the tweaking:

Tryhard:= proc(expr)
local _E;
subs(
pow= `^`
,codegen[optimize](subs(_E= expr, ()-> _E), tryhard)
)()
end proc:

Show that is does something potentially useful:

_EnvExplicit:= true:
p:= randpoly([x,y], degree= 4, dense);
root1:= solve(p, y)[1];
# Root is 11 screens long on my computer
simplify(root1);
# Still 11 screens long
r:= Tryhard(root1);
# 2 1/2 screens long, and it only took twice as long as the simplify.

The actual procedure returned by codegen[optimize] in this case is only
1/3 of a screen long. So, looking at that procedure can give a deeper
understanding of the internal structure of root1 than can be obtained by
looking at the 2 1/2 screens.

Test validity:

simplify(eval(p, y= r));
0

So people who collect such things can file that in their Maple trick bag.

[MUG] Re: Optimize tryhard
Author: Maple User Group    Posted: Wed, 4 Dec 2002 10:25:19 -0500 (

>> From: Maple User Group "maple_gr"

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Fri, 29 Nov 2002 12:00:18 -0800 (PST)
From: Robert Israel "israel"
To: "maple-list"
Subject: Optimize tryhard


Carl, your Tryhard looks interesting, but it doesn't quite work: I get

> Tryhard(root1);

Error, (in procmake) unbound lexically scoped identifier in
procedure or module

I think you have to make _E a global rather than a local. I'm
puzzled about this, because the function passed to codegen[optimize]
looks the same in both cases. But appearances are deceiving.

Consider:

> TL:= proc(expr) local _E; subs(_E=expr, () -> _E) end proc;
TG:= proc(expr) global _E; subs(_E=expr, () -> _E) end proc;

> FL:= TL(x+1);
> FG:= TG(x+1);

FL := () -> x + 1


FG := () -> x + 1

> codegen[optimize](FL,tryhard);

Error, (in procmake) unbound lexically scoped identifier in procedure or
module

> codegen[optimize](FG,tryhard);

proc() local result; global x; result := x + 1 end proc

Although FL and FG look the same, FL contains a lexical table while
FG does not.

> op(7,eval(FL));

_E, x + 1

> op(7,eval(FG));

(nothing returned)

Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2

> Date: Wed, 27 Nov 2002 18:11:28 -0500 (EST)
> From: Carl Devore "devore"
> To: "maple-list"
> Subject: Optimize tryhard
>
>
>
> On Tue, 26 Nov 2002, Moore, Brian wrote:
> > I'm looking for information on the algorithm used in the optimize with
> > tryhard option in the codegen package.
>
> It is all in procedures `codegen/optimize/tryhard/frontend` and its
> subsidiaries. Just read the procedures with showstat.
>
> > Actually, the optimize tryhard seems to generate very efficient code,
> > but it takes a long time to generate the code.
>
> Yeah, it is pretty good. With a tiny bit of tweaking, it can also be used
> as an expression simplifier. For lengthy algebraic number expressions, it
> often gives significantly more simplification than the other
> simplification commands. Here is the tweaking:
>
> Tryhard:= proc(expr)
> local _E;
> subs(
> pow= `^`
> ,codegen[optimize](subs(_E= expr, ()-> _E), tryhard)
> )()
> end proc:
>
> Show that is does something potentially useful:
>
> _EnvExplicit:= true:
> p:= randpoly([x,y], degree= 4, dense);
> root1:= solve(p, y)[1];
> # Root is 11 screens long on my computer
> simplify(root1);
> # Still 11 screens long
> r:= Tryhard(root1);
> # 2 1/2 screens long, and it only took twice as long as the simplify.
>
> The actual procedure returned by codegen[optimize] in this case is only
> 1/3 of a screen long. So, looking at that procedure can give a deeper
> understanding of the internal structure of root1 than can be obtained by
> looking at the 2 1/2 screens.
>
> Test validity:
>
> simplify(eval(p, y= r));
> 0
>
> So people who collect such things can file that in their Maple trick bag.



-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Fri, 29 Nov 2002 17:08:31 -0500 (EST)
From: Carl Devore "devore"
To: Robert Israel "israel"
Subject: Optimize tryhard



On Fri, 29 Nov 2002, Robert Israel wrote:
> Carl, your Tryhard looks interesting, but it doesn't quite work: I get
> > Tryhard(root1);
>
> Error, (in procmake) unbound lexically scoped identifier in
> procedure or module
>
> I think you have to make _E a global rather than a local.

Professor Israel is correct. I had switched from a global to a local
without restesting (foolish not to retest). One can substitute for a
string and avoid the dangers of global variables. Here is a correction:

Tryhard:= expr->
subs(pow= `^`, codegen[optimize](subs("E"= expr, ()-> "E", tryhard))()
;

And all of the benefits of this simplification method that I mentioned
before still hold.

There might be some functions other than `^` that get their name
unfortunately changed by the tryhard. If you find any, they can be
back-substituted also, and please let me know.

That explains why there are all those substitutions for strings in the
newer code in `dsolve/numeric` and its subsidiaries. For example, check
out line 168 in the Maple 8 version.

Previous by date: [MUG] convolution operator,  MTK-Adem Kilicman Dr
Next by date: [MUG] Re: graphing parametric equations in 3d, Maple User Group
Previous thread: [MUG] same function with different arrangement give different plots?, Xiaoyan Li
Next thread: [MUG] graphing parametric equations in 3d, Han Wesseling



Ready to buy?

Maple - single user licence
Add to shopping basket
$ 1,895.00
Upgrade to Maple 12 from v11
Add to shopping basket
$ 995.00
Upgrade to Maple 12 from v10 & below
Add to shopping basket
$ 1,395.00

Featured Downloads

What's New in Maple 11 for Professionals
Maple White Paper: Technical Knowledge - An Asset You Can Afford to Lose?
Maple in Electronics Application Pack
Maple in Robotics & Aerospace Application Pack
Maple in Finance Application Pack

Product Reviews

"Without the Maple software, we would have to spend weeks generating the equations of motion for every experiment. Then the chances that we did it right would basically be near zero. There would always be a mistake somewhere. It is very difficult to set up a dynamic motion model by hand."
- Jean-Claude PiedBeouf, Ph.D Manager of Robotics, Canadian Space Agency

"Its very good - highly accurate and easy to use. The speed of Maple allows me to change equations and quickly reintegrate them into the application, so more possibilities can be explored to achieve the precise effect desired."
Shawn Neely, Senior R & D Director for PDI/Dreamworks
adept

Top of the Page

Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2007, Adept Scientific plc.
Site designed and maintained by Adeptise

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055