# Optimization functions in Scilab

**URL:** https://scilab.discourse.group/t/optimization-functions-in-scilab/57
**Category:** Optimization
**Created:** [March 10, 2023, 12:32pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57 "2023-03-10T12:32:41Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)
#### Post date: [March 10, 2023, 12:32pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/1 "2023-03-10T12:32:41Z")

</div>

Scilab can solve many kinds of optimization problems, without or with constraints, needing derivatives or not. The following chart on [www.scilab.org](http://www.scilab.org) gives the name of the Scilab functions for each category of optimization problem :

 ![OptimList](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/02b04c44b8a0a207b025f1ed9dbf4d4d7db92ce6.jpeg)

The toolboxes [sci\_ipopt](https://atoms.scilab.org/toolboxes/sci_ipopt) and [fmincon](https://atoms.scilab.org/toolboxes/fmincon) allow to consider general non-linear problems with non-linear constraints (interior point method).

---

<div class="post-metadata">

### Author: ![cfuttrup](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@cfuttrup](https://scilab.discourse.group/u/cfuttrup)
#### Post date: [March 10, 2023, 7:04pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/2 "2023-03-10T19:04:26Z")

</div>

The available solvers, like e.g. fminsearch, does a good job, but I’d like to see CMA-ES implemented as well.  
I tried (some years ago) and was sidelined by the trouble. It exist in ATOMS, but probably doesn’t work:

> **[Scilab Module : CMA-ES](https://atoms.scilab.org/toolboxes/CMA-ES)**
>
> An algorithm for difficult non-linear non-convex optimization problems.

If anyone is willing to help, I’d like to pick it up (and give credit = we share the job).  
I have some ‘help’ or ‘demo’ code implemented (somewhere, maybe not on my latest computer).

Cheers,  
Claus

---

<div class="post-metadata">

### Author: ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)
#### Post date: [March 10, 2023, 10:55pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/3 "2023-03-10T22:55:23Z")

</div>

Hello Claus,

Did you try to recompile the toolbox ? As the package is of “noarch” type (no compiled gateways) there is a high probability that the toolbox could work as is in the latest release of Scilab. Anyway, thanks for pinging us on that subject as it helps to focus the work of the community on packages that are still of interest.

S.

---

<div class="post-metadata">

### Author: ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)
#### Post date: [March 12, 2023, 3:37am UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/4 "2023-03-12T03:37:46Z")

</div>

Sometimes, the most easy linear Least-Squares fit is used. We are inverting a rectangular matrix like below. Best greetings. Heinz

```auto
A=[0.0675954 0.1493283
   0.3516595 0.7155661
   0.5497236 1.0542451
   0.5852641 1.0899078
   0.5945036 1.1216345
   0.6952329 1.2505237
   0.7327987 1.2878655
   0.7935976 1.3476958
   0.8308286 1.4032977
   0.9171937 1.474964 ];
x=A(:,1); y=A(:,2);
plot(x,y,'o');xgrid();
M=[x x^3];
b=M\y
plot(x,M*b,'-');
xlabel('x');ylabel('y');title('Linear Least-Squares Fit');
legend('data','fit y=b(1).x+b(2).x^3',2);

```

 ![Capture d’écran 2023-03-15 à 08.57.18](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/0eb6ddac442cbeab8524d98f2851c50464341ca9.png)

---

<div class="post-metadata">

### Author: ![cfuttrup](https://avatars.discourse-cdn.com/v4/letter/c/3ec8ea/32.png) [@cfuttrup](https://scilab.discourse.group/u/cfuttrup)
#### Post date: [March 12, 2023, 3:42pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/5 "2023-03-12T15:42:23Z")

</div>

Hi Stéphane

I would like to work on updating the CMA-ES ATOMS package, but only if someone with experience helps me out.

Best regards,  
Claus

---

<div class="post-metadata">

### Author: ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)
#### Post date: [March 13, 2023, 8:08am UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/7 "2023-03-13T08:08:36Z")

</div>

Hello Heinz,

Please have a look to this topic:

[https://scilab.discourse.group/t/welcome-to-the-scilab-discourse-forum/7](https://scilab.discourse.group/t/welcome-to-the-scilab-discourse-forum/7)

You will learn how to format your code so that it can be copy-pasted by readers of you message. To include a screenshot (which could be also nice) click on the “upload” ![Capture d’écran 2023-03-13 à 09.08.02](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/6dc3e903d882dd0b894c7c752d83caab4feb95ed.png) button.

S.

---

<div class="post-metadata">

### Author: ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)
#### Post date: [March 14, 2023, 8:31pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/8 "2023-03-14T20:31:51Z")

</div>

> [@heinznabielek](#):
>
> Sometimes, the most easy linear Least-Squares fit is used. We are inverting a rectangular matrix like below. Best greetings. Heinz

Sometimes, the most easy linear Least-Squares fit can be used: we are inverting a rectangular matrix like below. Best greetings. Heinz

```auto
A=[0.0675954 0.1493283
   0.3516595 0.7155661
   0.5497236 1.0542451
   0.5852641 1.0899078
   0.5945036 1.1216345
   0.6952329 1.2505237
   0.7327987 1.2878655
   0.7935976 1.3476958
   0.8308286 1.4032977
   0.9171937 1.474964 ];
x=A(:,1); y=A(:,2);
plot(x,y,'o');xgrid();
M=[x x^3];
b=M\y
plot(x,M*b,'-');
xlabel('x');ylabel('y');title('Linear Least-Squares Fit');
legend('data','fit y=b(1).x+b(2).x^3',2);
xstring(0.1,1.2,'b(1)=2.0756'); xstring(0.1,1.1,'b(2)=-0.5688');

```

version = “scilab-2023.0.0” on macOS 10.15.7 (19H2026)  
options = “GCC” “x64” “release” “Mar 10 2023” “16:02:56”

OS = “Darwin”, version = “19.6.0”

---

<div class="post-metadata">

### Author: ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)
#### Post date: [March 14, 2023, 9:51pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/9 "2023-03-14T21:51:24Z")

</div>

Hi,

You can edit your post (to include the graphics) by clicking on the pen icon :  
 ![Capture d’écran 2023-03-14 à 22.50.17](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/fd18ee8448f42ead79e6d0f08cd8c06e3ad6aa91.png)

S.

---

<div class="post-metadata">

### Author: ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)
#### Post date: [August 14, 2023, 11:36pm UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/10 "2023-08-14T23:36:54Z")

</div>

I am doing my linear least-squares fits without any subrouten, just by inversion of a rectangular array. How do I handle this, when every y-value has its individual error range?  
Heinz

---

<div class="post-metadata">

### Author: ![heinznabielek](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@heinznabielek](https://scilab.discourse.group/u/heinznabielek)
#### Post date: [August 19, 2023, 3:09am UTC](https://scilab.discourse.group/t/optimization-functions-in-scilab/57/11 "2023-08-19T03:09:51Z")

</div>

Dead simple: divide your measurement vector and you rectangular matrix by the error vector. How could I forget?  
Heinz  
 ![weighted](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/c144f4792cd9c3bd321f7c19917bd4e4258f1ad5.png)
