## Integer Linear Program as a feasability test

I am a beginner in Integer Linear Programs and I have a question about a problem that I am dealing. This problem tracks a configuration of a graph by unitary transformations on the graph and I want to minimize these number of transformations to achieve another configuration of the graph. As I only allow exactly one transformation per step, minimizing the number of transformations is the same as minimizing the number of steps.

But, I enter in the following problem: There is no internal property that can be tracked so that I can check if one or other state is closer or farther from the wanted configuration. That means that I can only check if a specific sequence of transformation is correct in a prior-of-execution defined step, for example, $$T$$. Then, what I am thinking in doing is testing a range of values for $$T$$, as there is a polynomial upper-bound for this value, in increasing order (bound in the number of steps). Then I recover the answer of the first $$T$$ that gives me any answer, as I know it will be a optimal answer.

My questions are:

• This sort of is a feasibility test for a fixed $$T$$, as if the polytope exists, any answer will be a optimal answer, as they all have the same number of steps $$T$$. This approach is possible? In the sense that it can be calculated given a infinite amount of time? Because I am not sure what is the behavior of a IL program when there is no possible answer (ie. no polytope).
• If yes, there is some existing technique to deal/optimize this type of situations without finding a specific property?

## C ++ ERROR – [Error] ISO C ++ prohibits the comparison between pointer and integer [-fpermissive]

I am learning C ++ and have copied and modified a code from the Internet, but it shows the error when compiling – (error) ISO C ++ prohibits the comparison between pointer and integer (-fpermissive).

Code:

Include iostream

include stdio.h

Define SIZE 200

Character name (SIZE) (50);

Char (SIZE) (50);

int rg (SIZE) (50);

int cpf (SIZE) (50);

int tel (SIZE) (50);

int age (SIZE) (50);

int op;

Invalidate registration ();

void search ();

int main (void) {

``````cadastro();

pesquisa();
``````

}}

Invalidate registration () {

``````static int linha;

do{

printf("nDigite o nome: ");

scanf("%s", &nome(linha));

printf("nDigite o sexo (F/M): ");

scanf("%s", &sexo(linha));

printf("nDigite o RG: ");

scanf("%d", &rg(linha));

printf("nDigite o CPF: ");

scanf("%d", &cpf(linha));

printf("nDigite o telefone: ");

scanf("%d", &tel(linha));

printf("nDigite 1 para continuar ou 2 para sair: ");

scanf("%d", &op);

linha++;

}while(op==1);
``````

}}

void search () {

``````int cpfPesquisa;

int i;

do{

printf("nDigite o CPF que deseja buscar: ");

scanf("%d", &cpfPesquisa);

for(i=0;i``````
``` Gender (i), cpf (i), rg (i), age (i), tel (i)); } } printf("nDigite 1 para continuar pesquisando: "); scanf("%d", &op); }while(op==1); }} ```
``` ```
``` Author AdminPosted on May 15, 2020Categories ArticlesTags comparison, Error, fpermissive, integer, ISO, pointer, prohibits ```
``` Maximize BITWISE AND find an integer in the range [L,R] Given an integer x find y in the range L <= y <= R, so that x & y is maximal & is bitwise AND where 0 <L, R <10 ^ 12 I tried to iterate and solve, but it leads to TLE Author AdminPosted on May 9, 2020Categories ArticlesTags bitwise, Find, integer, Maximize, range Why is it impossible to have a complex number with an integer as the real part and an approximate number as the imaginary part? 1/3 + 3. I (*output 0.333333+3.I*) 2 + 3. I (*output 2.+3.I*) According to the code above, it seems impossible to have a complex number with an integer or an exact number as the real part and an approximate number as the imaginary part. The exact number as a real part is automatically and violently converted into an approximate number. I looked it up in the official document and found no explanation. Can anyone provide a documentation reference that explains this mechanism? Author AdminPosted on May 9, 2020Categories ArticlesTags approximate, complex, imaginary, impossible, integer, number, Part, real Integer in array returns zero I use the EDD_Fees class to add an additional fee to products. I've already used this class and it works like magic, but now I can't figure out why the amount is zero (it seems to return zero). But if i echo shows the integer value. Here is my full class code \$feeid_gen = date("Ydhis") . \$download_id; function cencored_function() { // Additional Services Price START here \$cencored_fee = array( 'amount' => \$int_val, 'label' => 'hbbl', 'id' => \$feeid_gen, 'no_tax' => false, 'type' => 'fee', 'download_id' => \$download_id, 'price_id' => NULL ); EDD()->fees->add_fee( \$cencored_fee); /// Additional Services Price END here } add_action( 'init', 'cencored_function' ); cencored_function(); // Runned Author AdminPosted on May 5, 2020Categories ArticlesTags array, integer, returns haskell – closed form Fibonacci with integer I implement the closed form of Fibonacci numbers. I think I can use a custom data type without leaving it Integer. It is no more efficient than the "standard" approach since I could not find an efficient way to calculate the performance of my custom number type. But if I stick to this algorithm, I would be interested in best practices to write this. In particular, I'm not sure about the use of Num for my FibNum and the use of fromJust. module Fibo ( fibo ) where import Data.Maybe (fromJust) -- use a data type similar to complex numbers. -- The only irrational number are multiples of sqrt 5 -- which will cancel away in the closed form. data FibNum = FibNum { int::Integer, sq5::Integer } deriving (Show) instance Num FibNum where (+) (FibNum a1 b1) (FibNum a2 b2) = FibNum (a1+a2) (b1 + b2) (*) (FibNum a1 b1) (FibNum a2 b2) = FibNum intSide rootSide where intSide = a1*a2 + 5 * b1 * b2 rootSide = a1*b2 + b1*a2 negate (FibNum a b) = FibNum (negate a) (negate b) fromInteger n = FibNum (fromInteger n) 0 -- no need for abs and sign for now abs _ = undefined signum _ = undefined funit = FibNum 1 0 -- actual phi and psi are (1 + sqrt 5)/2 and (1 - sqrt 5)/2 -- I would prefer to avoid fractions so I divide at the end fphi = FibNum 1 1 fpsi = FibNum 1 (negate 1) -- was originally planning to calculate the binomial coefficients -- but seeing that I just need n relatively simple multiplications -- that seem like unnecessary complication pow :: FibNum -> Integer -> FibNum pow _ 0 = funit pow x 1 = x pow x n = x * pow x (n-1) -- in the closed form the integer part is always 0 divR5 :: FibNum -> Maybe Integer divR5 (FibNum 0 n) = Just n divR5 _ = Nothing fibo :: Integer -> Integer fibo n = flip div p2 . fromJust \$ divR5 nom where nom = pow fphi n - pow fpsi n p2 = 2^n Author AdminPosted on May 1, 2020Categories ArticlesTags closed, Fibonacci, form, Haskell, integer Maximizing the integer determines the intersection (with integer delta). There are two sets of integers with different numbers of elements. X= { x_0, x_1, ... x_n }, x_0 < x_1 < ... < x_n Y= { y_0, y_1, ... y_m }, y_0 < y_1 < ... < y_m And there is a function of a single integer, defined as F(delta) = CountOfItems( Intersection( X, { y_0+delta, y_1+delta, ... y_m+delta) ) ) That is - I add delta Integer for each element of the Y and then count how many of the same integers there are X and the modified Y. And then the problem - find delta that maximizes F(delta). max( F(delta) ), where delta is integer Is there a "mathematical" name for such a task and an optimal algorithm for it? Of course I can use brute force here and enumerate all possible combinations - but it does not work for large n and m. Author AdminPosted on May 1, 2020Categories ArticlesTags delta, determines, integer, intersection, Maximizing Polynomials – factorization problem and integer solutions Find all pairs of Interger solutions ordered $$(x, y)$$ so that $$2 ^ x + 1 = y ^ 2$$ So I see that we can get $$2 ^ x = (y + 1) (y-1)$$ and from here we see that the right side must be a power of two. I found this problem online and it found the difference $$(y + 1) – (y-1)$$ must be $$2$$what I don't really see. If we take the case $$2 ^ 2 = (y + 1) (y-1)$$, then the difference should not be the same $$0$$? Author AdminPosted on April 30, 2020Categories ArticlesTags factorization, integer, polynomials, problem, Solutions Python – combinations of an integer list with product limit In Python, the itertools module is a good tool for generating combinations of elements. In this case I want to generate all combinations (without repetition) with a subset of the specified length, but also with a product limit. For example, for a list of integers, I want all subsets of length 4 whose product is above a certain numeric limit, like below: import functools, operator LST = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 ) prod = lambda A : functools.reduce(operator.mul, A ) def combinations_with_limit( LST, length,lim ) : ''':Description: LST - array of integers, length = number of elements in each subset , lim = product limit of each subset ''' H = list(range(length)) # H - represents the index array B = ( LST(ii) for ii in H ) # B - the main array with elements while H(0) <= len(LST)-length : for i in range( H(-1), len(LST)) : H = H(:-1) + (i) B = ( LST(ii) for ii in H ) if prod(B) > lim : ### LIMIT THE OUTCOME PART . It skips the rest of the iteration H(-1) = len(LST) - 1 elif prod(B) <= lim : yield B if H(-1) == len(LST) - 1 : # We reset the index array here j = len(H)-1 while H(j) == len(LST)-length+j : j -=1 H(j) +=1 for l in range(j+1, len(H)) : H(l) = H(l-1) +1 for i in combinations_with_limit(LST, 4 , 1000 ) : print(i ,end=' ' ) The output looks like this: (2, 3, 5, 7) (2, 3, 5, 11) (2, 3, 5, 13) (2, 3, 5, 17) (2, 3, 5, 19) (2, 3, 5, 23) (2, 3, 5, 29) (2, 3, 5, 31) (2, 3, 7, 11) (2, 3, 7, 13) (2, 3, 7, 17) (2, 3, 7, 19) (2, 3, 7, 23) (2, 5, 7, 11) (2, 5, 7, 13) And that's right. All product subsets are below the requested limit. However, I think the code above is not elegant and has some loop inefficiency. Do you have any ideas on how to improve it? Thanks a lot. Author AdminPosted on April 26, 2020Categories ArticlesTags combinations, integer, limit, list, product, Python PHP – Round price to nearest integer as an optional fee I wanted to add a feature to add an optional fee / surcharge to the checkout page and I found this answer. Instead of a fixed fee, however, I would like the amount to be set as the difference between the total amount of the car and the next whole pound / dollar / euro / whatever. It always has to be rounded up. Even if the cart total is £ 23.14, there should be an option to add a £ 0.86 charge to the order. The same applies to orders worth \$ 49.60. You should have the option to add \$ 0.40. How can I add this option to top up the order? Can it still be done with the product method? So far I have only added fees (percentages) that were not optional. Author AdminPosted on April 23, 2020Categories ArticlesTags fee, integer, Nearest, optional, PHP, price Posts navigation Page 1 Page 2 … Page 23 Next page ```