optimization

Z3 maximization API: possible bug?

家住魔仙堡 提交于 2020-01-05 09:15:46
问题 I'm currently playing with the maximization API for Z3 (opt branch), and I've stumbled upon a following bug: Whenever I give it any unbounded problem, it simply returns me OPT and gives zero in the resulting model (e.g. maximize Real('x') with no constraints on the model). Python example: from z3 import * context = main_ctx() x = Real('x') optimize_context = Z3_mk_optimize(context.ctx) Z3_optimize_assert(context.ctx, optimize_context, (x >= 0).ast) Z3_optimize_maximize(context.ctx, optimize

AMPL ecopy() error causing by comparison indices (element of set) with variable

落花浮王杯 提交于 2020-01-05 08:53:06
问题 I another bug as you can see below: Error at _cmdno 8 executing "solve" command (file ./script/runConfiguration.run, line 5, offset 127): error processing constraint c1a[2,'o1',1]: unexpected type 0x14205 in ecopy() I guess that the problem causing comparison with the index (element of set) variable in c1a constraint. Is it possible to avoid this bug? My new ampl model: #sets #------------------------------------------------------------------------------------- set K; #index of nodes with

How to optimise a query containing joins and subqueries

狂风中的少年 提交于 2020-01-05 08:51:50
问题 I have inherited the following query and DB structure and I want to optimise it as it is slow. It contains joins and subqueries which I've read isn't a good plan. I've tried various ways to improve it but am getting stuck/lost. If it is good as it is then fine but if there are suggestions for improving it I would be immensely grateful... The query draws data from various tables to produce a report on how many clickthroughs to a supplier's website, telephone number 'reveals' there have been

How to efficiently reference count cons cells (detecting cycles)?

一世执手 提交于 2020-01-05 08:37:33
问题 I need to make some sort of liblisp (in C11), and it will need to handle the basic functions, pretty much like what libobjc does for the Objective-C language. Edit I'm rewritting the question to something less generic. I got an implementation like this: typedef struct cons { void *car, *cdr; } *cons_t; cons_t cons_init(void *, void *); void *cons_get_car(cons_t); void *cons_get_cdr(cons_t); void cons_set_car(cons_t, void *); void cons_set_cdr(cons_t, void *); void cons_free(cons_t); bool cons

Affect m students to n groups, but with constraints?

痞子三分冷 提交于 2020-01-05 08:23:08
问题 I asked about the minimum cost maximum flow several weeks ago. Kraskevich's answer was brilliant and solved my problem. I've implemented it and it works fine (available only in French, sorry). Additionaly, the algorithm can handle the assignement of i ( i > 1) projects to each student. Now I'm trying something more difficult. I'd like to add constraints on choices. In the case one wants to affect i ( i > 1) projects to each student, I'd like to be able to specify which projects are compatible

Why my multi-threading program is slow? [duplicate]

限于喜欢 提交于 2020-01-05 08:10:48
问题 This question already has answers here : How to get a faster speed when using multi-threading in python (4 answers) Closed 2 years ago . I'm trying to make my program run faster, using threads but it takes too many time. The code must compute two kinds of matrices (word_level where I compare every two words of the query and a document, sequence_level: where I compare the query to different sequences on the document. Here are the principal functions: import threading from threading import

postgres: get random entries from table - too slow

允我心安 提交于 2020-01-05 07:49:15
问题 In my postgres database, I have the following relationships (simplified for the sake of this question): Objects (currently has about 250,000 records) ------- n_id n_store_object_id (references store.n_id, 1-to-1 relationship, some objects don't have store records) n_media_id (references media.n_id, 1-to-1 relationship, some objects don't have media records) Store (currently has about 100,000 records) ----- n_id t_name, t_description, n_status, t_tag Media ----- n_id t_media_path So far, so

How to turn a binary matrix into a data.frame in R? lpSolveAPI

回眸只為那壹抹淺笑 提交于 2020-01-05 07:15:02
问题 library(lpSolveAPI) lprec1 <- make.lp(0,nrow(df) add.constraint(lprec1, c(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<=", as.numeric(ads1)) add.constraint(lprec1, c(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<=", as.numeric(ads2)) add.constraint(lprec1, c(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<=", as.numeric(ads3)) add.constraint(lprec1, c(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<="

How to turn a binary matrix into a data.frame in R? lpSolveAPI

爷,独闯天下 提交于 2020-01-05 07:13:34
问题 library(lpSolveAPI) lprec1 <- make.lp(0,nrow(df) add.constraint(lprec1, c(1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<=", as.numeric(ads1)) add.constraint(lprec1, c(0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<=", as.numeric(ads2)) add.constraint(lprec1, c(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<=", as.numeric(ads3)) add.constraint(lprec1, c(0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0), "<="

How to track any object instantiation on my JVM with Runtime.freeMemory() and GC

我怕爱的太早我们不能终老 提交于 2020-01-05 07:08:24
问题 I am using the default GC with 1.6.0_27-b07 (Sun's JRE) and because of this I am not able to detect an increase in memory with Runtime.getRuntime().freeMemory(). Can anyone shed a light on how to accomplish this? Do I have to use a different GC? Which one? The simple program below prints 0 for the memory allocated. :( :( :( import java.util.HashSet; import java.util.Set; public class MemoryUtils { private static Set<String> set = new HashSet<String>(); public static void main(String[] args) {