Ortools CVRP reuse the used vehicle - python-3.x

I want to use or tools to solve the CVRP problem and I know can use routing.IsVehicleUsed(assignment, vehicle_id) method know the vehicle is used or not.
Can I reuse the used vehicle.
Because I have a problem ,when I set data['num_vehicles'] = 1 or-tools returns no result but when I set data['num_vehicles'] = 4 I got a solution.
It cannot be modified the data['vehicle_capacities'] so I want to the used vehicle can start again when it return start point

Once a vehicle reach its end node, it's over. End node are always the last node of a vehicle route.
You should create some dummy node (duplicate of depot) to simulate an unload please take a look at the refuel station example in the sample directory on github...

Related

Update a parameter value in Brightway

It seems to be a simple question but I have a hard time to find an answer to it. I already have a project with several parameters (project and database parameters). I would like to obtain the LCA results for several scenarios with my parameters having different values each time. I was thinking of the following simple procedure:
change the parameters' value,
update the exchanges in my project,
calculate the LCA results.
I know that the answer should be in the documentation somewhere, but I have a hard time to understand how I should apply it to my ProjectParameters, DatabaseParameters and ActivityParameters.
Thanks in advance!
EDIT: Thanks to #Nabla, I was able to come up with this:
For ProjectParameter
for pjparam in ProjectParameter.select():
if pjparam.name=='my_param_name':
break
pjparam.amount = 3
pjparam.save()
bw.parameters.recalculate()
For DatabaseParameter
for dbparam in DatabaseParameter.select():
if dbparam.name=='my_param_name':
break
dbparam.amount = 3
dbparam.save()
bw.parameters.recalculate()
For ActivityParameter
for param in ActivityParameter.select():
if param.name=='my_param_name':
break
param.amount = 3
param.save()
param.recalculate_exchanges(param.group)
You could import DatabaseParameter and ActivityParameter iterate until you find the parameter you want to change, update the value, save it and recalculate the exchanges. I think you need to do it in tiers. First you update the project parameters (if any) then the database parameters that may depend on project parameters and then the activity parameters that depend on them.
A simplified case without project parameters:
from bw2data.parameters import ActivityParameter,DatabaseParameter
# find the database parameter to be updated
for dbparam in DatabaseParameter.select():
if (dbparam.database == uncertain_db.name) and (dbparam.name=='foo'):
break
dbparam.amount = 3
dbparam.save()
#there is also this method if foruma depend on something else
#dbparam.recalculate(uncertain_db.name)
# here updating the exchanges of a particular activity (act)
for param in ActivityParameter.select():
if param.group == ":".join(act.key):
param.recalculate_exchanges(param.group)
you may want to update all the activities in the project instead of a single one like in the example. you just need to change the condition when looping through the activity parameters.

Let Alexa ask the user a follow up question (NodeJS)

Background
I have an Intent that fetches some Data from an API. This data contains an array and I am iterating over the first 10 entries of said array and read the results back to the user. However the Array is almost always bigger than 10 entries. I am using Lambda for my backend and NodeJS as my language.
Note that I am just starting out on Alexa and this is my first skill.
What I want to archive is the following
When the user triggers the intent and the first 10 entries have been read to the user Alexa should ask "Do you want to hear the next 10 entries?" or something similar. The user should be able to reply with either yes or no. Then it should read the next entries aka. access the array again.
I am struggling with the Alexa implementation of this dialog.
What I have tried so far: I've stumbled across this post here, however I couldn't get it to work and I didn't find any other examples.
Any help or further pointers are appreciated.
That tutorial gets the concept right, but glosses over a few things.
1: Add the yes and no intents to your model. They're "built in" intents, but you have to add them to the model (and rebuild it).
2: Add your new intent handlers to the list in the .addRequestHandlers(...) function call near the bottom of the base skill template. This is often forgotten and is not mentioned in the tutorial.
3: Use const sessionAttributes = handlerInput.attributesManager.getSessionAttributes(); to get your stored session attributes object and assign it to a variable. Make changes to that object's properties, then save it with handlerInput.attributesManager.setSessionAttributes(sessionAttributes);
You can add any valid property name and the values can be a string, number, boolean, or object literal.
So assume your launch handler greets the customer and immediately reads the first 10 items, then asks if they'd like to hear 10 more. You might store sessionAttributes.num_heard = 10.
Both the YesIntent and LaunchIntent handlers should simply pass a num_heard value to a function that retrieves the next 10 items and feeds it back as a string for Alexa to speak.
You just increment sessionAttributes.num_heard by 10 each time that yes intent runs and then save it with handlerInput.attributesManager.setSessionAttributes(sessionAttributes).
What you need to do is something called "Paging".
Let's imagine that you have a stock of data. each page contains 10 entries.
page 1: 1-10, page 2: 11-20, page 3: 21-30 and so on.
When you fetching your data from DB you can set your limitations, In SQL it's implemented with LIMIT ,. But how you get those values based on the page index?
Well, a simple calculation can help you:
let page = 1 //Your identifier or page index. Managed by your client frontend.
let chunk = 10
let _start = page * chunk - (chunk - 1)
let _end = start + (chunk - 1)
Hope this helped you :)

Where is scripted the Dalaran Well teleport (game object)?

When you try to reach the Dalaran Well in Dalaran, you are teleported to the sewers.
It is using this Game object: Doodad_Dalaran_Well_01 (id = 193904 )
Where is it scripted? How?
I've found nothing in the table smart_scripts, and found nothing in the core about this specific id so I'm curious because this type of teleport is really better than clicking on a game object
This gameobject is a unique case because it works like instance teleports do. If you check the gameobject_template table, you will see that it has several Data columns that have diferent values based on the type of the gameobject.
The gameobject you are refering too is the Well It self but the portal gameobject inside the well gives the player a dummy spell to tell the core that the player has been teleported (spell ID 61652).
For the specific case of the dalaran well, it's type is 30 which means, as the documentation says, GAMEOBJECT_TYPE_AURAGENERATOR. As soon as the player is in range, a dummy aura is cast on him to notify the core that this areatrigger has been activated (You could do stuff when player gets hit by the dummy spell).
The trick here is a bunny, but not the bunny itself since it is there mostly to determine an areatrigger. If you use command .go gobject 61148 you can check him out, he's inside the well.
Areatriggers are a DBC object that are actually present on our database on world.areatrigger. You can check the columns here. When the player enters the Radius box specified on the areatrigger, another thing happens in the core which is world.areatrigger_teleport.
If you run the following query you will be able to check the position where the trigger will teleport the player to.
SELECT * FROM areatrigger_teleport WHERE `Name` LIKE '%Dalaran Well teleporter%';

Group Position in Corona

I have a few codes below.
local mBackground = loader:loadBackground()
localGroup:insert(mBackground)
local mAnimals = loader:loadAnimal()
localGroup:insert(mAnimals)
local mDoor = loader:loadDoor()
localGroup:insert(mDoor)
The animals should always be left behind the door, but it can be updated by running the load function of loader few times.
I want to keep them behind the door whenever they are updated. How can I do that?
I used toBack(), but it doesn't seem right.
toBack() will make the object to the back of the group
toFront() will make the object to the front of the group
There is no way to move the object 1 index backward or forward, like move forward or move backward.
The method on your case will be this
mAnimals:toFront()
mDoor:toFront()
It's a little bit brute force, but it will solve the problem.
you can put an object on different index group buy doing this
local mBackground = loader:loadBackground()
localGroup:insert(1,mBackground) -- move object from index 1
local mAnimals = loader:loadAnimal()
localGroup:insert(2,mAnimals) -- move object from index 2
local mDoor = loader:loadDoor()
localGroup:insert(3,mDoor) -- move object from index 3
you can even change/update it's index if you want or put the same object in the same index

How To Obtain All the Nodes and Connections After Launching the GMF Project

After launching the GMF project, I get a new window to make my own model.
After placing some nodes and connections, I should calculate according to their attributes. At first, HOW can I obtain all the information of every node and every connection?
First , let's get the relevant editor:
DomainDiagramEditor d= (DomainDiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
Now, you can either get all the editparts in your diagram , getting the relevant model from them:
final List children = d.getDiagramEditPart().getChildren();
gets you a list of EditParts.
Or, you can get the model objects directly with:
EObject element = d.getDiagram().getElement();
EList<EObject> eContents_ = element.eContents();
That gives you a list of all the model objects in the active editor.
Hope that answers your question

Resources