PyDrake NLOpt Method Selection - drake

NLOpt has many different methods implemented as detailed here. I was wondering which one is used by default, and whether I could specify one of them in particular using the SolverOptions interface in pydrake.
I've tried, for example,
solver = NloptSolver()
options = SolverOptions()
options.SetOption(solver.solver_id(), "algorithm", "LD_LBFGS_NOCEDAL")
where I have replaced "LD_LBFGS_NOCEDAL" with "NLOPT_LD_LBFGS_NOCEDAL", "LD_LBFGS", etc. (enums taken from here) and checked the value of the optimal solution of a highly nonconvex program, which doesn't seem to change no matter what I specify. Is there any way to check whether the option has been set correctly (if it is possible to change it)?

Related

How can I programmatically set the value inside a complex Map/List by a given path in Dart?

Here is an example on DartPad.
The example has the commentary but let me explain anyway. Suppose we have a quite complex Map<String, dynamic> or a List<dynamic>, e.g. it might contain an integer inside a map inside a list inside another map inside another list...
I get a path, which I called targetPath and is a List<dynamic>, defining where the target value is inside this complex data.
I'd like to change the value referred by this targetPath but have no idea how to do that.
How can I change a value inside a List/Map given by a path?
Thanks in advance.
Troubleshooting
I have looked up some solutions on the internet which have not been applicable in my situation but I'd like to put them here and state why they did not work in my case.
Merging Two Maps
Combine/merge multiple maps into 1 map
I have come across this while looking for it but my case has targetPath which is not applicable to this situation. The question has many answers but none of it covers my case.
Environment
Dart 2.15.1
Flutter 2.8.1 (if relevant)
Actually, I have found a package called deeply, which addresses the same issue I have at hand.
All the examples adress Maps though. However, I took a quick look at the implementation, which seems to be friendly with List type at the first glance.

NiftyNet 'evaluation' action output is incorrect

I'm trying to use the new 'evaluation' action after inference to generate some metrics for my output. However, the .csv files just show scores of '0' for average_distance and '1' for Jaccard and Dice for each of my data volumes. I can't seem to find any documentation for the evaluation action, so I'm not sure what I'm doing wrong. Also, the --dataset_to_infer=Validation option doesn't seem to work, both inference and evaluation are being applied to all data rather than just the validation set.
Thanks!
For the evaluation issue, we're working on the documentation. The dataset_to_infer option is only tested for the applications in NiftyNet/niftynet/application; applications from the model zoo are not upgraded to support it yet (please file an issue with more details https://github.com/NifTK/NiftyNet/issues if you believe it's a bug).
For the time being, pointing directly to the inference result in the config.ini worked for me.
e.g.
[inferred]
csv_file = model_dir/save_seg_dir/inferred.csv
I believe this file is not found currently and then evaluation defaults to comparing labels to labels. See the issue on GitHub.

Modify local variable from another script in Lua

I'm trying to make a mod for the game Don't Starve Together, which makes use of Lua. For this reason, I can't modify their source variables/files.
In order to try to modify the world generation, I need to access a local table that was instantiated in another file (the file is called "levels.lua"). The variable name is "levellist". Is there a way to access the variable so that I can add certain elements to the table?
Namely, I want to add {"task_set", "cave_custom"} to levellist[DST_CAVE].overrides.
If someone could help or even just tell me if this is possible or not, that would be great. Thanks!
What you are trying to do simply doesn't make sense. Local variables are accessible only from the scope it was defined in, and it's nested scopes. There is no, normal, way to change it from different scopes, let alone an entirely different script.
If you want variables that all your scripts use, use globals.
Of course you can't get to local variables (i.e. "pointers") used by another function, save for obscure debug methods that are rarely exposed to user sandbox, but you don't need to. Because you do not want to modify some local variable (i.e. make it point to another table for example), but get to some table and modify value inside it. So you just need to find any place where it is exposed to you in any way.
You should somehow edit in relevant content in your question because it is PITA to Alt-Tab back and forth to your files. According to structure from comments/chat AddLevel(LEVELTYPE.SURVIVAL, ...) inserts an entry into levellist[LEVELTYPE.SURVIVAL] table. If you check levels.lua you can also see that it returns table with sandbox_levels assigned exactly to this.
So:
local levels = require "levels"
print(levels.sandbox_levels)
-- Will print "table: SOMENUMBERS" - i.e. address of levellist[LEVELTYPE.SURVIVAL]
You now can iterate it with for idx = 1, #levels.sandbox_levels or ipairs and find entry belonging to "DST_CAVE". I can't tell how field with ID will be called or how it will be structured because data is preprocessed with function Level before inserting that you did not include in the files you posted.
As others have suggested, this may not be your best strategy.
But depending on your environment, it may be possible to abuse some more esoteric features of the runtime to let you indirectly modify values that aren't "yours". Have a look at debug.sethook and setfenv.

Neo4J and timestamps

I need information about node's creation & last modification dates...
Is there a way to automatically handle created and updated properties for a node?
Hibernate offers #Version for updated field. Is there something similar with Node4J.
I found http://neo4j.rubyforge.org/classes/Neo4j/Rails/Timestamps.html but it seems to be only available for Ruby.
You can use annotations form the spring-data-commons library. Use #CreatedDate and #LastModifiedDate on properties of type Long. Make sure you're using the simple mapping mode. For now, advanced mapping mode does not support this, see DATAGRAPH-335.

OMNIORB: Read current orb setting

It is possible to use CORBA::ORB_init to set the native codeset for the orb.
But if in an application an orb is retrieved in different configurations the orb is initialized only once.
"-ORBconfigFile config1.cfg"
CORBA::ORB_var orb1 = CORBA::ORB_init(orbInitParams.argc(), orbInitParams.argv());
"-ORBconfigFile config2.cfg"
CORBA::ORB_var orb2 = CORBA::ORB_init(orbInitParams.argc(), orbInitParams.argv());
But the thing is that the first one wins. So in a big application where the caller of the second ORB_init does not know of the first caller he will get the orb configured like 1.
This matters if 1. uses
nativeCharCodeSet = ISO-8859-1
while 2 uses
nativeCharCodeSet = UTF-8
Is there a way to read the ORB setting to check if settings are attached successful?
Why this shows up: I am using Omniorb in a dll (Thats where I initialize it). Now the application has a second component using omniorb which comes first. So I lost my UTF-8 configuration.
With omniorb it seems not possible to have to orbs in one process or is it possible to read the configuration.

Resources