Category "optimization"

How can I reduce the number of database queries for a one to many association in Strawberry GraphQL and FastAPI?

I'm developing a python GraphQL API server using FastAPI and Strawberry, and I'm implementing this feature: I have two entities, User and Order, which have a on

How to structure data without bloating the size because of alignment?

Lets say we have a struct Original as this: class Original { int x; bool y; bool z; }; Due to alignment, the sizeof(Original) is 8 bytes. 4 for the int,

Why is the XOR swap optimized into a normal swap using the MOV instruction?

While testing things around Compiler Explorer, I tried out the following overflow-free function for calculating the average of 2 unsigned 32-bit integers: uint3

Count nodes within k distance of marked nodes in grid

I am attempting to solve a coding challenge however my solution is not very performant, I'm looking for advice or suggestions on how I can improve my algorithm.

ValueError: Covariance matrix does not match expected returns

I am trying to optimize a portfolio for a certain timer period Error message

how to write ant colony optimization code

i have a function function t=strength(x) t(1) = -0.804-0.001.*x(1)-0.001.*x(2)+0.0.*x(3)+0.0.*x(4)-0.031.*x(5)+0.005.*x(6)-0.002.*x(7)+0.001.*x(8)-0.735.

Time and Space complexity of the max disk space

from collections import deque def findMax(hardDiskSpace, k): n = len(hardDiskSpace) if n * k == 0: return [] if k > n: return []

Shorten JSON reading class

I have a simple JSON reading class that should grab values from a JSON object and put it in c# variables. Right now it uses 8 if statements, but I was wondering

how to model a GEKKO constraint to guarantee the count of variables with same value > k

I have the following objective function : Minimize(sum(abs(di[i]-d[i]) ) ) and I want to add a constraint to make sure that d[i] is appeared at least k times i

TensorFlow optimisation during running model speed up Predict

I want to disable a computation of several filters during Predict call with Tensorflow 2 and Keras. Do i have to modify the source code of Tensorflow to achieve

RL + optimization: how to do it better?

I am learning about how to optimize using reinforcement learning. I have chosen the problem of maximum matching in a bipartite graph as I can easily compute the

Python GEKKO: Objective function not showing correct results

I am trying to optimize the trajectory of a thrust propelled system. The control variable is the mass flow rate, and the final objective is to maximize the mass

GEKKO does not find optimal solution for a moon lander that does not go to zero height at zero speed

I'm trying to solve an optimal control problem where a person lands on the Moon, but has a device that can propel her upwards, via a control parameter, alpha. T

Cut a large cuboid into random small cuboids whose dimensions are within a certain range

I am trying to cut a large cuboid of dimension (L, W, H) into N (N can be an arbitrary number and doesn't need to be specified) small cuboids where length and w

Saving results of CPLEX with flow control (change data solve with regenerate)

After looking through stackoverflow + IBM forum + Alex Fleischer's How to Linkedin page, I manage to run my problem with script, changing a parameter at every i

Dodging the performance hit from using `in` with a struct without making the struct readonly?

C# 7.2 added two new features: In Parameters Using in for a parameter let's us pass by reference, but then prevents us from assigning a value to it. However the

How to use Google's "SimpleMinCostFlow" - C#

I want to create a Max Flow - Min Cost program in C# -Visual studio. I'm using this Guide , but I get error at this line MinCostFlow minCostFlow = new MinCostFl

Cplex Python Gaps

How can I print the gaps(each iteration) like OPL's engine in Python? I want to keep the gaps like this: Nodes Cuts

Apache performance tuning for high traffic with MPM Event

I currently manage the following set of servers that serve about 700 web pages: SERVER 1 (WEB) Web server: Apache 2.4.29 with MPM Event PHP 7.2.22 CPU: Intel

Slow MySQL query on 2mill record table despite indexes

Struggling to understand why my query is taking ~8-12s to complete when my table has millions of rows. I can force it to use a specific index, and depending on