Comments (7)
There is a change in the add_capacities
branch which allows the follows:
S += green_paint < green_post*Alice
This would imply that green_paint
is scheduled before green_post
if green_post
is schedule on Alice
(also works with the list). The *
can be interpreted in general as an if
.
Is this your requirement? The branch isnt merged yet, but it is basically complete, just didnt merge yet.
from pyschedule.
Looking at the axample, I think no. I want implement the following rules
if green_paint is scheduled on Alice then green_post should be scheduled on Bob
if green_paint is scheduled on Bob then green_post should be scheduled on Alice
green_paint < green_post
I think your code doesn't provide it.
from pyschedule.
here is some snippet that does that:
#! /usr/bin/env python
import sys
sys.path.append('../src')
from pyschedule import Scenario, Task, Resource, solvers, plotters, alt
horizon = 10
S = Scenario('Scenario',horizon=horizon)
green_paint = S.Task('green_paint',completion_time_cost=1)
green_post = S.Task('green_post',completion_time_cost=2)
person = S.Resources('person_',num=2)
green_paint += alt(person)
green_post += alt(person)
green_post += green_paint*person
solvers.mip.solve(S, msg=1)
plotters.matplotlib.plot(S, fig_size=(10, 5))
So if green_paint
is scheduled on any of the person
, then green_post
as well.
from pyschedule.
It looks like initial task where both tasks are scheduled on the same resource, and moreover green_post
is shceduling before green_paint
. In terms of your last example I want the following
if green_paint is scheduled on person_0 then green_post should be scheduled on person_1
if green_paint is scheduled on person_1 then green_post should be scheduled on person_0
green_paint < green_post
Your code sends both tasks to the same resource.
from pyschedule.
Ok, got it wrong, use a capacity constraint:
from pyschedule import Scenario, Task, Resource, solvers, plotters, alt
horizon = 10
S = Scenario('Scenario',horizon=horizon)
green_paint = S.Task('green_paint',completion_time_cost=1,green=1)
green_post = S.Task('green_post',completion_time_cost=2,green=1)
person = S.Resources('person',num=2)
green_paint += alt(person)
green_post += alt(person)
S += person[0]['green'] <= 1
S += person[1]['green'] <= 1
S += green_paint < green_post
solvers.mip.solve(S, msg=1)
plotters.matplotlib.plot(S, fig_size=(10, 5))
from pyschedule.
It looks like sports-scheduling example (link), but It generates an error:
TypeError: unorderable types: NoneType() <= int()
My artificial example (isnpired by your answer) generates 'no solution':
N = 2 # NUM of Tasks
K = 2 # NUM of Legs
M = 2 # NUM of Machines
minTimeTask,maxTimeTask=2,5 # Task Execution time
TaskOfTask = []
Machines = [S.Resource('Machine{0}'.format(m)) for m in range(M)]
for n in range(N):
subTasks = []
for k in range(K):
TaksName = "Task{0}_{1}".format(n+1,k+1)
Task = S.Task(TaksName,randint(minTimeTask,maxTimeTask), completion_time_cost=1, green = 1 )
Task += alt( R for R in Machines )
subTasks.append(Task)
TaskOfTask.append(subTasks)
for M in Machines:
S += M['green']<=1
S.use_makespan_objective()
solvers.mip.solve(S,msg=1)
What am I doing wrong?
from pyschedule.
The following works for me? Please upgrade to the newest version 0.2.29, maybe there is some old bug. I also did some simplification regarding the definiton of the machines. The S += M['green']<=1
is too hard, i dont get a solution, so changed just for testing. Note that i define the Machines as a list and apply the ['green'] <= 1
to all of them at once.
from pyschedule import Scenario, Task, Resource, solvers, plotters, alt
from random import randint
horizon = 50
S = Scenario('Scenario',horizon=horizon)
N = 2 # NUM of Tasks
K = 2 # NUM of Legs
M = 2 # NUM of Machines
minTimeTask,maxTimeTask=2,5 # Task Execution time
TaskOfTask = []
Machines = S.Resources('Machine',num=M)
for n in range(N):
subTasks = []
for k in range(K):
TaskName = "Task{0}_{1}".format(n+1,k+1)
Task = S.Task(TaskName,randint(minTimeTask,maxTimeTask), completion_time_cost=1, green= 1)
Task += alt(Machines)
subTasks.append(Task)
TaskOfTask.append(subTasks)
S += Machines['green'] <= 3
if solvers.mip.solve(S, msg=1):
plotters.matplotlib.plot(S, fig_size=(10, 5))
else:
print('no solution exists')
from pyschedule.
Related Issues (20)
- Assign task length depending on the resource HOT 1
- Annoucement: ProcessScheduler
- TypeError: unsupported operand type(s) for %: 'Task' and 'Resource'
- Py
- Assign Task to any couple of Resources HOT 1
- Python 3.8 : ImportError: cannot import name 'clock' from 'time' HOT 1
- += to Assign Task to Resource Not Working HOT 1
- Optimal solution HOT 3
- Assign any of 2 resources to a task HOT 1
- Restrict resources end time HOT 1
- plans for pyschedule HOT 4
- ImportError: cannot import name 'clock' from 'time' HOT 1
- Flexible Resources
- Different resource cost for different time periods?
- "length cost" by resource / task
- maintenance tasks in industry - BREAK
- Bug when using .diff together with blocking a ressource
- Theres any way to do the Inverse Problem?
- No module named 'pulp.solvers' HOT 2
- pyschedule only works with PuLP 2.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyschedule.