function maximize/minimize in Smath Studio

function maximize/minimize in Smath Studio - Help! - Messaggi

#1 Pubblicato: 28/04/2021 16:47:54
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Hi, guys
I need help for my graduation work, i need to use maximize function in Smath Studio, but i have no idea how to do it .
Is there a plugin for maximize / minimize functions in Smath Studio?
#2 Pubblicato: 28/04/2021 22:58:15
overlord

overlord

600 apprezzamenti in 1.381 post.

Gruppo: Moderator

Wrote

Hi, guys
I need help for my graduation work, i need to use maximize function in Smath Studio, but i have no idea how to do it .
Is there a plugin for maximize / minimize functions in Smath Studio?


You can write your own functions.
maximize and minimize are peak points of slope.
Take derivative of equation, solve it.
Check the examples below.

Regards

maximize_minimize.sm (16,48 KiB) scaricato 1227 volta(e).

maximize_minimize with different solvers.sm (28,5 KiB) scaricato 1230 volta(e).

maximize_minimize.png
1 utenti hanno apprezzato questo post
Alvaro 29/04/2021 00:29:00
#3 Pubblicato: 29/04/2021 09:00:50
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

I have a program in MathCad,the problem is that the marshmallow recipe is being optimized here,

I need a maximization function to find the maximum value of each ingredient.

sbalansir. + organoleptika zefira - f-cii Ketle.xls (21 KiB) scaricato 862 volta(e).

the exel file contains the values ​​of each marshmallow component that are used in the task.

sbalansir. + organoleptika zefira - f-cii Ketle.xmcd (250,52 KiB) scaricato 1285 volta(e).

The whole problem is that the function K(x) is six-dimensional and there is no idea how to find its derivatives.

I need to do the same in Smath Studio, but there are no Given / Maximize / Minimize functions in Smath,

I don't know how to implement this.

Here is everything that I could implement in Smath from the Mathcad file.

diplomnayaRabota.sm (33,8 KiB) scaricato 1172 volta(e).

p.s If something is not clear, ask, I will try to answer.
Sorry for my bad eng
#4 Pubblicato: 29/04/2021 09:22:32
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: User

Wrote



p.s If something is not clear, ask, I will try to answer.



Hi, can you upload a pdf instead the mathcad xmcd file, please?

Best regards.
Alvaro.
#5 Pubblicato: 29/04/2021 09:56:41
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote



p.s If something is not clear, ask, I will try to answer.



Hi, can you upload a pdf instead the mathcad xmcd file, please?

Best regards.
Alvaro.




everything is written in Russian, if you have any questions, I will explain.

Mathcad - sbalansir. + organoleptika zefira - f-cii Ketle.pdf (245,08 KiB) scaricato 701 volta(e).
#6 Pubblicato: 29/04/2021 10:18:43
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote

Hi, guys
I need help for my graduation work, i need to use maximize function in Smath Studio, but i have no idea how to do it .
Is there a plugin for maximize / minimize functions in Smath Studio?


You can write your own functions.
maximize and minimize are peak points of slope.
Take derivative of equation, solve it.
Check the examples below.

Regards

maximize_minimize.sm (16,48 KiB) scaricato 1227 volta(e).

maximize_minimize with different solvers.sm (28,5 KiB) scaricato 1230 volta(e).

maximize_minimize.png



Unfortunately, this does not work with my function, because it is more complex than yours.
#7 Pubblicato: 29/04/2021 11:44:59
gallyon1

gallyon1

0 apprezzamenti in 6 post.

Gruppo: User

Why are denominators 0? B2j≠B1j. Am i wrong?
#8 Pubblicato: 29/04/2021 12:16:06
overlord

overlord

600 apprezzamenti in 1.381 post.

Gruppo: Moderator

Wrote

Unfortunately, this does not work with my function, because it is more complex than yours.


Here is the first solution for your graphics. Rest are in the example.
This is an ugly and fast solution compiled in a haste.
I am pretty sure someone in the forum will come with a more classy method.

Regards

diplomnayaRabota_rev.sm (40,34 KiB) scaricato 1196 volta(e).

2021-04-29_18-12.png
1 utenti hanno apprezzato questo post
Denis 29/04/2021 13:03:00
#9 Pubblicato: 29/04/2021 12:38:37
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote

Wrote

Unfortunately, this does not work with my function, because it is more complex than yours.


Here is the first solution for your graphics. Rest are in the example.
This is an ugly and fast solution compiled in a haste.
I am pretty sure someone in the forum will come with a more classy method.

Regards

diplomnayaRabota_rev.sm (40,97 KiB) scaricato 1158 volta(e).

2021-04-29_18-12.png



Thanks for your feedback , but I need to calculate maximize from the function K(x),
not from y(j, x).

Check this pdf Mathcad file:
Mathcad - sbalansir. + organoleptika zefira - f-cii Ketle.pdf (245,08 KiB) scaricato 741 volta(e).

After the function K (x), the vector x is given as the initial approximation
and after that the Given and Miximize functions are used for the K(x) function.
I need to get vector X in Smath.
p.s sorry for my bad eng



#10 Pubblicato: 30/04/2021 06:31:24
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Graphs are doctored and more, but can't sanity more
Cheers ...Jean

diplomnayaRabota.sm (45,97 KiB) scaricato 1177 volta(e).



Thanks for your corrections , but the main question was how to get this vector X without the Given and Maximize functions,

because it's obtained from these functions: "X: = Maximize (K, x) ?

1.png
#11 Pubblicato: 30/04/2021 07:24:17
overlord

overlord

600 apprezzamenti in 1.381 post.

Gruppo: Moderator

Wrote

Thanks for your corrections , but the main question was how to get this vector X without the Given and Maximize functions,

because it's obtained from these functions: "X: = Maximize (K, x) ?


That is a total different solver. Smath don't have it integrated.
Maple software has it as Maximize() and Minimize() but plugin doesn't parse it under linux.
At least I couldn't do it with maple plugin.

Maxima can solve that kind of equations with maximize_lp() and minimize_lp().
You have to load(simplex) before using this two functions.
Maybe maxima plugin could work but I can't try it, need a windows user to try it.
I use maxima under terminal, maxima plugin doesn't work with linux.

Regards.
#12 Pubblicato: 30/04/2021 09:03:36
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote

but the main question was how to get this vector X without the Given and Maximize functions,
because it's obtained from these functions: "X: = Maximize (K, x) ?


The bloc solver Given ... Find, Minerr, Maximize, Minimize
is Mathsoft proprietary specific to Mathcad. No such equivalent Smath.
Given/Minerr for fitting model function to data set is done otherwise
in Smath via Conjugate Gradient ... same or even better.
If there is another way of doing in Smath, expect Designers to help.
Sorry Collab, can't help directly on that ... Jean.





I tried to do this for a simple function through the "roots" function, and in the end I found the maximum,

finding the maximum for a simple function.sm (12,91 KiB) scaricato 1233 volta(e).

but there are no ideas how to do this for K (X), since it depends on 6 arguments of the vector x.

Is it possible to somehow implement the same algorithm in my task?
#13 Pubblicato: 01/05/2021 07:42:10
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote

Is it possible to somehow implement the same algorithm in my task ?


The Ancestor of the savant solve is the TKsolve.
The designers of TKsolve are the Founders of Mathsoft/Mathcad.
No Mathcad gurus succeeded to crack the bloc, probably crypted deep.



It's a pity that this method is not solved.
#14 Pubblicato: 01/05/2021 16:57:32
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: User

Hi. There are no minimizers in SMath, with the probable exception of a library in Maxima that can be read and executed, as Overlod point.

However, a kind of minimizer can be implemented as shown in the attached, and incidentally, obtain a solution (just a little bit) better than Mathcad's.

diplomnayaRabota_nleqsol.sm (83,09 KiB) scaricato 1204 volta(e).

Best regards.
Alvaro.
1 utenti hanno apprezzato questo post
Denis 01/05/2021 20:09:00
#15 Pubblicato: 03/05/2021 08:00:05
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Hi. There are no minimizers in SMath, with the probable exception of a library in Maxima that can be read and executed, as Overlod point.

However, a kind of minimizer can be implemented as shown in the attached, and incidentally, obtain a solution (just a little bit) better than Mathcad's.

diplomnayaRabota_nleqsol.sm (83,09 KiB) scaricato 1204 volta(e).

Best regards.
Alvaro.



Thank you so much for your work. I appreciate it.
#16 Pubblicato: 04/05/2021 08:14:35
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Hi. There are no minimizers in SMath, with the probable exception of a library in Maxima that can be read and executed, as Overlod point.

However, a kind of minimizer can be implemented as shown in the attached, and incidentally, obtain a solution (just a little bit) better than Mathcad's.

diplomnayaRabota_nleqsol.sm (83,09 KiB) scaricato 1204 volta(e).

Best regards.
Alvaro.



Hi, I didn't really understand how you made such a function for the previous maximize problem,
I wanted to ask you to help me solve a simpler problem on this topic.

Milk shake optimization.sm (17,76 KiB) scaricato 1206 volta(e).

pdf Mathcad file:

Mathcad - mag.2020 Aleksandr Baranov Optimizacija molochnogo koktejjlja.pdf (99,43 KiB) scaricato 792 volta(e).

In this program, I need to repeat everything in the same way as in the screenshots of MathCad, i attached them to Smath.

I would be very grateful if you could help me.

If you have any questions, ask, I will answer them.
#17 Pubblicato: 04/05/2021 11:41:17
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote

In this program, I need to repeat everything in the same way as in the screenshots of MathCad, I attached them to Smath


Horrible screen shot, nothing to see for understanding.
Seemingly, you have a system to solve ... something like Butler.

Solve Given_Find [CO2_6179 Butler].sm (162,9 KiB) scaricato 1063 volta(e).



I'll try to make a pdf Mathcad file.
Some formulas simply dont fit into the full sheet and go beyond the boundaries.
#18 Pubblicato: 04/05/2021 13:33:46
Denis

Denis

0 apprezzamenti in 14 post.

Gruppo: User

Wrote

Wrote

Some formulas simply don't fit into the full sheet and go beyond the boundaries.


Your Mathcad document is surely badly dressed.



like it turned out to make pdf
Mathcad - mag.2020 Aleksandr Baranov Optimizacija molochnogo koktejjlja.pdf (99,43 KiB) scaricato 792 volta(e).
#19 Pubblicato: 04/05/2021 17:08:24
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: User

Wrote


Hi, I didn't really understand how you made such a function for the previous maximize problem,



Hi. Point is: how to solve that in SMath? Because SMath haven't maximizer, and what you have near to that is al_nleqsolve, you can read that in this way: How to use a traditional solver for seek a maximum with constraints?

So, you have a function K(x) with x element of R^6, a guess xo and the guess value for the maximum K(xo). First, write Check(x), for restrict x for the constraints. Next, because numerical solvers for roots needs the evaluation of the change in the target value, assume that you are looking for the zero of f(x) = K(x) - (1+p)*Ko, where p is some percent increment over Ko. Why? Because you guess that xo it's a good solution, so, Ko = K(xo) "must" to be a good guess for the maximum. The Maximize ad hoc function it's just the implementation for that: here the trick is use K(Check(x)) instead K(x). You can try to change the p-value for get the best answer that you can.

Wrote



In this program, I need to repeat everything in the same way as in the screenshots of MathCad, i attached them to Smath.

I would be very grateful if you could help me.

If you have any questions, ask, I will answer them.



The Mathcad's screenshots are perfect. Here you have a little difference: the restrictions involving another function Kc(x), but it's very similar, and need to write CheckX for x and CheckKc for Kc(x). The trick for CheckKc(x): No one, but three:

First, return some information to the solver about how the things are going. Instead of return 0 or 1, return 0 for Kc is in the good interval, and +/- normi(x) if not.
Second, include CheckKc(CheckX(x)) as second row in the target function for try to get zeros on both components.
Third, include CheckKc in the exit condition for the main loop.

Milk shake optimization nleqsol.sm (1,4 MiB) scaricato 1232 volta(e).


Hope that's helps.
Best regards.

Alvaro.
1 utenti hanno apprezzato questo post
Denis 04/05/2021 18:05:00
#20 Pubblicato: 04/05/2021 19:21:08
Davide Carpi

Davide Carpi

1.443 apprezzamenti in 2.936 post.

Gruppo: Moderator

You might try even these

GoldenSectionSearch.sm (21,17 KiB) scaricato 2061 volta(e).
GradientDescent.sm (16,99 KiB) scaricato 2276 volta(e).
NCGM.sm (19,68 KiB) scaricato 2294 volta(e).
LevenbergMarquardt.sm (45,97 KiB) scaricato 2363 volta(e).
NewtonMethod.sm (18,79 KiB) scaricato 2351 volta(e).
NelderMead.sm (33,02 KiB) scaricato 2261 volta(e).
GaussNewton.sm (20,15 KiB) scaricato 2368 volta(e).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
  • Nuovi post
  • Nessun nuovo post