Carl Love

## 26513 Reputation

11 years, 190 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

## Can you formulate it algebraically?...

@RukevweOyinloye Yes, that's what I thought: that something was missing. Yet I'm certain that my code has the same mathematical information as your code (same objective and constraints); I just made it linear. But I realize that neither of these codes captures the essence of your verbal description of the problem. Can you formulate algebraically some constraints to capture the role of groups? Perhaps you meant for the "... = 1" on the constraints to be attached to the inner add, thus making 6 constraints in this case rather than 3?

Please also see the similar Reply that I posted in the subthread under the main Question a few minutes ago.

## Please further explain the "groups"...

I notice from both your code and text that the "profiles" are partitioned into "groups", and also that the number of groups is irrelevant to this code because each constraint is simply the sum of a complete column of the decision-variable matrix X equated to 1. So, do you think that you need more constraints tthat use the groups?

Is there any real-world reason why the groups would be the same size? It would very easy to recode this so that the groups could be an arbitrary partition of the profiles rather than a partition into equal size blocks.

@acer It seems quite odd to me that indets is "smart enough" to avoid returning bound variables from RootOf, yet it doesn't do it for Int, int, Sum, sum, or any other standard command with a bound variable that I can find. The bound variables of ints and sums are often automatically generated by dsolve and other commands. One often sees _a_k1, etc.

Do you have any idea why indets gives special treatment to RootOf like this?

I've long thought that symbolic computation needs a formal way to declare a variable as bound.

## Confusing syntax...

@TKChang99 The syntax Surface(...certainly makes it seem as if Surface is a separate command (with its own help page) rather than simply an option to SurfaceInt, so it's no surprise that there was that confusion. The standard syntax for an option would be Surface= [...], and I can't see any good reason why the integration commands in VectorCalculus couldn't use this more-standard syntax.

## Streamlined version...

@RukevweOyinloye Here is a more-streamlined version of code that does exactly the same thing. While writing this code, I noticed that num_groups is irrelevant for this presumably toy example. Either I'm missing something, or its relevance won't become apparent until the example is more complicated.

 > restart :
 > num_profiles:= 4:  num_websites:= 3: X:= Matrix((num_profiles, num_websites), symbol= x); objs:= seq(ArrayTools:-AddAlongDimension(X,2)): 'objs' = ; constraints:=     seq(ArrayTools:-AddAlongDimension(X,1)) =~ 1,     z >=~ objs : 'constraints' = ; sol:= Optimization:-Minimize(     z, {constraints}, integervariables= {z}, binaryvariables= {seq}(X) ); optimal_assignment:= eval(X, sol[2]); for ij in op(2, optimal_assignment) do     printf("Profile %d assigned to Website %d.\n", lhs(ij)) od; printf("Objective Value (Minimized Maximum Website Overlap): %d.\n", sol[1]);

Profile 2 assigned to Website 2.
Profile 3 assigned to Website 3.
Profile 4 assigned to Website 1.
Objective Value (Minimized Maximum Website Overlap): 1.

## X is array of decision variables...

@mmcdara X is the array of binary decision variables such that X[i,j] = 1 iff profile i should be assigned to website j. It shouldn't have a numeric datatype.

## Remove "minimize"...

@RukevweOyinloye One thing that you certainly must do is remove the minimize from the objective function. The Optimization[Minimize] already specifies that you want to minimize.

You probably have other problems also, which'll be easier to diagnose when you upload a worksheet.

## Bound variable of RootOf...

@nm That _Z is the bound variable of RootOf​​​​​, and every RootOf has a _Z, so you'd might as well just filter out all occurences of RootOf. That _Z is very different from the free variables returned by discontsolve, etc., that you're otherwise looking for.

## Types thistype, typefunc, and typeindex...

@Carl Love Some commands may also return unknown functions, such as _F(x, y). For example, pdsolve might do this. These can be filtered by type typefunc(suffixed('_')) as the 2nd indets argument. To filter both symbols and functions, make the type

{thistype, typefunc}(suffixed('_'))

To filter indexed names as well, make it

{thistype, typefunc, typeindex}(suffixed('_'))

## evalb not needed...

@Thomas Dean You can use until testeq(...)=FAIL instead of the overly complicated
until evalb(testeq(...)=FAIL).

## Sorry, you're right...

@Thomas Dean Sorry, you were right; there is a difference. I think that the presence of a difference in how while and until handle FAIL should be considered a bug in the implementation of until.

## There is no difference!...

@Thomas Dean There is no difference in how ifwhile, and until interpret FAIL! They all interpret it the same as false.

@Preben Alsholm You can also do

TypeTools:-AddType(ID, ()-> try type(args) catch: false end try);

## Sorry, I didn't notice "Maple Flow"...

@tim_finks Sorry that I didn't notice that this was about Maple Flow instead of Maple.

## You're correct...

@nm Yes, you're right about numelems. I'll correct the Answer. I did know this, but I was momentarily fooled by the coincidence of both values being 3. Thank you for spotting that.

 First 7 8 9 10 11 12 13 Last Page 9 of 689
﻿