Here I will model and "implement" some linear optimization problems using CPlex library for C++ ^~^
- Download CPlex
-
- IBM made it specially for Visual Studio, and I couldn't be able to port it to anywhere (and it doesn't seem to be possible); it seems to be easy to setup it on VS, but I didn't try it. But you can run it with WSL (Windows Subsystem for Linux) and configure include folder on any IDE, so you will get some lints; and that's what I did.
-
- Make sure to have JDK 8 installed (If it still doesn't work, add it to the PATH).
- sudo apt install openjdk-8-jdk
- With the .bin (I will call it cplex.bin) downloaded, do:
- chmod +x cplex.bin
- ./cplex.bin
- Follow the installer. You can install it in any folder you want, just remember the path of it, we will need it to adjust the Makefile.
- Use the Makefile to compile:
- It receives: "path=<path to the name of your file (without .cpp)>" as argument, so you don't need to edit everytime neither copy it to the folder you're working on.
- Example: make TransportProblem/transportProblem
- If there's no compilation error: it will generate a yourFile.run
- It receives: "path=<path to the name of your file (without .cpp)>" as argument, so you don't need to edit everytime neither copy it to the folder you're working on.
- Run it using: ./yourFile.run
- Make sure to have JDK 8 installed (If it still doesn't work, add it to the PATH).
-
- In order to use lint/autocomplete in any IDE, you need to provide the "include" folder of the library you will use. But, for some reason, CPLEX include had a small bug that broke VisualCode's lint (and probably any other IDE). I fixed and it's here. Just copy and paste it into the "include" folder of your compiler.