What data structure or algorithm do I need?

So I have had a long term project goal for over 5 years that has driven my desire to master programming.

But maybe I am overthinking this and would like some feedback about what type of data-structure to house my problem & solution in.

What I want to do is input parameters related to fitness, and output a “smart” training plan.

Eventually I would like this to be AI driven but first I need to either create / design inputs with expert knowledge, or collect real data after the project starts to collect it from people.

So example inputs might be:
age
years training
goal event (distance)
goal date
best 5k time
best 10k time
best half marathon time

Normally I would use my “intuition” and experiene and plot this out on a spreadsheet. I have a flow that I use to do this, but I’ve been doing it so long I think I am having trouble abstracting my knowledge.

The other issue that maybe i"m overthinking is that I want to avoid strict algebraic projections of those inputs to fill out the schedule.

Ie training for a marathon 16 weeks away, experienced runner, currently running 40mph, no injuries, best 5k time is 19:00.

This initial data collection would let me start plottign out a schedule but i’m not really sure what it is I am doing in my head.

So how do I represent all of these elements & the schedule structure in javascript?

I appreciate any input. Thank you!

Oh yeah? what kind of tools? Any suggestions for me on structures?

I have pacing models that I successfully use based on writing by Peter Reigel. I thought you’d interpret my question as asking for advice on what to model, but i’m very comfortable with that. I have a lot of spreadsheets i’ve developed that can take a p ace and model a variety of workouts (similar to McMillan calculator).

However there’s a lot more to it as you know, such as when to choose what intensity based on a training plan model, and that model can change based on a lot of factors as well, right? I’m not struggling with how to plan the sessions, but how to model the plan if that makes sense, and how to do it programatically.

I think part of what stumps me is when I look at a calendar layout, there are repeating weeks and the week is a basic unit of my planning with progressions week to week, similar workouts on same day of the week, and training cycles are built up of 3-6 week blocks. When i LOOK at a calendar layout, I can do all of this intuitively.

The idea of iteration as part of the algorithm makes total sense.

Maybe I iterate once over a collection of weeks that represent training cycles, then iterate within those weeks to plan the days.

When I do it, there is also shuffling of blocks, long sessions, training days to get things to “fit” into easy to plan routines as well, and because the look of the plan can change once I get it all built out, I may reconsider.

So what I do isn’t black and white and its never the same even though there is a pattern and a flow.

Am I making any sense ?

Yes I completely agree. Some plans I change on a daily basis, but there is some underlying pattern Im tracking when I do so, even if I don’t write it down.

THe number of moving parts makes me think this is a cadidate for some type of machine learning solutions as well, but no idea how to implement that right now, aside from having done basic tutorials

Thanks for helping me think through this.

I can’t begin to contribute to the physical training discussion here (Gym class tanked my GPA), but taking it back to the technical problem as I understand it…
You will probably want to do your calculations (projections? suggestions? plan? whatever) on the fly, rather than storing it. There may be certain constant values that you will store under a user’s profile rather than recalculate because their inputs do not change (like if you always used age/number of legs in your plan calculations or whatever), but generally you would just build the schedule client side every time new data changes. Functionally, this is actually very much the same as what you do in excel if you apply a function to a row that uses earlier rows as input.

Structurally, you might do something like create a base “racePlan” class, with “marathonPlan” (etc) which extend that base class. If you can identify what, mathematically, differs between a 5k plan and a marathon plan, and write a shared function which can take that difference as a parameter.

1 Like

thanks that’s helpful as well.

programmatically, working with React and now react hooks have me a little confuzzeled. how do classes vs functions differ ? it used to be in react you needed to have a class (with methods) to use state…but now you can create and use state in a function with hooks.

If you can think of any simple examples of what you describe I would appreciate that.

THinking of the “What is different” between 2 types of plans is a good approach to organization as well.

Thank you

I don’t program in React, so I can’t speak to that. In JavaScript, class is really just syntactic sugar that makes JS’s prototypical inheritance look and feel more like classical inheritance.

1 Like

In the context of React, you can effectively get the same result with either option.

If you have a OOP background or preference, the class syntactic sugar may feel more comfortable. If you have some Functional Programming leanings, functional components may feel more comfortable. I prefer hooks, but YMMV.

Either way, a class is just one specific way to create and model objects - it’s not the only way. I tend to think of the modeling step the same way regardless of the inheritance model. One is more architecture, the other an implementation detail (in my mind. Perhaps others will enlighten me!).

2 Likes

I"m glad to read this. I forgot all about object constructors and so reviewed the FCC lessons on it last night.

I think it’s better to learn React without hooks first. Learn the difference between when you just need a function vs a class instance. Functions, generally, for less sophisticated things, when you just need to return some DOM node/s based on a prop, i.e. a text field. Classes for more sophisticated things like a container for some dynamically filtered or fetched data, or a fancy button that can do many different things. Hooks bring in some new ways to add sophistication to functional components and new ways to structure your component tree, but hard to understand the purpose of those things until you’ve found something hard to do or change in your program without using them.

Hey I really appreciate your input. I’ve done a score of little projects including 4 out of the 5 front end projects with react using both classes & functions and feel fine with it. But now I’m trying to learn hooks and it’s just confusing me more. useState for example…it seems like a shortcut to using local state (maybe that’s exactly what it is?)

So I’m trying to put in into context with what I already know. I can do everything I’m currently doing without hooks, the hook syntax is making local state really easy but so far that’s as far as I have gotton.