I need help for optimization using Ga (2024)

49 views (last 30 days)

Show older comments

noura on 19 Aug 2024 at 7:19

  • Link

    Direct link to this question

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga

  • Link

    Direct link to this question

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga

Commented: Star Strider on 19 Aug 2024 at 15:12

I want to make optimization using genetic algorithm to minimize error between force and displacement (simulated and desired ) . I have 3 numbers of variables (height , depth , width) .. can anyone help me for the coding please

5 Comments

Show 3 older commentsHide 3 older comments

Sam Chak on 19 Aug 2024 at 10:46

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240489

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240489

Hi @noura

What do you mean by "to minimize the error between force and displacement"? The reason I ask is that force and displacement do not have the same physical unit dimension. Although it is possible to compute the error between two variables of different units, does the optimal result retain interpretable meaning in the sense of human reasoning?

noura on 19 Aug 2024 at 11:02

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240519

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240519

I mean to minimize the error between the chart that obtained from ansys and the desired chart

Note : chart between force and displacement

Sam Chak on 19 Aug 2024 at 11:11

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240534

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240534

Hi @noura, Could you please provide a sketch of the "charting error" and evaluate how you plan to make effective use of the code snippet in the Answer below? Your feedback is essential for implementing the given code correctly.

noura on 19 Aug 2024 at 12:06

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240569

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240569

  • Messenger_creation_58bdd1d5-44b2-4fb8-9048-c9b4ef71aba6.jpeg

I need to make optimization using ga to minimize the error between simulated and desired chart as mentioned. The parameters ( height , depth , width ) of a cuboid

Sam Chak on 19 Aug 2024 at 13:12

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240654

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240654

Since you already have the code to run the sim, getting the "Simulated Displacement" points and the "Desired Displacement" points into the "data" array in @Walter Roberson's code should be a relatively easy thing to do.

Since the cuboid's dimension cannot be zero or infinity, estimate some realistic values for the lower and upper bounds for the GA to search within these bounded regions.

I need help for optimization using Ga (7)

Sign in to comment.

Sign in to answer this question.

Answers (2)

Walter Roberson on 19 Aug 2024 at 9:56

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#answer_1500764

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#answer_1500764

Open in MATLAB Online

data = Something Appropriate to set up data

numvar = 3;

A = []; b = [];

Aeq = []; beq = [];

lb = [0, 0, 0];

ub = [inf, inf, inf];

best = ga(@(x)Simulate_force(x, data), numvar, A, b, Aeq, beq, lb, ub);

function val = Simulate_force(x, data)

force = something appropriate using data

displacement = something else appropriate using data

val = sum((force - displacement).^2);

end

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Star Strider on 19 Aug 2024 at 13:16

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#answer_1500924

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#answer_1500924

Open in MATLAB Online

  • Messenger_creation_58bdd1d5-44b2-4fb8-9048-c9b4ef71aba6.jpeg

Perhaps something like this —

figure

imshow(imread('Messenger_crea...ef71aba6.jpeg'))

I need help for optimization using Ga (10)

x = [1 2.5 10:10:100];

simulated = 0.007 * x;

desired = 0.021 * x;

objfcn = @(b,x) b(1) + b(2).*x; % Objective Function

ftns = @(b) norm(desired - objfcn(b,simulated)); % Fitness Function

% PopSz = 500;

% Parms = 2;

% optsAns = optimoptions('ga', 'PopulationSize',PopSz, 'InitialPopulationMatrix',randi(1E+4,PopSz,Parms)*1E-3, 'MaxGenerations',5E3, 'FunctionTolerance',1E-10); % Options Structure For 'Answers' Problems

% t0 = clock;

% fprintf('\nStart Time: %4d-%02d-%02d %02d:%02d:%07.4f\n', t0)

% [B,fval,exitflag,output,population,scores] = ga(ftns, Parms, [],[],[],[],zeros(Parms,1),Inf(Parms,1),[],[],optsAns);

% t1 = clock;

% fprintf('\nStop Time: %4d-%02d-%02d %02d:%02d:%07.4f\n', t1)

% GA_Time = etime(t1,t0)

% DT_GA_Time = datetime([0 0 0 0 0 GA_Time], 'Format','HH:mm:ss.SSS');

% fprintf('\nElapsed Time: %23.15E\t\t%s\n\n', GA_Time, DT_GA_Time)

%

% fprintf('Fitness value at convergence = %.4f\nGenerations \t\t\t\t = %d\n\n',fval,output.generations)

%

% fprintf(1,'\tRate Constants:\n')

% for k1 = 1:length(B)

% fprintf(1, '\t\tB(%2d) = %8.5f\n', k1, theta(k1))

% end

B = ga(ftns, 2)

ga stopped because the average change in the fitness value is less than options.FunctionTolerance.

B = 1x2

0.0106 2.9520

<mw-icon class=""></mw-icon>

<mw-icon class=""></mw-icon>

figure

plot(x, simulated, 'o-', 'DisplayName','Simulated Displacement')

hold on

plot(x, desired, 'x-', 'DisplayName','Desired Displacement')

plot(x, objfcn(B, simulated), 'sr-', 'DisplayName','Optimised Result')

hold off

grid

legend('Location','best')

I need help for optimization using Ga (11)

The ‘B’ vector here are the intercept and slope transformation required to transform ‘simulated’ to ‘desired’. Using ga may be a bit of ‘overkill’ for this problem, however it can be done, assuming I understand what you want to do.

(I’m getting some sort of weird error with respect to declaring the options structure, so I commented-out that code example. That error is ‘The 'ga' function requires the Global Optimization Toolbox’ so I ran it without the options structure and the code I usually use for ga problems, and it worked.)

.

2 Comments

Show NoneHide None

Sam Chak on 19 Aug 2024 at 15:05

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240769

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240769

For static optimization problems involving linear graphs, using a ga() may indeed be considered excessive. However, it appears that the OP intends to determine the dimensions of a cuboid (length × width × height) such that, when a certain magnitude of force F is applied, the cuboid of mass m is displaced by a specific distance x. While the 2nd-order motion model is certainly available, the OP has not provided it.

Star Strider on 19 Aug 2024 at 15:12

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240779

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2146194-i-need-help-for-optimization-using-ga#comment_3240779

Noted. That is the reason I used what has been provided to create an example.

Sign in to comment.

Sign in to answer this question.

See Also

Categories

Mathematics and OptimizationGlobal Optimization ToolboxGenetic Algorithm

Find more on Genetic Algorithm in Help Center and File Exchange

Tags

  • matlab
  • genetic algorithm

Products

  • MATLAB
  • Optimization Toolbox

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


I need help for optimization using Ga (14)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

I need help for optimization using Ga (2024)

References

Top Articles
Raz-Plus ELL Resources for Kids K-6 | Learning A-Z
Raz-Plus ELL Edition - Grade 5
Camping World Of New River
Salons Open Near Me Today
Why Does It Say I Have 0 Followers on TikTok?
Mensenlinq: Overlijdensberichten zoeken in 2024
Audrey Boustani Age
Adventhealth Employee Hub Login
What Was D-Day Weegy
Castle Nail Spa (Plano)
Two men arrested following racially motivated attack on Sanford teen's car
Redbox Locations Walmart
Unlock the Fun: A Beginner's Guide to Playing TBG95 Unblocked Games at School and Beyond
John Chiv Words Worth
Folsom Gulch Covid
Myth or Fact: Massage Parlors and How They Play a Role in Trafficking | OUR Rescue
Craigslist Cars For Sale By Owner Oklahoma City
Iapd Lookup
781 Area Code | Telephone Directories
Katonah Train Times
Walmart Neighborhood Market Gas Price
How Much Is Felipe Valls Worth
Baca's Funeral Chapels & Sunset Crematory Las Cruces Obituaries
Rubmaps Springfield
Wisconsin Volleyball Team Full Leaks
craigslist: northern MI jobs, apartments, for sale, services, community, and events
Mcclure Nba Dfs
Find Words Containing Specific Letters | WordFinder®
Uganda: The tiny flea making it painful for people to walk and work | African Arguments
Duen Boobs
15 Best HDMovie2 Alternatives to Watch Movies in Hindi & Other Indian Languages Online Free Leawo Tutorial Center
Examination Policies: Finals, Midterms, General
Roxplayhouse
Ms Eppi Login
Shapovalov Flashscore
Texas State Final Grades
Dumb Money Showtimes Near Regal Dickson City
Dvax Message Board
Used Golf Clubs On Craigslist
Studentvue Paramount
Aces Login Palo Alto
Brooklyn Park City Hall
Dc Networks Claimant Services
Skip The Games Albany
Watch Shark Tank TV Show - ABC.com
Unveiling The &quot;Little Princess Poppy Only Fans Leak&quot;: Discoveries And Insights Revealed
Winding Road Ahead for China’s EV Growth
No Hard Feelings Showtimes Near Pullman Village Centre Cinemas
Oppenheimer Showtimes Near B&B Theatres Liberty Cinema 12
Best Drugstore Bronzers
Espn Masters Leaderboard
Bòlèt New York Soir
Latest Posts
Article information

Author: Gov. Deandrea McKenzie

Last Updated:

Views: 6116

Rating: 4.6 / 5 (46 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Gov. Deandrea McKenzie

Birthday: 2001-01-17

Address: Suite 769 2454 Marsha Coves, Debbieton, MS 95002

Phone: +813077629322

Job: Real-Estate Executive

Hobby: Archery, Metal detecting, Kitesurfing, Genealogy, Kitesurfing, Calligraphy, Roller skating

Introduction: My name is Gov. Deandrea McKenzie, I am a spotless, clean, glamorous, sparkling, adventurous, nice, brainy person who loves writing and wants to share my knowledge and understanding with you.