google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.77k stars 2.09k forks source link

Support for ortools in Golang #953

Open supriya-clutter opened 5 years ago

supriya-clutter commented 5 years ago

Has there been any it interest to support the or tools API in Go ?

EDIT: Current implementation:

ToDo List:

Mizux commented 5 years ago

It is currently not planned for he foreseeable future but since SWIG seems to support GO feel free to send us a PR for the support...

ref: http://www.swig.org/Doc3.0/SWIGDocumentation.html#Go

kchan628 commented 5 years ago

Hi, for anyone trying to go down this route. I started implementing a port of the java cp sat wrapper for go here. But we have decided to go java instead. For anyone that wants to complete the task you might want to pickup the work I started. I had branched from v7.0 tag.

https://github.com/google/or-tools/compare/v7.0...kchan628:go-wrapper

See the makefiles/Makefile.go.mk as a starting point. It currently only supports Mac

make third_party
make go
make test_go

See wrapper code at /go/sat

lperron commented 5 years ago

Hi,

very nice. Can you change the CL such that generated go code is in ortools/gen/go/ or ortools/gen/ortools/go Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00

De : kchan628 notifications@github.com Date : lun. 13 mai 2019 à 18:22 À : google/or-tools Cc : Subscribed

Hi, for anyone trying to go down this route. I started implementing a port

of the java cp sat wrapper for go here. But we have decided to go java instead. For anyone that wants to complete the task you might want to pickup the work I started. I had branched from v7.0 tag.

v7.0...kchan628:go-wrapper https://github.com/google/or-tools/compare/v7.0...kchan628:go-wrapper

See the makefiles/Makefile.go.mk as a starting point. It currently only supports Mac

make third_party make go make test_go

See wrapper code at /go/sat

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/953?email_source=notifications&email_token=ACUPL3PUH2M3IPJ7ZYFXSBLPVGIT7A5CNFSM4GHKMEZKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVI2UEI#issuecomment-491891217, or mute the thread https://github.com/notifications/unsubscribe-auth/ACUPL3NQQNYCCPTFDHVBTVDPVGIT7ANCNFSM4GHKMEZA .

kchan628 commented 5 years ago

hi @lperron I'm not planning to do any more dev work on the go wrapper at the moment. But that seems like a small change to make if somebody wants to continue it.

lperron commented 4 years ago

Agreed. Unfortunately, I have no bandwidth to work on this.

gonzojive commented 4 years ago

Would the OR tools authors like to include Go bindings in the official repo? I created a small project with SWIG bindings and a handwritten layer on top of the SWIG bindings here: https://github.com/gonzojive/or-tools-go. The bindings are quite limited now - only the linear solver.

The repo builds with Bazel, which was easier than dealing with make and friends for me. I don't have the bandwidth to add support for other build systems.

I would prefer to merge the project into the official repo so it can be tested continuously and not subject to as much bitrot, but of course it's up to the authors. Any suggestions about how to organize the code for a pull request would be appreciated.

CosminNechifor commented 3 years ago

Out of curiosity: I see that this was added on the v7.8 milestone. Can you please leave a comment with a small update regarding the go wrapper or if it in your future plans? Thank you. (Decided not to open a feat request since it would be clearly a duplicate of this)

keenanwl commented 3 years ago

I continued on where @kchan628 left off (thanks!):

master...keenanwl:add-go-wrapper

I also converted some of the Java examples into go test files, like the sudoku sat

In order to keep go.mod happy, I didn't move the generated files to ortools/gen/ortools/go as @lperron requested, but there may still be an idiomatic go way to get that done.

There is still some work needed to clean up a bit, fix the comments and add support for the knapsack solver, and any others I missed.

Otherwise:

make third_party
make go
make test_go
lperron commented 3 years ago

Actually, is it possible to generate the files in ortools/gen/ortools/sat/go (for the sat part) and still be able to import as ortools.sat.go ?

This is very nice. Laurent Perron | Operations Research | lperron@google.com | (33) 1 42 68 53 00

Le mar. 22 sept. 2020 à 21:29, keenanwl notifications@github.com a écrit :

I continued on where @kchan628 https://github.com/kchan628 left off (thanks!):

master...keenanwl:add-go-wrapper https://github.com/google/or-tools/compare/master...keenanwl:add-go-wrapper

I also converted some of the Java examples into go test files, like the sudoku sat https://github.com/keenanwl/or-tools/blob/add-go-wrapper/ortools/go/sat/cp_solver_test.go#L148

In order to keep go.mod happy, I didn't move the generated files to ortools/gen/ortools/go as @lperron https://github.com/lperron requested, but there may still be an idiomatic go way to get that done.

There is still some work needed to clean up a bit, fix the comments and add support for the knapsack solver, and any others I missed.

Otherwise:

make third_party make go make test_go

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/953#issuecomment-696932836, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3MSDOEVJMLMX3Z7Y73SHD3KLANCNFSM4GHKMEZA .

Mizux commented 3 years ago

Added a list at top with forks having some go stuff..., hope to work on it once release 8.0 is out

keenanwl commented 3 years ago

@lperron yes, that should be possible. I'll take a look at it tomorrow and see what I come up with.

keenanwl commented 3 years ago

Hopefully it is alright that I went with ortools/gen/ortools/go/sat (08a7fface34b4738a1cb275d60f40c19760d5693), there were some go specific build issues with ortools/gen/ortools/sat and ortools/gen/ortools/sat/go. But I am happy to look at it again if that still doesn't work for you @lperron .

Otherwise I'll just keep going down the list I made of outstanding issues.

amirmm11 commented 3 years ago

@Mizux Would it be easier to wrap the OR-Tools C++ code in a gRPC server (since protocol buffer files exist) and put it in a docker? Then everyone can pull the docker image and write a gRPC client.

irfansharif commented 2 years ago

Here's an adaptor for CP-SAT solver in Go: https://github.com/irfansharif/solver. Built on top of @gonzojive's and @brettgoing's earlier work -- thanks!

prasad-marne commented 2 years ago

@Mizux Any updates on this? I am willing to put in work to add Golang support for constraint solver. Will it be alright to create a PR for that?

solanu commented 2 years ago

What about this? ;-)

Mizux commented 2 years ago

Hi sorry for the delay... Hope to release v9.1 tomorrow then let's have a serious look at Golang support and how to move forward on this subject.

piyushuber commented 2 years ago

Hi. Any updates on this one ?

lperron commented 2 years ago

None, too busy. Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00

Le lun. 17 janv. 2022 à 13:38, piyushuber @.***> a écrit :

Hi. Any updates on this one ?

— Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/953#issuecomment-1014476400, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3LUOENNZ44VFOI7CH3UWQEU3ANCNFSM4GHKMEZA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

ca-123321 commented 2 years ago

I'm hoping this is in the future as well, currently duct-taping calling python from Go, yuck.

cristaloleg commented 6 months ago

Hey, do you need any help with that?

lperron commented 5 months ago

yes!!!

I pushed the CP-SAT go code and samples:

It does not contain any build instruction. In particular, I do not know how to package a go library that contains a significant C++ code.

Here is our badly exported BUILD file for reference in ortools/sat/go. Many of the deps are wrong and should be fixed.

go_library( name = "cpmodel", srcs = [ "cp_model.go", "cp_solver.go", "domain.go", ], cgo = 1, deps = [ ":cp_solver_c", # keep "//base/go:log", # not present in OSS "//third_party/golang/protobuf/v2/proto", # Wrong path "//ortools/sat:cp_model_go_proto", "//ortools/sat:sat_parameters_go_proto", ], )

go_test( name = "cpmodel_test", srcs = [ "cp_model_test.go", "cp_solver_test.go", "domain_test.go", ], cgo = 1, library = ":cpmodel", deps = [ "//base/go:log", "//third_party/golang/cmp", "//third_party/golang/protobuf/v2/proto", # Wrong path "//third_party/golang/protobuf/v2/testing/protocmp", # Wrong path "//ortools/sat:cp_model_go_proto", "//ortools:sat_parameters_go_proto", ], )

cc_library( name = "cp_solver_c", srcs = ["cp_solver_c.cc"], hdrs = ["cp_solver_c.h"], deps = [ "//strings", "//third_party/absl/log", "//ortools/sat:cp_model_cc_proto", "//ortools/sat:cp_model_solver", "//ortools/sat:sat_parameters_cc_proto", "//ortools/util:time_limit", "//util/task:status", # Should use absl status "//util/task:status_cc_proto", # Does it exists in OSS ? ], )

If you are familiar with cmake, you can use cmake.

Thanks Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00

Le jeu. 4 janv. 2024 à 12:13, Oleg Kovalov @.***> a écrit :

Hey, do you need any help with that?

— Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/953#issuecomment-1876922288, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3MLL4TWJXRZIH7K32DYM2FG7AVCNFSM4GHKMEZKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBXGY4TEMRSHA4A . You are receiving this because you were mentioned.Message ID: @.***>

Mizux commented 5 months ago

With color syntax:

go_library(
name = "cpmodel",
srcs = [
"cp_model.go",
"cp_solver.go",
"domain.go",
],
cgo = 1,
deps = [
":cp_solver_c", # keep
"//base/go:log", # not present in OSS
"//third_party/golang/protobuf/v2/proto", # Wrong path
"//ortools/sat:cp_model_go_proto",
"//ortools/sat:sat_parameters_go_proto",
],
)

go_test(
name = "cpmodel_test",
srcs = [
"cp_model_test.go",
"cp_solver_test.go",
"domain_test.go",
],
cgo = 1,
library = ":cpmodel",
deps = [
"//base/go:log",
"//third_party/golang/cmp",
"//third_party/golang/protobuf/v2/proto", # Wrong path
"//third_party/golang/protobuf/v2/testing/protocmp", # Wrong path
"//ortools/sat:cp_model_go_proto",
"//ortools:sat_parameters_go_proto",
],
)

cc_library(
name = "cp_solver_c",
srcs = ["cp_solver_c.cc"],
hdrs = ["cp_solver_c.h"],
deps = [
"//strings",
"//third_party/absl/log",
"//ortools/sat:cp_model_cc_proto",
"//ortools/sat:cp_model_solver",
"//ortools/sat:sat_parameters_cc_proto",
"//ortools/util:time_limit",
"//util/task:status", # Should use absl status
"//util/task:status_cc_proto", # Does it exists in OSS ?
],
)