optimization

How to do this coordinate system operation more efficiently?

泄露秘密 提交于 2020-01-15 16:00:22
问题 I'm making a 3D game, where the player's back should always be facing the camera and he should move in that direction. I didn't come to the "back facing the camera" part yet, but I believe that it will be simple once I figure out how to move the player in the right direction... Though it is a 3D coordinate system, height can be ignored (z-axis) because no matter how high the camera is, the player should always be going in the same speed (the camera system is planned to function much like in

How to remove elements from a vector in a fast way in Clojure?

百般思念 提交于 2020-01-15 13:21:16
问题 I'm trying to remove elements from a Clojure vector: Note that I'm using Clojure's operations from Kotlin val set = PersistentHashSet.create("foo") val vec = PersistentVector.create("foo", "bar") val seq = clojure.`core$remove`.invokeStatic(set, vec) as ISeq val resultVec = clojure.`core$vec`.invokeStatic(seq) as PersistentVector This is the equivalent of the following Clojure code: (remove #{"foo"} ["foo" "bar"]) The code works fine but I've noticed that creating a vector from the seq is

How to remove elements from a vector in a fast way in Clojure?

纵饮孤独 提交于 2020-01-15 13:21:13
问题 I'm trying to remove elements from a Clojure vector: Note that I'm using Clojure's operations from Kotlin val set = PersistentHashSet.create("foo") val vec = PersistentVector.create("foo", "bar") val seq = clojure.`core$remove`.invokeStatic(set, vec) as ISeq val resultVec = clojure.`core$vec`.invokeStatic(seq) as PersistentVector This is the equivalent of the following Clojure code: (remove #{"foo"} ["foo" "bar"]) The code works fine but I've noticed that creating a vector from the seq is

Flow/Job Shop to Boolean satisfiability [Polynomial-time reduction] part 2

徘徊边缘 提交于 2020-01-15 12:37:36
问题 here is the continuity of my first question (Flow Shop to Boolean satisfiability [Polynomial-time reduction]). Because something is wrong and I didn't success to know where exactly. I ask for the help of StackOverFlow's masters once again :) For the sum-up of what I have for now : I have input file who look like this : 3 2 1 1 1 1 1 1 Who represents : 3 jobs, 2 shops (machines), and the duration of each job on each shop (machine). And I want for theses problems, to find the optimum C_max

Numpy arange error with Lagrange Multiplier in Python

一笑奈何 提交于 2020-01-15 11:45:07
问题 I try to use Lagrange multiplier to optimize a function, and I am trying to loop through the function to get a list of number, however I got the error ValueError: setting an array element with a sequence. Here is my code, where do I go wrong? If the n is not an array I can get the result correctly though import numpy as np from scipy.optimize import fsolve n = np.arange(10000,100000,10000) def func(X): x = X[0] y = X[1] L = X[2] return (x + y + L * (x**2 + y**2 - n)) def dfunc(X): dLambda =

Python: Gridsearch Without Machine Learning?

可紊 提交于 2020-01-15 10:36:46
问题 I want to optimize an algorithm that has several variable parameters as input. For machine learning tasks, Sklearn offers the optimization of hyperparameters with the gridsearch functionality. Is there a standardized way / library in Python that allows the optimization of hyperparameters that is not limited to machine learning topics? 回答1: You can create a custom pipeline/estimator ( see link http://scikit-learn.org/dev/developers/contributing.html#rolling-your-own-estimator) with a score

Set up linear programming optimization in R using LpSolve?

僤鯓⒐⒋嵵緔 提交于 2020-01-15 10:16:09
问题 I have this optimization problem where I am trying to maximize column z based on a unique value from column X, but also within a constraint that each of the unique values picked of X added up column of Y most be less than (in this example) 23. For example, I have this sample data: d=data.frame(x=c(1,1,1,2,2,2,3,3,3),y=c(9,7,5,9,7,5,9,7,5),z=c(25,20,5,20,10,5,10,5,3)) Which looks like this: X Y Z 1 1 9 25 2 1 7 20 3 1 5 5 4 2 9 20 5 2 7 10 6 2 5 5 7 3 9 10 8 3 7 5 9 3 5 5 The result should

KCachegrind output for optimized vs unoptimized builds

自古美人都是妖i 提交于 2020-01-15 09:55:48
问题 I run valgrind --tool=callgrind ./executable on the executable file generated by the following code: #include <cstdlib> #include <stdio.h> using namespace std; class XYZ{ public: int Count() const {return count;} void Count(int val){count = val;} private: int count; }; int main() { XYZ xyz; xyz.Count(10000); int sum = 0; for(int i = 0; i < xyz.Count(); i++){ //My interest is to see how the compiler optimizes the xyz.Count() call sum += i; } printf("Sum is %d\n", sum); return 0; } I make a

Utilizing the power of clusters in the context of databases?

蓝咒 提交于 2020-01-15 09:20:42
问题 I have a 22 machine cluster with a common NFS mount. On each machine, I am able to start a new MySQL instance. I finished creating a table with about 71 million entries and started an ADD INDEX operation. It's been more than 12 hours and the operation is still going on. So what I logged onto one of my other machines in the cluster, started a new instance on MySQL daemon on that machine using: mysqld_safe --user=username And then created a MySQL client on the same machine to connect to the

Python: Using CVXOPT for quadratic programming

时光总嘲笑我的痴心妄想 提交于 2020-01-15 07:22:30
问题 I'm using CVXOPT to do quadratic programming to compute the optimal weights of a potfolio using mean-variance optimization. There is a great example at http://abel.ee.ucla.edu/cvxopt/userguide/coneprog.html#quadratic-programming. However, the arguments are in a regularized form (according to the author). The example is a basic version. I am looking to do a bit of a more complex problem where: min: x'Sx s.t.: x'a >= g x'1 = 0 x >= -Wb x <= c1 - Wb where: x: active weights of assets (active