Disclosure of Invention
The invention aims to solve the defects in the prior art, and provides a body-building exercise scheme generation method and system based on an optimization algorithm.
In order to achieve the above purpose, the present invention adopts the following technical scheme:
a body-building exercise scheme generation method based on an optimization algorithm comprises the following specific steps:
s1, acquiring and preprocessing basic information and body data of a user;
s2, carrying out priority allocation on a user fitness target and constructing a fitness map;
s3, generating a motion scheme meeting a user target based on graph reasoning;
s4, globally optimizing a preliminarily generated fitness scheme and gradually iterating an improved scheme;
S5, performing personalized adjustment on the data scheme according to real-time feedback and monitoring of the user;
and S6, performing multi-objective weighing and generating a final body-building exercise scheme.
As a further aspect of the present invention, the specific steps of the priority allocation in S2 are as follows:
p1.1, according to the body building requirement of a user, acquiring the overall body building target of the user, realizing all sub-targets of the overall target and a specific action scheme, and constructing a corresponding target layer, a criterion layer and a scheme layer according to all groups of information;
P1.2, based on expert experience and user preference, comparing each pair of sub-targets in a criterion layer in pairs, giving scores of relative importance, constructing a comparison matrix, inputting each group of scores into the comparison matrix, normalizing each column of the comparison matrix, and calculating the weight vector of each group of sub-targets in the normalized comparison matrix;
And P1.3, carrying out consistency verification on the processed comparison matrix, if the consistency ratio CR of the comparison matrix is smaller than 0.1, accepting consistency, otherwise, readjusting the comparison matrix, taking the weight vector of the comparison matrix passing the consistency verification as the final weight distribution result of each sub-target, sequencing each group of sub-targets according to the weight value from high to low, and if the weight value is larger, increasing the priority of the sub-targets.
As a further scheme of the invention, the specific steps of generating the motion scheme meeting the user target in the S3 are as follows:
P2.1, collecting user historical training data, body data and external conditions, extracting characteristic information of each group of data through characteristic engineering, setting a time step, taking the characteristic information of each time step as an input sequence, and dividing each generated group of input sequences into a training set and a verification set;
initializing parameters of an RNN model, inputting training set data into the RNN model, gradually processing each group of input sequences of the training set by the RNN model in the forward propagation process, calculating the hidden state and output of each time step, and calculating the error between the model prediction output and a real target through a mean square error function after the forward propagation is finished;
P2.3, counter-propagating the error value, calculating the gradient of each group of parameters of each layer of the error value relative to the model, updating the parameters of the RNN model through RMSprop algorithm according to the gradient calculated in the counter-propagation, evaluating the performance of the model on unseen data through the verification set, adjusting the model parameters according to the evaluation result, repeating training and verifying the model for a plurality of times until reaching a preset error threshold;
And P2.4, predicting the performance and progress of the user under different training conditions according to the exercise priority condition of the current user and the graph reasoning result by the RNN model after training, and generating a preliminary exercise scheme containing training contents, strength, frequency and combination according to the prediction result of the RNN.
As a further scheme of the invention, the global optimization preliminary generated fitness scheme of S4 comprises the following specific steps:
Extracting parameter combinations in a preliminarily generated motion scheme, randomly generating N groups of different random solutions, wherein each group of solutions represents the parameter combinations of one group of motion schemes, initializing a corresponding number of search bodies in a scheme space according to the generated random solutions, wherein each group of search body positions corresponds to one group of motion schemes, and calculating the adaptability of each group of motion schemes according to a user target;
p3.2, comparing the fitness of each motion scheme at the beginning of each iteration, determining the position with the highest fitness, calculating the distance between each search body and the optimal position and the movement coefficient, and judging whether the search body partially surrounds the optimal position or not;
If the movement coefficient is smaller than 1, updating the position of each search body according to the calculated distance and the set movement coefficient, calculating Euclidean distance between each updated search body and the optimal position again, updating the position again by using a logarithmic spiral formula, otherwise, randomly selecting the positions of a group of search bodies, and updating the positions of the rest search bodies;
And P3.4, repeatedly carrying out iterative updating on the position of the search body until the preset maximum iterative times are reached, outputting an optimal position after the iteration is finished, namely, an optimized motion scheme, and updating the training content, the strength, the frequency and the combination of the original scheme of the user according to the optimized motion scheme.
The fitness exercise scheme generating system based on the optimization algorithm comprises an information collecting module, a target setting module, a data processing module, a map constructing module, a weight distribution module, a preliminary generating module, an optimization evaluation module, a user feedback module, a scheme adjusting module and a result output module;
The information collection module is used for collecting basic information and health data of a user;
the target setting module is used for setting a personal fitness target, a target quantization index and a target time frame by a user;
The data processing module is used for cleaning, standardizing and encoding the collected user information and target data;
the map construction module is used for combining the health data of the user with the existing sports science knowledge and nutrition knowledge to construct a specific body-building map of the user;
The weight distribution module is used for distributing priorities to a plurality of targets of the user;
the preliminary generation module is used for generating a preliminary fitness scheme according to the user information, the target setting and the reasoning result of the knowledge graph;
the optimization evaluation module is used for carrying out global search and optimization on the preliminarily generated motion scheme, and evaluating the optimized motion scheme so as to carry out iterative improvement;
the user feedback module is used for recording the feedback actual experience and feeling of the user in the process of executing the motion scheme;
The scheme adjusting module is used for carrying out personalized adjustment on the exercise scheme according to user feedback and scheme evaluation results;
the result output module is used for outputting the optimized and adjusted fitness exercise scheme.
As a further aspect of the present invention, the profile construction module constructs a user-specific fitness profile as follows:
p4.1, collecting and arranging user health data, exercise science knowledge and nutrition knowledge, classifying various knowledge of body building exercise according to exercise type, intensity, body part and effect dimensions, and carrying out standardized processing on data from different sources;
p4.2, extracting each group of entity information from each processed data by NLP technology, defining attribute for each entity, determining relation information among different entities, taking the relation among the entities as edges, connecting each entity node to construct a corresponding graph structure, and storing the constructed fitness graph through a graph structure library;
And P4.3, analyzing the health data of the specific user by utilizing an inference engine based on the constructed exercise pattern, generating personalized suggestions by combining various information in the exercise pattern according to the specific health data and targets of the user, and periodically updating and maintaining the exercise pattern according to the latest exercise science research and user feedback.
As a further aspect of the present invention, the specific steps of the solution adjustment module for personalized adjustment of a motion solution are as follows:
P5.1, periodically collecting real-time feedback and monitoring data of a user, taking the maximized satisfaction degree of the user to a scheme as a target, constructing an objective function to evaluate the overall adaptability and effect of the user under a given motion scheme, constructing a priori probability model by using the current feedback data and monitoring data, and calculating the priori distribution of the current objective function through the priori probability model;
P5.2, after obtaining new user feedback and monitoring data, calculating and updating probability distribution of an objective function through a Bayesian formula according to prior distribution and likelihood function so as to obtain corresponding posterior distribution, and after updating the posterior distribution, selecting a next motion scheme for experiment through maximizing expected improvement;
And P5.3, carrying out loop iteration optimization, updating the prior probability model by using new user feedback and monitoring data after each experiment, reselecting the next exercise scheme to carry out the experiment until the preset target value is reached, stopping, collecting the current optimized exercise scheme after iteration is finished, and generating a detailed exercise scheme report according to the personalized adjusted scheme.
Compared with the prior art, the invention has the beneficial effects that:
1. The body-building exercise scheme generating method based on the optimization algorithm extracts parameter combinations in the preliminarily generated exercise scheme, randomly generates N groups of different random solutions, wherein each group of solutions represents the parameter combinations of one group of exercise schemes, initializes a corresponding number of search bodies in a scheme space according to the generated random solutions, each group of search body positions corresponds to one group of exercise schemes, calculates the fitness of each group of exercise schemes according to a user target, compares the fitness of each exercise scheme at the beginning of each iteration, determines the position with the highest fitness, calculates the distance between each search body and the optimal position and the movement coefficient, judges whether the search bodies partially surround the optimal position, if the movement coefficient is smaller than 1, calculates the fitness of each group of exercise schemes according to the calculated distance and the set movement coefficient, updating the positions of the search bodies, calculating Euclidean distance between each updated search body and the optimal position again, updating the positions again by using a logarithmic spiral formula, otherwise, randomly selecting the positions of a group of search bodies, updating the positions of the rest search bodies, repeatedly carrying out iterative updating on the positions of the search bodies until reaching the preset maximum iterative times, outputting the optimal position after iteration is finished, namely, the optimized exercise scheme, updating the training content, strength, frequency and combination of the original scheme of the user according to the optimized exercise scheme, improving the overall quality and rationality of the exercise scheme, ensuring that the generated scheme is more balanced in the training effect and user experience, avoiding tiredness of the user in the exercise process, and improving the overall training power and persistence.
2. The fitness exercise scheme generating system based on the optimization algorithm periodically collects real-time feedback and monitoring data of users, aims at maximizing satisfaction degree of the users to the scheme, builds objective function evaluation, under a given exercise scheme, builds a priori probability model by using current feedback data and monitoring data, calculates priori distribution of the current objective function through the priori probability model, calculates and updates probability distribution of the objective function according to the priori distribution and likelihood function after new user feedback and monitoring data are obtained, calculates and updates probability distribution of the objective function according to Bayesian formulas to obtain corresponding posterior distribution, and after posterior distribution update is completed, selects a next exercise scheme to conduct experiments through maximizing expected improvement, carries out cyclic iterative optimization, updates the priori probability model by using the new user feedback and monitoring data after each experiment, reselects the next exercise scheme to conduct experiments until reaching a preset target value, collects the current optimized fitness exercise scheme, generates a detailed fitness scheme report according to the personalized adjusted scheme, ensures that the fitness scheme can change of physical state and health condition of the users at any time, reduces the personalized risk, adjusts the personalized risk, and effectively adjusts the personalized adjustment time.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments.
Example 1
Referring to fig. 1, the embodiment discloses a body-building exercise scheme generating method based on an optimization algorithm, which comprises the following specific steps:
basic information and body data of a user are collected and preprocessed.
And carrying out priority allocation on the user fitness target and constructing a fitness map.
Specifically, according to the fitness requirement of a user, acquiring the overall fitness target of the user, realizing all sub-targets and a specific action scheme of the overall target, constructing a corresponding target layer, a criterion layer and a scheme layer according to all groups of information, comparing all the sub-targets in the criterion layer by pairs based on expert experience and user preference, giving relative importance scores, constructing a comparison matrix, inputting all the groups of scores into the comparison matrix, carrying out normalization processing on all columns of the comparison matrix, carrying out consistency verification on the processed comparison matrix, and if the consistency ratio CR of the comparison matrix is smaller than 0.1, readjusting the comparison matrix, taking the weight vector of the comparison matrix passing the consistency verification as the final weight distribution result of all the sub-targets, sequencing all the groups of sub-targets from high to low according to weight values, wherein the higher the weight value is, the higher the priority of the sub-targets is.
And generating a motion scheme meeting the user target based on graph reasoning.
Specifically, user historical training data, body data and external conditions are collected, feature information of each group of data is extracted through feature engineering, a time step is set, the feature information of each time step is used as an input sequence, each generated group of input sequences is divided into a training set and a verification set, parameters of an RNN model are initialized, the training set data are input into the RNN model, in the forward propagation process, the RNN model gradually processes each group of input sequences of the training set, hidden states and output of each time step are calculated, after the forward propagation is finished, an error between the model prediction output and a real target is calculated through a mean square error function, an error value is reversely propagated, gradients of each group of parameters of each layer of the model are calculated, the parameters of the RNN model are updated through RMSprop algorithm according to the gradients calculated in the reverse propagation, performance of the model on unseen data is estimated through the verification set, the model parameters are repeatedly trained and verified according to the estimated results until a preset error threshold is reached, and the trained RNN model is generated according to the current user body building priority and the predicted conditions, and the predicted results of the user under the conditions comprise the combined training conditions and the predicted training conditions and the initial exercise strength.
Globally optimizing the initially generated fitness program and iterating the improvement program step by step.
Specifically, parameter combinations in a preliminarily generated motion scheme are extracted, N groups of different random solutions are randomly generated, each group of solutions represents a group of parameter combinations of the motion scheme, then a corresponding number of search bodies are initialized in a scheme space according to the generated random solutions, each group of search body positions corresponds to one group of motion schemes, the fitness of each group of motion schemes is calculated according to a user target, at the beginning of each iteration, the fitness of each motion scheme is compared, the position with the highest fitness is determined, then the distance between each search body and the optimal position and the movement coefficient are calculated, whether the search bodies partially surround the optimal position or not is judged, if the movement coefficient is smaller than 1, the positions of each search body are updated according to the calculated distance and the set movement coefficient, the Euclidean distance between each search body and the optimal position after the update is calculated again, the positions of each search body after the update are updated again updated by using a logarithmic spiral formula, otherwise, the positions of the rest search bodies are randomly selected, the positions of each search body are updated repeatedly until the preset maximum iteration times are reached, after the iteration is finished, the optimal position is output, and the motion scheme is optimized, and the user content is combined according to the training frequency is optimized.
In this embodiment, a specific calculation formula of the distance between the search body and the optimal position is as follows:
in the formula, Representing the distance between the search volume and the optimal position; Representing the optimal solution of the current iteration; Representing the location of the current search volume; the representative coefficient vector is used for adjusting the relative distance between the current solution and the optimal solution;
The specific calculation formula for updating the position of each search body is as follows:
in the formula, Representing the distance between the search volume and the optimal position; and representing a coefficient vector that adjusts the magnitude of the search volume movement to the optimal solution.
It should be further noted that, based on the user's health data and goals, a preliminary exercise regimen is generated. The program comprises a training program for one week, and comprises strength training, aerobic exercise, flexibility training and the like. And optimizing the preliminary scheme by a WOA optimization algorithm, regarding the preliminary scheme as a solution in a search space, enabling a search body to surround a target area by gradually adjusting training parameters, simulating spiral swimming around a prey, updating the position of each solution to further explore the optimization direction of the scheme, and randomly searching the global space when the search body fails to find a better solution so as to avoid sinking into local optimization.
And carrying out personalized adjustment on the scheme according to the real-time feedback and the monitoring data of the user.
A multi-objective trade-off is made and a final fitness exercise program is generated.
Example 2
Referring to fig. 2, the embodiment discloses a fitness exercise scheme generating system based on an optimization algorithm, which comprises an information collecting module, a target setting module, a data processing module, a map construction module, a weight distribution module, a preliminary generation module, an optimization evaluation module, a user feedback module, a scheme adjustment module and a result output module;
The system comprises an information collection module, a target setting module, a data processing module and a map construction module, wherein the information collection module is used for collecting basic information and health data of a user, the target setting module is used for setting a personal fitness target, a target quantization index and a target time frame by the user, the data processing module is used for cleaning, standardizing and encoding the collected user information and target data, and the map construction module is used for combining the health data of the user with the existing sports science knowledge and nutrition knowledge to construct a user specific fitness map.
Specifically, user health data, sports science knowledge and nutrition knowledge are collected and arranged, then each knowledge of body building exercises is classified according to exercise type, intensity, body part and effect dimensions, data from different sources are standardized, each group of entity information is extracted from each processed data through an NLP technology, attributes are defined for each entity, relationship information among different entities is determined, the relationship among the entities is used as edges and connected with each entity node to construct a corresponding graph structure, the constructed exercise graph is stored through a graph structure library, based on the constructed exercise graph, the health data of a specific user is analyzed by utilizing an inference engine, personalized suggestions are generated according to the specific health data and targets of the user and each item of information in the exercise graph, and then the exercise graph is updated and maintained regularly according to latest sports science research and user feedback.
The system comprises a weight distribution module, a preliminary generation module, an optimization evaluation module and a user feedback module, wherein the weight distribution module is used for carrying out priority distribution on a plurality of targets of a user, the preliminary generation module is used for generating a preliminary body-building exercise scheme according to user information, target setting and reasoning results of a knowledge graph, the optimization evaluation module is used for carrying out global search and optimization on the preliminarily generated exercise scheme and evaluating the optimized exercise scheme so as to carry out iterative improvement, and the user feedback module is used for recording feedback actual experience and feeling of the user in the process of executing the exercise scheme.
The proposal adjusting module is used for carrying out personalized adjustment on the exercise proposal according to the feedback of the user and the proposal evaluation result, and the result output module is used for outputting the optimized and adjusted body-building exercise proposal.
Specifically, real-time feedback and monitoring data of a user are collected regularly, and objective of maximizing satisfaction degree of the user to a scheme is achieved, an objective function is built to evaluate overall adaptability and effect of the user under a given motion scheme, then a priori probability model is built by using current feedback data and monitoring data, the priori distribution of the current objective function is calculated through the priori probability model, after new user feedback and monitoring data are obtained, probability distribution of the objective function is updated through a Bayesian formula according to the priori distribution and likelihood function to obtain corresponding posterior distribution, after posterior distribution updating is completed, the next motion scheme is selected for experiment through maximizing expected improvement, iterative optimization is conducted, after each experiment is conducted, the new user feedback and monitoring data are utilized to update the priori probability model, the next motion scheme is reselected for experiment until a preset target value is reached, after iteration is finished, the current optimized exercise scheme is collected, and a detailed exercise scheme report is generated according to the personalized adjusted scheme.
In this embodiment, the posterior distribution specifically has the following calculation formula:
in the formula, Representing the function at a given targetIn the case of (a), observe dataProbability of (2); represents a normalization constant; Representing a priori distribution.