Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:10:11+00:00 2026-06-08T22:10:11+00:00

I am running into a puzzling error when when using the ga function in

  • 0

I am running into a puzzling error when when using the ga function in MATLAB’s global optimization toolbox, the error message is pasted below to see if anyone can decipher what this means.

I am trying to seed the ga with an initial population, a matrix of pop-by-nvar. However, this produces the error below. I can only get the ga to run if I pass in an initial population vector of (pop-1)-by-nvar. This is a little inconvenient since I want to specify the entire population. I hope someone who is familiar with the global optimization toolbox and the ga function can shed some light here!

??? Index exceeds matrix dimensions.

Error in ==> gacreationlinearfeasible>lhsLambda at 213
    [lambda(i,:),f,e] = fmincon(fun,lambda(i,:),[],[],Aeq,beq,lb,ub,[],opts);

Error in ==> gacreationlinearfeasible>feasibleLHS at 180
            initialPopulation(boundary_points+1:interior_points+boundary_points,:) = ...

Error in ==> gacreationlinearfeasible at 42
        feasiblePop = feasibleLHS(individualsToCreate,GenomeLength,options);

Error in ==> makeState at 30
      state.Population = feval(options.CreationFcn,GenomeLength,FitnessFcn,options,options.CreationFcnArgs{:});

Error in ==> galincon at 18
state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);

Error in ==> ga at 282
        [x,fval,exitFlag,output,population,scores] = galincon(FitnessFcn,nvars, ...
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:10:13+00:00Added an answer on June 8, 2026 at 10:10 pm

    Here is an example of using GA with specifying an initial population:

    %# find minima
    initPop = bsxfun(@plus, [2 3], randn(20,2)*2);    %# 20-by-2 matrix
    opts = gaoptimset('InitialPopulation',initPop);
    [x, fx, flag, out, pop] = ga(@rastriginsfcn, 2, [],[], [],[], [],[], [], opts);
    
    %# plot solution
    figure('Renderer','opengl')
    ezsurfc(@(x,y) rastriginsfcn([x,y])), colormap hot
    line(x(1), x(2), fx, 'Marker','.', 'MarkerSize',50, 'Color','b')
    view(3)
    

    Here is the solution I get after 72 generations:

    screenshot

    Note that the Rastrigin function has the global minimum at (0,0)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am running into a parse error while using xlwt. Simple formula's like SUM()
I am running into the following error using Pear Mail: Notice: Error in sending
Keep running into When using the multi-mapping APIs ensure you set the splitOn param
I'm running into trouble accessing global variables when I make an AJAX call to
I keep running into a pretty frustrating error in Xcode after implementing a date
I'm running into some really weird problems with ctypes. I'm using ctypes to interface
Been running into a problem ever since I started using rvm to manage my
I am running into issues using ASIFormDataRequest . The request seems to be made
Im running into this error that I can't work out Im writing some code
After running into some un-handled exceptions when using Response.Redirect() , I read it up,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.