# 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**34**

of 247,165

REPUTATION**4,922**

CONTRIBUTIONS

**0** Questions

**2,229** Answers

ANSWER ACCEPTANCE **
0.00%
**

VOTES RECEIVED**613**

RANK**4,738** of 17,235

REPUTATION**243**

AVERAGE RATING**0.00**

CONTRIBUTIONS**3** Files

DOWNLOADS **3**

ALL TIME DOWNLOADS**2438**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

**Content Feed**

Cancel objective function evaluation in Optimization

I think that you can write an output function for the ODE solver that will halt the solver if it takes too long or reaches too l...

2 days ago | 0

How to write the equation for minimizing one day power loss of a PV system as an objective function to be used in Genetic Algorithm.

I think that you need to rethink your objective function. It sounds like the input variables must be integers in a certain range...

2 days ago | 0

Define a optimization problem

Perhaps you left out constraints that the x, y, and z variables should be nonnegative. Put those constraints and the upper bound...

3 days ago | 0

| accepted

How to write the equation for minimizing one day power loss of a PV system as an objective function to be used in Genetic Algorithm.

Your function as written does not make use of the input x1 and x2 values. Instead, it declares these variables as indices for tw...

3 days ago | 0

Confusion over use of fmincon for an optimisation problem

There could be several reasons for your results, in addition to the hard-to-diagnose bugs and other programming errors. One is ...

4 days ago | 0

fsolve gives the same value for different parameters of the nonlinear equation

Your function funH returns the following iinternal values for your initial point x0 = 5 and the other parameters pmt = [1.027313...

4 days ago | 0

What does relative constraint tolerance of fmincon in detail ?

As far as the interpretation, a positive value means at least one constraint is violated. A zero (or negative for other solvers)...

6 days ago | 0

| accepted

Find gradient ascent for 3D surface

You might be interested in this example: Pattern Search Climbs Mount Washington Alan Weiss MATLAB mathematical toolbox documen...

7 days ago | 0

how to run different for loops in MATLAB

Usually, people write functions that accept arguments and return arguments, such as result(k,z,q) = Matlaboptimization(Pemax,Pb...

9 days ago | 0

| accepted

The running time complexity of Mixed-integer linear programming (MILP)?

It is well known that MILP is an NP-complete problem. See https://en.wikipedia.org/wiki/Integer_programming for an explanation. ...

9 days ago | 0

Matlab Optimisation toolbox (Score Constaint)

Instead of minimizing TARGETVALUE - ACTUALVALUE , instead minimize either abs(TARGETVALUE - ACTUALVALUE) or (TARGETVALUE - ACTUA...

10 days ago | 0

| accepted

Hi, I have been trying to carry out the mole balance of certain reactions on excel, but the equations have refused to converge, hence my switch to matlab.

You have a set of linear equations. You can represent your equations in terms of a matrix A and vector b in the usual framework ...

10 days ago | 1

| accepted

Energy storage optimisation problem - separate charge and discharge constraint

You are mixing up the problem-based and solver-based formulations. You need to choose one or the other. If you are using the sol...

10 days ago | 1

| accepted

How can I implement a constraint on any subset of columns in a matrix optimisation variable?

You need to use some of the ideas in Integer and Logical Modeling. Create an auxiliary binary variable tf the same size as resul...

10 days ago | 0

| accepted

How am I getting higher values for my objective function from a global search based on fmincon than I did from fmincon alone?

This does seem strange. If you look at the algorithm description in How GlobalSearch and MultiStart Work, you see that GlobalSea...

12 days ago | 0

| accepted

why there is a different value between the latest Fval and the Optimal Solution that Fmincon gives me

The answer is correct to within tolerances. Generally, you cannot expect an answer that is correct down to the last few decimal ...

12 days ago | 0

| accepted

Solve problem of choice of resistor

To allow this code to work, I copy over your data. % Power source source_V = 5; % voltage of the power source source_I...

14 days ago | 0

Link between Genetic Algorithm ga and Simulink

I am no expert in Simulink®, but perhaps some documented examples might show how to link (Global) Optimization Toolbox solvers t...

16 days ago | 0

Optimization Problem but don't have closed form expression

This seems like a straightforward problem using either the Problem-Based Optimization Workflow or the solver-based approach. As ...

16 days ago | 1

| accepted

How to solve the error "Conversion to logical from optim.problemdef.OptimizationConstraint is not possible!"

You probably need to formulate your constraints according to the procedures in Integer and Logical Modeling. Alan Weiss MATLAB...

27 days ago | 0

| accepted

How do I interpret the results from Multistart?

Here is how to interpret the results. I assume that the local solver is fmincon. The local exitflag is the exit flag from fminc...

27 days ago | 1

| accepted

LaGrange Multiplier constrain with discretised functions

I think that you are making a mistake by trying to use symbolic variables here. If I understand what you are trying to do, you ...

1 month ago | 0

How to check the FMINCON feasibility correctly

If you look at the documentation for fmincon iterative display, you see: Feasibility: Maximum constraint violation, where satis...

1 month ago | 1

How can I apply bayesopt to my Simulink model?

As the documentation states, the objective function accepts a 1-by-D table of values, where D is the number of variables. So you...

1 month ago | 1

| accepted

Implement parameter constraint for surrogateopt

The answer depends on your MATLAB version. As the Release Notes show, linear constraints were introduced in R2021a, nonlinear co...

1 month ago | 0

| accepted

How to constrain fmincon unknowns to itself

Or maybe with linear constraints: A = [1 1 -1 -1]; b = 0; unknowns = fmincon(@(x)fun(x),initial,A,b,[],[],lb,ub) What do the...

1 month ago | 0

| accepted

Global variables are forbidden in parallel multistart optimization

There are other ways to pass variables other than declariig them as global. See Passing Extra Parameters. Alan Weiss MATLAB ma...

1 month ago | 1

| accepted

Can I use "xxx.m" file for object function in GA tool

Please report the MATLAB version you are using, such as R2019a. It makes a difference, because, for example, the Optimization ap...

1 month ago | 1

Hardstop intlinprog & return the current solutions

You don't have to call prob2struct to solve your problem. Just call [sol,fval] = solve(prob,'Options',opts) Now, what should o...

1 month ago | 0

| accepted

How can I use lsqcurvefit with a look-up table search as the objective function? Currently, the initial guess always is identified as a local minimum.

To use lsqcurvefit your function needs to be defined and differentiable for continuous values of p. It looks to me as if your fu...

1 month ago | 0