# Alan Weiss

### MathWorks

I write documentation for MATLAB mathematical toolboxes, primarily optimization. I have also written documentation for PDE, statistics, symbolic math, and econometrics.

My pre-MathWorks job was with Bell Labs, primarily in mathematical models of data traffic, with a strong interest in parallel computation and in rare events (large deviations).

I do not provide private consulting. If you have a question, please ask on a public forum such as MATLAB Answers.

**Statistics**

RANK**35**

of 257,598

REPUTATION**5,080**

CONTRIBUTIONS

**0** Questions

**2,297** Answers

ANSWER ACCEPTANCE **
0.00%
**

VOTES RECEIVED**632**

RANK**4,811** of 17,747

REPUTATION**244**

AVERAGE RATING**0.00**

CONTRIBUTIONS**3** Files

DOWNLOADS **3**

ALL TIME DOWNLOADS**2444**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Simulink using with fmincon

Perhaps you can look at some worked examples and figure it out: Using fminimax with a Simulink Model lsqnonlin with a Simulink...

1 day ago | 0

I use fcn2optimexpr,but I got an error for scalar optimizationexpression

You had a misunderstanding. The A variable should be a scalar, not a vector. All issues stemmed from that one misunderstanding. ...

8 days ago | 0

| accepted

how can I optimize a neural network with multiple outputs using the Genetic Algorithm ?

Generally speaking, optimization algorithms try to minimize a single scalar function of the input variables . I don't know what...

10 days ago | 1

how can i validate my optimization algorithm?

Your objective function is smooth. Therefore, you should not be using particleswarm or ga or simulannealbnd, but instead should ...

10 days ago | 0

Using GA can I put a condition on Population?

Sure, that is a simple linear inequality constraint. Probably easiest to represent using the problem-based formulation, but do w...

12 days ago | 0

how to write multi objective particle swarm optimization?

As you probably understand, particleswarm is for single-objective optimization. You can fake the multiobjective part by taking a...

15 days ago | 0

fmincon does not fulfil constraints

As documented, Iterations Can Violate Constraints. So I am not sure whether you are complaining about intermediate iterations (w...

18 days ago | 0

| accepted

Gradient Calculation with fmincon and UseParallel

This is not the expected performance. I would usually expect that parallel gradient estimation would give you quite a bit of spe...

1 month ago | 0

Recommended ML toolbox for complex spaceship braking optimization.

You might be able to use some Optimization Toolbox solvers. There is one (laughably simplified, but still) relevant example here...

1 month ago | 0

Genetic Algorithm and PSO not varying from initial point, regardless of parameters and fitness function

You have a linear objective function and linear constraints. You should use linprog to solve your problem. Typically, a linear p...

1 month ago | 0

optimization toolbox in matlab

This sounds like a job for intlinprog. Alan Weiss MATLAB mathematical toolbox documentation

1 month ago | 0

Determinant of the Jacobian as a constraint couldn't avoid atan2(x,y) get into negative.

While I do not know what you are really doing, you should know that nonlinear constraints are not satisfied at intermediate iter...

1 month ago | 1

| accepted

Genetic algorithm takes too much time to solve _ only linear objective and constraints

You say that you have a linear objective function and linear and integer constraints. In that case, you should not use the gene...

1 month ago | 1

Arrays have incompatible sizes for this operation error

You are mixing up the two approaches, problem-based and solver-based. You cannot do that. You have x and y defined as optimizati...

1 month ago | 0

how to Plot convergence of Simulated annealing optimization problem?

Perhaps you want to collect the cost as a vector that you can then plot. Something like this: % Put this line immediately after...

1 month ago | 0

Very small feasibility value but very large first-order optimality value

This is a very interesting issue; I have never seen anything quite like it before. Apparently, you are providing gradients for b...

1 month ago | 0

| accepted

Arrays have incompatible sizes for this operation error

It looks like the issue is that ai is not 36-by-36. You probably want something like ai = repmat(ai,1,36); z= (-1)*sum(x.*rij....

1 month ago | 0

How to input mixed positive integer variable to "gamultiobj" fitness function?

If your MATLAB version is R2021b or later, you can use integer constraints in gamultiobj. For details, see the function referenc...

2 months ago | 0

How to introduce constraints to my objective function (Genetic Algorithm)

You have at least two errors that keep the constraint function from working properly. First, this section needs a loop such as f...

2 months ago | 0

| accepted

Problem training Gaussian process with 'ardsquaredexponential' kernel function using bayesopt

As stated in the documentation for OptimizeHyperparameters: "KernelScale cannot be optimized for any of the ARD kernels." Alan...

2 months ago | 1

| accepted

Optimization completed because the size of the gradient is less than the value of the optimality tolerance.

I think that you are mistaking the exit message for the solution. The solution resides in the p variable that the solver returns...

2 months ago | 1

I am doing Genetic algorithm for optimisation , but it is very slowly optimising, 1st itteration is not complete since 5hours but it is showing optimisation running.

ga is a slow algorithm. Most likely you have nonlinear constraints, which makes the algorithm even slower. If you do not have in...

2 months ago | 0

Get best hyperparameters for ionosphere data using fitcecoc & bayesopt. but i am getting error optimizableVariable.

I do not understand why you are attempting to use fitcecoc with a 2-class model. Try this instead: load ionosphere mdl = fitcs...

2 months ago | 0

| accepted

How to solve "Conversion to logical from optim.problemdef.OptimizationInequality is not possible." for logical statement for variable.

You need to take care of logical constraints using a roundabout sort of modeling construct. The documentation is here: Integer a...

2 months ago | 0

fmincon pause after 2 iterations when using gradients

I don't know for sure, but MATLAB has a just-in-time compiler that does indeed make a sort of cache for code that is repeatedly ...

2 months ago | 0

| accepted

lsqnonlin projectBox error when using OutputFcn

The error is because optimValues.residual is a vector, not a scalar. Possibly you want to write norm(optimValues.residual). Ala...

2 months ago | 0

How can I ensure the nonlinear constraints are met before running the objective function?

You are in luck: all of your "nonlinear" constraints are, in fact, linear constraints. Simply rewrite your constraints as linear...

2 months ago | 1

| accepted

When I'm using the fmincon function to solve an optimization problem，the optimization result is always near the initial value. How to avoid this situation?

There is a documentation section about this issue: Final Point Equals Initial Point. There is also the possibility that you are ...

3 months ago | 0

How can I use Genetic Algorithm toolbox to calibrate a model?

It is entirely possible that I have misunderstood your question in some way. Feel freee to ask again with more explanation if my...

3 months ago | 0

Optimization for differential equations and measuring points

You might find the following examples relevant: Fit ODE, Problem-Based Fit an Ordinary Differential Equation (ODE) Alan Weiss...

3 months ago | 0