Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tetrisched - Pass in utility to ChooseExpression and MalleableChooseExpression #62

Merged
merged 6 commits into from
Oct 31, 2023

Conversation

ruizehung
Copy link
Contributor

Summary

  • Add utility to ChooseExpression and MalleableChooseExpression constructor and pass the utility in utilityFunction->addTerm(utility, isSatisfiedVar);
  • Calculate the placement rewards skewed towards placing the task earlier and pass the reward as utility to tetrisched.strl.ChooseExpression
  • Fix build error.

Test Plan

Can build tetrisched

I use Cplex

@ruizehung ➜ .../erdos-scheduling-simulator/schedulers/tetrisched/build (tetrisched-input-utility) $ cmake ..
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The C compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Found Python3: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Using default CPLEX installation at: /workspaces/ibm/ILOG/CPLEX_Studio_Community2211
-- Using default Gurobi installation at: /opt/gurobi1001/linux64
-- Using default Google OR-Tools installation at: /usr/local/include/ortools
-- Adding CPLEX : /workspaces/ibm/ILOG/CPLEX_Studio_Community2211
-- Not Adding GUROBI
-- Not adding OR-Tools
-- pybind11 v2.11.1
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.10.12", minimum required is "3.6")
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython3.10.so
-- Performing Test HAS_FLTO
-- Performing Test HAS_FLTO - Success
-- Found Python: /usr/bin/python3.10 (found version "3.10.12") found components: Interpreter Development Development.Module Development.Embed
-- Installing Python bindings to /usr/lib/python3/dist-packages
-- Configuring done
-- Generating done
-- Build files have been written to: /workspaces/erdos-scheduling-simulator/schedulers/tetrisched/build
@ruizehung ➜ .../erdos-scheduling-simulator/schedulers/tetrisched/build (tetrisched-input-utility) $ make
[  5%] Building CXX object CMakeFiles/tetrisched.dir/src/Expression.cpp.o
[ 10%] Building CXX object CMakeFiles/tetrisched.dir/src/Partition.cpp.o
[ 15%] Building CXX object CMakeFiles/tetrisched.dir/src/SolverModel.cpp.o
[ 20%] Building CXX object CMakeFiles/tetrisched.dir/src/Scheduler.cpp.o
[ 25%] Building CXX object CMakeFiles/tetrisched.dir/src/CPLEXSolver.cpp.o
[ 30%] Linking CXX shared library libtetrisched.so
[ 30%] Built target tetrisched
[ 35%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 40%] Linking CXX static library ../../../lib/libgtest.a
[ 40%] Built target gtest
[ 45%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[ 50%] Linking CXX static library ../../../lib/libgtest_main.a
[ 50%] Built target gtest_main
[ 55%] Building CXX object CMakeFiles/test_tetrisched.dir/test/test_expression.cpp.o
[ 60%] Building CXX object CMakeFiles/test_tetrisched.dir/test/test_partitions.cpp.o
[ 65%] Building CXX object CMakeFiles/test_tetrisched.dir/test/test_solver.cpp.o
[ 70%] Linking CXX executable test_tetrisched
[ 70%] Built target test_tetrisched
[ 75%] Building CXX object CMakeFiles/tetrisched_py.dir/python/TetrischedPy.cpp.o
[ 80%] Linking CXX shared module tetrisched_py.cpython-310-x86_64-linux-gnu.so
[ 80%] Built target tetrisched_py
[ 85%] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o
[ 90%] Linking CXX static library ../../../lib/libgmock.a
[ 90%] Built target gmock
[ 95%] Building CXX object _deps/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[100%] Linking CXX static library ../../../lib/libgmock_main.a
[100%] Built target gmock_main
@ruizehung ➜ .../erdos-scheduling-simulator/schedulers/tetrisched/build (tetrisched-input-utility) $

Pass test_tetrisched

See https://gist.github.com/ruizehung/cdd9e23e391bee6e915d39d6421971e3

(TBD)Can run python3 main.py --flagfile=configs/new_av_workload.conf

I cannot run python3 main.py --flagfile=configs/new_av_workload.conf fully since I am using Cplex academic version and I'm having issue with license check ...

@ruizehung ➜ /workspaces/erdos-scheduling-simulator (tetrisched-input-utility) $ python3 main.py --flagfile=configs/new_av_workload.conf
Parsing LessThanExpression with name Sensor@AutonomousVehicle@0_less_than.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 0 and ending at 10.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 1 and ending at 11.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 2 and ending at 12.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 3 and ending at 13.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 4 and ending at 14.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 5 and ending at 15.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 6 and ending at 16.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 7 and ending at 17.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 8 and ending at 18.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 9 and ending at 19.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 10 and ending at 20.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 11 and ending at 21.
The Choose Expression for Sensor@AutonomousVehicle@0 will be limited to 1 partitions.
Parsing Choose expression for Sensor@AutonomousVehicle@0 to be placed starting at time 12 and ending at 22.
.....
.....
.....
Adding Constraint Planning@AutonomousVehicle@0_fulfills_demand_at_139(1438) to CPLEX Model.
Adding Constraint Planning@AutonomousVehicle@0_fulfills_demand_at_141(1440) to CPLEX Model.
Adding Constraint Planning@AutonomousVehicle@0_fulfills_demand_at_143(1442) to CPLEX Model.
Adding Constraint Planning@AutonomousVehicle@0_fulfills_demand_at_145(1444) to CPLEX Model.
Adding Constraint Planning@AutonomousVehicle@0_fulfills_demand_at_147(1446) to CPLEX Model.
Checking license ...
cpxchecklic: Exiting with code 1

Child process exited with code 1
No license found. [0.03 s]
Traceback (most recent call last):
  File "/workspaces/erdos-scheduling-simulator/main.py", line 634, in <module>
    app.run(main)
  File "/home/vscode/.local/lib/python3.10/site-packages/absl/app.py", line 308, in run
    _run_main(main, args)
  File "/home/vscode/.local/lib/python3.10/site-packages/absl/app.py", line 254, in _run_main
    sys.exit(main(argv))
  File "/workspaces/erdos-scheduling-simulator/main.py", line 630, in main
    simulator.simulate()
  File "/workspaces/erdos-scheduling-simulator/simulator.py", line 443, in simulate
    if self.__handle_event(self._event_queue.next()):
  File "/workspaces/erdos-scheduling-simulator/simulator.py", line 1424, in __handle_event
    self.__handle_scheduler_start(event)
  File "/workspaces/erdos-scheduling-simulator/simulator.py", line 483, in __handle_scheduler_start
    sched_finished_event = self.__run_scheduler(event)
  File "/workspaces/erdos-scheduling-simulator/simulator.py", line 1750, in __run_scheduler
    placements = self._scheduler.schedule(
  File "/workspaces/erdos-scheduling-simulator/schedulers/tetrisched_scheduler.py", line 136, in schedule
    self._scheduler.schedule(sim_time.time)
RuntimeError: Caught an unknown exception!
@ruizehung ➜ /workspaces/erdos-scheduling-simulator (tetrisched-input-utility) $

Copy link
Contributor

@sukritkalra sukritkalra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the quick PR. Minor changes requested.

schedulers/tetrisched/include/tetrisched/Expression.hpp Outdated Show resolved Hide resolved
schedulers/tetrisched/src/Expression.cpp Show resolved Hide resolved
Copy link
Contributor

@sukritkalra sukritkalra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Great work!

@sukritkalra sukritkalra merged commit 99450cf into main Oct 31, 2023
@sukritkalra sukritkalra deleted the tetrisched-input-utility branch November 10, 2023 01:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants