Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are replies submitted by Joe Riel

Can you upload the msim file? If that isn't feasible you can contact Maple support.

@das1404 Freidl's book is excellent, though quite a bit of the minutiae of crafting efficient regular expressions only applies to NFA based regular expression engines and the Maple StringTools engine uses a DFA.  

@Joe Riel I see that self can be used to refer to a containing Record.  Is that documented anywhere? I vaguely recall seeing usages of it, but it can find no mention of it in current help pages.  As an example

R :=  Record(a = 1, b = (() -> self:-a)):
R:-b();
                   1

@Mac Dude I don't understand what you are attempting to do with the self, but it is almost certainly invalid.  Maple has no 'self' builtin.  You might try running mint on your source code.  Here's what I get on the original (I exported it as a mpl file):

Nested Anonymous Operator proc( dppf ) on line 31
  These names were used as global names but were not declared:  dpp, self
Nested Anonymous Operator proc( bunch ) on line 32
  These names were used as global names but were not declared:  self
Nested Anonymous Operator proc( dpp ) on line 36
  These names were used as global names but were not declared:  self
Nested Anonymous Operator proc( dppf ) on line 43
  These names were used as global names but were not declared:  dpp, self
Nested Anonymous Operator proc( bunch ) on line 44
  These names were used as global names but were not declared:  self
Nested Procedure phiBooster( dppf ) on lines 62 to 66
  These names were used as global names but were not declared:  t, tc
Nested Procedure phiMBA( dppf ) on lines 69 to 72
  These names were used as global names but were not declared:  t, tc
Nested Procedure sineDiff( phiBooster, phiMBA ) on lines 75 to 88
  These names were used as global names but were not declared:  dpp
Module BooMBA() on lines 3 to 98
  These names were used as global names but were not declared:  R56, alpha__p, 
      bunchDelay, delay, dpp, f__rev, f__rf, h, omeg

@Christopher2222 It means I should not have uploaded that model, which is from a development version of MapleSim.  I thought it would work with the released 2016 version, but didn't have a release version handy to test with.  You should be able to replicate the model using the figures in this post as a guide.  

@Christopher2222 K is supposed to be a model parameter (spring stiffness). Try just replacing the symbolic value in the spring/force component in any of the link subystems with a numeric value.

@Matt C Anderson Your hunch is on the right track, but not quite correct.  Maple supports recursion, so a procedure calling itself is not necessarily a problem. The problem occurs when the recursive calls never terminate, which happens here because the typo prevents the first condition from ever evaluating true.  With that fixed the recursion eventually terminates.

@Carl Love It's safe here because the records are not changing.  If they did change, during the evaluation, then this wouldn't work. The forget in the outer call ensures this should still work if changes are made to the structure between calls.

An interesting question is how to do this with the more general structure of a graph, which can contain cycles.  Assuming records are used as the building block, does the following modification to my code always work (terminate and return the proper result):

EqualGraph := module()
    
export
    ModuleApply := proc(a,b)
        forget(equal);
        equal(a,b);
    end proc;
    
local
    equal := proc(a := NULL, b := NULL)    
    local aindx, bindx;
        if a::'record' and b::'record' then
            aindx := {exports(a)};
            bindx := {exports(b)};
            if aindx <> bindx then
                return false;
            else
                equal(args) := true;
                andmap(i->equal(a[i],b[i]), aindx);
            end if;
        else
            evalb(a = b);
        end if;
    end proc;
end module:

Followup

There is an issue with this algorithm. It returns true if the two graphs are equivalent (in some sense), but not necessarily equal. Consider

G1 := Record(nxt);
G2 := Record(nxt);
G3 := Record(nxt);
G1:-nxt := G1:
G2:-nxt := G3:
G3:-nxt := G2:

EqualGraph(G1,G2);
                   true

G1 consists of a single node that points to itself. G2 consists of two node, each pointing to the other node. Both graphs describe a loop, so in some sense are equivalent. This brings up a serious efficiency issue with the algorithm. Consider two loops, one of length n, the other of length n+1. If they are otherwise equivalent, the algorithm won't detect this until it has made n*(n+1) calls.

@AmirHosein Sadeghimanesh The 2D parser is the Maple parser that interprets the 2D (math-like) input.  By selecting Tools > Options > Display and changing the Input Display menu selection to Maple Notation, then input regions with prompts will use Maple notation rather than the 2D notation.  

@Christopher2222 See if this works for you. Beam.msim 

I'm having trouble understanding what you are trying to accomplish.  Presumably this is just toy code intended to learn something, however, its hard to see where it will go from here. 

I see you used my comment about converting this to an object.  That may not have been the best approach (in that it requires a bit more sophistication).  It's hard to say because, as mentioned, I have no idea where this is really headed. An object is a dynamic structure with both methods and data.  Here you don't really have any data and not much in the way of methods.  Forget about the profiling; what do you want to do?

@Christopher2222 What version of MapleSim do you have?  I created it with a development version, but will redo it with a released version.

@Christopher2222 How do you want to model the beam?  As inflexible? 

Followup

I modeled the beam as inflexible.  I broke into into four links, each link consisted of rigid frame, a point mass, and a spring connection to a fixed point. Then I applied a vertical force controlled by a signal at one end and sensed the vertical motion at the other.  Using the Linearization app I created a linear model of this and plotted the frequency response.  It basically showed a steady decay with some deviations as it went through resonance. 

Here's a picture of the link model

And here's the beam model

This took me about 10 minutes to put together (creating this post took considerably longer). 

@sand15athome Here's a simple comparison

MakeTable := proc(depth :: nonnegint, width :: nonnegint)
local i;
    if depth = 0 then 0
    else table([seq(i=thisproc(depth-1,width), i=1..width)]);
    end if;
end proc:

T := MakeTable(5,10):

CodeTools:-Usage(TableTest(T,T));
memory used=45.10MiB, alloc change=36.00MiB, cpu time=497.00ms, real time=498.00ms, gc time=0ns
                                                                                             
CodeTools:-Usage(TablesEqual(T,T)):
memory used=84.61MiB, alloc change=32.00MiB, cpu time=424.00ms, real time=357.00ms, gc time=128.00ms

They have similar performance when the tables match. If the tables differ, my routine will exit as soon as it finds the difference.

First 34 35 36 37 38 39 40 Last Page 36 of 195