Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Volmarias posted:

E: Nope, this is actually a different problem. This solves the question of "is it possible to take these X conveyor belts, with Y required splits, and fit it into space Z (and if so, how)"
sure, I meant only that the same mechanism (encoding the problem in SAT and handing it off to Yikes or Z3) might be able to be used to solve the problem, too.

Adbot
ADBOT LOVES YOU

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Dijkstracula posted:

sure, I meant only that the same mechanism (encoding the problem in SAT and handing it off to Yikes or Z3) might be able to be used to solve the problem, too.

Ah, ok. I'll take another look, it seemed like this was a way to show that it was possible, not what the optimal arrangement would be.

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


This looks almost like an optimal facility location problem. Might be worth looking to see if you can get something out of that.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Volmarias posted:

Ah, ok. I'll take another look, it seemed like this was a way to show that it was possible, not what the optimal arrangement would be.

In SAT problems often this is one and the same thing: the way to show that the problem is solvable is for the solver to return a model (a map of boolean variables to assigned values) that satisfies the formula. So, technically, there would be one additional step which is to relate that satisfying assignment back to your problem domain, which is the inverse of how you began (by mapping the problem domain into boolean satisfiability)

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

ultrafilter posted:

This looks almost like an optimal facility location problem. Might be worth looking to see if you can get something out of that.

Thanks, it looks a bit more relevant.

Dijkstracula posted:

In SAT problems often this is one and the same thing: the way to show that the problem is solvable is for the solver to return a model (a map of boolean variables to assigned values) that satisfies the formula. So, technically, there would be one additional step which is to relate that satisfying assignment back to your problem domain, which is the inverse of how you began (by mapping the problem domain into boolean satisfiability)

Sorry, I'm not sure I understand what you mean for that one additional step. Do you mean taking the set of satisfying answers and selecting the optimal one by cost etc?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Volmarias posted:

Sorry, I'm not sure I understand what you mean for that one additional step. Do you mean taking the set of satisfying answers and selecting the optimal one by cost etc?
well, no, you start with whatever problem you're trying to solve (as a simple example that we both can speak to, solving a sudoku puzzle) and begin by mapping it down into a boolean satisifiability problem - for instance, you might have a variable indicating "position 1,1 has value 1", "position 1,1 has value 2", and so on and so forth. From there, you have to build up constraints between the variables, such as "position 1,1 has value 1 implies that position 1,1 cannot have value 2,3,..9". Your game would of course have different encodings and constraints. The link I posted earlier shows the bit where the factorio solver builds up those constraints.

From there, the SAT solver will go off and find assignments to your boolean variables that satisfy your constraints. But, that model is only useful to you when you map it back to the original problem description, so there's a reverse process by which you go "ah, variable 72 is true, and variable 72 encoded whether position 5,2 has value 4, so I now know that value of that position on the board". You'd have to do a similar thing, mapping back the SAT encoding to the layout in your game grid or whatever.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
I think the underlying question here is:
How do you map an optimization problem like "What's the best way to place my buildings in this game to maximize X" to a yes/no decision problem like SAT?

So, the thing you do is you take your optimization problem and turn it into a decision subproblem. Instead of asking "how do I maximize X," you ask, "does there exist a placement of buildings such that X>Y" for a given Y.

Then you turn that into SAT, solve it, and the answer will either be "no" or "yes, and here it is"

If no, reduce Y. If yes, increase Y. You're going to do a binary search to find the largest value of Y where the answer is still yes.

Once you get there, you take the mapping that you did to turn that question into SAT and then run it backwards to get your answer in terms of "where do I place buildings?"

At least, that's my theoretical understanding from undergraduate CS. Maybe it works differently in practical terms, or I am just straight wrong.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Dijkstracula posted:

well, no, you start with whatever problem you're trying to solve (as a simple example that we both can speak to, solving a sudoku puzzle) and begin by mapping it down into a boolean satisifiability problem - for instance, you might have a variable indicating "position 1,1 has value 1", "position 1,1 has value 2", and so on and so forth. From there, you have to build up constraints between the variables, such as "position 1,1 has value 1 implies that position 1,1 cannot have value 2,3,..9". Your game would of course have different encodings and constraints. The link I posted earlier shows the bit where the factorio solver builds up those constraints.

From there, the SAT solver will go off and find assignments to your boolean variables that satisfy your constraints. But, that model is only useful to you when you map it back to the original problem description, so there's a reverse process by which you go "ah, variable 72 is true, and variable 72 encoded whether position 5,2 has value 4, so I now know that value of that position on the board". You'd have to do a similar thing, mapping back the SAT encoding to the layout in your game grid or whatever.

Ah, sorry, I suppose I just intuited that I would have to do that step anyway.

For a smaller problem size, say a 2x2 grid, there are multiple valid solutions (for the 6 different ways you can place 1 through 4 irradiator objects, and their combination of other objects also placed (including no object placed!) on the remaining grid cells). Even a 1x2 grid technically has 5 valid answers, although "place two irradiators, in both cells, since the bonus provided by the multiplier object would not be more than placing another irradiator" would be the optimal answer. How do I go from "all of these specific answers in this set satisfy the rules constraints" to ", and this is the most efficient one?" Do I just calculate the effectiveness of each solution and then pick the maximum? Or is there a way to do this more efficiently? For the case of an 8x8 grid, there are going to be an awful lot of valid answers, which is why I was hoping there might be a way to solve this (or approximate the answer) that isn't "try literally every possible combination"

KillHour
Oct 28, 2007


Welcome to one of the biggest unsolved problems in math and computer science - "Is this a global minima or just a local one?"

With enough dimensions, the search space becomes impossibly large to answer that definitely, so the best you can do is figure out a search algorithm that gets you a good, if not necessary completely optimal answer.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Yeah, it depends on what your cost function is - yours sounds like it might be convex, luckily, if I'm understanding what you're thinking of correctly.

In general, optimisation problems are harder than satisfiability problems and may require iterative calls to the SAT solver. It's not uncommon to use a solver to solve a bunch of particular instantiations of a problem and then choose the best out of it, for better or worse. That said, Z3 has the notion of minimizing or maximizing some value based on your formula but I've never used that part of the solver so I can't say how well it would work for you.

The good news is that for lots of real-world boolean satisfiability problems, a good solver's internal search heuristics can do better than "just brute force all possible assignments and see which one(s) inadvertently satisfy the formula", so even if your potential solution space is big you may not suffer too much in terms of performance. (In general, though, it's capital-H-Hard.) (e: if you are interested more specifically in what "solvers in practice do better than brute-forcing" means, I tried to do some effortposts on SAT solver internals on cohost a few years ago that build up to the canonical search algorithm)

Dijkstracula fucked around with this message at 19:35 on Mar 19, 2024

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Thanks. Yes, I figured it was going to be a Hard problem, I just wanted to know specifically what direction to start looking towards. I'll take a look at Z3 and Yikes and see what I can find.

Computer viking
May 30, 2011
Now with less breakage.

I've always been fond of stupid brute force approaches - my bachelor thesis was "a multilevel genetic algorithm for SAT problems". It's the classic GA "try random assignments, keep the best, breed them to new answers, add some noise, repeat", but at the beginning you randomly group variables into huge blocks that you flip together, splitting them whenever things seem to be slowing down.

redleader
Aug 18, 2005

Engage according to operational parameters

Dijkstracula posted:

I tried to do some effortposts on SAT solver internals on cohost a few years ago

yo, these are good as hell! did you only write 5 in total, or are there more that are private?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

redleader posted:

yo, these are good as hell! did you only write 5 in total, or are there more that are private?

Thanks for saying :shobon: I only ended up publishing those as ~engagement~ fell off and I wasn’t sure if anyone was reading them (and my insomnia fixed itself so I wasn’t up half the night anyway) but I’ve been meaning to get back into writing this sort of stuff anyway…

e: if you are interested in more :justpost: s about a more top-down application of SAT in verifying program correctness, shameless plug for these ones

Dijkstracula fucked around with this message at 15:36 on Mar 20, 2024

M_Gargantua
Oct 16, 2006

STOMP'N ON INTO THE POWERLINES

Exciting Lemon
Here is a question from a non-programmer (me) about important high level professional programmer stuff -

The question is about some sort of "Best Practice" or Terminology that I'm probably unaware of, and not implementation specific.

We've got a control system that runs some safety critical stuff, it's worked great over the years, and is pretty well maintained code with frequent updates.

There is a new need to have a standalone simulation for testing and training, generating fake sensor data from its own program & plant model, to feed into the existing software. Currently we have a fork that can run the software on a PC instead, and then the user can manually feed it 1 sensor value at a time directly into memory for testing. This new one would add some sort of API or network hook to talk to the plant model software to create real time sensor data and feedback.

Is there any way to guarantee that all that simulation only hook/API code is outright inactive when you compile for prod? Because its tied to safety cases I want to avoid even the possibility that a bugged input could be off in lala land looking for a value from the plant model while its running on the real hardware, or worse, somehow the simulation only "Ignore Shutdown" logic sim only testing control is somehow entered.

I'm assuming its something to do with the compiler and include files, is there a standardized way to do that without introducing discrepancies between the actual control response of the two branches of code?

KillHour
Oct 28, 2007


Preprocessor directives can be used to include/exclude code from the compiled program, but I also feel like this is one of those "if you have to ask, you probably shouldn't touch it" type situations, because it's going to be up to the developer to use them correctly.

https://cplusplus.com/doc/tutorial/preprocessor/

nielsm
Jun 1, 2009



A modular architecture where the sensor input module can be either a real sensor module that connects to the actual hardware, or a mock sensor module that receives inputs from test cases, and the software is only capable of having one input module installed at a time.
That way you can have a guarantee that there is no mocking code in the real sensor input module, the mocking code can be physically absent from a production deployment, and the rest of the software is ideally not able to tell the difference between whichever input module it's talking to.

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

Agreed that the preprocessor can be used to "comment out" the simulation tester code for production builds.

Another common approach involves dynamic linking, where you have something like a plugin system (in the same sense as in a web browser's plugins - bits of code that are not part of the core system that add extra functionality). The rough idea is that when your processing program starts up, the relevant "give me sensor data" plugin is given to it; in the test environment, that library would be your simulation generator, and in production it would be the thing that actually talks to the plant data. By simply not shipping the simulation generator plugin to production, you know for sure it's not going to interfere.

M_Gargantua posted:

The question is about some sort of "Best Practice" or Terminology that I'm probably unaware of, and not implementation specific.

Broadly I think the piece of terminology that you're looking for is "separation of concerns". Another piece of terminology that might be relevant to "how do I ensure only this particular implementation of the data source is used here and only this other one is used here" is "dependency injection".

M_Gargantua
Oct 16, 2006

STOMP'N ON INTO THE POWERLINES

Exciting Lemon

KillHour posted:

Preprocessor directives

nielsm posted:

mocking code

Dijkstracula posted:

"separation of concerns" [...] "dependency injection".

Much appreciated. I'll be doing a lot of reading on these. I will never ever be touching the code, closest I get is submitting change requests to table values that the programmers use as sources. But this is plenty for me to research so I can better stress to program management the importance and ease of doing this right.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
Worth noting, not only will it be safer to have a modular approach to allow for a fake sensor suite rather than manually poking values, but it will make things both cheaper and easier in the long run. Tests that would traditionally require you directly changing memory values can be replaced by automated test suites, that run some relevant scenarios entirely autonomously, and can directly point out what things appear to have broken in a recent change (or can at least help point you in the right direction). If your project management doesn't want to listen to "this is safer," appealing to money may help instead.

PhantomOfTheCopier
Aug 13, 2008

Pikabooze!
tldr: Prepare to build something new and disconnected. Go read The Atomic Chef first.

M_Gargantua posted:

But this is plenty for me to research so I can better stress to program management the importance and ease of doing this right.
Those are the correct technical concerns but you'll want to go into the conversation stressing the actual goals, the need for some solution, and that the request is to understand the options and tradeoffs. While it's not particularly aggressive, "doing this right" could be interpreted, particularly by engineering, as "the solution has been decided, make it happen or be fired".

Control software... Let us assume the worst scenario: Someone forgets a preprocessor directive and control rod insertion fails, hence meltdown. Or MAX software lets the plane crash. Depending on the safety requirements, it may be useful to start with the worst risk and assess likelihood with respect to the proposed changes. EG "consultants hired for the simulator create a new flag that the control engineers aren't informed about, hence the production system fails"; IE the safety model gets broken because an external factor introduces an unqualified process.

There may be dozens of engineering reasons that prevent the above ideas from being viable options. Of course we'd like modular software, interchangeable libraries for different environments, but plan to go into the conversation listening intently for any concerns. Embedded systems, control systems, may all be specialized to the point where they won't support that (eg having enough memory or storage for the additional object references). EG, ponder the stories you've heard about the computers on the space shuttle.

There's a good chance you'll never touch the control software in this project. There may be very good reasons this should only ever be a simulation. Maybe it can be fed data from real system metrics or reports, but bidirectionality might well be more trouble than it's worth.


ps https://en.m.wikipedia.org/wiki/Knight_Capital_Group#2012_stock_trading_disruption :) Flag-based software goof.

PhantomOfTheCopier fucked around with this message at 13:26 on Mar 23, 2024

JamesieAB
Nov 5, 2005
Not sure if I asked this question before.

Any advice on simple android dev tools that run on android?

All I have at the moment is an android tablet and phone so would like something that either runs on android or over the web like flutterflow. I am finding flutterflow a bit difficult to integrate the main functions of my simple app design and may just need to slog on.

The app is a simple culling tool that needs to integrate folder selection, full screen image presentation, swipe gestures for next/previous image and up/down swipes for keepers/delete.

Any suggestions for other tools or flutterflow examples I should look at would be greatly appreciated.

Boris Galerkin
Dec 17, 2011

I don't understand why I can't harass people online. Seriously, somebody please explain why I shouldn't be allowed to stalk others on social media!
Is the "lib" in eg "libfoo" pronounced like "nib" with an "L" or is it pronounced like the first part of the word "library" (lieb?). I always thought it was pronounced like "lib" but this engineer at work has been calling it lieb and tbh I don't think I've ever talked to anyone about a lib in speech before.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

Boris Galerkin posted:

Is the "lib" in eg "libfoo" pronounced like "nib" with an "L" or is it pronounced like the first part of the word "library" (lieb?). I always thought it was pronounced like "lib" but this engineer at work has been calling it lieb and tbh I don't think I've ever talked to anyone about a lib in speech before.

shor i. the far right hates static linking, but likes collecting binaries.

ToxicFrog
Apr 26, 2008


Boris Galerkin posted:

Is the "lib" in eg "libfoo" pronounced like "nib" with an "L" or is it pronounced like the first part of the word "library" (lieb?). I always thought it was pronounced like "lib" but this engineer at work has been calling it lieb and tbh I don't think I've ever talked to anyone about a lib in speech before.

"lib"-rhymes-with-"nib", "lib" as in the start of "library", and "lieb" are three distinct sounds for me, but to actually answer the question, I and most of the people I work with pronounce "libfoo" with the same start as "library". I do occasionally hear the rhymes-with-nib pronounciation, though.

dupersaurus
Aug 1, 2012

Futurism was an art movement where dudes were all 'CARS ARE COOL AND THE PAST IS FOR CHUMPS. LET'S DRAW SOME CARS.'

Boris Galerkin posted:

Is the "lib" in eg "libfoo" pronounced like "nib" with an "L" or is it pronounced like the first part of the word "library" (lieb?). I always thought it was pronounced like "lib" but this engineer at work has been calling it lieb and tbh I don't think I've ever talked to anyone about a lib in speech before.

gib

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

ToxicFrog posted:

"lib"-rhymes-with-"nib", "lib" as in the start of "library", and "lieb" are three distinct sounds for me, but to actually answer the question, I and most of the people I work with pronounce "libfoo" with the same start as "library". I do occasionally hear the rhymes-with-nib pronounciation, though.

how the heck do you say library

Tempora Mutantur
Feb 22, 2005

leebRARie

Polio Vax Scene
Apr 5, 2009



triggering my libs with dangerous invocations

mystes
May 31, 2006

mein lib

dirby
Sep 21, 2004


Helping goons with math

Jabor posted:

how the heck do you say library
I think it's just that ToxicFrog knows that if you see a spelling like "lieb" then it could be German and hence pronounced with an "ee" or an "ee-uh" sort of vowel sound.

But Boris Galerkin was just using "lieb" to suggest (the English pronunciation of) "lie"+"b", so that the vowel matches the one every English speaker has in "library".

Computer viking
May 30, 2011
Now with less breakage.

dirby posted:

I think it's just that ToxicFrog knows that if you see a spelling like "lieb" then it could be German and hence pronounced with an "ee" or an "ee-uh" sort of vowel sound.

But Boris Galerkin was just using "lieb" to suggest (the English pronunciation of) "lie"+"b", so that the vowel matches the one every English speaker has in "library".

On the same note, I'm from the lib-like-nib camp, and I'm 90% sure it's because that's the only sensible way to pronounce it in Norwegian.

KillHour
Oct 28, 2007


Computer viking posted:

On the same note, I'm from the lib-like-nib camp, and I'm 90% sure it's because that's the only sensible way to pronounce it in Norwegian.

I don't speak Norwegian, but lib absolutely rhymes with nib.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.
/ˈlaɪ.brer.i/

/lɪˈb/

mystes
May 31, 2006

For linux at least, I don't think I've ever heard anyone pronounce it any other way than rhyming with nib

If you go on youtube and search for libc, all the videos I opened before I got bored pronounced it like nib

I wouldn't be totally surprised if there are places or groups where people pronounce it differently though

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

I pronounce “lib” in the same way as “char”

VagueRant
May 24, 2012
Trying to write a Cron schedule expression that triggers on the last Sunday of March (at 00:50).

If I do:
50 00 25-31 3 SUN
it apparently treats the date range as an OR and therefore covers EVERY Sunday in March.

The pre-existing system this plugs into will only take a raw cron expression, I can't do anything fancy and dynamic that you could do in a terminal. Am I right in saying this is impossible?

ShoulderDaemon
Oct 9, 2003
support goon fund
Taco Defender

VagueRant posted:

Trying to write a Cron schedule expression that triggers on the last Sunday of March (at 00:50).

If I do:
50 00 25-31 3 SUN
it apparently treats the date range as an OR and therefore covers EVERY Sunday in March.

The pre-existing system this plugs into will only take a raw cron expression, I can't do anything fancy and dynamic that you could do in a terminal. Am I right in saying this is impossible?

This is the stupidest aspect of cron.

Per the manpage:
code:
Note: The day of a command's execution can be specified by two fields
— day of month, and day of week. If both fields are restricted (i.e.,
aren't *), the command will be run when either field matches the current
time. For example, “30 4 1,15 * 5” would cause a command to be run at
4:30 am on the 1st and 15th of each month, plus every Friday. One can,
however, achieve the desired result by adding a test to the command
(see the last example in EXAMPLE CRON FILE below).

EXAMPLE CRON FILE

#Execute early the next morning following the first
#Thursday of each month
57 2 * * 5 case $(date +d) in 0[2-8]) echo "After 1st Thursday"; esac
I have no idea why it works that way instead of being a logical and like every other field in a crontab. Everyone gets caught by this, it's never what people expect or want.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
The dumb libiberty name relies on "lib" being the first syllable of "liberty" and I've never heard it pronounced any other way.

Adbot
ADBOT LOVES YOU

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

leper khan posted:

shor i. the far right hates static linking, but likes collecting binaries.

Polio Vax Scene posted:

triggering my libs with dangerous invocations

I can see how the Nazis might make this confusing when it sounds like they're shouting "mein libn!"

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply