CP Solver to solve Scheduling Problem

307 views
Skip to first unread message

Kelvin S

unread,
Oct 22, 2020, 3:27:14 AM10/22/20
to Google Apps Script Community
Hi everyone, new to the Google Apps Script community and was tackling this particular problem where I have to turn availabilities into schedules with certain constraints. Found that this CP Solver can actually help to tackle this problem but I am not sure if it is possible to incorporate it into my GAS project. All help is welcomed! Many thanks in advance!

Source:
https://developers.google.com/optimization/scheduling/employee_scheduling#program2

Alan Wells

unread,
Oct 22, 2020, 9:41:03 AM10/22/20
to Google Apps Script Community
No, it's not possible to incorporate CP Solver into a GAS project.
CP Solver can be installed to your computer by downloading it, and the suggested installation of CP Solver is run using Python.
Apps Script can't communicate with your computer, and it can't run Python code.
CP Solver is a Constraint Solving program.
If you can find a Constraint Solving REST API then Apps Script could access it by using UrlFetchApp.fetch(url).
Or if there was a open source JavaScript Constraint Solving program that could be adapted to working in Apps Script,
that might be a possibility.
I can't find a Constraint Solving REST API.

There is an NPM (JavaScript) Constraint Solver.

And I found a typescript Constraint Solver.

But I have no idea how much work it would be to modify that code for use in Apps Script.

Apps Script actually has a linear optimization service.

Linear Programing is slightly different than Constraint programming.

If the Constraint Solving code took more time to run than your run time quota limit for Apps Script,
then it would "time out"  (end before it completed).

Kelvin S

unread,
Oct 23, 2020, 12:32:36 PM10/23/20
to Google Apps Script Community
Hey Alan! Thanks for taking the time out to help me out! Really appreciate it. Thanks for the detailed answer too! Will take a look at the links that you provided and see what I can do in the meantime. Cheers!

Delower Hossain

unread,
Feb 6, 2023, 6:08:30 AM2/6/23
to Google Apps Script Community
function onEdit(e) { var mySheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var myRange = e.range; var mySheetName = mySheet.getSheetName(); var currRow = myRange.getRow(); var currCol = myRange.getColumn(); var myCheck = myRange.getValue() if ( mySheetName === 'WITH APPS SCRIPT' && currRow === 1 && currCol === 1 ) { ShowFormulas(myCheck) }; };

how can I solve this problem?
Reply all
Reply to author
Forward
0 new messages