Create a Solver on Ai2

Hello everyone,

I want to create an app based on a googlesheet.
In this one there is a Solver.
I’d like to know if it’s possible to do the same on Ai2 ? If yes, someone could give me the solution or some clues to work on it ?

Thank you


Is the app allowed to cheat off the online sheet’s solver,
or does it have to work by itself offline?

Well I try to do it by itself offline.
I try to follow your advice. It’s about this project I don’t know if you remind it ^^ (Question about "CRUD with Google Sheets, Web App and AI2")

But if you think it’s not possible, I can consider to do it online, if it’s the only way.

The solver used on the sheet has three variables and the equation of the “target cell” use one of these variables.

Can you show us the solver invocation, so we can see if it can be done in blocks on lists?

I don’t know if it’s what you mean

And so variables are : C39;C37 and C34
The “target cell” is C41 which is the sum of values Q
We can have Pt thanks to an equation which use values of S and B. Latters are calculated with the three variables.

From what I can read of the picture of the solver, you are using the evolutionary algorithm in 3 variables with 6 constraints.
The choices of solver are described at

To code one of these solvers in blocks will be hard, compared to finding a JavaScript implementation and running it in a WebViewer.
Sample Google search targets:

Javascript stunt examples can be found at FAQ Section: JavaScript Stunts

To package problems and solutions across the AI2/JavaScript boundary, you should study JSON and Dictionaries.

Similar ?

Thank you both
I think I will follow the TIMAI2 example, this should be easier to me.

@clement_pomarede this is a good question. Thank you for asking it. Would suggest looking into the linear algebra extension on @Taifun website under extension section

1 Like

Well I created the link between the googlesheet and the app, and I added a solver on the sheet. The problem is that I have to play the solver, it does’nt work automatically.

Does someone know if it’s possible to play the solver from my app ? By using a script maybe ?

@clement_pomarede I’m able to confirm for you that this is possible. This kind of thing can be done in a couple of ways depending on your problem scope. Is there a specific optimization problem you are trying to approach?

I need to use a Solver to find 3 variables which are themselves used for others variables. The user of the application enter data which can change, so the solver needs to be updated. This solver uses the method “standard evolutionary”. I didn’t find a way to implement a solver in Ai2. TIMAI2 suggested to make a link between the google sheet and the app.

I choose this because it was the easiest way for me. So, I added a solver on my google sheet (which is my reference because may project is to an app similar to the spreadsheet). But to play the solver I have to click on the button “solve” of the google sheet, which is unfeasible from the application.

That why I need a way to activate the solver from the app. Because without the solver I can’t continue my project.

I hope I was clear ^^’

When you “click on a button” in the spreadsheet what is it doing? calling a google apps script ? If so you can call this when you send the data…

1 Like

It looks like this, the solver is an add-on :

So I have to click on the button solve to activate the solver. But I don’t know how to do it from the app.
And if it’s possible by using a google script, do I need to follow this ? -->
I know nothing in coding, that’s why I ask help …

Can’t find anything (after a quick search) that will allow the triggering of an add-on via script…

Search this board for 'inject' to find @Taifun's technique to push web buttons from AI2.

afaik this method will not work for Google spreadsheets...


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.