|
.. or using the wrong units can prang some very expensive hardware a long long way from home.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Of course, but that's why you have more than a couple of hours to think about things, and you have discussions with your peers, and peer reviewing, ...
But that wasn't exactly my point.
|
|
|
|
|
Background:
I developed a 2-d simulation that allows for the training of surgical technologists in the setup of surgical trays. The student is able to pick a tool from a toolbox and drag it onto the surface of the tray and orient it the way it needs to be for the surgery. The grading used a nearest neighbor algorithm using data from a tray set up in the graphical editor by an instructor or subject matter expert. I have available the coordinates of each image as well as the height and width and the orientation of the image. It works okay for that because we had a set of rules guiding the distance the tool can be away from a right answer and still be right.
Problem:
Now, I have to do a similar application for another purpose. The catch is that the grading is more "fuzzy". They don't want grading by the exact location of the user's answer as compared to the right answer. They just want the objects graded based on the approximate location of the object with regard to the other objects on the tray and they should be in the correct order. I have tried to figure this out but have come up short. I can always find that case that would throw the whole thing off. I was wondering if anyone here has any ideas?
Thanks in advance,
Joe
|
|
|
|
|
You said: "based on order".
There needs to be an "ideal order". Once that's established, you can determine what consitutes a "variance" from this "ideal"; how it's measured; etc.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
The definition of a "right" answer seems to be reasonably simple, are they in the right order and do the come within a minimum distance of another instrument.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
In the following problem, which algorithm should be considered?
Having a finite set of variable height brikcs, how can I find the subset that can reach at least a given height, minimizing the total height of the chosen bricks?
In other words, which bricks should I use to reach a given height minimizing cost of material?
Thanks
|
|
|
|
|
|
Yes, I thought about that algorithm for my purpose.
But the two targets are different: in the knapsack problem you must maximize a value minimizing a cost; the value and the cost are two different quantities.
In this case the value and the cost are very related and you have to minimize the value constrained it is more than a given quantity.
Maybe I can apply the same algorithm, but I cannot see how to reduce my problem to the knapsack's one.
|
|
|
|
|
It may be overkill but you can easily write it as an integer linear program:
minimize h.x
st.
h.x >= minheight
for all i: x[i] is boolean
Where h are the heights of the brights, x are boolean decision variables deciding for each brick whether to take it or not, minheight is the minimum height that must be reached, and . is the dot product between two vectors.
With just a little coding effort, you can make solvers like GLPK or Gurobi solve that.
Of course it can be solved with DP, but it will be at least an O(height*#bricks) time algorithm where height is the final height, and realistically you'd have to go a bit higher up to some guessed upper bound.
|
|
|
|
|
correct
thanks for the pointer to GLPK and Gurobi
|
|
|
|
|
Hello !
Can you mathmaticiens, help me ! I'm stuck for weaks to understand this;(least squares conformal mapping)
In the file uvedit_parametrizer.c (in blender or any src code) this part of code :
/* angle based lscm formulation */
ratio = (sina3 == 0.0f) ? 1.0f : sina2 / sina3;
cosine = cosf(a1) * ratio;
sine = sina1 * ratio;
EIG_linear_solver_matrix_add(context, row, 2 * v1->u.id, cosine - 1.0f);
EIG_linear_solver_matrix_add(context, row, 2 * v1->u.id + 1, -sine);
EIG_linear_solver_matrix_add(context, row, 2 * v2->u.id, -cosine);
EIG_linear_solver_matrix_add(context, row, 2 * v2->u.id + 1, sine);
EIG_linear_solver_matrix_add(context, row, 2 * v3->u.id, 1.0);
row++;
EIG_linear_solver_matrix_add(context, row, 2 * v1->u.id, sine);
EIG_linear_solver_matrix_add(context, row, 2 * v1->u.id + 1, cosine - 1.0f);
EIG_linear_solver_matrix_add(context, row, 2 * v2->u.id, -sine);
EIG_linear_solver_matrix_add(context, row, 2 * v2->u.id + 1, -cosine);
EIG_linear_solver_matrix_add(context, row, 2 * v3->u.id + 1, 1.0);
row++;
(sparsematrix) prepares a matrix.
what kind of eqaution is getting solved, Thanks!
|
|
|
|
|
Find optimum rectangular size of the box to pack all the small rectangular boxes
|
|
|
|
|
Hi Andrew and thank you very much for your library !
I have a little question for your concerning the BlobCounter method, what is its principle ?
Thank for advance
Vincent
|
|
|
|
|
You should post your question as a comment to the article it refers to. It's unlikely the author of the article will come here and answer, as there will not be any notification of your question.
selfish adj. Defines someone who does not think of me.
|
|
|
|
|
I would like to share some interesting results of playing with the N-Queens problem solver. The following plots represent distribution of the solutions number depending on the arrangement of a subset of queens. This distribution is built by iterating the possible permutations of such a subset and counting the number of all solutions containing the current permutation (i.e. by solving N-Queens Completion Problem for each permutation).
In this particular case, subset consists of three queens that occupy the first three adjacent columns and only the permutations without overlaps (no one attacks each other) are enumerated. The subset length affects the resolution of the plot but not the general nature of the distribution.
plots_img
plotly_link
|
|
|
|
|
If you want to offer this sort of information then you should write a proper article. The forums are more for technical questions.
|
|
|
|
|
OK! I just thought that amount of information I have at the moment is not enough for a new article
|
|
|
|
|
You can always post it as a Tip if there is not enough for a full article. But either way, it will be more accessible there than in the forums.
|
|
|
|
|
I am having difficulty figuring out how to go about creating a dialog box which, when the user clicks the OK button, if that user hasn't answered all the questions in the dialog, then an error message should appear and reshow the dialog (either with or without the selections made previously).
My original solution was something similar to this:
show dialog box
while (!allAnswered) {
if (OK clicked) {
if all questions have answers then allAnswered=true
else
show error message
show dialog box again
end if
end if
loop
Each of the questions contain a drop-down box with the first choice being empty. So, if the drop-down has the empty string for the result, then I know that it hasn't been answered.
However, I wasn't sure if I was performing the if and while in the correct order because it seemed that it wasn't. Could someone please confirm whether I have the proper algorithm or what I need to do to fix it.
Chris
|
|
|
|
|
I suggest doing the checks within the dialog box so you won't need a loop at all. If it's WinForms then it could look like this:
In the "calling" Form:
private void ShowQuestionsDialog()
{
using (QuestionsForm form = new QuestionsForm())
{
if (form.ShowDialog() == DialogResult.OK)
{
}
else
{
}
}
}
In the "Questions Dialog":
private void OkButton_Click(object sender, EventArgs e)
{
if ()
{
DialogResult = DialogResult.OK;
Close();
}
else
{
MessageBox.Show("Please answer all questions.");
}
}
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
A common method is to show the dialog only once (initial) and perform the checks in the OnOK handler.
If all has been answered, close the dialog. Otherwise, show the error message box, optionally reset the selections and return from the handler which should let the dialog stay visible and active.
A more specific answer requires knowing which GUI framework you are using. But those usually provide some kind of OnOK or OnClicked handler which by default call a function to close the dialog. Just don't call that default function and return from the handler to let the dialog be alive.
|
|
|
|
|
Could someone point me to an algorithm or something that might help me solve this problem:
I have 3 tours going to Disneyland, each of these tours need tickets for the passengers to get into Disneyland. In total I have 60 tickets and they can be distributed in this way: I have 20 tickets to share between Tour1 and Tour2. I have another 20 tickets to share between Tour2 and Tour3. I have another 20 tickets for just Tour3.
Image of ticket allocation to tours[^]
For each person that books a tour, the ticket number is reduced by 1.
I want to maximize the availability that is shown to the user when they are attempting to book any of the 3 tours
With no bookings, the Availability for each tour is:
Tour1: 20
Tour2: 40
Tour3: 40
If we now add bookings for each tour:
Tour1 Bookings: 12
Tour2 Bookings: 10
Tour3 Bookings: 10
The availability when looking at each tour INDIVIDUALLY (aka how many tickets can I book), it should return:
Tour1: 8
Tour2: 18
Tour3: 28
Image[^]
As we increase bookings, availability will be adjusted accordingly. Notice in the next example, when there are an additional 10 bookings for Tour1, Availability for all 3 tours change:
Tour1 Bookings: 18
Tour2 Bookings: 10
Tour3 Bookings: 10
The availability when looking at each tour INDIVIDUALLY (aka how many tickets can I book), it should return:
Tour1: 2
Tour2: 12
Tour3: 22
Image[^]
I'm sure someone has already come up with an algorithm for this... could someone point me in the right direction? Please?
modified 5-Oct-17 10:01am.
|
|
|
|
|
I would do it like this :
Assuming that a Tour has more Information/Content than only the Count :
- you have for each Tour an Array (or better a List) with the availible Tours and one with the booked Tours
- if you book one Tour you move it from the Availible_Tours to the Booked_Tours
- the other way round it you free a Tour
If you only need the Count you can work instead of this only with Integer-Variables.
|
|
|
|
|
You need to go "deeper"; and think "allocation" or "reservation" system.
You need "instances" for each ticket (60); tour (3); and "seats" (20;40;40).
A "booking" links a ticket with a passenger / seat.
Iterating over these "lists" of bookings, seats, tours allows you to know at any time what's what.
Draw a picture; or think of a flight seat reservation you make yourself.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi,
Let's say, I have an XML file that looks like this.
<donors>
<donor>
<donorid>1
<name>abc
<amount>$50
<donor>
....
and I have a table that looks like this:
Relation Name
-------------
Donor
Columns
-------
DonorID - bigint
DonorName - nvarchar(100)
DonationCeiling - float
I want to get all of the donor names and amounts from the xml and compare them against the maximum amount allowed. I want to remove all donors from the xml whose donation has exceed the ceiling.
I can do this.
XmlNamespaceManager nsmanager = new XmlNamespaceManager(reader.NameTable);
nsmanager.AddNamespace("donor", "www.mydomain.com/xmlns/donor");
nsmanager.PushScope();
XmlDocument doc = new XmlDocument();
doc.Load("donors.xml");
//Select and display the value of all the ISBN attributes.
XmlNodeList donorIds;
XmlNodeList donationAmount ;
XmlElement root = doc.DocumentElement;
nodeList = root.SelectNodes("/donors/donorid", nsmanager);
Is there a way to retrieve all xml node values from two different xml nodes using one xml path expression into one data structure. For instance, get all donor Ids an donation amount as a key-value list in one data-structure making a single call to root.SelectNodes
Once the donation ids and donations amounts are retrieved, even if they are retrieved as two separate XmlNodeLists, what is the most efficient way to compare these values to the DonationCeiling values returned from the Donor table.
The select query to the Donor table would look like this:
string sql = "Select DonorID, DonationCeiling from Donor where DonorID in ('" + (why can't we just pass the whole XmlNodeList as one data-structure here, without having to loop-through and build the list of DonorId's from the XMLNodeList + "') ;
recordset.ExecuteSQL(sql) ;
After the sql returns the recordset, is there an efficient way to compare the DonationAmounts in the XmlNodeList to the DonationCeiling amounts returned from the Donor table without having two nested loops.
int donorId = Convert.ToInt32(donorIds[0].InnerText) ;
while (!recordset.EOF) {
for (int i=0; i < donorIds.Count;i++) {
if (Convert.ToInt32(donationAmount[i].InnerText) > recordSet.Fields("donationCeiling").Value (should not have to cast to string and then to an integer - the compiler should automatically determine the type based on the returned value from the database column) {
// remove donor node from xml file
}
}
}
Is there a way to do the above without two loops?
Thanks for the time you might spend trying to figure this out. If you can't, that is ok, I have not figured it out so far. Maybe, there is no other way.
Thanks,
Saad
|
|
|
|