in or tools' VRPTW, how do we have customized objective function? - optimization

As title indicates, the or tools uses overall route driving time(or distance) as objective function and searches for a solution combination that minimizes the sum of driving times (or distances) for all routes using below line of code:
search_parameters.first_solution_strategy = (
routing_enums_pb2.FirstSolutionStrategy.PATH_CHEAPEST_ARC)
What if I want to have a custom objective function, like I want to minimize the number of stops that I am unable to reach within time window, or minimize the number of stops that are dropped from the solution. etc?

Related

How to add objective one by one

I have a gurobi optimization problem, now I set the objective using quicksum(quicksum ...) but it takes a long time for the objective to be added, I want to add the objective one by one to check where it might go wrong, how should I do it?
I have no idea yet. I am considering using a bunch of for loops.

Include a large amount of SubVIs in a main VI

I have a large amount (about 50) of SubVIs including beyond some usage specific code a small number of GUI elements (mostly about 2: input and output).
My goal is to reuse those VIs without creating a huge mess in a new ('main') VI and collect all GUI elements on a GUI common pane a user shall finally interact with.
I tried to use the Open VI Function, 'VI Reference' and 'Run SubVi' like in the examples to create references for subpanels, but the subpanel ui is only shown when the program is run and the amount of additional blocks is mostly bigger than the code in the respective SubVI.
The SubVIs should be loaded only once to construct the main User Interface.
In addition: In this tutorial they create a subVI and recreate GUI elements that are already defined in the subVI.
I assume this behaves like passing arguments as in a text based programming languages like the snippet:
def main_vi(x, y, z): # inputs x, y, z
s = sub_vi(x, y, z)
return s # output s
Is this necessary, or can the subvi's GUI controls directly be reused from outside?
Is it possible to use the subVIs inside of an "main" VI that includes everything and maps everything to a common UI using tabs?
Or is it better to copy everything to the main VI, i.e. no code reuse at all?
Thanks in advance!
Depending on the functionality you are going for, yo may want o look into XControls. This would allow you to encapsulate your functionality into a reusable control that could be used on a main panel without making the main panel very messy.
Large UI's can be a pain (pun with pane not intended), especially if there are a lot of controls and indicators. There are some useful ways to break UIs into modular components. XControls are one of those but I don't recommend them due to their unpredictable behaviors. Instead look into working with Sub Panels. There is a great toolkit for this from a company called Moore Good Ideas (or MGI). More info can be found on their website here.
There is also a better alternative to XControls, called QControls. More info on them can be found here.
In general, though, you might want to look into a more modular framework. More info on Frameworks can be found here.

How to implement a 4 quadrant atan2 function in gnuradio

I have recently begun experimenting with SDR and have been using the GNU Radio platform.
More specifically the 'gnuradio-companion' graphical interface.
I have a need to determine a 4 quadrant arcTangent function and have run into some trouble. Within a 'GRC' file I have been able to successfully evaluate an ATAN function but, although python supports ATAN2, I have not been able to figure out how to implement this function.
I have read that there is a lookup table function included in GNU Radio called fast_atan2f but I do not know if this is accessible from within the blocks contained in the standard gnuradio-companion setup. I was able to access the python expression 'math.atan2(arg1,arg2)' from within a constant source block but I don't need this as a constant value, I'm looking for a block with two floating point inputs (or a single complex input) that will fit within a flow graph to properly evaluate the ATAN2 function.
I have included a sample 'GRC' file that may help to illustrate the issue in case my description is unclear.
link to the GNU Radio companion example file
The block gnuradio.blocks.complex_to_arg (Complex to Arg in GRC) is an atan2 operation.
If you need two separate floating point inputs as you described, then just precede it with a Float To Complex block.
Depending on your specific application, you may also be interested in gnuradio.analog.quadrature_demod (Quadrature Demod in GRC). This block produces essentially the derivative of atan2, but without any discontinuities at 180° or 360°. This is appropriate for e.g. demodulating FM signals.

LabVIEW Programming for running the machine continuously

I want to run my Robot in 3 -axes(X,Y,Z) continuously with different values of
x, y, z. Suppose i want the machine to run 100 times. Each time the values of the x, y, z will be different and each time it will take the values from a table automatically so that while running the machine i don't need to change the values each time. How is it possible in Lab VIEW? I am using Lab VIEW 2011.
If you save your spreadsheet in CSV format, you can then read it into a LabVIEW array using Read from Spreadsheet File in the Programming > File I/O palette. You can then use the array functions in the Programming > Array palette to get the subarrays you need out of the first array. If you want to run the same code multiple times using different values from the spreadsheet then you will probably want to use a For or While loop.
If you carefully read the online help for these functions and try experimenting with them you should be able to work out how to do what you need. If you can't get it to work properly, post a screenshot or (better) VI snippet showing what you have tried and people will be able to offer more specific help.
LabVIEW doesn't have functions to read directly from Excel spreadsheet files, but there are third-party add-ons to do this if you want.
The best way for you would be to start learning LabVIEW little bit dipper before writing the code.
Anyway, you can use read from spreadsheet file.vi. Hope the links below will be helpful:
http://zone.ni.com/reference/en-XX/help/371361J-01/glang/read_from_spreadsheet_file/
https://decibel.ni.com/content/docs/DOC-12287

Can someone explain what a filter chain is in GPUImage in simple words?

I realize GPUImage has been well documented and there's a lot of instructions on how to use it on the main github page. However, it fails to explain what a filter chain is - what's addTarget? What's missing is a simple enough diagram showing what needs to be added to what. Is it always GPUImageView (source?) -> add target -> [filter]? I'm sorry if this sounds daft, but I fail to follow the correct sequence given there are so many ways of using it. To me, it sounds like you're connecting it the other way round (such as saying: Connect the socket to the TV). Why not add filter to the source? I'm trying to use it but I get lost in all the addTargets. Thanks!
You can think of it as a series of inputs and outputs. Look in the GPUImage framework project to see which are inputs (typically filters) and which are outputs (imageview, moviewriter, etc..). Every target effects the next target in the chain.
Example:
GPUImageMovie -> GPUImageSepiaFilter -> GPUImageMovieWriter
A movie will be sent to the sepia filter that will perform its job, the movie with a sepia filter applied will be sent to the movie writer, then the movie writer will export a movie with a sepia filter applied.
To help visualize what's going on, any node editor program typically uses this scheme. Think of calling addTarget: as one of the connections in the attached image.
A google image search for Node Editor will give you plenty of other image to help picture what adding targets does.